[MIRROR] (hopefully) improvements to use of scope and kinesis module [MDB IGNORE] (#17302)

* (hopefully) improvements to use of scope and kinesis module (#70934)

## About The Pull Request
so, scope and kinesis are the only things in the game (other than the
body zone selector) which use the function MouseMove. this tracks every
mouse movement, which meant we had to stuff a cooldown on it to not
calculate a ton of useless stuff. this time can misalign if you move
your mouse fast, not registering at all, as well as not working out with
the 0.2 second processing time of the things handling it (the scope
component and kinesis module)
instead of doing that, we are now keeping the mouse parameters as a
variable, which we update with every mousemove to the current
parameters. then we handle the calculations right as we need them (in
the kinesis/scope) module, rather than relying on mousemove cooldowns,
this should hopefully feel way better

## Why It's Good For The Game
😁

## Changelog
🆑
qol: sniper scopes and kinesis module should feel better to use
/🆑

* (hopefully) improvements to use of scope and kinesis module

* seconds

Co-authored-by: Fikou <23585223+Fikou@users.noreply.github.com>
Co-authored-by: tastyfish <crazychris32@gmail.com>
This commit is contained in:
SkyratBot
2022-11-04 17:55:05 +01:00
committed by GitHub
parent 5041cf3497
commit f3faa38e1c
10 changed files with 93 additions and 50 deletions
+29 -20
View File
@@ -48,6 +48,8 @@
. = ..()
if(!.)
return
if(!mod.wearer.client)
return
if(grabbed_atom)
launch()
clear_grab(playsound = FALSE)
@@ -64,15 +66,18 @@
var/mob/living/grabbed_mob = grabbed_atom
grabbed_mob.Stun(mob_stun_time)
playsound(grabbed_atom, 'sound/effects/contractorbatonhit.ogg', 75, TRUE)
START_PROCESSING(SSfastprocess, src)
kinesis_icon = mutable_appearance(icon='icons/effects/effects.dmi', icon_state="kinesis", layer=grabbed_atom.layer-0.1)
kinesis_icon.appearance_flags = RESET_ALPHA|RESET_COLOR|RESET_TRANSFORM
grabbed_atom.add_overlay(kinesis_icon)
kinesis_beam = mod.wearer.Beam(grabbed_atom, "kinesis")
kinesis_catcher = mod.wearer.overlay_fullscreen("kinesis", /atom/movable/screen/fullscreen/kinesis, 0)
kinesis_catcher.kinesis_user = mod.wearer
kinesis_catcher.view_list = getviewsize(mod.wearer.client.view)
kinesis_catcher.RegisterSignal(mod.wearer, COMSIG_MOVABLE_MOVED, /atom/movable/screen/fullscreen/kinesis.proc/on_move)
kinesis_catcher.RegisterSignal(mod.wearer, COMSIG_VIEWDATA_UPDATE, /atom/movable/screen/fullscreen/kinesis.proc/on_viewdata_update)
kinesis_catcher.calculate_params()
soundloop.start()
START_PROCESSING(SSfastprocess, src)
/obj/item/mod/module/anomaly_locked/kinesis/on_deactivation(display_message = TRUE, deleting = FALSE)
. = ..()
@@ -88,7 +93,9 @@
balloon_alert(mod.wearer, "out of range!")
clear_grab()
return
kinesis_catcher.calculate_params()
if(!kinesis_catcher.given_turf)
clear_grab()
return
drain_power(use_power_cost/10)
mod.wearer.setDir(get_dir(mod.wearer, grabbed_atom))
@@ -224,10 +231,11 @@
plane = HUD_PLANE
mouse_opacity = MOUSE_OPACITY_ICON
var/mob/kinesis_user
var/given_x = 16
var/given_y = 16
var/list/view_list
var/given_x
var/given_y
var/turf/given_turf
COOLDOWN_DECLARE(coordinate_cooldown)
var/mouse_params
/atom/movable/screen/fullscreen/kinesis/proc/on_move(atom/source, atom/oldloc, dir, forced)
SIGNAL_HANDLER
@@ -237,28 +245,29 @@
var/y_offset = source.loc.y - oldloc.y
given_turf = locate(given_turf.x+x_offset, given_turf.y+y_offset, given_turf.z)
/atom/movable/screen/fullscreen/kinesis/proc/on_viewdata_update(datum/source, view)
SIGNAL_HANDLER
view_list = getviewsize(view)
/atom/movable/screen/fullscreen/kinesis/MouseEntered(location, control, params)
. = ..()
MouseMove(location, control, params)
if(usr == kinesis_user)
calculate_params()
/atom/movable/screen/fullscreen/kinesis/MouseMove(location, control, params)
if(!kinesis_user?.client || usr != kinesis_user)
if(usr != kinesis_user)
return
if(!COOLDOWN_FINISHED(src, coordinate_cooldown))
return
COOLDOWN_START(src, coordinate_cooldown, 0.2 SECONDS)
var/list/modifiers = params2list(params)
var/icon_x = text2num(LAZYACCESS(modifiers, ICON_X))
var/icon_y = text2num(LAZYACCESS(modifiers, ICON_Y))
var/list/view = getviewsize(kinesis_user.client.view)
icon_x *= view[1]/FULLSCREEN_OVERLAY_RESOLUTION_X
icon_y *= view[2]/FULLSCREEN_OVERLAY_RESOLUTION_Y
var/our_x = round(icon_x / world.icon_size, 1)
var/our_y = round(icon_y / world.icon_size, 1)
var/mob_x = kinesis_user.x
var/mob_y = kinesis_user.y
var/mob_z = kinesis_user.z
given_turf = locate(mob_x+our_x-round(view[1]/2),mob_y+our_y-round(view[2]/2),mob_z)
mouse_params = params
/atom/movable/screen/fullscreen/kinesis/proc/calculate_params()
var/list/modifiers = params2list(mouse_params)
var/icon_x = text2num(LAZYACCESS(modifiers, VIS_X)) || view_list[1]*world.icon_size/2
var/icon_y = text2num(LAZYACCESS(modifiers, VIS_Y)) || view_list[2]*world.icon_size/2
var/our_x = round(icon_x / world.icon_size)
var/our_y = round(icon_y / world.icon_size)
given_turf = locate(kinesis_user.x+our_x-round(view_list[1]/2),kinesis_user.y+our_y-round(view_list[2]/2),kinesis_user.z)
given_x = round(icon_x - world.icon_size * our_x, 1)
given_y = round(icon_y - world.icon_size * our_y, 1)
+3 -3
View File
@@ -315,10 +315,10 @@
blind_message = span_hear("You hear a charging sound."))
playsound(src, 'sound/items/modsuit/loader_charge.ogg', 75, TRUE)
balloon_alert(mod.wearer, "you start charging...")
animate(mod.wearer, 0.3 SECONDS, pixel_z = 16, flags = ANIMATION_RELATIVE|SINE_EASING|EASE_OUT)
animate(mod.wearer, 0.3 SECONDS, pixel_z = 16, flags = ANIMATION_RELATIVE, easing = SINE_EASING|EASE_OUT)
addtimer(CALLBACK(mod.wearer, /atom.proc/SpinAnimation, 3, 2), 0.3 SECONDS)
if(!do_after(mod.wearer, 1 SECONDS, target = mod))
animate(mod.wearer, 0.2 SECONDS, pixel_z = -16, flags = ANIMATION_RELATIVE|SINE_EASING|EASE_IN)
animate(mod.wearer, 0.2 SECONDS, pixel_z = -16, flags = ANIMATION_RELATIVE, easing = SINE_EASING|EASE_IN)
return
animate(mod.wearer)
drain_power(use_power_cost)
@@ -332,7 +332,7 @@
if(!user)
return
user.transform = user.transform.Turn(angle)
animate(user, 0.2 SECONDS, pixel_z = -16, flags = ANIMATION_RELATIVE|SINE_EASING|EASE_IN)
animate(user, 0.2 SECONDS, pixel_z = -16, flags = ANIMATION_RELATIVE, easing = SINE_EASING|EASE_IN)
/obj/item/mod/module/power_kick/proc/on_throw_impact(mob/living/source, atom/target, datum/thrownthing/thrownthing)
SIGNAL_HANDLER
+3 -3
View File
@@ -118,12 +118,12 @@
pre_matrix.Scale(4, 0.25)
var/matrix/post_matrix = matrix()
post_matrix.Scale(0.25, 4)
animate(mod.wearer, teleport_time, color = COLOR_CYAN, transform = pre_matrix.Multiply(mod.wearer.transform), easing = EASE_OUT)
animate(mod.wearer, teleport_time, color = COLOR_CYAN, transform = pre_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_OUT)
if(!do_after(mod.wearer, teleport_time, target = mod))
balloon_alert(mod.wearer, "interrupted!")
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = EASE_IN)
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_IN)
return
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = EASE_IN)
animate(mod.wearer, teleport_time*0.1, color = null, transform = post_matrix.Multiply(mod.wearer.transform), easing = SINE_EASING|EASE_IN)
if(!do_teleport(mod.wearer, target_turf, asoundin = 'sound/effects/phasein.ogg'))
return
drain_power(use_power_cost)
+1 -1
View File
@@ -240,7 +240,7 @@
var/atom/game_renderer = mod.wearer.hud_used.get_plane_master(RENDER_PLANE_GAME)
var/matrix/render_matrix = matrix(game_renderer.transform)
render_matrix.Scale(1.25, 1.25)
animate(game_renderer, launch_time, flags = SINE_EASING|EASE_IN, transform = render_matrix)
animate(game_renderer, launch_time, transform = render_matrix)
var/current_time = world.time
mod.wearer.visible_message(span_warning("[mod.wearer] starts whirring!"), \
blind_message = span_hear("You hear a whirring sound."))