I am working on a easy expandable auto-movement system... Usable for mainly TDs or long routes i.e. patrols use.
I have one event handling trigger for that, which creates one Trigger for every event (i hope )! The Units run like they should ... most time...
sometimes all units at a specific Waypoint gets the result -3 and going to the wrong WP (Center of Map, which is default i think).
Question is now: Why do they SOMETIMES get the wrong results?
Code:
PS: Still have no good solution not to define the WP every event handling, so i can use the loop...don't wanna use vJass, even if some features are nice...
PPS: I really need that hide button...Which tag?
I have one event handling trigger for that, which creates one Trigger for every event (i hope )! The Units run like they should ... most time...
sometimes all units at a specific Waypoint gets the result -3 and going to the wrong WP (Center of Map, which is default i think).
Question is now: Why do they SOMETIMES get the wrong results?
Code:
JASS:
globals
rect array udg_zRegion
integer udg_yRegionsPerPlayer
integer udg_yPlayerCount
integer udg_zRegionCount
integer udg_UnitsToSpawn
trigger gg_trg_Spawn
endglobals
function SetRects takes nothing returns nothing
set udg_zRegion[1] = Rect( -2592.0, 2048.0, -2048.0, 2560.0 )
set udg_zRegion[2] = Rect( -1056.0, 2016.0, -480.0, 2592.0 )
set udg_zRegion[3] = Rect( -1056.0, 992.0, -480.0, 1536.0 )
set udg_zRegion[4] = Rect( -2624.0, 992.0, -2048.0, 1568.0 )
set udg_zRegion[5] = Rect( -896.0, 2432.0, -640.0, 2560.0 )
set udg_zRegion[6] = Rect( 0.0, 2304.0, 128.0, 2560.0 )
set udg_zRegion[7] = Rect( -128.0, 1664.0, 128.0, 1792.0 )
set udg_zRegion[8] = Rect( -896.0, 1664.0, -768.0, 1920.0 )
set udg_zRegion[9] = Rect( -2560.0, 1152.0, -2304.0, 1280.0 )
set udg_zRegion[10] = Rect( -1664.0, 1024.0, -1536.0, 1280.0 )
set udg_zRegion[11] = Rect( -1792.0, 384.0, -1536.0, 512.0 )
set udg_zRegion[12] = Rect( -2560.0, 384.0, -2432.0, 640.0 )
set udg_zRegion[13] = Rect( -896.0, 1152.0, -640.0, 1280.0 )
set udg_zRegion[14] = Rect( 0.0, 1024.0, 128.0, 1280.0 )
set udg_zRegion[15] = Rect( -128.0, 384.0, 128.0, 512.0 )
set udg_zRegion[16] = Rect( -896.0, 384.0, -768.0, 640.0 )
set udg_zRegionCount = 16 // the highest number in the array!
set udg_yPlayerCount = 4 // We have to start with 1 .. mod works for (x!=0)
set udg_yRegionsPerPlayer = 4 // 1 Red, 2 Blue ... etc
endfunction
//EndGlobals
function Trig_Spawn_Actions takes nothing returns nothing
local integer i = 1
local integer k = 1
loop
exitwhen k>udg_UnitsToSpawn // i suggest 1-9
set i=1
loop
exitwhen i>udg_zRegionCount
if ModuloInteger(i, (udg_yRegionsPerPlayer)) == 1 then
call CreateNUnitsAtLoc( 1, 'hpea', ConvertedPlayer(IAbsBJ( i / udg_yPlayerCount)+1), GetRectCenter(udg_zRegion[i]), bj_UNIT_FACING )
endif
set i = i+1
endloop
call TriggerSleepAction(1.5)
set k = k+1
endloop
endfunction
//===========================================================================
function InitTrig_Spawn takes nothing returns nothing
set gg_trg_Spawn = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Spawn, 0.5 )
call TriggerAddAction( gg_trg_Spawn, function Trig_Spawn_Actions )
endfunction
//===========================================================================
function Trig_Move_Cond takes nothing returns boolean
return true //later
endfunction
function Trig_Move_Actions takes nothing returns nothing
local integer i = 0
local integer triggeringRectId = 0
local unit triggeringUnit = GetTriggerUnit()
// ---function---
//call DisplayTimedTextToForce(GetPlayersAll(),20, "Inside Actions ;)")
//Wait untill unit is really in - Bugs without, when entering from top...no clue why ;)
call TriggerSleepAction(GetUnitMoveSpeed(triggeringUnit)/2000)
//Get triggeringRectId
set i = 1
loop
exitwhen i>udg_zRegionCount
if (RectContainsUnit(udg_zRegion[i],triggeringUnit)) then
set triggeringRectId = i
endif
set i = i+1
endloop
//Show result
call DisplayTimedTextToForce(GetPlayersAll(),20,"Entering udg_zRegion[" + I2S(triggeringRectId)+"]")
//Its NOT the last point = next spawn moving!
if ModuloInteger(triggeringRectId, (udg_yRegionsPerPlayer)) != 0 then //All Numbers are x*y (x=player no, y=playerwaypoints)
call IssuePointOrderLoc( triggeringUnit, "move", GetRectCenter(udg_zRegion[triggeringRectId+1]) )
call DisplayTimedTextToForce(GetPlayersAll(),20,"Moving To: " + I2S(triggeringRectId+1)+" - caused by Mod: "+ I2S(ModuloInteger(triggeringRectId, (udg_yRegionsPerPlayer))))
return
endif
// Its the last point...so do whatever you want
if ModuloInteger(triggeringRectId, (udg_yRegionsPerPlayer)) == 0 then
call IssuePointOrderLoc( triggeringUnit, "move", GetRectCenter(udg_zRegion[(triggeringRectId-(udg_yRegionsPerPlayer-1))]) )
call DisplayTimedTextToForce(GetPlayersAll(),20,"Moving To Start: " + I2S((triggeringRectId-(udg_yRegionsPerPlayer-1)))+" - caused by Mod: "+ I2S(ModuloInteger(triggeringRectId, (udg_yRegionsPerPlayer))))
return
endif
//---clean up---
set triggeringUnit = null
endfunction
//===========================================================================
function InitTrig_Movement takes nothing returns nothing
local trigger Movement = CreateTrigger( )
local integer i = 0
call SetRects()
loop // Register All Regions stored in the array
exitwhen i>udg_zRegionCount
call TriggerRegisterEnterRectSimple(Movement, udg_zRegion[i])
set i = i+1
endloop
call TriggerAddCondition( Movement, Condition( function Trig_Move_Cond ) )
call TriggerAddAction( Movement, function Trig_Move_Actions )
endfunction
PS: Still have no good solution not to define the WP every event handling, so i can use the loop...don't wanna use vJass, even if some features are nice...
PPS: I really need that hide button...Which tag?
Attachments
Last edited: