Files
Bubberstation/code/modules/assembly/mousetrap.dm
kevinz000 87dbd65811 [READY]] FLIGHTPACKS (AKA cooler, better, and technological wings with a unique gimmick!) (#20860)
* vroom

* wew

* a

* b

* morestuff

* .

* a

* .

* .

* basicsprites+extend/retract

* ...

* .

* thanks travis

* woops

* thankstravisv2

* redundence

* ishouldstopmakingsomanygoddamncommits+empdamage

* stuff

* ..

* ion_trails

* fixes_conflict_1

* fix

* compilesnow

* .

* fuck

* WIP: Multi Step Assembly

* thismightfixitthismightnot

* shoe-attachment

* noselfremoval

* wooops

* tweaksandcrashing

* runtimes

* runtimesfuntimes+crash update 1

* thisprobablywontcompile

* stillwip

* githubPLEASEWORK

* fixes conflicts 3/3

* REFACTORSUNTESTED

* fixingconflicts2

* fixingconflicts3/3

* updates

* stuffs

* ...

* stillWIP

* stufffs

* .

* ..

* runtimesfuntimes2

* stuffs2

* conflictfix

* ...

* fuck

* fix

* bah merge conflicts

* knockback_testing1

* conflictfixing...

* mergeconflicts

* plop

* socloseyetsofar

* tweaksandfixes

* conflicts

* fix

* fixes

* fix

* woops

* woops2

* hotfix

* ...

* flufftextandfixes

* test

* ..

* fix1/2

* stuff

* finallysomeoneteachesmehowtofixthisshit

* FIX

* why

* .

* bitflagsshitflags1

* bitflags-shitflags2

* bitflags-shitflags2

* bitflags_shitflags_4

* autofloating

* minerbuffgetthepun?

* notouchingfloors

* ...

* .

* f l o a t

* kek

* kek

* fixes

* fixes2

* sprites
2016-11-25 13:26:43 +13:00

140 lines
4.4 KiB
Plaintext

/obj/item/device/assembly/mousetrap
name = "mousetrap"
desc = "A handy little spring-loaded trap for catching pesty rodents."
icon_state = "mousetrap"
materials = list(MAT_METAL=100)
origin_tech = "combat=1;materials=2;engineering=1"
attachable = 1
var/armed = 0
/obj/item/device/assembly/mousetrap/examine(mob/user)
..()
if(armed)
user << "It looks like it's armed."
/obj/item/device/assembly/mousetrap/activate()
if(..())
armed = !armed
if(!armed)
if(ishuman(usr))
var/mob/living/carbon/human/user = usr
if((user.getBrainLoss() >= 60) || user.disabilities & CLUMSY && prob(50))
user << "<span class='warning'>Your hand slips, setting off the trigger!</span>"
pulse(0)
update_icon()
if(usr)
playsound(usr.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3)
/obj/item/device/assembly/mousetrap/describe()
return "The pressure switch is [armed?"primed":"safe"]."
/obj/item/device/assembly/mousetrap/update_icon()
if(armed)
icon_state = "mousetraparmed"
else
icon_state = "mousetrap"
if(holder)
holder.update_icon()
/obj/item/device/assembly/mousetrap/proc/triggered(mob/target, type = "feet")
if(!armed)
return
var/obj/item/bodypart/affecting = null
if(ishuman(target))
var/mob/living/carbon/human/H = target
if(PIERCEIMMUNE in H.dna.species.specflags)
playsound(src.loc, 'sound/effects/snap.ogg', 50, 1)
armed = 0
update_icon()
pulse(0)
return 0
switch(type)
if("feet")
if(!H.shoes)
affecting = H.get_bodypart(pick("l_leg", "r_leg"))
H.Weaken(3)
if("l_hand", "r_hand")
if(!H.gloves)
affecting = H.get_bodypart(type)
H.Stun(3)
if(affecting)
if(affecting.receive_damage(1, 0))
H.update_damage_overlays()
else if(ismouse(target))
var/mob/living/simple_animal/mouse/M = target
visible_message("<span class='boldannounce'>SPLAT!</span>")
M.splat()
playsound(src.loc, 'sound/effects/snap.ogg', 50, 1)
armed = 0
update_icon()
pulse(0)
/obj/item/device/assembly/mousetrap/attack_self(mob/living/carbon/human/user)
if(!armed)
user << "<span class='notice'>You arm [src].</span>"
else
if(((user.getBrainLoss() >= 60) || user.disabilities & CLUMSY) && prob(50))
var/which_hand = "l_hand"
if(!(user.active_hand_index % 2))
which_hand = "r_hand"
triggered(user, which_hand)
user.visible_message("<span class='warning'>[user] accidentally sets off [src], breaking their fingers.</span>", \
"<span class='warning'>You accidentally trigger [src]!</span>")
return
user << "<span class='notice'>You disarm [src].</span>"
armed = !armed
update_icon()
playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3)
/obj/item/device/assembly/mousetrap/attack_hand(mob/living/carbon/human/user)
if(armed)
if(((user.getBrainLoss() >= 60) || user.disabilities & CLUMSY) && prob(50))
var/which_hand = "l_hand"
if(!(user.active_hand_index % 2))
which_hand = "r_hand"
triggered(user, which_hand)
user.visible_message("<span class='warning'>[user] accidentally sets off [src], breaking their fingers.</span>", \
"<span class='warning'>You accidentally trigger [src]!</span>")
return
..()
/obj/item/device/assembly/mousetrap/Crossed(atom/movable/AM as mob|obj)
if(armed)
if(ismob(AM))
var/mob/MM = AM
if(!(MM.movement_type & FLYING))
if(ishuman(AM))
var/mob/living/carbon/H = AM
if(H.m_intent == "run")
triggered(H)
H.visible_message("<span class='warning'>[H] accidentally steps on [src].</span>", \
"<span class='warning'>You accidentally step on [src]</span>")
else if(AM.density) // For mousetrap grenades, set off by anything heavy
triggered(AM)
..()
/obj/item/device/assembly/mousetrap/on_found(mob/finder)
if(armed)
finder.visible_message("<span class='warning'>[finder] accidentally sets off [src], breaking their fingers.</span>", \
"<span class='warning'>You accidentally trigger [src]!</span>")
triggered(finder, (finder.active_hand_index % 2 == 0) ? "r_hand" : "l_hand")
return 1 //end the search!
return 0
/obj/item/device/assembly/mousetrap/hitby(A as mob|obj)
if(!armed)
return ..()
visible_message("<span class='warning'>[src] is triggered by [A].</span>")
triggered(null)
/obj/item/device/assembly/mousetrap/armed
icon_state = "mousetraparmed"
armed = 1