| 08-08-2007, 05:34 PM | #1 |
I'm having some problem with the "Unit takes damage" and timers. This is my current test code: JASS:function AA takes nothing returns nothing local unit u = udg_u local unit v = udg_v set udg_u = null set udg_v = null call SetUnitLifePercentBJ(v, 100 ) call TriggerSleepAction(0.1) call KillUnit(u) call RemoveUnit(u) set u = null set v = null endfunction function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing local timer t = CreateTimer() set udg_v = GetTriggerUnit() set udg_u = CreateUnitAtLoc(Player(0), 'h000', GetUnitLoc(udg_v), AngleBetweenPoints(GetUnitLoc(udg_v), GetUnitLoc(GetEventDamageSource()))) call TimerStart(t, 0.00, false, function AA) endfunction //=========================================================================== function InitTrig_Untitled_Trigger_002 takes nothing returns nothing set gg_trg_Untitled_Trigger_002 = CreateTrigger( ) call TriggerRegisterUnitEvent( gg_trg_Untitled_Trigger_002, gg_unit_hfoo_0000, EVENT_UNIT_DAMAGED ) call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions ) endfunction For some reason it doesnt remove the "u" unit. (an dummy effect) If I take away the TriggerSleepAction in the "AA" function, it works. However, if the unit is damaged too often too fast, it'll leave 1 "u" unit left for some reason. I've also tried commenting out the "set udg_u/v = null" parts, it didn't matter. I've also tried destroying the leaking timer, didn't make any difference. Anyone knows why this is occuring and how I can fix it? |
| 08-08-2007, 05:45 PM | #2 |
I'm not sure, but I think in GUI triggers their variables screw up if there's a wait, and since you're setting yours to a udg_variable it doesn't work. Again, I'm not sure. |
| 08-08-2007, 05:52 PM | #3 |
According to this there shouldn't be a timer wait: http://www.wc3campaigns.net/showthread.php?t=95822 And I'm storing the globals into the locals as you can see. |
| 08-08-2007, 07:00 PM | #4 |
You can't call TriggerSleepAction inside a timer callback, that's why the code doesn't run when it's not commented out. How about creating the effect in the main function and destroying it there? (with the 0.1 wait). You won't need to set the global variable then. On a different note: what exactly are you testing? Maybe I could give you a straight answer |
| 08-08-2007, 07:51 PM | #5 | |
Quote:
Ah thanks, I should've remembered that one. |
