From 17938853d5a5c7ebcd3cea8205daf75063b202a9 Mon Sep 17 00:00:00 2001 From: skull132 Date: Fri, 25 Mar 2016 20:25:54 +0200 Subject: [PATCH] Of Helper Procs & Dumbs Makes a mob/proc/can_use_hand(), which determines whether or not a mob can use a given hand. Redefined in human.dm to check a hand's status and usability. --- code/game/objects/items.dm | 7 ++--- code/game/objects/items/stacks/stack.dm | 3 +- code/game/objects/structures/extinguisher.dm | 10 ++----- code/game/objects/structures/watercloset.dm | 10 ++----- code/modules/mob/living/carbon/carbon.dm | 10 ++----- code/modules/mob/living/carbon/human/human.dm | 28 +++++++++---------- .../living/carbon/human/human_attackhand.dm | 9 ++---- code/modules/mob/mob.dm | 4 +++ code/modules/paperwork/paperbin.dm | 10 ++----- 9 files changed, 32 insertions(+), 59 deletions(-) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 9364b13b45c..4ae15667f74 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -147,10 +147,7 @@ /obj/item/attack_hand(mob/user as mob) if (!user) return - // Removed the hand check from here, and moved it into /mob/living/carbon/human/put_in_r_hand or put_in_l_hand respectively. - // put_in_active_hand must be called first, as it then checks whether or not we can actually use the hand. - // Then the obj/item/pickup() proc gets triggered. - if (!user.put_in_active_hand(src)) + if (!user.can_use_hand()) return src.pickup(user) @@ -166,6 +163,8 @@ if(isliving(src.loc)) return user.next_move = max(user.next_move+2,world.time + 2) + + user.put_in_active_hand(src) return /obj/item/attack_ai(mob/user as mob) diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index d3ce84029b4..c09902f7140 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -299,8 +299,9 @@ if (user.get_inactive_hand() == src) var/obj/item/stack/F = src.split(1) if (F) - if (!user.put_in_hands(F)) + if (!user.can_use_hand()) return + user.put_in_hands(F) src.add_fingerprint(user) F.add_fingerprint(user) spawn(0) diff --git a/code/game/objects/structures/extinguisher.dm b/code/game/objects/structures/extinguisher.dm index 872b8ff9885..0b6e579083d 100644 --- a/code/game/objects/structures/extinguisher.dm +++ b/code/game/objects/structures/extinguisher.dm @@ -31,14 +31,8 @@ /obj/structure/extinguisher_cabinet/attack_hand(mob/user) if(isrobot(user)) return - if (ishuman(user)) - var/mob/living/carbon/human/H = user - var/obj/item/organ/external/temp = H.organs_by_name["r_hand"] - if (user.hand) - temp = H.organs_by_name["l_hand"] - if(temp && !temp.is_usable()) - user << "You try to move your [temp.name], but cannot!" - return + if (!user.can_use_hand()) + return if(has_extinguisher) user.put_in_hands(has_extinguisher) user << "You take [has_extinguisher] from [src]." diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index c48edab1a9e..02cfed7d81a 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -346,14 +346,8 @@ var/busy = 0 //Something's being washed at the moment /obj/structure/sink/attack_hand(mob/user as mob) - if (ishuman(user)) - var/mob/living/carbon/human/H = user - var/obj/item/organ/external/temp = H.organs_by_name["r_hand"] - if (user.hand) - temp = H.organs_by_name["l_hand"] - if(temp && !temp.is_usable()) - user << "You try to move your [temp.name], but cannot!" - return + if (!user.can_use_hand()) + return if(isrobot(user) || isAI(user)) return diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 9f1bdb7b480..55f80d47f85 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -84,14 +84,8 @@ /mob/living/carbon/attack_hand(mob/M as mob) if(!istype(M, /mob/living/carbon)) return - if (ishuman(M)) - var/mob/living/carbon/human/H = M - var/obj/item/organ/external/temp = H.organs_by_name["r_hand"] - if (H.hand) - temp = H.organs_by_name["l_hand"] - if(temp && !temp.is_usable()) - H << "\red You can't use your [temp.name]" - return + if (!M.can_use_hand()) + return for(var/datum/disease/D in viruses) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index d34a1ed1d03..f5be082465c 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1420,15 +1420,6 @@ if(!..() || l_hand) return 0 - var/obj/item/organ/external/temp = organs_by_name["l_hand"] - if (temp && !temp.is_usable()) - src << "You try to move your [temp.name], but cannot!" - return 0 - - if (!temp) - src << "You try to use your hand, but realize it is no longer attached!" - return 0 - W.forceMove(src) l_hand = W W.equipped(src,slot_l_hand) @@ -1440,7 +1431,19 @@ if(!..() || r_hand) return 0 - var/obj/item/organ/external/temp = organs_by_name["r_hand"] + W.forceMove(src) + r_hand = W + W.equipped(src,slot_r_hand) + W.add_fingerprint(src) + update_inv_r_hand() + return 1 + +/mob/living/carbon/human/can_use_hand(var/selected_hand = hand) + var/hand_to_check = "l_hand" + if (!selected_hand) + hand_to_check = "r_hand" + + var/obj/item/organ/external/temp = organs_by_name[hand_to_check] if (temp && !temp.is_usable()) src << "You try to move your [temp.name], but cannot!" return 0 @@ -1449,9 +1452,4 @@ src << "You try to use your hand, but realize it is no longer attached!" return 0 - W.forceMove(src) - r_hand = W - W.equipped(src,slot_r_hand) - W.add_fingerprint(src) - update_inv_r_hand() return 1 diff --git a/code/modules/mob/living/carbon/human/human_attackhand.dm b/code/modules/mob/living/carbon/human/human_attackhand.dm index 20d45ea947d..5147dd641ed 100644 --- a/code/modules/mob/living/carbon/human/human_attackhand.dm +++ b/code/modules/mob/living/carbon/human/human_attackhand.dm @@ -7,13 +7,8 @@ /mob/living/carbon/human/attack_hand(mob/living/carbon/M as mob) var/mob/living/carbon/human/H = M - if(istype(H)) - var/obj/item/organ/external/temp = H.organs_by_name["r_hand"] - if(H.hand) - temp = H.organs_by_name["l_hand"] - if(!temp || !temp.is_usable()) - H << "\red You can't use your hand." - return + if(!M.can_use_hand()) + return ..() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index e1e6a672d85..028bc0103b4 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1110,3 +1110,7 @@ mob/proc/yank_out_object() feedback_add_details("admin_verb", "UNWIND") return + +//Helper proc for figuring out if the active hand (or given hand) is usable. +/mob/proc/can_use_hand() + return 1 diff --git a/code/modules/paperwork/paperbin.dm b/code/modules/paperwork/paperbin.dm index e2dd24c4a61..5dbead26083 100644 --- a/code/modules/paperwork/paperbin.dm +++ b/code/modules/paperwork/paperbin.dm @@ -22,14 +22,8 @@ return /obj/item/weapon/paper_bin/attack_hand(mob/user as mob) - if(ishuman(user)) - var/mob/living/carbon/human/H = user - var/obj/item/organ/external/temp = H.organs_by_name["r_hand"] - if (H.hand) - temp = H.organs_by_name["l_hand"] - if(temp && !temp.is_usable()) - user << "You try to move your [temp.name], but cannot!" - return + if(!user.can_use_hand()) + return var/response = "" if(!papers.len > 0) response = alert(user, "Do you take regular paper, or Carbon copy paper?", "Paper type request", "Regular", "Carbon-Copy", "Cancel")