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

18 lines
797 B
Lua

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
--- Поиск npc_homer без FindUnitsInRadius на весь мир (тяжёлый запрос при каждом тике карт 55/56).
function ____exports.findHomerNpc(self)
local byName = Entities:FindByName(nil, "npc_homer")
if byName and IsValidEntity(byName) and not byName:IsNull() and byName:GetUnitName() == "npc_homer" then
return byName
end
local allUnits = Entities:FindAllByClassname("npc_dota_creature")
for ____, unit in ipairs(allUnits) do
if unit and IsValidEntity(unit) and not unit:IsNull() and unit:GetUnitName() == "npc_homer" and unit:IsAlive() then
return unit
end
end
return nil
end
return ____exports