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

[General] Why do Blizzard Campaigns set every unit on the map into Variables?

Level 14
Joined
May 9, 2021
Messages
263
I've recently been looking at the original Blizzard Campaigns, and I've noticed something that confuses me...

We'll take the first Mission of the "Scourge of Lordaeron" for example - "The Defense of Strahnbrand".

Every unit, from the starting Footmen that arrive with Arthas to the Bandit Creeps are loaded into a unit variable that, to my knowledge, doesn't come up again.

Why is this? What is the point of it?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
I've recently been looking at the original Blizzard Campaigns, and I've noticed something that confuses me...

We'll take the first Mission of the "Scourge of Lordaeron" for example - "The Defense of Strahnbrand".

Every unit, from the starting Footmen that arrive with Arthas to the Bandit Creeps are loaded into a unit variable that, to my knowledge, doesn't come up again.

Why is this? What is the point of it?
I can't say for certain, but relying on direct unit references is just asking for trouble.

Imagine you had a pre-placed unit, let's say "Captain 001", that you're referencing in 10 different triggers. Then imagine you changed your mind and wanted this Unit to be a Hero instead, requiring you to create an entirely new Unit in the Object Editor. By deleting the original "Captain 001" you would cause all 10 of those triggers to break since their references would be lost.

But had you referenced a variable in those triggers, let's say My_Captain_Variable, then only the initial setting of the variable would break:
  • Actions
    • Set Variable My_Captain_Variable = ???
So you only need to fix the error once in one central trigger as opposed to having to fix the error all over the place.

It's also a lot more flexible. For example, you could "promote" a different Unit to use the My_Captain_Variable, allowing your triggers to continue to function while producing new results.
 
Last edited:
There was also a bug introduced in 1.31 (IIRC might have been a different patch) where certain unit events broke such as "A unit comes within range of unit" events where if you used the basic select unit option, upon saving and loading this event would break (there were a few events affected). The solution is/was to use generic unit events and then use unit variables in the condition, or use the trigger action Trigger - Add Event to Trigger, which allows the selection of unit variables for some events.

There's a thread about it here: [1.31.1] Bug: Loading saved game breaks some unit events
 
Top