Made mousetraps an assembly.

The path has changed from /obj/item/weapon/mousetrap to /obj/item/device/assembly/mousetrap
Deleted mousetraps.dm, and removed the original define from weapon.dm

Added a new /obj/item proc, on_found(). It's called when pockets are emptied, and whenever someone looks in a storage item. Currently used only by mousetraps and facehuggers~

Updated the map with path changes.
Updated the changelog.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4969 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
petethegoat@gmail.com
2012-10-27 16:39:52 +00:00
parent bc933cc10b
commit ce8d8be416
15 changed files with 179 additions and 154 deletions

View File

@@ -1468,23 +1468,6 @@
var/cigarcount = 6
flags = ONBELT | TABLEPASS */
/obj/item/weapon/mousetrap
name = "mousetrap"
desc = "A handy little spring-loaded trap for catching pesty rodents."
icon = 'icons/obj/weapons.dmi'
icon_state = "mousetrap"
item_state = "mousetrap"
w_class = 1
force = null
throwforce = null
var/armed = 0
origin_tech = "combat=1"
/obj/item/weapon/mousetrap/armed
icon_state = "mousetraparmed"
armed = 1
/obj/item/weapon/pai_cable
desc = "A flexible coated cable with a universal jack on one end."
name = "data cable"

View File

@@ -361,7 +361,7 @@
/obj/item/mecha_parts/mecha_equipment/weapon/ballistic/missile_rack/mousetrap_mortar
name = "Mousetrap Mortar"
icon_state = "mecha_mousetrapmrtr"
projectile = /obj/item/weapon/mousetrap
projectile = /obj/item/device/assembly/mousetrap
fire_sound = 'sound/items/bikehorn.ogg'
projectiles = 15
missile_speed = 1.5
@@ -379,8 +379,8 @@
action(target)
if(!action_checks(target)) return
set_ready_state(0)
var/obj/item/weapon/mousetrap/M = new projectile(chassis.loc)
M.armed = 1
var/obj/item/device/assembly/mousetrap/M = new projectile(chassis.loc)
M.secured = 1
playsound(chassis, fire_sound, 60, 1)
M.throw_at(target, missile_range, missile_speed)
projectiles--

View File

@@ -341,6 +341,10 @@
/obj/item/proc/on_enter_storage(obj/item/weapon/storage/S as obj)
return
// called when "found" in pockets and storage items. Returns 1 if the search should end.
/obj/item/proc/on_found(mob/finder as mob)
return
// called after an item is placed in an equipment slot
// user is mob that equipped it
// slot uses the slot_X defines found in setup.dm

View File

