Understanding Timers

There are two clocks in the IE:
  1. Real clock that tracks real time the player has spent with the game running (hereafter referred to as CREAL)
  2. In-game clock that tracks in-game time - (i.e. time displayed in lower left corner of the game screen) (hereafter referred to as CINGAME)

Time is tracked in ticks; by default there are 15 in a second. In BG2 there are 100 ticks in a combat round. A BG round lasts 6, IWD 7 and PST 5 seconds.

When the game starts, both clocks start from 0. When resting, CINGAME is incremented by the time spent resting (usually 8 hours). CREAL is incremented by a the few seconds while the rest movie is played. This puts CINGAME at a higher value than CREAL.

Timers relating to both clocks can be set through scripting:
SetGlobalTimer("TINGAME","GLOBAL",3600) - TINGAME will expire after half a day of in-game time
RealSetGlobalTimer("TREAL","GLOBAL",3600) - TREAL will expire after 3600 seconds of real time

When this is done, the game takes the values the relevant clocks, adds the specified number (e.g. 3600) and stores the result in a global variable (TINGAME or TREAL), e.g.
It should be noticed that TINGAME is higher than TREAL.

Timers can be checked by two commands in scripting:

To detemine whether timers have expired, the engine subtracts the current clock value from the time value. A negative result means the timer has expired (this is why a timer set 1 will expire instantly). As an example, using GlobalTimerExpired("TREAL","GLOBAL") the engine will subtract 2,399,458 (the value of TREAL) from 7,195,874 (the value of CINGAME) and return a negative number - hence an expired timer.