- Joined
- May 6, 2008
- Messages
- 284
Topic
call TriggerRegisterAnyUnitEventBJ( gg_trg_YOURTRIGGER, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_YOURTRIGGER, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
local unit u1 = GetTriggerUnit()
local unit u2 = GetOrderTargetUnit()
local integer i = GetIssuedOrderId()
local location l = GetOrderPointLoc()
local destructable d = GetOrderTargetDestructable()
if i == 851986 then
if u2 != null then
call IssueTargetOrder(u1,"attack",u2) // Attack Unit
elseif d != null then
call IssueTargetDestructableOrder(u1,"attack",d) // Attack Destructable
elseif l != null then
call IssuePointOrderLoc(u1,"attack",l) // Attack Move To
endif
endif
if i == 851990 then // Move
call IssuePointOrderLoc(u1,"smart",l)
endif
call RemoveLocation(l)
set u1 = null
set u2 = null
set d = null
set l = null
function Trig_CommandSystem_Actions takes nothing returns nothing
local unit u1 = GetTriggerUnit()
local unit u2 = GetOrderTargetUnit()
local integer i = GetIssuedOrderId()
local location l = GetOrderPointLoc()
local destructable d = GetOrderTargetDestructable()
if i == 851986 then
if u2 != null then
call IssueTargetOrder(u1,"attack",u2) // Attack Unit
elseif d != null then
call IssueTargetOrder( u1, "attack", d ) // Attack Destructable
elseif l != null then
call IssuePointOrderLoc(u1,"attack",l) // Attack Move To
call RemoveLocation(l)
endif
endif
if i == 851990 then // Move
call IssuePointOrderLoc(u1,"smart",l)
call RemoveLocation(l)
endif
set u1 = null
set u2 = null
set d = null
set l = null
endfunction
//===========================================================================
function InitTrig_CommandSystem takes nothing returns nothing
set gg_trg_CommandSystem = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CommandSystem, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CommandSystem, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_CommandSystem, function Trig_CommandSystem_Actions )
endfunction
Great job, =]
However, when you target a widget the script tries to remove a null location, which results in a thread crash, meaning the handles won't be nullified. Here's a fixed version which also replaces the unnecessary BJ.
JASS:function Trig_CommandSystem_Actions takes nothing returns nothing local unit u1 = GetTriggerUnit() local unit u2 = GetOrderTargetUnit() local integer i = GetIssuedOrderId() local location l = GetOrderPointLoc() local destructable d = GetOrderTargetDestructable() if i == 851986 then if u2 != null then call IssueTargetOrder(u1,"attack",u2) // Attack Unit elseif d != null then call IssueTargetOrder( u1, "attack", d ) // Attack Destructable elseif l != null then call IssuePointOrderLoc(u1,"attack",l) // Attack Move To call RemoveLocation(l) endif endif if i == 851990 then // Move call IssuePointOrderLoc(u1,"smart",l) call RemoveLocation(l) endif set u1 = null set u2 = null set d = null set l = null endfunction //=========================================================================== function InitTrig_CommandSystem takes nothing returns nothing set gg_trg_CommandSystem = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_CommandSystem, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerRegisterAnyUnitEventBJ( gg_trg_CommandSystem, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER ) call TriggerAddAction( gg_trg_CommandSystem, function Trig_CommandSystem_Actions ) endfunction
CAN i have this on map?
but is this gui?