-------GLOBALS------ local spawn_timer = time_global() + 60000 local spawn_active = true function random_spawner_main() local actor_rank = ranks.get_obj_rank_name(db.actor) local current_level = level.name() local coords_spawn = math.random(1, 2) local max_to_spawn = math.random(1,3) local levels = { ["la01_escape"] = { coords = { [1] = {x = -128.11, y = 4.07, z = 236.48}, [2] = {x = 306.26, y = 12.75, z = 290.55} } }, ["la02_garbage"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } }, ["la03_agroprom"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } }, ["la04_darkdolina"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } }, ["la05_bar_rostok"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } }, ["la07_military"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } }, ["la08_yantar"] = { coords = { [1] = {x = -178.97, y = -4.62, z = -142.04}, [2] = {x = -243.97, y = -7.62, z = -138.04} } } } if spawn_active == true and (spawn_timer == nil or spawn_timer < time_global() ) then for level,content in pairs(levels) do if ( current_level == level and db.actor:alive() ) then for min_to_spawn = 1,max_to_spawn do alife():create(rs_npc_select(), vector():set(levels[level].coords[coords_spawn].x,levels[level].coords[coords_spawn].y,levels[level].coords[coords_spawn].z), db.actor:level_vertex_id(), db.actor:game_vertex_id()) end spawn_active = true end spawn_timer = time_global() + 60000 end end end function rs_npc_select() local human_npc_groups = { ["military"] = { "esc_soldier_respawn_1", "rad_specnaz_respawn_specnaz", "rad_soldier_master", "val_soldier_respawn_1", "agr_soldier_regular" }, ["stalker"] = { "agr_stalker_regular", "gar_stalker_respawn_1", "gar_stalker_respawn_2", "ds_stalker_respawn_2", "bar_stalker_respawn_4" }, ["monolith"]= { "pri_monolith_respawn_1", "rad_monolith_respawn_1", "rad_monolith_respawn_2", "pri_monolith_respawn_2", "pri_monolith_respawn_3"}, ["killer"] = { "cit_killer_respawn_1", "ros_killer_respawn_3", "ros_killer_respawn_2", "mil_killer_respawn_1", "mil_killer_respawn_4" }, ["ecolog"] = { "yan_ecolog_respawn_1" }, ["bandit"] = { "agr_bandit_respawn_1", "agr_bandit_respawn_2", "gar_bandit_respawn_2", "ds_bandit_respawn_3", "cit_bandit_respawn_2" } } local groups_total = 0 for _ in pairs(human_npc_groups) do groups_total = groups_total + 1 end local npc_group = math.random(1,groups_total) local human_group = "" if(npc_group == 1) then human_group = "military" elseif(npc_group == 2) then human_group = "stalker" elseif(npc_group == 3) then human_group = "monolith" elseif(npc_group == 4) then human_group = "killer" elseif(npc_group == 5) then human_group = "ecolog" elseif(npc_group == 6) then human_group = "bandit" end local human_group_npc = math.random(1,#human_npc_groups[human_group]) return human_npc_groups[human_group][human_group_npc] end