@@ -1,94 +0,0 @@
/obj/item/weapon/mousetrap/examine()
set src in oview(12)
..()
if(armed)
usr << "\red It looks like it's armed."
/obj/item/weapon/mousetrap/proc/triggered(mob/target as mob, var/type = "feet")
if(!armed)
return
var/datum/organ/external/affecting = null
if(ishuman(target))
var/mob/living/carbon/human/H = target
switch(type)
if("feet")
if(!H.shoes)
affecting = H.get_organ(pick("l_leg", "r_leg"))
H.Weaken(3)
if("l_hand", "r_hand")
if(!H.gloves)
affecting = H.get_organ(type)
H.Stun(3)
if(affecting)
if(affecting.take_damage(1, 0))
H.UpdateDamageIcon()
H.updatehealth()
else if(ismouse(target))
var/mob/living/simple_animal/mouse/M = target
src.visible_message("\red <b>SPLAT!</b>")
M.splat()
playsound(target.loc, 'sound/effects/snap.ogg', 50, 1)
icon_state = "mousetrap"
armed = 0
/*
else if (ismouse(target))
target.adjustBruteLoss(100)
*/
/obj/item/weapon/mousetrap/attack_self(mob/living/user as mob)
if(!armed)
icon_state = "mousetraparmed"
user << "\blue You arm the mousetrap."
else
icon_state = "mousetrap"
if(( (user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50)))
var/which_hand = "l_hand"
if(!user.hand)
which_hand = "r_hand"
src.triggered(user, which_hand)
user << "\red <B>You accidentally trigger the mousetrap!</B>"
for(var/mob/O in viewers(user, null))
if(O == user)
continue
O.show_message("\red <B>[user] accidentally sets off the mousetrap, breaking their fingers.</B>", 1)
return
user << "\blue You disarm the mousetrap."
armed = !armed
playsound(user.loc, 'sound/weapons/handcuffs.ogg', 30, 1, -3)
/obj/item/weapon/mousetrap/attack_hand(mob/living/user as mob)
if(armed)
if(( (user.getBrainLoss() >= 60 || CLUMSY in user.mutations)) && prob(50))
var/which_hand = "l_hand"
if(!user.hand)
which_hand = "r_hand"
src.triggered(user, which_hand)
user << "\red <B>You accidentally trigger the mousetrap!</B>"
for(var/mob/O in viewers(user, null))
if(O == user)
continue
O.show_message("\red <B>[user] accidentally sets off the mousetrap, breaking their fingers.</B>", 1)
return
..()
/obj/item/weapon/mousetrap/HasEntered(AM as mob|obj)
if(armed)
if(ishuman(AM))
var/mob/living/carbon/H = AM
if(H.m_intent == "run")
src.triggered(H)
H << "\red <B>You accidentally step on the mousetrap!</B>"
for(var/mob/O in viewers(H, null))
if(O == H)
continue
O.show_message("\red <B>[H] accidentally steps on the mousetrap.</B>", 1)
if(ismouse(AM))
triggered(AM)
..()
/obj/item/weapon/mousetrap/hitby(A as mob|obj)
if(!armed)
return ..()
for(var/mob/O in viewers(src, null))
O.show_message("\red <B>The mousetrap is triggered by [A].</B>", 1)
src.triggered(null)

View File

@@ -31,18 +31,12 @@
return L
/obj/item/weapon/storage/proc/show_to(mob/user as mob)
if(user.s_active != src)
for(var/obj/item/I in src)
if(I.on_found(user))
return
if(user.s_active)
user.s_active.hide_from(user)
for(var/obj/item/weapon/mousetrap/MT in src)
if(MT.armed)
for(var/mob/O in viewers(user, null))
if(O == user)
user.show_message(text("\red <B>You reach into the [src.name], but there was a live mousetrap in there!</B>"), 1)
else
user.show_message(text("\red <B>[user] reaches into the [src.name] and sets off a hidden mousetrap!</B>"), 1)
user.drop_from_inventory(MT)
MT.triggered(user, user.hand ? "l_hand" : "r_hand")
return
user.client.screen -= src.boxes
user.client.screen -= src.closer
user.client.screen -= src.contents
@@ -499,12 +493,12 @@
return
/obj/item/weapon/storage/mousetraps/New()
new /obj/item/weapon/mousetrap( src )
new /obj/item/weapon/mousetrap( src )
new /obj/item/weapon/mousetrap( src )
new /obj/item/weapon/mousetrap( src )
new /obj/item/weapon/mousetrap( src )
new /obj/item/weapon/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
new /obj/item/device/assembly/mousetrap( src )
..()
return

View File

@@ -62,11 +62,11 @@
update_icon()
overlays = null
if(a_left)
overlays += "[initial(a_left.icon_state)]_left" //the initial() is probably unnecessary, but you just know
for(var/O in a_left.attached_overlays) //someone is gonna fuck around with the icon_state in the future
overlays += "[a_left.icon_state]_left"
for(var/O in a_left.attached_overlays)
overlays += "[O]_l"
if(a_right)
src.overlays += "[initial(a_right.icon_state)]_right"
src.overlays += "[a_right.icon_state]_right"
for(var/O in a_right.attached_overlays)
overlays += "[O]_r"
if(master)
@@ -98,7 +98,26 @@
a_right.HasProximity(AM)
if(special_assembly)
special_assembly.HasProximity(AM)
return
HasEntered(atom/movable/AM as mob|obj)
if(a_left)
a_left.HasEntered(AM)
if(a_right)
a_right.HasEntered(AM)
if(special_assembly)
special_assembly.HasEntered(AM)
on_found(mob/finder as mob)
if(a_left)
a_left.on_found(finder)
if(a_right)
a_right.on_found(finder)
if(special_assembly)
if(istype(special_assembly, /obj/item))
var/obj/item/S = special_assembly
S.on_found(finder)
Move()

