How to Write Checking Unit In Range code

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...
 

Kelvin87

New Member
Reaction score
14
This code is used for a group of units. So, how you do it? In custom code prefered...
 

LightChaosma

New Member
Reaction score
60
wouldnt know that... i dont know any custom codes but leak removers... if it was a single unit i would be able to help... too bad
 

Nina

New Member
Reaction score
8
well the unit you call Triggering Unit should be put in a variable(in this case unit) in another trigger because you can't have a unit respond to(trigger) an even inside the event. In this code the triggering unit is the unit that comes in range of the one you call Triggering Unit.

JASS:
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


256 is the range.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top