I have made a trigger that can successfully detect if a player leaves and disperses money to the remaining players. However. in regards to win conditions, how do I make the game detect if everyone except the AI left a team and then trigger victory conditions for the opposing team?
a more efficient way would be to use 2 player groups (1 for each team). everytime a player leaves u remove the player from the player group. if done this way then the code is much simpler and more efficient.
@Stormahawk: Go
The first code is standalone, however like i said its sloppy (not efficient) . also it doesnt count ai's it filters them out via "If (Controller of player (Picked player)) == User)"
Then whenever a player leaves, remove them from the TeamXPlayers group. Finally, at the end of the player leaves trigger, call a CheckVictory action, which would do the following
Thank you for all the advice. Since every team had an AI, I ended up checking to see the number of allies the AI had every 5 seconds. If the number of allies was 0, the game would end.
Thank you for all the advice. Since every team had an AI, I ended up checking to see the number of allies the AI had every 5 seconds. If the number of allies was 0, the game would end.
Definitely works fine in this case.
In general it would be better style to check the condition only when a player leaves, so that you aren't running excessive periodic events (ofc in this case it doesn't matter like I said, but if you run into more complicated cases with large looping triggers running periodically ever .1 seconds you may notice some lagg issues, in which case you want to think about giving triggers events that only fire when they absolutely need to).
In addition you would a "cleaner feel" running the check on player leave because then it would happen instantly every game, whereas in this case it takes an apparently random amount of time between 0 and 5 seconds for victory to occur.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I have made a trigger that can successfully detect if a player leaves and disperses money to the remaining players. However. in regards to win conditions, how do I make the game detect if everyone except the AI left a team and then trigger victory conditions for the opposing team?
Here is example of a sloppy way todo it, just put it under your code.
a more efficient way would be to use 2 player groups (1 for each team). everytime a player leaves u remove the player from the player group. if done this way then the code is much simpler and more efficient.
Thanks! I think the first trigger you have might be better since it may count the AI on each team as a player.
@Stormahawk: Go The first code is standalone, however like i said its sloppy (not efficient) . also it doesnt count ai's it filters them out via "If (Controller of player (Picked player)) == User)"
You could create player groups at initialization: Team1Players, and Team2Players with
Ditto for Team 2
Then whenever a player leaves, remove them from the TeamXPlayers group. Finally, at the end of the player leaves trigger, call a CheckVictory action, which would do the following
if Team1Players is empty ==> Team 2 Victory
if Team2Players is empty ==> Team1 Victory
Thank you for all the advice. Since every team had an AI, I ended up checking to see the number of allies the AI had every 5 seconds. If the number of allies was 0, the game would end.
Definitely works fine in this case.
In general it would be better style to check the condition only when a player leaves, so that you aren't running excessive periodic events (ofc in this case it doesn't matter like I said, but if you run into more complicated cases with large looping triggers running periodically ever .1 seconds you may notice some lagg issues, in which case you want to think about giving triggers events that only fire when they absolutely need to).
In addition you would a "cleaner feel" running the check on player leave because then it would happen instantly every game, whereas in this case it takes an apparently random amount of time between 0 and 5 seconds for victory to occur.