Jump to content

[Solved] SetGlobalTimer


Kish

Recommended Posts

CHAIN IF WEIGHT #0 ~Global("KishJanMageStronghold","GLOBAL",1)
InParty("Jan")
!Dead("Jan")
Global("KishGettingApprentices","GLOBAL",2)~ THEN MGTEOS01 IntroducesApprenticesToJan
~(Text elided.)~
== JANJ ~(Text elided.)~
== MGTEOS01 ~(Text elided.)~
= ~(Text elided.)~
= ~(Text elided.)~
== JANJ ~(Text elided.)~
== MGTEOS01 ~(Text elided.)~
== MGAPPR02 ~(Text elided.)~
== MGTEOS01 ~(Text elided.)~
== MGAPPR01 ~(Text elided.)~
== MGTEOS01 ~(Text elided.)~
== MGAPPR03 ~(Text elided.)~
== MGTEOS01 ~(Text elided.)~
== JANJ ~(Text elided.)~
== JANJ IF ~GlobalLT("Chapter","GLOBAL",6)~ THEN ~(Text elided.)~
== MGTEOS01 IF ~GlobalLT("Chapter","GLOBAL",6)~ THEN ~(Text elided.)~ DO ~SetGlobalTimer("KishJanSpeaksToApprentices","GLOBAL",30)
SetGlobal("KishGettingApprentices","GLOBAL",3)
ForceSpell(Myself,DRYAD_TELEPORT)~
== MGTEOS01 IF ~GlobalGT("Chapter","GLOBAL",5)~ THEN ~(Text elided.)~ DO ~SetGlobalTimer("KishJanSpeaksToApprentices","GLOBAL",30)
SetGlobal("KishGettingApprentices","GLOBAL",3)
ForceSpell(Myself,DRYAD_TELEPORT)~ EXIT

 

is setting the global timer KishJanSpeaksToApprentices to...4262965, not 30.

 

I have no clue. Does anyone else? (No, there's nothing else in the code that should be touching it at all.)

Link to comment

For your first question, the answer is "entirely too long." By my understanding of the conversion it should be over fifty in-game days, but if it's more than a few seconds it's a big problem, and as long as I've tried sitting there and staring at it, it doesn't run down (or get significantly closer to doing so). Everywhere else in my code it certainly seems to be the duration in seconds; I even set a different timer to 30 elsewhere (and it runs down within thirty seconds, as intended).

 

For your second, I'm not using the Enhanced Edition, if that's what you mean.

Link to comment

If you want it to be 30 seconds, you should be using RealSetGlobalTimer instead of SetGlobalTimer. SetGlobalTimer calculates in-game time and, in my experience, never does what you think it's going to do.

Link to comment

Timers in BG2 aren't treated as counters. Instead SetGlobalTimer() stores the current game time plus your specified delay into the timer variable (in your case "KishJanSpeaksToApprentices") and GlobalTimerExpired() checks whether the current game time is less or greater than the stored time in your variable. That's why the 'odd' value 4262965 is probably correct. You can find a more in-depth explanation of timers here.

Link to comment

RealSetGlobalTimer produces the opposite problem: instead of never firing off at all, the timer fires off instantly no matter what I set it to.

 

Thanks for the explanation of why the number's so high, argent77. Unfortunately, for whatever reason, it's definitely not going off after 30 seconds.

Link to comment

Real timers are only good for pacing romance tracks. Even then they're at best half-reliable.

 

For anything else it's safer to use normal timers, because they don't tick during the dialog mode and such.

 

As for why it doesn't expire in 30 seconds... well, are you certain other triggers in that block return all true?

Link to comment

I'm not sure what I wound up actually changing with all the tinkering I was doing--I might have wound up back at what I started with, with shorter timers--but it seems to be working now, in any event.

 

Thanks, everyone.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...