125 lines
4.4 KiB
Lua
125 lines
4.4 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 ____CardSystem = require("cards.CardSystem")
|
|
local CardBase = ____CardSystem.CardBase
|
|
local RegisterCard = ____CardSystem.RegisterCard
|
|
local ____CardBaseModifier = require("cards.CardBaseModifier")
|
|
local CardBaseModifier = ____CardBaseModifier.CardBaseModifier
|
|
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
|
|
local registerModifier = ____dota_ts_adapter.registerModifier
|
|
local CARD_ID = 66
|
|
____exports.card_66 = __TS__Class()
|
|
local card_66 = ____exports.card_66
|
|
card_66.name = "card_66"
|
|
card_66.____file_path = "scripts/vscripts/cards/examples/card_66.lua"
|
|
__TS__ClassExtends(card_66, CardBase)
|
|
function card_66.prototype.GetModifierName(self)
|
|
return "modifier_card_66"
|
|
end
|
|
card_66 = __TS__Decorate(card_66, card_66, {RegisterCard}, {kind = "class", name = "card_66"})
|
|
____exports.card_66 = card_66
|
|
____exports.modifier_card_66 = __TS__Class()
|
|
local modifier_card_66 = ____exports.modifier_card_66
|
|
modifier_card_66.name = "modifier_card_66"
|
|
modifier_card_66.____file_path = "scripts/vscripts/cards/examples/card_66.lua"
|
|
__TS__ClassExtends(modifier_card_66, CardBaseModifier)
|
|
function modifier_card_66.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.pendingStrikeCharges = 0
|
|
end
|
|
function modifier_card_66.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_66.prototype.OnCustomCreated(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self.pendingStrikeCharges = 0
|
|
end
|
|
function modifier_card_66.prototype.OnCustomRefresh(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if self.pendingStrikeCharges < 0 then
|
|
self.pendingStrikeCharges = 0
|
|
end
|
|
end
|
|
function modifier_card_66.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ABILITY_EXECUTED, MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_66.prototype.OnAbilityExecuted(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
if event.unit ~= hero then
|
|
return
|
|
end
|
|
local ability = event.ability
|
|
if not ability or ability:IsNull() then
|
|
return
|
|
end
|
|
if ability:IsItem() then
|
|
return
|
|
end
|
|
self.pendingStrikeCharges = self.pendingStrikeCharges + 1
|
|
end
|
|
function modifier_card_66.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if self.pendingStrikeCharges <= 0 then
|
|
return
|
|
end
|
|
local attacker = self:GetParent()
|
|
if not attacker or not IsValidEntity(attacker) or not attacker:IsRealHero() then
|
|
return
|
|
end
|
|
if event.attacker ~= attacker then
|
|
return
|
|
end
|
|
local target = event.target
|
|
if not target or not IsValidEntity(target) or target:IsNull() or not target:IsAlive() then
|
|
return
|
|
end
|
|
if target:GetTeamNumber() == attacker:GetTeamNumber() then
|
|
return
|
|
end
|
|
local copies = self:getCardCopies()
|
|
local hpPct = self:getValue("bonus_from_health_pct", 50) / 100 * copies
|
|
local manaPct = self:getValue("bonus_from_mana_pct", 50) / 100 * copies
|
|
local bonusDamage = attacker:GetHealth() * hpPct + attacker:GetMana() * manaPct
|
|
local pfx = ParticleManager:CreateParticle("particles/econ/items/dazzle/dazzle_ti9/dazzle_shadow_wave_ti9_crimson_impact_damage.vpcf", PATTACH_ABSORIGIN_FOLLOW, target)
|
|
ParticleManager:ReleaseParticleIndex(pfx)
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_DEADLY_BLOW,
|
|
target,
|
|
bonusDamage,
|
|
attacker:GetPlayerOwner()
|
|
)
|
|
EmitSoundOnLocationWithCaster(
|
|
target:GetAbsOrigin(),
|
|
"Hero_ChaosKnight.ChaosStrike",
|
|
attacker
|
|
)
|
|
if bonusDamage > 0 then
|
|
ApplyDamage({victim = target, attacker = attacker, damage = bonusDamage, damage_type = DAMAGE_TYPE_MAGICAL})
|
|
end
|
|
self.pendingStrikeCharges = math.max(0, self.pendingStrikeCharges - 1)
|
|
end
|
|
modifier_card_66 = __TS__Decorate(
|
|
modifier_card_66,
|
|
modifier_card_66,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_66"}
|
|
)
|
|
____exports.modifier_card_66 = modifier_card_66
|
|
return ____exports
|