/obj/item/assembly/mousetrap name = "mousetrap" desc = "A handy little spring-loaded trap for catching pesty rodents." item_icons = list( slot_l_hand_str = 'icons/mob/items/lefthand_janitor.dmi', slot_r_hand_str = 'icons/mob/items/righthand_janitor.dmi', ) icon_state = "mousetrap" drop_sound = 'sound/items/drop/component.ogg' pickup_sound = 'sound/items/pickup/component.ogg' surgerysound = 'sound/items/surgery/fixovein.ogg' origin_tech = list(TECH_COMBAT = 1) matter = list(MATERIAL_STEEL = 100) var/armed = FALSE /obj/item/assembly/mousetrap/Initialize(mapload) . = ..() var/static/list/loc_connections = list( COMSIG_ATOM_ENTERED = PROC_REF(on_entered), ) AddElement(/datum/element/connect_loc, loc_connections) /obj/item/assembly/mousetrap/feedback_hints(mob/user, distance, is_adjacent) . += ..() if(armed) . += SPAN_NOTICE("It looks like it's armed.") /obj/item/assembly/mousetrap/update_icon() icon_state = armed ? "mousetraparmed" : "mousetrap" if(holder) holder.update_icon() /obj/item/assembly/mousetrap/proc/triggered(var/mob/living/target, var/type = "feet") if(!armed || !istype(target)) return var/types = target.find_type() if(israt(target)) var/mob/living/simple_animal/rat/M = target audible_message(SPAN_DANGER("SPLAT!")) M.splat() else var/zone = BP_CHEST if(ishuman(target) && target.mob_size) var/mob/living/carbon/human/H = target switch(type) if("feet") zone = pick(BP_L_FOOT, BP_R_FOOT) if(!H.shoes) H.apply_effect(400 / (target.mob_size * (target.mob_size * 0.25)), DAMAGE_PAIN)//Halloss instead of instant knockdown //Mainly for the benefit of giant monsters like vaurca breeders if(BP_L_HAND, BP_R_HAND) zone = type if(!H.gloves) H.apply_effect(250 / (target.mob_size * (target.mob_size * 0.25)), DAMAGE_PAIN) if(!(types & TYPE_SYNTHETIC)) target.apply_damage(rand(6 , 14), DAMAGE_PAIN, def_zone = zone, used_weapon = src) target.apply_damage(rand(1 , 3), DAMAGE_BRUTE, def_zone = zone, used_weapon = src) playsound(target.loc, 'sound/effects/snap.ogg', 50, 1) layer = MOB_LAYER - 0.2 armed = FALSE update_icon() pulse(FALSE) /obj/item/assembly/mousetrap/attack_self(mob/living/user) if(!armed) to_chat(user, SPAN_NOTICE("You arm \the [src].")) else if(clumsy_check(user)) return to_chat(user, SPAN_NOTICE("You disarm \the [src].")) armed = !armed update_icon() playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3) /obj/item/assembly/mousetrap/attack_hand(mob/living/user) if(armed && clumsy_check(user)) return return ..() /obj/item/assembly/mousetrap/proc/clumsy_check(var/mob/living/user) if((user.is_clumsy() || (user.mutations & DUMB)) && prob(50)) var/which_hand = BP_L_HAND if(!user.hand) which_hand = BP_R_HAND triggered(user, which_hand) user.visible_message(SPAN_WARNING("[user] accidentally sets off \the [src]!"), SPAN_WARNING("You accidentally trigger \the [src]!")) return TRUE return FALSE /obj/item/assembly/mousetrap/on_entered(datum/source, atom/movable/arrived, atom/old_loc, list/atom/old_locs) if(armed) if(israt(arrived)) triggered(arrived) else if(ishuman(arrived)) var/mob/living/carbon/human/H = arrived if(!(H.shoes?.item_flags & ITEM_FLAG_LIGHT_STEP)) triggered(H) H.visible_message(SPAN_WARNING("\The [H] accidentally steps on \the [src]."), SPAN_WARNING("You accidentally step on \the [src].")) else if(isliving(arrived)) var/mob/living/L = arrived triggered(L) L.visible_message(SPAN_WARNING("\The [L] accidentally steps on \the [src]."), SPAN_WARNING("You accidentally step on \the [src].")) /obj/item/assembly/mousetrap/on_found(mob/finder) if(armed) finder.visible_message(SPAN_WARNING("[finder] accidentally sets off \the [src]!"), SPAN_WARNING("You accidentally trigger \the [src]!")) triggered(finder, finder.hand ? BP_L_HAND : BP_R_HAND) return TRUE return FALSE /obj/item/assembly/mousetrap/hitby(atom/movable/hitting_atom, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum) if(!armed) return ..() visible_message(SPAN_WARNING("\The [src] is triggered by \the [hitting_atom].")) triggered(null) /obj/item/assembly/mousetrap/armed icon_state = "mousetraparmed" armed = TRUE /obj/item/assembly/mousetrap/verb/hide_under() set src in oview(1) set name = "Hide" set category = "Object" if(usr.stat) return layer = TURF_LAYER + 0.2 to_chat(usr, SPAN_NOTICE("You hide \the [src]."))