From 9976291ca493af3544b9678d13d62c8d5f467b0c Mon Sep 17 00:00:00 2001 From: HarpyEagle Date: Tue, 24 May 2016 10:54:22 -0400 Subject: [PATCH] Refactors dislocation, clearer distinction between is_dislocated() and is_usable() Dislocation no longer relies on adjusting dislocated state of children. Fixes dislocating and relocating parent organs magically fixing children or protecting children from being dislocated. Dislocated limbs no longer count as unusable, since they already count for stance damage and dropping items anyways. In addition, dislocated limbs add to traumatic_shock Also corrects a misusage of traumatic_shock --- code/modules/mob/living/carbon/carbon.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 2 +- .../living/carbon/human/human_attackhand.dm | 2 +- code/modules/mob/living/carbon/human/life.dm | 5 +- code/modules/mob/living/carbon/shock.dm | 4 +- code/modules/organs/organ_external.dm | 48 +++++++++++-------- 6 files changed, 37 insertions(+), 26 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 6b9cbf02589..294b9c8669b 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -194,7 +194,7 @@ status += "hurts when touched" if(org.status & ORGAN_DEAD) status += "is bruised and necrotic" - if(!org.is_usable()) + if(!org.is_usable() || org.is_dislocated()) status += "dangling uselessly" if(status.len) src.show_message("My [org.name] is [english_list(status)].",1) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index d6a88f35ffd..01614964e39 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1324,7 +1324,7 @@ var/list/limbs = list() for(var/limb in organs_by_name) var/obj/item/organ/external/current_limb = organs_by_name[limb] - if(current_limb && current_limb.dislocated == 2) + if(current_limb && current_limb.dislocated > 0 && !current_limb.is_parent_dislocated()) //if the parent is also dislocated you will have to relocate that first limbs |= limb var/choice = input(usr,"Which joint do you wish to relocate?") as null|anything in limbs diff --git a/code/modules/mob/living/carbon/human/human_attackhand.dm b/code/modules/mob/living/carbon/human/human_attackhand.dm index 7cc3156f189..d8d40ab660a 100644 --- a/code/modules/mob/living/carbon/human/human_attackhand.dm +++ b/code/modules/mob/living/carbon/human/human_attackhand.dm @@ -326,7 +326,7 @@ if(!target_zone) return 0 var/obj/item/organ/external/organ = get_organ(check_zone(target_zone)) - if(!organ || organ.is_dislocated() || organ.dislocated == -1) + if(!organ || organ.dislocated > 0 || organ.dislocated == -1) //don't use is_dislocated() here, that checks parent return 0 user.visible_message("[user] begins to dislocate [src]'s [organ.joint]!") diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 80798fa57bb..8e892436e0e 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -847,7 +847,10 @@ if(!isSynthetic() && (species.flags & IS_PLANT) && (!light_organ || light_organ.is_broken())) if(nutrition < 200) take_overall_damage(2,0) - traumatic_shock++ + + //traumatic_shock is updated every tick, incrementing that is pointless - shock_stage is the counter. + //Not that it matters much for diona, who have NO_PAIN. + shock_stage++ // TODO: stomach and bloodstream organ. if(!isSynthetic()) diff --git a/code/modules/mob/living/carbon/shock.dm b/code/modules/mob/living/carbon/shock.dm index 92eccc66df8..370d3f89d24 100644 --- a/code/modules/mob/living/carbon/shock.dm +++ b/code/modules/mob/living/carbon/shock.dm @@ -23,8 +23,10 @@ if(istype(src,/mob/living/carbon/human)) var/mob/living/carbon/human/M = src for(var/obj/item/organ/external/organ in M.organs) - if(organ && (organ.is_broken() || organ.open)) + if(organ.is_broken() || organ.open) src.traumatic_shock += 30 + else if(organ.is_dislocated()) + src.traumatic_shock += 15 if(src.traumatic_shock < 0) src.traumatic_shock = 0 diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index a1a31fad7c6..d3b309fd846 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -60,7 +60,7 @@ var/cannot_gib // Impossible to gib, distinct from amputation. var/joint = "joint" // Descriptive string used in dislocation. 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. + var/dislocated = 0 // If you target a joint, you can dislocate the limb, impairing it's usefulness and causing pain var/encased // Needs to be opened with a saw to access the organs. // Surgery vars. @@ -156,32 +156,38 @@ /obj/item/organ/external/proc/is_dislocated() if(dislocated > 0) return 1 - if(parent) - return parent.is_dislocated() + if(is_parent_dislocated()) + return 1//if any parent is dislocated, we are considered dislocated as well return 0 -/obj/item/organ/external/proc/dislocate(var/primary) - if(dislocated != -1) - if(primary) - dislocated = 2 - else - dislocated = 1 - owner.verbs |= /mob/living/carbon/human/proc/undislocate - if(children && children.len) - for(var/obj/item/organ/external/child in children) - child.dislocate() +/obj/item/organ/external/proc/is_parent_dislocated() + var/obj/item/organ/external/O = parent + while(O && O.dislocated != -1) + if(O.dislocated == 1) + return 1 + O = O.parent + return 0 + + +/obj/item/organ/external/proc/dislocate() + if(dislocated == -1) + return + + dislocated = 1 + if(owner) + owner.verbs |= /mob/living/carbon/human/proc/undislocate /obj/item/organ/external/proc/undislocate() - if(dislocated != -1) - dislocated = 0 - if(children && children.len) - for(var/obj/item/organ/external/child in children) - if(child.dislocated == 1) - child.undislocate() + if(dislocated == -1) + return + + dislocated = 0 if(owner) owner.shock_stage += 20 + + //check to see if we still need the verb for(var/obj/item/organ/external/limb in owner.organs) - if(limb.dislocated == 2) + if(limb.dislocated == 1) return owner.verbs -= /mob/living/carbon/human/proc/undislocate @@ -1085,7 +1091,7 @@ Note that amputating the affected organ does in fact remove the infection from t return 0 /obj/item/organ/external/proc/is_usable() - return !is_dislocated() && !(status & (ORGAN_MUTATED|ORGAN_DEAD)) + return !(status & (ORGAN_MUTATED|ORGAN_DEAD)) /obj/item/organ/external/proc/is_malfunctioning() return ((robotic >= ORGAN_ROBOT) && (brute_dam + burn_dam) >= 10 && prob(brute_dam + burn_dam))