Check How Many Teams Alive
-
Is there a function to count total teams in a game and see if the teams have been eliminated? Basically, need to be able to check if only two teams are still alive. So, for example, if a game starts with 4 teams (or FFA), I would be able to know when only two teams are left.
I have an idea for a (horribly written) script that might do this, but if there is a function already available, that would be great.
-
After beating rocks together, I found a simple solution to my problem. I wouldn't call it elegant, but it works.
-
Depends on what you need: sim or UI script.
-
It is for SIM, really just needed to check if Team/FFA count was down to just 2 players.
-
There's likely an easier way, but one option is to cycle through each brain in ArmyBrains, exclude civilian brains, create a shortlist of those brains that aren't showing as defeated, sort them into teams using IsEnemy(), and use that to come up with a number.
What approach did you use?
-
That is actually very close to what I did. After spending hours failing with overly convoluted attempts, I figured there must be a simpler way!
I already had a list of armies that weren't allied with the HQ. Just ran a check to see if they were allied with each other or not.
-
Hey @Rama, i found this:
code to check if a brain is defeated:
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L66check for allied players:
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/victory.lua#L95maybe this can help to improve your code.
-
Oh, thank you! Will look through it. The current method is simpler and does the task, but this looks to give an accurate team count.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login