I have a tower defence map where gold is distributed to players at the end of each round. There is a gold pool which is split according to the pecentage of kills someone has. The idea is that the more kills someone has, the less of the gold pool they get. The less kills someone has, the more of the gold pool they get.
Here's the simplified version of my trigger
The system worked fine when there are only 2 players, but I think the system won't work when there are more. Take a look at the screenshot from in game.
30 total kills
player 1 has 30 kills
player 2 has 0 kill
player 3 has 0 kills
The system will award player 2 and 3 with 30 gold each. The total gold pool is 30, so they should each only get 15 each and player 1 should get nothing.
Can anyone help fix my system?
Here's the simplified version of my trigger
-
Add Point
-
Events
-
Unit - A unit owned by Player 11 (Dark Green) Dies
-
Unit - A unit owned by Player 12 (Brown) Dies
-
-
Conditions
-
Actions
-
Set leaderboard[(Player number of (Owner of (Killing unit)))] = (leaderboard[(Player number of (Owner of (Killing unit)))] + 1)
-
Set TotalKills = (TotalKills + 1)
-
Leaderboard - Change the value for (Owner of (Killing unit)) in (Last created leaderboard) to leaderboard[(Player number of (Owner of (Killing unit)))]
-
Leaderboard - Sort (Last created leaderboard) by Value in Descending order
-
-
-
Distribute Gold
-
Events
-
Conditions
-
Actions
-
Game - Display to (All players) for 15.00 seconds the text: Round Complete!
-
Set TempInteger = (Number of players in PlayersGroup)
-
Set GoldPool = 30.00
-
Player Group - Pick every player in PlayersGroup and do (Actions)
-
Loop - Actions
-
Set GoldPlayerPercentage[(Player number of (Picked player))] = ((Real(leaderboard[(Player number of (Picked player))])) / (Real(TotalKills)))
-
Set TempReal = ((1.00 - GoldPlayerPercentage[(Player number of (Picked player))]) x GoldPool)
-
Player - Add (Integer(TempReal)) to (Picked player) Current gold
-
-
-
-
The system worked fine when there are only 2 players, but I think the system won't work when there are more. Take a look at the screenshot from in game.
30 total kills
player 1 has 30 kills
player 2 has 0 kill
player 3 has 0 kills
The system will award player 2 and 3 with 30 gold each. The total gold pool is 30, so they should each only get 15 each and player 1 should get nothing.
Can anyone help fix my system?