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

Transforming a global trigger into a local one.

Level 3
Joined
Apr 16, 2025
Messages
30
As you know, when you access "trigger unit", the game creates a local variable. This is damn convenient. But when you access, for example, "selected unit", the game already accesses the global one.

So the question is, is it possible to somehow easily transform "selected unit" into "trigger unit"? I can't find such a function.
 
Level 29
Joined
Sep 26, 2009
Messages
2,609
Most events that are related to units, including the unit selection event, set (Triggering Unit), so it is safe to replace (Selected unit) for (Triggering unit).
However in some cases you can access units only via globals - for example "Unit Take Damage" event - the (Triggering unit) is same as (Damage Target), but there is no way to get the damaging unit other than (Damage Source), which (I assume) is global.

There is no way to transform "selected unit" into "trigger unit", as value assignment to those is done by WC3 engine itself.
You can use local variables (which are only accessible via custom script), but they are limited when it comes to nested function scopes, like "Unit Group - For every unit in group do Actions"
 
Top