Skip to content

Commit

Permalink
Merge branch 'staging-sierra' into fix-map
Browse files Browse the repository at this point in the history
  • Loading branch information
ddorou authored Mar 28, 2024
2 parents 879f34e + 432e0b5 commit db08a74
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 56 deletions.
130 changes: 75 additions & 55 deletions code/game/machinery/alarm/alarm.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/singleton/environment_data
var/list/important_gasses = list(
GAS_OXYGEN = TRUE,
GAS_NITROGEN = TRUE,
GAS_OXYGEN = TRUE,
GAS_NITROGEN = TRUE,
GAS_CO2 = TRUE
)
var/list/dangerous_gasses = list(
Expand All @@ -15,11 +15,20 @@
GAS_PHORON
)

/singleton/environment_data/finnish/Initialize()
. = ..()
important_gasses[GAS_STEAM] = TRUE
dangerous_gasses -= GAS_STEAM

/singleton/environment_data/finnish
important_gasses = list(
GAS_OXYGEN = TRUE,
GAS_NITROGEN = TRUE,
GAS_CO2 = TRUE,
GAS_STEAM = TRUE
)
filter_gasses = list(
GAS_OXYGEN,
GAS_NITROGEN,
GAS_CO2,
GAS_N2O,
GAS_PHORON
)

////////////////////////////////////////
//CONTAINS: Air Alarms and Fire Alarms//
Expand Down Expand Up @@ -99,8 +108,10 @@

var/datum/radio_frequency/radio_connection

var/list/TLV = list()
var/list/trace_gas = list() //list of other gases that this air alarm is able to detect
/// Lazy list of danger groups by environment criteria like temperature, pressure, specific gas etc.
/// Has following structure: criteria => list(danger_group_1, danger_group_2, danger_group_3, danger_group_4)
var/list/TLV
var/list/trace_gas

var/danger_level = 0
var/pressure_dangerlevel = 0
Expand All @@ -111,12 +122,16 @@
var/environment_type = /singleton/environment_data
var/report_danger_level = 1

//Used to cache the previous gas mixture result, and evaluate if we can skip processing or not
var/previous_environment_group_multiplier = null
var/previous_environment_temperature = null
var/previous_environment_total_moles = null
var/previous_environment_volume = null
var/list/previous_environment_gas = list()
/// Cached previous environment group multiplier
var/previous_environment_group_multiplier
/// Cached previous environment temperature
var/previous_environment_temperature
/// Cached previous environment total moles
var/previous_environment_total_moles
/// Cached previous environment volume
var/previous_environment_volume
/// Lazy list of cached previus enrironment gases as: gas_id => amount of moles
var/list/previous_environment_gas

/obj/machinery/alarm/Destroy()
unregister_radio(src, frequency)
Expand All @@ -126,7 +141,7 @@
..(loc)

if(dir)
src.set_dir(dir)
set_dir(dir)

if(istype(frame))
buildstage = 0
Expand All @@ -143,12 +158,15 @@
if (name == "alarm")
SetName("[alarm_area.name] Air Alarm")

LAZYINITLIST(TLV)
LAZYINITLIST(trace_gas)

// breathable air according to human/Life()
TLV[GAS_OXYGEN] = list(16, 19, 135, 140) // Partial pressure, kpa
TLV[GAS_OXYGEN] = list(16, 19, 135, 140) // Partial pressure, kpa
TLV[GAS_CO2] = list(-1.0, -1.0, 5, 10) // Partial pressure, kpa
TLV["other"] = list(-1.0, -1.0, 0.2, 0.5) // Partial pressure, kpa
TLV["pressure"] = list(ONE_ATMOSPHERE*0.80,ONE_ATMOSPHERE*0.90,ONE_ATMOSPHERE*1.10,ONE_ATMOSPHERE*1.20) /* kpa */
TLV["temperature"] = list(T0C-26, T0C, T0C+40, T0C+66) // K
TLV["other"] = list(-1.0, -1.0, 0.2, 0.5) // Partial pressure, kpa
TLV["pressure"] = list(ONE_ATMOSPHERE * 0.80, ONE_ATMOSPHERE * 0.90, ONE_ATMOSPHERE * 1.10, ONE_ATMOSPHERE * 1.20) /* kpa */
TLV["temperature"] = list(T0C-26, T0C, T0C+40, T0C+66) // K


var/singleton/environment_data/env_info = GET_SINGLETON(environment_type)
Expand Down Expand Up @@ -177,30 +195,11 @@
if(environment.return_pressure() > ONE_ATMOSPHERE*0.05)
handle_heating_cooling(environment)

var/is_same_environment = TRUE
for(var/gas_id in environment.gas)
if(environment.gas[gas_id] != previous_environment_gas[gas_id])
is_same_environment = FALSE
previous_environment_gas = environment.gas.Copy()
break

