diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index f4b2a2b5e49..5201016a5bd 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -66,3 +66,11 @@ #define MOVESPEED_ID_SHOVE "SHOVE" #define MOVESPEED_ID_PRONE_DRAGGING "PRONE_DRAG" #define MOVESPEED_ID_HUMAN_CARRYING "HUMAN_CARRY" + +#define MOVESPEED_ID_FAT "FAT" + +#define MOVESPEED_ID_COLD "COLD" + +#define MOVESPEED_ID_HUNGRY "HUNGRY" + +#define MOVESPEED_ID_DAMAGE_SLOWDOWN "DAMAGE" diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 44daef8e985..275887c66ce 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -919,6 +919,18 @@ /mob/living/carbon/human/updatehealth() . = ..() + if(!HAS_TRAIT(src, TRAIT_IGNOREDAMAGESLOWDOWN)) + var/health_deficiency = max((maxHealth - health), staminaloss) + if(health_deficiency >= 40) + if(movement_type & FLYING) + add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN, override = TRUE, multiplicative_slowdown = (health_deficiency / 75)) + else + add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN, override = TRUE, multiplicative_slowdown = (health_deficiency / 25)) + else + remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) + else + remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) + dna?.species.spec_updatehealth(src) /mob/living/carbon/human/adjust_nutrition(var/change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index c127421ca4e..c17d8b8d582 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -971,12 +971,14 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(H.overeatduration < 100) to_chat(H, "You feel fit again!") REMOVE_TRAIT(H, TRAIT_FAT, OBESITY) + H.remove_movespeed_modifier(MOVESPEED_ID_FAT) H.update_inv_w_uniform() H.update_inv_wear_suit() else if(H.overeatduration >= 100) to_chat(H, "You suddenly feel blubbery!") ADD_TRAIT(H, TRAIT_FAT, OBESITY) + H.add_movespeed_modifier(MOVESPEED_ID_FAT, multiplicative_slowdown = 1.5) H.update_inv_w_uniform() H.update_inv_wear_suit() @@ -1022,6 +1024,19 @@ GLOBAL_LIST_EMPTY(roundstart_races) to_chat(H, "You no longer feel vigorous.") H.metabolism_efficiency = 1 + //Hunger slowdown for if mood isn't enabled + if(CONFIG_GET(flag/disable_human_mood)) + if(!HAS_TRAIT(H, TRAIT_NOHUNGER)) + var/hungry = (500 - H.nutrition) / 5 //So overeat would be 100 and default level would be 80 + if(hungry >= 70) + H.add_movespeed_modifier(MOVESPEED_ID_HUNGRY, override = TRUE, multiplicative_slowdown = (hungry / 50)) + else if(isethereal(H)) + var/datum/species/ethereal/E = H.dna.species + if(E.get_charge(H) <= ETHEREAL_CHARGE_NORMAL) + H.add_movespeed_modifier(MOVESPEED_ID_HUNGRY, override = TRUE, multiplicative_slowdown = (1.5 * (1 - E.get_charge(H) / 100))) + else + H.remove_movespeed_modifier(MOVESPEED_ID_HUNGRY) + switch(H.nutrition) if(NUTRITION_LEVEL_FULL to INFINITY) H.throw_alert("nutrition", /obj/screen/alert/fat) @@ -1077,11 +1092,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) /datum/species/proc/movement_delay(mob/living/carbon/human/H) . = 0 //We start at 0. - var/flight = 0 //Check for flight and flying items var/gravity = 0 - if(H.movement_type & FLYING) - flight = 1 - gravity = H.has_gravity() if(!HAS_TRAIT(H, TRAIT_IGNORESLOWDOWN) && gravity) @@ -1094,33 +1105,12 @@ GLOBAL_LIST_EMPTY(roundstart_races) for(var/obj/item/I in H.held_items) if(I.item_flags & SLOWS_WHILE_IN_HAND) . += I.slowdown - if(!HAS_TRAIT(H, TRAIT_IGNOREDAMAGESLOWDOWN)) - var/health_deficiency = max(H.maxHealth - H.health, H.staminaloss) - if(health_deficiency >= 40) - if(flight) - . += (health_deficiency / 75) - else - . += (health_deficiency / 25) - if(CONFIG_GET(flag/disable_human_mood)) - if(!HAS_TRAIT(H, TRAIT_NOHUNGER)) - var/hungry = (500 - H.nutrition) / 5 //So overeat would be 100 and default level would be 80 - if((hungry >= 70) && !flight) //Being hungry will still allow you to use a flightsuit/wings. - . += hungry / 50 - else if(isethereal(H)) - var/datum/species/ethereal/E = H.dna.species - var/charge = E.get_charge() - if(charge <= ETHEREAL_CHARGE_NORMAL) - . += 1.5 * (1 - charge / 100) //Moving in high gravity is very slow (Flying too) if(gravity > STANDARD_GRAVITY) var/grav_force = min(gravity - STANDARD_GRAVITY,3) . += 1 + grav_force - if(HAS_TRAIT(H, TRAIT_FAT)) - . += (1.5 - flight) - if(H.bodytemperature < BODYTEMP_COLD_DAMAGE_LIMIT && !HAS_TRAIT(H, TRAIT_RESISTCOLD)) - . += (BODYTEMP_COLD_DAMAGE_LIMIT - H.bodytemperature) / COLD_SLOWDOWN_FACTOR return . ////////////////// @@ -1600,6 +1590,8 @@ GLOBAL_LIST_EMPTY(roundstart_races) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "hot", /datum/mood_event/hot) + H.remove_movespeed_modifier(MOVESPEED_ID_COLD) + var/burn_damage var/firemodifier = H.fire_stacks / 50 if (H.on_fire) @@ -1623,6 +1615,8 @@ GLOBAL_LIST_EMPTY(roundstart_races) else if(H.bodytemperature < BODYTEMP_COLD_DAMAGE_LIMIT && !HAS_TRAIT(H, TRAIT_RESISTCOLD)) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "cold", /datum/mood_event/cold) + //Sorry for the nasty oneline but I don't want to assign a variable on something run pretty frequently + H.add_movespeed_modifier(MOVESPEED_ID_COLD, override = TRUE, multiplicative_slowdown = ((BODYTEMP_COLD_DAMAGE_LIMIT - H.bodytemperature) / COLD_SLOWDOWN_FACTOR)) switch(H.bodytemperature) if(200 to BODYTEMP_COLD_DAMAGE_LIMIT) H.throw_alert("temp", /obj/screen/alert/cold, 1) @@ -1636,6 +1630,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) else H.clear_alert("temp") + H.remove_movespeed_modifier(MOVESPEED_ID_COLD) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot")