From 3eae36096311dcd51f3c0fdc23fe666314ef3162 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Thu, 31 Jul 2014 18:10:11 -0400 Subject: [PATCH] Handcuffs now require an aggressive grab Conflicts: code/game/objects/items/weapons/handcuffs.dm --- code/game/objects/items/weapons/handcuffs.dm | 96 ++++++++++++------- .../mob/living/carbon/human/inventory.dm | 12 ++- 2 files changed, 75 insertions(+), 33 deletions(-) diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index 07b506d4d50..d961325c779 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -14,43 +14,60 @@ origin_tech = "materials=1" var/dispenser = 0 var/breakouttime = 1200 //Deciseconds = 120s = 2 minutes + var/cuff_sound = 'sound/weapons/handcuffs.ogg' -/obj/item/weapon/handcuffs/attack(mob/living/carbon/C, mob/user) - if(M_CLUMSY in user.mutations && prob(50)) - user << "Uh... how do those things work?!" - if(!C.handcuffed) - user.drop_item() - loc = C - C.handcuffed = src - C.update_inv_handcuffed() - return - - var/cable = 0 - if(istype(src, /obj/item/weapon/handcuffs/cable)) - cable = 1 +/obj/item/weapon/handcuffs/attack(mob/living/carbon/C as mob, mob/user as mob) + if (!istype(user, /mob/living/carbon/human)) + user << "\red You don't have the dexterity to do this!" + return + if ((M_CLUMSY in usr.mutations) && prob(50)) + user << "\red Uh ... how do those things work?!" + place_handcuffs(user, user) + return if(!C.handcuffed) - C.visible_message("[user] is trying to put handcuffs on [C]!", \ - "[user] is trying to put handcuffs on [C]!") - - if(cable) - playsound(loc, 'sound/weapons/cablecuff.ogg', 30, 1, -2) - else - playsound(loc, 'sound/weapons/handcuffs.ogg', 30, 1, -2) - - if(do_mob(user, C, 30)) - if(C.handcuffed) + //check for an aggressive grab + for (var/obj/item/weapon/grab/G in C.grabbed_by) + if (G.loc == user && G.state == GRAB_AGGRESSIVE) + place_handcuffs(C, user) return - user.drop_item() - loc = C - C.handcuffed = src - C.update_inv_handcuffed() - if(cable) - feedback_add_details("handcuffs","C") - else - feedback_add_details("handcuffs","H") + user << "\red You need to have a firm grip on [C] before you can put \the [src] on!" - add_logs(user, C, "handcuffed") +/obj/item/weapon/handcuffs/proc/place_handcuffs(var/mob/living/carbon/target, var/mob/user) + playsound(src.loc, cuff_sound, 30, 1, -2) + + if (ishuman(target)) + var/mob/living/carbon/human/H = target + H.attack_log += text("\[[time_stamp()]\] Has been handcuffed (attempt) by [user.name] ([user.ckey])") + user.attack_log += text("\[[time_stamp()]\] Attempted to handcuff [H.name] ([H.ckey])") + msg_admin_attack("[key_name(user)] attempted to handcuff [key_name(H)]") + + var/obj/effect/equip_e/human/O = new /obj/effect/equip_e/human( ) + O.source = user + O.target = H + O.item = user.get_active_hand() + O.s_loc = user.loc + O.t_loc = H.loc + O.place = "handcuff" + H.requests += O + spawn( 0 ) + feedback_add_details("handcuffs","H") + O.process() + return + + if (ismonkey(target)) + var/mob/living/carbon/monkey/M = target + var/obj/effect/equip_e/monkey/O = new /obj/effect/equip_e/monkey( ) + O.source = user + O.target = M + O.item = user.get_active_hand() + O.s_loc = user.loc + O.t_loc = M.loc + O.place = "handcuff" + M.requests += O + spawn( 0 ) + O.process() + return var/last_chew = 0 /mob/living/carbon/human/RestrainedClickOn(var/atom/A) @@ -84,6 +101,7 @@ var/last_chew = 0 desc = "Looks like some cables tied together. Could be used to tie something up." icon_state = "cuff_red" breakouttime = 300 //Deciseconds = 30s + cuff_sound = 'sound/weapons/cablecuff.ogg' /obj/item/weapon/handcuffs/cable/red icon_state = "cuff_red" @@ -128,3 +146,17 @@ var/last_chew = 0 user << "You wrap the cable restraint around the top of the rod." del(src) +/obj/item/weapon/handcuffs/cyborg + dispenser = 1 + +/obj/item/weapon/handcuffs/cyborg/attack(mob/living/carbon/C as mob, mob/user as mob) + if(!C.handcuffed) + var/turf/p_loc = user.loc + var/turf/p_loc_m = C.loc + playsound(src.loc, cuff_sound, 30, 1, -2) + user.visible_message("\red [user] is trying to put handcuffs on [C]!") + spawn(30) + if(!C) return + if(p_loc == user.loc && p_loc_m == C.loc) + C.handcuffed = new /obj/item/weapon/handcuffs(C) + C.update_inv_handcuffed() diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index 16a724e48a9..28bca07a3c5 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -683,10 +683,20 @@ It can still be worn/put on as normal. slot_to_process = slot_back if (target.back) strip_item = target.back - if("handcuff") + if("handcuff") slot_to_process = slot_handcuffed if (target.handcuffed) strip_item = target.handcuffed + else + //check that we are still grabbing them + var/grabbing = 0 + for (var/obj/item/weapon/grab/G in target.grabbed_by) + if (G.loc == source && G.state == GRAB_AGGRESSIVE) + grabbing = 1 + if (!grabbing) + slot_to_process = null + source << "\red Your grasp was broken before you could restrain [target]!" + if("legcuff") slot_to_process = slot_legcuffed if (target.legcuffed)