| 07-02-2009, 11:52 PM | #1 |
This event is too bugged for me to rely on. i.e. When multiple units enter at the same time, the actions don't always fully run/ or run at all. |
| 07-02-2009, 11:57 PM | #2 |
Try running what you're trying to do in the filter func. It runs immediately each time a unit enters a region. The conditions and actions run after a 0 sec delay. Blame Blizzard. |
| 07-03-2009, 03:01 AM | #3 |
Something is very wierd. Moving it didn't seem to fix the problem What the code does: I have checkpoints in my map Unit enters Unit gets replaced with another Its CHECK value is passed (This is where it bugs) The CHECK value somehow gets to default on its own. JASS:scope Checkpoint initializer Init globals private constant real DELAY = 1. private constant integer MAX_CHECKPOINTS = 8 endglobals //====================================================== globals private integer array CHECKPOINTS[MAX_PLAYERS] public rect array AREA[MAX_CHECKPOINTS] endglobals private struct Check unit a integer c timer t private static method callback takes nothing returns nothing local Check dat = GetTimerData( GetExpiredTimer() ) //call BJDebugMsg(I2S(CHECK[dat.a]) + " == " + I2S(dat.c)) if CHECK[dat.a] == dat.c then call ReleaseTimer( dat.t ) call dat.destroy() return endif set CHECK[dat.a] = CHECK[dat.a] + 1 endmethod static method addLater takes unit a, integer c returns Check local Check dat = Check.allocate() set dat.a = a set dat.c = c set dat.t = NewTimer() call SetTimerData( dat.t, dat ) call TimerStart( dat.t, DELAY, true, function Check.callback ) return dat endmethod endstruct //====================================================== private function Actions takes unit a returns nothing local unit b local player p = GetOwningPlayer( a ) local integer c = CHECK[a] + 1 local real x = GetRectCenterX( AREA[c] ) local real y = GetRectCenterY( AREA[c] ) //if IsPointInRegion( GetTriggeringRegion(), x, y ) then if c >= 6 then set c = GetPlayerId( p ) set CHECKPOINTS[c] = CHECKPOINTS[c] + 1 call BoardUpdateText( 2, c + 1, " " + I2S( CHECKPOINTS[c] ) ) set c = 0 set CHECK[a] = c set x = GetRectCenterX( AREA[c] ) set y = GetRectCenterY( AREA[c] ) endif call RemoveUnit( a ) set b = CreateUnitEx( p, x, y ) call Check.addLater( b, c ) if p == GetLocalPlayer() then call ClearSelection() call SelectUnit( b, true ) call PanCameraToTimed( x, y, 0. ) endif //endif set b = null endfunction //====================================================== private function IHateJass takes nothing returns boolean if CHECK[GetFilterUnit()] > -1 then call BJDebugMsg("B " +I2S(CHECK[GetFilterUnit()])) //This shows once call Actions( GetFilterUnit() ) call BJDebugMsg("C " +I2S(CHECK[GetFilterUnit()])) //This shows once return true endif return false endfunction private function Init takes nothing returns nothing local integer i = 0 local region r = CreateRegion() set AREA[0] = Rect( -2624., -1888., -704., 32. ) set AREA[1] = Rect( -830., 575., 415., 1760. ) set AREA[2] = Rect( -4225., 670., -3135., 1790. ) set AREA[3] = Rect( -4225., -3138., -3232., -2496. ) set AREA[4] = Rect( 1092., -3171., 1543., -2624. ) set AREA[5] = Rect( 1230., 2264., 1550., 2688. ) set AREA[6] = Rect( -5056., 2464., -4832., 2688. ) set AREA[7] = Rect( -5056., -3232., -4732., -3096. ) loop call RegionAddRect( r, AREA[i] ) call TriggerRegisterEnterRegion( CreateTrigger(), r, Condition( function IHateJass ) ) set i = i + 1 exitwhen i >= MAX_CHECKPOINTS endloop endfunction endscope |
| 07-03-2009, 10:32 AM | #4 |
call TriggerRegisterEnterRegion( CreateTrigger(), r, Condition( function IHateJass ) ) this will make your function run 1 time for every rect you have in that region. that means 8 times. take that line out of the loop, and it will only run 1 time whenever a unit enters anywhere in the region. also, does this mean that your check value gets reset it -1 or to 0 every time? |
| 07-03-2009, 03:02 PM | #5 |
Nvm, found the problem. Should've known removing units are bad for unit indexers. |
| 07-04-2009, 05:46 AM | #6 |
Not if you use AutoIndex... |
