94 lines
3.0 KiB
Lua
94 lines
3.0 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.CARD_56_HOMER_MODIFIER_NAME = "modifier_card_56_homer"
|
|
____exports.modifier_card_56_homer = __TS__Class()
|
|
local modifier_card_56_homer = ____exports.modifier_card_56_homer
|
|
modifier_card_56_homer.name = "modifier_card_56_homer"
|
|
modifier_card_56_homer.____file_path = "scripts/vscripts/cards/modifier_card_56_homer.lua"
|
|
__TS__ClassExtends(modifier_card_56_homer, BaseModifier)
|
|
function modifier_card_56_homer.prototype.____constructor(self, ...)
|
|
BaseModifier.prototype.____constructor(self, ...)
|
|
self.reflectPct = 15
|
|
end
|
|
function modifier_card_56_homer.prototype.OnCreated(self, params)
|
|
if params and params.reflect_pct ~= nil then
|
|
self.reflectPct = params.reflect_pct
|
|
end
|
|
end
|
|
function modifier_card_56_homer.prototype.IsHidden(self)
|
|
return true
|
|
end
|
|
function modifier_card_56_homer.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_card_56_homer.prototype.RemoveOnDeath(self)
|
|
return false
|
|
end
|
|
function modifier_card_56_homer.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_card_56_homer.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_TAKEDAMAGE}
|
|
end
|
|
function modifier_card_56_homer.prototype.OnTakeDamage(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local victim = event.unit
|
|
if not victim or not IsValidEntity(victim) or victim:IsNull() then
|
|
return
|
|
end
|
|
if victim ~= self:GetParent() then
|
|
return
|
|
end
|
|
if victim:GetUnitName() ~= "npc_homer" then
|
|
return
|
|
end
|
|
if not victim:IsAlive() then
|
|
return
|
|
end
|
|
local attacker = event.attacker
|
|
if not attacker or not IsValidEntity(attacker) or attacker:IsNull() then
|
|
return
|
|
end
|
|
if not attacker:IsAlive() then
|
|
return
|
|
end
|
|
if attacker:GetTeamNumber() == victim:GetTeamNumber() then
|
|
return
|
|
end
|
|
if not attacker:IsCreep() then
|
|
return
|
|
end
|
|
local damage = event.damage
|
|
if damage <= 0 or self.reflectPct <= 0 then
|
|
return
|
|
end
|
|
local reflectedDamage = damage * (self.reflectPct / 100)
|
|
if reflectedDamage <= 0 then
|
|
return
|
|
end
|
|
ApplyDamage({
|
|
victim = attacker,
|
|
attacker = victim,
|
|
damage = reflectedDamage,
|
|
damage_type = event.damage_type,
|
|
ability = nil,
|
|
damage_flags = DOTA_DAMAGE_FLAG_REFLECTION + DOTA_DAMAGE_FLAG_NO_SPELL_AMPLIFICATION
|
|
})
|
|
end
|
|
modifier_card_56_homer = __TS__Decorate(
|
|
modifier_card_56_homer,
|
|
modifier_card_56_homer,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_56_homer"}
|
|
)
|
|
____exports.modifier_card_56_homer = modifier_card_56_homer
|
|
return ____exports
|