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

136 lines
5.1 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_general_fired = require("abilities.modifiers.modifier_general_fired")
local modifier_general_fired = ____modifier_general_fired.modifier_general_fired
local ____luck = require("utils.luck")
local rollLuckChance = ____luck.rollLuckChance
local CARD_ID = 13
____exports.card_13 = __TS__Class()
local card_13 = ____exports.card_13
card_13.name = "card_13"
card_13.____file_path = "scripts/vscripts/cards/examples/card_13.lua"
__TS__ClassExtends(card_13, CardBase)
function card_13.prototype.GetModifierName(self)
return "modifier_card_13"
end
card_13 = __TS__Decorate(card_13, card_13, {RegisterCard}, {kind = "class", name = "card_13"})
____exports.card_13 = card_13
____exports.modifier_card_13 = __TS__Class()
local modifier_card_13 = ____exports.modifier_card_13
modifier_card_13.name = "modifier_card_13"
modifier_card_13.____file_path = "scripts/vscripts/cards/examples/card_13.lua"
__TS__ClassExtends(modifier_card_13, CardBaseModifier)
function modifier_card_13.prototype.Precache(self, context)
PrecacheResource("particle", "particles/units/heroes/hero_techies/techies_blast_off.vpcf", context)
end
function modifier_card_13.prototype.DeclareFunctions(self)
return {MODIFIER_EVENT_ON_ATTACK_LANDED, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_13.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID)
end
function modifier_card_13.prototype.addFiredStacks(self, target, attacker, stacks)
if stacks <= 0 then
local ____opt_0 = target:FindModifierByName(modifier_general_fired.name)
return ____opt_0 and ____opt_0:GetStackCount() or 0
end
local firedModifier = target:AddNewModifier(
attacker,
getModifierSourceAbility(nil, attacker),
modifier_general_fired.name,
{}
)
if not firedModifier then
return 0
end
do
local i = 0
while i < stacks do
firedModifier:IncrementStackCount()
i = i + 1
end
end
return firedModifier:GetStackCount()
end
function modifier_card_13.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 copies = self:getCardCopies()
local stacksOnHit = self:getValue("fired_stacks_on_hit", 3) * copies
local firedStacks = self:addFiredStacks(target, attacker, stacksOnHit)
local chancePct = self:getValue("explosion_chance_pct", 18)
local ____attacker_IsRealHero_result_2
if attacker:IsRealHero() then
____attacker_IsRealHero_result_2 = rollLuckChance(nil, attacker, chancePct / 100)
else
____attacker_IsRealHero_result_2 = RollPercentage(chancePct)
end
local exploded = ____attacker_IsRealHero_result_2
if not exploded then
return
end
local radius = self:getValue("explosion_radius", 175)
local damagePerStack = self:getValue("explosion_damage_per_stack", 10)
local damage = (firedStacks * damagePerStack * copies + attacker:GetAverageTrueAttackDamage(target)) * copies
if damage <= 0 then
return
end
local particleName = "particles/units/heroes/hero_techies/techies_blast_off.vpcf"
local particle = ParticleManager:CreateParticle(particleName, PATTACH_WORLDORIGIN, nil)
ParticleManager:SetParticleControl(
particle,
0,
target:GetAbsOrigin()
)
ParticleManager:SetParticleControl(
particle,
1,
Vector(radius, 0, 0)
)
ParticleManager:ReleaseParticleIndex(particle)
local enemies = FindUnitsInRadius(
attacker:GetTeamNumber(),
target:GetAbsOrigin(),
nil,
radius,
DOTA_UNIT_TARGET_TEAM_ENEMY,
bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
DOTA_UNIT_TARGET_FLAG_NONE,
FIND_ANY_ORDER,
false
)
for ____, enemy in ipairs(enemies) do
ApplyDamage({victim = enemy, attacker = attacker, damage = damage, damage_type = DAMAGE_TYPE_MAGICAL})
end
end
modifier_card_13 = __TS__Decorate(
modifier_card_13,
modifier_card_13,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_13"}
)
____exports.modifier_card_13 = modifier_card_13
return ____exports