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

76 lines
2.1 KiB
Lua

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____card_data = require("cards.card_data")
local CARD_DATABASE = ____card_data.CARD_DATABASE
local CARD_ID = 53
local MOD_NAME = "modifier_card_53"
function ____exports.card53OnTargetHealed(self, target, amount, healer)
if not IsServer() then
return
end
if amount <= 0 then
return
end
if not target or not IsValidEntity(target) or not target:IsAlive() then
return
end
local ____this_1
____this_1 = target
local ____opt_0 = ____this_1.IsRealHero
if ____opt_0 ~= nil then
____opt_0 = ____opt_0(____this_1)
end
if not ____opt_0 or not target:HasModifier(MOD_NAME) then
return
end
local ____opt_2 = CARD_DATABASE[CARD_ID]
local row = ____opt_2 and ____opt_2.values
local radius = (row and row.link_radius) ~= nil and math.max(0, row.link_radius) or 800
local sharePct = (row and row.heal_transfer_pct) ~= nil and row.heal_transfer_pct or 20
if radius <= 0 or sharePct <= 0 then
return
end
local share = amount * (sharePct / 100)
if share <= 0 then
return
end
local allies = FindUnitsInRadius(
target:GetTeamNumber(),
target:GetAbsOrigin(),
nil,
radius,
DOTA_UNIT_TARGET_TEAM_FRIENDLY,
DOTA_UNIT_TARGET_HERO,
DOTA_UNIT_TARGET_FLAG_INVULNERABLE,
FIND_CLOSEST,
false
)
local recipients = {}
for ____, u in ipairs(allies) do
do
if u == target then
goto __continue9
end
if not u or not IsValidEntity(u) or not u:IsAlive() or not u:IsRealHero() then
goto __continue9
end
if healer and u == healer then
goto __continue9
end
recipients[#recipients + 1] = u
end
::__continue9::
end
if #recipients == 0 then
return
end
local each = share / #recipients
if each <= 0 then
return
end
for ____, a in ipairs(recipients) do
a:Heal(each, nil)
end
end
return ____exports