diff --git a/code/__SANDCODE/DEFINES/keybindings.dm b/code/__SANDCODE/DEFINES/keybindings.dm new file mode 100644 index 0000000000..ac65f5acdb --- /dev/null +++ b/code/__SANDCODE/DEFINES/keybindings.dm @@ -0,0 +1 @@ +#define COMSIG_KB_MOB_PIXELSHIFT "keybinding_mob_pixelshift" diff --git a/code/game/atoms.dm b/code/game/atoms.dm index 03338e9eaa..ad7b29ebab 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -106,6 +106,11 @@ /// A luminescence-shifted value of the last color calculated for chatmessage overlays var/chat_color_darkened + // Use SET_BASE_PIXEL(x, y) to set these in typepath definitions, it'll handle pixel_x and y for you + ///Default pixel x shifting for the atom's icon. + var/base_pixel_x = 0 + ///Default pixel y shifting for the atom's icon. + var/base_pixel_y = 0 ///Used for changing icon states for different base sprites. var/base_icon_state diff --git a/code/modules/keybindings/keybind/movement.dm b/code/modules/keybindings/keybind/movement.dm index 296b127cb4..4e14b69ae9 100644 --- a/code/modules/keybindings/keybind/movement.dm +++ b/code/modules/keybindings/keybind/movement.dm @@ -74,7 +74,7 @@ var/mob/M = user.mob M.westface() return TRUE - +/* /datum/keybinding/mob/shift_north hotkey_keys = list("CtrlShiftW", "CtrlShiftNorth") name = "pixel_shift_north" @@ -122,7 +122,7 @@ var/mob/M = user.mob M.westshift() return TRUE - +*/ /datum/keybinding/living/hold_sprint hotkey_keys = list() classic_keys = list() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 63021287e5..8794f2f9a3 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -669,7 +669,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) setDir(SOUTH) client.last_turn = world.time + MOB_FACE_DIRECTION_DELAY return TRUE - +/* /mob/verb/eastshift() set hidden = TRUE if(!canface()) @@ -701,7 +701,7 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) if(pixel_y >= -32) pixel_y-- is_shifted = TRUE - +*/ /mob/proc/IsAdvancedToolUser()//This might need a rename but it should replace the can this mob use things check return FALSE diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 138a3b9662..4f61a0260b 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -54,6 +54,8 @@ var/resting = 0 //Carbon var/lying = 0 var/lying_prev = 0 + + /// Whether the mob is pixel shifted or not var/is_shifted = FALSE /// List of movement speed modifiers applying to this mob diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 1da355a419..83f7bbbd82 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -45,6 +45,14 @@ if(mob.force_moving) return FALSE + // Sandstorm Edit + if(mob.shifting) + mob.pixel_shift(direction) + return FALSE + else if(mob.is_shifted) + mob.unpixel_shift() + // + var/mob/living/L = mob //Already checked for isliving earlier if(L.incorporeal_move) //Move though walls Process_Incorpmove(direction) diff --git a/modular_sand/code/modules/mob/living/living_movement.dm b/modular_sand/code/modules/mob/living/living_movement.dm index bf9c5e2912..4a0464ef6b 100644 --- a/modular_sand/code/modules/mob/living/living_movement.dm +++ b/modular_sand/code/modules/mob/living/living_movement.dm @@ -15,6 +15,7 @@ to_chat(src, span_warning("You cannot increase your layer priority any further.")) return + layer = clamp(layer, MOB_LAYER_SHIFT_MIN, MOB_LAYER_SHIFT_MAX) layer += MOB_LAYER_SHIFT_INCREMENT var/layer_priority = FLOOR((layer - MOB_LAYER) * 100, 1) // Just for text feedback to_chat(src, span_notice("Your layer priority is now [layer_priority].")) @@ -31,6 +32,7 @@ to_chat(src, span_warning("You cannot decrease your layer priority any further.")) return + layer = clamp(layer, MOB_LAYER_SHIFT_MIN, MOB_LAYER_SHIFT_MAX) layer -= MOB_LAYER_SHIFT_INCREMENT var/layer_priority = FLOOR((layer - MOB_LAYER) * 100, 1) // Just for text feedback to_chat(src, span_notice("Your layer priority is now [layer_priority].")) diff --git a/modular_sand/code/modules/pixel_shift/pixel_shift.dm b/modular_sand/code/modules/pixel_shift/pixel_shift.dm new file mode 100644 index 0000000000..253ab050f3 --- /dev/null +++ b/modular_sand/code/modules/pixel_shift/pixel_shift.dm @@ -0,0 +1,101 @@ +#define MAXIMUM_PIXEL_SHIFT 16 +#define PASSABLE_SHIFT_THRESHOLD 8 + +/mob + /// If we are in the shifting setting. + var/shifting = FALSE + + /// Takes the four cardinal direction defines. Any atoms moving into this atom's tile will be allowed to from the added directions. + var/passthroughable = NONE + +/datum/keybinding/mob/pixel_shift + hotkey_keys = list("B") + name = "pixel_shift" + full_name = "Pixel Shift" + description = "Shift your characters offset." + category = CATEGORY_MOVEMENT + keybind_signal = COMSIG_KB_MOB_PIXELSHIFT + +/datum/keybinding/mob/pixel_shift/down(client/user) + . = ..() + if(.) + return + var/mob/M = user.mob + M.shifting = TRUE + return TRUE + +/datum/keybinding/mob/pixel_shift/up(client/user) + . = ..() + if(.) + return + var/mob/M = user.mob + M.shifting = FALSE + return TRUE + +/mob/proc/unpixel_shift() + return + +/mob/living/unpixel_shift() + . = ..() + passthroughable = NONE + if(is_shifted) + is_shifted = FALSE + pixel_x = get_standard_pixel_x_offset() + base_pixel_x + client?.pixel_x = 0 + pixel_y = get_standard_pixel_y_offset() + base_pixel_y + client?.pixel_y = 0 + +/mob/proc/pixel_shift(direction) + return + +/mob/living/set_pull_offsets(mob/living/pull_target, grab_state) + pull_target.unpixel_shift() + return ..() + +/mob/living/reset_pull_offsets(mob/living/pull_target, override) + pull_target.unpixel_shift() + return ..() + +/mob/living/pixel_shift(direction) + passthroughable = NONE + // switch(direction) // diagonal pixel-shifting, rejoice + if(CHECK_BITFIELD(direction, NORTH)) + if(pixel_y <= MAXIMUM_PIXEL_SHIFT + base_pixel_y) + pixel_y++ + client?.pixel_y++ + is_shifted = TRUE + if(CHECK_BITFIELD(direction, EAST)) + if(pixel_x <= MAXIMUM_PIXEL_SHIFT + base_pixel_x) + pixel_x++ + client?.pixel_x++ + is_shifted = TRUE + if(CHECK_BITFIELD(direction, SOUTH)) + if(pixel_y >= -MAXIMUM_PIXEL_SHIFT + base_pixel_y) + pixel_y-- + client?.pixel_y-- + is_shifted = TRUE + if(CHECK_BITFIELD(direction, WEST)) + if(pixel_x >= -MAXIMUM_PIXEL_SHIFT + base_pixel_x) + pixel_x-- + client?.pixel_x-- + is_shifted = TRUE + + // Yes, I know this sets it to true for everything if more than one is matched. + // Movement doesn't check diagonals, and instead just checks EAST or WEST, depending on where you are for those. + if(pixel_y > PASSABLE_SHIFT_THRESHOLD) + passthroughable |= EAST | SOUTH | WEST + if(pixel_x > PASSABLE_SHIFT_THRESHOLD) + passthroughable |= NORTH | SOUTH | WEST + if(pixel_y < -PASSABLE_SHIFT_THRESHOLD) + passthroughable |= NORTH | EAST | WEST + if(pixel_x < -PASSABLE_SHIFT_THRESHOLD) + passthroughable |= NORTH | EAST | SOUTH + +/mob/living/CanAllowThrough(atom/movable/mover, turf/target) + // Make sure to not allow projectiles of any kind past where they normally wouldn't. + if(!istype(mover, /obj/item/projectile) && !mover.throwing && passthroughable & mover.dir) + return TRUE + return ..() + +#undef MAXIMUM_PIXEL_SHIFT +#undef PASSABLE_SHIFT_THRESHOLD diff --git a/tgstation.dme b/tgstation.dme index c5e710ef84..4c22ae184f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -237,6 +237,7 @@ #include "code\__HELPERS\sorts\TimSort.dm" #include "code\__SANDCODE\DEFINES\chat.dm" #include "code\__SANDCODE\DEFINES\DNA.dm" +#include "code\__SANDCODE\DEFINES\keybindings.dm" #include "code\__SANDCODE\DEFINES\language.dm" #include "code\__SANDCODE\DEFINES\lewd.dm" #include "code\__SANDCODE\DEFINES\loadout.dm" @@ -4191,6 +4192,7 @@ #include "modular_sand\code\modules\mob\living\simple_animal\hostile\mining_mobs\elites\legionnaire.dm" #include "modular_sand\code\modules\mob\living\simple_animal\hostile\mining_mobs\elites\pandora.dm" #include "modular_sand\code\modules\movespeed\modifiers\components.dm" +#include "modular_sand\code\modules\pixel_shift\pixel_shift.dm" #include "modular_sand\code\modules\power\cell.dm" #include "modular_sand\code\modules\power\lightning.dm" #include "modular_sand\code\modules\power\port_gen.dm"