diff --git a/code/game/objects/items/handcuffs.dm b/code/game/objects/items/handcuffs.dm index 8db6b3556a0..259d38119ac 100644 --- a/code/game/objects/items/handcuffs.dm +++ b/code/game/objects/items/handcuffs.dm @@ -46,11 +46,13 @@ throw_range = 5 custom_materials = list(/datum/material/iron= SMALL_MATERIAL_AMOUNT * 5) breakouttime = 1 MINUTES + armor_type = /datum/armor/restraints_handcuffs + custom_price = PAYCHECK_COMMAND * 0.35 + + ///How long it takes to handcuff someone var/handcuff_time = 4 SECONDS ///Multiplier for handcuff time var/handcuff_time_mod = 1 - armor_type = /datum/armor/restraints_handcuffs - custom_price = PAYCHECK_COMMAND * 0.35 ///Sound that plays when starting to put handcuffs on someone var/cuffsound = 'sound/weapons/handcuffs.ogg' ///If set, handcuffs will be destroyed on application and leave behind whatever this is set to. @@ -70,51 +72,68 @@ fire = 50 acid = 50 -/obj/item/restraints/handcuffs/attack(mob/living/carbon/C, mob/living/user) - if(!istype(C)) +/obj/item/restraints/handcuffs/attack(mob/living/target_mob, mob/living/user) + if(!iscarbon(target_mob)) return - if(SEND_SIGNAL(C, COMSIG_CARBON_CUFF_ATTEMPTED, user) & COMSIG_CARBON_CUFF_PREVENT) + attempt_to_cuff(target_mob, user) // avoid locking up the attack chain with sleeps + +/// Handles all of the checks and application in a typical situation where someone attacks a carbon victim with the handcuff item. +/obj/item/restraints/handcuffs/proc/attempt_to_cuff(mob/living/carbon/victim, mob/living/user) + if(SEND_SIGNAL(victim, COMSIG_CARBON_CUFF_ATTEMPTED, user) & COMSIG_CARBON_CUFF_PREVENT) + victim.balloon_alert(user, "can't be handcuffed!") return if(iscarbon(user) && (HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50))) //Clumsy people have a 50% chance to handcuff themselves instead of their target. to_chat(user, span_warning("Uh... how do those things work?!")) - apply_cuffs(user,user) + apply_cuffs(user, user) return + if(!isnull(victim.handcuffed)) + victim.balloon_alert(user, "already handcuffed!") + return + + if(victim.canBeHandcuffed()) + victim.balloon_alert(user, "can't be handcuffed!") + to_chat(user, span_warning("[victim] doesn't have two hands...")) + return + + victim.visible_message( + span_danger("[user] is trying to put [src] on [victim]!"), + span_userdanger("[user] is trying to put [src] on you!"), + ) + + if(victim.is_blind()) + to_chat(victim, span_userdanger("As you feel someone grab your wrists, [src] start digging into your skin!")) + + playsound(loc, cuffsound, 30, TRUE, -2) + log_combat(user, victim, "attempted to handcuff") + if(HAS_TRAIT(user, TRAIT_FAST_CUFFING)) handcuff_time_mod = 0.75 else handcuff_time_mod = 1 - if(!C.handcuffed) - if(C.canBeHandcuffed()) - C.visible_message(span_danger("[user] is trying to put [src] on [C]!"), \ - span_userdanger("[user] is trying to put [src] on you!")) - if(C.is_blind()) - to_chat(C, span_userdanger("As you feel someone grab your wrists, [src] start digging into your skin!")) - playsound(loc, cuffsound, 30, TRUE, -2) - log_combat(user, C, "attempted to handcuff") - if(do_after(user, handcuff_time * handcuff_time_mod, C, timed_action_flags = IGNORE_SLOWDOWNS) && C.canBeHandcuffed()) - if(iscyborg(user)) - apply_cuffs(C, user, TRUE) - else - apply_cuffs(C, user) - C.visible_message(span_notice("[user] handcuffs [C]."), \ - span_userdanger("[user] handcuffs you.")) - SSblackbox.record_feedback("tally", "handcuffs", 1, type) - - log_combat(user, C, "handcuffed") - else - to_chat(user, span_warning("You fail to handcuff [C]!")) - log_combat(user, C, "failed to handcuff") - else - to_chat(user, span_warning("[C] doesn't have two hands...")) + if(!do_after(user, handcuff_time * handcuff_time_mod, victim, timed_action_flags = IGNORE_SLOWDOWNS) || !victim.canBeHandcuffed()) + victim.balloon_alert(user, "failed to handcuff!") + to_chat(user, span_warning("You fail to handcuff [victim]!")) + log_combat(user, victim, "failed to handcuff") + return + + apply_cuffs(victim, user, dispense = iscyborg(user)) + + victim.visible_message( + span_notice("[user] handcuffs [victim]."), + span_userdanger("[user] handcuffs you."), + ) + + log_combat(user, victim, "successfully handcuffed") + SSblackbox.record_feedback("tally", "handcuffs", 1, type) + /** - * This handles handcuffing people + * When called, this instantly puts handcuffs on someone (if actually possible) * - * When called, this instantly puts handcuffs on someone (if possible) * Arguments: * * mob/living/carbon/target - Who is being handcuffed * * mob/user - Who or what is doing the handcuffing @@ -137,7 +156,6 @@ if(trashtype && !dispense) qdel(src) - return /** * # Alien handcuffs