Stop Global counting after 1 OnHit Event

Post » Wed May 08, 2013 4:36 am

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.

User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Wed May 08, 2013 7:15 am

you could just add a test on your RootHit value when entering the hit event

if RootHit.GetValue() ==4

return

if you do that it could be wise to store the value in a tmp var so you will not have to request the value twice

User avatar
gemma king
 
Posts: 3523
Joined: Fri Feb 09, 2007 12:11 pm

Post » Wed May 08, 2013 2:39 am

What would this do? And where would I put it in the existing scripts? I am trying to get a complete understanding of what the script is doing, these scripts are a mixed bag of Bethesda's own and my own edits.

User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Wed May 08, 2013 7:21 am

You want to know if something has been hit already--that's a yes/no, true/false condition--because depending on whether or not it has already been hit, it should react to being hit in two different ways. That suggests using either a boolean variable or using states.

User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Wed May 08, 2013 4:11 am

Try
Spoiler
and
Spoiler
?

These are both extending ObjectReference? In the future, please post the whole script and in code tags? Makes it a lot easier to digest/tinker with/try to compile a variant before answering.
User avatar
Noraima Vega
 
Posts: 3467
Joined: Wed Jun 06, 2007 7:28 am


Return to V - Skyrim