From dcf5d8db77aa295e36638f798426e2979b6a9fc0 Mon Sep 17 00:00:00 2001 From: TheDreamweaver Date: Sat, 17 Mar 2018 06:21:48 -0700 Subject: [PATCH] Fixes dupe and runtime issues with Rod of Asclepius (#36410) * Fixes bug with duplicating rod on removal while lying down, as well as implemented a new force_put_in_hand() proc, and cleaned up some code. * Merged force_put_in_hand() with put_in_hand() and cleaned up code. --- code/datums/status_effects/buffs.dm | 10 +++------- code/modules/mining/lavaland/necropolis_chests.dm | 7 ++++++- code/modules/mob/inventory.dm | 9 ++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/code/datums/status_effects/buffs.dm b/code/datums/status_effects/buffs.dm index 4457ff3ebd85..b7d2e49899ac 100644 --- a/code/datums/status_effects/buffs.dm +++ b/code/datums/status_effects/buffs.dm @@ -501,19 +501,15 @@ if(((hand % 2) == 0)) var/obj/item/bodypart/L = itemUser.newBodyPart("r_arm", FALSE, FALSE) L.attach_limb(itemUser) - itemUser.put_in_r_hand(newRod) + itemUser.put_in_hand(newRod, hand, forced = TRUE) else var/obj/item/bodypart/L = itemUser.newBodyPart("l_arm", FALSE, FALSE) L.attach_limb(itemUser) - itemUser.put_in_l_hand(newRod) + itemUser.put_in_hand(newRod, hand, forced = TRUE) to_chat(itemUser, "Your arm suddenly grows back with the Rod of Asclepius still attached!") else //Otherwise get rid of whatever else is in their hand and return the rod to said hand - itemUser.dropItemToGround(itemUser.get_item_for_held_index(hand)) - if(((hand % 2) == 0)) - itemUser.put_in_r_hand(newRod) - else - itemUser.put_in_l_hand(newRod) + itemUser.put_in_hand(newRod, hand, forced = TRUE) to_chat(itemUser, "The Rod of Asclepius suddenly grows back out of your arm!") //Because a servant of medicines stops at nothing to help others, lets keep them on their toes and give them an additional boost. if(itemUser.health < itemUser.maxHealth) diff --git a/code/modules/mining/lavaland/necropolis_chests.dm b/code/modules/mining/lavaland/necropolis_chests.dm index 7f3870e418e4..f9c3fdd43dc7 100644 --- a/code/modules/mining/lavaland/necropolis_chests.dm +++ b/code/modules/mining/lavaland/necropolis_chests.dm @@ -146,6 +146,7 @@ icon = 'icons/obj/lavaland/artefacts.dmi' icon_state = "asclepius_dormant" var/activated = FALSE + var/usedHand /obj/item/rod_of_asclepius/attack_self(mob/user) if(activated) @@ -154,6 +155,10 @@ to_chat(user, "The snake carving seems to come alive, if only for a moment, before returning to it's dormant state, almost as if it finds you incapable of holding it's oath.") return var/mob/living/carbon/itemUser = user + usedHand = itemUser.get_held_index_of_item(src) + if(itemUser.has_status_effect(STATUS_EFFECT_HIPPOCRATIC_OATH)) + to_chat(user, "You can't possibly handle the responsibility of more than one rod!") + return var/failText = "The snake seems unsatisfied with your incomplete oath and returns to it's previous place on the rod, returning to its dormant, wooden state. You must stand still while completing your oath!" to_chat(itemUser, "The wooden snake that was carved into the rod seems to suddenly come alive and begins to slither down your arm! The compulsion to help others grows abnormally strong...") if(do_after(itemUser, 40, target = itemUser)) @@ -178,7 +183,7 @@ return to_chat(itemUser, "The snake, satisfied with your oath, attaches itself and the rod to your forearm with an inseparable grip. Your thoughts seem to only revolve around the core idea of helping others, and harm is nothing more than a distant, wicked memory...") var/datum/status_effect/hippocraticOath/effect = itemUser.apply_status_effect(STATUS_EFFECT_HIPPOCRATIC_OATH) - effect.hand = itemUser.get_held_index_of_item(src) + effect.hand = usedHand activated() /obj/item/rod_of_asclepius/proc/activated() diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index acef80b8ba69..cb0ac4762bb8 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -170,8 +170,12 @@ return FALSE return !held_items[hand_index] -/mob/proc/put_in_hand(obj/item/I, hand_index) - if(can_put_in_hand(I, hand_index)) +/mob/proc/put_in_hand(obj/item/I, hand_index, forced = FALSE) + if(forced || can_put_in_hand(I, hand_index)) + if(hand_index == null) + return FALSE + if(get_item_for_held_index(hand_index) != null) + dropItemToGround(get_item_for_held_index(hand_index), force = TRUE) I.forceMove(src) held_items[hand_index] = I I.layer = ABOVE_HUD_LAYER @@ -185,7 +189,6 @@ return hand_index || TRUE return FALSE - //Puts the item into the first available left hand if possible and calls all necessary triggers/updates. returns 1 on success. /mob/proc/put_in_l_hand(obj/item/I) return put_in_hand(I, get_empty_held_index_for_side("l"))