From 3f6b96e00092fa74403fa489043b13059ed51b1d Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Fri, 15 Sep 2023 18:28:44 +0200 Subject: [PATCH] [MIRROR] second pass over the SC/FISHER code, incl. bitflags and PDAs [MDB IGNORE] (#23705) * second pass over the SC/FISHER code, incl. bitflags and PDAs * Update flashlight.dm --------- Co-authored-by: Hatterhat <31829017+Hatterhat@users.noreply.github.com> Co-authored-by: Pinta <68373373+softcerv@users.noreply.github.com> --- .../__DEFINES/dcs/signals/signals_saboteur.dm | 3 ++- code/game/machinery/camera/camera.dm | 2 +- code/game/objects/items/devices/flashlight.dm | 4 +-- .../mining/equipment/kinetic_crusher.dm | 2 +- .../carbon/human/species_types/ethereal.dm | 1 + .../modules/mob/living/silicon/robot/robot.dm | 2 +- .../computers/item/computer.dm | 25 +++++++++++++++++-- .../modular_computers/computers/item/pda.dm | 2 +- code/modules/power/floodlight.dm | 2 +- code/modules/power/lighting/light.dm | 2 +- .../projectile/special/lightbreaker.dm | 7 +++--- 11 files changed, 38 insertions(+), 14 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_saboteur.dm b/code/__DEFINES/dcs/signals/signals_saboteur.dm index 5ef536683fe..5b0fef52aee 100644 --- a/code/__DEFINES/dcs/signals/signals_saboteur.dm +++ b/code/__DEFINES/dcs/signals/signals_saboteur.dm @@ -1,4 +1,5 @@ // Light disruptor. Not to be confused with the light eater, which permanently disables lights. /// from /obj/projectile/energy/fisher/on_hit() or /obj/item/gun/energy/recharge/fisher when striking a target -#define COMSIG_HIT_BY_SABOTEUR "hit_by_saboteur" +#define COMSIG_HIT_BY_SABOTEUR "HIT_BY_SABOTEUR" + #define COMSIG_SABOTEUR_SUCCESS (1<<0) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 575464a98af..93ad579848b 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -180,7 +180,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/camera/xray, 0) /obj/machinery/camera/proc/on_saboteur(datum/source, disrupt_duration) SIGNAL_HANDLER emp_act(EMP_LIGHT, reset_time = disrupt_duration) - return TRUE + return COMSIG_SABOTEUR_SUCCESS /obj/machinery/camera/proc/post_emp_reset(thisemp, previous_network) if(QDELETED(src)) diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index ee7a66044fd..735510ae9d4 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -71,8 +71,8 @@ /obj/item/flashlight/proc/toggle_light(mob/user) var/disrupted = FALSE - //playsound(src, on ? sound_on : sound_off, 40, TRUE) SKYRAT EDIT REMOVAL - SOUND HANDLED IN MODULAR FLASHLIGHT.DM on = !on + //playsound(src, on ? sound_on : sound_off, 40, TRUE) SKYRAT EDIT REMOVAL - SOUND HANDLED IN MODULAR FLASHLIGHT.DM if(!COOLDOWN_FINISHED(src, disabled_time)) if(user) balloon_alert(user, "disrupted!") @@ -271,7 +271,7 @@ if(on) toggle_light() COOLDOWN_START(src, disabled_time, disrupt_duration) - return TRUE + return COMSIG_SABOTEUR_SUCCESS /obj/item/flashlight/pen name = "penlight" diff --git a/code/modules/mining/equipment/kinetic_crusher.dm b/code/modules/mining/equipment/kinetic_crusher.dm index 8ae842807a8..caee1bbac8d 100644 --- a/code/modules/mining/equipment/kinetic_crusher.dm +++ b/code/modules/mining/equipment/kinetic_crusher.dm @@ -169,7 +169,7 @@ /obj/item/kinetic_crusher/proc/on_saboteur(datum/source, disrupt_duration) set_light_on(FALSE) playsound(src, 'sound/weapons/empty.ogg', 100, TRUE) - return TRUE + return COMSIG_SABOTEUR_SUCCESS /obj/item/kinetic_crusher/update_icon_state() inhand_icon_state = "crusher[HAS_TRAIT(src, TRAIT_WIELDED)]" // this is not icon_state and not supported by 2hcomponent diff --git a/code/modules/mob/living/carbon/human/species_types/ethereal.dm b/code/modules/mob/living/carbon/human/species_types/ethereal.dm index f087eb6b92c..42c718477bc 100644 --- a/code/modules/mob/living/carbon/human/species_types/ethereal.dm +++ b/code/modules/mob/living/carbon/human/species_types/ethereal.dm @@ -157,6 +157,7 @@ to_chat(our_target, span_warning("Something inside of you crackles in a bad way.")) our_target.take_bodypart_damage(burn = 3, wound_bonus = CANT_WOUND) addtimer(CALLBACK(src, PROC_REF(stop_emp), our_target), disrupt_duration, TIMER_UNIQUE|TIMER_OVERRIDE) + return COMSIG_SABOTEUR_SUCCESS /datum/species/ethereal/proc/on_emag_act(mob/living/carbon/human/H, mob/user) SIGNAL_HANDLER diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 17e59660eb4..30559e616b5 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -477,7 +477,7 @@ if(lamp_enabled) toggle_headlamp(TRUE) to_chat(src, span_warning("Your headlamp was forcibly turned off. Restarting it should fix it, though.")) - return TRUE + return COMSIG_SABOTEUR_SUCCESS /** * Handles headlamp smashing diff --git a/code/modules/modular_computers/computers/item/computer.dm b/code/modules/modular_computers/computers/item/computer.dm index da83445a641..21d2b8352fb 100644 --- a/code/modules/modular_computers/computers/item/computer.dm +++ b/code/modules/modular_computers/computers/item/computer.dm @@ -65,6 +65,8 @@ ///If the computer has a flashlight/LED light built-in. var/has_light = FALSE + /// If the computer's flashlight/LED light has forcibly disabled for a temporary amount of time. + COOLDOWN_DECLARE(disabled_time) /// How far the computer's light can reach, is not editable by players. var/comp_light_luminosity = 3 /// The built-in light's color, editable by players. @@ -127,6 +129,7 @@ UpdateDisplay() if(has_light) add_item_action(/datum/action/item_action/toggle_computer_light) + RegisterSignal(src, COMSIG_HIT_BY_SABOTEUR, PROC_REF(on_saboteur)) if(inserted_disk) inserted_disk = new inserted_disk(src) if(internal_cell) @@ -657,7 +660,7 @@ /obj/item/modular_computer/ui_action_click(mob/user, actiontype) if(istype(actiontype, /datum/action/item_action/toggle_computer_light)) - toggle_flashlight() + toggle_flashlight(user) return return ..() @@ -668,14 +671,32 @@ * Called from ui_act(), does as the name implies. * It is separated from ui_act() to be overwritten as needed. */ -/obj/item/modular_computer/proc/toggle_flashlight() +/obj/item/modular_computer/proc/toggle_flashlight(mob/user) if(!has_light) return FALSE + if(!COOLDOWN_FINISHED(src, disabled_time)) + balloon_alert(user, "disrupted!") + return FALSE set_light_on(!light_on) update_appearance() update_item_action_buttons(force = TRUE) //force it because we added an overlay, not changed its icon return TRUE +/** + * Disables the computer's flashlight/LED light, if it has one, for a given disrupt_duration. + * + * Called when sent COMSIG_HIT_BY_SABOTEUR. + */ +/obj/item/modular_computer/proc/on_saboteur(datum/source, disrupt_duration) + SIGNAL_HANDLER + if(!has_light) + return + set_light_on(FALSE) + update_appearance() + update_item_action_buttons(force = TRUE) //force it because we added an overlay, not changed its icon + COOLDOWN_START(src, disabled_time, disrupt_duration) + return COMSIG_SABOTEUR_SUCCESS + /** * Sets the computer's light color, if it has a light. * diff --git a/code/modules/modular_computers/computers/item/pda.dm b/code/modules/modular_computers/computers/item/pda.dm index bc57f359784..a4b08f2d90f 100644 --- a/code/modules/modular_computers/computers/item/pda.dm +++ b/code/modules/modular_computers/computers/item/pda.dm @@ -379,7 +379,7 @@ .["comp_light_color"] = robo.lamp_color //Makes the flashlight button affect the borg rather than the tablet -/obj/item/modular_computer/pda/silicon/toggle_flashlight() +/obj/item/modular_computer/pda/silicon/toggle_flashlight(mob/user) if(!silicon_owner || QDELETED(silicon_owner)) return FALSE if(iscyborg(silicon_owner)) diff --git a/code/modules/power/floodlight.dm b/code/modules/power/floodlight.dm index 0898e31735b..f36c9b13038 100644 --- a/code/modules/power/floodlight.dm +++ b/code/modules/power/floodlight.dm @@ -293,7 +293,7 @@ /obj/machinery/power/floodlight/proc/on_saboteur(datum/source, disrupt_duration) SIGNAL_HANDLER atom_break(ENERGY) // technically, - return TRUE + return COMSIG_SABOTEUR_SUCCESS /obj/machinery/power/floodlight/atom_break(damage_flag) . = ..() diff --git a/code/modules/power/lighting/light.dm b/code/modules/power/lighting/light.dm index ea6a28a8fe4..4bb153d2c00 100644 --- a/code/modules/power/lighting/light.dm +++ b/code/modules/power/lighting/light.dm @@ -710,7 +710,7 @@ /obj/machinery/light/proc/on_saboteur(datum/source, disrupt_duration) SIGNAL_HANDLER break_light_tube() - return TRUE + return COMSIG_SABOTEUR_SUCCESS /obj/machinery/light/proc/grey_tide(datum/source, list/grey_tide_areas) SIGNAL_HANDLER diff --git a/code/modules/projectiles/projectile/special/lightbreaker.dm b/code/modules/projectiles/projectile/special/lightbreaker.dm index cf273a1d3b2..fd7d3d89e7a 100644 --- a/code/modules/projectiles/projectile/special/lightbreaker.dm +++ b/code/modules/projectiles/projectile/special/lightbreaker.dm @@ -11,11 +11,12 @@ /obj/projectile/energy/fisher/on_hit(atom/target, blocked, pierce_hit) . = ..() - SEND_SIGNAL(target, COMSIG_HIT_BY_SABOTEUR, disrupt_duration) + var/lights_flickered = 0 + if(SEND_SIGNAL(target, COMSIG_HIT_BY_SABOTEUR, disrupt_duration) & COMSIG_SABOTEUR_SUCCESS) + lights_flickered++ if(!isliving(target)) return var/list/things_to_disrupt = list() - var/lights_flickered = 0 if(ishuman(target)) var/mob/living/carbon/human/human_target = target things_to_disrupt = human_target.get_all_gear() @@ -23,7 +24,7 @@ var/mob/living/living_target = target // i guess this covers borgs too? things_to_disrupt = living_target.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE) for(var/obj/item/thingy as anything in things_to_disrupt) - if(SEND_SIGNAL(thingy, COMSIG_HIT_BY_SABOTEUR, disrupt_duration)) + if(SEND_SIGNAL(thingy, COMSIG_HIT_BY_SABOTEUR, disrupt_duration) & COMSIG_SABOTEUR_SUCCESS) lights_flickered++ if(lights_flickered) to_chat(target, span_warning("Your light [lights_flickered > 1 ? "sources flick" : "source flicks"] off."))