• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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,202
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