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

[Trigger] SOLVED - Help to Fix: Despawning Dummy Units

Level 11
Joined
Aug 24, 2022
Messages
432
Hello everyone here at Hive! I'm here looking for help about my triggers, that aren't despawning one kind of my dummies. Let me explain better:

I have three kinds of dummies inside my project: One that does nothing (for abilites, auras, etc), one with attack set to 1 (for orb effects), and one for visual effect (that appear casting abilities for heroes, but only for aesthetic purposes, like a serpent ward channeling Big Bad Voodoo).

I have an Arena System made by Uncle here at Hive (Didn't mark him, because I don't know if we can, but thank you very much Uncle), where units gets removed, winning or losing a wave of enemies.

  • Arena Players Win Wave
    • Events
    • Conditions
    • Actions
      • -------- --------
      • Set VariableSet Waves_Beated = (Waves_Beated + 1)
      • Trigger - Run Relics Check <gen> (checking conditions)
      • Item - Pick every item in Dropped Items Arena <gen> and do (Item - Move (Picked item) to (Random point in Item Stash Arena <gen>))
      • Item - Pick every item in Dropped Artifacts Arena <gen> and do (Item - Move (Picked item) to (Random point in Relics and Artifacts <gen>))
      • -------- --------
      • Game - Display to (All players) the text: <Empty String>
      • Game - Display to (All players) for 10.00 seconds the text: (You've completed |cff00ff00Wave + ((String(Arena_Current_Wave)) + |r!))
      • -------- --------
      • Unit Group - Pick every unit in Croud and do (Actions)
        • Loop - Actions
          • Animation - Play (Picked unit)'s stand, victory animation
      • Animation - Play Uncle Goblin, the Relicary 0012 <gen>'s stand fourth animation
      • -------- --------
      • Wait 1.00 game-time seconds
      • -------- --------
      • -------- Reward gold: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Arena_Win_Reward Greater than 0.00
        • Then - Actions
          • Game - Display to (All players) the text: (Reward: + (|cffffff00+ + ((String(Bounty_Win_Reward_Gold)) + Gold|r.)))
          • Sound - Play Reward <gen>
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Player - Add (Integer(Arena_Win_Reward)) to (Picked player).Current gold
        • Else - Actions
      • -------- --------
      • -------- Move/revive heroes back at the tavern: --------
      • Unit Group - Pick every unit in Player_Hero_Group and do (Actions)
        • Loop - Actions
          • Camera - Pan camera for (Owner of (Picked unit)) to Hero_Spawn_Point over 0.00 seconds
          • Unit - Move (Picked unit) instantly to Hero_Spawn_Point
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Human\MassTeleport\MassTeleportCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Hero - Instantly revive (Picked unit) at Hero_Spawn_Point, Show revival graphics
      • -------- --------
      • -------- Remove leftover units in the arena: --------
      • Unit Group - Pick every unit in (Units of type Dummy Arena Effect) and do (Unit - Remove (Picked unit) from the game)
      • Unit Group - Pick every unit in (Units in Arena 1 <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Destructible - Pick every destructible in (Playable map area) and do (If ((Destructible-type of (Picked destructible)) Equal to Barrel of Explosives) then do (Destructible - Kill (Picked destructible)) else do (Do nothing))
      • -------- --------
      • -------- End Any Boss Fight Trigger --------
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Environment - Remove Boss_Weather_Effect[(Integer A)]
      • Player Group - Pick every player in (All players) and do (Camera - Stop swaying/shaking the camera for (Picked player).)
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Starter Triggers --------
          • Trigger - Turn on Boss_Event_Start[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_A[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_B[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_C[(Integer A)]
          • -------- --------
          • -------- Loop Triggers --------
          • Trigger - Turn off Boss_Event_Loop[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_A[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_B[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_C[(Integer A)]
      • -------- --------
      • -------- Check if the players have finished the final wave! --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Arena_Current_Wave Equal to 22
        • Then - Actions
          • Trigger - Run Game Over Victory <gen> (ignoring conditions)
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- Hide Timer Wave Limit --------
      • Countdown Timer - Pause (Last started timer)
      • Countdown Timer - Hide (Last created timer window)
      • -------- --------
      • -------- Checking Time Limit for Creeps or Boss Waves --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Arena_Current_Wave Equal to 7
        • Then - Actions
          • Set VariableSet Arena_Wave_Time_Limit = 300.00
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Arena_Current_Wave Equal to 8
            • Then - Actions
              • Set VariableSet Arena_Wave_Time_Limit = 150.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Arena_Current_Wave Equal to 14
                • Then - Actions
                  • Set VariableSet Arena_Wave_Time_Limit = 300.00
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Arena_Current_Wave Equal to 15
                    • Then - Actions
                      • Set VariableSet Arena_Wave_Time_Limit = 150.00
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Arena_Current_Wave Equal to 21
                        • Then - Actions
                          • Set VariableSet Arena_Wave_Time_Limit = 300.00
                        • Else - Actions
                          • Do nothing
      • -------- --------
      • -------- Prepare the next wave: --------
      • If (Arena_Current_Wave Equal to 21) then do (Set VariableSet Arena_Time_Between_Waves = 120.00) else do (Do nothing)
      • Countdown Timer - Start Timer_Wave as a One-shot timer that will expire in Arena_Time_Between_Waves seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Next wave in:
      • Set VariableSet Timer_Window = (Last created timer window)
      • Countdown Timer - Show Timer_Window

  • Arena Players Lose Wave
    • Events
    • Conditions
    • Actions
      • Set VariableSet Player_Lives = (Player_Lives - 1)
      • Item - Pick every item in Dropped Items Arena <gen> and do (Item - Move (Picked item) to (Random point in Item Stash Arena <gen>))
      • Item - Pick every item in Dropped Artifacts Arena <gen> and do (Item - Move (Picked item) to (Random point in Relics and Artifacts <gen>))
      • -------- --------
      • Game - Display to (All players) for 1.00 seconds the text: <Empty String>
      • Game - Display to (All players) for 10.00 seconds the text: (You've failed |cffff0000Wave + ((String(Arena_Current_Wave)) + (|r + (- Player lives remaining: |cff00ff00 + ((String(Player_Lives)) + |r)))))
      • -------- --------
      • Animation - Play Uncle Goblin, the Relicary 0012 <gen>'s stand third animation
      • Unit Group - Pick every unit in Croud and do (Actions)
        • Loop - Actions
          • Animation - Play (Picked unit)'s death animation
      • -------- --------
      • -------- Reward some gold for trying: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Arena_Lose_Reward Greater than 0.00
        • Then - Actions
          • Game - Display to (All players) the text: <Empty String>
          • Game - Display to (All players) the text: (Consolation Prize: + (|cffffff00+ + ((String(Bounty_Lose_Reward)) + Gold|r.)))
          • Sound - Play Reward <gen>
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Player - Add (Integer(Arena_Lose_Reward)) to (Picked player).Current gold
        • Else - Actions
      • -------- --------
      • -------- Check if the players have run out of lives! --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Player_Lives Less than 0
        • Then - Actions
          • Trigger - Run Game Over Defeat <gen> (ignoring conditions)
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • Wait 1.00 game-time seconds
      • -------- --------
      • -------- Move/revive heroes back at the tavern: --------
      • Unit Group - Pick every unit in Player_Hero_Group and do (Actions)
        • Loop - Actions
          • Camera - Pan camera for (Owner of (Picked unit)) to Hero_Spawn_Point over 0.00 seconds
          • Unit - Move (Picked unit) instantly to Hero_Spawn_Point
          • Hero - Instantly revive (Picked unit) at Hero_Spawn_Point, Show revival graphics
      • -------- --------
      • -------- Remove leftover units in the arena: --------
      • Unit Group - Pick every unit in (Units in Arena 1 <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Creep Spawn East <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Creep Spawn North <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Creep Spawn South <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Creep Spawn West <gen>) and do (Actions)
        • Loop - Actions
          • If (((Picked unit) has buff Credits ) Equal to False) then do (Unit - Remove (Picked unit) from the game) else do (Do nothing)
      • Custom script: set bj_wantDestroyGroup = true
      • Destructible - Pick every destructible in (Playable map area) and do (If ((Destructible-type of (Picked destructible)) Equal to Barrel of Explosives) then do (Destructible - Kill (Picked destructible)) else do (Do nothing))
      • Set VariableSet Arena_Enemy_Alive = 0
      • -------- --------
      • -------- End Any Boss Fight Trigger --------
      • Unit Group - Pick every unit in (Units of type Dummy Arena Effect) and do (Unit - Remove (Picked unit) from the game)
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Environment - Remove Boss_Weather_Effect[(Integer A)]
      • Player Group - Pick every player in (All players) and do (Camera - Stop swaying/shaking the camera for (Picked player).)
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Starter Triggers --------
          • Trigger - Turn on Boss_Event_Start[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_A[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_B[(Integer A)]
          • Trigger - Turn on Last_Wave_Boss_Event_Start_C[(Integer A)]
          • -------- --------
          • -------- Loop Triggers --------
          • Trigger - Turn off Boss_Event_Loop[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_A[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_B[(Integer A)]
          • Trigger - Turn off Last_Wave_Boss_Event_Loop_C[(Integer A)]
      • -------- Hide Timer Wave Limit --------
      • Countdown Timer - Pause (Last started timer)
      • Countdown Timer - Hide (Last created timer window)
      • -------- --------
      • -------- Repeat the last wave: --------
      • Set VariableSet Arena_Current_Wave = (Arena_Current_Wave - 1)
      • Countdown Timer - Start Timer_Wave as a One-shot timer that will expire in Arena_Time_Between_Waves seconds
      • Countdown Timer - Create a timer window for Timer_Wave with title Next wave in:
      • Set VariableSet Timer_Window = (Last created timer window)
      • Countdown Timer - Show Timer_Window

And this trigger, is when a dummy is summoned, for arena events, feature used on my boss fights:

  • Petrified Second Phase
    • Events
      • Unit - A unit owned by Player 9 (Gray) Takes damage
    • Conditions
      • (Damage Target) Equal to Unique_Boss[1]
      • (Unit-type of (Damage Target)) Equal to Petrified Hero - |cffff8080Outerworld|r (Unique - Tier 1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer((Percentage life of Unique_Boss[1]))) Less than or equal to Boss_Health[2]
        • Then - Actions
          • Unit - Remove All buffs from Unique_Boss[1]
          • Special Effect - Create a special effect attached to the overhead of Unique_Boss[1] using Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Game - Display to (All players) the text: <Empty String>
          • Game - Display to (All players) the text: |cffff0000Petrified...
          • Sound - Play Boss_Warcry[2] at 100.00% volume, attached to Unique_Boss[1]
          • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 1.25)
          • Unit - Create 1 Dummy Arena Effect for (Random player from Group_Enemies) at Arena_Center facing Default building facing degrees
          • Unit - Add Earthquake (Arena Event) to (Last created unit)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing

What is exactly my problem? When this dummy has an aura effect, like this one above, he doesn't get removed if players lose the wave, but if they win, he gets removed normally. The same dummy, on other boss fights, that receive other abilities instead of an aura (One has permanent immolation, for example), gets removed normally, winning or losing a wave. The issue is, when players repeat the boss wave, the arena event is already happening, and it is harmful for players, or beneficial to the boss and his minions.

So, what is going on, that I'm not seeing? Maybe trigger is too big? The order of things happening is not right? I really don't see what is wrong, since both winning and losing waves have the same logic (In my view), and the dummy used is always the same. I'll leave the map here if you want to see the entire system by yourself.

I thank you in advance.
 

Attachments

  • Outerworld Arena BETA v.0.81 TEST.w3x
    6.4 MB · Views: 3

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Units with the Locust ability cannot be found when using Unit Group search functions like "Units within range of...". You could imagine all sorts of problems would arise if they could (a lot of your triggers would be trying to interact with them causing unexpected issues).

Instead, you can manually Add the Dummys to a constant Unit Group variable which you can clear at the end of the Arena.

On creating a dummy unit during the arena phase:
  • Unit - Create 1 Dummy...
  • Unit Group - Add (Last created unit) to Arena_Dummy_Group
On arena end:
  • Unit Group - Pick every unit in Arena_Dummy_Group and do (Actions)
    • Loop - Actions
      • Unit - Remove (Picked unit) from the game
  • Unit Group - Clear Arena_Dummy_Group
 
Last edited:
Level 11
Joined
Aug 24, 2022
Messages
432
In my defense, I didn't know that Locust units behave different on triggers, so, that's why I didn't find what was wrong.

You just stared at the trigger and already found the problem... Sometimes I'm ashamed in asking for help haha. Thank you one more time Uncle. I already tested here and you fixed the problem.

BTW, your NPC now plays the "Rolling Animation" when players win a Boss Fight. It's a cool animation, and I'm using it to get players' attention to the new Relics that appear in his shop.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
In my defense, I didn't know that Locust units behave different on triggers, so, that's why I didn't find what was wrong.

You just stared at the trigger and already found the problem... Sometimes I'm ashamed in asking for help haha. Thank you one more time Uncle. I already tested here and you fixed the problem.

BTW, your NPC now plays the "Rolling Animation" when players win a Boss Fight. It's a cool animation, and I'm using it to get players' attention to the new Relics that appear in his shop.
Nothing to be ashamed of, I didn't know this was a thing until I came to Hive asking a similar question.

Also, you may be able to take advantage of the Unit Indexer to save yourself some hassle:
  • Detect Dummy Units During Arena
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
      • Arena_Is_On Equal to True
      • (Level of Dummy (Class) for UDexUnits[UDex]) Equal to 1
    • Actions
      • Unit Group - Add UDexUnits[UDex] to Arena_Dummy_Group
^ This runs when the Unit Indexer registers a new unit, so basically whenever a unit comes into existence. It checks if the Arena is on and if the registered unit has the "Dummy (Class)" ability - which you'd add to your Dummy units in the Object Editor. If both are True then we know it's a Dummy unit and it should be added to our unit group.

I think you've used this type of pseudo-classification ability before, but if not, it would be a passive ability like Storm Hammers with it's icon hidden using button positions X: 0, Y: -11.
 
Last edited:
Level 11
Joined
Aug 24, 2022
Messages
432
Well, I still don't even know what is Unit Indexer and how to use it, but I'll keep your answer saved here. When improving the game itself, I may bump into this subject, and already have a starting lane.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Well, I still don't even know what is Unit Indexer and how to use it, but I'll keep your answer saved here. When improving the game itself, I may bump into this subject, and already have a starting lane.
Ah, could've sworn you had one in your map already.
^ Copy and paste the demo map triggers (should be one folder/trigger) into your map and from that point on the system will run automatically. The variables seen in my last post were provided by this system.

The quick summary:
Unit Indexing let's you to attach Variables to units. For example, let's attach a Special Effect to our casting unit and then destroy it 3 seconds later:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Cool Ability
  • Actions
    • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Human\DivineShield\DivineShieldTarget.mdl
    • Set Variable Cool_SFX[(Custom value of (Triggering unit))] = (Last created special effect)
    • Wait 3.00 seconds
    • Special Effect - Destroy Cool_SFX[(Custom value of (Triggering unit))]
This trigger is MUI thanks to the Unit Indexer. That means it will work for any number of units with this ability. Note that (Custom value) is a function that you have always been able to set/get for any unit. However, in this case it's been set by the Unit Indexer automatically.

HOWEVER, note that this trigger would break if a unit managed to cast this again while their previous cast was still active. But that's a separate problem and could easily be fixed. This example is simply meant to show how you can attach a variable to a unit by taking advantage of Unit Indexing.
 
Last edited:
Level 11
Joined
Aug 24, 2022
Messages
432
I'll study this and see how I can use, and how I could implement it, as I'm already using "Custom Unit Value". It is a fixed value to calculate the total bounty on creeps, and on heroes, I'm using it to call triggers like, for example, the "Random Hero Choice":

  • Random Player 1
    • Events
      • Player - Player 1 (Red) types a chat message containing -random as An exact match
      • Player - Player 1 (Red) types a chat message containing -r as An exact match
    • Conditions
    • Actions
      • Set VariableSet Temp_Char_Randomed = (Random integer number between 1 and 29)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Playable_Characters[Temp_Char_Randomed] Not equal to Playable_Characters[0]
        • Then - Actions
          • Unit - Create 1 Playable_Characters[Temp_Char_Randomed] for (Triggering player) at Hero_Spawn_Point facing Default building facing degrees
          • Hero - Create (Random level 1.Artifact item-type) and give it to (Last created unit)
          • Unit Group - Add (Last created unit) to Player_Hero_Group
          • Selection - Select (Last created unit) for (Owner of (Last created unit))
          • Set VariableSet Player_Hero_Alive = (Player_Hero_Alive + 1)
          • Neutral Building - Remove Playable_Characters[(Point-value of (Last created unit))] from all marketplaces
          • Camera - Pan camera for (Triggering player) to (Position of (Last created unit)) over 0.00 seconds
          • Game - Display to (All players) the text: (Player_Colors[(Player number of (Triggering player))] + ( has randomed the + Characters_Names[Temp_Char_Randomed]))
          • Unit - Kill (Random unit from (Units in Players Souls <gen> owned by (Triggering player)))
          • Set VariableSet Playable_Characters[Temp_Char_Randomed] = Playable_Characters[0]
          • Set VariableSet Temp_Char_Randomed = 0
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Trigger - Run (This trigger) (checking conditions)
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'll study this and see how I can use, and how I could implement it, as I'm already using "Custom Unit Value". It is a fixed value to calculate the total bounty on creeps, and on heroes, I'm using it to call triggers like, for example, the "Random Hero Choice":
The solution is very easy assuming you haven't set it in too many places.

Simply switch any case of you setting it yourself with a new Integer array variable.

So this:
  • Unit - Set custom value of (Triggering unit) to 5
Becomes this:
  • Set Variable Total_Bounty[(Custom value of (Triggering unit))] = 5
Then when you want to add the bonus bounty you would reference this variable:
  • Player - Add Total_Bounty[(Custom value of (Dying unit))] to (Owner of (Killing unit))'s current Gold
 
Level 11
Joined
Aug 24, 2022
Messages
432
I know that something good will come out from here haha! Thanks for your attention Uncle. The project is going very well here thanks to your teachings. A lot of things I've done all by myself after you explaining one or other thing.
 
Top