I've scripted a couple of tree roots, like the one in one of the quests in the game that requires Nettlebane dagger, and a couple of beehives to Mod(1) on a global counter when they are hit by any weapon. The idea being the player has to shoot down 2 beehives and "hit" 2 tree roots making the global counter reach 4 and progress the quest. Everything works fine, animations work and global counter works but I discovered that the player after hitting any of the 4 objects once can go back and hit the same object again and the global counter will still Mod(1). So effectively the player can hit 1 tree root or shoot 1 beehive and continually hit/shoot the same object and the quest will still progress. I need that when each of the 4 objects, 2 roots and 2 beehives, are hit they don't add to the global counter if hit/shot again. Here are the scripts I am using thus far the first is the script for the roots.
import debug
import utility
Quest Property MyQuest Auto
Int Property PreReqStage Auto
Int Property StageToSet Auto
GlobalVariable Property RootHit Auto
ObjectReference Property Sprigg Auto
ObjectReference Property Obj1 Auto
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
Actor actorRef = akAggressor as Actor
if(actorRef == game.getPlayer())
;player hit the object
RootHit.Mod(1)
playAnimation("Open")
Obj1.Enable()
if RootHit.GetValue() == 4
MyQuest.SetStage(StageToSet)
Sprigg.Enable()
if (getLinkedRef() != None)
getLinkedRef().disableNoWait()
endif
endif
wait(1.0)
endif
endEvent
Next is the beehive script.
Quest Property MyQuest Auto
Int Property PreReqStage Auto
Int Property StageToSet Auto
GlobalVariable Property RootHit Auto
ObjectReference Property Sprigg Auto
ObjectReference Property Obj1 Auto
Event OnLoad()
; Debug.Trace("This object is loaded, playing animations should work now")
self.SetMotionType(Motion_Keyframed, true)
endEvent
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
; Debug.Trace("I just got hit by something")
self.SetMotionType(Motion_Dynamic, true)
RootHit.Mod(1)
Obj1.Enable()
if RootHit.GetValue() == 4
MyQuest.SetStage(StageToSet)
Sprigg.Enable()
Endif
endEvent
I'm sure there is something simple I can add to these scripts to stop the excess count. Thanks for any help.