From cd3ca2b8d1bc41eed7d3df2f3120bb0a1359a0d7 Mon Sep 17 00:00:00 2001 From: DragonTrance Date: Tue, 23 Feb 2021 17:19:06 -0700 Subject: [PATCH] sorting thirst code + not-water replenishes hydration --- code/__DEFINES/mobs.dm | 9 +++++++++ code/datums/components/mood.dm | 10 ++++++---- code/modules/mob/living/blood.dm | 4 ++-- code/modules/mob/living/carbon/carbon_movement.dm | 2 +- code/modules/mob/living/carbon/human/species.dm | 11 +++++++++-- code/modules/mob/mob.dm | 1 + code/modules/reagents/chemistry/reagents.dm | 1 + .../reagents/chemistry/reagents/drink_reagents.dm | 3 --- .../reagents/chemistry/reagents/food_reagents.dm | 1 - .../reagents/chemistry/reagents/other_reagents.dm | 7 +------ code/modules/surgery/organs/stomach.dm | 3 ++- 11 files changed, 32 insertions(+), 20 deletions(-) diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index c7284dc4..a0aa5e6b 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -158,6 +158,15 @@ #define NUTRITION_LEVEL_START_MIN 250 #define NUTRITION_LEVEL_START_MAX 400 +//Hyperstation Thirst +#define THIRST_LEVEL_THRESHOLD 800 //Set to 0 to stop clamping +#define THIRST_LEVEL_QUENCHED 450 +#define THIRST_LEVEL_THIRSTY 250 +#define THIRST_LEVEL_PARCHED 150 + +#define THIRST_LEVEL_START_MIN 250 +#define THIRST_LEVEL_START_MAX 400 + //Disgust levels for humans #define DISGUST_LEVEL_MAXEDOUT 150 #define DISGUST_LEVEL_DISGUSTED 75 diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index dbce0072..4cda20f1 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -306,14 +306,16 @@ add_event(null, "nutrition", /datum/mood_event/starving) /datum/component/mood/proc/HandleThirst(mob/living/L) + if(THIRST_LEVEL_THRESHOLD) + L.thirst = clamp(L.thirst, 0, THIRST_LEVEL_THRESHOLD) switch(L.thirst) - if(NUTRITION_LEVEL_WELL_FED to INFINITY) + if(THIRST_LEVEL_QUENCHED to INFINITY) add_event(null, "thirst", /datum/mood_event/quenched) - if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_WELL_FED) + if(THIRST_LEVEL_THIRSTY to THIRST_LEVEL_QUENCHED) clear_event(null, "thirst") - if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY) + if(THIRST_LEVEL_PARCHED to THIRST_LEVEL_THIRSTY) add_event(null, "thirst", /datum/mood_event/thirsty) - if(0 to NUTRITION_LEVEL_STARVING) + if(0 to THIRST_LEVEL_PARCHED) add_event(null, "thirst", /datum/mood_event/dehydrated) #undef MINOR_INSANITY_PEN diff --git a/code/modules/mob/living/blood.dm b/code/modules/mob/living/blood.dm index 4b04639b..a5e55ea5 100644 --- a/code/modules/mob/living/blood.dm +++ b/code/modules/mob/living/blood.dm @@ -44,7 +44,7 @@ //Blood regeneration if there is some space if(blood_volume < (BLOOD_VOLUME_NORMAL * blood_ratio) && !HAS_TRAIT(src, TRAIT_NOHUNGER)) var/nutrition_ratio = 0 - var/thirst_ratio = 1 + //thirst_ratio = 1 //Uncomment if something fancy gets added switch(nutrition) if(0 to NUTRITION_LEVEL_STARVING) nutrition_ratio = 0.2 @@ -61,7 +61,7 @@ if(satiety > 80) nutrition_ratio *= 1.25 nutrition = max(0, nutrition - nutrition_ratio * HUNGER_FACTOR) - thirst = max(0, thirst - thirst_ratio * THIRST_FACTOR) + thirst = max(0, thirst - 0.8 * THIRST_FACTOR) blood_volume = min((BLOOD_VOLUME_NORMAL * blood_ratio), blood_volume + 0.5 * nutrition_ratio) //Effects of bloodloss diff --git a/code/modules/mob/living/carbon/carbon_movement.dm b/code/modules/mob/living/carbon/carbon_movement.dm index 93d3e1db..fcf85505 100644 --- a/code/modules/mob/living/carbon/carbon_movement.dm +++ b/code/modules/mob/living/carbon/carbon_movement.dm @@ -44,4 +44,4 @@ thirst -= THIRST_FACTOR/12 if(m_intent == MOVE_INTENT_RUN) nutrition -= HUNGER_FACTOR/5 - thirst -= THIRST_FACTOR/5 //running around depleats thirst more so. \ No newline at end of file + thirst -= THIRST_FACTOR/5 diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 643161bd..5f84c597 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1243,7 +1243,6 @@ GLOBAL_LIST_EMPTY(roundstart_races) if (H.nutrition > 0 && H.stat != DEAD && !HAS_TRAIT(H, TRAIT_NOHUNGER)) // THEY HUNGER var/hunger_rate = HUNGER_FACTOR - var/thirst_rate = THIRST_FACTOR var/datum/component/mood/mood = H.GetComponent(/datum/component/mood) if(mood && mood.sanity > SANITY_DISTURBED) hunger_rate *= max(0.5, 1 - 0.002 * mood.sanity) //0.85 to 0.75 @@ -1262,7 +1261,6 @@ GLOBAL_LIST_EMPTY(roundstart_races) hunger_rate = 3 * HUNGER_FACTOR hunger_rate *= H.physiology.hunger_mod H.nutrition = max(0, H.nutrition - hunger_rate) - H.thirst = max(0, H.thirst - thirst_rate) if (H.nutrition > NUTRITION_LEVEL_FULL) @@ -1298,6 +1296,14 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(0 to NUTRITION_LEVEL_STARVING) H.throw_alert("nutrition", /obj/screen/alert/starving) +/datum/species/proc/handle_thirst(mob/living/carbon/human/H) + if(HAS_TRAIT(src, TRAIT_NOTHIRST)) + return + + //Put more things here if you plan on adding more things. I know this proc is a bit empty at the moment + H.thirst -= THIRST_FACTOR + + switch(H.thirst) if(NUTRITION_LEVEL_HUNGRY to INFINITY) H.clear_alert("thirst") @@ -1306,6 +1312,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(0 to NUTRITION_LEVEL_STARVING) H.throw_alert("thirst", /obj/screen/alert/dehydrated) + /datum/species/proc/update_health_hud(mob/living/carbon/human/H) return 0 diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index af91754b..4f1afd3d 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -36,6 +36,7 @@ var/datum/atom_hud/alternate_appearance/AA = v AA.onNewMob(src) nutrition = rand(NUTRITION_LEVEL_START_MIN, NUTRITION_LEVEL_START_MAX) + thirst = rand(NUTRITION_LEVEL_START_MIN, NUTRITION_LEVEL_START_MAX) . = ..() update_config_movespeed() update_movespeed(TRUE) diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 61d32c29..89bd36a4 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -81,6 +81,7 @@ GLOBAL_LIST_INIT(name2reagent, build_name2reagent()) current_cycle++ if(holder) holder.remove_reagent(type, metabolization_rate * M.metabolism_efficiency) //By default it slowly disappears. + M.thirst += hydration return //called when a mob processes chems when dead. diff --git a/code/modules/reagents/chemistry/reagents/drink_reagents.dm b/code/modules/reagents/chemistry/reagents/drink_reagents.dm index 853a0000..d250f025 100644 --- a/code/modules/reagents/chemistry/reagents/drink_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drink_reagents.dm @@ -3,9 +3,6 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////// DRINKS BELOW, Beer is up there though, along with cola. Cap'n Pete's Cuban Spiced Rum//////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// -/datum/reagent/water/ - hydration = 10 * REAGENTS_METABOLISM - /datum/reagent/consumable/orangejuice name = "Orange Juice" description = "Both delicious AND rich in Vitamin C, what more do you need?" diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index b5384f8a..bb200cdc 100644 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -18,7 +18,6 @@ /datum/reagent/consumable/on_mob_life(mob/living/carbon/M) current_cycle++ M.nutrition += nutriment_factor - M.thirst += hydration holder.remove_reagent(type, metabolization_rate) /datum/reagent/consumable/reaction_mob(mob/living/M, method=TOUCH, reac_volume) diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 4e8671b3..c319899e 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -258,12 +258,7 @@ glass_name = "glass of water" glass_desc = "The father of all refreshments." shot_glass_icon_state = "shotglassclear" - hydration = 5 * REAGENTS_METABOLISM - -//hydration -/datum/reagent/water/on_mob_life(mob/living/carbon/M) - M.thirst += hydration - ..() + hydration = 10 * REAGENTS_METABOLISM /* * Water reaction to turf diff --git a/code/modules/surgery/organs/stomach.dm b/code/modules/surgery/organs/stomach.dm index 1d1aa3d6..256b2c3c 100644 --- a/code/modules/surgery/organs/stomach.dm +++ b/code/modules/surgery/organs/stomach.dm @@ -23,6 +23,7 @@ var/mob/living/carbon/human/H = owner if(!(organ_flags & ORGAN_FAILING)) H.dna.species.handle_digestion(H) + H.dna.species.handle_thirst(H) handle_disgust(H) Nutri = locate(/datum/reagent/consumable/nutriment) in H.reagents.reagent_list @@ -99,4 +100,4 @@ /obj/item/organ/stomach/ipc name = "ipc stomach" - icon_state = "stomach-ipc" \ No newline at end of file + icon_state = "stomach-ipc"