|
haseldow Newbie
Joined: 21 Sep 2002 Posts: 4
|
Posted: Sun Sep 22, 2002 5:34 pm
Ummm...this should be right? |
Anyone care to help me debug this one?
Trigger name:
^Haseldow ~[party~]: hp: (%d) ~((%d)~) sp: (%d) ~((%d)~)$
Trigger value:
#MATH addhp %1-@curhp
#MATH addsp %3-@cursp
#VA curhp %1
#VA maxhp %2
#VA cursp %3
#VA maxsp %4
#IF (@addsp>245) {
#MATH temp %time( hh)*3600+%time( nn)*60+%time( ss)-@tickstamp
#MATH tickstamp %time( hh)*3600+%time( nn)*60+%time( ss)
#EC Hpr: @addhp Spr: @addsp Tick: <@temp>sec
#TZ
} {#EC Hpr: @addhp Spr: @addsp}
Result:
Haseldow [party]: hp: 1502 (1250) sp: 1554 (2076)
Hpr: 0 Spr: 259 Tick: 68371sec
Where the hell did that 68371sec come from? Should be more like 35sec. After a second or so @temp variable does get the right value (something near 35), but where does the lag come from?
Some explanations about the trig:
We have a random regeneration interval in our MUD so this is the best way I can think of to make a good tick timer.
Basically you calculate the chage of hitpoints and spellpoints (regenerations).
Then you set your hitpoints, spellpoints, hitpoint maximum and spellpoint maximum into the right variables.
If spelpoint regeneration is enough (more than 245sp) then it is tick. Therefor the time that has been passed since last tick will be calculated by subtracting last tick timestamp from current timestamp. Then you set the current timestamp into the tickstamp variable which will be used when the next tick comes.
When you tick you also reset the builtin ticktimer and echo hitpoint and spellpoint regeneration and also the amount of time that has been passed since last tick.
If it was not a tick then you just echo the chage of hp and sp.
But something has gone wrong, anyone know what?
Haseldow |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Sep 22, 2002 10:57 pm |
It came from the bold command.
#IF (@addsp>245) {
#MATH temp %time( hh)*3600+%time( nn)*60+%time( ss)-@tickstamp
#MATH tickstamp %time( hh)*3600+%time( nn)*60+%time( ss)
#EC Hpr: @addhp Spr: @addsp Tick: <@temp>sec
#TZ
}
The first time this fires, @tickstamp doesn't exist so you'll get whatever the time converts to. After that it should be okay until you log off. The next time you log on, @tickstamp will either be it's default value (if it has one) or the value it had when you ended the previous session. In either case, the first time you use it you'll get unusual results.
LightBulb
Senior Member |
|
|
|
haseldow Newbie
Joined: 21 Sep 2002 Posts: 4
|
Posted: Mon Sep 23, 2002 7:50 pm |
Actually it should have worked on the second tick, but it didn't.
Funny thing was that when I moved
#MATH temp %time( hh)*3600+%time( nn)*60+%time( ss)-@tickstamp
to the very beginning of the trig it started working OK.
Go figure
-Haseldow |
|
|
|
|
|