Datumize tendon behavior, make tendon snapping more consistent (#11773)

This commit is contained in:
Wildkins
2021-05-01 00:00:29 -03:00
committed by GitHub
parent c2ca7e2655
commit c3861eba6a
15 changed files with 99 additions and 62 deletions
+19 -33
View File
@@ -63,6 +63,12 @@
var/supports_children = TRUE
var/list/internal_organs = list() // Internal organs of this body part
var/datum/tendon/tendon
var/tendon_path = /datum/tendon
var/tendon_name = "tendon" // Name of the limb's tendon. Achilles heel, etc.
var/tendon_dt // Damage threshold required to possibly snap a tendon
var/list/tendon_msgs = list("tore apart", "ripped away")
var/damage_msg = "<span class='warning'>You feel an intense pain!</span>"
var/broken_description
var/open = 0
@@ -72,7 +78,6 @@
var/encased // Needs to be opened with a saw to access the organs.
var/joint = "joint" // Descriptive string used in dislocation.
var/artery_name = "artery" //Name of the artery. Cartoid, etc.
var/tendon_name = "tendon" //Name of the limb's tendon. Achilles heel, etc.
var/amputation_point // Descriptive string used in amputation.
var/dislocated = 0 // If you target a joint, you can dislocate the limb, causing temporary damage to the organ.
@@ -227,6 +232,9 @@
get_icon()
if((limb_flags & ORGAN_HAS_TENDON) && !BP_IS_ROBOTIC(src))
tendon = new tendon_path(src, tendon_name, tendon_dt, tendon_msgs)
/obj/item/organ/external/replaced(var/mob/living/carbon/human/target)
..()
if(istype(owner))
@@ -291,8 +299,8 @@
handle_limb_gibbing(used_weapon, brute, burn)
if(brute_dam + brute > min_broken_damage && prob(brute_dam + brute * (1 + blunt)))
if(damage_flags & DAM_EDGE)
sever_tendon()
if((brute && !blunt) && istype(tendon) && brute_dam + brute > tendon.threshold)
tendon.sever()
if(brute_dam > FRACTURE_AND_TENDON_DAM_THRESHOLD)
fracture()
else
@@ -472,14 +480,14 @@ This function completely restores a damaged organ to perfect condition.
//Possibly trigger an internal wound, too.
var/local_damage = brute_dam + burn_dam + damage
if(damage > 15 && !(type in list(BURN, LASER)) && local_damage > 30 && !(status & ORGAN_ROBOT))
var/internal_damage
if(prob(damage) && sever_artery())
internal_damage = TRUE
if(prob(Ceiling(damage / 4)) && type == CUT && sever_tendon())
internal_damage = TRUE
if(internal_damage)
owner.custom_pain("You feel something rip in your [name]!", 25)
if(istype(tendon) && type == CUT && !(status & ORGAN_ROBOT))
var/DT = tendon.threshold
if(DT && local_damage > DT && damage > (DT / 2) && prob(damage))
tendon.sever()
//Burn damage can cause fluid loss due to blistering and cook-off
if((type in list(BURN, LASER)) && (damage > 5 || damage + burn_dam >= 15) && !BP_IS_ROBOTIC(src))
var/fluid_loss_severity
@@ -814,10 +822,7 @@ Note that amputating the affected organ does in fact remove the infection from t
//Bone fractures
if(config.bones_can_break && brute_dam > min_broken_damage * config.organ_health_multiplier && !(status & ORGAN_ROBOT))
if(cut_dam > brute_dam * 0.5)
sever_tendon()
else
fracture()
fracture()
update_damage_ratios()
/obj/item/organ/external/proc/update_damage_ratios()
@@ -1150,9 +1155,9 @@ Note that amputating the affected organ does in fact remove the infection from t
/obj/item/organ/external/is_usable()
if(is_dislocated())
return FALSE
if(status & ORGAN_TENDON_CUT)
if(istype(tendon) && !tendon.intact)
return FALSE
if(parent && (parent.status & ORGAN_TENDON_CUT))
if(parent && (istype(parent.tendon) && !parent.tendon.intact))
return FALSE
if(can_feel_pain() && get_pain() > pain_disability_threshold)
return FALSE
@@ -1356,25 +1361,6 @@ Note that amputating the affected organ does in fact remove the infection from t
status |= ORGAN_ARTERY_CUT
return TRUE
/obj/item/organ/external/proc/sever_tendon()
if(!(limb_flags & ORGAN_HAS_TENDON) || (status & ORGAN_ROBOT) || (status & ORGAN_TENDON_CUT))
return FALSE
. = TRUE
playsound(src.loc, 'sound/effects/snap.ogg', 40, 1, -2)
status |= ORGAN_TENDON_CUT
if(!owner)
return
var/message = pick("tore apart", "ripped away")
owner.visible_message(\
"<span class='warning'><font size=2>You hear a loud snapping sound coming from \the [owner]!</font></span>",\
"<span class='danger'><font size=3>Something feels like it [message] in your [name]!</font></span>",\
"You hear a sickening snap!")
if(owner.species && owner.can_feel_pain())
owner.emote("scream")
owner.flash_strong_pain()
// Damage procs
/obj/item/organ/external/proc/get_brute_damage()
return brute_dam
+2 -2
View File
@@ -251,8 +251,8 @@
O.status &= ~ORGAN_ARTERY_CUT
owner.visible_message(SPAN_WARNING("The severed artery in \the [owner]'s [O] stitches itself back together..."), SPAN_NOTICE("The severed artery in your [O] stitches itself back together..."))
healed = TRUE
else if(O.status & ORGAN_TENDON_CUT)
O.status &= ~ORGAN_TENDON_CUT
else if(istype(O.tendon) && !O.tendon.intact)
O.tendon.heal()
owner.visible_message(SPAN_WARNING("The severed tendon in \the [owner]'s [O] stitches itself back together..."), SPAN_NOTICE("The severed tendon in your [O] stitches itself back together..."))
healed = TRUE
else if(O.status & ORGAN_BROKEN)
+1 -5
View File
@@ -176,10 +176,6 @@
. = ..()
owner.update_hud_hands()
/obj/item/organ/external/hand/sever_tendon()
. = ..()
owner.update_hud_hands()
/obj/item/organ/external/hand/removed()
owner.drop_from_inventory(owner.gloves)
owner.update_hud_hands()
@@ -256,4 +252,4 @@
/obj/item/organ/external/head/droplimb(var/clean, var/disintegrate = DROPLIMB_EDGE, var/ignore_children = null)
if(iszombie(owner))
return ..(disintegrate = DROPLIMB_BLUNT)
return ..()
return ..()
+55
View File
@@ -0,0 +1,55 @@
/datum/tendon
var/name = "tendon"
var/threshold
var/intact = TRUE
var/list/messages
var/obj/item/organ/external/parent
/datum/tendon/New(var/obj/item/organ/external/E, var/name, var/damage_threshold, var/list/damage_msgs)
if(!istype(E))
crash_with("Tendon created with invalid parent organ: [E]")
qdel(src)
return
parent = E
if(name)
src.name = name
if(islist(damage_msgs))
messages = damage_msgs
if(damage_threshold)
threshold = damage_threshold
else
threshold = parent.min_broken_damage
/datum/tendon/proc/heal()
if(!parent?.owner || intact)
return FALSE
. = intact = TRUE
/datum/tendon/proc/sever()
if(!parent?.owner || !intact)
return FALSE
playsound(parent.owner.loc, 'sound/effects/snap.ogg', 40, 1, -2)
intact = FALSE
if(parent.owner.species && parent.owner.can_feel_pain())
parent.owner.emote("scream")
parent.owner.flash_strong_pain()
parent.owner.custom_pain("You feel something [pick(messages)] in your [parent.owner.name]!", 25)
parent.owner.visible_message(SPAN_WARNING("You hear a loud snapping sound coming from [parent.owner]!"),
blind_message = "You hear a sickening snap!")
else
parent.owner.visible_message(SPAN_WARNING("You hear a loud snapping sound coming from [parent.owner]!"),\
SPAN_DANGER("Something feels like it [pick(messages)] in your [parent.name]!"),\
"You hear a sickening snap!")
if(istype(parent, /obj/item/organ/external/hand))
parent.owner.update_hud_hands()
return TRUE