Refactor the Hunger Meter, add Machine People Battery Meters (#17603)

* Neat

* typo

* or

* Reworked, huh

* Update screen_hunger_machine.dmi

* Update life.dm
This commit is contained in:
Vi3trice
2022-04-20 12:30:39 +01:00
committed by GitHub
parent 5671f88ffd
commit 5f777f7f15
10 changed files with 75 additions and 58 deletions
@@ -95,6 +95,8 @@
var/datum/hud/hud = L.hud_used
if(hud?.vampire_blood_display)
hud.remove_vampire_hud()
L.dna.species.hunger_type = initial(L.dna.species.hunger_type)
L.dna.species.hunger_icon = initial(L.dna.species.hunger_icon)
owner.current.alpha = 255
REMOVE_TRAITS_IN(owner.current, "vampire")
return ..()
@@ -324,7 +326,9 @@
if(!owner.som) //thralls and mindslaves
owner.som = new()
owner.som.masters += owner
var/mob/living/L = new_body || owner.current
L.dna.species.hunger_type = "vampire"
L.dna.species.hunger_icon = 'icons/mob/screen_hunger_vampire.dmi'
check_vampire_upgrade(FALSE)
/datum/hud/proc/remove_vampire_hud()
@@ -22,8 +22,8 @@
/obj/screen/alert/too_much_oxy = "too_much_oxy",
/obj/screen/alert/too_much_co2 = "too_much_co2",
/obj/screen/alert/too_much_tox = "too_much_tox",
/obj/screen/alert/fat = "nutrition",
/obj/screen/alert/starving = "nutrition",
/obj/screen/alert/hunger/fat = "nutrition",
/obj/screen/alert/hunger/starving = "nutrition",
/obj/screen/alert/hot = "temp",
/obj/screen/alert/cold = "temp",
/obj/screen/alert/highpressure = "pressure",
+19 -29
View File
@@ -790,35 +790,25 @@
/mob/living/carbon/human/proc/handle_nutrition_alerts() //This is a terrible abuse of the alert system; something like this should be a HUD element
if(HAS_TRAIT(src, TRAIT_NOHUNGER))
return
if(mind?.has_antag_datum(/datum/antagonist/vampire)) //Vampires
switch(nutrition)
if(NUTRITION_LEVEL_FULL to INFINITY)
throw_alert("nutrition", /obj/screen/alert/fat/vampire)
if(NUTRITION_LEVEL_WELL_FED to NUTRITION_LEVEL_FULL)
throw_alert("nutrition", /obj/screen/alert/full/vampire)
if(NUTRITION_LEVEL_FED to NUTRITION_LEVEL_WELL_FED)
throw_alert("nutrition", /obj/screen/alert/well_fed/vampire)
if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_FED)
throw_alert("nutrition", /obj/screen/alert/fed/vampire)
if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY)
throw_alert("nutrition", /obj/screen/alert/hungry/vampire)
else
throw_alert("nutrition", /obj/screen/alert/starving/vampire)
else //Any other non-vampires
switch(nutrition)
if(NUTRITION_LEVEL_FULL to INFINITY)
throw_alert("nutrition", /obj/screen/alert/fat)
if(NUTRITION_LEVEL_WELL_FED to NUTRITION_LEVEL_FULL)
throw_alert("nutrition", /obj/screen/alert/full)
if(NUTRITION_LEVEL_FED to NUTRITION_LEVEL_WELL_FED)
throw_alert("nutrition", /obj/screen/alert/well_fed)
if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_FED)
throw_alert("nutrition", /obj/screen/alert/fed)
if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY)
throw_alert("nutrition", /obj/screen/alert/hungry)
else
throw_alert("nutrition", /obj/screen/alert/starving)
var/new_hunger
switch(nutrition)
if(NUTRITION_LEVEL_FULL to INFINITY)
new_hunger = "fat"
if(NUTRITION_LEVEL_WELL_FED to NUTRITION_LEVEL_FULL)
new_hunger = "full"
if(NUTRITION_LEVEL_FED to NUTRITION_LEVEL_WELL_FED)
new_hunger = "well_fed"
if(NUTRITION_LEVEL_HUNGRY to NUTRITION_LEVEL_FED)
new_hunger = "fed"
if(NUTRITION_LEVEL_STARVING to NUTRITION_LEVEL_HUNGRY)
new_hunger = "hungry"
else
new_hunger = "starving"
if(dna.species.hunger_type)
new_hunger += "/[dna.species.hunger_type]"
if(dna.species.hunger_level != new_hunger)
dna.species.hunger_level = new_hunger
throw_alert("nutrition", "/obj/screen/alert/hunger/[new_hunger]", icon_override = dna.species.hunger_icon)
/mob/living/carbon/human/handle_random_events()
// Puke if toxloss is too high
@@ -36,6 +36,9 @@
var/hunger_drain = HUNGER_FACTOR
var/digestion_ratio = 1 //How quickly the species digests/absorbs reagents.
var/taste_sensitivity = TASTE_SENSITIVITY_NORMAL //the most widely used factor; humans use a different one
var/hunger_icon = 'icons/mob/screen_hunger.dmi'
var/hunger_type
var/hunger_level
var/siemens_coeff = 1 //base electrocution coefficient
@@ -45,6 +45,9 @@
female_sneeze_sound = 'sound/effects/mob_effects/f_machine_sneeze.ogg'
butt_sprite = "machine"
hunger_icon = 'icons/mob/screen_hunger_machine.dmi'
hunger_type = "machine"
has_organ = list(
"brain" = /obj/item/organ/internal/brain/mmi_holder/posibrain,
"cell" = /obj/item/organ/internal/cell,