Does this trigger leak

Weyird

Member
Reaction score
5
As the title says, just want to know if this leaks. It's the type of trigger that'll run often, with every single selection event in the whole game. Also, is there a better way to do it?
Just to explain, there's a broken scout tower that a player can repair if they want. This trigger is so that any player can select the broken scout tower and gain ownership of it so they can upgrade it to a non-broken scout tower (which, if destroyed again, is triggered to create a broken scout tower again).

[war3]Broken Tower Select
Events
Player - Player 1 (Red) Selects a unit
Player - Player 2 (Blue) Selects a unit
Player - Player 3 (Teal) Selects a unit
Player - Player 4 (Purple) Selects a unit
Conditions
Actions
Set temp_Unit = (Random unit from (Units currently selected by (Triggering player)))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of temp_Unit) Equal to Scout Tower (Broken)
Then - Actions
Unit - Change ownership of temp_Unit to (Triggering player) and Change color
Else - Actions
[/war3]
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
not sure if single unit variables leak, but to be sure it doesnt, just set the variable to no unit
 

hopy

Active Member
Reaction score
64
not sure if single unit variables leak, but to be sure it doesnt, just set the variable to no unit
Single unit variables do NOT leak, ever. The variable doesn't create a new point, group or special effect, it just points at a unit.

Trigger:
  • Set temp_Unit = (Random unit from (Units currently selected by (Triggering player)))

However: (Units currently selected by (Triggering player))) is a unit group and does leak.
What you should do is:
Trigger:
  • Broken Tower Select
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
    • Conditions
    • Actions
      • Set Unit_Group = (Units currently selected by (Triggering player))
      • Set temp_Unit = (Random unit from Unit_Group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of temp_Unit) Equal to Scout Tower (Broken)
        • Then - Actions
          • Unit - Change ownership of temp_Unit to (Triggering player) and Change color
        • Else - Actions
      • Custom script: call DestroyGroup (udg_Unit_Group)



Also the trigger tags are: [WC3 ], not [war3]
 

HydraRancher

Truth begins in lies
Reaction score
197
Trigger:
  • Broken Tower Select
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
    • Conditions
      • (Unit-type of (Selected Unit)) Equal to Scout Tower (Broken)
    • Actions
      • Unit - Change ownership of (Selected Unit) to (Owner of (Selected Unit)) and Change color


Use this. More efficient.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top