• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Gold Distribution?

Status
Not open for further replies.
Level 5
Joined
Jul 24, 2008
Messages
106
How do you distribute gold to different teams? My map has 2 teams, each with a maximum of five players. How do I distribute a set amount of gold to the active players in one team?

For example:
----------------------
3/5 players are active in team A. How do I equally distribute 5000 gold to the 3 players?
2/5 players are active in team B. How do I equally distribute 5000 gold to the 2 players?
----------------------

I was thinking of putting this in the Map Initialization trigger..
Some sort of thing to avoid handicap if the state is 2 versus 1, 4 versus 3, etc..
 
Level 18
Joined
Mar 13, 2009
Messages
1,411
I would say that you should first store the amount of active users in an integer. Then you would just have to make an action that increases the property for those players by 5000/number of active users in the team.

For each Integer A from 1 to 5 do:
If player (Integer A) is Playing.
Add player to ActivePlayers

And in another action:
Pick all players in ActivePlayers and add propery equal to 5000/[number of players in ActivePlayers]

I currently don't have the option to open my Editor.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
My green circle TD version uses the very system you want, I can advise you look at the unoptimized versions to see how I did it.

Basically you need to count the whole number value that you have to add to each player. So you firstly count active players. You then get the total and divied it by that number to work out how much each. Finally you give it to all the players who are affected. This involves the use of forces.
This results in any remainder getting lost, which is generally a good idea as in your case it can atmost be 4 gold lost which is better than having people argue over the distribution being unfair.
 
Level 5
Joined
Jul 24, 2008
Messages
106
I would say that you should first store the amount of active users in an integer. Then you would just have to make an action that increases the property for those players by 5000/number of active users in the team.

For each Integer A from 1 to 5 do:
If player (Integer A) is Playing.
Add player to ActivePlayers


And in another action:
Pick all players in ActivePlayers and add propery equal to 5000/[number of players in ActivePlayers]

I currently don't have the option to open my Editor.

Could you enlighten me on how to perform this part?

I've done the integer for ActivePlayers for each team.

{EDIT}
My green circle TD version uses the very system you want, I can advise you look at the unoptimized versions to see how I did it.

Basically you need to count the whole number value that you have to add to each player. So you firstly count active players. You then get the total and divied it by that number to work out how much each. Finally you give it to all the players who are affected. This involves the use of forces.
This results in any remainder getting lost, which is generally a good idea as in your case it can atmost be 4 gold lost which is better than having people argue over the distribution being unfair.

Hmm, I'll try doing this too, thanks! :D
 
Last edited by a moderator:
Level 5
Joined
Jul 24, 2008
Messages
106
the bold part :grin:

{EDIT}
problem solved, I got the results I wanted to see. Thanks!
 
Last edited by a moderator:
Status
Not open for further replies.
Top