Files
Alan 25aac32c63 Migrate /obj/item/assembly to the new attack chain. (#31987)
* Migrate /obj/item/assembly to the new attack chain.

* Migrate more procs.

* Add parent calls to activate_self().

* Add parent call to activate_self() in noise sensor.

* Apply CRUNCH's style suggestions.

Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

* Change igniter attack to interact_with_atom().

* Restore assembly UIs.

* Ensure assembly interact procs fire, ensure fingerprints.

---------

Signed-off-by: Alan <alfalfascout@users.noreply.github.com>
Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
2026-05-17 18:42:49 +00:00

155 lines
4.2 KiB
Plaintext

/obj/item/assembly/mousetrap
name = "mousetrap"
desc = "A handy little spring-loaded trap for catching pesty rodents."
icon_state = "mousetrap"
inhand_icon_state = "mousetrap"
materials = list(MAT_METAL = 800, MAT_GLASS = 200)
origin_tech = "combat=1;materials=2;engineering=1"
var/armed = FALSE
bomb_name = "contact mine"
/obj/item/assembly/mousetrap/examine(mob/user)
. = ..()
if(armed)
. += "It looks like it's armed."
. += SPAN_NOTICE("<b>Alt-Click</b> to hide it.")
/obj/item/assembly/mousetrap/activate()
if(!..())
return
armed = !armed
if(!armed && ishuman(usr))
var/mob/living/carbon/human/user = usr
if((user.getBrainLoss() >= 60 || HAS_TRAIT(user, TRAIT_CLUMSY)) && prob(50))
to_chat(user, "Your hand slips, setting off the trigger.")
pulse(0)
update_icon()
if(usr)
playsound(usr.loc, 'sound/weapons/handcuffs.ogg', 30, TRUE, -3)
/obj/item/assembly/mousetrap/update_icon_state()
icon_state = "mousetrap[armed ? "armed": ""]"
if(holder)
holder.update_icon()
/obj/item/assembly/mousetrap/proc/triggered(mob/target, type = "feet")
if(!armed)
return
var/obj/item/organ/external/affecting = null
if(ishuman(target))
var/mob/living/carbon/human/H = target
if(HAS_TRAIT(H, TRAIT_PIERCEIMMUNE))
playsound(src, 'sound/effects/snap.ogg', 50, TRUE)
armed = FALSE
update_icon()
pulse(FALSE)
return FALSE
switch(type)
if("feet")
if(!H.shoes)
affecting = H.get_organ(pick("l_leg", "r_leg"))
H.Weaken(6 SECONDS)
if("l_hand", "r_hand")
if(!H.gloves)
affecting = H.get_organ(type)
H.Stun(6 SECONDS)
if(affecting)
affecting.receive_damage(1, 0)
else if(ismouse(target))
var/mob/living/basic/mouse/M = target
visible_message(SPAN_DANGER("SPLAT!"))
M.death()
M.splat()
playsound(loc, 'sound/effects/snap.ogg', 50, 1)
layer = MOB_LAYER - 0.2
armed = FALSE
update_icon()
pulse(0)
/obj/item/assembly/mousetrap/activate_self(mob/living/user)
. = ..()
if(!armed)
to_chat(user, SPAN_NOTICE("You arm [src]."))
else
if((user.getBrainLoss() >= 60 || HAS_TRAIT(user, TRAIT_CLUMSY)) && prob(50))
var/which_hand = "l_hand"
if(!user.hand)
which_hand = "r_hand"
triggered(user, which_hand)
user.visible_message(SPAN_WARNING("[user] accidentally sets off [src], breaking [user.p_their()] fingers."), SPAN_WARNING("You accidentally trigger [src]!"))
return
to_chat(user, SPAN_NOTICE("You disarm [src]."))
armed = !armed
update_icon()
playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, TRUE, -3)
/obj/item/assembly/mousetrap/attack_hand(mob/living/user)
if(!armed)
return ..()
if(!((user.getBrainLoss() >= 60 || HAS_TRAIT(user, TRAIT_CLUMSY)) && prob(50)))
return ..()
var/which_hand = "l_hand"
if(!user.hand)
which_hand = "r_hand"
triggered(user, which_hand)
user.visible_message(SPAN_WARNING("[user] accidentally sets off [src], breaking [user.p_their()] fingers."), SPAN_WARNING("You accidentally trigger [src]!"))
/obj/item/assembly/mousetrap/on_atom_entered(datum/source, atom/movable/entered)
if(armed)
if(ishuman(entered))
var/mob/living/carbon/H = entered
if(H.m_intent == MOVE_INTENT_RUN)
triggered(H)
H.visible_message(SPAN_WARNING("[H] accidentally steps on [src]."), SPAN_WARNING("You accidentally step on [src]"))
else if(ismouse(entered))
triggered(entered)
else if(entered.density) // For mousetrap grenades, set off by anything heavy
triggered(entered)
..()
/obj/item/assembly/mousetrap/on_found(mob/finder)
if(armed)
finder.visible_message(SPAN_WARNING("[finder] accidentally sets off [src], breaking [finder.p_their()] fingers."), SPAN_WARNING("You accidentally trigger [src]!"))
triggered(finder, finder.hand ? "l_hand" : "r_hand")
return TRUE // End the search!
return FALSE
/obj/item/assembly/mousetrap/hitby(atom/movable/AM, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum)
if(!armed)
return ..()
visible_message(SPAN_WARNING("[src] is triggered by [AM]."))
triggered(null)
/obj/item/assembly/mousetrap/armed
icon_state = "mousetraparmed"
armed = TRUE
/obj/item/assembly/mousetrap/AltClick(mob/user)
if(user.stat || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || !Adjacent(user))
return
layer = TURF_LAYER + 0.2
to_chat(user, SPAN_NOTICE("You hide [src]."))