From 6590860250beea9c06e37558eb217cc6c7183c06 Mon Sep 17 00:00:00 2001 From: QualityVan Date: Mon, 24 Apr 2017 15:32:00 -0400 Subject: [PATCH 1/3] Refactors zombie organs Fixes mounted chainsaws leaving a limb if acided Adds species support for mutanthands, basically hard-equipped items like zombie claws Fixes zombies not having claws on new arms Mobs manually set to zombie species revert to human when their infection is removed Inserts organs back into the mob when a bodypart is reattached No longer generates eyes or ears when a mob changes species without having a head Todo: fix the initial problem of zombies being able to not have claws due to having a nodrop item before zombification and losing it --- code/game/objects/items/weapons/weaponry.dm | 15 ++++++-- .../mob/living/carbon/human/species.dm | 37 ++++++++++++++----- .../carbon/human/species_types/zombies.dm | 25 +++---------- .../chemistry/reagents/other_reagents.dm | 4 +- .../surgery/bodyparts/dismemberment.dm | 5 +++ .../modules/surgery/prosthetic_replacement.dm | 4 +- code/modules/zombie/items.dm | 3 +- code/modules/zombie/organs.dm | 5 ++- 8 files changed, 60 insertions(+), 38 deletions(-) diff --git a/code/game/objects/items/weapons/weaponry.dm b/code/game/objects/items/weapons/weaponry.dm index d7465876c0e..71e7c0e5669 100644 --- a/code/game/objects/items/weapons/weaponry.dm +++ b/code/game/objects/items/weapons/weaponry.dm @@ -390,7 +390,7 @@ desc = "A chainsaw that has replaced your arm." icon_state = "chainsaw_on" item_state = "mounted_chainsaw" - flags = NODROP | ABSTRACT + flags = NODROP | ABSTRACT | DROPDEL w_class = WEIGHT_CLASS_HUGE force = 21 throwforce = 0 @@ -400,10 +400,17 @@ attack_verb = list("sawed", "torn", "cut", "chopped", "diced") hitsound = 'sound/weapons/chainsawhit.ogg' -/obj/item/weapon/mounted_chainsaw/dropped() - ..() +/obj/item/weapon/mounted_chainsaw/Destroy() + var/obj/item/bodypart/part new /obj/item/weapon/twohanded/required/chainsaw(get_turf(src)) - qdel(src) + if(iscarbon(loc)) + var/mob/living/carbon/holder = loc + var/index = holder.get_held_index_of_item(src) + if(index) + part = holder.hand_bodyparts[index] + . = ..() + if(part) + part.drop_limb() /obj/item/weapon/statuebust name = "bust" diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index efee3652574..71fa7f07407 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -73,6 +73,9 @@ //Ears var/obj/item/organ/ears/mutantears = /obj/item/organ/ears + //Hands + var/obj/item/mutanthands = null + /////////// // PROCS // /////////// @@ -115,7 +118,7 @@ var/obj/item/thing = C.get_item_by_slot(slot_id) if(thing && (!thing.species_exception || !is_type_in_list(src,thing.species_exception))) C.dropItemToGround(thing) - + // this needs to be FIRST because qdel calls update_body which checks if we have DIGITIGRADE legs or not and if not then removes DIGITIGRADE from species_traits if(("legs" in C.dna.species.mutant_bodyparts) && C.dna.features["legs"] == "Digitigrade Legs") species_traits += DIGITIGRADE @@ -139,15 +142,16 @@ qdel(lungs) lungs = null - if(eyes) - qdel(eyes) - eyes = new mutanteyes - eyes.Insert(C) + if(C.get_bodypart("head")) + if(eyes) + qdel(eyes) + eyes = new mutanteyes + eyes.Insert(C) - if(ears) - qdel(ears) - ears = new mutantears - ears.Insert(C) + if(ears) + qdel(ears) + ears = new mutantears + ears.Insert(C) if((!(NOBREATH in species_traits)) && !lungs) if(mutantlungs) @@ -169,11 +173,26 @@ if(exotic_bloodtype && C.dna.blood_type != exotic_bloodtype) C.dna.blood_type = exotic_bloodtype + if(mutanthands) + // Drop items in hands + // If you're lucky enough to have a NODROP item, then it stays. + for(var/V in C.held_items) + var/obj/item/I = V + if(istype(I)) + if(C.dropItemToGround(I)) + C.put_in_hands(new mutanthands()) + else //Entries in the list should only ever be items or null, so if it's not an item, we can assume it's an empty hand + C.put_in_hands(new mutanthands()) + /datum/species/proc/on_species_loss(mob/living/carbon/C) if(C.dna.species.exotic_bloodtype) C.dna.blood_type = random_blood_type() if(DIGITIGRADE in species_traits) C.Digitigrade_Leg_Swap(TRUE) + if(mutanthands) + for(var/obj/item/I in C.held_items) + if(istype(I, mutanthands)) + qdel(I) /datum/species/proc/handle_hair(mob/living/carbon/human/H, forced_colour) H.remove_overlay(HAIR_LAYER) diff --git a/code/modules/mob/living/carbon/human/species_types/zombies.dm b/code/modules/mob/living/carbon/human/species_types/zombies.dm index abd080bfaef..a2e26b4e5ef 100644 --- a/code/modules/mob/living/carbon/human/species_types/zombies.dm +++ b/code/modules/mob/living/carbon/human/species_types/zombies.dm @@ -13,6 +13,7 @@ name = "Infectious Zombie" id = "memezombies" limbs_id = "zombie" + mutanthands = /obj/item/zombie_hand no_equip = list(slot_wear_mask, slot_head) armor = 20 // 120 damage to KO a zombie, which kills it speedmod = 2 @@ -27,29 +28,15 @@ /datum/species/zombie/infectious/on_species_gain(mob/living/carbon/C, datum/species/old_species) . = ..() - // Drop items in hands - // If you're a zombie lucky enough to have a NODROP item, then it stays. - for(var/V in C.held_items) - var/obj/item/I = V - if(istype(I)) - if(C.dropItemToGround(I)) - var/obj/item/zombie_hand/zh = new /obj/item/zombie_hand() - C.put_in_hands(zh) - else //Entries in the list should only ever be items or null, so if it's not an item, we can assume it's an empty hand - var/obj/item/zombie_hand/zh = new /obj/item/zombie_hand() - C.put_in_hands(zh) - // Next, deal with the source of this zombie corruption + // Deal with the source of this zombie corruption + // Infection organ needs to be handled separately from mutant_organs + // because it persists through species transitions var/obj/item/organ/zombie_infection/infection infection = C.getorganslot("zombie_infection") if(!infection) - infection = new(C) - -/datum/species/zombie/infectious/on_species_loss(mob/living/carbon/C) - . = ..() - for(var/obj/item/I in C.held_items) - if(istype(I, /obj/item/zombie_hand)) - qdel(I) + infection = new() + infection.Insert(C) // Your skin falls off diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index cf956227ba1..b66a8ed8c08 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -1511,7 +1511,9 @@ /datum/reagent/romerol/on_mob_life(mob/living/carbon/human/H) // Silently add the zombie infection organ to be activated upon death - new /obj/item/organ/zombie_infection(H) + if(!H.getorganslot("zombie_infection")) + var/obj/item/organ/zombie_infection/ZI = new() + ZI.Insert(H) ..() /datum/reagent/growthserum diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index 7d9cf89ff06..22fe3d8f7c5 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -258,6 +258,8 @@ if(held_index > C.hand_bodyparts.len) C.hand_bodyparts.len = held_index C.hand_bodyparts[held_index] = src + if(C.dna.species.mutanthands && !is_pseudopart) + C.put_in_hand(new C.dna.species.mutanthands(), held_index) if(C.hud_used) var/obj/screen/inventory/hand/hand = C.hud_used.hand_slots["[held_index]"] if(hand) @@ -273,6 +275,9 @@ qdel(S) break + for(var/obj/item/organ/O in contents) + O.Insert(C) + update_bodypart_damage_state() C.updatehealth() diff --git a/code/modules/surgery/prosthetic_replacement.dm b/code/modules/surgery/prosthetic_replacement.dm index b054626f4e8..0f9a6489dda 100644 --- a/code/modules/surgery/prosthetic_replacement.dm +++ b/code/modules/surgery/prosthetic_replacement.dm @@ -58,9 +58,9 @@ user.visible_message("[user] successfully replaces [target]'s [parse_zone(target_zone)]!", "You succeed in replacing [target]'s [parse_zone(target_zone)].") return 1 else - target.regenerate_limb(target_zone) - var/obj/item/bodypart/L = target.get_bodypart(target_zone) + var/obj/item/bodypart/L = target.newBodyPart(target_zone, FALSE, FALSE) L.is_pseudopart = TRUE + L.attach_limb(target) user.visible_message("[user] finishes attaching [tool]!", "You attach [tool].") qdel(tool) if(istype(tool, /obj/item/weapon/twohanded/required/chainsaw)) diff --git a/code/modules/zombie/items.dm b/code/modules/zombie/items.dm index 1bdbd3fa45c..1b93a4f6857 100644 --- a/code/modules/zombie/items.dm +++ b/code/modules/zombie/items.dm @@ -46,7 +46,8 @@ var/obj/item/organ/zombie_infection/infection infection = target.getorganslot("zombie_infection") if(!infection) - infection = new(target) + infection = new() + infection.Insert(target) /obj/item/zombie_hand/proc/check_feast(mob/living/target, mob/living/user) if(target.stat == DEAD) diff --git a/code/modules/zombie/organs.dm b/code/modules/zombie/organs.dm index 295d7745955..e0c6a9da9b5 100644 --- a/code/modules/zombie/organs.dm +++ b/code/modules/zombie/organs.dm @@ -5,7 +5,7 @@ slot = "zombie_infection" icon_state = "blacktumor" origin_tech = "biotech=5" - var/datum/species/old_species + var/datum/species/old_species = /datum/species/human var/living_transformation_time = 3 var/converts_living = FALSE @@ -26,6 +26,7 @@ /obj/item/organ/zombie_infection/Insert(var/mob/living/carbon/M, special = 0) . = ..() START_PROCESSING(SSobj, src) + old_species = M.dna.species.type /obj/item/organ/zombie_infection/Remove(mob/living/carbon/M, special = 0) . = ..() @@ -63,6 +64,7 @@ if(!iszombie(owner)) old_species = owner.dna.species.type + owner.set_species(/datum/species/zombie/infectious) if(!converts_living && owner.stat != DEAD) return @@ -70,7 +72,6 @@ var/stand_up = (owner.stat == DEAD) || (owner.stat == UNCONSCIOUS) owner.grab_ghost() - owner.set_species(/datum/species/zombie/infectious) owner.revive(full_heal = TRUE) owner.visible_message("[owner] suddenly convulses, as [owner.p_they()][stand_up ? " stagger to [owner.p_their()] feet and" : ""] gain a ravenous hunger in [owner.p_their()] eyes!", "You HUNGER!") playsound(owner.loc, 'sound/hallucinations/far_noise.ogg', 50, 1) From edf412baa9d8b2dd58dfdf41bbd16541691426c9 Mon Sep 17 00:00:00 2001 From: QualityVan Date: Mon, 24 Apr 2017 15:42:39 -0400 Subject: [PATCH 2/3] not good to store old species immediately after changing species, turns out --- code/modules/zombie/organs.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/zombie/organs.dm b/code/modules/zombie/organs.dm index e0c6a9da9b5..28e6d9499f9 100644 --- a/code/modules/zombie/organs.dm +++ b/code/modules/zombie/organs.dm @@ -26,7 +26,6 @@ /obj/item/organ/zombie_infection/Insert(var/mob/living/carbon/M, special = 0) . = ..() START_PROCESSING(SSobj, src) - old_species = M.dna.species.type /obj/item/organ/zombie_infection/Remove(mob/living/carbon/M, special = 0) . = ..() From b9ba9356bd70a32ad8b1324b10d703c8e906d7c4 Mon Sep 17 00:00:00 2001 From: QualityVan Date: Tue, 25 Apr 2017 03:31:00 -0400 Subject: [PATCH 3/3] Puts mutanthands into newly empty hands if a species has them --- code/modules/mob/living/carbon/human/inventory.dm | 4 +++- code/modules/mob/living/carbon/human/species.dm | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 101b06849b0..1b5518008e5 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -142,10 +142,12 @@ return not_handled //For future deeper overrides /mob/living/carbon/human/doUnEquip(obj/item/I, force, newloc, no_move, invdrop = TRUE) + var/index = get_held_index_of_item(I) . = ..() //See mob.dm for an explanation on this and some rage about people copypasting instead of calling ..() like they should. if(!. || !I) return - + if(index && dna.species.mutanthands) + put_in_hand(new dna.species.mutanthands(), index) if(I == wear_suit) if(s_store && invdrop) dropItemToGround(s_store, TRUE) //It makes no sense for your suit storage to stay on you if you drop your suit. diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 71fa7f07407..5b566b4475a 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -173,14 +173,18 @@ if(exotic_bloodtype && C.dna.blood_type != exotic_bloodtype) C.dna.blood_type = exotic_bloodtype + if(old_species.mutanthands) + for(var/obj/item/I in C.held_items) + if(istype(I, old_species.mutanthands)) + qdel(I) + if(mutanthands) // Drop items in hands // If you're lucky enough to have a NODROP item, then it stays. for(var/V in C.held_items) var/obj/item/I = V if(istype(I)) - if(C.dropItemToGround(I)) - C.put_in_hands(new mutanthands()) + C.dropItemToGround(I) else //Entries in the list should only ever be items or null, so if it's not an item, we can assume it's an empty hand C.put_in_hands(new mutanthands()) @@ -189,10 +193,6 @@ C.dna.blood_type = random_blood_type() if(DIGITIGRADE in species_traits) C.Digitigrade_Leg_Swap(TRUE) - if(mutanthands) - for(var/obj/item/I in C.held_items) - if(istype(I, mutanthands)) - qdel(I) /datum/species/proc/handle_hair(mob/living/carbon/human/H, forced_colour) H.remove_overlay(HAIR_LAYER)