function spawn_to_nearest_kamp(section)
if not db.actor then return nil end
local actor_pos = db.actor:position()
-- Безопасный спавн в радиусе 8 метров вокруг ГГ
local spawn_pos = vector():set(
actor_pos.x + math.random(-8, 8),
actor_pos.y + 0.5,
actor_pos.z + math.random(-8, 8)
)
local lvid = db.actor:level_vertex_id()
local gvid = db.actor:game_vertex_id()
-- Спавним серверный объект
local se_obj = alife():create(section, spawn_pos, lvid, gvid)
if not se_obj then return nil end
-- Записываем бедолагу в пул для будущей ротации
table.insert(spawned_stalkers_pool, se_obj.id)
-- [ПАКТ О НЕЙТРАЛИТЕТЕ] ждем выхода в онлайн и мирим со всеми в Баре
if level.name() == "l05_bar" then
level.add_call(
function()
-- Ждем, пока объект материализуется в клиенте (выйдет в онлайн)
return level.object_by_id(se_obj.id) ~= nil
end,
function()
local npc = level.object_by_id(se_obj.id)
if npc then
-- Ставим нейтралитет с Меченым
npc:set_relation(game_object.neutral, db.actor)
-- Пробегаемся по всем, кто в онлайне, и заставляем дружить
for id, v in pairs(db.storage) do
local other_npc = level.object_by_id(id)
if other_npc and id ~= npc:id() then
npc:set_relation(game_object.neutral, other_npc)
other_npc:set_relation(game_object.neutral, npc)
end
end
end
end
)
end
return se_obj
end