From 2c4952b803b0deaeab41fcc8c8d727dbe7140d2f Mon Sep 17 00:00:00 2001 From: Fox-McCloud Date: Sun, 16 Jul 2017 04:07:54 -0400 Subject: [PATCH] finally --- code/modules/mob/living/carbon/carbon.dm | 2 +- .../mob/living/carbon/carbon_defines.dm | 2 - .../mob/living/carbon/human/human_defines.dm | 3 - .../mob/living/carbon/human/human_organs.dm | 46 ++----- code/modules/surgery/organs/organ.dm | 5 +- code/modules/surgery/organs/organ_external.dm | 123 +++++++----------- code/modules/surgery/organs/organ_icon.dm | 2 +- .../modules/surgery/organs/subtypes/skrell.dm | 2 +- .../surgery/organs/subtypes/standard.dm | 5 +- 9 files changed, 61 insertions(+), 129 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 15d9201b5cc..4de2dff6212 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -224,7 +224,7 @@ if(brutedamage > 0) status = "bruised" if(brutedamage > 20) - status = "bleeding" + status = "battered" if(brutedamage > 40) status = "mangled" if(brutedamage > 0 && burndamage > 0) diff --git a/code/modules/mob/living/carbon/carbon_defines.dm b/code/modules/mob/living/carbon/carbon_defines.dm index a409e8460db..c8171bcc47c 100644 --- a/code/modules/mob/living/carbon/carbon_defines.dm +++ b/code/modules/mob/living/carbon/carbon_defines.dm @@ -8,8 +8,6 @@ var/life_tick = 0 // The amount of life ticks that have processed on this mob. - // total amount of wounds on mob, used to spread out healing and the like over all wounds - var/number_wounds = 0 var/obj/item/handcuffed = null //Whether or not the mob is handcuffed var/obj/item/legcuffed = null //Same as handcuffs but for legs. Bear traps use this. diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 036202e1ae0..e7f3861eec1 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -52,9 +52,6 @@ var/global/default_martial_art = new/datum/martial_art var/special_voice = "" // For changing our voice. Used by a symptom. - var/last_dam = -1 //Used for determining if we need to process all organs or just some or even none. - var/list/bad_external_organs = list()// organs we check until they are good. - var/hand_blood_color var/name_override //For temporary visible name changes diff --git a/code/modules/mob/living/carbon/human/human_organs.dm b/code/modules/mob/living/carbon/human/human_organs.dm index 99a96ef48e3..124f78aa75e 100644 --- a/code/modules/mob/living/carbon/human/human_organs.dm +++ b/code/modules/mob/living/carbon/human/human_organs.dm @@ -9,50 +9,24 @@ // Takes care of organ related updates, such as broken and missing limbs /mob/living/carbon/human/proc/handle_organs() - - number_wounds = 0 - var/force_process = 0 - var/damage_this_tick = getBruteLoss() + getFireLoss() + getToxLoss() - if(damage_this_tick > last_dam) - force_process = 1 - last_dam = damage_this_tick - if(force_process) - bad_external_organs.Cut() - for(var/obj/item/organ/external/Ex in bodyparts) - bad_external_organs |= Ex - //processing internal organs is pretty cheap, do that first. for(var/obj/item/organ/internal/I in internal_organs) I.process() + for(var/obj/item/organ/external/E in bodyparts) + E.process() + + if(!lying && world.time - l_move_time < 15) + //Moving around with fractured ribs won't do you any good + if(E.is_broken() && E.internal_organs && E.internal_organs.len && prob(15)) + var/obj/item/organ/internal/I = pick(E.internal_organs) + custom_pain("You feel broken bones moving in your [E.name]!", 1) + I.take_damage(rand(3,5)) + //handle_stance() handle_grasp() handle_stance() - if(!force_process && !bad_external_organs.len) - return - - for(var/obj/item/organ/external/E in bad_external_organs) - if(!E) - continue - if(!E.need_process()) - bad_external_organs -= E - continue - else - E.process() - - if(!lying && world.time - l_move_time < 15) - //Moving around with fractured ribs won't do you any good - if(E.is_broken() && E.internal_organs && E.internal_organs.len && prob(15)) - var/obj/item/organ/internal/I = pick(E.internal_organs) - custom_pain("You feel broken bones moving in your [E.name]!", 1) - I.take_damage(rand(3,5)) - - //Moving makes open wounds get infected much faster - var/total_damage = E.brute_dam + E.burn_dam - if(total_damage && E.infection_check()) - germ_level++ - /mob/living/carbon/human/proc/handle_stance() // Don't need to process any of this if they aren't standing anyways diff --git a/code/modules/surgery/organs/organ.dm b/code/modules/surgery/organs/organ.dm index 4d7915812dc..a4fdfa5bc6c 100644 --- a/code/modules/surgery/organs/organ.dm +++ b/code/modules/surgery/organs/organ.dm @@ -110,9 +110,6 @@ var/list/organ_cache = list() if(germ_level >= INFECTION_LEVEL_THREE) necrotize() - if(damage >= max_damage) - necrotize() - else if(owner.bodytemperature >= 170) //cryo stops germs from moving and doing their bad stuffs //** Handle antibiotics and curing infections handle_antibiotics() @@ -130,7 +127,7 @@ var/list/organ_cache = list() return 1 if(is_found_within(/obj/structure/closet/crate/freezer)) return 1 - if(istype(loc,/turf)) + if(isturf(loc)) if(world.time - last_freezer_update_time > freezer_update_period) // I don't want to loop through everything in the tile constantly, especially since it'll be a pile of organs // if the virologist releases gibbingtons again or something diff --git a/code/modules/surgery/organs/organ_external.dm b/code/modules/surgery/organs/organ_external.dm index f08ac535558..2c5b31f6f94 100644 --- a/code/modules/surgery/organs/organ_external.dm +++ b/code/modules/surgery/organs/organ_external.dm @@ -25,7 +25,6 @@ var/brute_dam = 0 var/burn_dam = 0 var/max_size = 0 - var/last_dam = -1 var/icon/mob_icon var/gendered_icon = 0 var/limb_name @@ -36,11 +35,7 @@ var/list/s_col = null // If this is instantiated, it should be a list of length 3 var/list/child_icons = list() var/perma_injury = 0 - // 0: Don't fail when at full damage - // 1: Neatly pop off at full damage, stop damage propogation - // 2: Disintegrate at full damage, continue damage propogation - var/fail_at_full_damage = 0 - + var/dismember_at_max_damage = FALSE var/obj/item/organ/external/parent var/list/obj/item/organ/external/children @@ -72,7 +67,6 @@ if(owner) to_chat(owner, "You can't feel your [name] anymore...") owner.update_body(update_sprite) - owner.bad_external_organs |= src if(vital) owner.death() @@ -165,7 +159,7 @@ if(!parent.children) parent.children = list() parent.children.Add(src) - parent.update_damages() + parent.check_fracture() /obj/item/organ/external/attempt_become_organ(obj/item/organ/external/parent,mob/living/carbon/human/H) if(parent_organ != parent.limb_name) @@ -177,8 +171,8 @@ DAMAGE PROCS ****************************************************/ -/obj/item/organ/external/take_damage(brute, burn, sharp, used_weapon = null, list/forbidden_limbs = list()) - if(tough) +/obj/item/organ/external/take_damage(brute, burn, sharp, used_weapon = null, list/forbidden_limbs = list(), ignore_resists = FALSE) + if(tough && !ignore_resists) brute = max(0, brute - 5) burn = max(0, burn - 4) @@ -188,8 +182,9 @@ if(status & ORGAN_DESTROYED) return 0 - brute *= brute_mod - burn *= burn_mod + if(!ignore_resists) + brute *= brute_mod + burn *= burn_mod // Threshold needed to have a chance of hurting internal bits with something sharp #define LIMB_SHARP_THRESH_INT_DMG 5 @@ -215,10 +210,7 @@ if((brute_dam + burn_dam + brute + burn) < max_damage) brute_dam += brute burn_dam += burn - var/local_damage = brute_dam + burn_dam + brute - if(brute > 15 && local_damage > 30 && prob(brute) && !(status & ORGAN_ROBOT)) - internal_bleeding = TRUE - owner.custom_pain("You feel something rip in your [name]!", 1) + check_for_internal_bleeding(brute) else //If we can't inflict the full amount of damage, spread the damage in other ways //How much damage can we actually cause? @@ -232,6 +224,7 @@ can_inflict = max(0, can_inflict - brute) //How much brute damage is left to inflict brute = max(0, brute - temp) + check_for_internal_bleeding(brute) if(burn > 0 && can_inflict) //Inflict all burn damage we can @@ -240,33 +233,26 @@ burn = max(0, burn - can_inflict) //If there are still hurties to dispense if(burn || brute) - if(fail_at_full_damage == 1 && body_part != UPPER_TORSO && body_part != LOWER_TORSO) - droplimb(1) //Clean loss, just drop the limb and be done - else - //List organs we can pass it to - var/list/obj/item/organ/external/possible_points = list() - if(parent) - possible_points += parent - if(children) - for(var/organ in children) - if(organ) - possible_points += organ - if(forbidden_limbs.len) - possible_points -= forbidden_limbs - if(possible_points.len) - //And pass the pain around - var/obj/item/organ/external/target = pick(possible_points) - target.take_damage(brute, burn, sharp, used_weapon, forbidden_limbs + src) - if(fail_at_full_damage == 2 && body_part != UPPER_TORSO && body_part != LOWER_TORSO) - var/losstype - if(burn > brute) - losstype = DROPLIMB_BURN - else - losstype = DROPLIMB_BLUNT - droplimb(0, losstype) // less clean than a robot arm, doesn't buffer damage either + //List organs we can pass it to + var/list/obj/item/organ/external/possible_points = list() + if(parent) + possible_points += parent + if(children) + for(var/organ in children) + if(organ) + possible_points += organ + if(forbidden_limbs.len) + possible_points -= forbidden_limbs + if(possible_points.len) + //And pass the pain around + var/obj/item/organ/external/target = pick(possible_points) + target.take_damage(brute, burn, sharp, used_weapon, forbidden_limbs + src, ignore_resists = TRUE) //If the damage was reduced before, don't reduce it again - // sync the organ's damage with its wounds - update_damages() + if(dismember_at_max_damage && body_part != UPPER_TORSO && body_part != LOWER_TORSO) // We've ensured all damage to the mob is retained, now let's drop it, if necessary. + droplimb(1) //Clean loss, just drop the limb and be done + + // See if bones need to break + check_fracture() var/mob/living/carbon/owner_old = owner //Need to update health, but need a reference in case the below check cuts off a limb. //If limb took enough damage, try to cut or tear it off if(owner && loc == owner) @@ -295,8 +281,6 @@ status &= ~ORGAN_BROKEN perma_injury = 0 - //Sync the organ's damage with its wounds - update_damages() owner.updatehealth() return update_icon() @@ -339,23 +323,6 @@ This function completely restores a damaged organ to perfect condition. //Determines if we even need to process this organ. -/obj/item/organ/external/proc/need_process() - if(status & (ORGAN_CUT_AWAY|ORGAN_BROKEN|ORGAN_DESTROYED|ORGAN_SPLINTED|ORGAN_DEAD|ORGAN_MUTATED)) - return 1 - if(brute_dam || burn_dam) - return 1 - if(last_dam != brute_dam + burn_dam) // Process when we are fully healed up. - last_dam = brute_dam + burn_dam - return 1 - else - last_dam = brute_dam + burn_dam - if(germ_level) - return 1 - - if(update_icon()) - owner.UpdateDamageIcon(1) - return 0 - /obj/item/organ/external/process() if(owner) if(parent) @@ -364,8 +331,6 @@ This function completely restores a damaged organ to perfect condition. owner.update_body(1) return - update_wounds() - //Chem traces slowly vanish if(owner.life_tick % 10 == 0) for(var/chemID in trace_chemicals) @@ -468,23 +433,17 @@ Note that amputating the affected organ does in fact remove the infection from t germ_level++ owner.adjustToxLoss(1) -//Updating wounds. Handles wound natural I had some free spachealing, internal bleedings and infections -/obj/item/organ/external/proc/update_wounds() - - if((status & ORGAN_ROBOT)) //Robotic limbs don't heal or get worse. - return - - // sync the organ's damage with its wounds - update_damages() - if(update_icon()) - owner.UpdateDamageIcon(1) - //Updates brute_damn and burn_damn from wound damages. Updates BLEEDING status. -/obj/item/organ/external/proc/update_damages() - //Bone fractures +/obj/item/organ/external/proc/check_fracture() if(config.bones_can_break && brute_dam > min_broken_damage && !(status & ORGAN_ROBOT)) fracture() +/obj/item/organ/external/proc/check_for_internal_bleeding(damage) + var/local_damage = brute_dam + damage + if(damage > 15 && local_damage > 30 && prob(damage) && !(status & ORGAN_ROBOT)) + internal_bleeding = TRUE + owner.custom_pain("You feel something rip in your [name]!", 1) + // new damage icon system // returns just the brute/burn damage code /obj/item/organ/external/proc/damage_state_text() @@ -555,7 +514,12 @@ Note that amputating the affected organ does in fact remove the infection from t if(parent) parent.children -= src if(!nodamage) - parent.take_damage(brute_dam, burn_dam) + var/total_brute = brute_dam + var/total_burn = burn_dam + for(var/obj/item/organ/external/E in children) //Factor in the children's brute and burn into how much will transfer + total_brute += E.brute_dam + total_burn += E.burn_dam + parent.take_damage(total_brute, total_burn, ignore_resists = TRUE) //Transfer the full damage to the parent, bypass limb damage reduction. parent = null spawn(1) @@ -576,6 +540,8 @@ Note that amputating the affected organ does in fact remove the infection from t if(src && istype(loc,/turf)) dropped_part.throw_at(get_edge_target_turf(src,pick(alldirs)),rand(1,3),30) dir = 2 + brute_dam = 0 + burn_dam = 0 //Reset the damage on the limb; the damage should have transferred to the parent; we don't want extra damage being re-applie when then limb is re-attached return dropped_part else qdel(src) // If you flashed away to ashes, YOU FLASHED AWAY TO ASHES @@ -637,7 +603,7 @@ Note that amputating the affected organ does in fact remove the infection from t if(!make_tough) brute_mod = 0.66 burn_mod = 0.66 - fail_at_full_damage = 1 + dismember_at_max_damage = TRUE else tough = 1 // Robot parts also lack bones @@ -705,7 +671,6 @@ Note that amputating the affected organ does in fact remove the infection from t . = ..() status |= ORGAN_DESTROYED - victim.bad_external_organs -= src // Attached organs also fly off. if(!ignore_children) diff --git a/code/modules/surgery/organs/organ_icon.dm b/code/modules/surgery/organs/organ_icon.dm index 78244004ef1..f3edb2ec490 100644 --- a/code/modules/surgery/organs/organ_icon.dm +++ b/code/modules/surgery/organs/organ_icon.dm @@ -58,7 +58,7 @@ var/global/list/limb_icon_cache = list() var/obj/item/organ/internal/eyes/eyes = owner.get_int_organ(/obj/item/organ/internal/eyes)//owner.internal_bodyparts_by_name["eyes"] if(eyes) eyes.update_colour() -/obj/item/organ/external/head/remove() +/obj/item/organ/external/head/remove(mob/living/user, ignore_children) get_icon() . = ..() diff --git a/code/modules/surgery/organs/subtypes/skrell.dm b/code/modules/surgery/organs/subtypes/skrell.dm index 842088f2937..7e5785c7fa0 100644 --- a/code/modules/surgery/organs/subtypes/skrell.dm +++ b/code/modules/surgery/organs/subtypes/skrell.dm @@ -40,7 +40,7 @@ /obj/item/organ/internal/headpocket/on_owner_death() empty_contents() -/obj/item/organ/internal/headpocket/remove() +/obj/item/organ/internal/headpocket/remove(mob/living/carbon/M, special = 0) empty_contents() . = ..() diff --git a/code/modules/surgery/organs/subtypes/standard.dm b/code/modules/surgery/organs/subtypes/standard.dm index d3a76fab60c..bf2aeced0d4 100644 --- a/code/modules/surgery/organs/subtypes/standard.dm +++ b/code/modules/surgery/organs/subtypes/standard.dm @@ -46,6 +46,7 @@ w_class = WEIGHT_CLASS_BULKY // if you know what I mean ;) body_part = LOWER_TORSO vital = 1 + cannot_amputate = TRUE parent_organ = "chest" amputation_point = "lumbar" gendered_icon = 1 @@ -219,8 +220,8 @@ ..() -/obj/item/organ/external/head/take_damage(brute, burn, sharp, used_weapon = null, list/forbidden_limbs = list()) - ..(brute, burn, sharp, used_weapon, forbidden_limbs) +/obj/item/organ/external/head/take_damage(brute, burn, sharp, used_weapon = null, list/forbidden_limbs = list(), ignore_resists = FALSE) + ..(brute, burn, sharp, used_weapon, forbidden_limbs, ignore_resists) if(!disfigured) if(brute_dam > 40) if(prob(50))