84 lines
3.4 KiB
Lua
84 lines
3.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 ____modifier_card_cursed = require("cards.modifier_card_cursed")
|
|
local addCursedStack = ____modifier_card_cursed.addCursedStack
|
|
local getCursedStackCount = ____modifier_card_cursed.getCursedStackCount
|
|
local CARD_ID = 17
|
|
____exports.card_17 = __TS__Class()
|
|
local card_17 = ____exports.card_17
|
|
card_17.name = "card_17"
|
|
card_17.____file_path = "scripts/vscripts/cards/examples/card_17.lua"
|
|
__TS__ClassExtends(card_17, CardBase)
|
|
function card_17.prototype.GetModifierName(self)
|
|
return "modifier_card_17"
|
|
end
|
|
card_17 = __TS__Decorate(card_17, card_17, {RegisterCard}, {kind = "class", name = "card_17"})
|
|
____exports.card_17 = card_17
|
|
____exports.modifier_card_17 = __TS__Class()
|
|
local modifier_card_17 = ____exports.modifier_card_17
|
|
modifier_card_17.name = "modifier_card_17"
|
|
modifier_card_17.____file_path = "scripts/vscripts/cards/examples/card_17.lua"
|
|
__TS__ClassExtends(modifier_card_17, CardBaseModifier)
|
|
function modifier_card_17.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.cursedApplied = false
|
|
end
|
|
function modifier_card_17.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_17.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_PROCATTACK_BONUS_DAMAGE_PURE, MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_17.prototype.OnCustomCreated(self, params)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
addCursedStack(nil, hero)
|
|
self.cursedApplied = true
|
|
end
|
|
function modifier_card_17.prototype.OnAttackLanded(self, event)
|
|
local attacker = self:GetParent()
|
|
local minHealthPct = self:getValue("min_health_pct_to_activate", 80)
|
|
if attacker:GetHealthPercent() <= minHealthPct then
|
|
return
|
|
end
|
|
if attacker ~= event.attacker then
|
|
return
|
|
end
|
|
local copies = self:getCardCopies()
|
|
local hpCostPct = self:getValue("health_cost_pct", 5) / 100 * copies
|
|
local baseFromMaxHp = attacker:GetMaxHealth() * hpCostPct
|
|
local curses = math.max(
|
|
1,
|
|
getCursedStackCount(nil, attacker)
|
|
)
|
|
local pctPerCurse = self:getValue("curse_damage_pct_per_curse_stack", 0)
|
|
local curseDamageMult = 1 + curses * pctPerCurse / 100
|
|
attacker:ModifyHealth(
|
|
attacker:GetHealth() - baseFromMaxHp,
|
|
nil,
|
|
false,
|
|
0
|
|
)
|
|
ApplyDamage({victim = event.target, attacker = attacker, damage = baseFromMaxHp * curseDamageMult, damage_type = DAMAGE_TYPE_PURE})
|
|
end
|
|
modifier_card_17 = __TS__Decorate(
|
|
modifier_card_17,
|
|
modifier_card_17,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_17"}
|
|
)
|
|
____exports.modifier_card_17 = modifier_card_17
|
|
return ____exports
|