147 lines
5.4 KiB
Lua
147 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 __TS__Number = ____lualib.__TS__Number
|
|
local __TS__NumberIsFinite = ____lualib.__TS__NumberIsFinite
|
|
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
|
|
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 removeCursedStack = ____modifier_card_cursed.removeCursedStack
|
|
____exports.card_8 = __TS__Class()
|
|
local card_8 = ____exports.card_8
|
|
card_8.name = "card_8"
|
|
card_8.____file_path = "scripts/vscripts/cards/examples/card_8.lua"
|
|
__TS__ClassExtends(card_8, CardBase)
|
|
function card_8.prototype.GetModifierName(self)
|
|
return "modifier_card_8"
|
|
end
|
|
card_8 = __TS__Decorate(card_8, card_8, {RegisterCard}, {kind = "class", name = "card_8"})
|
|
____exports.card_8 = card_8
|
|
____exports.modifier_card_8 = __TS__Class()
|
|
local modifier_card_8 = ____exports.modifier_card_8
|
|
modifier_card_8.name = "modifier_card_8"
|
|
modifier_card_8.____file_path = "scripts/vscripts/cards/examples/card_8.lua"
|
|
__TS__ClassExtends(modifier_card_8, CardBaseModifier)
|
|
function modifier_card_8.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.appliedCursedStacks = 0
|
|
self.rampStacks = 0
|
|
end
|
|
function modifier_card_8.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
|
|
self:syncCursedStacks(hero)
|
|
end
|
|
function modifier_card_8.prototype.OnCustomRefresh(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
|
|
self:syncCursedStacks(hero)
|
|
hero:CalculateStatBonus(true)
|
|
self:SendBuffRefreshToClients()
|
|
end
|
|
function modifier_card_8.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_card_8.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_EXTRA_HEALTH_BONUS, MODIFIER_EVENT_ON_DEATH, MODIFIER_PROPERTY_PREATTACK_BONUS_DAMAGE, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_8.prototype.OnDeath(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.attacker ~= hero then
|
|
return
|
|
end
|
|
if event.unit == hero then
|
|
return
|
|
end
|
|
local hpThreshold = self:getCardValue("stack_health_threshold", 900, 8)
|
|
if hero:GetHealth() < hpThreshold then
|
|
return
|
|
end
|
|
self.rampStacks = self.rampStacks + 1
|
|
hero:CalculateStatBonus(true)
|
|
self:SendBuffRefreshToClients()
|
|
end
|
|
function modifier_card_8.prototype.GetModifierPreAttack_BonusDamage(self)
|
|
local perStack = self:getCardValue("damage_bonus_health_decress", 0, 8)
|
|
return perStack * self.rampStacks * self:getCardCopies()
|
|
end
|
|
function modifier_card_8.prototype.GetModifierExtraHealthBonus(self)
|
|
local perStack = self:getCardValue("damage_bonus_health_decress", 0, 8)
|
|
return -perStack * self.rampStacks * self:getCardCopies()
|
|
end
|
|
function modifier_card_8.prototype.OnDestroy(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
while self.appliedCursedStacks > 0 do
|
|
removeCursedStack(nil, hero)
|
|
self.appliedCursedStacks = self.appliedCursedStacks - 1
|
|
end
|
|
end
|
|
function modifier_card_8.prototype.syncCursedStacks(self, hero)
|
|
local desiredStacks = self:getCardCopies()
|
|
while self.appliedCursedStacks < desiredStacks do
|
|
addCursedStack(nil, hero)
|
|
self.appliedCursedStacks = self.appliedCursedStacks + 1
|
|
end
|
|
while self.appliedCursedStacks > desiredStacks do
|
|
removeCursedStack(nil, hero)
|
|
self.appliedCursedStacks = self.appliedCursedStacks - 1
|
|
end
|
|
end
|
|
function modifier_card_8.prototype.HandleCustomTransmitterData(self, data)
|
|
CardBaseModifier.prototype.HandleCustomTransmitterData(self, data)
|
|
local ____opt_result_2
|
|
if data ~= nil then
|
|
____opt_result_2 = data.card8_ramp_stacks
|
|
end
|
|
local rampStacksRaw = __TS__Number(____opt_result_2)
|
|
if __TS__NumberIsFinite(rampStacksRaw) and rampStacksRaw >= 0 then
|
|
self.rampStacks = math.floor(rampStacksRaw)
|
|
end
|
|
end
|
|
function modifier_card_8.prototype.AddCustomTransmitterData(self)
|
|
return __TS__ObjectAssign(
|
|
{},
|
|
CardBaseModifier.prototype.AddCustomTransmitterData(self),
|
|
{card8_ramp_stacks = self.rampStacks}
|
|
)
|
|
end
|
|
modifier_card_8 = __TS__Decorate(
|
|
modifier_card_8,
|
|
modifier_card_8,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_8"}
|
|
)
|
|
____exports.modifier_card_8 = modifier_card_8
|
|
return ____exports
|