Removing all units of control and splitting gold.

Ub3r_

New Member
Reaction score
4
Ok, so I'm making a TD and I'm wondering how I would make it if someone leaves all their towers are removed and their gold is shared equally/almost equally among the remaining players. Thanks if you can help.
 

Draphoelix

It's not the wintercold that's killing me
Reaction score
132
Something similar:

Player 1 Leaves

Set Gold = Gold of Player 1
Set Gold 2 = Gold of Player 1 / Player Number playing
Pick every player in all player
Picked is playing
Set gold of Picked to gold of Picked + Gold 2
 

saw792

Is known to say things. That is all.
Reaction score
280
Here is a trigger that will perform that function (perhaps not as efficiently as it should be, but it will work). You will need one of these for each player, replacing Player 1 (Red) with Player 2 (Blue) etc.
Code:
Untitled Trigger 001
    Events
        Player - Player 1 (Red) leaves the game
    Conditions
    Actions
        Set TempGroup = (Units owned by Player 1 (Red))
        Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
        Set CurrentPlayers = (All players matching ((Matching player) Not equal to Player 1 (Red)))
        Player - Set Player 2 (Blue) Current gold to ((Player 2 (Blue) Current gold) + ((Player 1 (Red) Current gold) / (Number of players in CurrentPlayers)))
        Player - Set Player 3 (Teal) Current gold to ((Player 3 (Teal) Current gold) + ((Player 1 (Red) Current gold) / (Number of players in CurrentPlayers)))
... {the rest of the players with same action}
        Custom script:   call DestroyGroup (udg_TempGroup)

Edit: Just realised that CurrentPlayers will include players who have already left. I'll fix it if I can be bothered.
 

saw792

Is known to say things. That is all.
Reaction score
280
Here this trigger should work fine. Once again, I'm sure it could be done more efficiently but oh well.

Variables:
RedLeft = Player
BlueLeft = Player
TealLeft = Player
...

LeftPlayers = Player Group
CurrentPlayers = Player Group
TempGroup = Unit Group

LeftPlayers should not be cleared/deleted at the end of each trigger as it is checked every time a player leaves.

Code:
    Events
        Player - Player 1 (Red) leaves the game
    Conditions
    Actions
        Set RedLeft = Player 1 (Red)
        Player Group - Add RedLeft to LeftPlayers
        Set TempGroup = (Units owned by Player 1 (Red))
        Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
        Set CurrentPlayers = (All players matching (((Matching player) is in LeftPlayers) Not equal to True))
        Player - Set Player 2 (Blue) Current gold to ((Player 2 (Blue) Current gold) + ((Player 1 (Red) Current gold) / (Number of players in CurrentPlayers)))
        Player - Set Player 3 (Teal) Current gold to ((Player 3 (Teal) Current gold) + ((Player 1 (Red) Current gold) / (Number of players in CurrentPlayers)))
        -------- Insert the rest of the player gold actions here. --------
        Custom script:   call DestroyGroup (udg_TempGroup)
        Player Group - Remove all players from CurrentPlayers
 

Ub3r_

New Member
Reaction score
4
Looks great. Just 2 things I can't find.

1. Set CurrentPlayers = (All players matching (((Matching player) is in LeftPlayers) Not equal to True))

2. Player Group - Remove all players from CurrentPlayers
 

saw792

Is known to say things. That is all.
Reaction score
280
1. First use 'All Players Matching Condition' and then 'Boolean Comparison' and then 'Player - Player in Player Group'.

2. Player Group - Clear
 

saw792

Is known to say things. That is all.
Reaction score
280
Remember that will only cover if red leaves. You will also need more triggers for if blue leaves, if teal leaves, etc. Put them in a folder :)

Edit: One more thing. Players on the enemy team must also be removed from CurrentPlayers. For example, if you have a computer controlled enemy as Player 12 (Brown) add in this line directly below Set CurrentPlayers = ...
Code:
Player Group - Remove Player 12 (Brown) from CurrentPlayers
 

Ub3r_

New Member
Reaction score
4
Remember that will only cover if red leaves. You will also need more triggers for if blue leaves, if teal leaves, etc. Put them in a folder :)

Edit: One more thing. Players on the enemy team must also be removed from CurrentPlayers. For example, if you have a computer controlled enemy as Player 12 (Brown) add in this line directly below Set CurrentPlayers = ...
Code:
Player Group - Remove Player 12 (Brown) from CurrentPlayers

Ok I added that in and I've made the triggers for the otehr players. Thanks.
 

saw792

Is known to say things. That is all.
Reaction score
280
It's a bit late now, but I've realised that all the triggers can be combined quite easily. Silly me.

Code:
Events
        Player - Player 1 (Red) leaves the game
        Player - Player 2 (Blue) leaves the game
        Player - Player 3 (Teal) leaves the game
        ---Remaining human-controlled players--
    Conditions
    Actions
        Set Leaver = (Triggering Player)
        Player Group - Add Leaver to LeftPlayers
        Set TempGroup = (Units owned by (Triggering Player))
        Unit Group - Pick every unit in TempGroup and do (Unit - Remove (Picked unit) from the game)
        Set CurrentPlayers = (All players matching (((Matching player) is in LeftPlayers) Not equal to True))
        Player Group - Remove Player 12 (Brown) from CurrentPlayers
        -----------------Other enemy players here-----------------
        If ((Triggering player) Not equal to Player 1 (Red)) then do (Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) + ((Triggering Player) Current gold) / (Number of players in CurrentPlayers)))) else do (Do Nothing)
        If ((Triggering player) Not equal to Player 2 (Blue)) then do (Player - Set Player 2 (Blue) Current gold to ((Player 2 (Blue) Current gold) + ((Triggering Player) Current gold) / (Number of players in CurrentPlayers)))) else do (Do Nothing)
        If ((Triggering player) Not equal to Player 3 (Teal)) then do Player - Set Player 3 (Teal) Current gold to ((Player 3 (Teal) Current gold) + ((Triggering Player) Current gold) / (Number of players in CurrentPlayers)))) else do (Do Nothing)
        -------- Insert the rest of the player gold actions here. --------
        Custom script:   call DestroyGroup (udg_TempGroup)
        Player Group - Remove all players from CurrentPlayers

Variables:
Leaver = Player
TempGroup = Unit Group
LeftPlayers = Player Group
CurrentPlayers = Player Group
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top