1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Split leaver gold equally

Discussion in 'Triggers & Scripts' started by Vacant, Sep 4, 2019.

  1. Vacant

    Vacant

    Joined:
    Jul 10, 2019
    Messages:
    5
    Resources:
    0
    Resources:
    0
    Trying to make a leaving players gold be equally split among remaining players. The message displays the correct number but no gold is added to anyones resources. I have another trigger that sets Player_User = All players matching controller equal to user

    • Leaver
      • Events
        • Time - Every 2.00 seconds of game time
      • Conditions
        • (Player 1 (Red) slot status) Equal to Has left the game
      • Actions
        • Game - Display to (All players) for 10.00 seconds the text: ((Name of Player 1 (Red)) + |c0000cdf9 has left the game|r)
        • Player Group - Remove Player 1 (Red) from Player_User
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) 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) is A structure) Equal to False
              • Then - Actions
                • Unit - Remove (Picked unit) from the game
              • Else - Actions
                • Unit - Change ownership of (Picked unit) to (Random player from Player_User) and Change color
        • Set leaverGold = (Player 1 (Red) Current gold)
        • Player Group - Pick every player in Player_User and do (Player - Add (leaverGold / (Number of players in Player_User)) to (Picked player) Current gold)
        • Player Group - Pick every player in Player_User and do (Game - Display to (All players) the text: (|cff8080ffYou received |r + ((String((leaverGold / (Number of players in Player_User)))) + |cff8080ff gold from the leaving player.|r)))
        • Trigger - Turn off Wave Spawning Red <gen>
        • Trigger - Turn off (This trigger)
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,905
    Resources:
    1
    Spells:
    1
    Resources:
    1
    • There is a "<Player> leaves the game" event you could use instead of this. I presume you have a trigger like this for every player? They could all be combined into one using an event like that for each slot that could have a user player.

    • You could compute leaverGold = (<Player> current gold) / (Number of players in Player_User) to save yourself having to recompute it each time.

    • The 'gold received' message doesn't need to be inside a Player Group - Pick action.

    • If it truly is displaying the right number of gold but not adding it, I do not see the reason for this. Looks like it should work to me. I would delete the whole line and create it again.
     
  3. Vacant

    Vacant

    Joined:
    Jul 10, 2019
    Messages:
    5
    Resources:
    0
    Resources:
    0
    I ended up with something like this and it seems to work fine now. I don't understand how I could combine it though.

    • Red Leaver
      • Events
        • Player - Player 1 (Red) leaves the game
      • Conditions
      • Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Set tempUserGroup = (All players matching (((Matching player) slot status) Equal to Is playing))
        • Set leaverGold = ((Player 1 (Red) Current gold) / (Number of players in tempUserGroup))
        • Player Group - Pick every player in tempUserGroup and do (Player - Add leaverGold to (Picked player) Current gold)
        • Game - Display to (All players) for 10.00 seconds the text: ((Name of Player 1 (Red)) + |c0000cdf9 has left the game|r)
        • Game - Display to (All players) for 10.00 seconds the text: (|cff8080ffYou received |r + ((String(leaverGold)) + |cff8080ff gold from the leaving player.|r))
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) is A structure) Equal to False
              • Then - Actions
                • Unit - Remove (Picked unit) from the game
              • Else - Actions
                • Unit - Change ownership of (Picked unit) to (Random player from tempUserGroup) and Change color
        • Trigger - Turn off Wave Spawning Red <gen>
     
  4. wc3neverdies

    wc3neverdies

    Joined:
    Sep 20, 2015
    Messages:
    281
    Resources:
    1
    Maps:
    1
    Resources:
    1
    As Pyrogasm said, you can add multiple player in the event and then use TriggerPlayer to do the actions you need.

    Event
    Player 1 leave the game
    Player 2 leave the game
    ecc

    Actions
    ...
    Display Text to All players : (Name of (Trigger Player) has left the game)
    Pick every unit in Map Area Owned by Trigger Player
     
  5. Vacant

    Vacant

    Joined:
    Jul 10, 2019
    Messages:
    5
    Resources:
    0
    Resources:
    0
    Oh I see. Something like this then?
    • Leaver
      • Events
        • Player - Player 1 (Red) leaves the game
        • Player - Player 2 (Blue) leaves the game
      • Conditions
      • Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Set tempUserGroup = (All players matching (((Matching player) controller) Equal to User))
        • Set leaverGold = (((Triggering player) Current gold) / (Number of players in tempUserGroup))
        • Player Group - Pick every player in tempUserGroup and do (Player - Add leaverGold to (Picked player) Current gold)
        • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Triggering player)) + |c0000cdf9 has left the game|r)
        • Game - Display to (All players) for 10.00 seconds the text: (|cff8080ffYou received |r + ((String(leaverGold)) + |cff8080ff gold from the leaving player.|r))
        • Unit Group - Pick every unit in (Units in (Playable map area) owned by (Triggering player)) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Picked unit) is A structure) Equal to False
              • Then - Actions
                • Unit - Remove (Picked unit) from the game
              • Else - Actions
                • Unit - Change ownership of (Picked unit) to (Random player from Player_User) and Change color
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Triggering player) Equal to Player 1 (Red)
          • Then - Actions
            • Trigger - Turn off Wave Spawning Red <gen>
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Triggering player) Equal to Player 2 (Blue)
          • Then - Actions
            • Trigger - Turn off Wave Spawning Blue <gen>
          • Else - Actions
     
  6. wc3neverdies

    wc3neverdies

    Joined:
    Sep 20, 2015
    Messages:
    281
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Yes. You can and add as many player as you want.