[Trigger] SOLVED: Leaving players breaking game system

Level 11
Joined
Aug 24, 2022
Messages
430
Hello once more, Hivers. Now, I come asking for some help to detect what I'm doing wrong. It's been a while since this problem occurs, and I always try to fix the problem, but I still didn't find what is missing or missplaced.

When someone leaves the game DURING the fight inside the arena, sometimes the trigger counts the leaving hero, and sometimes, doesn't count. With this, when all players die inside the arena, the game never ends, since the leaving player "life" is still counting.

I have this trigger, that is supposed to fire when a player leaves, sharing his resources to the remaining players, removing his units from the game, closing share options, that sort of thing:

  • Leaver Trigger
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
      • Player - Player 3 (Teal) leaves the game
      • Player - Player 4 (Purple) leaves the game
      • Player - Player 5 (Yellow) leaves the game
      • Player - Player 6 (Orange) leaves the game
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from Active_Players.
      • Set VariableSet Player_Currency[1] = (((Triggering player) Current gold) / (Number of players in (All players controlled by a User player)))
      • Set VariableSet Player_Currency[2] = (((Triggering player) Current lumber) / (Number of players in (All players controlled by a User player)))
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Game - Display to (Player group((Player((Integer A))))) the text: <Empty String>
          • Game - Display to (Player group((Player((Integer A))))) the text: (Player_Colors[(Player number of (Triggering player))] + has left the arena. What a coward!)
          • Game - Display to (Player group((Player((Integer A))))) the text: (The leaver + ( left |cffffff00 + ((String(Player_Currency[1])) + ( gold|r and |cff00ff00 + ((String(Player_Currency[2])) + souls|r for you.)))))
      • Unit Group - Pick every unit in (Units owned by (Triggering player).) and do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot 1 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Hero - Drop the item from slot 2 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Hero - Drop the item from slot 3 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Hero - Drop the item from slot 4 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Hero - Drop the item from slot 5 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Hero - Drop the item from slot 6 of (Picked unit).
          • Item - Move (Last dropped item) to (Random point in Item Stash Arena <gen>)
          • Unit - Remove (Picked unit) from the game
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Player - Make (Picked player) treat (Triggering player) as an Enemy
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player - Add Player_Currency[1] to (Picked player).Current gold
              • Player - Add Player_Currency[2] to (Picked player).Current lumber
            • Else - Actions
      • Trigger - Run Arena Unit Dies <gen> (checking conditions)
      • Trigger - Run Handicap System <gen> (checking conditions)

