- Joined
- Sep 2, 2005
- Messages
- 1,029
JASS:
function ResourceTaxes takes nothing returns nothing
local integer i = -1
local integer taxes = 0
local integer water = 0 //These are just to make the code easier to read
local group g
local integer heroRate = 50
local integer buildingRate = 25
local integer entRate = buildingRate
local integer entBuilderRate = entRate/2
local integer remainder
local group all
local integer allCount
local integer i2 = -1
loop
set i = i+1
exitwhen i==12
set water = GetPlayerState(Player(i),PLAYER_STATE_RESOURCE_GOLD)
//call DisplayTextToForce( GetPlayersAll(), "Current Water: "+I2S(water)+" water" )
//Remove the water for the cost of the buildings and units.
set all= GetUnitsOfPlayerAll(Player(i))
set allCount = CountUnitsInGroup(all)
//Ent Heroes = 10/s
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00A')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00H')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00K')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00J')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00B')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00I')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00M')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00L')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'n000')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'n001')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'n002')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'n003')
set taxes = taxes + CountUnitsInGroup(g) * heroRate
//Buildings = 2/s
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'h000')
set taxes = taxes + CountUnitsInGroup(g) * buildingRate
//Ent Builders = 1/s
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00e')
set taxes = taxes + CountUnitsInGroup(g) * entBuilderRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00s')
set taxes = taxes + CountUnitsInGroup(g) * entBuilderRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00t')
set taxes = taxes + CountUnitsInGroup(g) * entBuilderRate
set g = GetUnitsOfPlayerAndTypeId(Player(i), 'e00u')
set taxes = taxes + CountUnitsInGroup(g) * entBuilderRate
call DisplayTextToForce( GetPlayersAll(), "Taxes: "+I2S(taxes)+" water" )
//call DisplayTextToForce( GetPlayersAll(), "Total: "+I2S(water-taxes)+" water" )
call SetPlayerState( Player(i), PLAYER_STATE_RESOURCE_GOLD, water - taxes)
call DestroyGroup(g)
set g = null //This is how you clear the group,
endloop // and it must be in the loop for this function
endfunction
There's my function.
So its supposed to go through the units and have taxes according to the unit in question. Unfortunately, at the end, the tax amount always comes up as 0 regardless of what I do. Any suggestions?