| 12-07-2006, 03:53 AM | #1 |
Why does nothing after the PolledWait work in this function? (If I comment it out then the rest does work.) JASS:function TelewhackFunction takes nothing returns nothing local unit m = GetTriggerCollisionMissile() local unit victim = GetAttachedUnit(m,"telewhackee") local unit whacker local real r local effect e if (GetTriggerUnit() == victim) then set whacker = GetAttachedUnit(m,"telewhacker") set udg_p = GetUnitLoc(victim) set udg_p2 = GetUnitLoc(whacker) set r = DistanceBetweenPoints(udg_p, udg_p2) set r = r/512 //kill the missile call CleanAttachedVars(m) call CollisionMissile_Destroy(m) //stun effect call PauseUnit(victim, true) set e = AddSpecialEffectTargetUnitBJ( "overhead", victim, "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl" ) call PolledWait( 2.0 ) call DisplayTextToPlayer(Player(0), 0, 0, "Made it") call DisplayTextToPlayer(Player(0), 0, 0, GetUnitName(victim)) call DestroyEffect( e ) call PauseUnit(victim, false) endif set m = null set victim = null set whacker = null set e = null endfunction //=========================================================================== function InitTrig_Telewhack_Functions takes nothing returns nothing endfunction This is called from the OnImpact event for a Caster System collision missile if that makes a difference. |
| 12-07-2006, 04:04 AM | #2 |
If it's a timer callback, any TriggerSleepAction() variant will crash the thread. My recommendation: Don't use any TriggerSleepAction() variant. |
| 12-07-2006, 04:07 AM | #3 |
Yup. Timer's can't use waits. It will halt the function completely. There is a workaround though. You can use a seperate trigger and make a call to it inside the timer callback. You can have waits inside the other trigger because it's not part of the timer callback function. |
| 12-07-2006, 04:52 AM | #4 |
Oh and I suppose the OnImpact thing is in a timer callback as you call it checking for collisions periodically. I didn't think it would actually matter what the function was called from. Crazy. Well thanks guys, I figured if I used a timer to achieve the wait it would have worked but I thought it was dumb to have to re-attach the victim/attacker units to a new timer. If I set them to global variables and then call another trigger which sets them to local variables and then does the wait that would be more convoluted but more efficient then accessing the gamecache with attached vars right? |
| 12-07-2006, 01:36 PM | #5 |
Yes, also even if it worked the readme says you shouldn't have waits on collision events. Because that would pretty much cause some huge issues |
| 12-08-2006, 09:56 PM | #6 |
Oh I guess I missed that part of the readme. |
| 12-08-2006, 10:26 PM | #7 |
Well if you haven't figured a solution out for yourself, heres one (the same problem happened to me). Just attach all of the values you need to another timer that is created, and delete the old timer, this way the timer will act as a wait but with 100% precision. I hate both of the functions TriggerSleepAction and PolledWait because they are both not as accurate as timers. |
