Files
Dota-Zombie-Invasion/scripts/vscripts/cards/examples/card_43.lua
T
2026-05-29 15:11:31 +07:00

151 lines
5.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 __TS__Number = ____lualib.__TS__Number
local __TS__NumberIsFinite = ____lualib.__TS__NumberIsFinite
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_bat_stacking = require("cards.card_bat_stacking")
local applyHeroTargetBat = ____card_bat_stacking.applyHeroTargetBat
local computeAttackSpeedBonusForTargetBat = ____card_bat_stacking.computeAttackSpeedBonusForTargetBat
local MODIFIER_CARD_43 = ____card_bat_stacking.MODIFIER_CARD_43
local CARD_ID = 43
____exports.card_43 = __TS__Class()
local card_43 = ____exports.card_43
card_43.name = "card_43"
card_43.____file_path = "scripts/vscripts/cards/examples/card_43.lua"
__TS__ClassExtends(card_43, CardBase)
function card_43.prototype.GetModifierName(self)
return MODIFIER_CARD_43
end
card_43 = __TS__Decorate(card_43, card_43, {RegisterCard}, {kind = "class", name = "card_43"})
____exports.card_43 = card_43
____exports.modifier_card_43 = __TS__Class()
local modifier_card_43 = ____exports.modifier_card_43
modifier_card_43.name = "modifier_card_43"
modifier_card_43.____file_path = "scripts/vscripts/cards/examples/card_43.lua"
__TS__ClassExtends(modifier_card_43, CardBaseModifier)
function modifier_card_43.prototype.____constructor(self, ...)
CardBaseModifier.prototype.____constructor(self, ...)
self.totalBatReductionFlat = 0
self.totalProjectileBonus = 0
self.totalAnimReductionPct = 0
end
function modifier_card_43.prototype.OnCustomCreated(self, _params)
if not IsServer() then
return
end
Timers:CreateTimer(
0,
function()
if self:IsNull() then
return nil
end
self:refreshBonuses()
return nil
end
)
end
function modifier_card_43.prototype.OnCustomRefresh(self, params)
local ____opt_result_2
if params ~= nil then
____opt_result_2 = params.card_level
end
local levelRaw = __TS__Number(____opt_result_2)
if __TS__NumberIsFinite(levelRaw) and levelRaw > 0 then
self.cardLevelSnapshot = math.floor(levelRaw)
end
if not IsServer() then
return
end
self:refreshBonuses()
end
function modifier_card_43.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_ATTACKSPEED_BONUS_CONSTANT, MODIFIER_PROPERTY_PROJECTILE_SPEED_BONUS, MODIFIER_PROPERTY_ATTACK_ANIM_TIME_PERCENTAGE, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_43.prototype.GetModifierAttackSpeedBonus_Constant(self)
local parent = self:GetParent()
if not parent or not IsValidEntity(parent) then
return 0
end
return computeAttackSpeedBonusForTargetBat(nil, parent, self.totalBatReductionFlat)
end
function modifier_card_43.prototype.GetModifierProjectileSpeedBonus(self)
if self.totalProjectileBonus <= 0 then
return 0
end
local parent = self:GetParent()
if not parent or not IsValidEntity(parent) or not parent:IsRangedAttacker() then
return 0
end
return self.totalProjectileBonus
end
function modifier_card_43.prototype.GetModifierPercentageAttackAnimTime(self)
return self.totalAnimReductionPct
end
function modifier_card_43.prototype.OnTooltip(self)
return self:getCardCopies()
end
function modifier_card_43.prototype.HandleCustomTransmitterData(self, data)
local ____opt_result_5
if data ~= nil then
____opt_result_5 = data.card_level_snapshot
end
local levelRaw = __TS__Number(____opt_result_5)
if __TS__NumberIsFinite(levelRaw) and levelRaw > 0 then
self.cardLevelSnapshot = math.floor(levelRaw)
end
local ____opt_result_8
if data ~= nil then
____opt_result_8 = data.bat_flat
end
self.totalBatReductionFlat = __TS__Number(____opt_result_8) or 0
local ____opt_result_11
if data ~= nil then
____opt_result_11 = data.projectile_bonus
end
self.totalProjectileBonus = __TS__Number(____opt_result_11) or 0
local ____opt_result_14
if data ~= nil then
____opt_result_14 = data.anim_pct
end
self.totalAnimReductionPct = __TS__Number(____opt_result_14) or 0
end
function modifier_card_43.prototype.AddCustomTransmitterData(self)
return {card_level_snapshot = self.cardLevelSnapshot or 1, bat_flat = self.totalBatReductionFlat, projectile_bonus = self.totalProjectileBonus, anim_pct = self.totalAnimReductionPct}
end
function modifier_card_43.prototype.refreshBonuses(self)
if not IsServer() then
return
end
local parent = self:GetParent()
if not parent or not IsValidEntity(parent) then
return
end
local copies = self:getCardCopies()
local batPerCopy = self:getCardValue("bat_reduction", 0.1, CARD_ID)
self.totalBatReductionFlat = copies * batPerCopy
self.totalProjectileBonus = copies * self:getCardValue("projectile_speed_bonus", 0, CARD_ID)
self.totalAnimReductionPct = copies * self:getCardValue("attack_anim_reduction_pct", 0, CARD_ID)
applyHeroTargetBat(nil, parent, self.totalBatReductionFlat)
self:SendBuffRefreshToClients()
if parent:IsRealHero() then
parent:CalculateStatBonus(true)
end
end
modifier_card_43 = __TS__Decorate(
modifier_card_43,
modifier_card_43,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_43"}
)
____exports.modifier_card_43 = modifier_card_43
return ____exports