Trying to Combine Two Triggers That do Very Similar Things

Level 21
Joined
Mar 16, 2008
Messages
955
These are triggers that handle alliance changes in my map. One of these triggers skips the dialog menu if the player is an AI or if it's the first 90 sec of the game. Then the other runs the trigger depending on the dialog menu acepted. Multiple players use these triggers. It's annoying to need to remember to edit both. So I want to combine them. But I can't think of a good way to do it.

  • Universal Cast Join
    • Events
      • Unit - Altar of Knights 0225 <gen> Begins casting an ability
      • Unit - Altar of Knights 0226 <gen> Begins casting an ability
      • Unit - Altar of Knights 0227 <gen> Begins casting an ability
      • Unit - Altar of Knights 0319 <gen> Begins casting an ability
      • Unit - Altar of Knights 0320 <gen> Begins casting an ability
      • Unit - Altar of Knights 0326 <gen> Begins casting an ability
      • Unit - Altar of Knights 0340 <gen> Begins casting an ability
      • Unit - Altar of Knights 0341 <gen> Begins casting an ability
      • Unit - Altar of Knights 0342 <gen> Begins casting an ability
      • Unit - Altar of Knights 0343 <gen> Begins casting an ability
      • Unit - Altar of Knights 0352 <gen> Begins casting an ability
      • Unit - Altar of Knights 0504 <gen> Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
    • Actions
      • Set VariableSet PN_cast_join = (Player number of (Owner of (Casting unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
        • Then - Actions
          • Set VariableSet join_target = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
        • Then - Actions
          • Set VariableSet join_target = 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
        • Then - Actions
          • Set VariableSet join_target = 3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
        • Then - Actions
          • Set VariableSet join_target = 4
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Castle_Alive[join_target] Equal to False
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • joining_enabled Equal to False
        • Then - Actions
          • Quest - Display to solo_group[PN_cast_join] the Hint message: |cff808080Knights m...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • join_CD[PN_cast_join] Equal to True
        • Then - Actions
          • Quest - Display to solo_group[PN_cast_join] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[join_target] Current gold) Less than 1000
        • Then - Actions
          • Quest - Display to solo_group[PN_cast_join] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • kingdom_knight_cap[join_target] Greater than or equal to limits_max_knights
        • Then - Actions
          • Quest - Display to solo_group[PN_cast_join] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Hero_Var[PN_cast_join] is being transported) Equal to True
        • Then - Actions
          • Quest - Display to solo_group[PN_cast_join] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[PN_cast_join] is in Groups[join_target].) Equal to True
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • Dialog - Hide dialog_join[PN_cast_join] for Player 1 (Red)
      • Dialog - Hide dialog_join[PN_cast_join] for Player 2 (Blue)
      • Dialog - Hide dialog_join[PN_cast_join] for Player 3 (Teal)
      • Dialog - Hide dialog_join[PN_cast_join] for Player 4 (Purple)
      • -------- --------
      • -------- this will automatically join the knight to the king if it's before 90 sec or if the king is running an AI script --------
      • -------- it's pretty much a copy paste of the main part of the "Universal Accept" trigger --------
      • -------- this part runs if the king is AI or it's first 90 sec of the game, to avoid the annoyance of dialogs at this point --------
      • -------- it's pretty much redundant with the accept trigger --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ninty_sec_time Equal to False
              • ai_king[join_target] Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[join_target] Current gold) Greater than 1000
            • Then - Actions
              • Player - Add -1000 to Player_array_var[join_target].Current gold
            • Else - Actions
              • Player - Set Player_array_var[join_target].Current gold to 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Unit Inventory (Human, no use items) for Knight_Altar_Var[PN_cast_join]) Equal to 1
            • Then - Actions
            • Else - Actions
              • Unit - Add Unit Inventory (Human, no use items) to Knight_Altar_Var[PN_cast_join]
          • Unit - Remove Mark of Black Knights from Knight_Altar_Var[PN_cast_join]
          • Unit - Remove Mark of Black Knights from Knight_Hero_Var[PN_cast_join]
          • Set VariableSet units_owned[PN_cast_join] = (Units owned by Player_array_var[PN_cast_join].)
          • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) has an item of type Midnight Ankh) Equal to True
                      • ((Picked unit) has an item of type Plans: Black Tent) Equal to True
                • Then - Actions
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[5].) Equal to True
            • Then - Actions
              • Item - Pick every item in (Entire map) and do (If (Midnight Ankh Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
              • Item - Pick every item in (Entire map) and do (If (Plans: Black Tent Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
            • Else - Actions
          • Unit Group - Remove Knight_Hero_Var[PN_cast_join] from units_owned[PN_cast_join].
          • Unit Group - Remove Knight_Altar_Var[PN_cast_join] from units_owned[PN_cast_join].
          • Unit Group - Remove pirate_ship_unit[PN_cast_join] from units_owned[PN_cast_join].
          • Unit Group - Remove wisp_tree from units_owned[PN_cast_join].
          • Unit Group - Remove vault_array[PN_cast_join] from units_owned[PN_cast_join].
          • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Mark of Wisp Knight for (Picked unit)) Equal to 1
                      • (Level of Mark of Peasant Knight for (Picked unit)) Equal to 1
                      • (Unit-type of (Picked unit)) Equal to Pack Horse (King Unit)
                      • (Unit-type of (Picked unit)) Equal to Wagon
                      • (Unit-type of (Picked unit)) Equal to Passenger Ship
                      • (Unit-type of (Picked unit)) Equal to Red Riding Dragonling
                      • (Unit-type of (Picked unit)) Equal to Red Riding Dragon
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from units_owned[PN_cast_join].
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[1].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[2].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[3].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[4].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[PN_cast_join] is in Groups[5].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[PN_cast_join] and do (Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_units_owned[udg_PN_cast_join])
          • Set VariableSet loyalty_status[PN_cast_join] = 0
          • Countdown Timer - Pause loyalty_timer[PN_cast_join]
          • Countdown Timer - Start loyalty_timer[PN_cast_join] as a Repeating timer that will expire in 660.00 seconds
          • Unit - Remove hire_buttons_red[PN_cast_join] from the game
          • Unit - Remove hire_buttons_blue[PN_cast_join] from the game
          • Unit - Remove hire_buttons_teal[PN_cast_join] from the game
          • Unit - Remove hire_buttons_purp[PN_cast_join] from the game
          • Countdown Timer - Start End_Timer as a One-shot timer that will expire in 0.10 seconds
          • Countdown Timer - Start End_Timer_Camera as a One-shot timer that will expire in 1.00 seconds
          • Countdown Timer - Start join_cd_timer[PN_cast_join] as a One-shot timer that will expire in 2.00 seconds
          • Set VariableSet join_CD[PN_cast_join] = True
          • Countdown Timer - Start allegiance_cd_timer[PN_cast_join] as a One-shot timer that will expire in 5.00 seconds
          • Hero - Make Player_array_var[PN_cast_join] Heroes gain 100.00% experience from future kills
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[0].
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[1].
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[2].
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[3].
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[4].
          • Player Group - Remove Player_array_var[PN_cast_join] from Groups[5].
          • Player Group - Add Player_array_var[PN_cast_join] to Groups[join_target]
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Royal Weapons for (Picked player)) Less than (Current research level of Royal Weapons for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Royal Weapons to (Current research level of Royal Weapons for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Royal Armor for (Picked player)) Less than (Current research level of Royal Armor for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Royal Armor to (Current research level of Royal Armor for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Improved Masonry for (Picked player)) Less than (Current research level of Improved Masonry for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Improved Masonry to (Current research level of Improved Masonry for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Black Gunpowder for (Picked player)) Less than (Current research level of Black Gunpowder for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Black Gunpowder to (Current research level of Black Gunpowder for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Animal Breeding for (Picked player)) Less than (Current research level of Animal Breeding for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Black Gunpowder to (Current research level of Black Gunpowder for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Sundering Blades for (Picked player)) Less than (Current research level of Sundering Blades for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Sundering Blades to (Current research level of Sundering Blades for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Magic Sentry for (Picked player)) Less than (Current research level of Magic Sentry for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Magic Sentry to (Current research level of Magic Sentry for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Flare for (Picked player)) Less than (Current research level of Flare for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Flare to (Current research level of Flare for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Arcanite Shields (upgrade) for (Picked player)) Less than (Current research level of Arcanite Shields (upgrade) for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Arcanite Shields (upgrade) to (Current research level of Arcanite Shields (upgrade) for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Improved Lumber Harvesting for (Picked player)) Less than (Current research level of Improved Lumber Harvesting for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Improved Lumber Harvesting to (Current research level of Improved Lumber Harvesting for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Rogue's Cloak for (Picked player)) Less than (Current research level of Rogue's Cloak for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Rogue's Cloak to (Current research level of Rogue's Cloak for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Royal Arcanist Adept Training for (Picked player)) Less than (Current research level of Royal Arcanist Adept Training for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Royal Arcanist Adept Training to (Current research level of Royal Arcanist Adept Training for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Priest Adept Training for (Picked player)) Less than (Current research level of Priest Adept Training for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Priest Adept Training to (Current research level of Priest Adept Training for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player Group - Pick every player in Groups[join_target] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Sorcery Upgrade for (Picked player)) Less than (Current research level of Sorcery Upgrade for Player_array_var[join_target])
                • Then - Actions
                  • Player - Set the current research level of Sorcery Upgrade to (Current research level of Sorcery Upgrade for Player_array_var[join_target]) for (Picked player)
                • Else - Actions
          • Player - Set the current research level of Gluttony to 0 for Player_array_var[PN_cast_join]
          • Player - Set Player_array_var[PN_cast_join].Food max to 99
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Knight_Altar_Var[PN_cast_join] is invulnerable) Equal to False
            • Then - Actions
              • Unit - Add Invulnerable (Neutral) to Knight_Altar_Var[PN_cast_join]
            • Else - Actions
          • Set VariableSet temp_point = (Position of Knight_Altar_Var[PN_cast_join])
          • Special Effect - Create a special effect at temp_point using Heavens Gate Channel.mdx
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_temp_point)
          • Special Effect - Create a special effect attached to the origin of Knight_Altar_Var[PN_cast_join] using Heavens Gate.mdx
          • Special Effect - Destroy (Last created special effect)
          • Unit - Move Knight_Altar_Var[PN_cast_join] instantly to (Load PN_cast_join of join_target in kni_king_altars_hashtable.)
          • Camera - Pan camera for Player_array_var[PN_cast_join] to (Load PN_cast_join of join_target in kni_king_altars_hashtable.) over 1.00 seconds
          • Cinematic - Ping minimap for solo_group[PN_cast_join] at (Load PN_cast_join of join_target in kni_king_altars_hashtable.) for 5.00 seconds
          • Quest - Display to (All players) the Quest Update message: (The + (player_color_knight_strings[PN_cast_join] + ( has pledged allegiance to the + (player_color_knight_strings[join_target] + .))))
          • Unit - Order Knight_Altar_Var[PN_cast_join] to Revive Hero Knight_Hero_Var[PN_cast_join]
          • Unit - Change color of Knight_Hero_Var[PN_cast_join] to player_color[join_target]
          • Leaderboard - Change the label for Player_array_var[PN_cast_join] in Alliances_Leaderboard to (kingdom_color_string[join_target] + (Name of Player_array_var[PN_cast_join]))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • join_target Equal to 1
            • Then - Actions
              • Leaderboard - Change the color of the label for Player_array_var[PN_cast_join] in Alliances_Leaderboard to (97.00%, 1.00%, 1.00%) with 0.00% transparency
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • join_target Equal to 2
            • Then - Actions
              • Leaderboard - Change the color of the label for Player_array_var[PN_cast_join] in Alliances_Leaderboard to (0.00%, 26.00%, 100.00%) with 0.00% transparency
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • join_target Equal to 3
            • Then - Actions
              • Leaderboard - Change the color of the label for Player_array_var[PN_cast_join] in Alliances_Leaderboard to (11.00%, 91.00%, 73.00%) with 0.00% transparency
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • join_target Equal to 4
            • Then - Actions
              • Leaderboard - Change the color of the label for Player_array_var[PN_cast_join] in Alliances_Leaderboard to (33.00%, 0.00%, 49.00%) with 0.00% transparency
            • Else - Actions
          • Leaderboard - Sort Alliances_Leaderboard by Label in Ascending order
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Knight_Hero_Var[PN_cast_join] is alive) Equal to True
              • (knght_room_region_array[PN_cast_join] contains Knight_Hero_Var[PN_cast_join]) Equal to True
            • Then - Actions
              • Unit - Move Knight_Hero_Var[PN_cast_join] instantly to king_vendor[join_target]
            • Else - Actions
          • -------- empty group --------
          • Player Group - Make Groups[0] treat Groups[0] as an Neutral
          • Player Group - Make Groups[0] treat Groups[1] as an Neutral
          • Player Group - Make Groups[0] treat Groups[2] as an Neutral
          • Player Group - Make Groups[0] treat Groups[3] as an Neutral
          • Player Group - Make Groups[0] treat Groups[4] as an Neutral
          • Player Group - Make Groups[0] treat Groups[5] as an Neutral
          • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
          • -------- red --------
          • Player Group - Make Groups[1] treat Groups[0] as an Enemy
          • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
          • Player Group - Make Groups[1] treat Groups[2] as an Enemy
          • Player Group - Make Groups[1] treat Groups[3] as an Enemy
          • Player Group - Make Groups[1] treat Groups[4] as an Enemy
          • Player Group - Make Groups[1] treat Groups[5] as an Enemy
          • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 1 (Red) treat Player 13 (Maroon) as an Neutral with shared vision
          • -------- blue --------
          • Player Group - Make Groups[2] treat Groups[0] as an Enemy
          • Player Group - Make Groups[2] treat Groups[1] as an Enemy
          • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
          • Player Group - Make Groups[2] treat Groups[3] as an Enemy
          • Player Group - Make Groups[2] treat Groups[4] as an Enemy
          • Player Group - Make Groups[2] treat Groups[5] as an Enemy
          • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 2 (Blue) treat Player 14 (Navy) as an Neutral with shared vision
          • -------- teal --------
          • Player Group - Make Groups[3] treat Groups[0] as an Enemy
          • Player Group - Make Groups[3] treat Groups[1] as an Enemy
          • Player Group - Make Groups[3] treat Groups[2] as an Enemy
          • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
          • Player Group - Make Groups[3] treat Groups[4] as an Enemy
          • Player Group - Make Groups[3] treat Groups[5] as an Enemy
          • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 3 (Teal) treat Player 15 (Turquoise) as an Neutral with shared vision
          • -------- purple --------
          • Player Group - Make Groups[4] treat Groups[0] as an Enemy
          • Player Group - Make Groups[4] treat Groups[1] as an Enemy
          • Player Group - Make Groups[4] treat Groups[2] as an Enemy
          • Player Group - Make Groups[4] treat Groups[3] as an Enemy
          • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
          • Player Group - Make Groups[4] treat Groups[5] as an Enemy
          • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 4 (Purple) treat Player 16 (Violet) as an Neutral with shared vision
          • -------- black --------
          • Player Group - Make Groups[5] treat Groups[0] as an Enemy
          • Player Group - Make Groups[5] treat Groups[1] as an Enemy
          • Player Group - Make Groups[5] treat Groups[2] as an Enemy
          • Player Group - Make Groups[5] treat Groups[3] as an Enemy
          • Player Group - Make Groups[5] treat Groups[4] as an Enemy
          • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
          • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
          • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
          • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
          • -------- white --------
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
          • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
          • -------- ------ --------
          • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
          • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
          • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
          • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
        • Else - Actions
          • Dialog - Hide dialog_join[5] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[6] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[7] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[8] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[9] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[10] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[11] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[12] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[17] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[18] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[19] for Player_array_var[join_target]
          • Dialog - Hide dialog_join[20] for Player_array_var[join_target]
          • Dialog - Show dialog_join[PN_cast_join] for Player_array_var[join_target]

  • Universal Accept
    • Events
      • Dialog - A dialog button is clicked for dialog_join[5]
      • Dialog - A dialog button is clicked for dialog_join[6]
      • Dialog - A dialog button is clicked for dialog_join[7]
      • Dialog - A dialog button is clicked for dialog_join[8]
      • Dialog - A dialog button is clicked for dialog_join[9]
      • Dialog - A dialog button is clicked for dialog_join[10]
      • Dialog - A dialog button is clicked for dialog_join[11]
      • Dialog - A dialog button is clicked for dialog_join[12]
      • Dialog - A dialog button is clicked for dialog_join[17]
      • Dialog - A dialog button is clicked for dialog_join[18]
      • Dialog - A dialog button is clicked for dialog_join[19]
      • Dialog - A dialog button is clicked for dialog_join[20]
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Red
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Blue
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Teal
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Purp
    • Conditions
    • Actions
      • -------- this first condition checks if knight or king is the accepting party --------
      • -------- the "then" part is if king is accpeting the knights request to join --------
      • -------- the "else" part checks if the king is offering for the knight to join --------
      • -------- ...and sets variables accordingly --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Triggering player) Equal to Player 1 (Red)
              • (Triggering player) Equal to Player 2 (Blue)
              • (Triggering player) Equal to Player 3 (Teal)
              • (Triggering player) Equal to Player 4 (Purple)
        • Then - Actions
          • Set VariableSet PN_accept = (Player number of (Triggering player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[5]
            • Then - Actions
              • Set VariableSet accepted_knight = 5
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[6]
            • Then - Actions
              • Set VariableSet accepted_knight = 6
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[7]
            • Then - Actions
              • Set VariableSet accepted_knight = 7
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[8]
            • Then - Actions
              • Set VariableSet accepted_knight = 8
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[9]
            • Then - Actions
              • Set VariableSet accepted_knight = 9
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[10]
            • Then - Actions
              • Set VariableSet accepted_knight = 10
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[11]
            • Then - Actions
              • Set VariableSet accepted_knight = 11
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[12]
            • Then - Actions
              • Set VariableSet accepted_knight = 12
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[17]
            • Then - Actions
              • Set VariableSet accepted_knight = 17
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[18]
            • Then - Actions
              • Set VariableSet accepted_knight = 18
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[19]
            • Then - Actions
              • Set VariableSet accepted_knight = 19
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[20]
            • Then - Actions
              • Set VariableSet accepted_knight = 20
            • Else - Actions
          • Dialog - Hide dialog_join[accepted_knight] for Player_array_var[PN_accept]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_decline[accepted_knight]
            • Then - Actions
              • Unit - For Unit Knight_Altar_Var[accepted_knight], start cooldown of ability pledge_spells[PN_accept] " over "kingdom_join_CD seconds.
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
          • Set VariableSet accepted_knight = (Player number of (Triggering player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Red
            • Then - Actions
              • Set VariableSet PN_accept = 1
              • Dialog - Hide Hire_Dialog_Menu_Red for Player_array_var[PN_accept]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Red
            • Then - Actions
              • Set VariableSet PN_accept = 1
              • Quest - Display to solo_group[PN_accept] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Blue
            • Then - Actions
              • Set VariableSet PN_accept = 2
              • Dialog - Hide Hire_Dialog_Menu_Blue for Player_array_var[PN_accept]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Blue
            • Then - Actions
              • Set VariableSet PN_accept = 2
              • Quest - Display to solo_group[PN_accept] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Teal
            • Then - Actions
              • Set VariableSet PN_accept = 3
              • Dialog - Hide Hire_Dialog_Menu_Teal for Player_array_var[PN_accept]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Teal
            • Then - Actions
              • Set VariableSet PN_accept = 3
              • Quest - Display to solo_group[PN_accept] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Purp
            • Then - Actions
              • Set VariableSet PN_accept = 4
              • Dialog - Hide Hire_Dialog_Menu_Purp for Player_array_var[PN_accept]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Purp
            • Then - Actions
              • Set VariableSet PN_accept = 4
              • Quest - Display to solo_group[PN_accept] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
      • -------- -------------- --------
      • -------- this is the main part of the trigger that sets up the alliance, moves units, etc --------
      • -------- -------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[PN_accept] Current gold) Greater than 1000
        • Then - Actions
          • Player - Add -1000 to Player_array_var[PN_accept].Current gold
        • Else - Actions
          • Player - Set Player_array_var[PN_accept].Current gold to 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Unit Inventory (Human, no use items) for Knight_Altar_Var[accepted_knight]) Equal to 1
        • Then - Actions
        • Else - Actions
          • Unit - Add Unit Inventory (Human, no use items) to Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Hero_Var[accepted_knight]
      • Set VariableSet units_owned[accepted_knight] = (Units owned by Player_array_var[accepted_knight].)
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) has an item of type Midnight Ankh) Equal to True
                  • ((Picked unit) has an item of type Plans: Black Tent) Equal to True
            • Then - Actions
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Item - Pick every item in (Entire map) and do (If (Midnight Ankh Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
          • Item - Pick every item in (Entire map) and do (If (Plans: Black Tent Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
        • Else - Actions
      • Unit Group - Remove Knight_Hero_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove Knight_Altar_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove pirate_ship_unit[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove wisp_tree from units_owned[accepted_knight].
      • Unit Group - Remove vault_array[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Level of Mark of Wisp Knight for (Picked unit)) Equal to 1
                  • (Level of Mark of Peasant Knight for (Picked unit)) Equal to 1
                  • (Unit-type of (Picked unit)) Equal to Pack Horse (King Unit)
                  • (Unit-type of (Picked unit)) Equal to Wagon
                  • (Unit-type of (Picked unit)) Equal to Passenger Ship
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragonling
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragon
            • Then - Actions
              • Unit Group - Remove (Picked unit) from units_owned[accepted_knight].
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[1].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[2].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[3].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[4].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_units_owned[udg_accepted_knight])
      • Set VariableSet loyalty_status[accepted_knight] = 0
      • Countdown Timer - Pause loyalty_timer[accepted_knight]
      • Countdown Timer - Start loyalty_timer[accepted_knight] as a Repeating timer that will expire in 660.00 seconds
      • Unit - Remove hire_buttons_red[accepted_knight] from the game
      • Unit - Remove hire_buttons_blue[accepted_knight] from the game
      • Unit - Remove hire_buttons_teal[accepted_knight] from the game
      • Unit - Remove hire_buttons_purp[accepted_knight] from the game
      • Countdown Timer - Start End_Timer as a One-shot timer that will expire in 0.10 seconds
      • Countdown Timer - Start End_Timer_Camera as a One-shot timer that will expire in 1.00 seconds
      • Countdown Timer - Start join_cd_timer[accepted_knight] as a One-shot timer that will expire in 2.00 seconds
      • Set VariableSet join_CD[accepted_knight] = True
      • Countdown Timer - Start allegiance_cd_timer[accepted_knight] as a One-shot timer that will expire in 5.00 seconds
      • Hero - Make Player_array_var[accepted_knight] Heroes gain 100.00% experience from future kills
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[0].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[1].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[2].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[3].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[4].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[5].
      • Player Group - Add Player_array_var[accepted_knight] to Groups[PN_accept]
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Royal Weapons for (Picked player)) Less than (Current research level of Royal Weapons for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Royal Weapons to (Current research level of Royal Weapons for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Royal Armor for (Picked player)) Less than (Current research level of Royal Armor for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Royal Armor to (Current research level of Royal Armor for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Improved Masonry for (Picked player)) Less than (Current research level of Improved Masonry for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Improved Masonry to (Current research level of Improved Masonry for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Black Gunpowder for (Picked player)) Less than (Current research level of Black Gunpowder for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Black Gunpowder to (Current research level of Black Gunpowder for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Animal Breeding for (Picked player)) Less than (Current research level of Animal Breeding for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Black Gunpowder to (Current research level of Black Gunpowder for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Sundering Blades for (Picked player)) Less than (Current research level of Sundering Blades for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Sundering Blades to (Current research level of Sundering Blades for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Magic Sentry for (Picked player)) Less than (Current research level of Magic Sentry for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Magic Sentry to (Current research level of Magic Sentry for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Flare for (Picked player)) Less than (Current research level of Flare for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Flare to (Current research level of Flare for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Arcanite Shields (upgrade) for (Picked player)) Less than (Current research level of Arcanite Shields (upgrade) for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Arcanite Shields (upgrade) to (Current research level of Arcanite Shields (upgrade) for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Improved Lumber Harvesting for (Picked player)) Less than (Current research level of Improved Lumber Harvesting for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Improved Lumber Harvesting to (Current research level of Improved Lumber Harvesting for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Rogue's Cloak for (Picked player)) Less than (Current research level of Rogue's Cloak for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Rogue's Cloak to (Current research level of Rogue's Cloak for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Royal Arcanist Adept Training for (Picked player)) Less than (Current research level of Royal Arcanist Adept Training for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Royal Arcanist Adept Training to (Current research level of Royal Arcanist Adept Training for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Priest Adept Training for (Picked player)) Less than (Current research level of Priest Adept Training for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Priest Adept Training to (Current research level of Priest Adept Training for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player Group - Pick every player in Groups[PN_accept] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Sorcery Upgrade for (Picked player)) Less than (Current research level of Sorcery Upgrade for Player_array_var[PN_accept])
            • Then - Actions
              • Player - Set the current research level of Sorcery Upgrade to (Current research level of Sorcery Upgrade for Player_array_var[PN_accept]) for (Picked player)
            • Else - Actions
      • Player - Set the current research level of Gluttony to 0 for Player_array_var[accepted_knight]
      • Player - Set Player_array_var[accepted_knight].Food max to 99
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Altar_Var[accepted_knight] is invulnerable) Equal to False
        • Then - Actions
          • Unit - Add Invulnerable (Neutral) to Knight_Altar_Var[accepted_knight]
        • Else - Actions
      • Set VariableSet temp_point = (Position of Knight_Altar_Var[accepted_knight])
      • Special Effect - Create a special effect at temp_point using Heavens Gate Channel.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_temp_point)
      • Special Effect - Create a special effect attached to the origin of Knight_Altar_Var[accepted_knight] using Heavens Gate.mdx
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move Knight_Altar_Var[accepted_knight] instantly to (Load accepted_knight of PN_accept in kni_king_altars_hashtable.)
      • Camera - Pan camera for Player_array_var[accepted_knight] to (Load accepted_knight of PN_accept in kni_king_altars_hashtable.) over 1.00 seconds
      • Cinematic - Ping minimap for solo_group[accepted_knight] at (Load accepted_knight of PN_accept in kni_king_altars_hashtable.) for 5.00 seconds
      • Quest - Display to (All players) the Quest Update message: (The + (player_color_knight_strings[accepted_knight] + ( has pledged allegiance to the + (player_color_knight_strings[PN_accept] + .))))
      • Unit - Order Knight_Altar_Var[accepted_knight] to Revive Hero Knight_Hero_Var[accepted_knight]
      • Unit - Change color of Knight_Hero_Var[accepted_knight] to player_color[PN_accept]
      • Leaderboard - Change the label for Player_array_var[accepted_knight] in Alliances_Leaderboard to (kingdom_color_string[PN_accept] + (Name of Player_array_var[accepted_knight]))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN_accept Equal to 1
        • Then - Actions
          • Leaderboard - Change the color of the label for Player_array_var[accepted_knight] in Alliances_Leaderboard to (97.00%, 1.00%, 1.00%) with 0.00% transparency
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN_accept Equal to 2
        • Then - Actions
          • Leaderboard - Change the color of the label for Player_array_var[accepted_knight] in Alliances_Leaderboard to (0.00%, 26.00%, 100.00%) with 0.00% transparency
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN_accept Equal to 3
        • Then - Actions
          • Leaderboard - Change the color of the label for Player_array_var[accepted_knight] in Alliances_Leaderboard to (11.00%, 91.00%, 73.00%) with 0.00% transparency
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN_accept Equal to 4
        • Then - Actions
          • Leaderboard - Change the color of the label for Player_array_var[accepted_knight] in Alliances_Leaderboard to (33.00%, 0.00%, 49.00%) with 0.00% transparency
        • Else - Actions
      • Leaderboard - Sort Alliances_Leaderboard by Label in Ascending order
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Hero_Var[accepted_knight] is alive) Equal to True
          • (knght_room_region_array[accepted_knight] contains Knight_Hero_Var[accepted_knight]) Equal to True
        • Then - Actions
          • Unit - Move Knight_Hero_Var[accepted_knight] instantly to king_vendor[PN_accept]
        • Else - Actions
      • -------- end main part of join trigger --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- this next part is just generic stuff to reset all alliances, since a player has changed groups --------
      • -------- empty group --------
      • Player Group - Make Groups[0] treat Groups[0] as an Neutral
      • Player Group - Make Groups[0] treat Groups[1] as an Neutral
      • Player Group - Make Groups[0] treat Groups[2] as an Neutral
      • Player Group - Make Groups[0] treat Groups[3] as an Neutral
      • Player Group - Make Groups[0] treat Groups[4] as an Neutral
      • Player Group - Make Groups[0] treat Groups[5] as an Neutral
      • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
      • -------- red --------
      • Player Group - Make Groups[1] treat Groups[0] as an Enemy
      • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
      • Player Group - Make Groups[1] treat Groups[2] as an Enemy
      • Player Group - Make Groups[1] treat Groups[3] as an Enemy
      • Player Group - Make Groups[1] treat Groups[4] as an Enemy
      • Player Group - Make Groups[1] treat Groups[5] as an Enemy
      • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 1 (Red) treat Player 13 (Maroon) as an Neutral with shared vision
      • -------- blue --------
      • Player Group - Make Groups[2] treat Groups[0] as an Enemy
      • Player Group - Make Groups[2] treat Groups[1] as an Enemy
      • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
      • Player Group - Make Groups[2] treat Groups[3] as an Enemy
      • Player Group - Make Groups[2] treat Groups[4] as an Enemy
      • Player Group - Make Groups[2] treat Groups[5] as an Enemy
      • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 2 (Blue) treat Player 14 (Navy) as an Neutral with shared vision
      • -------- teal --------
      • Player Group - Make Groups[3] treat Groups[0] as an Enemy
      • Player Group - Make Groups[3] treat Groups[1] as an Enemy
      • Player Group - Make Groups[3] treat Groups[2] as an Enemy
      • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
      • Player Group - Make Groups[3] treat Groups[4] as an Enemy
      • Player Group - Make Groups[3] treat Groups[5] as an Enemy
      • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 3 (Teal) treat Player 15 (Turquoise) as an Neutral with shared vision
      • -------- purple --------
      • Player Group - Make Groups[4] treat Groups[0] as an Enemy
      • Player Group - Make Groups[4] treat Groups[1] as an Enemy
      • Player Group - Make Groups[4] treat Groups[2] as an Enemy
      • Player Group - Make Groups[4] treat Groups[3] as an Enemy
      • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
      • Player Group - Make Groups[4] treat Groups[5] as an Enemy
      • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 4 (Purple) treat Player 16 (Violet) as an Neutral with shared vision
      • -------- black --------
      • Player Group - Make Groups[5] treat Groups[0] as an Enemy
      • Player Group - Make Groups[5] treat Groups[1] as an Enemy
      • Player Group - Make Groups[5] treat Groups[2] as an Enemy
      • Player Group - Make Groups[5] treat Groups[3] as an Enemy
      • Player Group - Make Groups[5] treat Groups[4] as an Enemy
      • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
      • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
      • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
      • -------- white --------
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
      • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
      • -------- ------ --------
      • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
      • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
      • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
      • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • no_knight_cap Equal to False
          • teams_locked Equal to False
        • Then - Actions
          • Countdown Timer - Pause knight_max_calculate_timer
          • Countdown Timer - Start knight_max_calculate_timer as a One-shot timer that will expire in 2.00 seconds
        • Else - Actions
 
I'm guessing the main area of concern is the player alliance adjustments? (e.g. where it says -- empty group --, -- red --, --blue --, etc.)

If so, if they are exactly the same, then you can copy it into a separate trigger with no events:
  • Update Alliances
    • Events
    • Conditions
    • Actions
      • -------- this next part is just generic stuff to reset all alliances, since a player has changed groups --------
      • -------- empty group --------
      • Player Group - Make Groups[0] treat Groups[0] as an Neutral
      • Player Group - Make Groups[0] treat Groups[1] as an Neutral
      • Player Group - Make Groups[0] treat Groups[2] as an Neutral
      • Player Group - Make Groups[0] treat Groups[3] as an Neutral
      • Player Group - Make Groups[0] treat Groups[4] as an Neutral
      • Player Group - Make Groups[0] treat Groups[5] as an Neutral
      • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
      • -------- red --------
      • Player Group - Make Groups[1] treat Groups[0] as an Enemy
      • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
      • Player Group - Make Groups[1] treat Groups[2] as an Enemy
      • Player Group - Make Groups[1] treat Groups[3] as an Enemy
      • Player Group - Make Groups[1] treat Groups[4] as an Enemy
      • Player Group - Make Groups[1] treat Groups[5] as an Enemy
      • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 1 (Red) treat Player 13 (Maroon) as an Neutral with shared vision
      • -------- blue --------
      • Player Group - Make Groups[2] treat Groups[0] as an Enemy
      • Player Group - Make Groups[2] treat Groups[1] as an Enemy
      • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
      • Player Group - Make Groups[2] treat Groups[3] as an Enemy
      • Player Group - Make Groups[2] treat Groups[4] as an Enemy
      • Player Group - Make Groups[2] treat Groups[5] as an Enemy
      • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 2 (Blue) treat Player 14 (Navy) as an Neutral with shared vision
      • -------- teal --------
      • Player Group - Make Groups[3] treat Groups[0] as an Enemy
      • Player Group - Make Groups[3] treat Groups[1] as an Enemy
      • Player Group - Make Groups[3] treat Groups[2] as an Enemy
      • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
      • Player Group - Make Groups[3] treat Groups[4] as an Enemy
      • Player Group - Make Groups[3] treat Groups[5] as an Enemy
      • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 3 (Teal) treat Player 15 (Turquoise) as an Neutral with shared vision
      • -------- purple --------
      • Player Group - Make Groups[4] treat Groups[0] as an Enemy
      • Player Group - Make Groups[4] treat Groups[1] as an Enemy
      • Player Group - Make Groups[4] treat Groups[2] as an Enemy
      • Player Group - Make Groups[4] treat Groups[3] as an Enemy
      • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
      • Player Group - Make Groups[4] treat Groups[5] as an Enemy
      • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 4 (Purple) treat Player 16 (Violet) as an Neutral with shared vision
      • -------- black --------
      • Player Group - Make Groups[5] treat Groups[0] as an Enemy
      • Player Group - Make Groups[5] treat Groups[1] as an Enemy
      • Player Group - Make Groups[5] treat Groups[2] as an Enemy
      • Player Group - Make Groups[5] treat Groups[3] as an Enemy
      • Player Group - Make Groups[5] treat Groups[4] as an Enemy
      • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
      • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
      • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
      • -------- white --------
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
      • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
      • -------- ------ --------
      • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
      • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
      • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
      • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
Then you can just run it in those two triggers:
  • Trigger - Run Update Alliances <gen> (ignoring conditions)
This way you get to re-use the code and maintain it in a single place.

If there are any parts that need to change for one trigger vs. the other, you can make a dedicated variable for that to be treated as a parameter, e.g.
  • Set MySpecialGroup = Groups[0]
  • Trigger - Run Update Alliances <gen> (ignoring conditions)
  • -------- and then in "Update Alliances" you would use "MySpecialGroup" --------
 
Level 21
Joined
Mar 16, 2008
Messages
955
I was more thinking the other part of the trigger since they have different triggering events, one is based off dialog response and the other is based off the player requesting the alliance change but it skips the dialog first 90 seconds. but I want to combine them because it's annoying to edit both anytime I make a change. Your suggestions helps either way though. Thanks.
 
Ah gotcha--I see which part you're talking about. Then I would still move the common parts to its own trigger, and then use variables for the parts that need to be customized.

For example, the parts that differ between those parts in the two triggers are mostly just the indices:
  • PN_cast_join vs. accepted_knight
  • join_target vs. PN_accept
So I would make integer variables for those, e.g. PN_TriggeringPlayer and PN_To_Join. Copy and paste the common parts of those triggers into their own trigger, and update the index to use those variables.

Then you would just run that helper trigger in each trigger accordingly, e.g.:
  • -------- Universal Cast Join --------
  • Set PN_TriggeringPlayer = PN_cast_join
  • Set PN_To_Join = join_target
  • Trigger - Run Join Party <gen> (ignoring conditions)
  • -------- Universal Accept --------
  • Set PN_TriggeringPlayer = accepted_knight
  • Set PN_To_Join = PN_accept
  • Trigger - Run Join Party <gen> (ignoring conditions)
This can be really handy for easy maintenance too (and these sorts of "reusable functions" are at the heart of efficient programming). Doing this, combined with clever uses of arrays and loops, can make the code a lot easier to build on top of.



Just as another example, the code for updating the player's research level is a bit repetitive and probably is clunky to manage. You could do something similar by extracting the logic into a generic trigger "Update Tech Levels", like so:
  • Update Tech Levels
    • Events
    • Conditions
    • Actions
      • -------- --------
      • -------- Parameter 1: UTL_PlayerGroup (Player Group) --------
      • -------- Parameter 2: UTL_JoinTarget (Player) --------
      • -------- Parameter 3: UTL_TechType (Tech-Type Array) --------
      • -------- --------
      • For each (Integer A) from 1 to 8191, do (Actions)
        • Loop - Actions
          • -------- --------
          • -------- Once we reach the end of the array, skip remaining actions --------
          • -------- --------
          • Custom script: if udg_UTL_TechType[bj_forLoopAIndex] == 0 then
          • Skip remaining actions
          • Custom script: endif
          • -------- --------
          • -------- Main Logic To Update Research Level --------
          • -------- --------
          • Player Group - Pick every player in UTL_PlayerGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of UTL_TechType[(Integer A)] for (Picked player)) Less than (Current research level of UTL_TechType[(Integer A)] for UTL_JoinTarget)
                • Then - Actions
                  • Player - Set the current research level of UTL_TechType[(Integer A)] to (Current research level of UTL_TechType[(Integer A)] for UTL_JoinTarget) for (Picked player)
                • Else - Actions
          • -------- --------
          • -------- Clear out the array in case we want to run this again with different parameters --------
          • -------- --------
          • Custom script: set udg_UTL_TechType[bj_forLoopAIndex] = 0
Then at the call-site, you just want to set up the necessary parameters accordingly:
  • Set VariableSet UTL_PlayerGroup = Groups[join_target]
  • Set VariableSet UTL_JoinTarget = Player_array_var[join_target]
  • Set VariableSet UTL_TechType[1] = Royal Weapons
  • Set VariableSet UTL_TechType[2] = Royal Armor
  • Set VariableSet UTL_TechType[3] = Improved Masonry
  • Set VariableSet UTL_TechType[4] = Black Gunpowder
  • Set VariableSet UTL_TechType[5] = Sundering Blades
  • Set VariableSet UTL_TechType[6] = Magic Sentry
  • Set VariableSet UTL_TechType[7] = Flare
  • Set VariableSet UTL_TechType[8] = Arcanite Shields
  • Set VariableSet UTL_TechType[9] = Improved Lumber Harvesting
  • Set VariableSet UTL_TechType[10] = Rogue's Cloak
  • Set VariableSet UTL_TechType[11] = Royal Arcanist Adept Training
  • Set VariableSet UTL_TechType[12] = Priest Adept Training
  • Set VariableSet UTL_TechType[13] = Sorcery Upgrade
  • Trigger - Run Update Tech Levels <gen> (ignoring conditions)
That way it becomes a lot easier to add to later on. :thumbs_up:
 
Level 21
Joined
Mar 16, 2008
Messages
955
  • -------- Universal Cast Join --------
  • Set PN_TriggeringPlayer = PN_cast_join
  • Set PN_To_Join = join_target
  • Trigger - Run Join Party <gen> (ignoring conditions)
  • -------- Universal Accept --------
  • Set PN_TriggeringPlayer = accepted_knight
  • Set PN_To_Join = PN_accept
  • Trigger - Run Join Party <gen> (ignoring conditions)
Couldn't variables get mixed up in a MUI situation? I think this is really the core of my question.

Thx! I'm still reading the entire post.

  • For each (Integer tech_loop_cast_integer) from 1 to 14, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[accepted_knight]) Less than (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[accepting_king])
        • Then - Actions
          • Player - Set the current research level of Tech_Type[tech_loop_cast_integer] to (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[accepting_king]) for Player_array_var[accepted_knight]
        • Else - Actions
Does this look right?
 
Last edited:
Couldn't variables get mixed up in a MUI situation? I think this is really the core of my question.
Good q! In this case, no--it won't cause issues with MUI, but I'll try to explain why.

MUI stands for multiple unit instanceability, which is just a fancy way of saying "hey, this code should work for two units triggering it at the same time". And typically, one big concern is that global variables will get unexpectedly overwritten and lead to bugs. However, it is important to keep in mind that Warcraft 3 runs its scripts single threaded. This means that even if two units die "at the same time", the triggers that respond to the "unit dies" event will not actually run in parallel. One trigger will run, complete its actions (or at least up to the first "wait")--and then the next trigger will run. This is really important, because it means that as long as we don't have waits/timers in our logic, our code will run in a predictable fashion!

That's why MUI is only a concern when you need to keep track of variables over some period of time. "Time" is the key part that causes the issue (e.g. waits, timers, or trying to store something until some game event naturally occurs later on), since that provides an opportunity for the variables to get overwritten. However, if your code is "instant" (no waits/timers/etc.), then you don't need to worry about having issues with MUI.

The one other caveat with global variables is to be wary of side-effects of your code that lead to variables being overwritten. If Warcraft 3 is running an action that triggers an event, it will fire the triggers that respond to that event before returning to finish the remaining actions of the original code. For example, if you kill a unit via code, it will immediately trigger the "unit dies" event (and therefore, any triggers using that event), before completing the next actions. For example, if you have two triggers like the ones below:
  • Test
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set VariableSet TestInt = 1
      • Unit - Kill Sorceress 0010 <gen>
      • Game - Display to (All players) the text: (String(TestInt))
  • UnitDeath
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set VariableSet TestInt = 2
It will print "2", since the "Unit - Kill Sorceress" line triggers "UnitDeath" to run to completion before it returns to display the message. This can be quite tricky to debug, but generally you can stay safe by using unique variables for each trigger. And for loops, it is generally a good practice to use a unique integer variable (like the one you had with tech_loop_cast_integer).



The TL;DR version is: as long as you use unique variables for your trigger and you aren't trying to keep track of things over time (e.g. with waits), you should be safe! If you do need to track things over time, then I'd recommend using a technique like Dynamic Indexing (Visualize: Dynamic Indexing) to make sure you don't run into bugs.

In this case, the code that you are running is instant and you have unique variables for that helper trigger, so they should be totally fine to use!

Gnuoy said:
Does this look right?

Yep! That looks great!
 
Level 21
Joined
Mar 16, 2008
Messages
955
What if i have a loop
Set PN = loop interger
Run trigger x

The also have
If player types -join
Set PN = triggering player
Run trigger x

If all of this is happening at the same time, do you think all the right triggers will get the right PNs?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
What if i have a loop
Set PN = loop interger
Run trigger x

The also have
If player types -join
Set PN = triggering player
Run trigger x

If all of this is happening at the same time, do you think all the right triggers will get the right PNs?
Triggers use a queue system. I'll use a real life example to help describe this.

Imagine you're standing in line at the grocery store waiting for your turn to checkout. You cannot checkout until all of the people in front of you have finished, and only one person can checkout at a time.

Now think of your triggers like the people standing in line. If the same trigger runs twice at the same exact time then both of those triggers will be put into the queue. One trigger is going to placed at the front of the queue and the other will be placed behind it. Then they will proceed to checkout one by one (run their Conditions -> Actions), but not until it's their turn.

So neither of them are running at the same time, that's not possible. One thing has to happen before the other, logically. Warcraft 3 runs on a single thread.

That's why when two Footman with 1 HP swing at each other at the same exact time, only one of them dies. One of them has to die first, and when that happens it will interrupt that dying unit's attack and as a result prevent it's attack from dealing any damage to the other unit.

HOWEVER, there are some rulebreakers out there that will cut in line and ruin the normally organized queue.

One cause of this problem is the Event A unit Dies.
Whenever this Event fires it breaks the queue and executes it's Conditions/Actions immediately, injecting that logic directly into whatever trigger caused it to run in the first place. While this is happening any shared variables between those triggers could easily get changed and ruin the expected outcome.
  • Events
    • Unit - A unit Dies

Another cause of this problem is the Wait action, since that introduces a period of time in which other triggers can be running and changing things. This is because the queue does NOT care about Waits and will move on to the next trigger without waiting!
  • Wait 1.00 seconds

Another important thing to mention is that the Run Trigger action will execute it's Conditions/Actions immediately. This is the behavior that you probably want from it, but it's still important to remember this since the trigger that you run could be using the same variables as the trigger that ran it.
  • Trigger - Run MyOtherTrigger (checking conditions)

Once you understand this concept it will make fixing these issues easier. All you have to do is avoid or workaround these rulebreakers and everything should be fine. For example, you can use unique variables in any trigger that has the A unit Dies Event or other types of rulebreakers. Another smart thing to do is avoid using Waits whenever possible, especially in custom spells or triggers like them.
 
Last edited:
Level 21
Joined
Mar 16, 2008
Messages
955
So it sounds like Run Trigger is a "rule breaker" and could cause bugs. On the other hand, while "run trigger" is a "rule breaker" and cuts the trigger queue, only one trigger is calling the "run trigger" function at a time. So it won't cause a problem?

In my map there are multiple ways to change teams, but I want everything running through one trigger for ease of editing. But it seems the closest i can get to that is having a few unique triggers.

loop
Set PN = loop interger
Run trigger x

types -join
Set PN = triggering player
Run trigger x

I suppose I could just test but I want zero chance of bugs, of course.

EDIT:
  • Universal Cast Join
    • Events
      • Unit - Altar of Knights 0225 <gen> Begins casting an ability
      • Unit - Altar of Knights 0226 <gen> Begins casting an ability
      • Unit - Altar of Knights 0227 <gen> Begins casting an ability
      • Unit - Altar of Knights 0319 <gen> Begins casting an ability
      • Unit - Altar of Knights 0320 <gen> Begins casting an ability
      • Unit - Altar of Knights 0326 <gen> Begins casting an ability
      • Unit - Altar of Knights 0340 <gen> Begins casting an ability
      • Unit - Altar of Knights 0341 <gen> Begins casting an ability
      • Unit - Altar of Knights 0342 <gen> Begins casting an ability
      • Unit - Altar of Knights 0343 <gen> Begins casting an ability
      • Unit - Altar of Knights 0352 <gen> Begins casting an ability
      • Unit - Altar of Knights 0504 <gen> Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
    • Actions
      • Set VariableSet joining_knight = (Player number of (Owner of (Casting unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
        • Then - Actions
          • Set VariableSet join_target_king = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
        • Then - Actions
          • Set VariableSet join_target_king = 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
        • Then - Actions
          • Set VariableSet join_target_king = 3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
        • Then - Actions
          • Set VariableSet join_target_king = 4
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Castle_Alive[join_target_king] Equal to False
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • joining_enabled Equal to False
        • Then - Actions
          • Quest - Display to solo_group[joining_knight] the Hint message: |cff808080Knights m...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • join_CD[joining_knight] Equal to True
        • Then - Actions
          • Quest - Display to solo_group[joining_knight] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[join_target_king] Current gold) Less than 1000
        • Then - Actions
          • Quest - Display to solo_group[joining_knight] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • kingdom_knight_cap[join_target_king] Greater than or equal to limits_max_knights
        • Then - Actions
          • Quest - Display to solo_group[joining_knight] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Hero_Var[joining_knight] is being transported) Equal to True
        • Then - Actions
          • Quest - Display to solo_group[joining_knight] the Mission Failed message: |cffff0000Error|r: ...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[joining_knight] is in Groups[join_target_king].) Equal to True
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • Dialog - Hide dialog_join[joining_knight] for Player 1 (Red)
      • Dialog - Hide dialog_join[joining_knight] for Player 2 (Blue)
      • Dialog - Hide dialog_join[joining_knight] for Player 3 (Teal)
      • Dialog - Hide dialog_join[joining_knight] for Player 4 (Purple)
      • -------- --------
      • -------- this will automatically join the knight to the king if it's before 90 sec or if the king is running an AI script --------
      • -------- it's pretty much a copy paste of the main part of the "Universal Accept" trigger --------
      • -------- this part runs if the king is AI or it's first 90 sec of the game, to avoid the annoyance of dialogs at this point --------
      • -------- it's pretty much redundant with the accept trigger --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ninty_sec_time Equal to False
              • ai_king[join_target_king] Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[join_target_king] Current gold) Greater than 1000
            • Then - Actions
              • Player - Add -1000 to Player_array_var[join_target_king].Current gold
            • Else - Actions
              • Player - Set Player_array_var[join_target_king].Current gold to 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Unit Inventory (Human, no use items) for Knight_Altar_Var[joining_knight]) Equal to 1
            • Then - Actions
            • Else - Actions
              • Unit - Add Unit Inventory (Human, no use items) to Knight_Altar_Var[joining_knight]
          • Unit - Remove Mark of Black Knights from Knight_Altar_Var[joining_knight]
          • Unit - Remove Mark of Black Knights from Knight_Hero_Var[joining_knight]
          • Set VariableSet units_owned[joining_knight] = (Units owned by Player_array_var[joining_knight].)
          • Unit Group - Pick every unit in units_owned[joining_knight] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) has an item of type Midnight Ankh) Equal to True
                      • ((Picked unit) has an item of type Plans: Black Tent) Equal to True
                • Then - Actions
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                  • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[5].) Equal to True
            • Then - Actions
              • Item - Pick every item in (Entire map) and do (If (Midnight Ankh Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
              • Item - Pick every item in (Entire map) and do (If (Plans: Black Tent Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
            • Else - Actions
          • Unit Group - Remove Knight_Hero_Var[joining_knight] from units_owned[joining_knight].
          • Unit Group - Remove Knight_Altar_Var[joining_knight] from units_owned[joining_knight].
          • Unit Group - Remove pirate_ship_unit[joining_knight] from units_owned[joining_knight].
          • Unit Group - Remove wisp_tree from units_owned[joining_knight].
          • Unit Group - Remove vault_array[joining_knight] from units_owned[joining_knight].
          • Unit Group - Pick every unit in units_owned[joining_knight] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Level of Mark of Kobold Candle Altar for (Picked unit)) Equal to 1
                      • (Level of Mark of Wisp Knight for (Picked unit)) Equal to 1
                      • (Level of Mark of Peasant Knight for (Picked unit)) Equal to 1
                      • (Unit-type of (Picked unit)) Equal to Pack Horse (King Unit)
                      • (Unit-type of (Picked unit)) Equal to Wagon
                      • (Unit-type of (Picked unit)) Equal to Passenger Ship
                      • (Unit-type of (Picked unit)) Equal to Red Riding Dragonling
                      • (Unit-type of (Picked unit)) Equal to Red Riding Dragon
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from units_owned[joining_knight].
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[1].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[joining_knight] and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[2].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[joining_knight] and do (Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[3].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[joining_knight] and do (Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[4].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[joining_knight] and do (Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player_array_var[joining_knight] is in Groups[5].) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in units_owned[joining_knight] and do (Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color)
            • Else - Actions
          • Custom script: call DestroyGroup(udg_units_owned[udg_joining_knight])
          • Set VariableSet loyalty_status[joining_knight] = 0
          • Countdown Timer - Pause loyalty_timer[joining_knight]
          • Countdown Timer - Start loyalty_timer[joining_knight] as a Repeating timer that will expire in 660.00 seconds
          • Unit - Remove hire_buttons_red[joining_knight] from the game
          • Unit - Remove hire_buttons_blue[joining_knight] from the game
          • Unit - Remove hire_buttons_teal[joining_knight] from the game
          • Unit - Remove hire_buttons_purp[joining_knight] from the game
          • Countdown Timer - Start End_Timer as a One-shot timer that will expire in 0.10 seconds
          • Countdown Timer - Start End_Timer_Camera as a One-shot timer that will expire in 1.00 seconds
          • Countdown Timer - Start join_cd_timer[joining_knight] as a One-shot timer that will expire in 2.00 seconds
          • Set VariableSet join_CD[joining_knight] = True
          • Countdown Timer - Start allegiance_cd_timer[joining_knight] as a One-shot timer that will expire in 5.00 seconds
          • Hero - Make Player_array_var[joining_knight] Heroes gain 100.00% experience from future kills
          • Player Group - Remove Player_array_var[joining_knight] from Groups[0].
          • Player Group - Remove Player_array_var[joining_knight] from Groups[1].
          • Player Group - Remove Player_array_var[joining_knight] from Groups[2].
          • Player Group - Remove Player_array_var[joining_knight] from Groups[3].
          • Player Group - Remove Player_array_var[joining_knight] from Groups[4].
          • Player Group - Remove Player_array_var[joining_knight] from Groups[5].
          • Player Group - Add Player_array_var[joining_knight] to Groups[join_target_king]
          • For each (Integer tech_loop_cast_integer) from 1 to 14, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[joining_knight]) Less than (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[join_target_king])
                • Then - Actions
                  • Player - Set the current research level of Tech_Type[tech_loop_cast_integer] to (Current research level of Tech_Type[tech_loop_cast_integer] for Player_array_var[join_target_king]) for Player_array_var[joining_knight]
                • Else - Actions
          • Player - Set the current research level of Gluttony to 0 for Player_array_var[joining_knight]
          • Player - Set Player_array_var[joining_knight].Food max to 99
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Knight_Altar_Var[joining_knight] is invulnerable) Equal to False
            • Then - Actions
              • Unit - Add Invulnerable (Neutral) to Knight_Altar_Var[joining_knight]
            • Else - Actions
          • Set VariableSet temp_point = (Position of Knight_Altar_Var[joining_knight])
          • Special Effect - Create a special effect at temp_point using Heavens Gate Channel.mdx
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_temp_point)
          • Special Effect - Create a special effect attached to the origin of Knight_Altar_Var[joining_knight] using Heavens Gate.mdx
          • Special Effect - Destroy (Last created special effect)
          • Unit - Move Knight_Altar_Var[joining_knight] instantly to (Load joining_knight of join_target_king in kni_king_altars_hashtable.)
          • Camera - Pan camera for Player_array_var[joining_knight] to (Load joining_knight of join_target_king in kni_king_altars_hashtable.) over 1.00 seconds
          • Cinematic - Ping minimap for solo_group[joining_knight] at (Load joining_knight of join_target_king in kni_king_altars_hashtable.) for 5.00 seconds
          • Quest - Display to (All players) the Quest Update message: (The + (player_color_knight_strings[joining_knight] + ( has pledged allegiance to the + (player_color_knight_strings[join_target_king] + .))))
          • Unit - Order Knight_Altar_Var[joining_knight] to Revive Hero Knight_Hero_Var[joining_knight]
          • Unit - Change color of Knight_Hero_Var[joining_knight] to player_color[join_target_king]
          • Player - Change color of Player_array_var[joining_knight] to original_color[joining_knight], Retaining color of existing units
          • Unit - Set Name of Knight_Altar_Var[joining_knight] to (player_color_knight_strings[joining_knight] + 's Altar)
          • Countdown Timer - Pause multiboard_update_timer
          • Countdown Timer - Start multiboard_update_timer as a One-shot timer that will expire in 2.00 seconds
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Knight_Hero_Var[joining_knight] is alive) Equal to True
              • (knght_room_region_array[joining_knight] contains Knight_Hero_Var[joining_knight]) Equal to True
            • Then - Actions
              • Unit - Move Knight_Hero_Var[joining_knight] instantly to king_vendor[join_target_king]
            • Else - Actions
          • -------- empty group --------
          • Player Group - Make Groups[0] treat Groups[0] as an Neutral
          • Player Group - Make Groups[0] treat Groups[1] as an Neutral
          • Player Group - Make Groups[0] treat Groups[2] as an Neutral
          • Player Group - Make Groups[0] treat Groups[3] as an Neutral
          • Player Group - Make Groups[0] treat Groups[4] as an Neutral
          • Player Group - Make Groups[0] treat Groups[5] as an Neutral
          • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
          • -------- red --------
          • Player Group - Make Groups[1] treat Groups[0] as an Enemy
          • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
          • Player Group - Make Groups[1] treat Groups[2] as an Enemy
          • Player Group - Make Groups[1] treat Groups[3] as an Enemy
          • Player Group - Make Groups[1] treat Groups[4] as an Enemy
          • Player Group - Make Groups[1] treat Groups[5] as an Enemy
          • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 13 (Maroon) treat Player 21 (Coal) as an Neutral
          • -------- blue --------
          • Player Group - Make Groups[2] treat Groups[0] as an Enemy
          • Player Group - Make Groups[2] treat Groups[1] as an Enemy
          • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
          • Player Group - Make Groups[2] treat Groups[3] as an Enemy
          • Player Group - Make Groups[2] treat Groups[4] as an Enemy
          • Player Group - Make Groups[2] treat Groups[5] as an Enemy
          • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 14 (Navy) treat Player 21 (Coal) as an Neutral
          • -------- teal --------
          • Player Group - Make Groups[3] treat Groups[0] as an Enemy
          • Player Group - Make Groups[3] treat Groups[1] as an Enemy
          • Player Group - Make Groups[3] treat Groups[2] as an Enemy
          • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
          • Player Group - Make Groups[3] treat Groups[4] as an Enemy
          • Player Group - Make Groups[3] treat Groups[5] as an Enemy
          • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 15 (Turquoise) treat Player 21 (Coal) as an Neutral
          • -------- purple --------
          • Player Group - Make Groups[4] treat Groups[0] as an Enemy
          • Player Group - Make Groups[4] treat Groups[1] as an Enemy
          • Player Group - Make Groups[4] treat Groups[2] as an Enemy
          • Player Group - Make Groups[4] treat Groups[3] as an Enemy
          • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
          • Player Group - Make Groups[4] treat Groups[5] as an Enemy
          • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
          • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
          • Player - Make Player 16 (Violet) treat Player 21 (Coal) as an Neutral
          • -------- black --------
          • Player Group - Make Groups[5] treat Groups[0] as an Enemy
          • Player Group - Make Groups[5] treat Groups[1] as an Enemy
          • Player Group - Make Groups[5] treat Groups[2] as an Enemy
          • Player Group - Make Groups[5] treat Groups[3] as an Enemy
          • Player Group - Make Groups[5] treat Groups[4] as an Enemy
          • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
          • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
          • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
          • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
          • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
          • -------- white --------
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
          • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
          • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
          • -------- ------ --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of players in Groups[0]) Equal to 0
            • Then - Actions
              • Set VariableSet additional_knight_cap = 1
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • no_knight_cap Equal to False
                  • teams_locked Equal to False
                • Then - Actions
                  • Countdown Timer - Pause knight_max_calculate_timer
                  • Countdown Timer - Start knight_max_calculate_timer as a One-shot timer that will expire in 2.00 seconds
                • Else - Actions
            • Else - Actions
          • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
          • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
          • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
          • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
        • Else - Actions
          • Dialog - Hide dialog_join[5] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[6] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[7] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[8] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[9] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[10] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[11] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[12] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[17] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[18] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[19] for Player_array_var[join_target_king]
          • Dialog - Hide dialog_join[20] for Player_array_var[join_target_king]
          • Dialog - Show dialog_join[joining_knight] for Player_array_var[join_target_king]
  • Universal Accept
    • Events
      • Dialog - A dialog button is clicked for dialog_join[5]
      • Dialog - A dialog button is clicked for dialog_join[6]
      • Dialog - A dialog button is clicked for dialog_join[7]
      • Dialog - A dialog button is clicked for dialog_join[8]
      • Dialog - A dialog button is clicked for dialog_join[9]
      • Dialog - A dialog button is clicked for dialog_join[10]
      • Dialog - A dialog button is clicked for dialog_join[11]
      • Dialog - A dialog button is clicked for dialog_join[12]
      • Dialog - A dialog button is clicked for dialog_join[17]
      • Dialog - A dialog button is clicked for dialog_join[18]
      • Dialog - A dialog button is clicked for dialog_join[19]
      • Dialog - A dialog button is clicked for dialog_join[20]
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Red
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Blue
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Teal
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Purp
    • Conditions
    • Actions
      • -------- this first condition checks if knight or king is the accepting party --------
      • -------- the "then" part is if king is accpeting the knights request to join --------
      • -------- the "else" part checks if the king is offering for the knight to join --------
      • -------- ...and sets variables accordingly --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Triggering player) Equal to Player 1 (Red)
              • (Triggering player) Equal to Player 2 (Blue)
              • (Triggering player) Equal to Player 3 (Teal)
              • (Triggering player) Equal to Player 4 (Purple)
        • Then - Actions
          • Set VariableSet accepting_king = (Player number of (Triggering player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[5]
            • Then - Actions
              • Set VariableSet accepted_knight = 5
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[6]
            • Then - Actions
              • Set VariableSet accepted_knight = 6
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[7]
            • Then - Actions
              • Set VariableSet accepted_knight = 7
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[8]
            • Then - Actions
              • Set VariableSet accepted_knight = 8
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[9]
            • Then - Actions
              • Set VariableSet accepted_knight = 9
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[10]
            • Then - Actions
              • Set VariableSet accepted_knight = 10
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[11]
            • Then - Actions
              • Set VariableSet accepted_knight = 11
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[12]
            • Then - Actions
              • Set VariableSet accepted_knight = 12
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[17]
            • Then - Actions
              • Set VariableSet accepted_knight = 17
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[18]
            • Then - Actions
              • Set VariableSet accepted_knight = 18
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[19]
            • Then - Actions
              • Set VariableSet accepted_knight = 19
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_accept[20]
            • Then - Actions
              • Set VariableSet accepted_knight = 20
            • Else - Actions
          • Dialog - Hide dialog_join[accepted_knight] for Player_array_var[accepting_king]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to button_decline[accepted_knight]
            • Then - Actions
              • Unit - For Unit Knight_Altar_Var[accepted_knight], start cooldown of ability pledge_spells[accepting_king] " over "kingdom_join_CD seconds.
              • Skip remaining actions
            • Else - Actions
        • Else - Actions
          • Set VariableSet accepted_knight = (Player number of (Triggering player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Red
            • Then - Actions
              • Set VariableSet accepting_king = 1
              • Dialog - Hide Hire_Dialog_Menu_Red for Player_array_var[accepting_king]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Red
            • Then - Actions
              • Set VariableSet accepting_king = 1
              • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Blue
            • Then - Actions
              • Set VariableSet accepting_king = 2
              • Dialog - Hide Hire_Dialog_Menu_Blue for Player_array_var[accepting_king]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Blue
            • Then - Actions
              • Set VariableSet accepting_king = 2
              • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Teal
            • Then - Actions
              • Set VariableSet accepting_king = 3
              • Dialog - Hide Hire_Dialog_Menu_Teal for Player_array_var[accepting_king]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Teal
            • Then - Actions
              • Set VariableSet accepting_king = 3
              • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_Yes_Button_Purp
            • Then - Actions
              • Set VariableSet accepting_king = 4
              • Dialog - Hide Hire_Dialog_Menu_Purp for Player_array_var[accepting_king]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to Hire_No_Button_Purp
            • Then - Actions
              • Set VariableSet accepting_king = 4
              • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
              • Skip remaining actions
            • Else - Actions
      • -------- -------------- --------
      • -------- this is the main part of the trigger that sets up the alliance, moves units, etc --------
      • -------- -------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepting_king] Current gold) Greater than 1000
        • Then - Actions
          • Player - Add -1000 to Player_array_var[accepting_king].Current gold
        • Else - Actions
          • Player - Set Player_array_var[accepting_king].Current gold to 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Unit Inventory (Human, no use items) for Knight_Altar_Var[accepted_knight]) Equal to 1
        • Then - Actions
        • Else - Actions
          • Unit - Add Unit Inventory (Human, no use items) to Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Hero_Var[accepted_knight]
      • Set VariableSet units_owned[accepted_knight] = (Units owned by Player_array_var[accepted_knight].)
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) has an item of type Midnight Ankh) Equal to True
                  • ((Picked unit) has an item of type Plans: Black Tent) Equal to True
            • Then - Actions
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Item - Pick every item in (Entire map) and do (If (Midnight Ankh Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
          • Item - Pick every item in (Entire map) and do (If (Plans: Black Tent Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
        • Else - Actions
      • Unit Group - Remove Knight_Hero_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove Knight_Altar_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove pirate_ship_unit[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove wisp_tree from units_owned[accepted_knight].
      • Unit Group - Remove vault_array[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Mark of Peasant Knight for (Picked unit)) Equal to 1
                      • (Level of Mark of Peasant Knight for Knight_Hero_Var[accepted_knight]) Equal to 1
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Mark of Wisp Knight for Knight_Hero_Var[accepted_knight]) Equal to 1
                      • (Level of Mark of Wisp Knight for (Picked unit)) Equal to 1
                  • (Level of Mark of Kobold Candle Altar for (Picked unit)) Equal to 1
                  • (Unit-type of (Picked unit)) Equal to Pack Horse (King Unit)
                  • (Unit-type of (Picked unit)) Equal to Wagon
                  • (Unit-type of (Picked unit)) Equal to Passenger Ship
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragonling
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragon
            • Then - Actions
              • Unit Group - Remove (Picked unit) from units_owned[accepted_knight].
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[1].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[2].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[3].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[4].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_units_owned[udg_accepted_knight])
      • Set VariableSet loyalty_status[accepted_knight] = 0
      • Countdown Timer - Pause loyalty_timer[accepted_knight]
      • Countdown Timer - Start loyalty_timer[accepted_knight] as a Repeating timer that will expire in 660.00 seconds
      • Unit - Remove hire_buttons_red[accepted_knight] from the game
      • Unit - Remove hire_buttons_blue[accepted_knight] from the game
      • Unit - Remove hire_buttons_teal[accepted_knight] from the game
      • Unit - Remove hire_buttons_purp[accepted_knight] from the game
      • Countdown Timer - Start End_Timer as a One-shot timer that will expire in 0.10 seconds
      • Countdown Timer - Start End_Timer_Camera as a One-shot timer that will expire in 1.00 seconds
      • Countdown Timer - Start join_cd_timer[accepted_knight] as a One-shot timer that will expire in 2.00 seconds
      • Set VariableSet join_CD[accepted_knight] = True
      • Countdown Timer - Start allegiance_cd_timer[accepted_knight] as a One-shot timer that will expire in 5.00 seconds
      • Hero - Make Player_array_var[accepted_knight] Heroes gain 100.00% experience from future kills
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[0].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[1].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[2].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[3].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[4].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[5].
      • Player Group - Add Player_array_var[accepted_knight] to Groups[accepting_king]
      • For each (Integer tech_loop_accpt_integer) from 1 to 14, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepted_knight]) Less than (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepting_king])
            • Then - Actions
              • Player - Set the current research level of Tech_Type[tech_loop_accpt_integer] to (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepting_king]) for Player_array_var[accepted_knight]
            • Else - Actions
      • Player - Set the current research level of Gluttony to 0 for Player_array_var[accepted_knight]
      • Player - Set Player_array_var[accepted_knight].Food max to 99
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Altar_Var[accepted_knight] is invulnerable) Equal to False
        • Then - Actions
          • Unit - Add Invulnerable (Neutral) to Knight_Altar_Var[accepted_knight]
        • Else - Actions
      • Set VariableSet temp_point = (Position of Knight_Altar_Var[accepted_knight])
      • Special Effect - Create a special effect at temp_point using Heavens Gate Channel.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_temp_point)
      • Special Effect - Create a special effect attached to the origin of Knight_Altar_Var[accepted_knight] using Heavens Gate.mdx
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move Knight_Altar_Var[accepted_knight] instantly to (Load accepted_knight of accepting_king in kni_king_altars_hashtable.)
      • Camera - Pan camera for Player_array_var[accepted_knight] to (Load accepted_knight of accepting_king in kni_king_altars_hashtable.) over 1.00 seconds
      • Cinematic - Ping minimap for solo_group[accepted_knight] at (Load accepted_knight of accepting_king in kni_king_altars_hashtable.) for 5.00 seconds
      • Quest - Display to (All players) the Quest Update message: (The + (player_color_knight_strings[accepted_knight] + ( has pledged allegiance to the + (player_color_knight_strings[accepting_king] + .))))
      • Unit - Order Knight_Altar_Var[accepted_knight] to Revive Hero Knight_Hero_Var[accepted_knight]
      • Unit - Change color of Knight_Hero_Var[accepted_knight] to player_color[accepting_king]
      • Player - Change color of Player_array_var[accepted_knight] to original_color[accepted_knight], Retaining color of existing units
      • Unit - Set Name of Knight_Altar_Var[accepted_knight] to (player_color_knight_strings[accepted_knight] + 's Altar)
      • Countdown Timer - Pause multiboard_update_timer
      • Countdown Timer - Start multiboard_update_timer as a One-shot timer that will expire in 2.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Hero_Var[accepted_knight] is alive) Equal to True
          • (knght_room_region_array[accepted_knight] contains Knight_Hero_Var[accepted_knight]) Equal to True
        • Then - Actions
          • Unit - Move Knight_Hero_Var[accepted_knight] instantly to king_vendor[accepting_king]
        • Else - Actions
      • -------- end main part of join trigger --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- this next part is just generic stuff to reset all alliances, since a player has changed groups --------
      • -------- empty group --------
      • Player Group - Make Groups[0] treat Groups[0] as an Neutral
      • Player Group - Make Groups[0] treat Groups[1] as an Neutral
      • Player Group - Make Groups[0] treat Groups[2] as an Neutral
      • Player Group - Make Groups[0] treat Groups[3] as an Neutral
      • Player Group - Make Groups[0] treat Groups[4] as an Neutral
      • Player Group - Make Groups[0] treat Groups[5] as an Neutral
      • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
      • -------- red --------
      • Player Group - Make Groups[1] treat Groups[0] as an Enemy
      • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
      • Player Group - Make Groups[1] treat Groups[2] as an Enemy
      • Player Group - Make Groups[1] treat Groups[3] as an Enemy
      • Player Group - Make Groups[1] treat Groups[4] as an Enemy
      • Player Group - Make Groups[1] treat Groups[5] as an Enemy
      • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 13 (Maroon) treat Player 21 (Coal) as an Neutral
      • -------- blue --------
      • Player Group - Make Groups[2] treat Groups[0] as an Enemy
      • Player Group - Make Groups[2] treat Groups[1] as an Enemy
      • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
      • Player Group - Make Groups[2] treat Groups[3] as an Enemy
      • Player Group - Make Groups[2] treat Groups[4] as an Enemy
      • Player Group - Make Groups[2] treat Groups[5] as an Enemy
      • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 14 (Navy) treat Player 21 (Coal) as an Neutral
      • -------- teal --------
      • Player Group - Make Groups[3] treat Groups[0] as an Enemy
      • Player Group - Make Groups[3] treat Groups[1] as an Enemy
      • Player Group - Make Groups[3] treat Groups[2] as an Enemy
      • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
      • Player Group - Make Groups[3] treat Groups[4] as an Enemy
      • Player Group - Make Groups[3] treat Groups[5] as an Enemy
      • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 15 (Turquoise) treat Player 21 (Coal) as an Neutral
      • -------- purple --------
      • Player Group - Make Groups[4] treat Groups[0] as an Enemy
      • Player Group - Make Groups[4] treat Groups[1] as an Enemy
      • Player Group - Make Groups[4] treat Groups[2] as an Enemy
      • Player Group - Make Groups[4] treat Groups[3] as an Enemy
      • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
      • Player Group - Make Groups[4] treat Groups[5] as an Enemy
      • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 16 (Violet) treat Player 21 (Coal) as an Neutral
      • -------- black --------
      • Player Group - Make Groups[5] treat Groups[0] as an Enemy
      • Player Group - Make Groups[5] treat Groups[1] as an Enemy
      • Player Group - Make Groups[5] treat Groups[2] as an Enemy
      • Player Group - Make Groups[5] treat Groups[3] as an Enemy
      • Player Group - Make Groups[5] treat Groups[4] as an Enemy
      • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
      • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
      • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
      • -------- white --------
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
      • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
      • -------- ------ --------
      • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
      • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
      • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
      • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in Groups[0]) Equal to 0
        • Then - Actions
          • Set VariableSet additional_knight_cap = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • no_knight_cap Equal to False
          • teams_locked Equal to False
        • Then - Actions
          • Countdown Timer - Pause knight_max_calculate_timer
          • Countdown Timer - Start knight_max_calculate_timer as a One-shot timer that will expire in 2.00 seconds
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
So it sounds like Run Trigger is a "rule breaker" and could cause bugs.
Yes, although it's not a bug, it's how it's designed to work. It just causes problems if you aren't careful.

only one trigger is calling the "run trigger" function at a time. So it won't cause a problem?
If the trigger that is calling "run trigger" uses the same variables as "run trigger" then it can cause problems.

Maybe this will help visualize it...

This example will cause problems because TriggerB runs immediately and they're both using (Integer A). You need to use 2 different Integer variables here:
  • TriggerA
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 5 do (Actions)
        • Loop - Actions
          • Trigger - Run TriggerB (ignoring conditions)
  • TriggerB
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3 do (Actions)
        • Loop - Actions
          • ...
The final result would be this:
  • Actions
    • For each (Integer A) from 1 to 5 do (Actions)
      • Loop - Actions
        • For each (Integer A) from 1 to 3 do (Actions)
          • Loop - Actions
            • ...

However, this example will work without issues because both triggers run separately:
  • TriggerA
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Trigger - Run TriggerB (ignoring conditions)
      • For each (Integer A) from 1 to 5 do (Actions)
        • Loop - Actions
          • ...
  • TriggerB
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3 do (Actions)
        • Loop - Actions
          • ...
The final result would be this:
  • Actions
    • For each (Integer A) from 1 to 3 do (Actions)
      • Loop - Actions
        • ...
    • For each (Integer A) from 1 to 5 do (Actions)
      • Loop - Actions
        • ...
 
Last edited:
Level 29
Joined
Sep 26, 2009
Messages
2,594
So it sounds like Run Trigger is a "rule breaker" and could cause bugs. On the other hand, while "run trigger" is a "rule breaker" and cuts the trigger queue, only one trigger is calling the "run trigger" function at a time. So it won't cause a problem?
While "Run trigger" action does cut into the trigger queue, it is entirely under your control - you have to call the action, so you know what will happen. On the other hand triggers with events like "Unit dies" that Uncle mentioned will cut into the queue without you having any control over it.

As for the "Run trigger" itself, you can think of it as if the actions of the trigger you run have been copied over to the trigger that calls "Run trigger".
For example this trigger calls another trigger via "Run trigger" action:
  • Start Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set VariableSet TargetLoc = (Position of (Triggering unit))
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet Count[PN] = (Count[PN] + 1)
      • Unit - Kill Summon[PN]
      • Trigger - Run Create Summon <gen> (checking conditions)
      • Custom script: call RemoveLocation(udg_TargetLoc)
  • Create Summon
    • Events
    • Conditions
      • PN Greater than 0
    • Actions
      • Unit - Create 1 Enraged Elemental for (Player(PN)) at TargetLoc facing Default building facing degrees
      • Set VariableSet Summon[PN] = (Last created unit)
      • Animation - Change Summon[PN]'s vertex coloring to (20.00%, 70.00%, 100.00%) with 20.00% transparency
      • Special Effect - Create a special effect attached to the origin of Summon[PN] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
      • Special Effect - Destroy (Last created special effect)
You can think as if it did this:
  • Start Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Water Elemental
    • Actions
      • Set VariableSet TargetLoc = (Position of (Triggering unit))
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet Count[PN] = (Count[PN] + 1)
      • Unit - Kill Summon[PN]
      • -------- Here we originally called "Run trigger" action --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PN Greater than 0
        • Then - Actions
          • Unit - Create 1 Enraged Elemental for (Player(PN)) at TargetLoc facing Default building facing degrees
          • Set VariableSet Summon[PN] = (Last created unit)
          • Animation - Change Summon[PN]'s vertex coloring to (20.00%, 70.00%, 100.00%) with 20.00% transparency
          • Special Effect - Create a special effect attached to the origin of Summon[PN] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TargetLoc)
 
Level 21
Joined
Mar 16, 2008
Messages
955
Thank you for the detailed explanations. I still don't fully understand though and I'm still slightly confused.

This is a bit of a rough draft but thinking something like the triggers below. If multiple players are spamming both triggers, do you think there is any chance of "variables getting mixed up"?

  • Universal Cast Join Copy
    • Events
      • Unit - Altar of Knights 0225 <gen> Begins casting an ability
      • Unit - Altar of Knights 0226 <gen> Begins casting an ability
      • Unit - Altar of Knights 0227 <gen> Begins casting an ability
      • Unit - Altar of Knights 0319 <gen> Begins casting an ability
      • Unit - Altar of Knights 0320 <gen> Begins casting an ability
      • Unit - Altar of Knights 0326 <gen> Begins casting an ability
      • Unit - Altar of Knights 0340 <gen> Begins casting an ability
      • Unit - Altar of Knights 0341 <gen> Begins casting an ability
      • Unit - Altar of Knights 0342 <gen> Begins casting an ability
      • Unit - Altar of Knights 0343 <gen> Begins casting an ability
      • Unit - Altar of Knights 0352 <gen> Begins casting an ability
      • Unit - Altar of Knights 0504 <gen> Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
    • Actions
      • Set VariableSet accepted_knight = (Player number of (Owner of (Casting unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (red) (new)
        • Then - Actions
          • Set VariableSet accepting_king = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (blue) (new)
        • Then - Actions
          • Set VariableSet accepting_king = 2
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (teal) (new)
        • Then - Actions
          • Set VariableSet accepting_king = 3
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Pledge Allegiance (purple) (new)
        • Then - Actions
          • Set VariableSet accepting_king = 4
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ninty_sec_time Equal to False
              • ai_king[join_target_king] Equal to True
        • Then - Actions
          • Trigger - Run Universal Accept <gen> (ignoring conditions)
        • Else - Actions
          • Dialog - Show dialog_join[accepted_knight] for Player_array_var[accepting_king]
  • Universal Accept Copy
    • Events
      • Dialog - A dialog button is clicked for dialog_join[5]
      • Dialog - A dialog button is clicked for dialog_join[6]
      • Dialog - A dialog button is clicked for dialog_join[7]
      • Dialog - A dialog button is clicked for dialog_join[8]
      • Dialog - A dialog button is clicked for dialog_join[9]
      • Dialog - A dialog button is clicked for dialog_join[10]
      • Dialog - A dialog button is clicked for dialog_join[11]
      • Dialog - A dialog button is clicked for dialog_join[12]
      • Dialog - A dialog button is clicked for dialog_join[17]
      • Dialog - A dialog button is clicked for dialog_join[18]
      • Dialog - A dialog button is clicked for dialog_join[19]
      • Dialog - A dialog button is clicked for dialog_join[20]
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Red
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Blue
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Teal
      • Dialog - A dialog button is clicked for Hire_Dialog_Menu_Purp
    • Conditions
    • Actions
      • -------- this first condition checks if knight or king is the accepting party --------
      • -------- the "then" part is if king is accpeting the knights request to join --------
      • -------- the "else" part checks if the king is offering for the knight to join --------
      • -------- ...and sets variables accordingly --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • accepted_knight Equal to 0
          • accepting_king Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Triggering player) Equal to Player 1 (Red)
                  • (Triggering player) Equal to Player 2 (Blue)
                  • (Triggering player) Equal to Player 3 (Teal)
                  • (Triggering player) Equal to Player 4 (Purple)
            • Then - Actions
              • Set VariableSet accepting_king = (Player number of (Triggering player))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[5]
                • Then - Actions
                  • Set VariableSet accepted_knight = 5
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[6]
                • Then - Actions
                  • Set VariableSet accepted_knight = 6
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[7]
                • Then - Actions
                  • Set VariableSet accepted_knight = 7
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[8]
                • Then - Actions
                  • Set VariableSet accepted_knight = 8
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[9]
                • Then - Actions
                  • Set VariableSet accepted_knight = 9
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[10]
                • Then - Actions
                  • Set VariableSet accepted_knight = 10
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[11]
                • Then - Actions
                  • Set VariableSet accepted_knight = 11
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[12]
                • Then - Actions
                  • Set VariableSet accepted_knight = 12
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[17]
                • Then - Actions
                  • Set VariableSet accepted_knight = 17
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[18]
                • Then - Actions
                  • Set VariableSet accepted_knight = 18
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[19]
                • Then - Actions
                  • Set VariableSet accepted_knight = 19
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_accept[20]
                • Then - Actions
                  • Set VariableSet accepted_knight = 20
                • Else - Actions
              • Dialog - Hide dialog_join[accepted_knight] for Player_array_var[accepting_king]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to button_decline[accepted_knight]
                • Then - Actions
                  • Unit - For Unit Knight_Altar_Var[accepted_knight], start cooldown of ability pledge_spells[accepting_king] " over "kingdom_join_CD seconds.
                  • Skip remaining actions
                • Else - Actions
            • Else - Actions
              • Set VariableSet accepted_knight = (Player number of (Triggering player))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_Yes_Button_Red
                • Then - Actions
                  • Set VariableSet accepting_king = 1
                  • Dialog - Hide Hire_Dialog_Menu_Red for Player_array_var[accepting_king]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_No_Button_Red
                • Then - Actions
                  • Set VariableSet accepting_king = 1
                  • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
                  • Skip remaining actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_Yes_Button_Blue
                • Then - Actions
                  • Set VariableSet accepting_king = 2
                  • Dialog - Hide Hire_Dialog_Menu_Blue for Player_array_var[accepting_king]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_No_Button_Blue
                • Then - Actions
                  • Set VariableSet accepting_king = 2
                  • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
                  • Skip remaining actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_Yes_Button_Teal
                • Then - Actions
                  • Set VariableSet accepting_king = 3
                  • Dialog - Hide Hire_Dialog_Menu_Teal for Player_array_var[accepting_king]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_No_Button_Teal
                • Then - Actions
                  • Set VariableSet accepting_king = 3
                  • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
                  • Skip remaining actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_Yes_Button_Purp
                • Then - Actions
                  • Set VariableSet accepting_king = 4
                  • Dialog - Hide Hire_Dialog_Menu_Purp for Player_array_var[accepting_king]
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Clicked dialog button) Equal to Hire_No_Button_Purp
                • Then - Actions
                  • Set VariableSet accepting_king = 4
                  • Quest - Display to solo_group[accepting_king] the Quest Failed message: (The + (player_color_knight_strings[accepted_knight] + has declined your offer.))
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
      • -------- -------------- --------
      • -------- this is the main part of the trigger that sets up the alliance, moves units, etc --------
      • -------- -------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepting_king] Current gold) Greater than 1000
        • Then - Actions
          • Player - Add -1000 to Player_array_var[accepting_king].Current gold
        • Else - Actions
          • Player - Set Player_array_var[accepting_king].Current gold to 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Unit Inventory (Human, no use items) for Knight_Altar_Var[accepted_knight]) Equal to 1
        • Then - Actions
        • Else - Actions
          • Unit - Add Unit Inventory (Human, no use items) to Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Altar_Var[accepted_knight]
      • Unit - Remove Mark of Black Knights from Knight_Hero_Var[accepted_knight]
      • Set VariableSet units_owned[accepted_knight] = (Units owned by Player_array_var[accepted_knight].)
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) has an item of type Midnight Ankh) Equal to True
                  • ((Picked unit) has an item of type Plans: Black Tent) Equal to True
            • Then - Actions
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Midnight Ankh) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
              • Hero - Drop (Item carried by (Picked unit) of type Plans: Black Tent) from (Picked unit).
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Item - Pick every item in (Entire map) and do (If (Midnight Ankh Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
          • Item - Pick every item in (Entire map) and do (If (Plans: Black Tent Equal to (Item-type of (Picked item))) then do (Item - Remove (Picked item)) else do (Do nothing))
        • Else - Actions
      • Unit Group - Remove Knight_Hero_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove Knight_Altar_Var[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove pirate_ship_unit[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Remove wisp_tree from units_owned[accepted_knight].
      • Unit Group - Remove vault_array[accepted_knight] from units_owned[accepted_knight].
      • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Mark of Peasant Knight for (Picked unit)) Equal to 1
                      • (Level of Mark of Peasant Knight for Knight_Hero_Var[accepted_knight]) Equal to 1
                  • And - All (Conditions) are true
                    • Conditions
                      • (Level of Mark of Wisp Knight for (Picked unit)) Equal to 1
                      • (Level of Mark of Wisp Knight for Knight_Hero_Var[accepted_knight]) Equal to 1
                  • (Level of Mark of Kobold Candle Altar for (Picked unit)) Equal to 1
                  • (Unit-type of (Picked unit)) Equal to Pack Horse (King Unit)
                  • (Unit-type of (Picked unit)) Equal to Wagon
                  • (Unit-type of (Picked unit)) Equal to Passenger Ship
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragonling
                  • (Unit-type of (Picked unit)) Equal to Red Riding Dragon
            • Then - Actions
              • Unit Group - Remove (Picked unit) from units_owned[accepted_knight].
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[1].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[2].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[3].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[4].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player_array_var[accepted_knight] is in Groups[5].) Equal to True
        • Then - Actions
          • Unit Group - Pick every unit in units_owned[accepted_knight] and do (Unit - Change ownership of (Picked unit) to Player 21 (Coal) and Change color)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_units_owned[udg_accepted_knight])
      • Set VariableSet loyalty_status[accepted_knight] = 0
      • Countdown Timer - Pause loyalty_timer[accepted_knight]
      • Countdown Timer - Start loyalty_timer[accepted_knight] as a Repeating timer that will expire in 660.00 seconds
      • Unit - Remove hire_buttons_red[accepted_knight] from the game
      • Unit - Remove hire_buttons_blue[accepted_knight] from the game
      • Unit - Remove hire_buttons_teal[accepted_knight] from the game
      • Unit - Remove hire_buttons_purp[accepted_knight] from the game
      • Countdown Timer - Start End_Timer as a One-shot timer that will expire in 0.10 seconds
      • Countdown Timer - Start End_Timer_Camera as a One-shot timer that will expire in 1.00 seconds
      • Countdown Timer - Start join_cd_timer[accepted_knight] as a One-shot timer that will expire in 2.00 seconds
      • Set VariableSet join_CD[accepted_knight] = True
      • Countdown Timer - Start allegiance_cd_timer[accepted_knight] as a One-shot timer that will expire in 5.00 seconds
      • Hero - Make Player_array_var[accepted_knight] Heroes gain 100.00% experience from future kills
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[0].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[1].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[2].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[3].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[4].
      • Player Group - Remove Player_array_var[accepted_knight] from Groups[5].
      • Player Group - Add Player_array_var[accepted_knight] to Groups[accepting_king]
      • For each (Integer tech_loop_accpt_integer) from 1 to 14, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepted_knight]) Less than (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepting_king])
            • Then - Actions
              • Player - Set the current research level of Tech_Type[tech_loop_accpt_integer] to (Current research level of Tech_Type[tech_loop_accpt_integer] for Player_array_var[accepting_king]) for Player_array_var[accepted_knight]
            • Else - Actions
      • Player - Set the current research level of Gluttony to 0 for Player_array_var[accepted_knight]
      • Player - Set Player_array_var[accepted_knight].Food max to 99
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Altar_Var[accepted_knight] is invulnerable) Equal to False
        • Then - Actions
          • Unit - Add Invulnerable (Neutral) to Knight_Altar_Var[accepted_knight]
        • Else - Actions
      • Set VariableSet temp_point = (Position of Knight_Altar_Var[accepted_knight])
      • Special Effect - Create a special effect at temp_point using Heavens Gate Channel.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_temp_point)
      • Special Effect - Create a special effect attached to the origin of Knight_Altar_Var[accepted_knight] using Heavens Gate.mdx
      • Special Effect - Destroy (Last created special effect)
      • Unit - Move Knight_Altar_Var[accepted_knight] instantly to (Load accepted_knight of accepting_king in kni_king_altars_hashtable.)
      • Camera - Pan camera for Player_array_var[accepted_knight] to (Load accepted_knight of accepting_king in kni_king_altars_hashtable.) over 1.00 seconds
      • Cinematic - Ping minimap for solo_group[accepted_knight] at (Load accepted_knight of accepting_king in kni_king_altars_hashtable.) for 5.00 seconds
      • Quest - Display to (All players) the Quest Update message: (The + (player_color_knight_strings[accepted_knight] + ( has pledged allegiance to the + (player_color_knight_strings[accepting_king] + .))))
      • Unit - Order Knight_Altar_Var[accepted_knight] to Revive Hero Knight_Hero_Var[accepted_knight]
      • Unit - Change color of Knight_Hero_Var[accepted_knight] to player_color[accepting_king]
      • Player - Change color of Player_array_var[accepted_knight] to original_color[accepted_knight], Retaining color of existing units
      • Unit - Set Name of Knight_Altar_Var[accepted_knight] to (player_color_knight_strings[accepted_knight] + 's Altar)
      • Countdown Timer - Pause multiboard_update_timer
      • Countdown Timer - Start multiboard_update_timer as a One-shot timer that will expire in 2.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Knight_Hero_Var[accepted_knight] is alive) Equal to True
          • (knght_room_region_array[accepted_knight] contains Knight_Hero_Var[accepted_knight]) Equal to True
        • Then - Actions
          • Unit - Move Knight_Hero_Var[accepted_knight] instantly to king_vendor[accepting_king]
        • Else - Actions
      • -------- end main part of join trigger --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- -------------- --------
      • -------- this next part is just generic stuff to reset all alliances, since a player has changed groups --------
      • -------- empty group --------
      • Player Group - Make Groups[0] treat Groups[0] as an Neutral
      • Player Group - Make Groups[0] treat Groups[1] as an Neutral
      • Player Group - Make Groups[0] treat Groups[2] as an Neutral
      • Player Group - Make Groups[0] treat Groups[3] as an Neutral
      • Player Group - Make Groups[0] treat Groups[4] as an Neutral
      • Player Group - Make Groups[0] treat Groups[5] as an Neutral
      • Player Group - Make Groups[0] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[0] treat Player Group - Player 21 (Coal) as an Enemy
      • -------- red --------
      • Player Group - Make Groups[1] treat Groups[0] as an Enemy
      • Player Group - Make Groups[1] treat Groups[1] as an Ally with shared vision
      • Player Group - Make Groups[1] treat Groups[2] as an Enemy
      • Player Group - Make Groups[1] treat Groups[3] as an Enemy
      • Player Group - Make Groups[1] treat Groups[4] as an Enemy
      • Player Group - Make Groups[1] treat Groups[5] as an Enemy
      • Player Group - Make Groups[1] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[1] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 13 (Maroon) treat Player 21 (Coal) as an Neutral
      • -------- blue --------
      • Player Group - Make Groups[2] treat Groups[0] as an Enemy
      • Player Group - Make Groups[2] treat Groups[1] as an Enemy
      • Player Group - Make Groups[2] treat Groups[2] as an Ally with shared vision
      • Player Group - Make Groups[2] treat Groups[3] as an Enemy
      • Player Group - Make Groups[2] treat Groups[4] as an Enemy
      • Player Group - Make Groups[2] treat Groups[5] as an Enemy
      • Player Group - Make Groups[2] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[2] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 14 (Navy) treat Player 21 (Coal) as an Neutral
      • -------- teal --------
      • Player Group - Make Groups[3] treat Groups[0] as an Enemy
      • Player Group - Make Groups[3] treat Groups[1] as an Enemy
      • Player Group - Make Groups[3] treat Groups[2] as an Enemy
      • Player Group - Make Groups[3] treat Groups[3] as an Ally with shared vision
      • Player Group - Make Groups[3] treat Groups[4] as an Enemy
      • Player Group - Make Groups[3] treat Groups[5] as an Enemy
      • Player Group - Make Groups[3] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[3] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 15 (Turquoise) treat Player 21 (Coal) as an Neutral
      • -------- purple --------
      • Player Group - Make Groups[4] treat Groups[0] as an Enemy
      • Player Group - Make Groups[4] treat Groups[1] as an Enemy
      • Player Group - Make Groups[4] treat Groups[2] as an Enemy
      • Player Group - Make Groups[4] treat Groups[3] as an Enemy
      • Player Group - Make Groups[4] treat Groups[4] as an Ally with shared vision
      • Player Group - Make Groups[4] treat Groups[5] as an Enemy
      • Player Group - Make Groups[4] treat Player Group - Player 22 (Snow) as an Neutral with shared vision
      • Player Group - Make Groups[4] treat Player Group - Player 21 (Coal) as an Enemy
      • Player - Make Player 16 (Violet) treat Player 21 (Coal) as an Neutral
      • -------- black --------
      • Player Group - Make Groups[5] treat Groups[0] as an Enemy
      • Player Group - Make Groups[5] treat Groups[1] as an Enemy
      • Player Group - Make Groups[5] treat Groups[2] as an Enemy
      • Player Group - Make Groups[5] treat Groups[3] as an Enemy
      • Player Group - Make Groups[5] treat Groups[4] as an Enemy
      • Player Group - Make Groups[5] treat Groups[5] as an Ally with shared vision
      • Player Group - Make Groups[5] treat Player Group - Player 22 (Snow) as an Enemy
      • Player Group - Make Groups[5] treat Player Group - Player 21 (Coal) as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[0] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[1] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[2] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[3] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[4] as an Enemy
      • Player Group - Make Player Group - Player 21 (Coal) treat Groups[5] as an Ally with shared vision
      • Player Group - Make Player Group - Player 21 (Coal) treat Player Group - Player 22 (Snow) as an Enemy
      • -------- white --------
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[0] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[1] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[2] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[3] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[4] as an Ally
      • Player Group - Make Player Group - Player 22 (Snow) treat Groups[5] as an Enemy
      • Player Group - Make Player Group - Player 22 (Snow) treat Player Group - Player 21 (Coal) as an Enemy
      • -------- ------ --------
      • Set VariableSet kingdom_knight_cap[1] = ((Number of players in Groups[1]) - 2)
      • Set VariableSet kingdom_knight_cap[2] = ((Number of players in Groups[2]) - 2)
      • Set VariableSet kingdom_knight_cap[3] = ((Number of players in Groups[3]) - 2)
      • Set VariableSet kingdom_knight_cap[4] = ((Number of players in Groups[4]) - 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in Groups[0]) Equal to 0
        • Then - Actions
          • Set VariableSet additional_knight_cap = 1
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • no_knight_cap Equal to False
          • teams_locked Equal to False
        • Then - Actions
          • Countdown Timer - Pause knight_max_calculate_timer
          • Countdown Timer - Start knight_max_calculate_timer as a One-shot timer that will expire in 2.00 seconds
        • Else - Actions
      • Set VariableSet accepted_knight = 0
      • Set VariableSet accepting_king = 0
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I'll mainly comment on the first trigger, since it's easier to read. Ask yourself these questions...

