mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Re-adds support for pixel shifting (#17332)
* Re-adds support for pixel shifting * Allow rebinding * fuck * Reset upon walking
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#define COMSIG_BLOCK_RELAYMOVE (1<<0)
|
||||
///from base of atom/setDir(): (old_dir, new_dir). Called before the direction changes.
|
||||
#define COMSIG_ATOM_DIR_CHANGE "atom_dir_change"
|
||||
///from base of atom/setShift(): (dir). Called before the shift changes.
|
||||
#define COMSIG_ATOM_SHIFT_CHANGE "atom_shift_change"
|
||||
/// from /datum/component/singularity/proc/can_move(), as well as /obj/energy_ball/proc/can_move()
|
||||
/// if a callback returns `SINGULARITY_TRY_MOVE_BLOCK`, then the singularity will not move to that turf
|
||||
#define COMSIG_ATOM_SINGULARITY_TRY_MOVE "atom_singularity_try_move"
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
return TRUE
|
||||
var/cd = cooldown
|
||||
if (is_keybind)
|
||||
cd = 1 SECONDS // cooldown when used as a keybind
|
||||
cd = 2 SECONDS // cooldown when used as a keybind
|
||||
if(user.emotes_used && user.emotes_used[src] + cd > world.time)
|
||||
return FALSE
|
||||
if(!update)
|
||||
|
||||
@@ -228,3 +228,18 @@
|
||||
|
||||
/datum/keybinding/mob/prevent_movement/up(client/user)
|
||||
user.movement_locked = FALSE
|
||||
|
||||
|
||||
/datum/keybinding/mob/pixel_shift
|
||||
hotkey_keys = list("CtrlShift")
|
||||
name = "pixel_shift"
|
||||
full_name = "Pixel shift"
|
||||
description = "Allows you to shift your characters by a few pixels"
|
||||
|
||||
/datum/keybinding/mob/prevent_movement/down(client/user)
|
||||
user.movement_locked = TRUE // we also set this to ensure we don't move
|
||||
user.pixel_shifting = TRUE
|
||||
|
||||
/datum/keybinding/mob/prevent_movement/up(client/user)
|
||||
user.movement_locked = FALSE
|
||||
user.pixel_shifting = FALSE
|
||||
|
||||
@@ -826,6 +826,31 @@
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_DIR_CHANGE, dir, newdir)
|
||||
dir = newdir
|
||||
|
||||
/**
|
||||
* Used to change the pixel shift of an atom
|
||||
*/
|
||||
/atom/proc/setShift(dir)
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
SEND_SIGNAL(src, COMSIG_ATOM_SHIFT_CHANGE, dir)
|
||||
|
||||
var/new_x = pixel_x
|
||||
var/new_y = pixel_y
|
||||
|
||||
if (dir & NORTH)
|
||||
new_y++
|
||||
|
||||
if (dir & EAST)
|
||||
new_x++
|
||||
|
||||
if (dir & SOUTH)
|
||||
new_y--
|
||||
|
||||
if (dir & WEST)
|
||||
new_x--
|
||||
|
||||
pixel_x = clamp(new_x, -16, 16)
|
||||
pixel_y = clamp(new_y, -16, 16)
|
||||
|
||||
///Handle melee attack by a mech
|
||||
/atom/proc/mech_melee_attack(obj/mecha/M, equip_allowed = TRUE)
|
||||
return
|
||||
|
||||
@@ -154,6 +154,8 @@
|
||||
var/list/movement_keys = list()
|
||||
///Are we locking our movement input?
|
||||
var/movement_locked = FALSE
|
||||
///Are we trying to pixel-shift
|
||||
var/pixel_shifting = FALSE
|
||||
|
||||
/// A buffer of currently held keys.
|
||||
var/list/keys_held = list()
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
if((movement_dir & EAST) && (movement_dir & WEST))
|
||||
movement_dir &= ~(EAST|WEST)
|
||||
|
||||
if(user.movement_locked)
|
||||
if (user.pixel_shifting)
|
||||
setShift(movement_dir)
|
||||
else if(user.movement_locked)
|
||||
setDir(movement_dir)
|
||||
else
|
||||
user.Move(get_step(src, movement_dir), movement_dir)
|
||||
|
||||
@@ -879,81 +879,13 @@
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
///Hidden verb to turn east
|
||||
/mob/verb/eastface()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
/mob/setShift(dir)
|
||||
if (!canface())
|
||||
return FALSE
|
||||
setDir(EAST)
|
||||
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
|
||||
return TRUE
|
||||
|
||||
///Hidden verb to turn west
|
||||
/mob/verb/westface()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
setDir(WEST)
|
||||
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
|
||||
return TRUE
|
||||
is_shifted = TRUE
|
||||
|
||||
///Hidden verb to turn north
|
||||
/mob/verb/northface()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
setDir(NORTH)
|
||||
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
|
||||
return TRUE
|
||||
|
||||
///Hidden verb to turn south
|
||||
/mob/verb/southface()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
setDir(SOUTH)
|
||||
client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY
|
||||
return TRUE
|
||||
|
||||
/mob/verb/eastshift()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
if (istype(src,/mob/living/silicon/ai) || istype(src,/mob/camera))
|
||||
return FALSE
|
||||
if(pixel_x <= 16)
|
||||
pixel_x++
|
||||
is_shifted = TRUE
|
||||
|
||||
/mob/verb/westshift()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
if (istype(src,/mob/living/silicon/ai) || istype(src,/mob/camera))
|
||||
return FALSE
|
||||
if(pixel_x >= -16)
|
||||
pixel_x--
|
||||
is_shifted = TRUE
|
||||
|
||||
/mob/verb/northshift()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
if (istype(src,/mob/living/silicon/ai) || istype(src,/mob/camera))
|
||||
return FALSE
|
||||
if(pixel_y <= 16)
|
||||
pixel_y++
|
||||
is_shifted = TRUE
|
||||
|
||||
/mob/verb/southshift()
|
||||
set hidden = TRUE
|
||||
if(!canface())
|
||||
return FALSE
|
||||
if (istype(src,/mob/living/silicon/ai) || istype(src,/mob/camera))
|
||||
return FALSE
|
||||
if(pixel_y >= -16)
|
||||
pixel_y--
|
||||
is_shifted = TRUE
|
||||
return ..()
|
||||
|
||||
///This might need a rename but it should replace the can this mob use things check
|
||||
/mob/proc/IsAdvancedToolUser()
|
||||
|
||||
Reference in New Issue
Block a user