| 08-10-2009, 12:13 PM | #1 |
Was wondering if anyone had a function that worked like Polled Wait except wasn't horrible coded? |
| 08-10-2009, 02:45 PM | #2 |
Use a timer with TimerUtils. It's a bit tricky (you have to save all your data into either structs or hastable, then attach the struct/parent-/childkey to the timer), but it's not horribly coded. -------- Edit -------- Maybe an example would help. JASS:globals hashtable MyHash endglobals function KillCaster takes nothing returns nothing call KillUnit( LoadSavedHandle( MyHash, 0, GetTimerData(GetExpiredTimer()) ) ) endfunction function Actions takes nothing returns nothing local timer t = NewTimer() local unit u = GetTriggerUnit() //Assuming this is a spell call SaveUnitHandle( MyHash, 0, GetHandleId( u ), u ) call SetTimerData( t, GetHandleId( u ) ) call TimerStart( t, 10., false, function KillCaster ) endfunction In this spell (which doesn't have a initializer, thus can't be cast) the caster would die after 10 seconds. Doesn't make much sence but it's easier to understand this way. |
| 08-10-2009, 02:52 PM | #3 |
Thank you for replying. I just want to point out that i'm looking for a replacement to PolledWait. I understand the NewTimer method, but that would require creating two functions for everything, even simple things such as spells that deal damage to the unit after 2 seconds. I also have a question about this line: call SetTimerData( t, GetHandleId( u ) ) What's the point of it? Couldn't you just do (in the first function) call SaveUnitHandle( MyHash, GetHandleId( t ), 0 , u ) Then in the timer function: local timer t = GetExpiredTimer() call KillUnit( LoadSavedHandle( MyHash, GetHandleId(t), 0 ) ) ) |
| 08-10-2009, 06:26 PM | #4 |
Well, if you're looking for a (not entirely, but close to) bugfree way to do stuff, use timers. If you don't, well, keep using polledwait or triggersleepaction (I don't recommend any of them). Anyway I did that snippet in like 2 minutes, so yes you may do it your way (silly me) |
| 08-10-2009, 06:58 PM | #5 | |
Quote:
|
| 08-10-2009, 08:08 PM | #6 |
Alright I'll trust you Rising_Dusk, but I do have a question that. What's the GetTimerData function for? Btw Rising_Dusk when playing AotZ as the samurai, I used his ult, the one where he lunges forward and he infinitely was paused (even after death I was still paused). I'm not exactly sure the cause of it, but a similar thing has happened to a hero spell in my map. Did you ever manage to fix that bug or find it's source? |
| 08-10-2009, 08:38 PM | #7 | ||
Quote:
Quote:
|
| 08-11-2009, 03:07 PM | #8 | |
Quote:
How did you fix it? I'm having the same problem with my hero. |
| 08-16-2009, 12:27 AM | #9 |
Bump for answer? |
