18 lines
797 B
Lua
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
|