Hey guys, really solvable problem, which I'm having problems figuring out in GUI. I have a space map where you colonize planets one by one. When a planet is colonized, it's added to a Unit Group Array (PlanetID[player#]) where the index is the player number.
Each planet is a hero and generates income based on their strength stat. The income can be increased by 30% per upgrade of a levelable hero ability each planet has. I've got each planet contributing income properly but...
I can't seem to figure out how to calculate the combined total income of all the planets and store it in a global variable:
This trigger is obviously incomplete. The thing is, I realized I don't know how to go through each unit in a unitgroup (in this case PlanetID) and add its individual income to the TotalIncome variable using GUI
I stopped triggering at the end when I realized I couldn't get around it by declaring a 2D array because... I can't do it in GUI.
I've seen this simple sum of incomes done so many times before, any ideas?
Each planet is a hero and generates income based on their strength stat. The income can be increased by 30% per upgrade of a levelable hero ability each planet has. I've got each planet contributing income properly but...
I can't seem to figure out how to calculate the combined total income of all the planets and store it in a global variable:
Code:
Total Income
Events
Player - Player 1 (Red) types a chat message containing test2 as An exact match
Conditions
Actions
For each (Integer A) from 1 to (Number of players), do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in PlanetID[(Integer A)]) Less than 1
Then - Actions
Set TotalIncome[(Integer A)] = 0
Else - Actions
For each (Integer B) from 1 to (Number of units in PlanetID[(Integer A)]), do (Actions)
Loop - Actions
Set TotalIncome[(Integer A)] = ((Strength of (Picked unit) (Include bonuses)) + (Integer(((Real((Strength of (Picked unit) (Include bonuses)))) x (0.30 x (Real((Level of Economy for (Picked unit)))))))))
This trigger is obviously incomplete. The thing is, I realized I don't know how to go through each unit in a unitgroup (in this case PlanetID) and add its individual income to the TotalIncome variable using GUI
I stopped triggering at the end when I realized I couldn't get around it by declaring a 2D array because... I can't do it in GUI.
I've seen this simple sum of incomes done so many times before, any ideas?