Мне нужно для каждого игрока сложить здоровье всех юнитов типа "золото" в области 512 от всех юнитов взятого игрока типа "сокровищница" и затем установить золото текущее взятого игрока равному полученной сумме Сделать ето на триггерах никак не выходит. В попытках это сделать я сотворил триггер и перевел его в код, попытался довести до ума уже код но не вышло.
Code
function Trig_Gold_Deposit_Func001Func001001002 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'h000' )
endfunction
function Trig_Gold_Deposit_Func001Func001Func001001003 takes nothing returns boolean
return ( GetUnitTypeId(GetFilterUnit()) == 'o001' )
endfunction
function Trig_Gold_Deposit_Func001Func001Func001A takes nothing returns nothing
call SetPlayerStateBJ( GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD, ( GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_GOLD) + R2I(GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit())) ) )
endfunction
function Trig_Gold_Deposit_Func001Func001A takes nothing returns nothing
call ForGroupBJ( GetUnitsInRangeOfLocMatching(512, GetUnitLoc( "ЮНИТ" ), Condition(function Trig_Gold_Deposit_Func001Func001Func001001003)), function Trig_Gold_Deposit_Func001Func001Func001A )
endfunction
function Trig_Gold_Deposit_Func001A takes nothing returns nothing
call ForGroupBJ( GetUnitsOfPlayerMatching(GetEnumPlayer(), Condition(Trig_Gold_Deposit_Func001Func001Func001001003)), function Trig_Gold_Deposit_Func001Func001A )
endfunction
function Trig_Gold_Deposit_Actions takes nothing returns nothing
call ForForce( GetPlayersAll(), function Trig_Gold_Deposit_Func001A )
endfunction
//===========================================================================
function InitTrig_Gold_Deposit takes nothing returns nothing
set gg_trg_Gold_Deposit = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Gold_Deposit, 1.00 )
call TriggerAddAction( gg_trg_Gold_Deposit, function Trig_Gold_Deposit_Actions )
endfunction