139 lines
5.4 KiB
Lua
139 lines
5.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 ____luck = require("utils.luck")
|
|
local rollLuckChance = ____luck.rollLuckChance
|
|
local ____card_value_resolver = require("cards.card_value_resolver")
|
|
local getCardValueByLevel = ____card_value_resolver.getCardValueByLevel
|
|
local CARD_ID = 67
|
|
local PROC_HIT_PARTICLE = "particles/econ/items/centaur/centaur_ti9/centaur_double_edge_ti9_hit_tgt.vpcf"
|
|
local PROC_HIT_SOUND = "Hero_Centaur.DoubleEdge"
|
|
____exports.card_67 = __TS__Class()
|
|
local card_67 = ____exports.card_67
|
|
card_67.name = "card_67"
|
|
card_67.____file_path = "scripts/vscripts/cards/examples/card_67.lua"
|
|
__TS__ClassExtends(card_67, CardBase)
|
|
function card_67.prototype.GetModifierName(self)
|
|
return "modifier_card_67"
|
|
end
|
|
card_67 = __TS__Decorate(card_67, card_67, {RegisterCard}, {kind = "class", name = "card_67"})
|
|
____exports.card_67 = card_67
|
|
____exports.modifier_card_67 = __TS__Class()
|
|
local modifier_card_67 = ____exports.modifier_card_67
|
|
modifier_card_67.name = "modifier_card_67"
|
|
modifier_card_67.____file_path = "scripts/vscripts/cards/examples/card_67.lua"
|
|
__TS__ClassExtends(modifier_card_67, CardBaseModifier)
|
|
function modifier_card_67.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.nextProcTime = 0
|
|
end
|
|
function modifier_card_67.prototype.playProcFx(self, attacker, target)
|
|
local targetOrigin = target:GetAbsOrigin()
|
|
local pfx = ParticleManager:CreateParticle(PROC_HIT_PARTICLE, PATTACH_ABSORIGIN, attacker)
|
|
ParticleManager:SetParticleControl(pfx, 0, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 1, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 2, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 3, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 4, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 5, targetOrigin)
|
|
ParticleManager:SetParticleControl(pfx, 9, targetOrigin)
|
|
ParticleManager:ReleaseParticleIndex(pfx)
|
|
end
|
|
function modifier_card_67.prototype.getValue(self, key, fallback)
|
|
local hero = self:GetParent()
|
|
return getCardValueByLevel(
|
|
nil,
|
|
CARD_ID,
|
|
hero,
|
|
key,
|
|
fallback
|
|
)
|
|
end
|
|
function modifier_card_67.prototype.OnCustomCreated(self, params)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return
|
|
end
|
|
hero:CalculateStatBonus(true)
|
|
end
|
|
function modifier_card_67.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_EXTRA_HEALTH_BONUS, MODIFIER_PROPERTY_DAMAGEOUTGOING_PERCENTAGE, MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_67.prototype.GetModifierExtraHealthBonus(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
local hpPerStrength = self:getScaledCardValue("hp_per_strength", 2.5)
|
|
return hero:GetStrength() * hpPerStrength
|
|
end
|
|
function modifier_card_67.prototype.GetModifierDamageOutgoing_Percentage(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
local outgoingPctPerStrength = self:getScaledCardValue("outgoing_pct_per_strength", 1)
|
|
return hero:GetStrength() * outgoingPctPerStrength
|
|
end
|
|
function modifier_card_67.prototype.OnAttackLanded(self, event)
|
|
if not IsServer() 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 now = GameRules:GetGameTime()
|
|
if now < self.nextProcTime then
|
|
return
|
|
end
|
|
local procChancePct = self:getValue("proc_chance_pct", 50)
|
|
local didProc = rollLuckChance(nil, attacker, procChancePct / 100)
|
|
if not didProc then
|
|
return
|
|
end
|
|
local bonusDamagePctFromMaxHp = self:getScaledCardValue("bonus_damage_from_max_hp_pct", 70)
|
|
local bonusDamage = attacker:GetMaxHealth() * (bonusDamagePctFromMaxHp / 100)
|
|
if bonusDamage <= 0 then
|
|
return
|
|
end
|
|
ApplyDamage({victim = target, attacker = attacker, damage = bonusDamage, damage_type = DAMAGE_TYPE_PHYSICAL})
|
|
EmitSoundOn(PROC_HIT_SOUND, target)
|
|
self:playProcFx(attacker, target)
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_CRITICAL,
|
|
target,
|
|
bonusDamage,
|
|
attacker:GetPlayerOwner()
|
|
)
|
|
self.nextProcTime = now + self:getValue("proc_cooldown_sec", 3)
|
|
end
|
|
modifier_card_67 = __TS__Decorate(
|
|
modifier_card_67,
|
|
modifier_card_67,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_67"}
|
|
)
|
|
____exports.modifier_card_67 = modifier_card_67
|
|
return ____exports
|