if(is_same_environment)
if((environment.temperature != previous_environment_temperature) ||\
(environment.group_multiplier != previous_environment_group_multiplier) ||\
(environment.total_moles != previous_environment_total_moles) ||\
(environment.volume != previous_environment_volume)
)
is_same_environment = FALSE
previous_environment_group_multiplier = environment.group_multiplier
previous_environment_temperature = environment.temperature
previous_environment_total_moles = environment.total_moles
previous_environment_volume = environment.volume

if(is_same_environment)
if(is_same_environment(environment))
return

var/old_level = danger_level
danger_level = get_overall_danger_level(environment)
danger_level = get_max_danger_level(environment)

if (old_level != danger_level)
if(danger_level == 2)
Expand Down Expand Up @@ -252,6 +251,28 @@
else if(dev_type == "AVP")
alarm_area.air_vent_info[id_tag] = signal.data

/obj/machinery/alarm/proc/is_same_environment(datum/gas_mixture/environment)
if(length(previous_environment_gas) != length(environment.gas))
return FALSE

for(var/gas_id in environment.gas)
if(environment.gas[gas_id] != previous_environment_gas[gas_id])
previous_environment_gas = environment.gas.Copy()
return FALSE

if((environment.temperature != previous_environment_temperature) || \
(environment.group_multiplier != previous_environment_group_multiplier) || \
(environment.total_moles != previous_environment_total_moles) || \
(environment.volume != previous_environment_volume)
)
previous_environment_group_multiplier = environment.group_multiplier
previous_environment_temperature = environment.temperature
previous_environment_total_moles = environment.total_moles
previous_environment_volume = environment.volume
return FALSE

return TRUE

/obj/machinery/alarm/proc/handle_heating_cooling(datum/gas_mixture/environment)
var/danger_level = get_danger_level(target_temperature, TLV["temperature"])

Expand Down Expand Up @@ -300,38 +321,37 @@
environment.merge(gas)

/**
* Get the danger level of a zone
* Get the danger level of specific criteria based on `danger_levels`
*
* * RETURN_VALUE - The variable to store the return value
* * current_value - The current value to check the danger-ness against
* * danger_levels - A list with the danger levels
*/
/obj/machinery/alarm/proc/get_danger_level(current_value, list/danger_levels)
if((current_value > danger_levels[4] && danger_levels[4] > 0) || current_value < danger_levels[1])
return 2
else if((current_value > danger_levels[3] && danger_levels[3] > 0) || current_value < danger_levels[2])

if((current_value > danger_levels[3] && danger_levels[3] > 0) || current_value < danger_levels[2])
return 1
else
return 0

return 0

/**
* Get the overall danger level of the environment
* Get the maximum danger level across all environment criteria
*
* * RETURN_VALUE - The variable to store the return value
* * environment - A `/datum/gas_mixture` to perform the danger level calculation against
*/
/obj/machinery/alarm/proc/get_overall_danger_level(datum/gas_mixture/environment)
/obj/machinery/alarm/proc/get_max_danger_level(datum/gas_mixture/environment)
var/partial_pressure = R_IDEAL_GAS_EQUATION * environment.temperature / environment.volume
var/other_moles = 0
for(var/gas_id in trace_gas)
other_moles += environment.get_gas(gas_id)
other_moles += environment.gas[gas_id]

return max(
get_danger_level(environment.return_pressure(), TLV["pressure"]),
get_danger_level(environment.gas[GAS_OXYGEN] * partial_pressure, TLV[GAS_OXYGEN]),
get_danger_level(environment.gas[GAS_CO2] * partial_pressure, TLV[GAS_CO2]),
get_danger_level(environment.temperature, TLV["temperature"]),
get_danger_level(other_moles*partial_pressure, TLV["other"])
get_danger_level(other_moles * partial_pressure, TLV["other"])
)


Expand Down Expand Up @@ -934,11 +954,11 @@
report_danger_level = 0
breach_pressure = -1

/obj/machinery/alarm/server/New()
..()
/obj/machinery/alarm/server/Initialize()
. = ..()
req_access = list(access_rd, access_atmospherics, access_engine_equip)
TLV["temperature"] = list(T0C-26, T0C, T0C+30, T0C+40) // K
target_temperature = T0C+10
TLV["temperature"] = list(T0C-26, T0C, T0C+30, T0C+40)
target_temperature = T0C + 10

