Hi, I have a problem with a script for my quest mod. I have a script that sometimes does not work. Here it is:
Hi, I have a problem with a script for my quest mod. I have a script that sometimes does not work. Here it is:
I'm not sure what's causing your script to fail. The OnUpdate should only not be triggered if there is an UnregsiterForUpdate. Regardless, you don't want to be polling like that. Calling for the script to run once every second is very performance inefficient. You should use events to detect when your reference aliases die. For example:
Scriptname _test_testscript extends ReferenceAlias
Event OnDeath(Actor akKiller)
_test_testquest kQuest = GetOwningQuest() as _test_testquest ;_test_testquest is the script on the quest with these referencealiases
kQuest.incrementDeadActor()
endEvent
Scriptname _test_testquest extends Quest
Quest Property quest1 Auto
int iDeadCount
Function incrementDeadActor()
iDeadCount += 1
if iDeadCount == 3
quest1.SetStage(20)
endIf
endFunction
Also as a side note, you can use "and" in your if statements... for example:
Actor Bob
Actor Joe
Actor Sue
Function SomeFunction()
if Bob.IsDead() && Joe.IsDead() && Sue.IsDead()
;do something
else
;do something else
endIf
endFunction
Thanks for the reply!
I suspected that it would be performance heavy, yes, but the battle with the NPCs is going on at the same time, so I don't know which one will die last. That is why I thought it would prove difficult To have an OnDeath event for each of the six actors.
I also do not understand everything in your example scripts (I am fairly new to papyrus and programming). Is the IncrementDeadActor() function global? How did you make it global? How does the += thing in front of the iDeadCount work. Other than these things, I see how the script would work, if I apply it to the actors.
I understand if you don't want to explain all of those things. If so, thanks for the help anyway. I'm sure I'll figure it out.
incrementDeadActor is a function that I made in the "quest" script. It is not global. You must call it on the script that it is in. So lets say you have a quest called "MyQuest01". MyQuest01 will have the "_test_testquest" script attached to it. MyQuest01 also has three reference aliases. Each reference alias in MyQuest01 has the "_test_testscript" attached to it. Whenever one of those reference alias dies, the incrementDeadActor function is called to run from the _test_testquest script (we find the quest/script to talk to with the GetOwningQuest() function).
iDeadCount += 1 is the same as iDeadCount = iDeadCount + 1. It just increases the variable by one. Once our counter hits 3, we change the quest stage.
Edit: Also, I edited the script above as there was an error
Ohh, now I see. Thanks for your help, it's going to make thing a lot easier.