mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-05-17 04:40:46 +01:00
94cbfb30c3
About The Pull Request Fixes #69043 assemblies not providing a UI when part of a one-tank bomb. (This doesn't count voice analyzers, which don't have UI) Fixes #68139 assemblies triggering themselves (and often turning themselves off). Fixes timers ceasing to loop if the timer is set to less than the 3-second anti-spam threshold. #69335, #68733 signalers occasionally runtiming due to qdel'd weak reference datums. Already addressed by another PR Proximity sensors and mousetraps work on more wire datums, but proximity sensors are still buggy. Igniter-sensor pairs can detonate fuel tanks properly, including plumbed fuel tanks. Fuel tank explosions scale with how much fuel is in them; this is slightly nerfed from existing values. The fuel tank detonation code has been made generic, but other reagent dispensers have rigging turned off. If turned on with a varedit, you can rig and detonate water and other reagent tanks. Reagent tanks can theoretically both explode and spread reagents if it should happen to contain both welding fuel and other stuff. I have not actually tested this part of it, but I have detonated both water tanks and fuel tanks and each works correctly. In making mousetraps work on wire datums, I had the opportunity to make it so that you could place a mousetrap in a door's wire and it would activate when someone passed through the door (useful to bolt a door open when someone authorized goes through, for example). This is a fun mechanic but does not make sense for a simple mousetrap to be so powerful, so it is disabled. Ideally, you could put the laser tripwire in a door's wires to do the same thing, but that would be a massive rework. Mousetraps still work in on-found mode for all wire datums, and will work on items with wiring datums (like C4 and chem bombs) when stepped on. The signaler runtimes were a result of weak_ref datums being deleted, and the communications system not handling that. It's probably not ideal to run null checks in the post_signal loop, but I am not going to worry about it. Many of the assemblies were not properly registering when the assembly holder was attached to an item. This was most important for proximity sensors, but that also has other problems that I haven't been able to track down. The problem with UI not appearing was a result of the transition to TGUI however long ago that was; the proc that assures TGUI that you have the right item needed to be aware of one-tank bombs and similar, or else when you pass along an interact request it says "but you can't see it" and ignores you. Why It's Good For The Game Bugfixen. The thing with the reagent dispensers only got this complicated when I realized that the plumbed fuel tank variant wasn't a subtype and therefore couldn't be rigged. And then... I basically just scaled it because the flat scale no matter the contents of the tank offended me. You could wrench open tanks, drain them entirely of fuel, rig them, and they would still go off like a pile of dynamite. I used to have code in my branch that turned chem bombs into variants depending on the trigger, with mousetraps being mines for example. That's honestly the main reason I went out of my way to make mousetraps work better as assemblies. I could wish it were better supported, but mousetraps on grenade wiring will have to do for now. Changelog cl balance: Welding fuel tank explosions have been scaled slightly down and require the fuel tanks to actually be full of welding fuel fix: You can detonate welding fuel tanks with an igniter-sensor assembly fix: You can reach your one-tank bomb's assembly controls by activating the item in your hand. fix: Certain assemblies should no longer turn themselves off. fix: Clumsy fools handling a mousetrap-based multi-part assembly may set it off by accident /cl
236 lines
7.6 KiB
Plaintext
236 lines
7.6 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"
|
|
custom_materials = list(/datum/material/iron=100)
|
|
attachable = TRUE
|
|
var/armed = FALSE
|
|
drop_sound = 'sound/items/handling/component_drop.ogg'
|
|
pickup_sound = 'sound/items/handling/component_pickup.ogg'
|
|
var/obj/item/host = null
|
|
var/turf/host_turf = null
|
|
|
|
/**
|
|
* update_host: automatically setup host and host_turf
|
|
*
|
|
* Arguments:
|
|
* * force: Re-register signals even if the host or loc is unchanged
|
|
*/
|
|
/obj/item/assembly/mousetrap/proc/update_host(force = FALSE)
|
|
var/obj/item/newhost
|
|
// Pick the first valid object in this list:
|
|
// Wiring datum's owner
|
|
// assembly holder's attached object
|
|
// assembly holder itself
|
|
// us
|
|
newhost = connected?.holder || holder?.master || holder || src
|
|
|
|
// ok look
|
|
// previously this wasn't working and thus no concern, but I made mousetraps work with wires
|
|
// specifically in step-on-the-mousetrap mode, ie, when you enter its turf
|
|
// and as a consequence, you can put a mousetrap in door wires and it will be set off
|
|
// the first time someone walks through a door (enters the door's loc)
|
|
// that's an interesting mechanic (bolt open a door for example) but it's not appropriate for a mousetrap
|
|
// similarly if used on say an apc's wires it would go into effect when someone walked by it. Not appropriate.
|
|
// other assemblies could be made to do something similar instead.
|
|
// mousetrap assemblies will still receive on-found notifications when you open a wiring panel
|
|
// and (whether reasonable or not) mousetraps that do this do still trigger wires
|
|
// the point is for now step-on-mousetrap mode should only work on items
|
|
// maybe it should never have been an assembly in the first place.
|
|
|
|
// tl;dr only trigger step-on mode if the host is an item
|
|
if(!istype(newhost,/obj/item))
|
|
if(host)
|
|
UnregisterSignal(host,COMSIG_MOVABLE_MOVED)
|
|
host = src
|
|
if(isturf(host_turf))
|
|
UnregisterSignal(host_turf,COMSIG_ATOM_ENTERED)
|
|
host_turf = null
|
|
return
|
|
|
|
// If host changed
|
|
if((newhost != host) || force)
|
|
if(host)
|
|
UnregisterSignal(host,COMSIG_MOVABLE_MOVED)
|
|
host = newhost
|
|
RegisterSignal(host,COMSIG_MOVABLE_MOVED,.proc/holder_movement)
|
|
|
|
// If host moved
|
|
if((host_turf != host.loc) || force)
|
|
if(isturf(host_turf))
|
|
UnregisterSignal(host_turf,COMSIG_ATOM_ENTERED)
|
|
host_turf = null
|
|
if(isturf(host.loc))
|
|
host_turf = host.loc
|
|
RegisterSignal(host_turf,COMSIG_ATOM_ENTERED,.proc/on_entered)
|
|
else
|
|
host_turf = null
|
|
|
|
/obj/item/assembly/mousetrap/holder_movement()
|
|
. = ..()
|
|
update_host()
|
|
|
|
/obj/item/assembly/mousetrap/Initialize(mapload)
|
|
. = ..()
|
|
update_host(force = TRUE)
|
|
|
|
/obj/item/assembly/mousetrap/examine(mob/user)
|
|
. = ..()
|
|
. += span_notice("The pressure plate is [armed?"primed":"safe"].")
|
|
|
|
/obj/item/assembly/mousetrap/activate()
|
|
if(..())
|
|
armed = !armed
|
|
if(!armed)
|
|
if(ishuman(usr))
|
|
var/mob/living/carbon/human/user = usr
|
|
if((HAS_TRAIT(user, TRAIT_DUMB) || HAS_TRAIT(user, TRAIT_CLUMSY)) && prob(50))
|
|
to_chat(user, span_warning("Your hand slips, setting off the trigger!"))
|
|
pulse(FALSE)
|
|
update_appearance()
|
|
playsound(src, 'sound/weapons/handcuffs.ogg', 30, TRUE, -3)
|
|
|
|
/obj/item/assembly/mousetrap/update_icon_state()
|
|
icon_state = "mousetrap[armed ? "armed" : ""]"
|
|
return ..()
|
|
|
|
/obj/item/assembly/mousetrap/update_icon(updates=ALL)
|
|
. = ..()
|
|
holder?.update_icon(updates)
|
|
|
|
/obj/item/assembly/mousetrap/on_attach()
|
|
. = ..()
|
|
update_host()
|
|
|
|
/obj/item/assembly/mousetrap/on_detach()
|
|
. = ..()
|
|
update_host()
|
|
|
|
/obj/item/assembly/mousetrap/proc/triggered(mob/target, type = "feet")
|
|
if(!armed)
|
|
return
|
|
armed = FALSE // moved to the top because you could trigger it more than once under some circumstances
|
|
update_appearance()
|
|
var/obj/item/bodypart/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)
|
|
pulse(FALSE)
|
|
return FALSE
|
|
switch(type)
|
|
if("feet")
|
|
if(!H.shoes)
|
|
affecting = H.get_bodypart(pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG))
|
|
H.Paralyze(60)
|
|
if(BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND)
|
|
if(!H.gloves)
|
|
affecting = H.get_bodypart(type)
|
|
H.Stun(60)
|
|
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_boldannounce("SPLAT!"))
|
|
M.splat()
|
|
else if(israt(target))
|
|
var/mob/living/simple_animal/hostile/rat/ratt = target
|
|
visible_message(span_boldannounce("Clink!"))
|
|
ratt.apply_damage(5) //Not lethal, but just enought to make a mark.
|
|
ratt.Stun(1 SECONDS)
|
|
else if(isregalrat(target))
|
|
visible_message(span_boldannounce("Skreeeee!")) //He's simply too large to be affected by a tiny mouse trap.
|
|
playsound(src, 'sound/effects/snap.ogg', 50, TRUE)
|
|
pulse(FALSE)
|
|
|
|
/**
|
|
* clumsy_check: Sets off the mousetrap if handled by a clown (with some probability)
|
|
*
|
|
* Arguments:
|
|
* * user: The mob handling the trap
|
|
*/
|
|
/obj/item/assembly/mousetrap/proc/clumsy_check(mob/living/carbon/human/user)
|
|
if(!armed)
|
|
return FALSE
|
|
if((HAS_TRAIT(user, TRAIT_DUMB) || HAS_TRAIT(user, TRAIT_CLUMSY)) && prob(50))
|
|
var/which_hand = BODY_ZONE_PRECISE_L_HAND
|
|
if(!(user.active_hand_index % 2))
|
|
which_hand = BODY_ZONE_PRECISE_R_HAND
|
|
triggered(user, which_hand)
|
|
user.visible_message(span_warning("[user] accidentally sets off [src], breaking their fingers."), \
|
|
span_warning("You accidentally trigger [src]!"))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/assembly/mousetrap/attack_self(mob/living/carbon/human/user)
|
|
if(!armed)
|
|
to_chat(user, span_notice("You arm [src]."))
|
|
else
|
|
if(clumsy_check(user))
|
|
return
|
|
to_chat(user, span_notice("You disarm [src]."))
|
|
armed = !armed
|
|
update_appearance()
|
|
playsound(src, 'sound/weapons/handcuffs.ogg', 30, TRUE, -3)
|
|
|
|
|
|
// Clumsy check only
|
|
/obj/item/assembly/mousetrap/attack_hand(mob/living/carbon/human/user, list/modifiers)
|
|
if(clumsy_check(user))
|
|
return
|
|
return ..()
|
|
|
|
|
|
/obj/item/assembly/mousetrap/proc/on_entered(datum/source, atom/movable/AM as mob|obj)
|
|
SIGNAL_HANDLER
|
|
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 == MOVE_INTENT_RUN)
|
|
INVOKE_ASYNC(src, .proc/triggered, H)
|
|
H.visible_message(span_warning("[H] accidentally steps on [src]."), \
|
|
span_warning("You accidentally step on [src]"))
|
|
else if(ismouse(MM) || israt(MM) || isregalrat(MM))
|
|
INVOKE_ASYNC(src, .proc/triggered, MM)
|
|
else if(AM.density) // For mousetrap grenades, set off by anything heavy
|
|
INVOKE_ASYNC(src, .proc/triggered, AM)
|
|
|
|
/obj/item/assembly/mousetrap/on_found(mob/finder)
|
|
if(armed)
|
|
if(finder)
|
|
finder.visible_message(span_warning("[finder] accidentally sets off [src], breaking their fingers."), \
|
|
span_warning("You accidentally trigger [src]!"))
|
|
triggered(finder, (finder.active_hand_index % 2 == 0) ? BODY_ZONE_PRECISE_R_HAND : BODY_ZONE_PRECISE_L_HAND)
|
|
return TRUE //end the search!
|
|
else
|
|
visible_message(span_warning("[src] snaps shut!"))
|
|
triggered(loc)
|
|
return FALSE
|
|
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/Destroy()
|
|
if(host)
|
|
UnregisterSignal(host,COMSIG_MOVABLE_MOVED)
|
|
host = null
|
|
if(isturf(host_turf))
|
|
UnregisterSignal(host_turf,COMSIG_ATOM_ENTERED)
|
|
host_turf = null
|
|
return ..()
|
|
|
|
/obj/item/assembly/mousetrap/armed
|
|
icon_state = "mousetraparmed"
|
|
armed = TRUE
|