From bc4eae9a95de33cae79d11a8ddd19db59a66e40a Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 4 Jul 2024 07:13:06 +0200 Subject: [PATCH] [MIRROR] You no longer need to reach the very edge of the game screen to reach the maximum zoom range when scoped (#28584) * You no longer need to reach the very edge of the game screen to reach the maximum zoom range when scoped (#84544) ## About The Pull Request This PR multiplies, by 1.1, and caps the x and y offset coords of the zoom cursor catcher to make it humanly beareable to reach the maximum zoom range without slipping the cursor out of the game screen. ## Why It's Good For The Game The scope component is nice but it can be annoying at times. ## Changelog :cl: qol: You no longer need to reach the very edge of the game screen to reach the maximum zoom range when scoped. /:cl: * You no longer need to reach the very edge of the game screen to reach the maximum zoom range when scoped --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/datums/components/scope.dm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/code/datums/components/scope.dm b/code/datums/components/scope.dm index dfc9d1c66c4..087eb0c06d2 100644 --- a/code/datums/components/scope.dm +++ b/code/datums/components/scope.dm @@ -1,3 +1,6 @@ +///Used to allow reaching the maximum offset range without exiting the boundaries of the game screen. +#define MOUSE_POINTER_OFFSET_MULT 1.1 + ///A component that allows players to use the item to zoom out. Mainly intended for firearms, but now works with other items too. /datum/component/scope /// How far we can extend, with modifier of 1, up to our vision edge, higher numbers multiply. @@ -249,6 +252,12 @@ icon_y = text2num(LAZYACCESS(modifiers, ICON_Y)) if(isnull(icon_y)) icon_y = view_list[2]*world.icon_size/2 - given_x = round(range_modifier * (icon_x - view_list[1]*world.icon_size/2)) - given_y = round(range_modifier * (icon_y - view_list[2]*world.icon_size/2)) + var/x_cap = range_modifier * view_list[1]*world.icon_size / 2 + var/y_cap = range_modifier * view_list[2]*world.icon_size / 2 + var/uncapped_x = round(range_modifier * (icon_x - view_list[1]*world.icon_size/2) * MOUSE_POINTER_OFFSET_MULT) + var/uncapped_y = round(range_modifier * (icon_y - view_list[2]*world.icon_size/2) * MOUSE_POINTER_OFFSET_MULT) + given_x = clamp(uncapped_x, -x_cap, x_cap) + given_y = clamp(uncapped_y, -y_cap, y_cap) given_turf = locate(owner.x+round(given_x/world.icon_size, 1),owner.y+round(given_y/world.icon_size, 1),owner.z) + +#undef MOUSE_POINTER_OFFSET_MULT