Hey, I have this code that gives income, and I need a function, I set it up to add the function, I just have no idea how to make it :S
What I want is a script that calculates income based on all units of unit_type Ancient owned by the player. The unit will have the income it gives in their point value.
Thanks in advance :O
What I want is a script that calculates income based on all units of unit_type Ancient owned by the player. The unit will have the income it gives in their point value.
JASS:
scope Income initializer Init
private function fTrue takes nothing returns boolean
return true
endfunction
private function CalculateIncome takes player p returns integer
return 1
endfunction
private function GiveGold takes nothing returns nothing
local player p = GetEnumPlayer()
local integer income = 1
set income = CalculateIncome(p)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + income)
endfunction
private function actions takes nothing returns nothing
local force f = CreateForce()
call ForceEnumPlayers(f,Condition(function fTrue))
call ForForce(f, function GiveGold)
call DestroyForce(f)
set f = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 5.00, true)
call TriggerAddAction(t, function actions)
endfunction
endscope
Thanks in advance :O