Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------- Схема поведения НПС при выбросе для OGSM 2.x -----------------
- ------------------------- Copyright 2007-2008 DEXXX ---------------------------
- restrictor_list = {}
- local npc_psy = {}
- local npc_run = {}
- local npc_sit = {}
- local npc_go = {}
- -- We check whether NPC is in specific rectangle zone (are set for special places,
- -- such as bar, where NPCs should not react to blowout at all)
- function npc_in_zone(obj,lev,pos_psy_x,pos_psy_y,size_psy_x,size_psy_y,z1,z2)
- local level_name = level.name()
- if level_name ~= lev then
- return false
- end
- local pos = obj:position()
- local x1 = pos_psy_x
- local x2 = pos_psy_y
- local y1 = size_psy_x
- local y2 = size_psy_y
- if (pos.x >= x1 and pos.x <= x2) and (pos.z >= y1 and pos.z <= y2) and (pos.y >= z1) and (pos.y <= z2) then
- return true
- end
- return false
- end
- -- We get the nearest to NPC hide
- function get_nearest_hide(npc)
- local hideout_list = {}
- for k,v in pairs(restrictor_list) do
- local community, radius = get_community_hide(v)
- local obj = level.object_by_id(v.id)
- if obj and string.find(community, npc:character_community()) then
- local npc_pos = npc:position()
- local hide_pos = obj:position()
- local distance = npc_pos:distance_to(hide_pos)
- local hide = {obj = obj, rad = radius, dist = distance}
- table.insert(hideout_list, hide)
- end
- end
- table.sort(hideout_list, function(a,b) return a.dist < b.dist end)
- local nearest_hide = hideout_list[1]
- return nearest_hide
- end
- -- We get the hideout data (communities, radius)
- function get_community_hide(obj)
- if not obj then return "none" end
- local packet = net_packet()
- obj:STATE_Write(packet)
- local game_vertex_id = packet:r_u16()
- local cse_alife_object__unk1_f32 = packet:r_float()
- local cse_alife_object__unk2_u32 = packet:r_s32()
- local level_vertex_id = packet:r_s32()
- local object_flags = packet:r_s32()
- local custom_data = packet:r_stringZ()
- local cd = parse_custom_data(custom_data)
- if not cd.parameters then return "none" end
- if not cd.parameters.community then return "none" end
- if not cd.parameters.radius then return "none" end
- return cd.parameters.community, cd.parameters.radius
- end
- function is_in_specific_zone(npc)
- if npc_in_zone(npc,"l01_escape",-256,-246,-137,-132,-25,-20) or -- Бункер Сидора
- npc_in_zone(npc,"l03_agroprom",-198.31,-195.66,85.4,96.54,2,5.3) or -- Вагон дезертира
- npc_in_zone(npc,"l04_darkvalley",30,50,-60,-25,-4,0) or -- Тюрьма в Темной долине
- npc_in_zone(npc,"l05_bar",123,140,18,30,-6,0) or -- Бар
- npc_in_zone(npc,"l05_bar",118,121,34,41,-4,1) or -- Охранник Бара
- npc_in_zone(npc,"l05_bar",149,158,67,74,0,4) or -- Приемная Арни
- npc_in_zone(npc,"l05_bar",136,168,73,134,-22,-10) or -- Арена
- npc_in_zone(npc,"l05_bar",208,234,120,139,-6,2) or -- База Долга
- npc_in_zone(npc,"l06_rostok",-90,-87,125,151,0,6) or -- Блокпост наемников
- npc_in_zone(npc,"l07_military",-27,-16,-33,-14,-9,0) or -- База Свободы
- npc_in_zone(npc,"l08_yantar",23,40,-282,-269,-16,0) or -- Бункер ученых
- npc_in_zone(npc,"l08_yantar",-265,-22,-218,-6,-20,-11) or -- Кишка
- npc_in_zone(npc,"l11_pripyat",-16,-2,188,204,-5,0) then -- Подвал ДК
- return true
- end
- return false
- end
- function is_in_hide(npc)
- if npc_in_zone(npc,"l01_escape",-211,-198,-132,-125,-23,-20) or -- Подвал 1 в лагере новичков
- npc_in_zone(npc,"l01_escape",-216,-209,-133,-120,-24,-20) or -- Подвал 2 в лагере новичков
- npc_in_zone(npc,"l02_garbage",-112,-57,-6,25,-9,90) or -- Ангар на Свалке
- npc_in_zone(npc,"l05_bar",206,213,50,68,0,4) or -- Магазин Петренко
- npc_in_zone(npc,"l06_rostok",-285,-235,78,112,-7,0) or -- Тоннель Фримена
- npc_in_zone(npc,"l10_radar",639,664,167,189,-45,-37) or -- Секретная база Монолита
- npc_in_zone(npc,"l10_radar",86.73,153,-27,-21.70,-10,-4.6) or -- Вход в бункер
- npc_in_zone(npc,"l11_pripyat",-18,-12,58,83,-6,-3) or -- Подземный переход
- npc_in_zone(npc,"l11_pripyat",167,173,58,83,-6,-3) or -- Подземный переход
- npc_in_zone(npc,"l11_pripyat",-24,55,116,122,-4,0) then -- Канализация
- return true
- else
- local hide = get_nearest_hide(npc)
- if hide then
- if utils.npc_in_zone(npc, hide.obj) then
- return true
- end
- end
- end
- return false
- end
- -- Spawn function. Better watch out :)
- function spawn_restrictor(p_level, p_vector, p_lv, p_gv, p_type, p_radius)
- local p_name
- p_name = p_level.."_hide_restrictor"
- local obj = alife():create(p_name, p_vector, p_lv, p_gv)
- local hide_name
- if string.find(p_type, "_") then hide_name = "ogsm_common_hide"
- else hide_name = "ogsm_"..p_type.."_hide" end
- local mapspot
- if p_radius < 4 then mapspot = "ogsm_hide_spot_min"
- elseif p_radius < 11 then mapspot = "ogsm_hide_spot_mdl"
- else mapspot = "ogsm_hide_spot_max" end
- local packet = net_packet()
- obj:STATE_Write(packet)
- -- свойства cse_alife_object
- local game_vertex_id = packet:r_u16()
- local cse_alife_object__unk1_f32 = packet:r_float()
- local cse_alife_object__unk2_u32 = packet:r_s32()
- local level_vertex_id = packet:r_s32()
- local object_flags = packet:r_s32()
- local custom_data = packet:r_stringZ()
- local story_id = packet:r_s32()
- local cse_alife_object__unk3_u32 = packet:r_s32()
- -- свойства cse_shape
- local shape_count = packet:r_u8()
- local shape_type
- local center
- local radius
- if shape_count == 0 then
- shape_type = 0
- center = vector():set(0,0,0)
- radius = 10.0
- shape_count = 1
- else
- for i=1,shape_count do
- local shape_type = packet:r_u8()
- if shape_type == 0 then
- local center = packet:r_vec3()
- local radius = packet:r_float()
- else
- local v1 = packet:r_vec3()
- local v2 = packet:r_vec3()
- local v3 = packet:r_vec3()
- local v4 = packet:r_vec3()
- end
- end
- end
- -- свойства cse_alife_space_restrictor
- local restrictor_type = packet:r_u8()
- -- свойства cse_alife_object
- packet:w_u16(game_vertex_id)
- packet:w_float(cse_alife_object__unk1_f32)
- packet:w_s32(cse_alife_object__unk2_u32)
- packet:w_s32(level_vertex_id)
- packet:w_s32(object_flags)
- custom_data = "[logic] \nactive = sr_mapspot \n[sr_mapspot] \nhint = "..hide_name.." \nlocation = "..mapspot
- local cd = parse_custom_data(custom_data)
- if not cd then cd={} end
- if not cd.parameters then cd.parameters = {} end
- cd.parameters.community = p_type
- cd.parameters.radius = p_radius
- custom_data = gen_custom_data(cd)
- packet:w_stringZ(custom_data)
- packet:w_s32(story_id)
- packet:w_s32(cse_alife_object__unk3_u32)
- -- свойства cse_shape
- packet:w_u8(shape_count)
- for i=1,shape_count do
- packet:w_u8(shape_type)
- if shape_type == 0 then
- packet:w_vec3(center)
- packet:w_float(p_radius)
- else
- packet:w_vec3(v1)
- packet:w_vec3(v2)
- packet:w_vec3(v3)
- packet:w_vec3(v4)
- end
- end
- -- свойства cse_alife_space_restrictor
- packet:w_u8(restrictor_type)
- obj:STATE_Read(packet, packet:w_tell()-packet:r_tell())
- return obj
- end
- -- Don't touch this too.
- function parse_custom_data(str)
- local t={}
- if str then
- for section, section_data in string.gfind(str,"%s*%[([^%]]*)%]%s*([^%[%z]*)%s*") do
- section = trim(section)
- t[section]={}
- for line in string.gfind(trim(section_data), "([^\n]*)\n*") do
- if string.find(line,"=")~=nil then
- for k, v in string.gfind(line, "([^=]-)%s*=%s*(.*)") do
- k = trim(k)
- if k~=nil and k~='' and v~=nil then
- t[section][k]=trim(v)
- end
- end
- else
- for k, v in string.gfind(line, "(.*)") do
- k = trim(k)
- if k~=nil and k~='' then
- t[section][k]="<<no_value>>"
- end
- end
- end
- end
- end
- end
- return t
- end
- function gen_custom_data(tbl)
- local str=''
- for key, value in pairs(tbl) do
- str = str.."["..key.."]\n"
- for k, v in pairs(value) do
- if v~="<<no_value>>" then
- str=str..k.." = "..v.."\n"
- else
- str=str..k.."\n"
- end
- end
- end
- return str
- end
- function trim (s)
- return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
- end
- -- Getting the list of hideouts on game load
- function get_level_hides()
- for i=1,65535 do
- local obj = alife():object(i)
- if obj then
- if string.find(obj:name(), level.name().."_hide_restrictor") then
- table.insert(restrictor_list, obj)
- end
- end
- end
- end
- -- First run spawn. If parameter p_type is "fake_" - it means that the hide is fake - it is only for actor
- -- NPCs ignore such fake hides
- function first_run()
- ------------------
- -- Escape Hides --
- ------------------
- -- Бункер Сидора
- spawn_restrictor("l01_escape", vector():set(-249.9,-24.8,-134.4), 10136, 7, "fake_", 3)
- -- Лагерь новичков
- spawn_restrictor("l01_escape", vector():set(-206.5,-22.53,-128.1), 46582, 58, "stalker", 3)
- spawn_restrictor("l01_escape", vector():set(-211.4,-23.17,-129.5), 41963, 59, "stalker", 3)
- -- Ферма
- spawn_restrictor("l01_escape", vector():set(-8.4,0.64,258.3), 268724, 183, "stalker", 4)
- -- Заброшенный дом рядом с Лисом
- spawn_restrictor("l01_escape", vector():set(133.0,0.22,339.5), 437657, 232, "stalker_bandit", 3)
- -- АТП
- spawn_restrictor("l01_escape", vector():set(109.9,-7.48,7.7), 411371, 118, "stalker_bandit", 5)
- -- Блокпост
- spawn_restrictor("l01_escape", vector():set(-119.7,-30.04,-386.4), 133789, 27, "military", 4)
- spawn_restrictor("l01_escape", vector():set(-140.7,-29.68,-361.2), 109717, 18, "military", 4)
- -- Мельница
- spawn_restrictor("l01_escape", vector():set(13.3,2.7,98.7), 290783, 92, "military", 3)
- -------------------
- -- Garbage Hides --
- -------------------
- -- Ангар - восточная часть
- spawn_restrictor("l02_garbage", vector():set(-61.6,0.75,9.1), 135489, 330, "stalker", 6)
- -- Изгородь
- spawn_restrictor("l02_garbage", vector():set(66.5,0.6,144.9), 237602, 364, "bandit", 2)
- -- Ангар - западная часть
- spawn_restrictor("l02_garbage", vector():set(-102.9,0.44,11.9), 110339, 328, "bandit", 6)
- --------------------
- -- Agroprom Hides --
- --------------------
- -- Строение в районе Крота
- spawn_restrictor("l03_agroprom", vector():set(16.8,0,14), 256750, 693, "stalker_bandit_military", 6)
- -- Убежище Крота
- spawn_restrictor("l03_agroprom", vector():set(39.9,2.5,-10.5), 278041, 693, "stalker", 6)
- -- Казармы у подземелья
- spawn_restrictor("l03_agroprom", vector():set(-158.2,1.1,-151.2), 79088, 693, "military", 5)
- -- Казармы у НИИ
- spawn_restrictor("l03_agroprom", vector():set(-153.3,1.1,-166.6), 84356, 693, "military", 5)
- -- Строение у НИИ
- spawn_restrictor("l03_agroprom", vector():set(-179.9,0,-187.6), 56704, 693, "military", 6)
- -- НИИ Агропром
- spawn_restrictor("l03_agroprom", vector():set(-145.6,0,-200.9), 92513, 693, "military", 6)
- ----------------------
- -- Darkvalley Hides --
- ----------------------
- -- Строения над входом в Х18
- spawn_restrictor("l04_darkvalley", vector():set(146.3,0.22,-263.2), 345170, 813, "bandit_military_dolg", 15)
- spawn_restrictor("l04_darkvalley", vector():set(128.1,0.14,-294), 325149, 813, "bandit_military_dolg", 7)
- -- Ферма
- spawn_restrictor("l04_darkvalley", vector():set(-135.1,0.97,-511), 22718, 813, "stalker", 8)
- -- Бензоколонка
- spawn_restrictor("l04_darkvalley", vector():set(101.5,0.7,-7.7), 297166, 813, "stalker_", 6)
- -- Подвал рядом с ямой
- spawn_restrictor("l04_darkvalley", vector():set(34.3,-2.93,-0.7), 216848, 813, "bandit_dolg", 4)
- -- Элеватор
- spawn_restrictor("l04_darkvalley", vector():set(-7,0.11,-57.4), 165893, 813, "bandit", 4)
- -- Комната Борова
- spawn_restrictor("l04_darkvalley", vector():set(39.2,4.54,-84), 223238, 813, "bandit", 5)
- -- Холл
- spawn_restrictor("l04_darkvalley", vector():set(37.1,0.375,-66.5), 220567, 813, "bandit", 5)
- -- Над тюрьмой
- spawn_restrictor("l04_darkvalley", vector():set(40.6,1.01,-31.5), 225406, 813, "bandit", 7)
- ---------------
- -- Bar Hides --
- ---------------
- -- Бункер на заставе
- spawn_restrictor("l05_bar", vector():set(214.2,-1.57,-18.9), 52736, 1233, "stalker_dolg", 3)
- -- Иди своей дорогой, сталкер...
- spawn_restrictor("l05_bar", vector():set(178.5,0.09,49.0), 44766, 1233, "stalker_dolg", 6)
- -- Магазин Петренко
- spawn_restrictor("l05_bar", vector():set(210.0,0.42,61.6), 51205, 1233, "dolg", 5)
- -- База Долга
- spawn_restrictor("l05_bar", vector():set(224.0,-5.26,130.9), 56342, 1233, "fake_", 8)
- -- Предбанник Арены
- spawn_restrictor("l05_bar", vector():set(142.8,0.09,93.1), 38428, 1233, "stalker_dolg", 6)
- -- Строения у Бара
- spawn_restrictor("l05_bar", vector():set(112.7,0.097,68.6), 33337, 1233, "stalker_dolg", 6)
- spawn_restrictor("l05_bar", vector():set(144.9,-0.012,40.6), 38939, 1233, "stalker_dolg", 6)
- -- Бар
- spawn_restrictor("l05_bar", vector():set(131.6,-4.83,23.8), 36240, 1233, "fake_", 10)
- ------------------
- -- Rostok Hides --
- ------------------
- -- Блокпост наемников
- spawn_restrictor("l06_rostok", vector():set(-88.9,0,137.2), 46715, 1311, "stalker_dolg_killer_ecolog", 2)
- spawn_restrictor("l06_rostok", vector():set(-82.6,1.95,156.8), 48150, 1311, "stalker_dolg_killer_ecolog", 3)
- -- Ангар с пси-зоной
- spawn_restrictor("l06_rostok", vector():set(-191.8,0,130.9), 28448, 1311, "stalker_dolg_killer_ecolog", 6)
- -- Тоннель Фримена
- spawn_restrictor("l06_rostok", vector():set(-280,-6,109.2), 1769, 1311, "ecolog", 3)
- -- Засады наемников
- spawn_restrictor("l06_rostok", vector():set(-242.9,0,140), 12634, 1311, "killer", 2)
- spawn_restrictor("l06_rostok", vector():set(-228.2,0.13,141.4), 19047, 1311, "killer", 2)
- spawn_restrictor("l06_rostok", vector():set(-250.6,1.43,14), 9490, 1311, "killer", 2)
- --------------------
- -- Military Hides --
- --------------------
- -- База Долга
- spawn_restrictor("l07_military", vector():set(-191.8,-13,39.9), 133097, 1546, "dolg", 4)
- -- Деревня кровососов
- spawn_restrictor("l07_military", vector():set(-228.9,-21.78,196.7), 102257, 1546, "freedom", 4)
- -- Стоянка нейтралов
- spawn_restrictor("l07_military", vector():set(-71.4,-16.83,242.9), 240966, 1546, "stalker", 3)
- -- Барьер
- spawn_restrictor("l07_military", vector():set(84.7,-7,341.6), 382116, 1546, "freedom", 3)
- -- Хутор Павлика
- spawn_restrictor("l07_military", vector():set(-190.4,-16,371), 134714, 1546, "killer_freedom", 4)
- -- Штаб Свободы
- spawn_restrictor("l07_military", vector():set(-21.7,-4.12,-23.8), 285439, 1546, "fake_", 6)
- -- Казармы
- spawn_restrictor("l07_military", vector():set(9.1,-7.28,16.1), 316470, 1546, "freedom", 6)
- spawn_restrictor("l07_military", vector():set(57.4,-8.054,16.8), 356438, 1546, "freedom", 6)
- -- Кухня
- spawn_restrictor("l07_military", vector():set(-77,-11.34,30.1), 235657, 1546, "freedom", 6)
- ------------------
- -- Yantar Hides --
- ------------------
- -- Бункер ученых
- spawn_restrictor("l08_yantar", vector():set(31.5,-11.68,-272.3), 54643, 1459, "fake_", 6)
- -----------------
- -- Radar Hides --
- -----------------
- -- Секретная база Монолита
- spawn_restrictor("l10_radar", vector():set(650.955,-43.887,182.48), 226701, 1868, "dolg_freedom_stalker_military_monolith", 7)
- -- Вход в бункер
- spawn_restrictor("l10_radar", vector():set(147.35,-9.277,-24.21), 52689, 1868, "dolg_freedom_stalker_military_monolith", 4)
- -- Казармы на Радаре
- spawn_restrictor("l10_radar", vector():set(33.6,-3.38,-42), 21487, 1868, "dolg_freedom_stalker_military_monolith", 4)
- -------------------
- -- Pripyat Hides --
- -------------------
- -- Подземная автостоянка
- spawn_restrictor("l11_pripyat", vector():set(85.4,-7.39,20.3), 196856, 2269, "stalker_military_freedom_dolg_killer", 15)
- -- Сберкасса
- spawn_restrictor("l11_pripyat", vector():set(60.2,-1.74,33.6), 172091, 2269, "stalker_military_freedom_dolg_killer", 4)
- -- Милиция
- spawn_restrictor("l11_pripyat", vector():set(-35.7,-1.68,34.3), 63044, 2269, "stalker_military_freedom_dolg_killer", 6)
- -- Сельхозуправление
- spawn_restrictor("l11_pripyat", vector():set(-51.1,0,140), 48522, 2269, "stalker_military_freedom_dolg_killer", 12)
- -- Подвал Дома культуры
- spawn_restrictor("l11_pripyat", vector():set(-5.6,-5.169,193.2), 95262, 2269, "fake_", 6)
- -- Подземные переходы
- spawn_restrictor("l11_pripyat", vector():set(-15.4,-5.55,69.3), 83833, 2269, "stalker_military_freedom_dolg_killer", 3)
- spawn_restrictor("l11_pripyat", vector():set(170.8,-5.55,69.3), 253270, 2269, "stalker_military_freedom_dolg_killer", 3)
- -- Канализация
- spawn_restrictor("l11_pripyat", vector():set(19.6,-3.634,121.1), 125990, 2269, "stalker_military_freedom_dolg_killer", 2)
- end
- -- The Scheme itself below should not be edited if you don't how to do it
- property_base = 12221
- property_blowout = property_base+1
- property_hideout_lost = property_base+2
- property_inhide = property_base+3
- act_base = 13332
- act_hideout = act_base+1
- act_psy_effect = act_base+2
- act_inhide = act_base+3
- -- Создаем эвалуатор - проверяем, начался ли выброс
- class "evaluator_blowout" (property_evaluator)
- function evaluator_blowout:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function evaluator_blowout:evaluate()
- if not self.object:best_enemy() and
- db.Flag2==1 and db.Dead2==0 and
- not (level.name()=="l11_pripyat" and self.object:character_community() == "monolith") and
- not is_in_hide(self.object) and not is_in_specific_zone(self.object) then
- self.st.blowout = true
- else
- self.st.blowout = false
- end
- return self.st.blowout == true
- end
- -- Создаем эвалуатор - проверяем, потерял ли непись укрытие
- class "evaluator_hideout" (property_evaluator)
- function evaluator_hideout:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function evaluator_hideout:evaluate()
- if db.Dead2==1 and not is_in_hide(self.object) and not is_in_specific_zone(self.object) then
- self.st.hideout_lost = true
- else
- self.st.hideout_lost = false
- end
- return self.st.hideout_lost == true
- end
- -- Создаем эвалуатор - проверяем, сидит ли уже непись в укрытии
- class "evaluator_inhide" (property_evaluator)
- function evaluator_inhide:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function evaluator_inhide:evaluate()
- if db.Flag2==1 and is_in_hide(self.object) then
- self.st.inhide = true
- else
- self.st.inhide = false
- end
- return self.st.inhide == true
- end
- -- Создаем оператор - направляем НПС в укрытие
- class "action_hideout" (action_base)
- function action_hideout:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function action_hideout:initialize()
- local npc = self.object
- npc:set_desired_position()
- npc:set_desired_direction()
- npc:clear_animations()
- npc:set_detail_path_type(move.line)
- npc:set_path_type(game_object.level_path)
- npc:remove_all_restrictions()
- if npc_run[npc:id()] ~= 1 then
- self.hide = get_nearest_hide(npc)
- if self.hide then
- npc:add_restrictions(self.hide.obj:name(), "")
- state_mgr.set_state(npc, "assault")
- else
- npc:remove_all_restrictions()
- state_mgr.set_state(npc, "hide")
- end
- npc_run[npc:id()] = 1
- end
- end
- function action_hideout:execute()
- local npc = self.object
- npc:disable_talk()
- end
- function action_hideout:finalize()
- action_base.finalize(self)
- local npc = self.object
- npc_run[npc:id()] = 0
- end
- -- Создаем оператор - колбасим НПС, если он не нашел укрытие
- class "action_raskolbas" (action_base)
- function action_raskolbas:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function action_raskolbas:initialize() --Some kind of brain frying thing
- local npc = self.object
- npc:set_desired_position()
- npc:set_desired_direction()
- npc:clear_animations()
- npc:remove_all_restrictions()
- local ran = math.random(1,2)
- if npc_psy[npc:id()] ~= 1 then
- if npc:character_community() == "monolith" then
- state_mgr.set_state(npc, "trans_1")
- else
- if ran == 1 then
- state_mgr.set_state(npc, "psycho_pain")
- else
- state_mgr.set_state(npc, "psy_pain")
- end
- end
- npc_psy[npc:id()] = 1
- end
- end
- function action_raskolbas:execute()
- local npc=self.object
- npc:disable_talk()
- end
- function action_raskolbas:finalize()
- action_base.finalize(self)
- local npc = self.object
- npc_psy[npc:id()] = 0
- end
- -- Создаем оператор - усаживаем НПС, если он нашел укрытие
- class "action_inhide" (action_base)
- function action_inhide:__init(name, storage) super (nil, name)
- self.st = storage
- end
- function action_inhide:initialize()
- local npc = self.object
- npc:set_desired_position()
- npc:set_desired_direction()
- npc:clear_animations()
- npc:set_detail_path_type(move.line)
- npc:set_path_type(game_object.level_path)
- npc:remove_all_restrictions()
- self.hide = get_nearest_hide(npc)
- if self.hide then
- self.vertex = self.hide.obj:level_vertex_id()
- self.offset = vector():set(math.random()*3-1, 0, math.random()*3-1)
- self.offset:normalize()
- self.radius = math.random(1, self.hide.rad-1)
- self.lvid = npc:vertex_in_direction(self.vertex, self.offset, self.radius)
- if npc:level_vertex_id()~=self.lvid then
- state_mgr.set_state(npc,"raid")
- utils.send_to_nearest_accessible_vertex(npc, self.lvid)
- else
- state_mgr.set_state(npc,"hide")
- end
- else
- state_mgr.set_state(npc,"hide")
- end
- end
- function action_inhide:execute()
- local npc = self.object
- npc:disable_talk()
- if npc:level_vertex_id()~=self.lvid then
- if npc_go[npc:id()]~=1 then
- state_mgr.set_state(npc,"raid")
- utils.send_to_nearest_accessible_vertex(npc, self.lvid)
- npc_go[npc:id()] = 1
- npc_sit[npc:id()] = 0
- end
- else
- if npc_sit[npc:id()]~=1 then
- if npc:character_community()=="monolith" then
- state_mgr.set_state(npc,"trans_0")
- else
- state_mgr.set_state(npc,"hide")
- end
- npc_sit[npc:id()] = 1
- npc_go[npc:id()] = 0
- end
- end
- end
- function action_inhide:finalize()
- action_base.finalize(self)
- local npc = self.object
- npc_sit[npc:id()] = 0
- npc_go[npc:id()] = 0
- npc:remove_all_restrictions()
- end
- -- Добавляем в планировщик нашу схему
- function add_to_binder(object, char_ini, scheme, section, st)
- local manager = object:motivation_action_manager()
- local property_wounded = xr_evaluators_id.sidor_wounded_base
- manager:remove_evaluator(property_blowout)
- manager:add_evaluator(property_blowout, evaluator_blowout("evaluator_blowout", st))
- manager:remove_evaluator(property_hideout_lost)
- manager:add_evaluator(property_hideout_lost, evaluator_hideout("evaluator_hideout", st))
- manager:remove_evaluator(property_inhide)
- manager:add_evaluator(property_inhide, evaluator_inhide("evaluator_inhide", st))
- local action = action_hideout("action_hideout", st)
- action:add_precondition(world_property(stalker_ids.property_alive, true))
- action:add_precondition(world_property(property_wounded, false))
- action:add_precondition(world_property(stalker_ids.property_enemy, false))
- action:add_precondition(world_property(stalker_ids.property_danger, false))
- action:add_precondition(world_property(property_hideout_lost, false))
- action:add_precondition(world_property(property_inhide, false))
- action:add_precondition(world_property(property_blowout, true))
- action:add_effect(world_property(property_blowout, false))
- manager:add_action(act_hideout, action)
- local action = action_raskolbas("action_raskolbas", st)
- action:add_precondition(world_property(stalker_ids.property_alive, true))
- action:add_precondition(world_property(property_wounded, false))
- action:add_precondition(world_property(property_blowout, false))
- action:add_precondition(world_property(property_inhide, false))
- action:add_precondition(world_property(property_hideout_lost, true))
- action:add_effect(world_property(property_hideout_lost, false))
- manager:add_action(act_psy_effect, action)
- local action = action_inhide("action_inhide", st)
- action:add_precondition(world_property(stalker_ids.property_alive, true))
- action:add_precondition(world_property(property_wounded, false))
- action:add_precondition(world_property(stalker_ids.property_enemy, false))
- action:add_precondition(world_property(stalker_ids.property_danger, false))
- action:add_precondition(world_property(property_blowout, false))
- action:add_precondition(world_property(property_hideout_lost, false))
- action:add_precondition(world_property(property_inhide, true))
- action:add_effect(world_property(property_inhide, false))
- manager:add_action(act_inhide, action)
- action = manager:action(stalker_ids.action_alife_planner)
- action:add_precondition(world_property(property_blowout, false))
- action:add_precondition(world_property(property_hideout_lost, false))
- action:add_precondition(world_property(property_inhide, false))
- action = manager:action(stalker_ids.action_combat_planner)
- action:add_precondition(world_property(property_hideout_lost, false))
- action = manager:action(stalker_ids.action_danger_planner)
- action:add_precondition(world_property(property_hideout_lost, false))
- end
- -- Функции включения/выключения схемы
- function enable_scheme(npc, ini)
- local st = xr_logic.assign_storage_and_bind(npc, ini, "ogsm_hideout")
- st.enabled=true
- end
- function disable_scheme(npc, scheme)
- local st = db.storage[npc:id()][scheme]
- if st then
- st.enabled = false
- end
- end
- ---------------- Схема поведения НПС при выбросе для OGSM 2.x -----------------
- ------------------------- Copyright 2007-2008 DEXXX ---------------------------
- --[[
- If you're going to use the whole of this script or its parts in your own creative
- developments for the S.T.A.L.K.E.R. game, please don't become such a goddamn
- motherfucker like the notorious author of the ABC Mod - Carbrobro. Leave the
- copyrights, note the real author(s) and don't claim others' ideas and their
- realization to be your own ones. It's just simple Modmakers' Ethics. Thank you!
- Если вы собираетесь использовать данный скрипт целиком или частично в своих
- разработках по игре S.T.A.L.K.E.R., пожалуйста не опускайтесь до уровня печально
- известного автора ABC мода - Carbrobro. Не удаляйте копирайты, указывайте настоящего
- автора(ов) и не выдавайте чужие идеи и их реализацию за свои. Ведь это элементарная
- этика модостроителей! Спасибо за понимание.
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment