function arszi_get_env_rads() -- printf("override get_env_rads") return arszi_radiation.environmental_radiation end function actor_on_first_update() -- Special tactics - override "level" engine namespace for item_device -- put custom get_env_rads function there -- in case of looking for another function, it will be referred back to engine namespace via metatables local item_device_level = item_device.level local overrideLevel = setmetatable({ get_env_rads = arszi_get_env_rads }, { __index = item_device_level }) item_device.level = overrideLevel local ui_dosimeter_level = ui_dosimeter.level local overrideLevel = setmetatable({ get_env_rads = arszi_get_env_rads }, { __index = ui_dosimeter_level }) ui_dosimeter.level = overrideLevel end rad_zones = { ["zone_field_radioactive"] = true, ["zone_field_radioactive_very_weak"] = true, ["zone_field_radioactive_weak"] = true, ["zone_field_radioactive_below_average"] = true, ["zone_field_radioactive_average"] = true, ["zone_field_radioactive_above_average"] = true, ["zone_field_radioactive_strong"] = true, ["zone_field_radioactive_lethal"] = true, ["zone_radioactive"] = true, ["zone_radioactive_very_weak"] = true, ["zone_radioactive_weak"] = true, ["zone_radioactive_below_average"] = true, ["zone_radioactive_average"] = true, ["zone_radioactive_above_average"] = true, ["zone_radioactive_strong"] = true, ["zone_radioactive_lethal"] = true } function on_anomaly_touch(obj, flags) -- printf("overriding on_anomaly_touch") --Notice: Geiger sounds were moved into arszi_radiation.script if obj then -- Don't play gieger sound if player don't have a geiger counter if rad_zones[obj:section()] then if game_difficulties.get_game_factor("notify_geiger") then local obj_geiger = item_device.device_geiger and db.actor:object(item_device.device_geiger) if not (obj_geiger and item_device.drain_device_on_event(obj_geiger, item_device.device_geiger, 1)) then flags.ret_value = false return end end -- Anomaly detector elseif (not game_difficulties.get_game_factor("notify_anomaly")) then flags.ret_value = false return end end flags.ret_value = true end item_device_og_RSC = item_device.RegisterScriptCallback item_device.RegisterScriptCallback = function(k, f) if item_device_og_RSC ~= _G.RegisterScriptCallback then item_device_og_RSC(k, f) end if k == "actor_on_feeling_anomaly" then return end return _G.RegisterScriptCallback(k, f) end ui_sleep_dialog_test_and_show = ui_sleep_dialog.UISleep.TestAndShow ui_sleep_dialog.UISleep.TestAndShow = function(self, force) if (force ~= true) then -- Immersive Sleep Patch if actor_status_sleep.get_last_sleep then local last_sleep = actor_status_sleep.get_last_sleep() printdbg("#Immersive Sleep | last_sleep: %s",tostring(last_sleep)) if(last_sleep < 3000) then actor_menu.set_msg(1, game.translate_string("st_sleep_awake"),4) disable_info("sleep_active") return end end local bleeding = db.actor.bleeding > 0 local radiation = db.actor.radiation > 0 -- Prevent sleep if bleeding and/or iradiated. if arszi_radiation and (arszi_radiation.settings.sleepWithRads == 1 and db.actor.radiation <= arszi_radiation.settings.RADIATION_THRESHOLD or arszi_radiation.settings.sleepWithRads == 2) then if (bleeding) then actor_menu.set_msg(1, game.translate_string("st_sleep_bleeding"),4) disable_info("sleep_active") return end else if (bleeding or radiation) then if (bleeding and radiation) then actor_menu.set_msg(1, game.translate_string("st_sleep_bleeding_irradiated"),5) elseif (bleeding) then actor_menu.set_msg(1, game.translate_string("st_sleep_bleeding"),4) elseif (radiation) then actor_menu.set_msg(1, game.translate_string("st_sleep_irradiated"),4) end disable_info("sleep_active") return end end -- Check if actor is inside a safe zone local actor_hide = GetEvent("current_safe_cover") and true or false -- Check if actor is inside a tent if (not actor_hide) then actor_hide = item_tent.get_nearby_tent(1.5) end -- If all is no, dont sleep if (not actor_hide) then actor_menu.set_msg(1, game.translate_string("st_cant_sleep_find_shelter_mlr"),4) disable_info("sleep_active") return end end self:Initialize() self:ShowDialog(true) Register_UI("UISleep","ui_sleep_dialog") end agony_is_bleeding = gamemode_agony.is_bleeding gamemode_agony.is_bleeding = function(flags) -- Prevent saving if bleeding local bleeding = db.actor.bleeding > 0 if (bleeding) then flags.str = game.translate_string("st_ui_no_save_bleed") flags.ret = true return true end return false end function on_game_start() RegisterScriptCallback("actor_on_feeling_anomaly", on_anomaly_touch) RegisterScriptCallback("actor_on_first_update", actor_on_first_update) end