diff --git a/gamedata/configs/mod_script_ixray.ltx b/gamedata/configs/mod_script_ixray.ltx new file mode 100644 index 000000000..d4fa27859 --- /dev/null +++ b/gamedata/configs/mod_script_ixray.ltx @@ -0,0 +1,3 @@ +![common] + >script = ixray_global + >class_registrators = ixray_global.register diff --git a/gamedata/scripts/_g.script b/gamedata/scripts/_g.script index 7c5502054..5fa016327 100644 --- a/gamedata/scripts/_g.script +++ b/gamedata/scripts/_g.script @@ -1,15 +1,7 @@ ---// JIT init if (jit == nil) then profiler.setup_hook () end -math.randomseed(time_global()) - -isMarshal = marshal ~= nil -isLfs = lfs ~= nil - ---// Some X-Ray block -DebugLog = false function empty (container) if (type(container) == "function") then @@ -32,15 +24,6 @@ end schemes = {} -- соответствие схем модулям stypes = {} -- типы схем -function log(str) - if DebugLog then - SemiLog(str) - end - if DebuggerMode then - LuaPanda.printToVSCode(str,1,2) - end -end - -- Загружает схему из файла на диске и активирует в мотиваторе. -- Здесь: -- filename - имя файла, в котором реализована схема, без расширения @@ -425,10 +408,23 @@ local stalker_classes = {} local weapon_classes = {} local artefact_classes = {} -IsMonster = function(object, class_id) return monster_classes [class_id or get_clsid(object) or -1] ~= nil end -IsStalker = function(object, class_id) return stalker_classes [class_id or get_clsid(object) or -1] ~= nil end -isWeapon = function(object, class_id) return weapon_classes [class_id or get_clsid(object) or -1] ~= nil end -isArtefact = function(object, class_id) return artefact_classes[class_id or get_clsid(object) or -1] ~= nil end +-- IX-Ray Refactor (Optional) +IsMonster = function(object, class_id) + return monster_classes[class_id or get_clsid(object) or -1] ~= nil +end + +IsStalker = function(object, class_id) + return stalker_classes[class_id or get_clsid(object) or -1] ~= nil +end + +isWeapon = function(object, class_id) + return weapon_classes[class_id or get_clsid(object) or -1] ~= nil +end + +isArtefact = function(object, class_id) + return artefact_classes[class_id or get_clsid(object) or -1] ~= nil +end +-- END IX-Ray ------------------------------------------------------------------------------------------- function get_object_community(obj) if type(obj.id) == "function" then @@ -487,6 +483,16 @@ function set_inactivate_input_time(delta) level.disable_input() end +-- Принимает: позицию положения, позицию куда смотреть, время сна в минутах. +--[[ +function set_sleep_relocate(point, look, timeout) + db.storage[db.actor:id()].sleep_relocate_time = game.get_game_time() + db.storage[db.actor:id()].sleep_relocate_idle = timeout*60 + db.storage[db.actor:id()].sleep_relocate_point = point + db.storage[db.actor:id()].sleep_relocate_look = look +end +]]-- + -- проверяет целую часть числа на нечетность function odd( x ) return math.floor( x * 0.5 ) * 2 == math.floor( x ) @@ -601,6 +607,9 @@ function start_game_callback() sim_board.clear() sr_light.clean_up () pda.add_quick_slot_items_on_game_start() + -- Tестирование оптимизации + --local test_object = test_object.test_object_class() + --test_object:test() end --' Усталость @@ -697,14 +706,22 @@ function get_param_string(src_string , obj) end end +-- IX-Ray Hack: For backwards compatibility (Optional, for set_save_marker) +if not IsEditor then + IsEditor = function () + return false + end +end + local save_markers = {} -- Функции для проверки корректности сейв лоад function set_save_marker(p, mode, check, prefix) - if (not IsEditor()) then + -- IX-Ray + if save and not IsEditor() then save.set_stage(prefix) end - + -- END IX-Ray -- определяем ключ маркера. local result = "" -- if debug ~= nil then @@ -730,11 +747,13 @@ function set_save_marker(p, mode, check, prefix) printf("WARNING! may be this is problem save point") end if dif >= 10240 then + -- IX-Ray callstack() - - if (not IsEditor()) then + + if save and not IsEditor() then save.call_error() end + -- END IX-Ray end p:w_u16(dif) else @@ -861,4 +880,4 @@ function show_all_ui(show) -- db.actor:hide_weapon() db.actor:disable_hit_marks(true) end -end \ No newline at end of file +end diff --git a/gamedata/scripts/bind_anomaly_zone.script b/gamedata/scripts/bind_anomaly_zone.script index d2f0203f5..56e7f6b02 100644 --- a/gamedata/scripts/bind_anomaly_zone.script +++ b/gamedata/scripts/bind_anomaly_zone.script @@ -1,5 +1,5 @@ --'****************************************************** ---'* ?????? ??????? ???? ???????? . +--'* . --'****************************************************** artefact_ways_by_id = {} artefact_points_by_id = {} @@ -7,6 +7,7 @@ parent_zones_by_artefact_id = {} ANOMAL_ZONE_SECT = "anomal_zone" function bind(obj) + -- IX-Ray: Added security check for multiplayer compatibility if IsGameTypeSingle() or OnServer() then obj:bind_object(anomaly_zone_binder(obj)) end @@ -189,11 +190,13 @@ end function anomaly_zone_binder:respawn_artefacts_and_replace_anomaly_zone() local anom_fields = bind_anomaly_field.fields_by_names self.respawn_artefacts = true - + + -- START IX-Ray: Added security check for multiplayer compatibility if not IsGameTypeSingle() then return end - + -- END IX-Ray + if(self.custom_placement) then local layer = self.cur_layer for k,v in pairs(self.fields_table[layer]) do @@ -277,8 +280,9 @@ function anomaly_zone_binder:spawn_artefact_randomly() parent_zones_by_artefact_id[artefact_obj.id] = self self.spawned_count = self.spawned_count + 1 + -- START IX-Ray pda.change_anomalies_names() - + -- END IX-Ray end function anomaly_zone_binder:get_artefact_path() @@ -476,4 +480,4 @@ function anomaly_zone_binder:load(thread) end self.turned_off = thread:r_bool() set_save_marker(thread, "load", true, "anomaly_zone_binder") -end \ No newline at end of file +end diff --git a/gamedata/scripts/bind_stalker.script b/gamedata/scripts/bind_stalker.script index 3f44f5730..8f2d51e7a 100644 --- a/gamedata/scripts/bind_stalker.script +++ b/gamedata/scripts/bind_stalker.script @@ -56,6 +56,7 @@ function actor_binder:net_spawn(data) self.task_manager = task_manager.get_task_manager() self.spawn_frame = device().frame self.already_jumped = false + -- self.loaded = false benchmark.main() --' Distemper 06.2008 -- return true end @@ -352,6 +353,11 @@ function actor_binder:update(delta) -- Апдейт доступности для симуляции. simulation_objects.get_sim_obj_registry():update_avaliability(alife():actor()) + -- Not used + --if not self.loaded then + -- get_console():execute("dump_infos") + -- self.loaded = true + --end treasure_manager.get_treasure_manager():update() if not(primary_objects_filled) then @@ -360,7 +366,7 @@ function actor_binder:update(delta) end pda.fill_sleep_zones() - SendScriptCallback("update") + SendScriptCallback("update") -- IX-Ray end ---------------------------------------------------------------------------------------------------------------------- function actor_binder:save(packet) @@ -429,7 +435,7 @@ function actor_binder:save(packet) end set_save_marker(packet, "save", true, "actor_binder") - SendScriptCallback("save", packet) + SendScriptCallback("save", packet) -- IX-Ray end ---------------------------------------------------------------------------------------------------------------------- function actor_binder:load(reader) @@ -487,7 +493,7 @@ function actor_binder:load(reader) end set_save_marker(reader, "load", true, "actor_binder") - SendScriptCallback("load", reader) + SendScriptCallback("load", reader) -- IX-Ray end --************************************************************* diff --git a/gamedata/scripts/class_registrator.script b/gamedata/scripts/class_registrator.script index 87bfc03d5..82f5fca79 100644 --- a/gamedata/scripts/class_registrator.script +++ b/gamedata/scripts/class_registrator.script @@ -32,7 +32,6 @@ function register(object_factory) -- ARTEFACTS -------------------------------------------------------------------------------------------------------------------------- cs_register (object_factory, "CElectricBall", "se_artefact.se_artefact", "SCRPTART", "artefact_s") - cs_register (object_factory, "CCar", "se_car.se_car", "SCRPTCAR", "car_s") -- MONSTERS --------------------------------------------------------------------------------------------------------------------------- @@ -135,4 +134,4 @@ function register(object_factory) -- ONLINE_OFFLINE_GROUP -------------------------------------------------------------------------------------------------------------- s_register (object_factory, "sim_squad_scripted.sim_squad_scripted", "ON_OFF_S", "online_offline_group_s") -end +end \ No newline at end of file diff --git a/gamedata/scripts/gulag_general.script b/gamedata/scripts/gulag_general.script index d1c75c5e5..2dc635ed8 100644 --- a/gamedata/scripts/gulag_general.script +++ b/gamedata/scripts/gulag_general.script @@ -885,7 +885,7 @@ local job_type_by_scheme = { function add_exclusive_job(sect, work_field, smart_ini, job_table) local work = utils.cfg_get_string(smart_ini, sect, work_field, nil, false, "") if work == nil then return end - local ini_path = "scripts\\"..work + local ini_path = "\scripts\\"..work local fs = getFS() if fs:exist("$game_config$",ini_path) == nil then diff --git a/gamedata/scripts/ixray_global.script b/gamedata/scripts/ixray_global.script new file mode 100644 index 000000000..6507899ad --- /dev/null +++ b/gamedata/scripts/ixray_global.script @@ -0,0 +1,25 @@ +math.randomseed(time_global()) + +_G.isMarshal = marshal ~= nil +_G.isLfs = lfs ~= nil + +_G.bit_and = bit.band +_G.bit_or = bit.bor +_G.bit_xor = bit.bxor +_G.bit_not = bit.bnot + +--// Some X-Ray block +_G.DebugLog = false + +_G.log = function (str) + if DebugLog then + SemiLog(str) + end + if DebuggerMode then + LuaPanda.printToVSCode(str,1,2) + end +end + +function register(object_factory) + class_registrator.cs_register(object_factory, "CCar", "se_car.se_car", "SCRPTCAR", "car_s") +end diff --git a/gamedata/scripts/level_weathers.script b/gamedata/scripts/level_weathers.script index 2b7258c7e..05ea5890f 100644 --- a/gamedata/scripts/level_weathers.script +++ b/gamedata/scripts/level_weathers.script @@ -17,10 +17,10 @@ function WeatherManager:__init() end end --- load(). . +-- Вызывается после load(). Состояние погоды уже загружено. function WeatherManager:reset() printf("WeatherManager:WeatherManager():Reset()") - -- . + -- Загрузить кондлист с погодой. local ini = ini_file("game.ltx") local weather = utils.cfg_get_string(ini, level.name(), "weathers", db.actor, false, "", "[default]") local postprocess = utils.cfg_get_string(ini, level.name(), "postprocess", db.actor, false, "") @@ -32,7 +32,7 @@ function WeatherManager:reset() level.remove_pp_effector(999) end if weather == "[default]" then - -- + -- сетим дефолтовую погоду self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", "[default]") else self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", weather) @@ -43,7 +43,7 @@ end function WeatherManager:forced_weather_change() self.forced_weather_change_on_time_change = true end --- . +-- Обновляем погоду раз в час. function WeatherManager:update() if(level.is_wfx_playing()) then self.weather_fx = level.get_weather() @@ -57,7 +57,7 @@ function WeatherManager:update() st.current_state=st.next_state st.next_state=get_next_state(st.graph,st.current_state) end - -- + -- Устанавливаем погоду на текущем уровне self:select_weather(false) end end @@ -67,20 +67,20 @@ function WeatherManager:select_weather(now) local weather = xr_logic.pick_section_from_condlist(db.actor, db.actor, self.weather_list) local graph=self:get_graph_by_name(weather) local weather_section_name="" - -- , ... + -- Проверим, совпадает ли текущий граф уровня с полученным по кондлисту... if graph==nil then - -- + -- Переходим на статику self.state[weather]=nil weather_section_name=weather else - -- - . , / + -- Новая погода - динамическая. Проверим, нужно ли менять/устанавливать граф if self.state[weather]==nil or self.state[weather].graph_name~=weather then - -- . . + -- Граф изменился. Переходим на него. self.state[weather]=self:init_by_graph(graph,weather) -- else -- now = false end - -- . + -- Получаем название секции по текущему состоянию. local st=self.state[weather] --weather_section_name="dw_"..st.current_state.."_"..st.next_state.."_"..level.get_time_hours() weather_section_name="default_"..st.current_state @@ -103,14 +103,14 @@ function WeatherManager:select_weather(now) -- end end --- . +-- Возвращает начальное состояние погоды. function WeatherManager:init_by_graph(graph,graph_name) local cur_state=get_next_state(graph,"") local next_state=get_next_state(graph,cur_state) return {current_state=cur_state,next_state=next_state,graph_name=graph_name,graph=graph} end --- , . +-- Возвращает одно из следующих состояний графа, согласно прописанным вероятностям. function get_next_state(graph,state) local sum=0 for st,prob in pairs(graph) do @@ -130,7 +130,7 @@ function get_next_state(graph,state) return next_state end --- , +-- Устанавливаем состояние менеджера, распарсивая строку состояния function WeatherManager:set_state_as_string(ss) self.state={} for lvlstring in string.gmatch(ss,"[^;]+") do @@ -144,14 +144,14 @@ function WeatherManager:set_state_as_string(ss) local graph_name=self:unpack_graph_name(grname) local graph=self:get_graph_by_name(graph_name) if graph==nil then - -- ? - + -- Старая сохранёнка? Будем считать что на этом уровне - статическая погода else self.state[graph_name]={current_state=current_state,next_state=next_state,graph_name=graph_name,graph=graph} end end end --- +-- Преобразуем текущее состояние менеджера в строку function WeatherManager:get_state_as_string() local lvlstrings={} for lvl_name,st in pairs(self.state) do @@ -164,7 +164,7 @@ function WeatherManager:get_state_as_string() return table.concat(lvlstrings,";") end --- ( ) +-- Получить граф (таблицу переходов состояний погоды) по его названию и названию игрового уровня function WeatherManager:get_graph_by_name(name) if not self.graphs[name] then self.graphs[name] = xr_s.parse_ini_section_to_array(self.graphs_ini,name) @@ -172,27 +172,27 @@ function WeatherManager:get_graph_by_name(name) return self.graphs[name] end --- +-- Запаковать название вершины графа function WeatherManager:pack_state(state) - -- . + -- Пока паковать не будем. return state end --- +-- Распаковать название вершины графа function WeatherManager:unpack_state(st) - -- + -- Пока паковать не будем return st end --- +-- Запаковать название графа переходов погоды function WeatherManager:pack_graph_name(graph_name) - -- . + -- Пока паковать не будем. return graph_name end --- +-- Распаковать название графа переходов погоды function WeatherManager:unpack_graph_name(grn) - -- + -- Пока паковать не будем return grn end diff --git a/gamedata/scripts/lua_help.script b/gamedata/scripts/lua_help.script index ced200713..28d0b11da 100644 --- a/gamedata/scripts/lua_help.script +++ b/gamedata/scripts/lua_help.script @@ -1014,7 +1014,7 @@ C++ class DIK_keys { const DIK_R = 19; const DIK_RBRACKET = 27; const DIK_RCONTROL = 157; - const DIK_RETURN = 40; + const DIK_RETURN = 28; const DIK_RIGHT = 205; const DIK_RMENU = 184; const DIK_RSHIFT = 54; diff --git a/gamedata/scripts/se_smart_cover.script b/gamedata/scripts/se_smart_cover.script index 972d02aec..654dcc541 100644 --- a/gamedata/scripts/se_smart_cover.script +++ b/gamedata/scripts/se_smart_cover.script @@ -63,7 +63,9 @@ function se_smart_cover:STATE_Read (packet, size) end else local smart_cover_description = self:description() - if smart_cover_description ~= nil and smart_covers.descriptions[smart_cover_description] ~= nil then + if smart_cover_description ~= nil and + smart_covers.descriptions[smart_cover_description] ~= nil -- IX-Ray: Fixed scripts working in editors + then local loopholes = smart_covers.descriptions[smart_cover_description].loopholes for k,v in pairs (loopholes) do self.loopholes[v.id] = true diff --git a/gamedata/scripts/sim_squad_scripted.script b/gamedata/scripts/sim_squad_scripted.script index b6376ab89..3ecdd94e3 100644 --- a/gamedata/scripts/sim_squad_scripted.script +++ b/gamedata/scripts/sim_squad_scripted.script @@ -846,7 +846,7 @@ function sim_squad_scripted:show() return end local spot = "" - if dev_debug then + if dev_debug then -- IX-Ray: Fixed PDA squad rendering in Lua devmode if not(is_squad_monster[self.player_id]) then local relation = game_relations.get_squad_goodwill_to_actor_by_id(self.id) if(relation=="friends") then diff --git a/gamedata/scripts/sr_no_weapon.script b/gamedata/scripts/sr_no_weapon.script index 080e8347f..0266efe91 100644 --- a/gamedata/scripts/sr_no_weapon.script +++ b/gamedata/scripts/sr_no_weapon.script @@ -44,9 +44,11 @@ function action_no_weapon:update( delta ) self:switch_state( actor ) + -- IX-Ray: Added security check for multiplayer compatibility if (IsDedicated()) then return end + -- END IX-Ray local hud = get_hud() local custom_static = hud:GetCustomStatic("can_use_weapon_now") @@ -84,10 +86,12 @@ function action_no_weapon:zone_enter() self.state = state_inside bind_stalker.hide_weapon(self.object:id()) + -- IX-Ray: Added security check for multiplayer compatibility if (IsDedicated()) then return end - + -- END IX-Ray + local hud = get_hud() local custom_static = hud:GetCustomStatic("can_use_weapon_now") if custom_static ~= nil then diff --git a/gamedata/scripts/ui_load_dialog.script b/gamedata/scripts/ui_load_dialog.script index 8d40fde2f..9600cc169 100644 --- a/gamedata/scripts/ui_load_dialog.script +++ b/gamedata/scripts/ui_load_dialog.script @@ -29,7 +29,7 @@ end function load_dialog:FillList() self.list_box:RemoveAll() local f = getFS() - local flist = f:file_list_open_ex("$game_saves$",bit.bor(FS.FS_ListFiles,FS.FS_RootOnly),"*"..saved_game_extension) + local flist = f:file_list_open_ex("$game_saves$",bit_or(FS.FS_ListFiles,FS.FS_RootOnly),"*"..saved_game_extension) local f_cnt = flist:Size() flist:Sort(FS.FS_sort_by_modif_down) @@ -109,7 +109,7 @@ end function file_exist(fname) local f = getFS(); - local flist = f:file_list_open_ex("$game_saves$",bit.bor(FS.FS_ListFiles,FS.FS_RootOnly) , fname) + local flist = f:file_list_open_ex("$game_saves$",bit_or(FS.FS_ListFiles,FS.FS_RootOnly) , fname) local f_cnt = flist:Size() if f_cnt > 0 then @@ -127,9 +127,12 @@ function delete_save_game(filename) local f = getFS() f:file_delete("$game_saves$", save_file) + + -- START IX-Ray if save_manager then save_manager.deleteObsoleteData(filename) end + -- END IX-Ray if file_exist(dds_file) then f:file_delete("$game_saves$", dds_file) @@ -150,7 +153,7 @@ end function file_data(fname) local f = getFS(); - local flist = f:file_list_open_ex("$game_saves$",bit.bor(FS.FS_ListFiles,FS.FS_RootOnly) , fname .. saved_game_extension) + local flist = f:file_list_open_ex("$game_saves$",bit_or(FS.FS_ListFiles,FS.FS_RootOnly) , fname .. saved_game_extension) local f_cnt = flist:Size() if f_cnt > 0 then @@ -326,7 +329,7 @@ function load_dialog:OnKeyboard(dik, keyboard_action) --virtual function self:OnButton_back_clicked() else - DIK_RETURN = 40 + DIK_RETURN = 40 -- IX-Ray: Fixed DIK_RETURN if dik == DIK_RETURN and keyboard_action == ui_events.WINDOW_KEY_PRESSED then self:OnButton_load_clicked() diff --git a/gamedata/scripts/ui_main_menu.script b/gamedata/scripts/ui_main_menu.script index c9e567cdf..160b54846 100644 --- a/gamedata/scripts/ui_main_menu.script +++ b/gamedata/scripts/ui_main_menu.script @@ -66,7 +66,7 @@ function main_menu:InitCallBacks() self:AddCallback("btn_save", ui_events.BUTTON_CLICKED, self.OnButton_save_clicked, self) -- multiplayer - if (IsSupportMP()) then + if (IsSupportMP()) then -- IX-Ray: Optional multiplayer check self:AddCallback("btn_net_game", ui_events.BUTTON_CLICKED, self.OnButton_network_game_clicked, self) self:AddCallback("btn_internet", ui_events.BUTTON_CLICKED, self.OnButton_internet_clicked, self) self:AddCallback("btn_localnet", ui_events.BUTTON_CLICKED, self.OnButton_localnet_clicked, self) diff --git a/gamedata/scripts/ui_mm_mp_demo.script b/gamedata/scripts/ui_mm_mp_demo.script index 89dd42bc8..fd758b578 100644 --- a/gamedata/scripts/ui_mm_mp_demo.script +++ b/gamedata/scripts/ui_mm_mp_demo.script @@ -141,7 +141,7 @@ end function mp_demo:FillList() self.demo_list:RemoveAll() local f = getFS() - local flist = f:file_list_open_ex("$logs$",bit.bor(FS.FS_ListFiles,FS.FS_RootOnly),"*.demo") + local flist = f:file_list_open_ex("$logs$",bit_or(FS.FS_ListFiles,FS.FS_RootOnly),"*.demo") local f_cnt = flist:Size() flist:Sort(FS.FS_sort_by_modif_down) diff --git a/gamedata/scripts/ui_save_dialog.script b/gamedata/scripts/ui_save_dialog.script index 6480d00b4..893481393 100644 --- a/gamedata/scripts/ui_save_dialog.script +++ b/gamedata/scripts/ui_save_dialog.script @@ -206,7 +206,7 @@ function save_dialog:OnKeyboard(dik, keyboard_action) --virtual function self:OnButton_cancel_clicked() else - DIK_RETURN = 40 + DIK_RETURN = 40 -- IX-Ray: Fixed DIK_RETURN if dik == DIK_RETURN and keyboard_action == ui_events.WINDOW_KEY_PRESSED then self:OnButton_ok_clicked() diff --git a/gamedata/scripts/ui_scenes.script b/gamedata/scripts/ui_scenes.script index 0dad27621..a6e3ac205 100644 --- a/gamedata/scripts/ui_scenes.script +++ b/gamedata/scripts/ui_scenes.script @@ -156,7 +156,7 @@ function scenes_item_dialog:OnKeyboard(dik, keyboard_action) if bind == key_bindings.kQUIT then self:OnButton_close_clicked() else - if dik==40 then + if dik==28 then self:OnButton_create_clicked() end end diff --git a/gamedata/scripts/ui_si.script b/gamedata/scripts/ui_si.script index f52b15788..5d3fda7bc 100644 --- a/gamedata/scripts/ui_si.script +++ b/gamedata/scripts/ui_si.script @@ -386,7 +386,7 @@ function spawn_item_dialog:OnKeyboard(dik, keyboard_action) if bind == key_bindings.kQUIT then self:OnButton_close_clicked() else - if dik==40 then + if dik==28 then self:OnButton_create_clicked() end end diff --git a/gamedata/scripts/xr_hear.script b/gamedata/scripts/xr_hear.script index 8cb118b4c..853c72ff8 100644 --- a/gamedata/scripts/xr_hear.script +++ b/gamedata/scripts/xr_hear.script @@ -1,42 +1,42 @@ local function get_sound_type(sound_type) local s_type = "NIL" - if bit.band(sound_type, snd_type.weapon) == snd_type.weapon then + if bit_and(sound_type, snd_type.weapon) == snd_type.weapon then s_type = "WPN" - if bit.band(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then + if bit_and(sound_type, snd_type.weapon_shoot) == snd_type.weapon_shoot then s_type = "WPN_shoot" - elseif bit.band(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then + elseif bit_and(sound_type, snd_type.weapon_empty) == snd_type.weapon_empty then s_type = "WPN_empty" - elseif bit.band(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then + elseif bit_and(sound_type, snd_type.weapon_bullet_hit) == snd_type.weapon_bullet_hit then s_type = "WPN_hit" - elseif bit.band(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then + elseif bit_and(sound_type, snd_type.weapon_reload) == snd_type.weapon_reload then s_type = "WPN_reload" end - elseif bit.band(sound_type, snd_type.item) == snd_type.item then + elseif bit_and(sound_type, snd_type.item) == snd_type.item then s_type = "ITM" - if bit.band(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then + if bit_and(sound_type, snd_type.item_pick_up) == snd_type.item_pick_up then s_type = "ITM_pckup" - elseif bit.band(sound_type, snd_type.item_drop) == snd_type.item_drop then + elseif bit_and(sound_type, snd_type.item_drop) == snd_type.item_drop then s_type = "ITM_drop" - elseif bit.band(sound_type, snd_type.item_hide) == snd_type.item_hide then + elseif bit_and(sound_type, snd_type.item_hide) == snd_type.item_hide then s_type = "ITM_hide" - elseif bit.band(sound_type, snd_type.item_take) == snd_type.item_take then + elseif bit_and(sound_type, snd_type.item_take) == snd_type.item_take then s_type = "ITM_take" - elseif bit.band(sound_type, snd_type.item_use) == snd_type.item_use then + elseif bit_and(sound_type, snd_type.item_use) == snd_type.item_use then s_type = "ITM_use" end - elseif bit.band(sound_type, snd_type.monster) == snd_type.monster then + elseif bit_and(sound_type, snd_type.monster) == snd_type.monster then s_type = "MST" - if bit.band(sound_type, snd_type.monster_die) == snd_type.monster_die then + if bit_and(sound_type, snd_type.monster_die) == snd_type.monster_die then s_type = "MST_die" - elseif bit.band(sound_type, snd_type.monster_injure) == snd_type.monster_injure then + elseif bit_and(sound_type, snd_type.monster_injure) == snd_type.monster_injure then s_type = "MST_damage" - elseif bit.band(sound_type, snd_type.monster_step) == snd_type.monster_step then + elseif bit_and(sound_type, snd_type.monster_step) == snd_type.monster_step then s_type = "MST_step" - elseif bit.band(sound_type, snd_type.monster_talk) == snd_type.monster_talk then + elseif bit_and(sound_type, snd_type.monster_talk) == snd_type.monster_talk then s_type = "MST_talk" - elseif bit.band(sound_type, snd_type.monster_attack) == snd_type.monster_attack then + elseif bit_and(sound_type, snd_type.monster_attack) == snd_type.monster_attack then s_type = "MST_attack" - elseif bit.band(sound_type, snd_type.monster_eat) == snd_type.monster_eat then + elseif bit_and(sound_type, snd_type.monster_eat) == snd_type.monster_eat then s_type = "MST_eat" end end diff --git a/gamedata/scripts/xr_wounded.script b/gamedata/scripts/xr_wounded.script index 3bec627f9..be9d47d81 100644 --- a/gamedata/scripts/xr_wounded.script +++ b/gamedata/scripts/xr_wounded.script @@ -1,5 +1,5 @@ --- --- : (Stohe) +-- Схема раненного +-- автор: Диденко Руслан (Stohe) -- TODO: ---------------------------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ function action_wounded:execute () end end - -- . + -- Проверяем возможность скушать аптечку. if self.a.autoheal == true then if wound_manager.can_use_medkit ~= true then local begin_wounded = xr_logic.pstor_retrieve(self.object, "begin_wounded") @@ -108,8 +108,8 @@ function action_wounded:execute () h.type = hit.wound self.object:hit(h) else - --' . - --' . + --' жрание аптечек и прочей срани. + --' Использовать можно только если нам можно сейчас есть аптечку. if self.a.use_medkit == true then wound_manager:eat_medkit() end @@ -122,7 +122,7 @@ function action_wounded:execute () state_mgr.set_state(self.object, wound_manager_state, nil, nil, {look_object = victim}, nil) end - -- + -- нужно отыграть фоновый if wound_manager_sound == "nil" then xr_sound.set_sound_play(self.object:id(), nil) else @@ -148,7 +148,7 @@ function Cwound_manager:__init(npc, storage) self.can_use_medkit = false end function Cwound_manager:update() - --' + --' Автовылечивание раненых после боя -- if self.npc:best_enemy() == nil then -- self.npc.health = 1 -- end @@ -163,12 +163,12 @@ function Cwound_manager:update() if self.state == "nil" and self.sound == "nil" then - -- + -- проверяем на обычную раненость self.state, self.sound = self:process_hp_wound(hp) self.fight = self:process_fight(hp) self.victim = self:process_victim(hp) else - -- + -- устанавливаем пси раненость self.fight = "false" self.cover = "false" self.victim = "nil" @@ -342,13 +342,13 @@ end ------------ --- , , --- . +-- Вызывается только в начале на чтении логики, создает экшены, эвалуаторы и производит +-- первичную настройку. function set_wounded(npc, ini, scheme, section) local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section) st.wound_manager = Cwound_manager(npc, st) end --- . . +-- Вызывается на переключении на новую секцию. Производит вычитывание настроек из текущей секции. function reset_wounded(npc, scheme, st, section) local wounded_section if scheme == nil or scheme == "nil" then @@ -359,7 +359,7 @@ function reset_wounded(npc, scheme, st, section) init_wounded(npc, st.ini, wounded_section, st.wounded, scheme) st.wounded.wound_manager:hit_callback() end --- . , . +-- Функция чтения настроек. В нее передается секция, откуда их нужно читать. local wounded_by_state = { [0] = "wounded_heavy", [1] = "wounded_heavy_2", @@ -425,7 +425,7 @@ function init_wounded(npc, ini, section, st, scheme) if tostring(section) == "nil" then - -- ! + -- Загружаем дефолты! st.hp_state = utils.parse_data(npc, def.hp_state) st.hp_state_see = utils.parse_data(npc, def.hp_state_see) st.psy_state = utils.parse_data(npc, def.psy_state) @@ -455,7 +455,7 @@ function init_wounded(npc, ini, section, st, scheme) st.not_for_help = utils.cfg_get_bool(ini, section, "not_for_help", npc, false, def.not_for_help) end - -- , + -- флажок, что функция хотя бы раз вызывалась st.wounded_set = true end @@ -490,7 +490,7 @@ function is_wounded(npc) return false end -function hit_callback(npc_id) -- . +function hit_callback(npc_id) -- Тут может не быть стораджа. if db.storage[npc_id].wounded ~= nil then db.storage[npc_id].wounded.wound_manager:hit_callback() end