31 lines
967 B
Lua
31 lines
967 B
Lua
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
|
local ____exports = {}
|
|
--- Как в defension (lib/utils.ts + lib/Filters.ts): от юнита к «настоящему» герою игрока для учёта урона.
|
|
function ____exports.getTrueHeroFromEntity(self, ent)
|
|
if not ent then
|
|
return nil
|
|
end
|
|
if ent:IsBaseNPC() then
|
|
local npc = ent
|
|
if npc:IsRealHero() then
|
|
return npc
|
|
end
|
|
local ownerEnt = npc:GetOwner()
|
|
if ownerEnt and ownerEnt:IsBaseNPC() then
|
|
local owner = ownerEnt
|
|
if owner:IsRealHero() then
|
|
return owner
|
|
end
|
|
end
|
|
local player = npc:GetPlayerOwner()
|
|
if player ~= nil then
|
|
local hero = player:GetAssignedHero()
|
|
if hero and hero:IsRealHero() then
|
|
return hero
|
|
end
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
return ____exports
|