mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-10 00:43:14 +00:00
* Restores Spell Card targetting behaviour (#73706) ## About The Pull Request Fixes #52946 This has been broken ever since #44112 which apparently removed the proc in this component which selected a target for performance reasons and just... didn't replace it with anything else? So it's been bricked ever since. In order to restore the removed mouse tracking behaviour I implemented the pattern used in scoped weapons and the kinesis module. As this was the third thing I could find to use this code, I abstracted it out into an object where most of the shared behaviour lives. I tested those things too and they still seem to do what they used to. Here it is in action: https://user-images.githubusercontent.com/7483112/221954852-22244bb1-7c87-452d-a9b0-ebed81c4c1ef.mp4 Because this spell now applies a full screen overlay in order to function, it's really begging for someone to make some touhou-style art with cards and patterns around the edge of the screen while you are in aiming mode, but I'm not going to be the one to make it. I tidied this component up and refactored it as best I could while I was reworking it to use a full screen overlay but I am... not totally confident that it should be a component at all given that it keeps being created and destroyed. But also it has worked that way for like four years now, so who am I to say. Oh yeah also the icon for this spell broke, so I fixed it. ## Why It's Good For The Game Makes a reasonably terrible wizard spell marginally less bad. Maybe now that this component works, some other things can use it? If we make a fourth thing which follows your cursor it won't need to copy/paste code around. ## Changelog 🆑 fix: Spell Cards from the Wizard spell will now home in somewhat on the target nearest to your cursor. fix: The Spell Cards spell now displays the correct icon instead of a big red "error" text. /🆑 * Restores Spell Card targetting behaviour --------- Co-authored-by: Jacquerel <hnevard@gmail.com>
63 lines
2.3 KiB
Plaintext
63 lines
2.3 KiB
Plaintext
/// An effect which tracks the cursor's location on the screen
|
|
/atom/movable/screen/fullscreen/cursor_catcher
|
|
icon_state = "fullscreen_blocker" // Fullscreen semi transparent icon
|
|
plane = HUD_PLANE
|
|
mouse_opacity = MOUSE_OPACITY_ICON
|
|
/// The mob whose cursor we are tracking.
|
|
var/mob/owner
|
|
/// Client view size of the scoping mob.
|
|
var/list/view_list
|
|
/// Pixel x we send to the scope component.
|
|
var/given_x
|
|
/// Pixel y we send to the scope component.
|
|
var/given_y
|
|
/// The turf we send to the scope component.
|
|
var/turf/given_turf
|
|
/// Mouse parameters, for calculation.
|
|
var/mouse_params
|
|
|
|
/// Links this up with a mob
|
|
/atom/movable/screen/fullscreen/cursor_catcher/proc/assign_to_mob(mob/owner)
|
|
src.owner = owner
|
|
view_list = getviewsize(owner.client.view)
|
|
RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
|
|
RegisterSignal(owner, COMSIG_VIEWDATA_UPDATE, PROC_REF(on_viewdata_update))
|
|
calculate_params()
|
|
|
|
/// Update when the mob we're assigned to has moved
|
|
/atom/movable/screen/fullscreen/cursor_catcher/proc/on_move(atom/source, atom/oldloc, dir, forced)
|
|
SIGNAL_HANDLER
|
|
|
|
if(!given_turf)
|
|
return
|
|
var/x_offset = source.loc.x - oldloc.x
|
|
var/y_offset = source.loc.y - oldloc.y
|
|
given_turf = locate(given_turf.x+x_offset, given_turf.y+y_offset, given_turf.z)
|
|
|
|
/// Update when our screen size changes
|
|
/atom/movable/screen/fullscreen/cursor_catcher/proc/on_viewdata_update(datum/source, view)
|
|
SIGNAL_HANDLER
|
|
|
|
view_list = getviewsize(view)
|
|
|
|
/atom/movable/screen/fullscreen/cursor_catcher/MouseEntered(location, control, params)
|
|
. = ..()
|
|
MouseMove(location, control, params)
|
|
if(usr == owner)
|
|
calculate_params()
|
|
|
|
/atom/movable/screen/fullscreen/cursor_catcher/MouseMove(location, control, params)
|
|
if(usr != owner)
|
|
return
|
|
mouse_params = params
|
|
|
|
/atom/movable/screen/fullscreen/cursor_catcher/proc/calculate_params()
|
|
var/list/modifiers = params2list(mouse_params)
|
|
var/icon_x = text2num(LAZYACCESS(modifiers, VIS_X))
|
|
var/icon_y = text2num(LAZYACCESS(modifiers, VIS_Y))
|
|
var/our_x = round(icon_x / world.icon_size)
|
|
var/our_y = round(icon_y / world.icon_size)
|
|
given_turf = locate(owner.x + our_x - round(view_list[1]/2), owner.y + our_y - round(view_list[2]/2), owner.z)
|
|
given_x = round(icon_x - world.icon_size * our_x, 1)
|
|
given_y = round(icon_y - world.icon_size * our_y, 1)
|