Yes using Temp variables in multiple triggers is fine if used properly however I don't think Uncle is correct in saying "A Unit Enters Playable Map Area" will intercept a running trigger that spawns a unit. Here is a test I made:
-
Spawn Trigger
-

Events
-


Time - Elapsed game time is 3.00 seconds
-

Conditions
-

Actions
-


Game - Display to (All players) for 30.00 seconds the text: Starting Spawn Trig...
-


Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
-


Game - Display to (All players) for 30.00 seconds the text: Finishing Spawn Tri...
-
Enter Trigger
-

Events
-


Unit - A unit enters (Playable map area)
-

Conditions
-

Actions
-


Game - Display to (All players) for 30.00 seconds the text: Starting Enter Area...
-


Game - Display to (All players) for 30.00 seconds the text: Finishing Enter Are...
See attached screenshot for the result. We can clearly see that the Spawn trigger finishes it's execution
before the Enter triggers fires. Are you able to edit your post as to prevent any mis-information? Sorry if I've gotten anything wrong, happy to discuss.
Would it be safe to use the same variable for dozens of triggers that might all be used within a second of eachother?
Issue is my map is a long-term game, people usually end up playing it for multiple hours, so i imagine instability is likely to happen after it has leaked over a thousand times.
I already went through and gave every point in my map it's own variable, and set them all to a specific point on map initialization to wipe out those leaks.
Lots of item drops in regions and monster respawns, I literally have like 100 defined point variables now.
I'll use the word "Temp Variable" to mean a variable which is used in multiple different unrelated triggers.
You're welcome to use the same temp variable in as many triggers as you like and they can all be running within seconds of eachother no problem.
The general rule I follow is
never add any kind of wait or amount of time between setting and using/removing a Temp variable. The moment you pause a trigger, something else can begin to run. That something else might overwrite your important variables.
Here is an example of bad Temp variable usage:
-
Heal Unit
-

Events
-


Unit - A unit Starts the effect of an ability
-

Conditions
-

Actions
-


Set VariableSet TempUnit = (Triggering unit)
-


Set VariableSet TempPoint = (Position of TempUnit)
-


Wait 5.00 seconds
-


Unit - Set life of TempUnit to 100.00%
-


Special Effect - Create a special effect at TempPoint using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call Remove Location (udg_TempPoint)
Here we have a simple heal spell. A unit casts the ability and 5 seconds later, they are healed. Let's pretend the unit has to "charge" up or something. This will work fine in isolation, but the trouble is....
.what happens if another ability or trigger (which uses TempUnit or TempPoint) runs while you're "charging up" (waiting 5 seconds)?
The other ability will set it's variables to do it's thing then 5 seconds later in our Heal spell, the TempUnit will refer to someone else. It no longer references the original unit whom casted the spell. So now a different unit will get healed. Depending on what and how many triggers happen to be using the same variable improperly, this could cause numerous different problems or strange outcomes.
So what is the solution?
If you ever need to use a wait, or have something remembered for later, make sure you use unique variables that can't be hijacked or used by another system, spell, or whatever.
-
Heal Unit
-

Events
-


Unit - A unit Starts the effect of an ability
-

Conditions
-

Actions
-


Set VariableSet HealUnit_Unit = (Triggering unit)
-


Set VariableSet HealUnit_Point = (Position of TempUnit)
-


Wait 5.00 seconds
-


Unit - Set life of HealUnit_Unit to 100.00%
-


Special Effect - Create a special effect at HealUnit_Point using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
-


Special Effect - Destroy (Last created special effect)
-


Custom script: call Remove Location (udg_HealUnit_Point)
I use temp variables all the time. Saves me making hundreds of variables in my map. You just gotta use them properly
A side note, when making spells and stuff with waits, you often use concepts like MPI (Multi-Player Instancability) or MUI (Multi Unit Intancability) which allow the same trigger to run multiple times, even at the same time without overwriting eachother. This is needed if you have multiple players or units with the same heal ability. It might be easier to hold this discussion off for another day and let you focus on fixing your leaks

There are tutorials on the Hive about MPI and MUI if you're interested.