131 lines
4.8 KiB
Lua
131 lines
4.8 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 ____vampirism = require("utils.vampirism")
|
|
local addMagicalVampirism = ____vampirism.addMagicalVampirism
|
|
local addPhysicalVampirism = ____vampirism.addPhysicalVampirism
|
|
local precacheVampirismParticle = ____vampirism.precacheVampirismParticle
|
|
local reduceMagicalVampirism = ____vampirism.reduceMagicalVampirism
|
|
local reducePhysicalVampirism = ____vampirism.reducePhysicalVampirism
|
|
local CARD_ID = 83
|
|
____exports.card_83 = __TS__Class()
|
|
local card_83 = ____exports.card_83
|
|
card_83.name = "card_83"
|
|
card_83.____file_path = "scripts/vscripts/cards/examples/card_83.lua"
|
|
__TS__ClassExtends(card_83, CardBase)
|
|
function card_83.prototype.GetModifierName(self)
|
|
return "modifier_card_83"
|
|
end
|
|
card_83 = __TS__Decorate(card_83, card_83, {RegisterCard}, {kind = "class", name = "card_83"})
|
|
____exports.card_83 = card_83
|
|
____exports.modifier_card_83 = __TS__Class()
|
|
local modifier_card_83 = ____exports.modifier_card_83
|
|
modifier_card_83.name = "modifier_card_83"
|
|
modifier_card_83.____file_path = "scripts/vscripts/cards/examples/card_83.lua"
|
|
__TS__ClassExtends(modifier_card_83, CardBaseModifier)
|
|
function modifier_card_83.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.vampirismApplied = false
|
|
self.appliedPhysicalVamp = 0
|
|
self.appliedMagicalVamp = 0
|
|
end
|
|
function modifier_card_83.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_83.prototype.Precache(self, context)
|
|
precacheVampirismParticle(nil, context)
|
|
end
|
|
function modifier_card_83.prototype.OnCustomCreated(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
addCursedStack(nil, hero)
|
|
self:applyVampirism(hero)
|
|
end
|
|
function modifier_card_83.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return
|
|
end
|
|
self:removeVampirism(hero)
|
|
end
|
|
function modifier_card_83.prototype.OnCustomRefresh(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return
|
|
end
|
|
self:removeVampirism(hero)
|
|
self:applyVampirism(hero)
|
|
end
|
|
function modifier_card_83.prototype.applyVampirism(self, hero)
|
|
local physicalPct = self:getScaledCardValue("physical_vampirism_pct", 10)
|
|
local magicalPct = self:getScaledCardValue("magical_vampirism_pct", 10)
|
|
if physicalPct > 0 then
|
|
addPhysicalVampirism(nil, hero, physicalPct)
|
|
self.appliedPhysicalVamp = physicalPct
|
|
end
|
|
if magicalPct > 0 then
|
|
addMagicalVampirism(nil, hero, magicalPct)
|
|
self.appliedMagicalVamp = magicalPct
|
|
end
|
|
self.vampirismApplied = physicalPct > 0 or magicalPct > 0
|
|
end
|
|
function modifier_card_83.prototype.removeVampirism(self, hero)
|
|
if not self.vampirismApplied then
|
|
return
|
|
end
|
|
if self.appliedPhysicalVamp > 0 then
|
|
reducePhysicalVampirism(nil, hero, self.appliedPhysicalVamp)
|
|
self.appliedPhysicalVamp = 0
|
|
end
|
|
if self.appliedMagicalVamp > 0 then
|
|
reduceMagicalVampirism(nil, hero, self.appliedMagicalVamp)
|
|
self.appliedMagicalVamp = 0
|
|
end
|
|
self.vampirismApplied = false
|
|
end
|
|
function modifier_card_83.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_MODEL_SCALE, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_83.prototype.GetModifierModelScale(self)
|
|
return self:getScaledCardValue("model_scale_pct", 20)
|
|
end
|
|
function modifier_card_83.prototype.OnTooltip(self)
|
|
return self:getScaledCardValue("model_scale_pct", 20)
|
|
end
|
|
function modifier_card_83.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_card_83.prototype.GetTexture(self)
|
|
return "cards/card_" .. tostring(CARD_ID)
|
|
end
|
|
modifier_card_83 = __TS__Decorate(
|
|
modifier_card_83,
|
|
modifier_card_83,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_83"}
|
|
)
|
|
____exports.modifier_card_83 = modifier_card_83
|
|
return ____exports
|