diff --git a/code/datums/brain_damage/special.dm b/code/datums/brain_damage/special.dm index 7d3c5f6d2fb1..0bbbf8de08fc 100644 --- a/code/datums/brain_damage/special.dm +++ b/code/datums/brain_damage/special.dm @@ -15,7 +15,7 @@ if(prob(4)) if(prob(33) && (owner.IsStun() || owner.IsKnockdown() || owner.IsUnconscious())) speak("unstun", TRUE) - else if(prob(60) && owner.health <= owner.crit_modifier()) + else if(prob(60) && owner.health <= owner.crit_threshold) speak("heal", TRUE) else if(prob(30) && owner.a_intent == INTENT_HARM) speak("aggressive") diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 9efc7d8958f7..d36f7965730f 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -1,3 +1,6 @@ +#define MINOR_INSANITY_PEN 5 +#define MAJOR_INSANITY_PEN 10 + /datum/component/mood var/mood //Real happiness var/sanity = 100 //Current sanity @@ -6,6 +9,8 @@ var/mood_modifier = 1 //Modifier to allow certain mobs to be less affected by moodlets var/datum/mood_event/list/mood_events = list() var/mob/living/owner + var/insanity_effect = 0 //is the owner being punished for low mood? If so, how much? + var/holdmyinsanityeffect = 0 //before we edit our sanity lets take a look /datum/component/mood/Initialize() if(!isliving(parent)) @@ -120,13 +125,13 @@ switch(mood_level) if(1) - DecreaseSanity(0.2, 0) + DecreaseSanity(0.2) if(2) - DecreaseSanity(0.125, 25) + DecreaseSanity(0.125, SANITY_CRAZY) if(3) - DecreaseSanity(0.075, 50) + DecreaseSanity(0.075, SANITY_UNSTABLE) if(4) - DecreaseSanity(0.025, 75) + DecreaseSanity(0.025, SANITY_DISTURBED) if(5) IncreaseSanity(0.1) if(6) @@ -134,9 +139,15 @@ if(7) IncreaseSanity(0.20) if(8) - IncreaseSanity(0.25, 125) + IncreaseSanity(0.25, SANITY_GREAT) if(9) - IncreaseSanity(0.4, 125) + IncreaseSanity(0.4, SANITY_GREAT) + + if(insanity_effect != holdmyinsanityeffect) + if(insanity_effect > holdmyinsanityeffect) + owner.crit_threshold += (insanity_effect - holdmyinsanityeffect) + else + owner.crit_threshold -= (holdmyinsanityeffect - insanity_effect) if(owner.has_trait(TRAIT_DEPRESSION)) if(prob(0.05)) @@ -147,17 +158,29 @@ add_event("jolly", /datum/mood_event/jolly) clear_event("depression") -/datum/component/mood/proc/DecreaseSanity(amount, limit = 0) - if(sanity < limit) //This might make KevinZ stop fucking pinging me. + holdmyinsanityeffect = insanity_effect + +/datum/component/mood/proc/DecreaseSanity(amount, minimum = SANITY_INSANE) + if(sanity < minimum) //This might make KevinZ stop fucking pinging me. IncreaseSanity(0.5) else - sanity = max(0, sanity - amount) + sanity = max(minimum, sanity - amount) + if(sanity < SANITY_UNSTABLE) + if(sanity < SANITY_CRAZY) + insanity_effect = (MAJOR_INSANITY_PEN) + else + insanity_effect = (MINOR_INSANITY_PEN) -/datum/component/mood/proc/IncreaseSanity(amount, limit = 99) - if(sanity > limit) +/datum/component/mood/proc/IncreaseSanity(amount, maximum = SANITY_NEUTRAL) + if(sanity > maximum) DecreaseSanity(0.5) //Removes some sanity to go back to our current limit. else - sanity = min(limit, sanity + amount) + sanity = min(maximum, sanity + amount) + if(sanity > SANITY_CRAZY) + if(sanity > SANITY_UNSTABLE) + insanity_effect = 0 + else + insanity_effect = MINOR_INSANITY_PEN /datum/component/mood/proc/add_event(category, type, param) //Category will override any events in the same category, should be unique unless the event is based on the same thing like hunger. var/datum/mood_event/the_event @@ -183,3 +206,6 @@ mood_events -= category qdel(event) update_mood() + +#undef MINOR_INSANITY_PEN +#undef MAJOR_INSANITY_PEN diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index e2398649744b..c48430d2b6b9 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -72,7 +72,7 @@ if(prob(20)) if(carbon_owner) carbon_owner.handle_dreams() - if(prob(10) && owner.health > owner.crit_modifier()) + if(prob(10) && owner.health > owner.crit_threshold) owner.emote("snore") /obj/screen/alert/status_effect/asleep diff --git a/code/modules/mining/equipment/regenerative_core.dm b/code/modules/mining/equipment/regenerative_core.dm index e50370ff448a..d6e99f7361c9 100644 --- a/code/modules/mining/equipment/regenerative_core.dm +++ b/code/modules/mining/equipment/regenerative_core.dm @@ -63,7 +63,7 @@ /obj/item/organ/regenerative_core/on_life() ..() - if(owner.health < owner.crit_modifier()) + if(owner.health < owner.crit_threshold) ui_action_click() /obj/item/organ/regenerative_core/afterattack(atom/target, mob/user, proximity_flag) diff --git a/code/modules/mob/living/carbon/alien/larva/life.dm b/code/modules/mob/living/carbon/alien/larva/life.dm index 9632fbc5e32a..8474ad05da31 100644 --- a/code/modules/mob/living/carbon/alien/larva/life.dm +++ b/code/modules/mob/living/carbon/alien/larva/life.dm @@ -18,7 +18,7 @@ if(health<= -maxHealth || !getorgan(/obj/item/organ/brain)) death() return - if(IsUnconscious() || IsSleeping() || getOxyLoss() > 50 || (has_trait(TRAIT_FAKEDEATH)) || health <= crit_modifier()) + if(IsUnconscious() || IsSleeping() || getOxyLoss() > 50 || (has_trait(TRAIT_FAKEDEATH)) || health <= crit_threshold) if(stat == CONSCIOUS) stat = UNCONSCIOUS blind_eyes(1) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index c7d987fd36e3..ffad7bb78c3a 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -599,7 +599,7 @@ if(!client) return - if(health <= crit_modifier()) + if(health <= crit_threshold) var/severity = 0 switch(health) if(-20 to -10) @@ -728,7 +728,7 @@ stat = UNCONSCIOUS blind_eyes(1) else - if(health <= crit_modifier() && !has_trait(TRAIT_NOSOFTCRIT)) + if(health <= crit_threshold && !has_trait(TRAIT_NOSOFTCRIT)) stat = SOFT_CRIT else stat = CONSCIOUS diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index c9ac8655f90b..f18d6d363df0 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -372,12 +372,3 @@ var/obj/item/organ/ears/ears = getorganslot(ORGAN_SLOT_EARS) if(istype(ears) && !ears.deaf) . = TRUE - -/mob/living/carbon/crit_modifier() - . = ..() - GET_COMPONENT(mood, /datum/component/mood) - if(mood) - if(mood.sanity >= SANITY_UNSTABLE) - . += 5 - else if(mood.sanity >= SANITY_CRAZY) - . += 10 diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 3f65c0c5268c..1a9469b4869b 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -656,7 +656,7 @@ var/they_breathe = !C.has_trait(TRAIT_NOBREATH) var/they_lung = C.getorganslot(ORGAN_SLOT_LUNGS) - if(C.health > C.crit_modifier()) + if(C.health > C.crit_threshold) return src.visible_message("[src] performs CPR on [C.name]!", "You perform CPR on [C.name].") diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index c840315a6139..390dd75a6c6d 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -84,7 +84,7 @@ var/L = getorganslot(ORGAN_SLOT_LUNGS) if(!L) - if(health >= crit_modifier()) + if(health >= crit_threshold) adjustOxyLoss(HUMAN_MAX_OXYLOSS + 1) else if(!has_trait(TRAIT_NOCRITDAMAGE)) adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 7d7407f5859c..5d506427c88a 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -709,7 +709,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) H.losebreath = 0 var/takes_crit_damage = (!H.has_trait(TRAIT_NOCRITDAMAGE)) - if((H.health < H.crit_modifier()) && takes_crit_damage) + if((H.health < H.crit_threshold) && takes_crit_damage) H.adjustBruteLoss(1) /datum/species/proc/spec_death(gibbed, mob/living/carbon/human/H) diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index b2b470bca505..00b895a601d4 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -59,7 +59,7 @@ if(health <= HEALTH_THRESHOLD_FULLCRIT || (pulledby && pulledby.grab_state >= GRAB_KILL)) losebreath++ //You can't breath at all when in critical or when being choked, so you're going to miss a breath - else if(health <= crit_modifier()) + else if(health <= crit_threshold) losebreath += 0.25 //You're having trouble breathing in soft crit, so you'll miss a breath one in four times //Suffocate @@ -154,7 +154,7 @@ else //Enough oxygen failed_last_breath = 0 - if(health >= crit_modifier()) + if(health >= crit_threshold) adjustOxyLoss(-5) oxygen_used = breath_gases[/datum/gas/oxygen][MOLES] clear_alert("not_enough_oxy") diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 3cd776c3da37..e1f321f0fa93 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -281,7 +281,7 @@ return TRUE /mob/living/proc/InCritical() - return (health <= crit_modifier() && (stat == SOFT_CRIT || stat == UNCONSCIOUS)) + return (health <= crit_threshold && (stat == SOFT_CRIT || stat == UNCONSCIOUS)) /mob/living/proc/InFullCritical() return (health <= HEALTH_THRESHOLD_FULLCRIT && stat == UNCONSCIOUS) @@ -807,7 +807,7 @@ var/stam = getStaminaLoss() if(stam) var/total_health = (health - stam) - if(total_health <= crit_modifier() && !stat && !IsKnockdown()) + if(total_health <= crit_threshold && !stat && !IsKnockdown()) to_chat(src, "You're too exhausted to keep going...") Knockdown(100) update_health_hud() diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 2823d6041762..0ce42af01b1c 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -61,9 +61,6 @@ else return 0 -/mob/living/proc/crit_modifier() - return HEALTH_THRESHOLD_CRIT - /mob/living/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE) if(istype(AM, /obj/item)) var/obj/item/I = AM diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index d0ae17515195..fa38f831f04a 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -20,6 +20,7 @@ var/fireloss = 0 //Burn damage caused by being way too hot, too cold or burnt. var/cloneloss = 0 //Damage caused by being cloned or ejected from the cloner early. slimes also deal cloneloss damage to victims var/staminaloss = 0 //Stamina damage, or exhaustion. You recover it slowly naturally, and are knocked down if it gets too high. Holodeck and hallucinations deal this. + var/crit_threshold = HEALTH_THRESHOLD_CRIT // when the mob goes from "normal" to crit var/confused = 0 //Makes the mob move in random directions. diff --git a/code/modules/surgery/organs/heart.dm b/code/modules/surgery/organs/heart.dm index 9eeb667e2fc0..52904b8af120 100644 --- a/code/modules/surgery/organs/heart.dm +++ b/code/modules/surgery/organs/heart.dm @@ -54,11 +54,11 @@ var/sound/fastbeat = sound('sound/health/fastbeat.ogg', repeat = TRUE) var/mob/living/carbon/H = owner - if(H.health <= H.crit_modifier() && beat != BEAT_SLOW) + if(H.health <= H.crit_threshold && beat != BEAT_SLOW) beat = BEAT_SLOW H.playsound_local(get_turf(H), slowbeat,40,0, channel = CHANNEL_HEARTBEAT) to_chat(owner, "You feel your heart slow down...") - if(beat == BEAT_SLOW && H.health > H.crit_modifier()) + if(beat == BEAT_SLOW && H.health > H.crit_threshold) H.stop_sound_channel(CHANNEL_HEARTBEAT) beat = BEAT_NONE diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index e338c4aa0ca2..114fe8bf9d57 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -64,7 +64,7 @@ if(!breath || (breath.total_moles() == 0)) if(H.reagents.has_reagent(crit_stabilizing_reagent)) return - if(H.health >= H.crit_modifier()) + if(H.health >= H.crit_threshold) H.adjustOxyLoss(HUMAN_MAX_OXYLOSS) else if(!H.has_trait(TRAIT_NOCRITDAMAGE)) H.adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS) @@ -111,7 +111,7 @@ H.throw_alert("not_enough_oxy", /obj/screen/alert/not_enough_oxy) else H.failed_last_breath = FALSE - if(H.health >= H.crit_modifier()) + if(H.health >= H.crit_threshold) H.adjustOxyLoss(-5) gas_breathed = breath_gases[/datum/gas/oxygen][MOLES] H.clear_alert("not_enough_oxy") @@ -139,7 +139,7 @@ H.throw_alert("nitro", /obj/screen/alert/not_enough_nitro) else H.failed_last_breath = FALSE - if(H.health >= H.crit_modifier()) + if(H.health >= H.crit_threshold) H.adjustOxyLoss(-5) gas_breathed = breath_gases[/datum/gas/nitrogen][MOLES] H.clear_alert("nitro") @@ -176,7 +176,7 @@ H.throw_alert("not_enough_co2", /obj/screen/alert/not_enough_co2) else H.failed_last_breath = FALSE - if(H.health >= H.crit_modifier()) + if(H.health >= H.crit_threshold) H.adjustOxyLoss(-5) gas_breathed = breath_gases[/datum/gas/carbon_dioxide][MOLES] H.clear_alert("not_enough_co2") @@ -206,7 +206,7 @@ H.throw_alert("not_enough_tox", /obj/screen/alert/not_enough_tox) else H.failed_last_breath = FALSE - if(H.health >= H.crit_modifier()) + if(H.health >= H.crit_threshold) H.adjustOxyLoss(-5) gas_breathed = breath_gases[/datum/gas/plasma][MOLES] H.clear_alert("not_enough_tox")