I'm just curious which method would be faster - using the trigger's 'Conditions' function, or simply sticking the conditions in the 'Actions' function? This Trigger is going to be called a LOT, so speed is important.
Putting the conditions in the actions makes it so some local variables only have to be allocated once instead of twice, which also means one less call to GetTriggerUnit()
All opinions welcome!
Here's the code incase an expert is interested...though I've got a half dozen more scripts that integrate with it, so it doesn't appear complete.
Thanks!
Putting the conditions in the actions makes it so some local variables only have to be allocated once instead of twice, which also means one less call to GetTriggerUnit()
All opinions welcome!
Here's the code incase an expert is interested...though I've got a half dozen more scripts that integrate with it, so it doesn't appear complete.
JASS:
function Trig_Spot_Units_Actions takes nothing returns nothing
local unit myUnit = GetTriggerUnit()
local integer WaypointNum = R2I(GetUnitAcquireRange(myUnit))-49
if(GetPlayerId(GetOwningPlayer(myUnit)) == 10) and (RAbsBJ(GetUnitX(myUnit)-udg_PointIndexX[WaypointNum]) < 16) and (RAbsBJ(GetUnitY(myUnit)-udg_PointIndexY[WaypointNum]) < 16) then
// Not at End
if R2I(GetUnitAcquireRange(myUnit)) != (48+udg_PointCount) then
call SetUnitAcquireRange(myUnit, GetUnitAcquireRange(myUnit)+1)
call IssuePointOrder(myUnit, "move", udg_PointIndexX[WaypointNum +1], udg_PointIndexY[WaypointNum +1])
// At End of Path
else
call ExplodeUnitBJ(myUnit)
endif
endif
endfunction
//===========================================================================
function InitTrig_Spot_Units takes nothing returns nothing
call TriggerAddAction(CreateTrigger(), function Trig_Spot_Units_Actions)
endfunction