• 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.

Count Mercenary Upkeep

Status
Not open for further replies.
Level 3
Joined
Feb 12, 2020
Messages
34
Hi guys,

I am still working on my map, where players can buy strong units at the cost of an additional upkeep paid in gold.
I am using an integer variable to count the total "Mercenary_Upkeep".


The upkeep is calculated by the following action:

Player Group - Pick every player in (All players) and do (Player - Add (0 - Total_Upkeep_Mercs[(Player number of (Picked player))]) to (Picked player).Current gold).

This works as I count positited numbers but have to substract it from the regular income recieved, thats why its 0 - "Mercenary_Upkeep".

For now I have a total of 5 potential mercenary units to be recruited. The problem starts here. I want to add all 5 units to the total "Mercenary_Upkeep", each with a different amount of upkeep. I figured out how to do this with 2 mercenary units as you can read below:

All Mercenary Upkeep set
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Player Group - Pick every player in (All players) and do (Set VariableSet Total_Upkeep_Mercs[(Player number of (Picked player))] = (((Number of living Golden Centaur Horde 1 units owned by (Picked player)) x 120) + ((Number of living Golden Centaur Horde 2 units owned by (Picked player)) x 190)))


Like this, each unit will calculate a different amount of upkeep, still added to the same variable. But how do I do this with more than 2 units? The arithmetic fucntion only allows you to do this with 2 of them in one action.

Please help me out :)))
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
I don't exactly get all the details of what you are trying to do, but you could probably just -

Player Group - Pick every player in (All players) and do -

if then else multiple functions:

if unit is x then do y

else :
if then else...:


and just specify what to do for each kind of unit....
 
Level 3
Joined
Feb 12, 2020
Messages
34
Thanks for your reply. I get what you are trying to say, though I am at the final bit.
The action always starts with "set veriable". If I would have multiple actions setting the same variable they would be overriding each other :0

I am missing something Im sure, but this is where Im getting stuck at.
 
Level 25
Joined
Mar 29, 2020
Messages
1,466
oh, I think the solution is actually much simpler... after the + part of your function, select arithmetic again. and keep doing that untill you add in all the info you want.

like this:

Player - Add (10 + (10 + (10 + (10 + 10)))) to Player 2 (Blue) Current gold
 
Level 3
Joined
Feb 12, 2020
Messages
34
I got too confused trying that one out. I found another probably longer solution to it.
The total amount of various mercs is now 6. Each action as I made them can only combine 2 units into one variable. I simply made a bracket, using a total of 3 variables merged by a total of 6 actions.

Thanks for your help :))
 
Status
Not open for further replies.
Top