• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Splitting up a player's assets

Status
Not open for further replies.
Level 4
Joined
May 6, 2007
Messages
87
Heyas, folks.

I'm a little bit stumped on how to do this correctly:

Let's say that a player has just left in a TD. I want to split his assets up (gold, towers, etc.) up between the remaining players.

This is what I've got so far:

  • Cleanup
    • Events
      • Player - Player 10 (Light Blue)'s Food used becomes Equal to 0.00
    • Conditions
    • Actions
      • -------- When Light Blue's food reaches zero (all of the attacking monsters are dead), the level is increased. --------
      • Set currentLevel = (currentLevel + 1)
      • -------- Rewards the players for surviving. --------
      • Player Group - Pick every player in (All players) and do (Player - Add (5 + (currentLevel x 2)) to (Picked player) Current gold)
      • Player Group - Pick every player in Allies_Red_Group and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to (==) Has left the game
            • Then - Actions
              • Set Units_Leaver_Group = (Units owned by (Picked player))
              • Set playerGold[(Player number of (Picked player))] = ((Player((Player number of (Picked player)))) Current gold)
              • Set totalPlayers = (Number of players in (All players matching ((((Matching player) controller) Equal to (==) User) and (((Matching player) slot status) Equal to (==) Is playing))))
              • -------- Resets the leaving player's multiboard information. --------
              • Multiboard - Set the text for (Last created multiboard) item in column 1, row boardRow[(Player number of (Picked player))] to |cff808080Disconnec...
              • Multiboard - Set the text for (Last created multiboard) item in column 2, row boardRow[(Player number of (Picked player))] to 0
              • Multiboard - Set the text for (Last created multiboard) item in column 3, row boardRow[(Player number of (Picked player))] to 0
              • Unit Group - Pick every unit in Units_Leaver_Group and do (Unit - Change ownership of (Picked unit) to (Random player from Allies_Red_Group) and Change color)
              • -------- If a player has left, his assets are split up between the remaining players. --------
                • Do Multiple ActionsFor each (Integer A) from 1 to totalPlayers, do (Actions)
                  • Loop - Actions
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • ((Player((Integer A))) slot status) Equal to (==) Is playing
                      • Then - Actions
                        • -------- The leaving player's gold is split evenly between the remaining players. --------
                        • Player - Add (playerGold[(Player number of (Picked player))] / totalPlayers) to (Player((Integer A))) Current gold
                          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Count structures controlled by (Picked player) (Include incomplete structures)) Greater than (>) 0
                            • Then - Actions
                              • -------- If the leaving player still has towers, they are split up as evenly as possible between the remaining players. --------
                              • Unit - Change ownership of (Random unit from (Units owned by (Picked player))) to (Player((Integer A))) and Change color
                            • Else - Actions
                              • Do nothing
                      • Else - Actions
                        • Do nothing
              • Custom script: call DestroyGroup(udg_Units_Leaver_Group)
            • Else - Actions
              • Do nothing
I believe that the gold is being split between the remaining players correctly. However, I am a bit stumped as to how I should go about splitting up the leaving player's towers.

  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Count structures controlled by (Picked player) (Include incomplete structures)) Greater than (>) 0
    • Then - Actions
      • -------- If the leaving player still has towers, they are split up as evenly as possible between the remaining players. --------
      • Unit - Change ownership of (Random unit from (Units owned by (Picked player))) to (Player((Integer A))) and Change color
    • Else - Actions
      • Do nothing
This is my train of thought: I thought that I could use an integer condition to see if the leaving player has towers left. If he does, then player[Integer A] would get one random tower from the leaving player. However, I can't remember whether the Loop from earlier will prevent other players from getting a turn at recieving towers; instead, it might just give the first player to go through the Loop a tower each time it loops until there are no more towers left.

Any thoughts?

Thanks for your time.
 
Level 4
Joined
May 6, 2007
Messages
87
This is what I came up with. What do you think?

  • Do Multiple ActionsFor each (Integer A) from 1 to totalPlayers, do (Actions)
    • Loop - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Player((Integer A))) slot status) Equal to (==) Is playing
        • Then - Actions
          • -------- The leaving player's gold is split evenly between the remaining players. --------
          • Player - Add (playerGold[(Player number of (Picked player))] / totalPlayers) to (Player((Integer A))) Current gold
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Count structures controlled by (Picked player) (Include incomplete structures)) Greater than (>) 0
              • Then - Actions
                • Set leavingGroup = (Units owned by (Picked player) matching (((Matching unit) is A structure) Equal to (==) True))
                • Set totalTowers[((Player number of (Picked player)) - 1)] = (Number of units in leavingGroup)
                  • Do Multiple ActionsFor each (Integer B) from 1 to totalTowers[((Player number of (Picked player)) - 1)], do (Actions)
                    • Loop - Actions
                      • -------- This loops through all of the leaving player's towers and assigns each to a player, going through the players in order, checking to see if they are still playing. --------
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • ((Player(playerNumber)) slot status) Equal to (==) Is playing
                          • Then - Actions
                            • Unit - Change ownership of (Random unit from leavingGroup) to (Player(playerNumber)) and Change color
                          • Else - Actions
                            • Do nothing
                      • Set playerNumber = (playerNumber + 1)
                      • If (playerNumber Greater than (>) 7) then do (Set playerNumber = 1) else do (Do nothing)
                • Custom script: call DestroyGroup(udg_leavingGroup)
              • Else - Actions
                • Do nothing
        • Else - Actions
          • Do nothing
 
Level 4
Joined
May 6, 2007
Messages
87
I'm not ready to take this online yet, and I'd need three computers to test it over LAN. Although, that gives me an idea. I currently have the game stop spawning creatures in lanes without an active player. Instead of giving the actual towers to someone (their only use would be to sell them...), I might just be able to get the value of all the towers and divide it up between the remaining players.
 
Status
Not open for further replies.
Top