library Ability initializer Init
globals
private constant real INTERVAL = 3.00
private constant integer ABILITY ='A000' //Add Lumber Ability Raw Code
private constant integer LUMBER = 3
endglobals
// Create floating text for player. Basically I made the system working in multiplayer...
public function AddFT takes player p , string s , real x , real y, real speed, real angle, real scale returns nothing
local texttag FT
if GetLocalPlayer( ) == p then
set FT = CreateTextTag( )
call SetTextTagPos( FT , x , y , 128 )
call SetTextTagPermanent( FT , false )
call SetTextTagVelocity( FT, (speed * 0.071 / 128) * Cos(angle * bj_DEGTORAD), (speed * 0.071 / 128) * Sin(angle * bj_DEGTORAD) )
call SetTextTagFadepoint( FT , 90. )
call SetTextTagLifespan( FT , 2. )
call SetTextTagText( FT , s , scale )
call SetTextTagVisibility( FT , true )
endif
set FT = null
endfunction
private function IncreaseLumber takes nothing returns boolean
local unit u
call GroupEnumUnitsInRect(bj_lastCreatedGroup, bj_mapInitialPlayableArea, null)
loop
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen u == null
if GetUnitAbilityLevel(u, ABILITY) > 0 then
call SetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_LUMBER) + LUMBER)
call AddFT(GetOwningPlayer(u), "|c0020C000+ " + I2S(LUMBER), GetUnitX(u), GetUnitY(u), 65., 90., 0.02)
endif
call GroupRemoveUnit(bj_lastCreatedGroup, u)
endloop
return false
endfunction
function Init takes nothing returns nothing
local trigger T = CreateTrigger()
call TriggerRegisterTimerEvent(T, INTERVAL, true)
call TriggerAddCondition( T, Condition( function IncreaseLumber ) )
set T = null
endfunction
endlibrary