Jump to content

[Solved] SetGlobalTimer


Kish

Recommended Posts

Posted

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.)

Posted

Stupid question: How long does it take to run out? Because the number is not the duration in seconds - I think? Which game version are you on?

Posted

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.

Posted

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.

Posted

Of course - what Rhaella said.

Now I remember, that SetGlobalTimer only works as intended for timers of ONE_DAY etc., but can do strange things for values that are meant to be seconds. Or so.

Posted

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.

Posted

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.

Posted

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?

Posted

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.

Archived

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

×
×
  • Create New...