I'm trying to make a more-or-less king of the hill map in which the player with the biggest amount of units in a region will receive victory points.
I got the trigger working but it's incredible inefficient - I bet alot of you guys know how make it more efficient.
Basicly in the trigger I have a If Then Else Action where I check a And condition. The And condition compares if number of units owned by player 1 in the region is bigger than the number of units owned by player 2 in the region AND if number of units owned by player 1 in the region is bigger than number of units owned by player 3 in the region AND etc for player 1 compared to 4 and player 1 compared to 5. Then give VP to player 1. ELSE compare if player 2 has bigger number than player 3 etc etc.
Again, this is incredible inefficient. Also, I don't know yet what to about a tie except creating a gigantic If Then Else comparison again between player 1&2 > to rest etc etc.
Do you have any suggestions?
I hope I made the situation pretty clear. Basicly, I'm looking for a function that finds the biggest integer among a group of integers (number of units) and another one that can give me the leading tie.
@Flabberghast: Go
I would create an array of ints with 15 slots, called unitCount. Then I would make a function with a player int and a region as paramters, that updates the slot with the id of the players number.
So when you start comparing the numbers (finding max) you would have an array with the numbers to compare. This is important.
max (int) = 0
king (int) = 0
player (int) = 0
For each integer (player,0,14,1)
if(unitCount[player] > max) {
_ then
_ _ max = unitCount[player]
_ _ king = player }
else {}
The king int is then the player number.
If you want team-scores, you would have to make a similar array for team score and then compare them instead.
You can't pass arrays as arguments in the editor.
Its getting late here so I'm not sure this would work... ;)
@SouLCarveRR yea that's the function I use. The problem I had is that the loops comparing all players when there's (say) 8 players gets extremely tedious.
@Monkalizer That's basicly how I solved it now. Works fine thanks. The problem I got right now is how to simplify solving ties. Because I want the player with most units get 1st place victory points, player with second most gets 2nd place victory points. If there's a tie for first place, then they share 2nd most VP and no other gets points. If there is a tie for second place (but not first place), tied players don't receive anything.
I'll post something more when I got a bit further with the issue.
Hi Mapster!
I'm trying to make a more-or-less king of the hill map in which the player with the biggest amount of units in a region will receive victory points.
I got the trigger working but it's incredible inefficient - I bet alot of you guys know how make it more efficient.
Basicly in the trigger I have a If Then Else Action where I check a And condition. The And condition compares if number of units owned by player 1 in the region is bigger than the number of units owned by player 2 in the region AND if number of units owned by player 1 in the region is bigger than number of units owned by player 3 in the region AND etc for player 1 compared to 4 and player 1 compared to 5. Then give VP to player 1. ELSE compare if player 2 has bigger number than player 3 etc etc.
Again, this is incredible inefficient. Also, I don't know yet what to about a tie except creating a gigantic If Then Else comparison again between player 1&2 > to rest etc etc.
Do you have any suggestions?
I hope I made the situation pretty clear. Basicly, I'm looking for a function that finds the biggest integer among a group of integers (number of units) and another one that can give me the leading tie.
Thanks!
@Flabberghast: Go I would create an array of ints with 15 slots, called unitCount. Then I would make a function with a player int and a region as paramters, that updates the slot with the id of the players number.
So when you start comparing the numbers (finding max) you would have an array with the numbers to compare. This is important.
max (int) = 0
king (int) = 0
player (int) = 0
For each integer (player,0,14,1)
if(unitCount[player] > max) {
_ then
_ _ max = unitCount[player]
_ _ king = player }
else {}
The king int is then the player number. If you want team-scores, you would have to make a similar array for team score and then compare them instead. You can't pass arrays as arguments in the editor.
Its getting late here so I'm not sure this would work... ;)
@Flabberghast: Go
Number of units in unit group( all units in entire map owned by player 1) > Number of units in unit group( all units in entire map owned by player 2)
basically creating unit groups on the fly... theres a built in function that returns the count of units in the unit group.
theres filters on creating the unit groups so you dont count (dead units, missle units, worker units, structures, or heros) lots of options
You would have to loop through all the players and find which player has the most units in the given region.
@SouLCarveRR yea that's the function I use. The problem I had is that the loops comparing all players when there's (say) 8 players gets extremely tedious.
@Monkalizer That's basicly how I solved it now. Works fine thanks. The problem I got right now is how to simplify solving ties. Because I want the player with most units get 1st place victory points, player with second most gets 2nd place victory points. If there's a tie for first place, then they share 2nd most VP and no other gets points. If there is a tie for second place (but not first place), tied players don't receive anything.
I'll post something more when I got a bit further with the issue.
Im thinking aboutmaking an example using string manipulation....
but yeah you have to do a bunch of condition checks...