Brainmed Code Quality + Organ Scarring (#7645)

Organ scarring has been made into a better system.

New healthdoll.

Other misc code cleanup attempts.

Fixes #7647
This commit is contained in:
Matt Atlas
2019-12-14 00:10:53 +02:00
committed by Erki
parent 480f537afb
commit 37abd8f771
24 changed files with 356 additions and 332 deletions
+3 -1
View File
@@ -78,7 +78,9 @@
drop_l_hand()
if(healths)
healths.icon_state = "health7"
healths.overlays.Cut() // This is specific to humans but the relevant code is here; shouldn't mess with other mobs.
if("health7" in icon_states(healths.icon))
healths.icon_state = "health7"
timeofdeath = world.time
if (isanimal(src))
@@ -16,95 +16,6 @@
/obj/item/organ/internal/brain/xeno/gain_trauma()
return
/obj/item/organ/internal/brain/proc/clear_screen()
if (brainmob && brainmob.client)
brainmob.client.screen.Cut()
/obj/item/organ/internal/brain/Destroy()
if(brainmob)
qdel(brainmob)
brainmob = null
return ..()
/obj/item/organ/internal/brain/proc/transfer_identity(var/mob/living/carbon/H)
brainmob = new(src)
brainmob.name = H.real_name
brainmob.real_name = H.real_name
brainmob.dna = H.dna.Clone()
brainmob.timeofhostdeath = H.timeofdeath
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>")
callHook("debrain", list(brainmob))
/obj/item/organ/internal/brain/examine(mob/user) // -- TLE
..(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.")
else
to_chat(user, "This one seems particularly lifeless. Perhaps it will regain some of its luster later..")
/obj/item/organ/internal/brain/removed(var/mob/living/user)
for(var/X in traumas)
var/datum/brain_trauma/BT = X
BT.on_lose(TRUE)
BT.owner = null
var/mob/living/simple_animal/borer/borer = owner.has_brain_worms()
if(borer)
borer.detatch() //Should remove borer if the brain is removed - RR
var/obj/item/organ/internal/brain/B = src
if(istype(B) && istype(owner))
B.transfer_identity(owner)
..()
/obj/item/organ/internal/brain/replaced(var/mob/living/target)
if(target.key)
target.ghostize()
if(brainmob)
if(brainmob.mind)
brainmob.mind.transfer_to(target)
else
target.key = brainmob.key
for(var/X in traumas)
var/datum/brain_trauma/BT = X
BT.owner = owner
BT.on_gain()
..()
/obj/item/organ/internal/brain/proc/lobotomize(mob/user as mob)
lobotomized = 1
if(owner)
to_chat(owner, "<span class='danger'>As part of your brain is drilled out, you feel your past self, your memories, your very being slip away...</span>")
to_chat(owner, "<b>Your brain has been surgically altered to remove your memory recall. Your ability to recall your former life has been surgically removed from your brain, and while your brain is in this state you remember nothing that ever came before this moment.</b>")
else if(brainmob)
to_chat(brainmob, "<span class='danger'>As part of your brain is drilled out, you feel your past self, your memories, your very being slip away...</span>")
to_chat(brainmob, "<b>Your brain has been surgically altered to remove your memory recall. Your ability to recall your former life has been surgically removed from your brain, and while your brain is in this state you remember nothing that ever came before this moment.</b>")
return
/obj/item/organ/internal/brain/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W,/obj/item/surgicaldrill))
if(!can_lobotomize)
return
if(!lobotomized)
user.visible_message("<span class='danger'>[user] drills [src] deftly with [W] into the brain!</span>")
lobotomize(user)
else
to_chat(user, "<span class='notice'>The brain has already been operated on!</span>")
..()
/obj/item/organ/internal/brain/slime
name = "slime core"
desc = "A complex, organic knot of jelly and crystalline particles."
@@ -120,49 +31,3 @@
icon = 'icons/obj/wizard.dmi'
icon_state = "scroll"
can_lobotomize = 0
////////////////////////////////////TRAUMAS////////////////////////////////////////
/obj/item/organ/internal/brain/proc/has_trauma_type(brain_trauma_type, consider_permanent = FALSE)
for(var/X in traumas)
var/datum/brain_trauma/BT = X
if(istype(BT, brain_trauma_type) && (consider_permanent || !BT.permanent))
return BT
//Add a specific trauma
/obj/item/organ/internal/brain/proc/gain_trauma(datum/brain_trauma/trauma, permanent = FALSE, list/arguments)
var/trauma_type
if(ispath(trauma))
trauma_type = trauma
traumas += new trauma_type(arglist(list(src, permanent) + arguments))
else
traumas += trauma
trauma.permanent = permanent
//Add a random trauma of a certain subtype
/obj/item/organ/internal/brain/proc/gain_trauma_type(brain_trauma_type = /datum/brain_trauma, permanent = FALSE)
var/list/datum/brain_trauma/possible_traumas = list()
for(var/T in subtypesof(brain_trauma_type))
var/datum/brain_trauma/BT = T
if(initial(BT.can_gain))
possible_traumas += BT
var/trauma_type = pick(possible_traumas)
traumas += new trauma_type(src, permanent)
//Cure a random trauma of a certain subtype
/obj/item/organ/internal/brain/proc/cure_trauma_type(brain_trauma_type, cure_permanent = FALSE)
var/datum/brain_trauma/trauma = has_trauma_type(brain_trauma_type)
if(trauma && (cure_permanent || !trauma.permanent))
qdel(trauma)
/obj/item/organ/internal/brain/proc/cure_all_traumas(cure_permanent = FALSE, cure_type = "")
for(var/X in traumas)
var/datum/brain_trauma/trauma = X
if(trauma.cure_type == cure_type || cure_type == CURE_ADMIN)
if(cure_permanent || !trauma.permanent)
qdel(trauma)
if(cure_type != CURE_ADMIN)
break
@@ -59,7 +59,7 @@
msg += ", a <b><font color='[species.examine_color || species.flesh_color]'>[species.name]</font></b>"
msg += "!\n"
if (species && species.has_organ[BP_IPCTAG] && internal_organs_by_name[BP_IPCTAG])
if (should_have_organ(BP_IPCTAG) && internal_organs_by_name[BP_IPCTAG])
msg += "[T.He] [T.is] wearing a tag designating them as Integrated Positronic Chassis <b>[src.real_name]</b>.\n"
//uniform
@@ -1709,32 +1709,32 @@
/mob/living/carbon/human/proc/get_traumas()
. = list()
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.traumas
/mob/living/carbon/human/proc/has_trauma_type(brain_trauma_type, consider_permanent = FALSE)
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.has_trauma_type(brain_trauma_type, consider_permanent)
/mob/living/carbon/human/proc/gain_trauma(datum/brain_trauma/trauma, permanent = FALSE, list/arguments)
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.gain_trauma(trauma, permanent, arguments)
/mob/living/carbon/human/proc/gain_trauma_type(brain_trauma_type = /datum/brain_trauma, permanent = FALSE)
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.gain_trauma_type(brain_trauma_type, permanent)
/mob/living/carbon/human/proc/cure_trauma_type(brain_trauma_type, cure_permanent = FALSE)
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.cure_trauma_type(brain_trauma_type, cure_permanent)
/mob/living/carbon/human/proc/cure_all_traumas(cure_permanent = FALSE, cure_type = "")
var/obj/item/organ/internal/brain/B = internal_organs_by_name[BP_BRAIN]
if(B && species && species.has_organ[BP_BRAIN] && !isipc(src))
if(B && should_have_organ(BP_BRAIN) && !isipc(src))
. = B.cure_all_traumas(cure_permanent, cure_type)
/mob/living/carbon/human/get_metabolism(metabolism)
@@ -6,8 +6,6 @@
stat = CONSCIOUS
return
update_health_display()
health = maxHealth - getBrainLoss()
//TODO: fix husking
@@ -206,3 +206,28 @@
if(!istype(heart) || !heart.is_working())
return TRUE
return FALSE
/mob/living/carbon/human/proc/get_brain_status()
var/brain_result
if(should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/brain/brain = internal_organs_by_name[BP_BRAIN]
if(!brain || stat == DEAD || (status_flags & FAKEDEATH))
brain_result = 0
else if(stat != DEAD)
brain_result = round(max(0,(1 - brain.damage/brain.max_damage)*100))
else
brain_result = -1
switch(brain_result)
if(0)
brain_result = "<span class='bad'>none, patient is braindead</span>"
if(-1)
brain_result = "<span class='average'>ERROR - Nonstandard biology</span>"
else
if(brain_result <= 50)
brain_result = "<span class='bad'>[brain_result]%</span>"
else if(brain_result <= 80)
brain_result = "<span class='average'>[brain_result]%</span>"
else
brain_result = "[brain_result]%"
return brain_result
+42 -60
View File
@@ -878,10 +878,9 @@
if(!..())
return
if(stat == UNCONSCIOUS)
//Critical damage passage overlay
if(health < maxHealth/2)
var/ovr = "passage0"
if(stat != DEAD)
if(stat == UNCONSCIOUS && health < maxHealth/2)
var/ovr
switch(health - maxHealth/2)
if(-20 to -10)
ovr = "passage1"
@@ -908,22 +907,9 @@
damageoverlay.cut_overlay(last_brute_overlay)
damageoverlay.add_overlay(ovr)
last_brute_overlay = ovr
else
//Oxygen damage overlay
update_oxy_overlay()
// Vampire frenzy overlay.
if (mind.vampire)
if (mind.vampire.status & VAMP_FRENZIED)
if (!last_frenzy_state)
damageoverlay.add_overlay("frenzyoverlay")
last_frenzy_state = TRUE
else if (last_frenzy_state)
damageoverlay.cut_overlay("frenzyoverlay")
last_frenzy_state = FALSE
else if (last_frenzy_state)
damageoverlay.cut_overlay("frenzyoverlay")
last_frenzy_state = FALSE
else
//Oxygen damage overlay
update_oxy_overlay()
//Fire and Brute damage overlay (BSSR)
var/hurtdamage = src.getBruteLoss() + src.getFireLoss() + damageoverlaytemp
@@ -948,11 +934,43 @@
damageoverlay.cut_overlay(last_brute_overlay)
damageoverlay.add_overlay(ovr)
last_brute_overlay = ovr
else if (last_brute_overlay)
damageoverlay.cut_overlay(last_brute_overlay)
last_brute_overlay = null
update_health_display()
if(healths)
healths.overlays.Cut()
if (chem_effects[CE_PAINKILLER] > 100)
healths.icon_state = "health_numb"
else
// Generate a by-limb health display.
healths.icon_state = "blank"
var/no_damage = 1
var/trauma_val = 0 // Used in calculating softcrit/hardcrit indicators.
if(can_feel_pain())
trauma_val = max(shock_stage,get_shock())/(species.total_health-100)
// Collect and apply the images all at once to avoid appearance churn.
var/list/health_images = list()
for(var/obj/item/organ/external/E in organs)
if(no_damage && (E.brute_dam || E.burn_dam))
no_damage = 0
health_images += E.get_damage_hud_image()
// Apply a fire overlay if we're burning.
if(on_fire)
health_images += image('icons/mob/screen1_health.dmi',"burning")
// Show a general pain/crit indicator if needed.
if(is_asystole())
health_images += image('icons/mob/screen1_health.dmi',"hardcrit")
else if(trauma_val)
if(can_feel_pain())
if(trauma_val > 0.7)
health_images += image('icons/mob/screen1_health.dmi',"softcrit")
if(trauma_val >= 1)
health_images += image('icons/mob/screen1_health.dmi',"hardcrit")
else if(no_damage)
health_images += image('icons/mob/screen1_health.dmi',"fullhealth")
healths.overlays += health_images
//Update hunger and thirst UI less often, its not important
if((life_tick % 3 == 0))
@@ -1387,42 +1405,6 @@
if (client)
hud_used.move_intent.update_move_icon(src)
/mob/living/carbon/human/proc/update_health_display()
if(!healths)
return
var/new_state
if (stat == DEAD)
new_state = "health7"
else if (analgesic > 100)
new_state = "health_numb"
else
switch(hal_screwyhud)
if(1)
new_state = "health6"
if(2)
new_state = "health7"
else
//switch(health - halloss)
switch(health - get_shock())
if(100 to INFINITY)
new_state = "health0"
if(80 to 100)
new_state = "health1"
if(60 to 80)
new_state = "health2"
if(40 to 60)
new_state = "health3"
if(20 to 40)
new_state = "health4"
if(0 to 20)
new_state = "health5"
else
new_state = "health6"
if (healths.icon_state != new_state)
healths.icon_state = new_state
/mob/living/carbon/human/proc/update_oxy_overlay()
var/new_oxy
if(getOxyLoss())
@@ -76,7 +76,7 @@
var/grab_mod = 1 // How easy it is to grab the species. Higher is harder to grab.
var/metabolism_mod = 1 // Reagent metabolism modifier
var/bleed_mod = 1 // How fast this species bleeds.
var/blood_volume = DEFAULT_BLOOD_SPECIES // Blood volume.
var/blood_volume = DEFAULT_BLOOD_AMOUNT // Blood volume.
var/vision_flags = DEFAULT_SIGHT // Same flags as glasses.
var/inherent_eye_protection // If set, this species has this level of inherent eye protection.
@@ -137,6 +137,7 @@
// HUD data vars.
var/datum/hud_data/hud
var/hud_type
var/health_hud_intensity = 1
// Body/form vars.
var/list/inherent_verbs // Species-specific verbs.