Доброго времени суток.
Друзья, так как джасс начал учить недавно, не уверен что написанное мной не создаёт утечек.
Просмотрите код. Есть ли тут серьёзные утечки?
Code
function Trig_ShadowBlink_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00O' ) ) then
return false
endif
return true
endfunction
function Trig_ShadowBlink_IllusionMove takes nothing returns nothing
if ((GetOwningPlayer(udg_ShadowBlink[0]) == GetOwningPlayer(GetEnumUnit())) and (IsUnitIllusion(GetEnumUnit()) == true)) then
call SetUnitX(GetEnumUnit(), GetUnitX(udg_ShadowBlink[1]))
call SetUnitY(GetEnumUnit(), GetUnitY(udg_ShadowBlink[1]))
call IssueTargetOrder( GetEnumUnit(), "attack", udg_ShadowBlink[1] )
endif
endfunction
function Trig_ShadowBlink_Move takes nothing returns nothing
local location loc
local location loctg
local location locsh
local timer tm = GetExpiredTimer()
local group gr = CreateGroup()
local real dx
local real dy
local real bd
set loctg = Location(GetUnitX(udg_ShadowBlink[1]), GetUnitY (udg_ShadowBlink[1]))
set locsh = Location(GetUnitX(udg_ShadowBlink[0]), GetUnitY (udg_ShadowBlink[0]))
set loc = Location(GetLocationX(locsh) + 55.00 * Cos((bj_RADTODEG * Atan2(GetLocationY(loctg) - GetLocationY(locsh), GetLocationX(loctg) - GetLocationX(locsh))) * bj_DEGTORAD), GetLocationY(locsh) + 55.00 * Sin((bj_RADTODEG * Atan2(GetLocationY(loctg) - GetLocationY(locsh), GetLocationX(loctg) - GetLocationX(locsh))) * bj_DEGTORAD))
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Undead\\DeathandDecay\\DeathandDecayTarget.mdl", locsh))
call SetUnitPositionLoc( udg_ShadowBlink[0], loc )
set dx = GetLocationX(loctg) - GetLocationX(locsh)
set dy = GetLocationY(loctg) - GetLocationY(locsh)
set bd = SquareRoot(dx * dx + dy * dy)
call RemoveLocation(loc)
call RemoveLocation(loctg)
call RemoveLocation(locsh)
set loc = null
set loctg = null
set locsh = null
if(bd <= 60.00) then
call UnitDamageTarget(udg_ShadowBlink[0] , udg_ShadowBlink[1] , (GetHeroAgi(udg_ShadowBlink[0], true)) * 2 , true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DEATH, WEAPON_TYPE_WHOKNOWS)
call SetUnitPathing( udg_ShadowBlink[0], true )
call PauseUnit(udg_ShadowBlink[0], false)
call GroupEnumUnitsInRange( gr, GetUnitX(udg_ShadowBlink[0]), GetUnitY(udg_ShadowBlink[0]), 3000.00, null)
call ForGroup( gr, function Trig_ShadowBlink_IllusionMove)
set udg_ShadowBlink[0] = null
set udg_ShadowBlink[1] = null
call DestroyGroup(gr)
set gr = null
call DestroyTimer(tm)
set tm = null
endif
endfunction
function Trig_ShadowBlink_Actions takes nothing returns nothing
local timer t = CreateTimer()
//Памятка
// udg_ShadowBlink[0] - кастер
// udg_ShadowBlink[1] - цель
set udg_ShadowBlink[0] = GetSpellAbilityUnit()
set udg_ShadowBlink[1] = GetSpellTargetUnit()
call SetUnitPathing( udg_ShadowBlink[0], false )
call TriggerSleepAction (0.1)
call PauseUnit(udg_ShadowBlink[0], true)
call TimerStart(t, 0.04, true, function Trig_ShadowBlink_Move)
set t = null
endfunction
//===========================================================================
function InitTrig_ShadowBlink takes nothing returns nothing
local integer index
set gg_trg_ShadowBlink = CreateTrigger( )
call DisableTrigger( gg_trg_ShadowBlink )
set index = 0
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_ShadowBlink, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition( gg_trg_ShadowBlink, Condition( function Trig_ShadowBlink_Conditions ) )
call TriggerAddAction( gg_trg_ShadowBlink, function Trig_ShadowBlink_Actions )
endfunction
Заранее спасибо.