Kelvin87
New Member
- Reaction score
- 14
Can somebody help me to write the code of checking the unit come in a range of Triggering Unit and want the Triggering Unit to attack it if the coming unit is an enemy...
function unitEnemy takes nothing returns boolean
return(IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(udg_unit)))
endfunction
function Trig_trigger_Actions takes nothing returns nothing
local unit c = GetTriggerUnit
local unit u = udg_unit
call IssueTargetOrder(u, "attack", c)
endfunction
//===========================================================================
function InitTrig_trigger takes nothing returns nothing
set gg_trg_trigger = CreateTrigger( )
call TriggerRegisterUnitInRange( gg_trg_trigger, udg_unit, 256 )
call TriggerAddCondition(gg_trg_trigger, Condition(function unitEnemy))
call TriggerAddAction( gg_trg_trigger, function Trig_trigger_Actions )
endfunction