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

[Trigger] How to order hostile units to cast spells at a point when a unit comes within range?

Status
Not open for further replies.
Level 1
Joined
Jul 10, 2014
Messages
3
Hello, I've been going to hive workshop for years and I've finally made an account.

Anyways, I've recently started map making and I've been teaching my self GUI while making a map. However, I've come across a problem I can't figure out. Checking online, I found nothing after searching forever for something similar.

===================================================

In my map certain hostile units have a spell which fires an arrow 1500 distance from the angle and position of the unit towards a point.

I would like Ancient units (Unit classification for units with the spell) to begin casting at the point of a unit that's not equal to neutral hostile once they come within range. I tried using the event "Comes within distance" but it only allows preset units.

I tried to make this happen several ways, and this is the only way I've managed to scrap together. I don't like it, the neutral hostile unit has to fire one ranged auto attack at you before he starts casting the dummy arrows at your hero's position.

Would anyone mind helping me fix this?

  • Arrow Aggro
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is An Ancient) Equal to True
      • (Owner of (Attacking unit)) Equal to Neutral Hostile
    • Actions
      • Set UnitBowAttack = (Attacked unit)
      • Trigger - Turn on Arrow Aggro Copy <gen>

  • Arrow Aggro Copy
    • Events
      • Time - Every 2.55 seconds of game time
    • Conditions
    • Actions
      • Set MoveGroup = (Units within 4000.00 of (Position of UnitBowAttack) matching ((((Matching unit) is An Ancient) Equal to True) and ((Owner of (Matching unit)) Equal to Neutral Hostile)))
      • Unit Group - Pick every unit in MoveGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (All units of MoveGroup are dead) Equal to False
              • (UnitBowAttack is alive) Equal to True
            • Then - Actions
              • Set PointBowAttack = (Position of UnitBowAttack)
              • Unit - Order (Picked unit) to Neutral Tinker - Cluster Rockets (PointBowAttack offset by (0.00, 0.00))
              • Custom script: call RemoveLocation(udg_PointBowAttack)
            • Else - Actions
              • Trigger - Turn off (This trigger)
 
You could pick every unit that has this ability and within the enumeration block (Unit Group - Pick every unit within range), add the action "Trigger - Add to Trigger 2 <gen> the event (Unit - A unit comes within X of (Picked unit))".
In Trigger2 <gen>, order your unit to cast the ability. You could also use a local timer, attached on the picked unit, to disallow potential interception of orders and to order it only when the timer has expired (the timer timeout equals to the cooldown of the ability).

It is generally not efficient to use Neutral Hostile to script custom behavior, as they are affected by AI and are thus unpredictable.
 
Level 1
Joined
Jul 10, 2014
Messages
3
Is there another way to do this?

I cant pick every unit with this ability because they are spawned randomly in packs (like an RPG) when a player's hero is within a region.
I was hoping a trigger that does this constantly, because almost every unit in the map is created through triggers.

Or do I have to keep selecting every unit in playable map area that's player brown and ancient and keep adding them to player group? Won't that cause buildup of lag or desync if it's checking every 5 seconds or so?

And thank you ^^ I'll change hostile to player brown.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
To keep performance high, there should be 2 parts to the system.
Target approximation, are any units roughly even in the right place to consider looking for a target?
Target resolution. Actually find the target, if any.

The target approximation system is responsible for adding units to the more demanding target resolution system. It could be something as dumb as a massive region containing all areas near the units. Target resolution would be an area search for any targets viable for casting.
 
Status
Not open for further replies.
Top