167 lines
5.5 KiB
Lua
167 lines
5.5 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 ____heal_tracker = require("utils.heal_tracker")
|
|
local HealWithBattlePass = ____heal_tracker.HealWithBattlePass
|
|
local CARD_ID = 76
|
|
local STRIKE_PARTICLE = "particles/econ/items/pugna/pugna_ward_ti5/pugna_ward_attack_heavy_ti_5.vpcf"
|
|
____exports.card_76 = __TS__Class()
|
|
local card_76 = ____exports.card_76
|
|
card_76.name = "card_76"
|
|
card_76.____file_path = "scripts/vscripts/cards/examples/card_76.lua"
|
|
__TS__ClassExtends(card_76, CardBase)
|
|
function card_76.prototype.GetModifierName(self)
|
|
return "modifier_card_76"
|
|
end
|
|
card_76 = __TS__Decorate(card_76, card_76, {RegisterCard}, {kind = "class", name = "card_76"})
|
|
____exports.card_76 = card_76
|
|
____exports.modifier_card_76 = __TS__Class()
|
|
local modifier_card_76 = ____exports.modifier_card_76
|
|
modifier_card_76.name = "modifier_card_76"
|
|
modifier_card_76.____file_path = "scripts/vscripts/cards/examples/card_76.lua"
|
|
__TS__ClassExtends(modifier_card_76, CardBaseModifier)
|
|
function modifier_card_76.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_76.prototype.Precache(self, context)
|
|
PrecacheResource("particle", STRIKE_PARTICLE, context)
|
|
end
|
|
function modifier_card_76.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ABILITY_FULLY_CAST, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_76.prototype.OnAbilityFullyCast(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsAlive() or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
if event.unit ~= hero then
|
|
return
|
|
end
|
|
local ability = event.ability
|
|
if not ability or ability:IsNull() then
|
|
return
|
|
end
|
|
if ability:IsItem() or ability:IsToggle() then
|
|
return
|
|
end
|
|
local radius = self:getValue("radius", 250)
|
|
local maxTargets = math.max(
|
|
1,
|
|
math.floor(self:getValue("target_count", 1))
|
|
)
|
|
local manaDamagePct = self:getScaledCardValue("mana_damage_pct", 20)
|
|
local currentMana = hero:GetMana()
|
|
if currentMana <= 0 or manaDamagePct <= 0 then
|
|
return
|
|
end
|
|
local damage = currentMana * (manaDamagePct / 100)
|
|
if damage <= 0 then
|
|
return
|
|
end
|
|
local enemies = FindUnitsInRadius(
|
|
hero:GetTeamNumber(),
|
|
hero:GetAbsOrigin(),
|
|
nil,
|
|
radius,
|
|
DOTA_UNIT_TARGET_TEAM_ENEMY,
|
|
bit.bor(DOTA_UNIT_TARGET_HERO, DOTA_UNIT_TARGET_BASIC),
|
|
bit.bor(DOTA_UNIT_TARGET_FLAG_FOW_VISIBLE, DOTA_UNIT_TARGET_FLAG_NO_INVIS),
|
|
FIND_CLOSEST,
|
|
false
|
|
)
|
|
local hitCount = 0
|
|
local totalDamageDealt = 0
|
|
for ____, enemy in ipairs(enemies) do
|
|
do
|
|
if not enemy or not IsValidEntity(enemy) or enemy:IsNull() or not enemy:IsAlive() then
|
|
goto __continue14
|
|
end
|
|
if hitCount >= maxTargets then
|
|
break
|
|
end
|
|
hitCount = hitCount + 1
|
|
local healthBefore = enemy:GetHealth()
|
|
self:playStrikeEffect(hero, enemy)
|
|
ApplyDamage({victim = enemy, attacker = hero, damage = damage, damage_type = DAMAGE_TYPE_MAGICAL})
|
|
local damageDealt = math.max(
|
|
0,
|
|
healthBefore - math.max(
|
|
0,
|
|
enemy:GetHealth()
|
|
)
|
|
)
|
|
if damageDealt > 0 then
|
|
totalDamageDealt = totalDamageDealt + damageDealt
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_BONUS_SPELL_DAMAGE,
|
|
enemy,
|
|
damageDealt,
|
|
hero:GetPlayerOwner()
|
|
)
|
|
end
|
|
end
|
|
::__continue14::
|
|
end
|
|
if totalDamageDealt > 0 and hero:IsAlive() then
|
|
HealWithBattlePass(
|
|
nil,
|
|
hero,
|
|
totalDamageDealt,
|
|
nil,
|
|
hero,
|
|
false
|
|
)
|
|
SendOverheadEventMessage(
|
|
nil,
|
|
OVERHEAD_ALERT_HEAL,
|
|
hero,
|
|
totalDamageDealt,
|
|
hero:GetPlayerOwner()
|
|
)
|
|
end
|
|
end
|
|
function modifier_card_76.prototype.playStrikeEffect(self, caster, target)
|
|
local particle = ParticleManager:CreateParticle(STRIKE_PARTICLE, PATTACH_CUSTOMORIGIN, caster)
|
|
ParticleManager:SetParticleControlEnt(
|
|
particle,
|
|
0,
|
|
caster,
|
|
PATTACH_POINT_FOLLOW,
|
|
"attach_attack1",
|
|
caster:GetAbsOrigin(),
|
|
true
|
|
)
|
|
ParticleManager:SetParticleControlEnt(
|
|
particle,
|
|
1,
|
|
target,
|
|
PATTACH_POINT_FOLLOW,
|
|
"attach_hitloc",
|
|
target:GetAbsOrigin(),
|
|
true
|
|
)
|
|
ParticleManager:ReleaseParticleIndex(particle)
|
|
EmitSoundOn("Hero_Lion.FingerOfDeath", caster)
|
|
end
|
|
modifier_card_76 = __TS__Decorate(
|
|
modifier_card_76,
|
|
modifier_card_76,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_76"}
|
|
)
|
|
____exports.modifier_card_76 = modifier_card_76
|
|
return ____exports
|