Attack move towards a random target?

X-maul

AKA: Demtrod
Reaction score
201
I got this map where I got 8 players, and each player got a unit which is getting hunted by attacking units, the only problem is that, I dont know how I should come around ordering the attackers to attack the targets.

I want to have the attackers attack a random unit within my unit group
- If there is any of the players units within 30 range of the attackers the attackers should target the nearest unit.
- The attackers are in 4 groups of up to 8 units each. (The groups does not have to attack the same target.
- If possible I would love to have it count the range in path distance (Though I do not know if this is possible, and if it's not - that doesnt matter)

How would I come around doing this?
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Your title seems to suggest that you want the enemy groups to attack a random target while the text seems to suggest that you want them to attack the closest target, pathing-wise. Which one is the case?
 

X-maul

AKA: Demtrod
Reaction score
201
Your title seems to suggest that you want the enemy groups to attack a random target while the text seems to suggest that you want them to attack the closest target, pathing-wise. Which one is the case?
Uhm - well yeah the title might be misleading - I want to attack a random target if there are no targets within 30 range
 

X-maul

AKA: Demtrod
Reaction score
201
Bumb
- I do not want you guys to create a the entire trigger for me, I'd just love if you gave me a hint on how to create it, as it is right now, I cant seem to figure out a way to check which unit is closest :confused:
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Code:
Pick every unit in UnitsAttacking:
   set nearbyunits = Units in region matching condition(make the region "Convert Circle to region and set the radius to 30)
   if (Number of units in nearbyunits) > 0:
      for each unit u in nearby units:
         if u is not in player units:
            remove u from nearby units
      Unit - Order (Picked Unit) to attack (Closest unit to (Position of (Picked Unit)) in nearbyunits)
   else:
      Unit - Order (Picked Unit) to attack (Random unit in player units)

Something like that should give you an idea.
 

X-maul

AKA: Demtrod
Reaction score
201
Code:
Pick every unit in UnitsAttacking:
  set nearbyunits = Units in region matching condition(make the region "Convert Circle to region and set the radius to 30)
  if (Number of units in nearbyunits) > 0:
      for each unit u in nearby units:
        if u is not in player units:
            remove u from nearby units
      Unit - Order (Picked Unit) to attack (Closest unit to (Position of (Picked Unit)) in nearbyunits)
  else:
      Unit - Order (Picked Unit) to attack (Random unit in player units)

Something like that should give you an idea.
Ohhhhh! I didnt know of that "Closest unit" action :D
This makes it so much easier - thank you Siretu :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top