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

121 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 ____luck = require("utils.luck")
local rollLuckChance = ____luck.rollLuckChance
local CARD_ID = 19
local GHOST_STEP_MODIFIER = "modifier_card_19_ghost_step"
____exports.card_19 = __TS__Class()
local card_19 = ____exports.card_19
card_19.name = "card_19"
card_19.____file_path = "scripts/vscripts/cards/examples/card_19.lua"
__TS__ClassExtends(card_19, CardBase)
function card_19.prototype.GetModifierName(self)
return "modifier_card_19"
end
card_19 = __TS__Decorate(card_19, card_19, {RegisterCard}, {kind = "class", name = "card_19"})
____exports.card_19 = card_19
____exports.modifier_card_19 = __TS__Class()
local modifier_card_19 = ____exports.modifier_card_19
modifier_card_19.name = "modifier_card_19"
modifier_card_19.____file_path = "scripts/vscripts/cards/examples/card_19.lua"
__TS__ClassExtends(modifier_card_19, CardBaseModifier)
function modifier_card_19.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID)
end
function modifier_card_19.prototype.DeclareFunctions(self)
return {MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_19.prototype.OnAttackLanded(self, event)
if not IsServer() then
return
end
local attacker = self:GetParent()
if not attacker or not IsValidEntity(attacker) or event.attacker ~= attacker then
return
end
local target = event.target
if not target or not IsValidEntity(target) or not target:IsAlive() then
return
end
if target:GetTeamNumber() == attacker:GetTeamNumber() then
return
end
local chancePct = self:getValue("ghost_step_chance_pct", 20)
local duration = self:getValue("ghost_step_duration", 2)
local ____attacker_IsRealHero_result_0
if attacker:IsRealHero() then
____attacker_IsRealHero_result_0 = rollLuckChance(nil, attacker, chancePct / 100)
else
____attacker_IsRealHero_result_0 = RollPercentage(chancePct)
end
local proc = ____attacker_IsRealHero_result_0
if not proc or duration <= 0 then
return
end
attacker:AddNewModifier(
attacker,
getModifierSourceAbility(nil, attacker),
GHOST_STEP_MODIFIER,
{duration = duration}
)
end
modifier_card_19 = __TS__Decorate(
modifier_card_19,
modifier_card_19,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_19"}
)
____exports.modifier_card_19 = modifier_card_19
____exports.modifier_card_19_ghost_step = __TS__Class()
local modifier_card_19_ghost_step = ____exports.modifier_card_19_ghost_step
modifier_card_19_ghost_step.name = "modifier_card_19_ghost_step"
modifier_card_19_ghost_step.____file_path = "scripts/vscripts/cards/examples/card_19.lua"
__TS__ClassExtends(modifier_card_19_ghost_step, CardBaseModifier)
function modifier_card_19_ghost_step.prototype.getCardCopiesFromOwner(self)
local owner = self:GetCaster()
if not owner or not IsValidEntity(owner) then
return 1
end
local cardMod = owner:FindModifierByName("modifier_card_19")
return math.max(
1,
math.floor(cardMod and cardMod:GetStackCount() or 0)
)
end
function modifier_card_19_ghost_step.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID) * self:getCardCopiesFromOwner()
end
function modifier_card_19_ghost_step.prototype.IsPurgable(self)
return false
end
function modifier_card_19_ghost_step.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE, MODIFIER_PROPERTY_EVASION_CONSTANT, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_19_ghost_step.prototype.GetModifierMoveSpeedBonus_Percentage(self)
return self:getValue("ghost_step_move_speed_pct", 20)
end
function modifier_card_19_ghost_step.prototype.GetModifierEvasion_Constant(self)
return self:getValue("ghost_step_evasion_pct", 15)
end
function modifier_card_19_ghost_step.prototype.CheckState(self)
return {[MODIFIER_STATE_NO_UNIT_COLLISION] = true}
end
modifier_card_19_ghost_step = __TS__Decorate(
modifier_card_19_ghost_step,
modifier_card_19_ghost_step,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_19_ghost_step"}
)
____exports.modifier_card_19_ghost_step = modifier_card_19_ghost_step
return ____exports