function LifeDrainCancelUpgrade( keys )
local caster = keys.caster
local ability_cancel = caster:FindAbilityByName(keys.ability_cancel)
-- Upgrade the Life Drain Cancel ability (Обновление Похищение жизни Отменить способность)
if ability_cancel then
ability_cancel:SetLevel(1)
end
end
--[[
modifier_enemy = class({})
function modifier_enemy:GetAttributes()
return MODIFIER_ATTRIBUTE_MULTIPLE
end
function modifier_enemy:IsHidden()
return false
end
]]--
function LifeDrain( keys )
local caster = keys.caster
local target = keys.target
local ability = keys.ability
local ability_level = ability:GetLevel() - 1
local sound_cast = keys.sound_cast
local sound_target = keys.sound_target
local modifier_enemy = keys.modifier_enemy
local modifier_ally = keys.modifier_ally
-- Parameters
local duration = ability:GetLevelSpecialValueFor("duration", ability_level)
-- Play cast sounds
caster:EmitSound(sound_cast)
target:EmitSound(sound_target)
ability:ApplyDataDrivenModifier(caster, target, modifier_ally, {})
--[[]]--
end
function LifeDrainAllyStart( keys )
local caster = keys.caster
local target = keys.target
local particle_drain = keys.particle_drain
local sound_loop = keys.sound_loop
-- Stop any ongoing looping sound on the target
target:StopSound(sound_loop)
target:EmitSound(sound_loop)
-- End any pre-existing particle
if target.life_give_particle then
ParticleManager:DestroyParticle(target.life_give_particle, false)
ParticleManager:ReleaseParticleIndex(target.life_give_particle)
end
-- Play ally particle
target.life_give_particle = ParticleManager:CreateParticle(particle_drain, PATTACH_ABSORIGIN, caster)
ParticleManager:SetParticleControlEnt(target.life_give_particle, 0, caster, PATTACH_POINT_FOLLOW, "attach_hitloc", caster:GetAbsOrigin(), true)
ParticleManager:SetParticleControlEnt(target.life_give_particle, 1, target, PATTACH_POINT_FOLLOW, "attach_hitloc", target:GetAbsOrigin(), true)
end
function LifeDrainTickAlly( keys )
local caster = keys.caster
local target = keys.target
local ability = keys.ability
local ability_level = ability:GetLevel() - 1
local modifier_ally = keys.modifier_ally
-- Parameters
local break_range = ability:GetLevelSpecialValueFor("break_range", ability_level)
local tick_rate = ability:GetLevelSpecialValueFor("tick_rate", ability_level)
local caster_max_mana = caster:GetMaxMana()
local target_max_mana = target:GetMaxMana()
local caster_current_mana = caster:GetMana()
local target_current_mana = target:GetMana()
if target_max_mana ~= target_current_mana and caster_current_mana >= 5 then
caster:ReduceMana(5)
target:GiveMana(5)
end
-- Update particle color
ParticleManager:SetParticleControl(target.life_give_particle, 11, Vector(1, 0, 0))
-- Check link break conditions
local should_break = false
-- Break the link if the caster is stunned or silenced or dead
if caster:IsStunned() or caster:IsSilenced() or not caster:IsAlive() then
should_break = true
end
-- Break the link if this target is out of the world or no longer visible
if target:IsOutOfGame() then
should_break = true
end
-- Calculate distance from this target to the caster
local target_loc = target:GetAbsOrigin()
local caster_loc = caster:GetAbsOrigin()
local distance = (target_loc - caster_loc):Length2D()
-- Break the link if the distance is too large
if distance > break_range then
should_break = true
end
-- If any of the break conditions is true, break the link
if should_break then
target:RemoveModifierByName(modifier_ally)
end
end
function LifeDrainCancel( keys )
local caster = keys.caster
local ability = keys.ability
local ability_level = ability:GetLevel() - 1
local modifier_ally = keys.modifier_ally
-- Parameters
local search_range = ability:GetLevelSpecialValueFor("search_range", ability_level)
-- Find all currently tethered allies (Найти все в настоящее время на привязи союзников)
local allies = FindUnitsInRadius(caster:GetTeamNumber(), caster:GetAbsOrigin(), nil, search_range, DOTA_UNIT_TARGET_TEAM_FRIENDLY, DOTA_UNIT_TARGET_BASIC + DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_FLAG_INVULNERABLE + DOTA_UNIT_TARGET_FLAG_OUT_OF_WORLD, FIND_ANY_ORDER, false)
-- Iterate through valid allies, removing the life drain modifier
for _,ally in pairs(allies) do
ally:RemoveModifierByNameAndCaster(modifier_ally, caster)
end
end
function LifeDrainAllyEnd( keys )
local caster = keys.caster
local target = keys.target
local sound_loop = keys.sound_loop
local sound_target = keys.sound_target
-- End the particle
ParticleManager:DestroyParticle(target.life_give_particle, false)
ParticleManager:ReleaseParticleIndex(target.life_give_particle)
target.life_give_particle = nil
-- Stop the looping sound
target:StopSound(sound_target)
target:StopSound(sound_loop)
end