mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 23:27:34 +01:00
[MIRROR] Refactors and optimizes breath code (Saves 12% of carbon/Life()) [MDB IGNORE] (#20080)
* Refactors and optimizes breath code (Saves 12% of carbon/Life()) * Update lungs.dm --------- Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
This commit is contained in:
co-authored by
LemonInTheDark
Gandalf
parent
2a9c057f33
commit
1df520a7df
@@ -11,6 +11,10 @@
|
||||
/// Amount of air to take a from a tile
|
||||
#define BREATH_PERCENTAGE (BREATH_VOLUME/CELL_VOLUME)
|
||||
|
||||
/// Return this from a while_present proc to call its on_loss version, if one exists
|
||||
/// Useful for doing "we're done" effects without duped code
|
||||
#define BREATH_LOST 1
|
||||
|
||||
//Defines for N2O and Healium euphoria moodlets
|
||||
#define EUPHORIA_INACTIVE 0
|
||||
#define EUPHORIA_ACTIVE 1
|
||||
|
||||
@@ -56,9 +56,8 @@
|
||||
|
||||
//Lung respiration type flags
|
||||
#define RESPIRATION_OXYGEN (1 << 0)
|
||||
#define RESPIRATION_CO2 (1 << 1)
|
||||
#define RESPIRATION_N2 (1 << 2)
|
||||
#define RESPIRATION_PLASMA (1 << 3)
|
||||
#define RESPIRATION_N2 (1 << 1)
|
||||
#define RESPIRATION_PLASMA (1 << 2)
|
||||
|
||||
//Organ defines for carbon mobs
|
||||
#define ORGAN_ORGANIC 1
|
||||
|
||||
@@ -261,7 +261,6 @@ DEFINE_BITFIELD(mob_biotypes, list(
|
||||
|
||||
DEFINE_BITFIELD(mob_respiration_type, list(
|
||||
"RESPIRATION_OXYGEN" = RESPIRATION_OXYGEN,
|
||||
"RESPIRATION_CO2" = RESPIRATION_CO2,
|
||||
"RESPIRATION_N2" = RESPIRATION_N2,
|
||||
"RESPIRATION_PLASMA" = RESPIRATION_PLASMA,
|
||||
))
|
||||
@@ -424,7 +423,6 @@ DEFINE_BITFIELD(organ_flags, list(
|
||||
|
||||
DEFINE_BITFIELD(respiration_type, list(
|
||||
"RESPIRATION_OXYGEN" = RESPIRATION_OXYGEN,
|
||||
"RESPIRATION_CO2" = RESPIRATION_CO2,
|
||||
"RESPIRATION_N2" = RESPIRATION_N2,
|
||||
"RESPIRATION_PLASMA" = RESPIRATION_PLASMA,
|
||||
))
|
||||
|
||||
@@ -75,7 +75,6 @@
|
||||
return ..()
|
||||
|
||||
/mob/living/carbon/human/check_breath(datum/gas_mixture/breath)
|
||||
|
||||
var/L = getorganslot(ORGAN_SLOT_LUNGS)
|
||||
|
||||
if(!L)
|
||||
|
||||
@@ -391,7 +391,7 @@
|
||||
// More N2O, more severe side-effects. Causes stun/sleep.
|
||||
n2o_euphoria = EUPHORIA_ACTIVE
|
||||
throw_alert(ALERT_TOO_MUCH_N2O, /atom/movable/screen/alert/too_much_n2o)
|
||||
// 60 gives them one second to wake up and run away a bit!
|
||||
// give them one second of grace to wake up and run away a bit!
|
||||
Unconscious(6 SECONDS)
|
||||
// Enough to make the mob sleep.
|
||||
if(n2o_pp > n2o_sleep_min)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -99,10 +99,8 @@
|
||||
// Minimum and maximum gas tolerances for the 4 main life-sustaining gases.
|
||||
var/min_oxygen = test_lungs.safe_oxygen_min
|
||||
var/min_nitro = test_lungs.safe_nitro_min
|
||||
var/min_co2 = test_lungs.safe_co2_min
|
||||
var/min_plasma = test_lungs.safe_plasma_min
|
||||
var/max_oxygen = test_lungs.safe_oxygen_max
|
||||
var/max_nitro = test_lungs.safe_nitro_max
|
||||
var/max_co2 = test_lungs.safe_co2_max
|
||||
var/max_plasma = test_lungs.safe_plasma_max
|
||||
|
||||
@@ -122,9 +120,7 @@
|
||||
lungs_test_alert_max(lab_rat, test_lungs, ALERT_TOO_MUCH_OXYGEN, max_oxygen, oxygen_pp)
|
||||
|
||||
lungs_test_alert_min(lab_rat, test_lungs, ALERT_NOT_ENOUGH_NITRO, min_nitro, nitro_pp)
|
||||
lungs_test_alert_max(lab_rat, test_lungs, ALERT_TOO_MUCH_NITRO, max_nitro, nitro_pp)
|
||||
|
||||
lungs_test_alert_min(lab_rat, test_lungs, ALERT_NOT_ENOUGH_CO2, min_co2, co2_pp)
|
||||
lungs_test_alert_max(lab_rat, test_lungs, ALERT_TOO_MUCH_CO2, max_co2, co2_pp)
|
||||
|
||||
lungs_test_alert_min(lab_rat, test_lungs, ALERT_NOT_ENOUGH_PLASMA, min_plasma, plasma_pp)
|
||||
@@ -143,9 +139,6 @@
|
||||
if(min_nitro)
|
||||
expected_co2 += GET_MOLES(test_breath_backup, /datum/gas/nitrogen)
|
||||
expected_nitro = 0
|
||||
if(min_co2)
|
||||
expected_oxygen += GET_MOLES(test_breath_backup, /datum/gas/carbon_dioxide)
|
||||
expected_co2 -= GET_MOLES(test_breath_backup, /datum/gas/carbon_dioxide)
|
||||
if(min_plasma)
|
||||
expected_co2 += GET_MOLES(test_breath_backup, /datum/gas/plasma)
|
||||
expected_plasma = 0
|
||||
@@ -157,9 +150,6 @@
|
||||
if(min_nitro)
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/nitrogen), expected_nitro), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should consume all Nitrogen initially present in the breath."))
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/carbon_dioxide), expected_co2), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should convert Nitrogen into an equivalent volume of CO2."))
|
||||
if(min_co2)
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/carbon_dioxide), expected_co2), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should consume all CO2 initially present in the breath."))
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/oxygen), expected_oxygen), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should convert CO2 into an equivalent volume of Oxygen."))
|
||||
if(min_plasma)
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/plasma), expected_plasma), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should consume all Plasma initially present in the breath."))
|
||||
TEST_ASSERT(molar_cmp_equals(GET_MOLES(test_breath, /datum/gas/carbon_dioxide), expected_co2), TEST_CHECK_BREATH_MESSAGE(test_lungs, "should convert Plasma into an equivalent volume of CO2."))
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
icon = 'modular_skyrat/master_files/icons/obj/surgery.dmi'
|
||||
icon_state = "lungs-ipc"
|
||||
safe_nitro_min = 0
|
||||
safe_nitro_max = 0
|
||||
safe_co2_min = 0
|
||||
safe_co2_max = 0
|
||||
safe_plasma_min = 0
|
||||
safe_plasma_max = 0
|
||||
|
||||
Reference in New Issue
Block a user