Skip to content

Commit

Permalink
Further refinement of nutrition/thirst procs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Aug 6, 2023
1 parent 6c17c46 commit 4d0558a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 21 deletions.
7 changes: 4 additions & 3 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1293,10 +1293,11 @@

/mob/living/carbon/human/handle_nutrition_and_hydration()
..()
apply_nutrition_and_hydration_stressors()

/mob/living/carbon/human/proc/apply_nutrition_and_hydration_stressors()
SHOULD_CALL_PARENT(TRUE)
// Apply stressors.
if(!client)
return

var/nut = get_nutrition()
var/maxnut = get_max_nutrition()
if(nut < (maxnut * 0.3))
Expand Down
30 changes: 25 additions & 5 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,33 @@

return 1

/mob/living/proc/handle_nutrition_and_hydration()
/mob/living/proc/experiences_hunger_and_thirst()
return TRUE

/mob/living/proc/get_hunger_factor()
var/decl/species/my_species = get_species()
if(my_species)
return my_species.hunger_factor
return 0

/mob/living/proc/get_thirst_factor()
var/decl/species/my_species = get_species()
if(my_species)
if(nutrition > 0 && my_species.hunger_factor)
adjust_nutrition(-(my_species.hunger_factor))
if(hydration > 0 && my_species.thirst_factor)
adjust_hydration(-(my_species.thirst_factor))
return my_species.hunger_factor
return 0

/mob/living/proc/handle_nutrition_and_hydration()
SHOULD_CALL_PARENT(TRUE)
if(!experiences_hunger_and_thirst())
return
if(get_nutrition() > 0)
var/hunger_factor = get_hunger_factor()
if(hunger_factor)
adjust_nutrition(-(hunger_factor))
if(get_hydration() > 0)
var/thirst_factor = get_thirst_factor()
if(thirst_factor)
adjust_hydration(-(thirst_factor))

/mob/living/proc/handle_breathing()
return
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/silicon/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
QDEL_NULL_LIST(stock_parts)
return ..()

/mob/living/silicon/handle_nutrition_and_hydration()
return // Doesn't really apply to robots. Maybe unify this with cells in the future.
/mob/living/silicon/experiences_hunger_and_thirst()
return FALSE // Doesn't really apply to robots. Maybe unify this with cells in the future.

/mob/living/silicon/get_nutrition()
return get_max_nutrition()
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/simple_animal/simple_animal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,9 @@ var/global/list/simplemob_icon_bitflag_cache = list()
/mob/living/simple_animal/proc/can_act()
return !(QDELETED(src) || incapacitated() || (is_aquatic && !submerged()))

/mob/living/simple_animal/handle_nutrition_and_hydration()
return // They need a reliable way to recover nutrition/hydration before this is made general.
/mob/living/simple_animal/experiences_hunger_and_thirst()
// return !supernatural && !isSynthetic()
return FALSE // They need a reliable way to recover nutrition/hydration before this is made general.

/mob/living/simple_animal/get_nutrition()
return get_max_nutrition()
Expand Down
14 changes: 7 additions & 7 deletions mods/content/xenobiology/slime/_slime.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
bone_amount = 0
ai = /datum/ai/slime
hud_type = /datum/hud/slime
nutrition = 800

var/is_adult = FALSE
var/mutation_chance = 30 // Chance of mutating, should be between 25 and 35
var/powerlevel = 0 // 0-10 controls how much electricity they are generating
var/amount_grown = 0 // controls how long the slime has been overfed, if 10, grows or reproduces
var/weakref/feeding_on
var/nutrition = 800
var/toxloss = 0
var/hurt_temperature = T0C-50 // slime keeps taking damage when its bodytemperature is below this
var/die_temperature = 50 // slime dies instantly when its bodytemperature is below this
Expand Down Expand Up @@ -292,6 +292,12 @@
/mob/living/slime/check_has_mouth()
return 0

/mob/living/slime/set_nutrition(amt)
..()

/mob/living/slime/get_hydration()
return get_nutrition()

/mob/living/slime/proc/gain_nutrition(var/amount)
adjust_nutrition(amount)
if(prob(amount * 2)) // Gain around one level per 50 nutrition
Expand All @@ -300,12 +306,6 @@
powerlevel = 10
adjustToxLoss(-10)

/mob/living/slime/get_nutrition()
return nutrition

/mob/living/slime/adjust_nutrition(var/amt)
nutrition = clamp(nutrition + amt, 0, get_max_nutrition())

/mob/living/slime/proc/get_hunger_state()
. = 0
if (nutrition < get_starve_nutrition())
Expand Down
8 changes: 6 additions & 2 deletions mods/content/xenobiology/slime/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@
if(length(contents) != last_contents_length)
queue_icon_update()

/mob/living/slime/handle_nutrition_and_hydration()
/mob/living/slime/get_hunger_factor()
return (0.1 + 0.05 * is_adult)

/mob/living/slime/get_thirst_factor()
return 0

adjust_nutrition(-(0.1 + 0.05 * is_adult))
/mob/living/slime/handle_nutrition_and_hydration()

// Digest whatever we've got floating around in our goop.
if(length(contents))
Expand Down

0 comments on commit 4d0558a

Please sign in to comment.