View File

@@ -7,9 +7,6 @@
w_amt = 10
origin_tech = "magnets=1"
secured = 1
activate()
if(!..()) return 0//Cooldown check
var/turf/location = get_turf(loc)

View File

@@ -0,0 +1,115 @@
/obj/item/device/assembly/mousetrap
name = "mousetrap"
desc = "A handy little spring-loaded trap for catching pesty rodents."
icon_state = "mousetrap"
m_amt = 100
w_amt = 10
origin_tech = "combat=1"
var/armed = 0
examine()
..()
if(armed)
usr << "It looks like it's armed."
update_icon()
if(armed)
icon_state = "mousetraparmed"
else
icon_state = "mousetrap"
if(holder)
holder.update_icon()
proc/triggered(mob/target as mob, var/type = "feet")
if(!armed)
return
var/datum/organ/external/affecting = null
if(ishuman(target))
var/mob/living/carbon/human/H = target
switch(type)
if("feet")
if(!H.shoes)
affecting = H.get_organ(pick("l_leg", "r_leg"))
H.Weaken(3)
if("l_hand", "r_hand")
if(!H.gloves)
affecting = H.get_organ(type)
H.Stun(3)
if(affecting)
if(affecting.take_damage(1, 0))
H.UpdateDamageIcon()
H.updatehealth()
else if(ismouse(target))
var/mob/living/simple_animal/mouse/M = target
visible_message("\red <b>SPLAT!</b>")
M.splat()
playsound(target.loc, 'sound/effects/snap.ogg', 50, 1)
armed = 0
update_icon()
pulse(0)
attack_self(mob/living/user as mob)
if(!armed)
user << "<span class='notice'>You arm [src].</span>"
else
if(((user.getBrainLoss() >= 60 || (CLUMSY in user.mutations)) && prob(50)))
var/which_hand = "l_hand"
if(!user.hand)
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)
attack_hand(mob/living/user as mob)
if(armed)
if(((user.getBrainLoss() >= 60 || CLUMSY in user.mutations)) && prob(50))
var/which_hand = "l_hand"
if(!user.hand)
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
..()
HasEntered(AM as mob|obj)
if(armed)
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>")
if(ismouse(AM))
triggered(AM)
..()
on_found(mob/finder as mob)
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.hand ? "l_hand" : "r_hand")
return 1 //end the search!
return 0
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

View File

@@ -84,6 +84,10 @@ var/const/MAX_ACTIVE_TIME = 400
HasProximity(target)
return
/obj/item/clothing/mask/facehugger/on_found(mob/finder as mob)
Attach(finder)
return 1
/obj/item/clothing/mask/facehugger/dropped()
..()
GoActive()

View File

@@ -362,6 +362,9 @@
if("legcuff")
message = "\red <B>[source] is trying to unlegcuff [target]!</B>"
if("uniform")
for(var/obj/item/I in list(target.l_store, target.r_store))
if(I.on_found(source))
return
if(target.w_uniform && !target.w_uniform.canremove)
message = "\red <B>[source] fails to take off \a [target.w_uniform] from [target]'s body!</B>"
else
@@ -369,19 +372,8 @@
if("s_store")
message = "\red <B>[source] is trying to take off \a [target.s_store] from [target]'s suit!</B>"
if("pockets")
for(var/obj/item/weapon/mousetrap/MT in list(target.l_store, target.r_store))
if(MT.armed)
for(var/mob/O in viewers(target, null))
if(O == source)
O.show_message("\red <B>You reach into the [target]'s pockets, but there was a live mousetrap in there!</B>", 1)
else
O.show_message("\red <B>[source] reaches into [target]'s pockets and sets off a hidden mousetrap!</B>", 1)
target.u_equip(MT)
if (target.client)
target.client.screen -= MT
MT.loc = source.loc
MT.triggered(source, source.hand ? "l_hand" : "r_hand")
MT.layer = OBJ_LAYER
for(var/obj/item/I in list(target.l_store, target.r_store))
if(I.on_found(source))
return
message = "\red <B>[source] is trying to empty [target]'s pockets.</B>"
if("CPR")