The Dink Network

Code in hit proc

May 13th 2009, 11:43 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Seems that code inside a monster's hit procedure is run before hitpoints are deducted from the monster. Is there a way to run code after the hitpoints are updated?
May 13th 2009, 11:59 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Nevermind, wait(30); seemed to do the trick. It's still a bit unreliable, though... And what's the logic in that 30? It didn't work if the wait was shorter than that.
May 13th 2009, 12:08 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Maybe under 30 is too short time?
May 13th 2009, 12:11 PM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Seems so, but why? Wait(1); is usually enough to let other scripts do their stuff first before continuing.
May 13th 2009, 12:18 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Actually, I don't think wait(1); is usually enough.
May 13th 2009, 12:29 PM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
It should be. Taken from DinkC Reference:

"...So any wait(), even a wait(1), makes a script "yield the floor" to other active scripts to allow them time to finish or at least get to their own wait() points before this script is resumed."

So wait(); isn't just a delay, it pauses the script and lets other scripts run their stuff. Wait(1); usually solves quite a few problems with script execution, for example, in cutscenes with screenchanges and screen base scripts.

I can't figure out why wait(30); works in this case, and wait(1); doesn't. Basically, is wait(4); the same as four consecutive wait(1)s or not?
May 13th 2009, 01:05 PM
custom_skull.gif
Skull
Peasant He/Him Finland bloop
A Disembodied Sod 
Sorry, I'm pretty bad in DinkC. I can mae a good D-Mod. But I usually make them with pretty standard scripts.
May 13th 2009, 01:28 PM
spike.gif
Here's how I would imagine it: Wait(4) pauses the script for 4 thousands of a second and then gets back to it. Four wait(1)s pauses the script for a thousandth, gets back to it, pauses the script for a thousandth, gets back to it, pauses the script for a thousandth, gets back to it, pauses the script for a thousandth, gets back to it. Having lots of waits might show in the game's performance, similar to how loops with a very short amount of wait can slow the game down considerably (on a crappy machine, like my laptop).

The problem might be with some kind of internal timer, like with the shadow brain. If you kill the sprite the shadow is attached to, it takes a while before the shadow dies.
May 13th 2009, 07:25 PM
fairy.gif
Someone
Peasant He/Him Australia
 
I don't believe there are any internal timers like that.

Don't use wait(30). Use two wait(1)s. If that is not reliable, use three. (But I think 2 will do.)

4 wait(1)s is not the same as wait(4).

This is what wait does:
Do all other tasks in the que
IF the time is up, then return, otherwise wait until it is

You should be able to see from that that wait(0) could be used instead of wait(1).. You want to use wait to allow the other tasks to be executed, not so much to "wait".

I've got stuff very similar to what you want to do in my tutorial.
May 14th 2009, 05:26 AM
slayer.gif
MadStalker
Peasant He/Him Finland
tag line 
Yeah, I thought so, but the 30 instead of 1 seemed a bit strange. Wait(1) (and wait(0)) had always worked before. Maybe I'll try to use two wait(1)s, thanks.