Вообщем варик жрёт память, обратно не возвращает!
мб хендлы обнулять надо???
function SFRCondition takes nothing returns boolean
if ( not ( GetItemTypeId(GetManipulatedItem()) == 'I000' ) ) then
return false
endif
return true
endfunction
function SFRCheckPlayer takes nothing returns boolean
local timer t=GetExpiredTimer()
local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
if GetOwningPlayer(tcu) != GetOwningPlayer(GetFilterUnit()) then
set tcu=null
set t=null
return true
else
set tcu=null
set t=null
return false
endif
endfunction
function SFRPickUnits takes nothing returns boolean
local timer t=GetExpiredTimer()
local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
if ( not ( CountUnitsInGroup(GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer))) > 0 ) ) then
set tcu=null
set t=null
return false
endif
set tcu=null
set t=null
return true
endfunction
function SFRActionsForPickedUnits takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
call UnitDamageTargetBJ( tcu, GetEnumUnit(), 50.00, ATTACK_TYPE_SIEGE, DAMAGE_TYPE_UNIVERSAL )
set tcu=null
set t=null
endfunction
function SFRMove_Unit takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit ccu=LoadUnitHandle(udg_Hash,GetHandleId(t),0)
local unit tcu=LoadUnitHandle(udg_Hash,GetHandleId(t),1)
local location cup=LoadLocationHandle(udg_Hash, GetHandleId(t), 2)
local real cspeed=LoadReal(udg_Hash,GetHandleId(t),4)
local real cangle=LoadReal(udg_Hash,GetHandleId(t),5)
local real distance=LoadReal(udg_Hash,GetHandleId(t),7)
local real ccangle2
local location cUnitPoint=GetUnitLoc(tcu)
local location cUnitTempPoint=PolarProjectionBJ(cUnitPoint,cspeed,cangle)
set cangle = GetUnitFacing(tcu)-GetRandomReal(85,95)
call SetUnitPositionLoc( tcu, cUnitTempPoint )
set distance=distance-10
if distance<=0 or SFRPickUnits() then
call ForGroupBJ( GetUnitsInRangeOfLocMatching(150.00, GetUnitLoc(tcu), Condition(function SFRCheckPlayer)), function SFRActionsForPickedUnits )
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl",cUnitTempPoint))
call RemoveUnit(tcu)
call FlushChildHashtable(udg_Hash, GetHandleId(t))
call DestroyTimer(t)
endif
call SaveReal(udg_Hash, GetHandleId(t), 4, cspeed)
call SaveReal(udg_Hash, GetHandleId(t), 7, distance)
call SaveReal(udg_Hash, GetHandleId(t), 5, cangle)
call RemoveLocation(cUnitTempPoint)
call RemoveLocation(cUnitPoint)
call RemoveLocation(cup)
set t=null
set ccu=null
set distance=0
set tcu=null
set cup=null
set cUnitTempPoint=null
set cUnitPoint=null
set cangle=0
set ccangle2=0
endfunction
function SFRActions takes nothing returns nothing
local timer t=CreateTimer()
local unit ccu=GetTriggerUnit()
local unit tcu
local location cup=GetUnitLoc(ccu)
local real cspeed=25
local real distance=500
local real cangle=GetUnitFacing(ccu)-GetRandomReal(85,95)
call CreateNUnitsAtLoc( 1, 'n000', GetOwningPlayer(ccu), GetUnitLoc(ccu), GetUnitFacing(ccu) )
set tcu=GetLastCreatedUnit()
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl",cup))
call SaveUnitHandle(udg_Hash, GetHandleId(t), 0, ccu)
call SaveUnitHandle(udg_Hash, GetHandleId(t), 1, tcu)
call SaveLocationHandle(udg_Hash, GetHandleId(t), 2, cup)
call SaveReal(udg_Hash, GetHandleId(t), 4, cspeed)
call SaveReal(udg_Hash, GetHandleId(t), 5, cangle)
call SaveReal(udg_Hash, GetHandleId(t), 7, distance)
call SetUnitPathing( tcu, false )
call TimerStart(t, 0.025, true, function SFRMove_Unit)
set t=null
set ccu=null
set distance=0
set cspeed=0
set cangle=0
set tcu=null
call RemoveLocation(cup)
set cup=null
endfunction
function InitTrig_ShipFireRight takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddCondition( t, Condition( function SFRCondition) )
call TriggerAddAction( t, function SFRActions )
set t=null
endfunction