Entities needed:
- game_zone_player
- trigger_player_count
- math_counter
- logic_playerproxy
- point_servercommand
- The game_zone_player will detect automatically all the players that are inside the volume. With it, we will know how many players are at the map at the beginning.
- Then we call the math_counter, and we multiply the total number of players with the initial value of the math_counter, which represents the number of lives that has every player, setting the maximum value of the entity.
- After that, we subtract 1 from the total value. We do this because we wanna add the triggers to the last player that still alive, and only has one live left.
- The trigger_player_count will subtract 1 from the math_counter every time a player dies. When it reachs 0 (only left one player alive with only one live), it will fire his OnHitMin outputs.
- These outputs will add to the logic_playerproxy some PlayerDied outputs. This is because we can't choose when enable or disable the logic_playerproxy entity, so it would fire the outputs when a player died, instead of firing with the last alive.
- When the player dies, it will disable automatically the lives mode, by firing the mp_livesmode 0 command into the point_servercommand entity and triggering it.
- Create first the volume brush which it will be the game_zone_player entity. Put this volume on the initial spawn zone of your map.
- Place now a math_counter. Set it as "starts enabled". On the initial value, put the number of the lives that the players will have (for example 3). At the maximum value, multiply the initial value with the total number of players that your map will allow to play (example, 8 players, with 3 lives each one, makes 24).
- Place a logic_playerproxy and a point_servercommand somewhere.
- Now, create a volume brush which it will be the trigger_player_count entity. This brush must be cover all the playable area of the map (with a single volume, or a few, you will decide).
game_zone_player
Code: Select all
PlayersInCount->nameofthemath_counter->Multiply->(leave this part empty)->Delay:0->Only once:no (doesn't really matter, you are only going to use this entity once).
PlayersInCount->nameofthemath_counter->GetValue->(leave this part empty)->Delay:0->Only once:no (doesn't really matter, you are only going to use this entity once).
Code: Select all
OnGetValue->!self->Subtract->1->Delay: 0->Only once:no
OnHitMin->nameofthelogic_playerproxy->AddOutput->PlayerDied [i]nameofyourpoint_servercommand[/i]:Command:mp_livesmode 0:0:0->Delay:0 (you can delay one second without triggering the map ending, IDK for how long you will be able to delay it, but probably for not more of 3 seconds)->Only once:no
Code: Select all
OnPlayerLeave->nameofyourmath_counter->Subtract->1->Delay:0->Only once:no
With this, when the player dies, it will disable the lives mode, without triggering the end. From this point, you can trigger whatever you want (for example, I can use a game_lives_manager to give 1 live before disabling the lives mode, so all the players would appear again at the map). This system can handle any (static) number of players, from one player, to the amount you wish on your map (by setting adequately the total number of lives at the Maximum legal value at the math_counter), as well as any number of lives.
Disadvantages:
- It can't control those players who joins/leaves the map when this system started, making it not work properly (If a player joins, the outputs could be fired when not all the players are dead, and if a player leaves without spending all his lives, it could not make the count reach zero, firing the normal map ending of the lives mode, not triggering the outputs of the map when everybody died).
- Once the playerproxy sends the outputs to the last reminding player alive, there is no way to cancel these outputs. I mean, that if after disabling lives mode, and all the players respawns, if the original player dies, it will trigger these outputs.
I don't know if I explained it well, but if is necessary, I can upload a VMF as example.