From 9d69f3aecf6a0070861688c5648479e8db6b679d Mon Sep 17 00:00:00 2001 From: fira Date: Fri, 20 Oct 2023 15:57:35 +0200 Subject: [PATCH] Fixes bugs with designator usage (#4693) # About the pull request The Laser Designator is a JTACer's workhorse and it's CLUNKY AS HELL. This fixes two main bugs: * The `interactee` is not properly cleared when using the designator (or any zoomed item), causing it to be unset instead of set the next time you use it. This means if you look up then back down your designator, you can't laze. * The interaction system wasn't made with movement in mind. It is a problem because zoom system allows movement, and designators are where the two meet. Now, they can explicitely keep interaction despite movement. # Explain why it's good for the game QoL that should have been done 6 years ago, give or take Because Zooming interactions are an awful mess, i'm flagging this for Testmerge where it'll inevitably break down # Testing Photographs and Procedure I take designator, i look, i try to laze. I put them down, move, do it again. And again. Several combinations of actions. The unzoom logic is blatantly busted and out of scope of the PR. # Changelog :cl: fix: Fixed Rangefinders/Designators preventing you from lazing if you looked up/down them without moving. fix: Fixed Rangefinders/Designators forcing you to look up/down again if you had moved while using them. /:cl: --- code/__DEFINES/dcs/signals/atom/mob/living/signals_human.dm | 4 ++++ code/game/objects/items.dm | 2 ++ code/game/objects/items/devices/binoculars.dm | 6 +++++- code/modules/mob/living/carbon/human/human_movement.dm | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/dcs/signals/atom/mob/living/signals_human.dm b/code/__DEFINES/dcs/signals/atom/mob/living/signals_human.dm index 0a9e00b59e04..6614272d33e5 100644 --- a/code/__DEFINES/dcs/signals/atom/mob/living/signals_human.dm +++ b/code/__DEFINES/dcs/signals/atom/mob/living/signals_human.dm @@ -36,6 +36,10 @@ #define COMSIG_HUMAN_UPDATE_SIGHT "human_update_sight" #define COMPONENT_OVERRIDE_UPDATE_SIGHT (1<<0) +///from /mob/living/carbon/human/movement_delay() +#define COMSIG_HUMAN_MOVEMENT_CANCEL_INTERACTION "human_movement_cancel_interaction" + #define COMPONENT_HUMAN_MOVEMENT_KEEP_USING (1<<0) + ///from /mob/living/carbon/human/update_sight() #define COMSIG_HUMAN_POST_UPDATE_SIGHT "human_post_update_sight" ///from /mob/living/carbon/human/movement_delay(): (list/movedata) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 077c0a463aaa..2d142789fdaf 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -824,6 +824,8 @@ cases. Override_icon_state should be a list.*/ unzoom(user) /obj/item/proc/unzoom(mob/living/user) + if(user.interactee == src) + user.unset_interaction() var/zoom_device = zoomdevicename ? "\improper [zoomdevicename] of [src]" : "\improper [src]" INVOKE_ASYNC(user, TYPE_PROC_REF(/atom, visible_message), SPAN_NOTICE("[user] looks up from [zoom_device]."), SPAN_NOTICE("You look up from [zoom_device].")) diff --git a/code/game/objects/items/devices/binoculars.dm b/code/game/objects/items/devices/binoculars.dm index a4589fb1dd78..2d44ce076f30 100644 --- a/code/game/objects/items/devices/binoculars.dm +++ b/code/game/objects/items/devices/binoculars.dm @@ -38,10 +38,14 @@ /obj/item/device/binoculars/on_set_interaction(mob/user) flags_atom |= RELAY_CLICK - + RegisterSignal(user, COMSIG_HUMAN_MOVEMENT_CANCEL_INTERACTION, PROC_REF(interaction_handler)) /obj/item/device/binoculars/on_unset_interaction(mob/user) flags_atom &= ~RELAY_CLICK + UnregisterSignal(user, COMSIG_HUMAN_MOVEMENT_CANCEL_INTERACTION) + +/obj/item/device/binoculars/proc/interaction_handler() + return COMPONENT_HUMAN_MOVEMENT_KEEP_USING /obj/item/device/binoculars/civ desc = "A pair of binoculars." diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index e4ed65107f03..1a906dfa5c11 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -4,7 +4,8 @@ recalculate_move_delay = FALSE if(interactee)// moving stops any kind of interaction - unset_interaction() + if(!(SEND_SIGNAL(src, COMSIG_HUMAN_MOVEMENT_CANCEL_INTERACTION) & COMPONENT_HUMAN_MOVEMENT_KEEP_USING)) + unset_interaction() if(species.slowdown) . += species.slowdown