Do any of those Actions in the first trigger cause another trigger to run? If yes, do they cause it to run immediately or in the queue? Furthermore, do they even share anything (same variables) that could cause problems? The answers to these questions will help you determine if it's safe or not.

Some tips:

Setting a variable isn't going to cause another trigger to run, unless it's a Real and you're doing something like this with it:
  • Events
    • Game - SomeReal becomes Equal to 1.00
But I highly doubt that you're using the "Real Event" anywhere yourself, that's often used by Jass systems to communicate with GUI (think bribe's Damage Engine or Unit Indexer). So none of the "Set Variable" actions in the first trigger cause anything else to happen which means that no other triggers are involved. In other words, it's safe.

Now look at the "Show Dialog" action at the very end of your trigger, does showing a Dialog cause any other trigger to run? No, there's no Event related to a Dialog being shown. So it's safe.

Now look at the "Run Trigger" action at the very end of your trigger. We both know that this causes another trigger to run and it's one of our "rulebreakers" that cuts in line in our trigger queue. HOWEVER, it's also the very last Action in the trigger, meaning that nothing else is going to happen after it anyway, so it's basically cutting to the front of an empty line... which is not really cutting at all.

In other words, there's nothing that could get overwritten since the trigger is already finished. So the issue I showed happening to (Integer A) in my For Loop example in my previous post is not possible in this specific situation.


The second trigger could use some more For Loops / Arrays / etc. to help simplify things, there's a lot of unnecessary repetition. But glancing through it, I think it's fine? It's really something that you need to better understand yourself because there's too many triggers in your map that we can't see. It's difficult for me to say anything for certain without seeing EVERYTHING (that's not a request, sorry).
 
Last edited:
Top