124 lines
3.6 KiB
Lua
124 lines
3.6 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Class = ____lualib.__TS__Class
|
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
local __TS__Decorate = ____lualib.__TS__Decorate
|
|
local ____exports = {}
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local BaseModifier = ____dota_ts_adapter.BaseModifier
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
____exports.modifier_vampirism = __TS__Class()
|
|
local modifier_vampirism = ____exports.modifier_vampirism
|
|
modifier_vampirism.name = "modifier_vampirism"
|
|
modifier_vampirism.____file_path = "scripts/vscripts/abilities/modifiers/modifier_vampirism.lua"
|
|
__TS__ClassExtends(modifier_vampirism, BaseModifier)
|
|
function modifier_vampirism.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_vampirism.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_vampirism.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_vampirism.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_EVENT_ON_TAKEDAMAGE}
|
|
end
|
|
function modifier_vampirism.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_vampirism.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if event.attacker ~= self:GetParent() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
local physicalVampirism = getPhysicalVampirism(nil, hero)
|
|
if physicalVampirism <= 0 then
|
|
return
|
|
end
|
|
local attackDamage = event.damage or 0
|
|
if attackDamage <= 0 then
|
|
return
|
|
end
|
|
local healAmount = attackDamage * physicalVampirism / 100
|
|
if healAmount <= 0 then
|
|
return
|
|
end
|
|
hero:HealWithParams(
|
|
healAmount,
|
|
self:GetAbility(),
|
|
false,
|
|
true,
|
|
hero,
|
|
false
|
|
)
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_HEAL,
|
|
hero,
|
|
healAmount,
|
|
hero:GetPlayerOwner()
|
|
)
|
|
self:CreateVampirismEffect(event.target)
|
|
end
|
|
function modifier_vampirism.prototype.OnTakeDamage(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if event.attacker ~= self:GetParent() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
local magicalVampirism = getMagicalVampirism(nil, hero)
|
|
if magicalVampirism <= 0 then
|
|
return
|
|
end
|
|
local damage = event.damage
|
|
local healAmount = 0
|
|
if magicalVampirism > 0 and event.inflictor ~= nil then
|
|
local magicalHeal = damage * magicalVampirism / 100
|
|
healAmount = healAmount + magicalHeal
|
|
end
|
|
if healAmount > 0 then
|
|
hero:HealWithParams(
|
|
healAmount,
|
|
self:GetAbility(),
|
|
false,
|
|
true,
|
|
hero,
|
|
false
|
|
)
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_HEAL,
|
|
hero,
|
|
healAmount,
|
|
hero:GetPlayerOwner()
|
|
)
|
|
self:CreateVampirismEffect(event.unit)
|
|
end
|
|
end
|
|
function modifier_vampirism.prototype.CreateVampirismEffect(self, target)
|
|
local attackerParticle = ParticleManager:CreateParticle(
|
|
"particles/units/heroes/hero_bloodseeker/bloodseeker_bloodbath.vpcf",
|
|
PATTACH_ABSORIGIN_FOLLOW,
|
|
self:GetParent()
|
|
)
|
|
ParticleManager:SetParticleControl(
|
|
attackerParticle,
|
|
0,
|
|
self:GetParent():GetAbsOrigin()
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(attackerParticle)
|
|
end
|
|
modifier_vampirism = __TS__Decorate(
|
|
modifier_vampirism,
|
|
modifier_vampirism,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_vampirism"}
|
|
)
|
|
____exports.modifier_vampirism = modifier_vampirism
|
|
return ____exports
|