From 9fd0b4e77071355cf5d92a73e47789ac2bb1f7c4 Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Tue, 23 May 2023 01:55:11 +0100 Subject: [PATCH] Fixes bypassing integrated circuit cooldowns with module components. (#75581) ## About The Pull Request See title. In order for this change to work, these components will not work if there is no shell, but this will change nothing user-facing because all player-facing circuits require shells to function in the first place anyways. ## Why It's Good For The Game Fixes a cooldown bypass bug. Closes #75580 ## Changelog :cl: fix: Fixed bypassing component cooldowns with module components. /:cl: --------- Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> --- .../wiremod/components/action/soundemitter.dm | 7 +++++-- code/modules/wiremod/components/action/speech.dm | 12 +++++------- .../wiremod/components/bci/hud/target_intercept.dm | 8 ++++++-- .../wiremod/components/sensors/view_sensor.dm | 7 +++++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/code/modules/wiremod/components/action/soundemitter.dm b/code/modules/wiremod/components/action/soundemitter.dm index ea43e937711..6ee9b273fae 100644 --- a/code/modules/wiremod/components/action/soundemitter.dm +++ b/code/modules/wiremod/components/action/soundemitter.dm @@ -84,7 +84,10 @@ else ui_color = initial(ui_color) - if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER)) + if(!parent.shell) + return + + if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER)) return var/sound_to_play = options_map[sound_file.value] @@ -99,4 +102,4 @@ playsound(src, sound_to_play, actual_volume, TRUE, frequency = actual_frequency) - TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown) + TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_SOUNDEMITTER, sound_cooldown) diff --git a/code/modules/wiremod/components/action/speech.dm b/code/modules/wiremod/components/action/speech.dm index 10d56860566..809c473c14a 100644 --- a/code/modules/wiremod/components/action/speech.dm +++ b/code/modules/wiremod/components/action/speech.dm @@ -23,15 +23,13 @@ message = add_input_port("Message", PORT_TYPE_STRING, trigger = null) /obj/item/circuit_component/speech/input_received(datum/port/input/port) + if(!parent.shell) + return - if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_SPEECH)) + if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_SPEECH)) return if(message.value) var/atom/movable/shell = parent.shell - // Prevents appear as the individual component if there is a shell. - if(shell) - shell.say(message.value, forced = "circuit speech | [key_name(parent.get_creator())]") - else - say(message.value, forced = "circuit speech | [parent.get_creator()]") - TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown) + shell.say(message.value, forced = "circuit speech | [key_name(parent.get_creator())]") + TIMER_COOLDOWN_START(shell, COOLDOWN_CIRCUIT_SPEECH, speech_cooldown) diff --git a/code/modules/wiremod/components/bci/hud/target_intercept.dm b/code/modules/wiremod/components/bci/hud/target_intercept.dm index 1cd2ff997dc..8352b0aead9 100644 --- a/code/modules/wiremod/components/bci/hud/target_intercept.dm +++ b/code/modules/wiremod/components/bci/hud/target_intercept.dm @@ -35,11 +35,14 @@ if(!bci) return + if(!parent.shell) + return + var/mob/living/owner = bci.owner if(!owner || !istype(owner) || !owner.client) return - if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_TARGET_INTERCEPT)) + if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT)) return to_chat(owner, "Left-click to trigger target interceptor!") @@ -55,7 +58,8 @@ user.client.click_intercept = null clicked_atom.set_output(object) trigger_output.set_output(COMPONENT_SIGNAL) - TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_TARGET_INTERCEPT, intercept_cooldown) + if(parent.shell) + TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_TARGET_INTERCEPT, intercept_cooldown) /obj/item/circuit_component/target_intercept/get_ui_notices() . = ..() diff --git a/code/modules/wiremod/components/sensors/view_sensor.dm b/code/modules/wiremod/components/sensors/view_sensor.dm index e6a190a829d..f65853986e3 100644 --- a/code/modules/wiremod/components/sensors/view_sensor.dm +++ b/code/modules/wiremod/components/sensors/view_sensor.dm @@ -34,7 +34,10 @@ . += create_ui_notice("Scan Cooldown: [DisplayTimeText(view_cooldown)]", "orange", "stopwatch") /obj/item/circuit_component/view_sensor/input_received(datum/port/input/port) - if(TIMER_COOLDOWN_CHECK(parent, COOLDOWN_CIRCUIT_VIEW_SENSOR)) + if(!parent.shell) + return + + if(TIMER_COOLDOWN_CHECK(parent.shell, COOLDOWN_CIRCUIT_VIEW_SENSOR)) result.set_output(null) cooldown.set_output(COMPONENT_SIGNAL) return @@ -66,4 +69,4 @@ object_list += target result.set_output(object_list) - TIMER_COOLDOWN_START(parent, COOLDOWN_CIRCUIT_VIEW_SENSOR, view_cooldown) + TIMER_COOLDOWN_START(parent.shell, COOLDOWN_CIRCUIT_VIEW_SENSOR, view_cooldown)