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
+1 -1
View File
@@ -90,7 +90,7 @@
//Organ defines
#define PROCESS_ACCURACY 10
#define DEFAULT_BLOOD_SPECIES 560 //Default blood for species
#define DEFAULT_BLOOD_AMOUNT 560 //Default blood amount in units
//These are used Bump() code for living mobs, in the mob_bump_flag, mob_swap_flags, and mob_push_flags vars to determine whom can bump/swap with whom.
#define HUMAN 1
+2 -2
View File
@@ -36,8 +36,8 @@
var/list/human_icon_cache = list()
var/list/tail_icon_cache = list() //key is [species.race_key][r_skin][g_skin][b_skin]
var/list/light_overlay_cache = list()
// Cached body hair icons, used by resomi.
var/list/body_hair_cache = list()
// Cached limb icons, used by the damage health doll.
var/list/limb_icons_cache = list()
// Cached human damage icons.
var/list/damage_icon_parts = list()
// Cached human body markings.
+7 -44
View File
@@ -336,28 +336,7 @@
if (!data["invalid"])
var/datum/reagents/R = occupant.bloodstr
var/brain_result
if(occupant.should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/brain/brain = occupant.internal_organs_by_name[BP_BRAIN]
if(!brain || occupant.stat == DEAD || (occupant.status_flags & FAKEDEATH))
brain_result = 0
else if(occupant.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]%"
var/brain_result = occupant.get_brain_status()
var/pulse_result
if(occupant.should_have_organ(BP_HEART))
@@ -518,6 +497,9 @@
if(O.rejecting)
wounds += "Shows symptoms of organ rejection."
if(O.get_scarring_level() > 0.01)
wounds += "[O.get_scarring_results()]."
data["hasWounds"] = length(wounds) ? 1 : 0
data["wounds"] = wounds
organs += list(data)
@@ -556,28 +538,7 @@
if (!occupant || !istype(occupant, /mob/living/carbon/human))
return
var/mob/living/carbon/human/H = occupant
var/brain_result
if(H.should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/brain/brain = H.internal_organs_by_name[BP_BRAIN]
if(!brain || H.stat == DEAD || (H.status_flags & FAKEDEATH))
brain_result = 0
else if(H.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]%"
var/brain_result = H.get_brain_status()
var/list/occupant_data = list(
"stationtime" = worldtime2text(),
@@ -727,6 +688,8 @@
infection += "(being rejected)"
var/necrotic = ""
if(i.get_scarring_level() > 0.01)
necrotic += ", [i.get_scarring_results()]"
if(i.status & ORGAN_DEAD)
necrotic = ", <font color='red'>necrotic and decaying</font>"
+3 -27
View File
@@ -45,33 +45,9 @@
dat += "<A HREF='?src=\ref[user];mach_close=op'>Close</A><br><br>" //| <A HREF='?src=\ref[user];update=1'>Update</A>"
if(src.table && (src.table.check_victim()))
src.victim = src.table.victim
var/brain_result = "normal"
if(victim.should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/brain/brain = victim.internal_organs_by_name[BP_BRAIN]
if(!brain || victim.stat == DEAD || (victim.status_flags & FAKEDEATH))
brain_result = "<span class='scan_danger'>none, patient is braindead</span>"
else if(victim.stat != DEAD)
if(istype(brain))
switch(brain.get_current_damage_threshold())
if(0)
brain_result = "normal"
if(1 to 2)
brain_result = "<span class='scan_notice'>minor brain damage</span>"
if(3 to 5)
brain_result = "<span class='scan_warning'>weak</span>"
if(6 to 8)
brain_result = "<span class='scan_danger'>extremely weak</span>"
if(9 to INFINITY)
brain_result = "<span class='scan_danger'>fading</span>"
else
brain_result = "<span class='scan_danger'>ERROR - Hardware fault</span>"
else
if(victim.isFBP())
brain_result = "normal"
else
brain_result = "<span class='scan_danger'>ERROR - Organ not recognized</span>"
else
brain_result = "<span class='scan_danger'>ERROR - Non-standard biology</span>"
var/brain_result = victim.get_brain_status()
if(victim.isFBP())
brain_result = "normal"
dat += {"
<B>Patient Information:</B><BR>
Brain Activity: <b>[brain_result]</b><br>
+1 -27
View File
@@ -110,33 +110,7 @@ BREATH ANALYZER
. += "[b]Scan results for \the [H]:[endb]"
// Brain activity.
var/brain_result = "normal"
if(H.should_have_organ(BP_BRAIN))
var/obj/item/organ/internal/brain/brain = H.internal_organs_by_name[BP_BRAIN]
if(!brain || H.stat == DEAD || (H.status_flags & FAKEDEATH))
brain_result = "<span class='scan_danger'>none, patient is braindead</span>"
else if(H.stat != DEAD)
if(istype(brain))
switch(brain.get_current_damage_threshold())
if(0)
brain_result = "normal"
if(1 to 2)
brain_result = "<span class='scan_notice'>minor brain damage</span>"
if(3 to 5)
brain_result = "<span class='scan_warning'>weak</span>"
if(6 to 8)
brain_result = "<span class='scan_danger'>extremely weak</span>"
if(9 to INFINITY)
brain_result = "<span class='scan_danger'>fading</span>"
else
brain_result = "<span class='scan_danger'>ERROR - Hardware fault</span>"
else
if(H.isFBP())
brain_result = "normal"
else
brain_result = "<span class='scan_danger'>ERROR - Organ not recognized</span>"
else
brain_result = "<span class='scan_danger'>ERROR - Non-standard biology</span>"
var/brain_result = H.get_brain_status()
dat += "Brain activity: [brain_result]."
if(H.stat == DEAD || (H.status_flags & FAKEDEATH))
+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.
+3 -4
View File
@@ -9,13 +9,12 @@
if(vessel)
return
vessel = new/datum/reagents(DEFAULT_BLOOD_SPECIES + 40)
vessel.my_atom = src
vessel = new/datum/reagents(species.blood_volume, src)
if(species && species.flags & NO_BLOOD) //We want the var for safety but we can do without the actual blood.
return
vessel.add_reagent("blood", DEFAULT_BLOOD_SPECIES)
vessel.add_reagent("blood", species.blood_volume)
fixblood()
//Resets blood data
@@ -209,7 +208,7 @@
var/list/chems = list()
chems = params2list(injected.data["trace_chem"])
for(var/C in chems)
src.reagents.add_reagent(C, (text2num(chems[C]) / DEFAULT_BLOOD_SPECIES) * amount)//adds trace chemicals to owner's blood
src.reagents.add_reagent(C, (text2num(chems[C]) / species.blood_volume) * amount)//adds trace chemicals to owner's blood
reagents.update_total()
//Transfers blood from reagents to vessel, respecting blood types compatability.
+16 -1
View File
@@ -44,9 +44,24 @@
if((status & ORGAN_DEAD) && dead_icon)
icon_state = dead_icon
/obj/item/organ/internal/proc/surgical_fix() //to be used for scarring -mattatlas
/obj/item/organ/internal/proc/surgical_fix(mob/user)
if(damage > min_broken_damage)
var/scarring = damage/max_damage
scarring = 1 - 0.3 * scarring ** 2 // Between ~15 and 30 percent loss
var/new_max_dam = Floor(scarring * max_damage)
if(new_max_dam < max_damage)
to_chat(user, "<span class='warning'>Not every part of [src] could be saved, some dead tissue had to be removed, making it more suspectable to damage in the future.</span>")
set_max_damage(new_max_dam)
heal_damage(damage)
/obj/item/organ/internal/proc/get_scarring_level()
. = (initial(max_damage) - max_damage)/initial(max_damage)
/obj/item/organ/internal/proc/get_scarring_results()
var/scar_level = get_scarring_level()
if(scar_level > 0.01)
. += "[get_wound_severity(get_scarring_level())] scarring"
/obj/item/organ/internal/is_usable()
return ..() && !is_broken()
+156 -10
View File
@@ -28,6 +28,57 @@
var/healed_threshold = 1
var/oxygen_reserve = 6
/obj/item/organ/internal/brain/Initialize(mapload)
. = ..()
if(species)
set_max_damage(species.total_health)
else
set_max_damage(200)
if(!mapload)
addtimer(CALLBACK(src, .proc/clear_screen), 5)
/obj/item/organ/internal/brain/Destroy()
if(brainmob)
qdel(brainmob)
brainmob = null
return ..()
/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/can_recover()
return ~status & ORGAN_DEAD
@@ -41,15 +92,6 @@
..()
damage_threshold_value = round(max_damage / damage_threshold_count)
/obj/item/organ/internal/brain/Initialize(mapload)
. = ..()
if(species)
set_max_damage(species.total_health)
else
set_max_damage(200)
if(!mapload)
addtimer(CALLBACK(src, .proc/clear_screen), 5)
/obj/item/organ/internal/brain/process()
if(owner)
if(damage > max_damage / 2 && healed_threshold)
@@ -157,4 +199,108 @@
if(is_broken())
if(!owner.lying)
to_chat(owner, "<span class='danger'>You black out!</span>")
owner.Paralyse(10)
owner.Paralyse(10)
/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>")
set_max_damage(Floor(max_damage - 0.25*damage))
heal_damage(damage)
/obj/item/organ/internal/brain/get_scarring_level()
. = (species.total_health - max_damage)/species.total_health
////////////////////////////////////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
//Miscellaneous
/obj/item/organ/internal/brain/proc/clear_screen()
if (brainmob && brainmob.client)
brainmob.client.screen.Cut()
/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/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>")
..()
+1 -1
View File
@@ -119,7 +119,7 @@
var/blood_volume = round(owner.vessel.get_reagent_amount("blood"))
//Blood regeneration if there is some space
if(blood_volume < DEFAULT_BLOOD_SPECIES && blood_volume)
if(blood_volume < species.blood_volume && blood_volume)
var/datum/reagent/blood/B = locate() in owner.vessel.reagent_list //Grab some blood
if(B) // Make sure there's some blood at all
if(weakref && B.data["donor"] != weakref) //If it's not theirs, then we look for theirs - donor is a weakref here, but it should be safe to just directly compare it.
+2
View File
@@ -86,6 +86,8 @@
var/atom/movable/applied_pressure //Pressure applied to wounds. It'll make them bleed less, generally.
var/image/hud_damage_image
/obj/item/organ/external/proc/invalidate_marking_cache()
cached_markings = null
+39 -3
View File
@@ -113,6 +113,7 @@
add_overlay(finished_icon) //So when it's not on your body, it has icons
mob_icon.Blend(finished_icon, ICON_OVERLAY) //So when it's on your body, it has icons
/obj/item/organ/external/var/icon_cache_key
/obj/item/organ/external/proc/get_icon(var/skeletal)
var/gender = "f"
@@ -158,18 +159,19 @@
mob_icon.Blend(rgb(s_tone, s_tone, s_tone), ICON_ADD)
else
mob_icon.Blend(rgb(-s_tone, -s_tone, -s_tone), ICON_SUBTRACT)
apply_markings()
if(body_hair && hair_color)
var/list/limb_icon_cache = SSicon_cache.body_hair_cache
if(body_hair)
var/list/limb_icon_cache = SSicon_cache.limb_icons_cache
var/cache_key = "[body_hair]-[icon_name]-[hair_color]"
if(!limb_icon_cache[cache_key])
var/icon/I = icon(species.icobase, "[icon_name]_[body_hair]")
I.Blend(hair_color, ICON_ADD)
limb_icon_cache[cache_key] = I
mob_icon.Blend(limb_icon_cache[cache_key], ICON_OVERLAY)
icon_cache_key = cache_key
icon = mob_icon
@@ -217,3 +219,37 @@
LAZYADD(cached_markings, genetic_markings)
if (LAZYLEN(temporary_markings))
LAZYADD(cached_markings, temporary_markings)
// Global scope, used in code below.
var/list/flesh_hud_colours = list("#00ff00","#aaff00","#ffff00","#ffaa00","#ff0000","#aa0000","#660000")
var/list/robot_hud_colours = list("#ffffff","#cccccc","#aaaaaa","#888888","#666666","#444444","#222222","#000000")
/obj/item/organ/external/proc/get_damage_hud_image()
// Generate the greyscale base icon and cache it for later.
// icon_cache_key is set by any get_icon() calls that are made.
// This looks convoluted, but it's this way to avoid icon proc calls.
var/list/limb_icon_cache = SSicon_cache.limb_icons_cache
if(!hud_damage_image)
var/cache_key = "dambase-[icon_cache_key]"
if(!icon_cache_key || !limb_icon_cache[cache_key])
limb_icon_cache[cache_key] = icon(get_icon(), null, SOUTH)
var/image/temp = image(limb_icon_cache[cache_key])
if(species)
// Calculate the required colour matrix.
var/r = 0.30 * species.health_hud_intensity
var/g = 0.59 * species.health_hud_intensity
var/b = 0.11 * species.health_hud_intensity
temp.color = list(r, r, r, g, g, g, b, b, b)
hud_damage_image = image(null)
hud_damage_image.overlays += temp
// Calculate the required color index.
var/dam_state = min(1,((brute_dam+burn_dam)/max(1,max_damage)))
var/min_dam_state = min(1,(get_pain()/max(1,max_damage)))
if(min_dam_state && dam_state < min_dam_state)
dam_state = min_dam_state
// Apply colour and return product.
var/list/hud_colours = !BP_IS_ROBOTIC(src) ? flesh_hud_colours : robot_hud_colours
hud_damage_image.color = hud_colours[max(1,min(Ceiling(dam_state*hud_colours.len),hud_colours.len))]
return hud_damage_image
@@ -747,7 +747,7 @@
if (caffeine)
if(!modifier)
modifier = M.add_modifier(/datum/modifier/stimulant, MODIFIER_REAGENT, src, _strength = caffeine, override = MODIFIER_OVERRIDE_STRENGTHEN)
M.add_chemical_effect(CE_PULSE, caffeine*2)
M.add_chemical_effect(CE_PULSE, 1)
M.dizziness = max(0, M.dizziness + adj_dizzy)
M.drowsyness = max(0, M.drowsyness + adj_drowsy)
M.sleeping = max(0, M.sleeping + adj_sleepy)
+1 -1
View File
@@ -70,7 +70,7 @@
if(I && I.damage > 0 && !BP_IS_ROBOTIC(I))
user.visible_message("<span class='notice'>[user] treats damage to [target]'s [I.name] with [tool_name].</span>", \
"<span class='notice'>You treat damage to [target]'s [I.name] with [tool_name].</span>" )
I.surgical_fix()
I.surgical_fix(user)
var/obj/item/organ/internal/brain/sponge = target.internal_organs_by_name[BP_BRAIN]
if(sponge && istype(I, sponge))
target.cure_all_traumas(cure_type = CURE_SURGERY)
+2 -4
View File
@@ -21,7 +21,7 @@
return 0
var/obj/item/organ/external/affected = target.get_organ(target_zone)
if(!affected)
if(!affected)
return
return affected.open >= 2 && (affected.status & ORGAN_ARTERY_CUT)
@@ -40,7 +40,7 @@
affected.status &= ~ORGAN_ARTERY_CUT
affected.update_damages()
if(ishuman(user) && prob(40))
if(ishuman(user) && prob(40))
user:bloody_hands(target, 0)
/datum/surgery_step/fix_vein/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
@@ -103,8 +103,6 @@
user.visible_message("<span class='notice'>[user] has cut away necrotic tissue from [target]'s [organ_to_fix.name] with \the [tool].</span>", \
"<span class='notice'>You have cut away necrotic tissue in [target]'s [organ_to_fix.name] with \the [tool].</span>")
organ_to_fix.status &= ~ORGAN_DEAD
if(organ_to_fix.max_damage > 15)
organ_to_fix.max_damage -= rand(1, 10) //remove some max damage, since we cut away the organ
/datum/surgery_step/fix_dead_tissue/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
@@ -0,0 +1,42 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################
# Your name.
author: MattAtlas
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True
# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Added a fancy new health doll."
- rscadd: "Organ scarring now shows on scanners."
Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B