This is the "Arena Unit Dies" trigger that fires:

  • Arena Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) belongs to an ally of Player 8 (Pink).) Equal to True
          • ((Triggering unit) is Summoned) Equal to False
          • ((Triggering unit) is Magic Immune) Equal to False
        • Then - Actions
          • -------- ARENA ENEMY DIED (Non-Summoned): --------
          • Unit Group - Remove (Triggering unit) from Arena_Enemy_Group.
          • -------- --------
          • Set VariableSet Arena_Enemy_Alive = (Arena_Enemy_Alive - 1)
          • Set VariableSet Kill_Counter = (Kill_Counter + 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Arena_Enemy_Alive Equal to 0
            • Then - Actions
              • Trigger - Run Arena Players Win Wave <gen> (ignoring conditions)
              • Trigger - Run Tier Change Event <gen> (checking conditions)
            • Else - Actions
        • Else - Actions
          • -------- PLAYER HERO DIED: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is A Hero) Equal to True
              • ((Triggering unit) is an illusion) Equal to False
            • Then - Actions
              • Set VariableSet Player_Hero_Alive = (Player_Hero_Alive - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Player_Hero_Alive Equal to 0
                • Then - Actions
                  • Trigger - Run Arena Players Lose Wave <gen> (ignoring conditions)
                • Else - Actions
            • Else - Actions

And this one is the Handicap System:

  • Handicap System
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in (All allies of Player 1 (Red).)) Equal to 5
        • Then - Actions
          • Player Group - Pick every player in (All allies of Player 1 (Red).) and do (Hero - Make (Picked player) Heroes gain 80.00% experience from future kills)
          • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Set (Picked player) handicap to 88.00%)
          • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Make (Picked player)'s units deal 88.00% of normal damage)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in (All allies of Player 1 (Red).)) Equal to 4
            • Then - Actions
              • Player Group - Pick every player in (All allies of Player 1 (Red).) and do (Hero - Make (Picked player) Heroes gain 63.00% experience from future kills)
              • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Set (Picked player) handicap to 76.00%)
              • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Make (Picked player)'s units deal 76.00% of normal damage)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of players in (All allies of Player 1 (Red).)) Equal to 3
                • Then - Actions
                  • Player Group - Pick every player in (All allies of Player 1 (Red).) and do (Hero - Make (Picked player) Heroes gain 46.00% experience from future kills)
                  • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Set (Picked player) handicap to 64.00%)
                  • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Make (Picked player)'s units deal 64.00% of normal damage)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of players in (All allies of Player 1 (Red).)) Equal to 2
                    • Then - Actions
                      • Player Group - Pick every player in (All allies of Player 1 (Red).) and do (Hero - Make (Picked player) Heroes gain 29.00% experience from future kills)
                      • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Set (Picked player) handicap to 52.00%)
                      • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Make (Picked player)'s units deal 52.00% of normal damage)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of players in (All allies of Player 1 (Red).)) Equal to 1
                        • Then - Actions
                          • Player Group - Pick every player in (All allies of Player 1 (Red).) and do (Hero - Make (Picked player) Heroes gain 12.00% experience from future kills)
                          • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Set (Picked player) handicap to 40.00%)
                          • Player Group - Pick every player in (All allies of Player 8 (Pink).) and do (Player - Make (Picked player)'s units deal 40.00% of normal damage)
                        • Else - Actions
                          • Do nothing

What am I letting pass, that is causing this trouble? I couldn't find, and I already tried some weeks before coming here and asking for help.

Thanks in advance.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Running "Run Arena Unit Dies <gen>" on player leaves is worthless since there isnt a triggering unit when run that way, so all conditions with triggering unit will return false results.

The important part is probably that when a player leaves that is alive the "Set VariableSet Player_Hero_Alive = (Player_Hero_Alive - 1)" part never occurs.
 
Level 4
Joined
Oct 11, 2017
Messages
37
Running a trigger through an action does not register any event responses, so instead, simply kill all units from the leaving player, and the trigger will run by it's own terms.
 
Level 24
Joined
Feb 27, 2019
Messages
833
Killing the unit could work, unless it has an ankh or reincarnation which doesnt trigger the A unit dies event. In any case I suggest removing it after, which should be fine instantly since removed units linger for a frame, to avoid it being bought back from a shop. In essence: Ankh and Reincarnation doesnt trigger the event A unit dies. The hero can be bought back unless its removed.
 
Level 4
Joined
Oct 11, 2017
Messages
37
Killing the unit could work, unless it has an ankh or reincarnation which doesnt trigger the A unit dies event. In any case I suggest removing it after, which should be fine instantly since removed units linger for a frame, to avoid it being bought back from a shop. In essence: Ankh and Reincarnation doesnt trigger the event A unit dies. The hero can be bought back unless its removed.
@Barbafire's "Player Leaves" trigger already drops all items from all units, so that's why I haven't worried about it
 
Level 11
Joined
Aug 24, 2022
Messages
430
Running a trigger through an action does not register any event responses, so instead, simply kill all units from the leaving player, and the trigger will run by it's own terms.
I've already tried to simply kill all his units, and when this happens inside the base, it can (not always) trigger the "Arena Lose Wave", that is when all players die. Maybe value gets 0 or negative when killing units. Also, the majority of times, players leave the game AFTER dying inside it, and that's when the bug occurs.

Running "Run Arena Unit Dies <gen>" on player leaves is worthless since there isnt a triggering unit when run that way, so all conditions with triggering unit will return false results.

The important part is probably that when a player leaves that is alive the "Set VariableSet Player_Hero_Alive = (Player_Hero_Alive - 1)" part never occurs.
Reading this, I think the best option is to stop re-using the same trigger from the arena system, and create a custom one just for this event. For that, I need to sit a little and think about it.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I've already tried to simply kill all his units, and when this happens inside the base, it can (not always) trigger the "Arena Lose Wave", that is when all players die. Maybe value gets 0 or negative when killing units. Also, the majority of times, players leave the game AFTER dying inside it, and that's when the bug occurs.


Reading this, I think the best option is to stop re-using the same trigger from the arena system, and create a custom one just for this event. For that, I need to sit a little and think about it.
It's not that complicated, put one central trigger for counting someone as "out of the game" and run it (checking conditions) when necessary:
  • Events
  • Conditions
    • Has_Lost_The_Game[(Player number of Losing_Player)] = False
  • Actions
    • Has_Lost_The_Game[(Player number of Losing_Player)] = True
    • ... Run your actions related to someone losing
You would Set Losing_Player before running this trigger to the Player that has "lost" the game.

This would ensure that someone can only lose once.

You also need to ensure that your Heroes always die. There are effects in this game that may skip "A unt Dies", like Removal, and you need to avoid those.
 
Level 11
Joined
Aug 24, 2022
Messages
430
I've spent some time to solve this problem, and as Uncle said, it was easy to fix. The new trigger received the lines below, and the problem is now solved:
  • Leaver Trigger
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Player_Lose[(Player number of (Triggering player))] Equal to True
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Player_Hero_Alive Equal to 0
          • Then - Actions
            • Trigger - Run Arena Players Lose Wave <gen> (ignoring conditions)
          • Else - Actions
      • Else - Actions
        • Set VariableSet Player_Hero_Alive = (Player_Hero_Alive - 1)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Player_Hero_Alive Equal to 0
          • Then - Actions
            • Trigger - Run Arena Players Lose Wave <gen> (ignoring conditions)
          • Else - Actions
    • Trigger - Run Handicap System <gen> (checking conditions)
 
Top