• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] TeamSize missing out a couple people

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2021
Messages
89
Greetings once again to the lovely Hive Community!

I have a trigger here that should seem to be straight forward but i currently cannot seem to fix this and my brain has started to hurt.

All in all what its supposed to do is take the amount of players and divide them into wether it should be 1, 2, 3 or 4 teams and it does just that, but, hitting an uneven number after 5 means someone is left out.
Example:
1. 5 players enter the game, all 5 players hit "Team1"
2. 7 players enter the game, 3 players go on "Team1" and "Team2" but then 1 person goes on "Team3" because of how i made it, obviously i see whats going wrong, but the only solution i can come up with is writing all the "equal to" individually, and that is not going to happen, any ideas on how to fix this?

(Individually i mean like if playertotal = 20 then set teamsize to 5, and if playertotal = 19 set teamsize to 5 and stuff like that, reeeeaally dont wanna do that)

  • TeamSizeControl
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PlayerTotal Greater than 15
        • Then - Actions
          • Set VariableSet TeamSize = (PlayerTotal / 4)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PlayerTotal Greater than 10
              • PlayerTotal Less than or equal to 15
            • Then - Actions
              • Set VariableSet TeamSize = (PlayerTotal / 3)
              • Set VariableSet TeamSize = (PlayerTotal / 3)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • PlayerTotal Greater than 5
                  • PlayerTotal Less than or equal to 10
                • Then - Actions
                  • Set VariableSet TeamSize = (PlayerTotal / 2)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • PlayerTotal Greater than 0
                      • PlayerTotal Less than or equal to 5
                    • Then - Actions
                      • Set VariableSet TeamSize = PlayerTotal
                    • Else - Actions
- Thanks for even looking, hope you guys have any good ideas.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,548
You could use the Modulo math function to determine whether a number is even or odd:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PlayerTotal mod 2) Equal to 0
    • Then - Actions
      • -------- Even --------
    • Else - Actions
      • -------- Odd --------
If it's odd then simply increase PlayerTotal by 1. You can subtract 1 from it after TeamSize is calculated so it's not incorrect later on.
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
You could use the Modulo math function to determine whether a number is even or odd:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PlayerTotal mod 2) Equal to 0
    • Then - Actions
      • -------- Even --------
    • Else - Actions
      • -------- Odd --------
If it's odd then simply increase PlayerTotal by 1. You can subtract 1 from it after TeamSize is calculated so it's not incorrect later on.
You have just come up with the best and simplest solution that has taken me several days of headaches, i have without a doubt been looking to hard, i like your idea, it will easily fix my problem, and i have in my head already made it work, thank you, now i just need time to implement it! :D


EDIT: I literally just added this at the bottom, and it works like a charm! perfect! thank you so much!
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PlayerTotal mod TeamSize) Greater than 0
    • Then - Actions
      • Set VariableSet TeamSize = (TeamSize + 1)
    • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top