Using a condition that looks if the number is even or odd

I want to modify something in a gamemode I made. It is a PVE where each 2 rounds, a random bot is added. For exemple, if at round 1 there is reaper, at round 3 a random hero will be added so it might be Reaper and Widowmaker. Round 5, another random hero is added.
So far i have my initial condition that every round, it will look the following IF condition

If round ==1
add reaper in the array
else if round == 3
add random hero in the array

I have this condition going from round 1 and doing all heroes in the game. The only problem is that it takes a lot of place and I was wondering if it was possible to say every time the round number is even or odd. So it looks the IF condition every time the round number is either 2,4,6… etc.

If I can clarify something, please let me know.

modulo(global variable(round), 2) == 0 detects even numbers.

modulo(global variable(round), 2) == 1 detects odd numbers.

What the modulo function (it exists in math aswell, thats why I use the term “function” and not “action”) does is an integer division, but instead of returning the result it returns the rest of a natural-number division.
So it returns 0 if the first number “can” be divided by the second number and it returns 1 or higher if the first number “can’t” be divided by the second number.

2 Likes

Thank you for your answer :smiley:

1 Like