[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
@@ -46,6 +46,8 @@
#define COMSIG_MOB_RESET_PERSPECTIVE "mob_reset_perspective"
/// from base of /client/proc/set_eye() : (atom/old_eye, atom/new_eye)
#define COMSIG_CLIENT_SET_EYE "client_set_eye"
/// from base of /datum/view_data/proc/afterViewChange() : (view)
#define COMSIG_VIEWDATA_UPDATE "viewdata_update"
///from mind/transfer_to. Sent to the receiving mob.
+6
View File
@@ -153,6 +153,7 @@ GLOBAL_LIST_INIT(available_erp_ui_styles, list(
RegisterSignal(mymob, COMSIG_MOB_LOGIN, .proc/client_refresh)
RegisterSignal(mymob, COMSIG_MOB_LOGOUT, .proc/clear_client)
RegisterSignal(mymob, COMSIG_MOB_SIGHT_CHANGE, .proc/update_sightflags)
RegisterSignal(mymob, COMSIG_VIEWDATA_UPDATE, .proc/on_viewdata_update)
update_sightflags(mymob, mymob.sight, NONE)
/datum/hud/proc/client_refresh(datum/source)
@@ -163,6 +164,11 @@ GLOBAL_LIST_INIT(available_erp_ui_styles, list(
if(mymob.canon_client)
UnregisterSignal(mymob.canon_client, COMSIG_CLIENT_SET_EYE)
/datum/hud/proc/on_viewdata_update(datum/source, view)
SIGNAL_HANDLER
view_audit_buttons()
/datum/hud/proc/on_eye_change(datum/source, atom/old_eye, atom/new_eye)
SIGNAL_HANDLER
if(old_eye)
+36 -17
View File
@@ -32,9 +32,10 @@
if(!tracker.marksman.client)
stop_zooming(tracker.marksman)
return
tracker.calculate_params()
if(!length(tracker.marksman.client.keys_held & tracker.marksman.client.movement_keys))
tracker.marksman.face_atom(tracker.given_turf)
animate(tracker.marksman.client, 0.2 SECONDS, easing = SINE_EASING, flags = EASE_OUT, pixel_x = tracker.given_x, pixel_y = tracker.given_y)
animate(tracker.marksman.client, world.tick_lag, pixel_x = tracker.given_x, pixel_y = tracker.given_y)
/datum/component/scope/proc/on_move(atom/movable/source, atom/oldloc, dir, forced)
SIGNAL_HANDLER
@@ -84,6 +85,8 @@
if(iseffect(possible_target))
continue
if(ismob(possible_target))
if(possible_target == tracker.marksman)
continue
return possible_target
if(!possible_target.density)
non_dense_targets += possible_target
@@ -110,9 +113,12 @@
tracker = user.overlay_fullscreen("scope", /atom/movable/screen/fullscreen/scope, 0)
tracker.range_modifier = range_modifier
tracker.marksman = user
tracker.view_list = getviewsize(user.client.view)
tracker.RegisterSignal(user, COMSIG_MOVABLE_MOVED, /atom/movable/screen/fullscreen/scope.proc/on_move)
tracker.RegisterSignal(user, COMSIG_VIEWDATA_UPDATE, /atom/movable/screen/fullscreen/scope.proc/on_viewdata_update)
tracker.calculate_params()
RegisterSignal(user, COMSIG_MOB_SWAP_HANDS, .proc/stop_zooming)
START_PROCESSING(SSfastprocess, src)
START_PROCESSING(SSprojectiles, src)
/**
* We stop zooming, canceling processing, resetting stuff back to normal and deleting our tracker.
@@ -123,7 +129,7 @@
/datum/component/scope/proc/stop_zooming(mob/user)
SIGNAL_HANDLER
STOP_PROCESSING(SSfastprocess, src)
STOP_PROCESSING(SSprojectiles, src)
UnregisterSignal(user, COMSIG_MOB_SWAP_HANDS)
if(user.client)
animate(user.client, 0.2 SECONDS, pixel_x = 0, pixel_y = 0)
@@ -141,14 +147,16 @@
var/range_modifier = 1
/// The mob the scope is on.
var/mob/marksman
/// Client view size of the scoping mob.
var/list/view_list
/// Pixel x we send to the scope component.
var/given_x = 0
var/given_x
/// Pixel y we send to the scope component.
var/given_y = 0
var/given_y
/// The turf we send to the scope component.
var/turf/given_turf
/// The coordinate on our mouseentered, for performance reasons.
COOLDOWN_DECLARE(coordinate_cooldown)
/// Mouse parameters, for calculation.
var/mouse_params
/atom/movable/screen/fullscreen/scope/proc/on_move(atom/source, atom/oldloc, dir, forced)
SIGNAL_HANDLER
@@ -159,20 +167,31 @@
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/scope/proc/on_viewdata_update(datum/source, view)
SIGNAL_HANDLER
view_list = getviewsize(view)
/atom/movable/screen/fullscreen/scope/MouseEntered(location, control, params)
. = ..()
MouseMove(location, control, params)
if(usr == marksman)
calculate_params()
/atom/movable/screen/fullscreen/scope/MouseMove(location, control, params)
if(!marksman?.client || usr != marksman)
if(usr != marksman)
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, VIS_X))
var/icon_y = text2num(LAZYACCESS(modifiers, VIS_Y))
var/list/view = getviewsize(marksman.client.view)
given_x = round(range_modifier * (icon_x - view[1]*world.icon_size/2))
given_y = round(range_modifier * (icon_y - view[2]*world.icon_size/2))
mouse_params = params
/atom/movable/screen/fullscreen/scope/Click(location, control, params)
if(usr == marksman)
calculate_params()
return ..()
/atom/movable/screen/fullscreen/scope/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
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))
given_turf = locate(marksman.x+round(given_x/world.icon_size, 1),marksman.y+round(given_y/world.icon_size, 1),marksman.z)
+2 -2
View File
@@ -38,8 +38,8 @@
assertFormat()
else
resetFormat()
var/datum/hud/our_hud = chief?.mob?.hud_used
our_hud.view_audit_buttons() // Make sure our hud's buttons are in our new size
if(chief?.mob)
SEND_SIGNAL(chief.mob, COMSIG_VIEWDATA_UPDATE, getView())
/datum/view_data/proc/assertFormat()//T-Pose
winset(chief, "mapwindow.map", "zoom=0")
+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."))
@@ -329,7 +329,7 @@
recoil = 2
weapon_weight = WEAPON_HEAVY
mag_type = /obj/item/ammo_box/magazine/sniper_rounds
fire_delay = 40
fire_delay = 4 SECONDS
burst_size = 1
w_class = WEIGHT_CLASS_NORMAL
slot_flags = ITEM_SLOT_BACK
@@ -342,6 +342,13 @@
. = ..()
AddComponent(/datum/component/scope, range_modifier = 2)
/obj/item/gun/ballistic/automatic/sniper_rifle/reset_semicd()
. = ..()
if(suppressed)
playsound(src, 'sound/machines/eject.ogg', 25, TRUE, ignore_walls = FALSE, extrarange = SILENCED_SOUND_EXTRARANGE, falloff_distance = 0)
else
playsound(src, 'sound/machines/eject.ogg', 50, TRUE)
/obj/item/gun/ballistic/automatic/sniper_rifle/syndicate
name = "syndicate sniper rifle"
desc = "An illegally modified .50 cal sniper rifle with suppression compatibility. Quickscoping still doesn't work."
@@ -188,12 +188,12 @@
/obj/item/gun/ballistic/automatic/sniper_rifle
icon = 'modular_skyrat/modules/aesthetics/guns/icons/guns_gubman2.dmi'
icon_state = "sniper"
fire_delay = 60
fire_delay = 6 SECONDS
/obj/item/gun/ballistic/automatic/sniper_rifle/syndicate
icon = 'modular_skyrat/modules/aesthetics/guns/icons/guns_gubman2.dmi'
icon_state = "sniper2"
fire_delay = 55
fire_delay = 5.5 SECONDS
/obj/item/gun/ballistic/automatic/sniper_rifle/modular
name = "AUS-107 anti-materiel rifle"
@@ -211,7 +211,7 @@
icon_state = "sysniper"
fire_sound = 'modular_skyrat/modules/aesthetics/guns/sound/sniperrifle.ogg'
suppressed_sound = 'modular_skyrat/modules/aesthetics/guns/sound/sniperrifle_s.ogg'
fire_delay = 40 //Delay reduced thanks to recoil absorption
fire_delay = 4 SECONDS //Delay reduced thanks to recoil absorption
burst_size = 0.5
recoil = 1
can_suppress = TRUE