From a3e7c70f6da0fc7ea9929ddb39beddcf3113707f Mon Sep 17 00:00:00 2001 From: necromanceranne <40847847+necromanceranne@users.noreply.github.com> Date: Sun, 11 Dec 2022 23:31:09 +1100 Subject: [PATCH] Bodypart code cleanup, robotic limbs can actually be disabled through damage again. (#71739) ## About The Pull Request Cleans up various variables and code comments in bodypart code so that it is easier to understand (hopefully) what the fuck is happening there. Fixes a hilarious oversight. For what may have been an entire 2 year span, robotic limbs were unable to be disabled whatsoever. Good stuff. ## Why It's Good For The Game Lost all your limbs and now have only surplus prosthetics? Congratulations! You're now more durable than even someone with proper robotic limbs, as your arms do not contribute anything more than 10 damage (or 15 stamina) to your overall damage taken. Furthermore, taking the maximum amount of damage is actually entirely meaningless to you. Laugh as someone attempting to shoot your arms does almost no meaningful damage once you hit the cap! It's all sunk cost! You can't have it blown off anyway, because dismembering surplus limbs is gone! Who knew getting into a horrible bluespace/goliath accident could have such an impact on your combat prowess. Thanks Nanotrasen! Anyway, these vars are ugly. ## Changelog :cl: code: Makes a lot of the bodypart variables clearer as to what they do. Includes more detailed code comments. fix: Robotic limbs are no longer immune to being disabled through reaching maximum damage. /:cl: --- code/modules/surgery/bodyparts/_bodyparts.dm | 35 ++++++++++++------- code/modules/surgery/bodyparts/head.dm | 4 +-- code/modules/surgery/bodyparts/parts.dm | 4 +-- .../surgery/bodyparts/robot_bodyparts.dm | 7 +++- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/code/modules/surgery/bodyparts/_bodyparts.dm b/code/modules/surgery/bodyparts/_bodyparts.dm index 0c1a3d2f8de..59e8eefd133 100644 --- a/code/modules/surgery/bodyparts/_bodyparts.dm +++ b/code/modules/surgery/bodyparts/_bodyparts.dm @@ -55,27 +55,35 @@ /// For limbs that don't really exist, eg chainsaws var/is_pseudopart = FALSE - ///If disabled, limb is as good as missing. + // Limb disabling variables + ///Controls if the limb is disabled. TRUE means it is disabled (similar to being removed, but still present for the sake of targeted interactions). var/bodypart_disabled = FALSE - ///Multiplied by max_damage it returns the threshold which defines a limb being disabled or not. From 0 to 1. 0 means no disable thru damage - var/disable_threshold = 0 - ///Controls whether bodypart_disabled makes sense or not for this limb. - var/can_be_disabled = FALSE - ///Multiplier of the limb's damage that gets applied to the mob + ///Handles limb disabling by damage. If 0 (0%), a limb can't be disabled via damage. If 1 (100%), it is disabled at max limb damage. Anything between is the percentage of damage against maximum limb damage needed to disable the limb. + var/disabling_threshold_percentage = 0 + ///Whether it is possible for the limb to be disabled whatsoever. TRUE means that it is possible. + var/can_be_disabled = FALSE //Defaults to FALSE, as only human limbs can be disabled, and only the appendages. + + // Damage state variables + + ///A mutiplication of the burn and brute damage that the limb's stored damage contributes to its attached mob's overall wellbeing. var/body_damage_coeff = 1 + ///Used in determining overlays for limb damage states. As the mob receives more burn/brute damage, their limbs update to reflect. var/brutestate = 0 var/burnstate = 0 ///The current amount of brute damage the limb has var/brute_dam = 0 ///The current amount of burn damage the limb has var/burn_dam = 0 - ///The maximum "physical" damage a bodypart can take. Set by children + ///The maximum brute OR burn damage a bodypart can take. Once we hit this cap, no more damage of either type! var/max_damage = 0 + ///Gradually increases while burning when at full damage, destroys the limb when at 100 var/cremation_progress = 0 - ///Subtracted to brute damage taken + + // Damage reduction variables for damage handled on the limb level. Handled after worn armor. + ///Amount subtracted from brute damage inflicted on the limb. var/brute_reduction = 0 - ///Subtracted to burn damage taken + ///Amount subtracted from burn damage inflicted on the limb. var/burn_reduction = 0 //Coloring and proper item icon update @@ -86,8 +94,8 @@ ///An "override" color that can be applied to ANY limb, greyscale or not. var/variable_color = "" - ///whether it can be dismembered with a weapon. - var/dismemberable = 1 + ///whether the limb can be mutilated, including dismemberment for appendages and heads, and disembowelment for chests. TRUE means it can be subjected to these effects. + var/dismemberable = TRUE var/px_x = 0 var/px_y = 0 @@ -112,6 +120,7 @@ var/brute_damage_desc = DEFAULT_BRUTE_EXAMINE_TEXT var/burn_damage_desc = DEFAULT_BURN_EXAMINE_TEXT + // Wounds related variables /// The wounds currently afflicting this body part var/list/wounds @@ -545,7 +554,7 @@ var/total_damage = brute_dam + burn_dam // this block of checks is for limbs that can be disabled, but not through pure damage (AKA limbs that suffer wounds, human/monkey parts and such) - if(!disable_threshold) + if(!disabling_threshold_percentage) if(total_damage < max_damage) last_maxed = FALSE else @@ -556,7 +565,7 @@ return // we're now dealing solely with limbs that can be disabled through pure damage, AKA robot parts - if(total_damage >= max_damage * disable_threshold) + if(total_damage >= max_damage * disabling_threshold_percentage) if(!last_maxed) if(owner.stat < UNCONSCIOUS) INVOKE_ASYNC(owner, TYPE_PROC_REF(/mob, emote), "scream") diff --git a/code/modules/surgery/bodyparts/head.dm b/code/modules/surgery/bodyparts/head.dm index 9ee63c7812c..aa32af96099 100644 --- a/code/modules/surgery/bodyparts/head.dm +++ b/code/modules/surgery/bodyparts/head.dm @@ -335,7 +335,7 @@ should_draw_greyscale = FALSE px_x = 0 px_y = 0 - dismemberable = 0 + dismemberable = FALSE max_damage = 500 bodytype = BODYTYPE_HUMANOID | BODYTYPE_ALIEN | BODYTYPE_ORGANIC @@ -348,6 +348,6 @@ should_draw_greyscale = FALSE px_x = 0 px_y = 0 - dismemberable = 0 + dismemberable = FALSE max_damage = 50 bodytype = BODYTYPE_LARVA_PLACEHOLDER | BODYTYPE_ORGANIC diff --git a/code/modules/surgery/bodyparts/parts.dm b/code/modules/surgery/bodyparts/parts.dm index 9b2f3f60fc3..33f24c9fc6e 100644 --- a/code/modules/surgery/bodyparts/parts.dm +++ b/code/modules/surgery/bodyparts/parts.dm @@ -53,7 +53,7 @@ bodytype = BODYTYPE_HUMANOID | BODYTYPE_ALIEN | BODYTYPE_ORGANIC is_dimorphic = FALSE should_draw_greyscale = FALSE - dismemberable = 0 + dismemberable = FALSE max_damage = 500 acceptable_bodytype = BODYTYPE_HUMANOID @@ -64,7 +64,7 @@ limb_id = BODYPART_ID_LARVA is_dimorphic = FALSE should_draw_greyscale = FALSE - dismemberable = 0 + dismemberable = FALSE max_damage = 50 bodytype = BODYTYPE_LARVA_PLACEHOLDER | BODYTYPE_ORGANIC acceptable_bodytype = BODYTYPE_LARVA_PLACEHOLDER diff --git a/code/modules/surgery/bodyparts/robot_bodyparts.dm b/code/modules/surgery/bodyparts/robot_bodyparts.dm index f1033c70864..27acb3fc3bc 100644 --- a/code/modules/surgery/bodyparts/robot_bodyparts.dm +++ b/code/modules/surgery/bodyparts/robot_bodyparts.dm @@ -39,6 +39,7 @@ brute_damage_desc = ROBOTIC_BRUTE_EXAMINE_TEXT burn_damage_desc = ROBOTIC_BURN_EXAMINE_TEXT + disabling_threshold_percentage = 1 /obj/item/bodypart/arm/right/robot name = "cyborg right arm" @@ -58,6 +59,7 @@ brute_reduction = 5 burn_reduction = 4 + disabling_threshold_percentage = 1 light_brute_msg = ROBOTIC_LIGHT_BRUTE_MSG medium_brute_msg = ROBOTIC_MEDIUM_BRUTE_MSG @@ -67,6 +69,7 @@ medium_burn_msg = ROBOTIC_MEDIUM_BURN_MSG heavy_burn_msg = ROBOTIC_HEAVY_BURN_MSG + /obj/item/bodypart/leg/left/robot name = "cyborg left leg" desc = "A skeletal limb wrapped in pseudomuscles, with a low-conductivity case." @@ -85,6 +88,7 @@ brute_reduction = 5 burn_reduction = 4 + disabling_threshold_percentage = 1 light_brute_msg = ROBOTIC_LIGHT_BRUTE_MSG medium_brute_msg = ROBOTIC_MEDIUM_BRUTE_MSG @@ -94,6 +98,7 @@ medium_burn_msg = ROBOTIC_MEDIUM_BURN_MSG heavy_burn_msg = ROBOTIC_HEAVY_BURN_MSG + /obj/item/bodypart/leg/right/robot name = "cyborg right leg" desc = "A skeletal limb wrapped in pseudomuscles, with a low-conductivity case." @@ -112,6 +117,7 @@ brute_reduction = 5 burn_reduction = 4 + disabling_threshold_percentage = 1 light_brute_msg = ROBOTIC_LIGHT_BRUTE_MSG medium_brute_msg = ROBOTIC_MEDIUM_BRUTE_MSG @@ -371,7 +377,6 @@ burn_reduction = 0 max_damage = 20 - #undef ROBOTIC_LIGHT_BRUTE_MSG #undef ROBOTIC_MEDIUM_BRUTE_MSG #undef ROBOTIC_HEAVY_BRUTE_MSG