Skip to content

Commit

Permalink
Tweaks to brain damage & healing (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit authored Jan 22, 2024
1 parent 6e37f34 commit 9df06cc
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions code/modules/organs/internal/brain.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
var/mob/living/carbon/brain/brainmob = null
var/const/damage_threshold_count = 10
var/damage_threshold_value
var/healed_threshold = 1
// When TRUE - next Life() tick will trigger severe damage effects. Basically exists as a sort of a cooldown.
var/healed_threshold = TRUE
var/oxygen_reserve = 6

/obj/item/organ/internal/brain/New(mob/living/carbon/holder)
Expand All @@ -44,14 +45,13 @@
handle_severe_brain_damage()

if(damage < (max_damage / 4))
healed_threshold = 1
healed_threshold = TRUE

handle_disabilities()
handle_damage_effects()

// Brain damage from low oxygenation or lack of blood.
if(owner.should_have_organ(BP_HEART))

// No heart? You are going to have a very bad time. Not 100% lethal because heart transplants should be a thing.
var/blood_volume = owner.get_blood_oxygenation()
if(blood_volume < BLOOD_VOLUME_SURVIVE)
Expand All @@ -61,51 +61,52 @@
oxygen_reserve = min(initial(oxygen_reserve), oxygen_reserve+1)
if(!oxygen_reserve) //(hardcrit)
owner.Paralyse(3)
var/can_heal = damage && damage < max_damage && (damage % damage_threshold_value || owner.chem_effects[CE_BRAIN_REGEN] || (!past_damage_threshold(3) && owner.chem_effects[CE_STABLE]))
var/can_heal = damage && damage < max_damage && (!past_damage_threshold(6) || owner.chem_effects[CE_BRAIN_REGEN])
var/damprob
//Effects of bloodloss
switch(blood_volume)

if(BLOOD_VOLUME_SAFE to INFINITY)
if(can_heal)
damage = max(damage-1, 0)
heal_damage(1)
if(BLOOD_VOLUME_OKAY to BLOOD_VOLUME_SAFE)
if(prob(1))
to_chat(owner, "<span class='warning'>You feel [pick("dizzy","woozy","faint")]...</span>")
damprob = owner.chem_effects[CE_STABLE] ? 30 : 60
to_chat(owner, SPAN_WARNING("You feel [pick("dizzy","woozy","faint")]..."))
damprob = owner.chem_effects[CE_STABLE] ? 15 : 60
if(!past_damage_threshold(2) && prob(damprob))
take_internal_damage(1)
take_internal_damage(0.25)
if(BLOOD_VOLUME_BAD to BLOOD_VOLUME_OKAY)
owner.eye_blurry = max(owner.eye_blurry,6)
damprob = owner.chem_effects[CE_STABLE] ? 40 : 80
damprob = owner.chem_effects[CE_STABLE] ? 20 : 80
if(!past_damage_threshold(4) && prob(damprob))
take_internal_damage(1)
take_internal_damage(0.5)
if(!owner.paralysis && prob(10))
owner.Paralyse(rand(1,3))
to_chat(owner, "<span class='warning'>You feel extremely [pick("dizzy","woozy","faint")]...</span>")
to_chat(owner, SPAN_WARNING("You feel extremely [pick("dizzy","woozy","faint")]..."))
if(BLOOD_VOLUME_SURVIVE to BLOOD_VOLUME_BAD)
owner.eye_blurry = max(owner.eye_blurry,6)
damprob = owner.chem_effects[CE_STABLE] ? 60 : 100
damprob = owner.chem_effects[CE_STABLE] ? 22 : 90
if(!past_damage_threshold(6) && prob(damprob))
take_internal_damage(1)
if(!owner.paralysis && prob(15))
owner.Paralyse(3,5)
to_chat(owner, "<span class='warning'>You feel extremely [pick("dizzy","woozy","faint")]...</span>")
to_chat(owner, SPAN_DANGER("You feel extremely [pick("dizzy","woozy","faint")]..."))
if(-(INFINITY) to BLOOD_VOLUME_SURVIVE) // Also see heart.dm, being below this point puts you into cardiac arrest.
owner.eye_blurry = max(owner.eye_blurry,6)
damprob = owner.chem_effects[CE_STABLE] ? 80 : 100
damprob = owner.chem_effects[CE_STABLE] ? 25 : 100
if(prob(damprob))
take_internal_damage(1)
if(prob(damprob))
take_internal_damage(1)
..()
take_internal_damage(2)
// Alkysine and the like passively heal brain damage below certain threshold
var/brain_heal_effect = owner.chem_effects[CE_BRAIN_REGEN]
if(brain_heal_effect && !past_damage_threshold(7 + brain_heal_effect))
heal_damage(brain_heal_effect)
return ..()

/obj/item/organ/internal/brain/examine(mob/user)
. = ..()
if(brainmob && brainmob.client)//if thar be a brain inside... the brain.
to_chat(user, "You can feel the small spark of life still left in this one.")
to_chat(user, SPAN_NOTICE(SPAN_BOLD("You can feel the small spark of life still left in this one.")))
else
to_chat(user, "This one seems particularly lifeless. Perhaps it will regain some of its luster later..")
to_chat(user, SPAN_DEADSAY("This one seems particularly lifeless. Perhaps it will regain some of its luster later.."))

/obj/item/organ/internal/brain/removed(mob/living/user)
if(!istype(owner))
Expand Down Expand Up @@ -139,7 +140,7 @@
/obj/item/organ/internal/brain/surgical_fix(mob/user)
var/blood_volume = owner.get_blood_oxygenation()
if(blood_volume < BLOOD_VOLUME_SURVIVE)
to_chat(user, "<span class='danger'>Parts of [src] didn't survive the procedure due to lack of air supply!</span>")
to_chat(user, SPAN_DANGER("Parts of [src] didn't survive the procedure due to lack of air supply!"))
set_max_damage(Floor(max_damage - 0.25*damage))
heal_damage(damage)

Expand Down Expand Up @@ -196,7 +197,7 @@
if(H.mind)
H.mind.transfer_to(brainmob)

to_chat(brainmob, "<span class='notice'>You feel slightly disoriented. That's normal when you're just \a [initial(src.name)].</span>")
to_chat(brainmob, SPAN_NOTICE("You feel slightly disoriented. That's normal when you're just \a [initial(src.name)]."))
callHook("debrain", list(brainmob))

/obj/item/organ/internal/brain/proc/get_current_damage_threshold()
Expand All @@ -207,7 +208,7 @@

/obj/item/organ/internal/brain/proc/handle_severe_brain_damage()
set waitfor = FALSE
healed_threshold = 0
healed_threshold = FALSE
to_chat(owner, "<span class = 'notice' font size='10'><B>Where am I...?</B></span>")
sleep(5 SECONDS)
if(!owner)
Expand Down Expand Up @@ -244,17 +245,17 @@
/obj/item/organ/internal/brain/proc/handle_damage_effects()
if(owner.stat)
return
if(damage > 0 && prob(1))
if(damage > 5 && prob(1))
owner.custom_pain("Your head feels numb and painful.",10)
if(is_bruised() && prob(1) && owner.eye_blurry <= 0)
to_chat(owner, "<span class='warning'>It becomes hard to see for some reason.</span>")
to_chat(owner, SPAN_WARNING("It becomes hard to see for some reason."))
owner.eye_blurry = 5
if(damage >= 0.5*max_damage && prob(1) && owner.get_active_hand())
to_chat(owner, "<span class='danger'>Your hand won't respond properly, and you drop what you are holding!</span>")
if(damage >= 0.5 * max_damage && prob(1) && owner.get_active_hand())
to_chat(owner, SPAN_DANGER("Your hand won't respond properly, and you drop what you are holding!"))
owner.unequip_item()
if(damage >= 0.6*max_damage)
if(damage >= 0.75 * max_damage)
owner.slurring = max(owner.slurring, 2)
if(is_broken())
if(!owner.lying)
to_chat(owner, "<span class='danger'>You black out!</span>")
to_chat(owner, SPAN_DANGER("You black out!"))
owner.Paralyse(10)

0 comments on commit 9df06cc

Please sign in to comment.