• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Auto Engage Event

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
If two hostile units are in each others acquisition range they will automatically engage in combat, the problem is that there no command for this action.

An event like A unit Is Attacked fires only when the unit starts the action but there is no way to detect when the unit leaves its position to attack a unit because it has entered its acquisition range.

Is there a way to detect this event ?

The only solution I have found is by picking every unit in the map that can attack and check the nearest unit to the picked unit and see if one is in the acquisition range of the other or not but something like that may be slow but that is the only thing I can think of.

Any ideas/solutions ?
 
Level 9
Joined
Jul 10, 2011
Messages
562
just make 2 triggers....1 with the actions you wanna do when they engage, 1 adding during map ini and whenever a unit enters the map the event to the first trigger 'a unit comes within X of (your units)' for every unit in the map...

that way you have a trigger running everytime the units get in acquisition range.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Events
    • Unit - No unit Acquires a target
Unit - Specific Unit Event

If the unit is a variable, you can use this to register the unit to that event (since that event does not accept variable-type unit).
NOTE: ONLY REGISTER THE UNIT ONCE TO THE EVENT. Registering a unit multiple times to a single event cause instance bugs. How to do this ? Simple. When you want to register, do an IF/THEN/ELSE check, if the unit is not in a Unit Group (variable), add it and register it, if it already enters the unit group, do nothing (literally - leave it blank).
  • Trigger - Add to Acquire Target <gen> the event (Unit - Unit Acquires a target)
At the event (different trigger);
  • Acquire Target
    • Events
    • Conditions
    • Actions
      • -------- ACTIONS HERE --------
 
Status
Not open for further replies.
Top