• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Swap system, whats missing?

Status
Not open for further replies.
Level 6
Joined
Aug 31, 2018
Messages
157
  • Init1
    • Events
      • Player - Player 1 (Red) types a chat message containing swap as A substring
      • Player - Player 2 (Blue) types a chat message containing swap as A substring
      • Player - Player 3 (Teal) types a chat message containing swap as A substring
      • Player - Player 4 (Purple) types a chat message containing swap as A substring
      • Player - Player 5 (Yellow) types a chat message containing swap as A substring
      • Player - Player 7 (Green) types a chat message containing swap as A substring
      • Player - Player 8 (Pink) types a chat message containing swap as A substring
      • Player - Player 9 (Gray) types a chat message containing swap as A substring
      • Player - Player 10 (Light Blue) types a chat message containing swap as A substring
      • Player - Player 11 (Dark Green) types a chat message containing swap as A substring
    • Conditions
      • CanSwap Equal to 1
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 1
          • ((Triggering player) is an ally of Player 1 (Red).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 1
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[1] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 2
          • ((Triggering player) is an ally of Player 1 (Red).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 2
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by Player 2 (Blue) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 2 (Blue) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 2 (Blue) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[2] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 3
          • ((Triggering player) is an ally of Player 1 (Red).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 3
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 3 (Teal) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 3 (Teal) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 3 (Teal) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[3] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 4
          • ((Triggering player) is an ally of Player 1 (Red).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 4
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 4 (Purple) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 4 (Purple) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 4 (Purple) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[4] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 5
          • ((Triggering player) is an ally of Player 1 (Red).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 5
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 5 (Yellow) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 5 (Yellow) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 5 (Yellow) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[5] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 6
          • ((Triggering player) is an ally of Player 7 (Green).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 7
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 7 (Green) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 7 (Green) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 7 (Green) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[7] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 7
          • ((Triggering player) is an ally of Player 7 (Green).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 8
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 8 (Pink) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 8 (Pink) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 8 (Pink) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[8] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 8
          • ((Triggering player) is an ally of Player 7 (Green).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 9
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 9 (Gray) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 9 (Gray) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[9] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 9
          • ((Triggering player) is an ally of Player 7 (Green).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 10
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 10 (Light Blue) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[10] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap 10
          • ((Triggering player) is an ally of Player 7 (Green).) Equal to True
        • Then - Actions
          • Set VariableSet Swap[(Player number of (Triggering player))] = 11
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Swap[Swap[(Player number of (Triggering player))]] Equal to (Player number of (Triggering player))
            • Then - Actions
              • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) has buff Pet ) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Remove (Picked unit) from the game
              • Unit Group - Pick every unit in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to Player 11 (Dark Green) and Change color
                  • Set VariableSet TempUnit = (Picked unit)
              • Unit Group - Pick every unit in (Units owned by Player 11 (Dark Green) matching ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to TempUnit)).) and do (Actions)
                • Loop - Actions
                  • Unit - Change ownership of (Picked unit) to (Triggering player) and Change color
              • Set VariableSet Swap[(Player number of (Triggering player))] = 0
              • Set VariableSet Swap[11] = 0
            • Else - Actions
              • Do nothing
        • Else - Actions
          • Do nothing
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
Your logic is sound but you're doing yourself a disservice by making it so complicated. You can design the trigger to work without the need of making specific cases for each player.
  • Swap
    • Events
      • Player - Player 1 (Red) types a chat message containing -swap as A substring
    • Conditions
    • Actions
      • Set VariableSet Swap_Integer = (Integer((Substring((Entered chat string), 7, 8))))
      • -------- --------
      • Set VariableSet Swap_Source = (Triggering player)
      • Set VariableSet Swap_Source_PN = (Player number of (Triggering player))
      • -------- --------
      • Set VariableSet Swap_Target[Swap_Source_PN] = (Player(Swap_Integer))
      • Set VariableSet Swap_Target_PN = (Player number of Swap_Target[Swap_Source_PN])
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Swap_Source is an ally of Swap_Target[Swap_Source_PN].) Equal to True
          • Swap_Target[Swap_Target_PN] Equal to Swap_Source
        • Then - Actions
          • -------- Change Source Hero Ownership --------
          • Set VariableSet TempGroup = (Units owned by Swap_Source matching (((Matching unit) is A Hero) Equal to True).)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Change ownership of (Picked unit) to Swap_Target[Swap_Source_PN] and Change color
          • Custom script: call DestroyGroup (udg_TempGroup)
          • -------- --------
          • -------- Change Target Hero Ownership --------
          • Set VariableSet TempGroup = (Units owned by Swap_Target[Swap_Target_PN] matching (((Matching unit) is A Hero) Equal to True).)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Change ownership of (Picked unit) to Swap_Source and Change color
          • Custom script: call DestroyGroup (udg_TempGroup)
          • -------- --------
          • -------- Remove Source Pets --------
          • Set VariableSet TempGroup = (Units owned by Swap_Source matching (((Matching unit) has buff Aerial Shackles) Equal to True).)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup (udg_TempGroup)
          • -------- --------
          • -------- Remove Target Pets --------
          • Set VariableSet TempGroup = (Units owned by Swap_Target[Swap_Target_PN] matching (((Matching unit) has buff Aerial Shackles) Equal to True).)
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
          • Custom script: call DestroyGroup (udg_TempGroup)
          • -------- --------
          • Set VariableSet Swap_Target[Swap_Source_PN] = Neutral Passive
          • Set VariableSet Swap_Target[Swap_Target_PN] = Neutral Passive
        • Else - Actions
Some notes:
You're leaking Unit Groups when you use "Pick every unit...". I fix this by creating a temporary Unit Group (TempGroup) which is destroyed after we're done using it.

Do Nothing is pointless, you can just leave the Else - Actions blank.

Something to be aware of, I left out CanSwap1, the other Players in the Events, and i'm using Aerial Shackles as the "Pet" buff.
 

Attachments

  • Swap Example.w3m
    17.2 KB · Views: 28
Last edited:
Status
Not open for further replies.
Top