/*
AIR ALARM CIRCUIT
Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/preference_setup/general/01_basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

/datum/category_item/player_setup_item/physical/basic/OnTopic(href, list/href_list, mob/user)
if(href_list["rename"])
var/raw_name = tgui_input_text(user, "Choose your character's name", "Character Name", max_length = MAX_NAME_LEN)
var/raw_name = tgui_input_text(user, "Choose your character's name", "Character Name", max_length = MAX_NAME_LEN, encode = FALSE)
if(isnull(raw_name) && CanUseTopic(user))
return

Expand Down
7 changes: 7 additions & 0 deletions html/changelogs/.all_changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23272,3 +23272,10 @@ DO NOT EDIT THIS FILE BY HAND! AUTOMATICALLY GENERATED BY sierra_genchangelog.p
- wip: Partially ported escape pod system, allowing for hacking & premature launch.
- tweak: Ported an air alarm refactor, improving optimization.
- tweak: Xeno characters are now allowed to learn Legalise.
2024-03-27:
UEDHighCommand:
- bugfix: Introduced a hotfix for Air Alarm triggering conditions.
Lexanx:
- rscadd: Added a chance to fail surgery based on whether the patient is clothed or not.
dorou:
- bugfix: Fixed welding lenses augment.
7 changes: 7 additions & 0 deletions maps/sierra/items/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,10 @@ Passports

/material/wood
sheet_icon_base = "sheet-wood"

/obj/item/clothing/glasses/glare_dampeners
flash_protection = FLASH_PROTECTION_MAJOR
tint = TINT_HEAVY

/obj/item/organ/internal/augment/active/item/glare_dampeners
desc = "Thick, tinted lenses installed in your head can deploy over your eyes, reducing visibility but providing protection from welding glare and bright lights."
1 change: 1 addition & 0 deletions mods/global_modpacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "nyc_posters/_nyc_posters.dme"
#include "ssinput/_ssinput.dme"
#include "statusbar/_statusbar.dme"
#include "surgery/_surgery.dme"
#include "unathi/_unathi.dme"
#include "utf8/_utf8.dme"
#include "utility_items/_utility_items.dme"
Expand Down
74 changes: 74 additions & 0 deletions mods/surgery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

#### Список PRов:

- https://github.com/SierraBay/SierraBay12/pull/2051
<!--
Ссылки на PRы, связанные с модом:
- Создание
- Большие изменения
-->

<!-- Название мода. Не важно на русском или на английском. -->
## Мод-пример

ID мода: MODPACK_SURGERY
<!--
Название модпака прописными буквами, СОЕДИНЁННЫМИ_ПОДЧЁРКИВАНИЕМ,
которое ты будешь использовать для обозначения файлов.
-->

### Описание мода

Добавляет проверку на одежду при проведении операция
<!--
Что он делает, что добавляет: что, куда, зачем и почему - всё здесь.
А также любая полезная информация.
-->

### Изменения *кор кода*

- `code\modules\surgery\surgery.dm`: `/singleton/surgery_step/proc/success_chance`
<!--
Если вы редактировали какие-либо процедуры или переменные в кор коде,
они должны быть указаны здесь.
Нужно указать и файл, и процедуры/переменные.
Изменений нет - напиши "Отсутствуют"
-->

### Оверрайды

<!--
Если ты добавлял новый модульный оверрайд, его нужно указать здесь.
Здесь указываются оверрайды в твоём моде и папке `_master_files`
Изменений нет - напиши "Отсутствуют"
-->

### Дефайны

<!--
Если требовалось добавить какие-либо дефайны, укажи файлы,
в которые ты их добавил, а также перечисли имена.
И то же самое, если ты используешь дефайны, определённые другим модом.
Не используешь - напиши "Отсутствуют"
-->

### Используемые файлы, не содержащиеся в модпаке

<!--
Будь то немодульный файл или модульный файл, который не содержится в папке,
принадлежащей этому конкретному моду, он должен быть упомянут здесь.
Хорошими примерами являются иконки или звуки, которые используются одновременно
несколькими модулями, или что-либо подобное.
-->

### Авторы:

Lexanx
<!--
Здесь находится твой никнейм
Если работал совместно - никнеймы тех, кто помогал.
В случае порта чего-либо должна быть ссылка на источник.
-->
4 changes: 4 additions & 0 deletions mods/surgery/_surgery.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/singleton/modpack/syrgery
name = "Хирургия"
desc = "Сюда следует помещать все изменения связанные с хирургией в коде."
author = "Lexanx"
8 changes: 8 additions & 0 deletions mods/surgery/_surgery.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef MODPACK_SURGERY
#define MODPACK_SURGERY

#include "_surgery.dm"

#include "code/surgery.dm"

#endif
5 changes: 5 additions & 0 deletions mods/surgery/code/surgery.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/singleton/surgery_step/success_chance(mob/living/user, mob/living/carbon/human/target, obj/item/tool, target_zone)
.=..()
var/obj/item/I = target.get_covering_equipped_item_by_zone(target_zone)
if(I && (I.body_parts_covered))
. -= 30

0 comments on commit db08a74

Please sign in to comment.