Setting a variable in a Quest script.

Post » Fri Feb 18, 2011 10:11 pm

Alright, so I have quite a bit to explain so please bear with me.

Basically I am working on a quest (well technically a series of quest). Currently my Journal Updates in a split second after any conditions have been met ... but what I want is there to be a delay of a few seconds before the Journal Update ... because it just feels more natural.

I have been able to achieve this by adding in a "delay" quest attached to the sample timer script available on the CS http://cs.elderscrolls.com/constwiki/index.php/Scripting_Tutorial:_Creating_a_Simple_Timer (the second last one).

Here is what I am using:

scn Xdelayscriptfloat timerfloat fQuestDelayTimeshort doOncebegin gamemode     set fQuestDelayTime to 0.001     if ( doOnce )         ; the == operator isn't necessary when checking boolean values....         return            ; ... the above expression is equivalent to (doOnce != 0)     elseif( timer > 5 )             set doOnce to 1         SetStage MyQuestName 30     else         set timer to timer + getSecondsPassed     endifend



The problem however is that I will need to make several of these delay quests ... a seperate one for each delay I want ... and thats just wasteful.

So ... my question is ... is there a better way to delay the Quest Updates after the conditions have been met?

For those wondering what the topic name is about ... I was thinking that maybe it is possible to make "MyQuestName" and the "stage" in the above script a variable that I could modify from the response code of the previous quest. (is that even possible}
User avatar
Erin S
 
Posts: 3416
Joined: Sat Jul 29, 2006 2:06 pm

Post » Sat Feb 19, 2011 8:01 am

There are a few ways to do it. I'll give you two, you can use either or a combination of both, depending on what is triggering your current timer scripts to run.

1. If the new stage should be set a few seconds after activating, picking up, selling, dropping or equipping a unique object:
Then add this to the object's script, instead of a separate quest script. You would run this script in the appropriate block type (onDrop, onEquip, onAdd, etc...) possibly with the "Player" parameter to further limit the code (onAdd Player). You would also add a condition so that the code would only run at the right time. I.e., "If GetStage MyQuest == 20", then run this timer stuff, then setstage to 30.

2. You can use short variables as flags in your main quest script to keep all your timers in one place. So whatever event you now have triggering the timer quest, have that event instead "set MyQuest.Stage30Flag to 1". In your main quest script, have a short variable called Stage30Flag. And then add the timer code to the main quest script, with a condition that Stage30Flag must equal 1. Make sure you set it back to 0 after the timer is run (perhaps in the stage 30 results script, or just within the main quest script itself), or it will continue running all the time.

I tend to go for option #2 in similar cases, as I like having all the guts of a quest centralized as much as is reasonable for my own sanity. Option #1 will usually be a bit more efficient, however.

Hope this is helpful!
User avatar
Elle H
 
Posts: 3407
Joined: Sun Aug 06, 2006 3:15 am


Return to IV - Oblivion