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

How to run an action on all Heroes not owned by Computer-controlled players?

Level 2
Joined
Aug 14, 2024
Messages
8
Hey there,

I want my trigger to add experience to all heroes on the map that are owned by actual human players, that is, any heroes not owned by an AI. I'm assuming it's Unit Group - Pick every unit in unit group and do action, but it's been a while since I've messed with the wc3 editor, so I'm not sure exactly how to go about it. Any help would be appreciated. Thank you.
 
Level 30
Joined
Aug 29, 2012
Messages
1,386
You can do it like this
  • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Owner of (Matching unit)) controller) Equal to User))) and do (Actions)
1723647932303.png
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Be aware that as written by Chaosium that line leaks a unit group object, which is permanent memory allocation in the map that will never return. A single group is tiny and won't matter. A hundred such groups won't matter. But doing something like the above line 20 times a second throughout the entire map's duration would be a significant issue.

Context is important, and nothing says you have to prevent the leak just that you should for a better user experience. Here's the best tutorial on what the heck I'm talking about if it makes no sense to you: Memory Leaks
 
Top