Name | Type | is_array | initial_value |
function GiveLumberForLumberMills takes nothing returns nothing
local integer i = 0
local player p
local group g
local unit u
local integer lumberMills
local integer lumberIncome
// Loop through all players
loop
exitwhen i >= bj_MAX_PLAYERS
set p = Player(i)
// Check if the player is a user, playing, and has the upgrade
if GetPlayerController(p) == MAP_CONTROL_USER and GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and GetPlayerTechCount(p, 'R01M', true) > 0 then
set g = CreateGroup()
set lumberMills = 0
// Find all units owned by the player that are Lumber Mills
call GroupEnumUnitsOfPlayer(g, p, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
// Check if the unit is a Lumber Mill and fully constructed (not partially built)
if GetUnitTypeId(u) == 'hlum' then
if GetUnitState(u, UNIT_STATE_LIFE) == GetUnitState(u, UNIT_STATE_MAX_LIFE) then
set lumberMills = lumberMills + 1
endif
endif
call GroupRemoveUnit(g, u)
endloop
// Calculate the lumber income and add it to the player
set lumberIncome = 25 * lumberMills
call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) + lumberIncome)
// Display the income message to the player
if lumberIncome > 0 then
call DisplayTextToPlayer(p, 0, 0, "|cff00ff00You have received " + I2S(lumberIncome) + " lumber from your Lumber Mills.|r")
endif
// Clean up the group
call DestroyGroup(g)
endif
set i = i + 1
endloop
endfunction
function InitTrig_JASSLumber takes nothing returns nothing
local trigger t = CreateTrigger()
// Register a periodic event to trigger every 15 seconds
call TriggerRegisterTimerEventPeriodic(t, 15.0)
call TriggerAddAction(t, function GiveLumberForLumberMills)
endfunction