From 707483128dc77ec76176381f4b320a39e4c222a6 Mon Sep 17 00:00:00 2001 From: WolvesAndOwls <79985892+WolvesAndOwls@users.noreply.github.com> Date: Sun, 9 Aug 2026 09:33:06 -0500 Subject: [PATCH] Tilt code (#19641) * Add variables for tilting * Add reset logic for pixel tilt * Add tilt logic * Add keybinds to skin * Add checks and a define to stop tilt from breaking * Simplified checks using incapacitated() proc * Removed hardcoded number * reset tilt before lie down transform * Use update_transform() --------- Co-authored-by: Cameron Lennox --- code/__defines/mobs.dm | 2 ++ code/modules/mob/living/living.dm | 5 ++++- code/modules/mob/living/living_movement.dm | 2 ++ code/modules/mob/mob.dm | 22 ++++++++++++++++++++ code/modules/mob/mob_defines.dm | 6 +++++- interface/skin.dmf | 24 ++++++++++++++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index 592b7a74ba6..c6b62fe8cf0 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -63,6 +63,8 @@ #define STANCES_COMBAT list(STANCE_ALERT, STANCE_APPROACH, STANCE_FIGHT, STANCE_BLINDFIGHT, STANCE_REPOSITION) +#define TILT_INCAPACITATED_WAITTIME (3 SECONDS) + #define LEFT 0x1 #define RIGHT 0x2 #define UNDER 0x4 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 487a78e4795..4a8be120f67 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -882,6 +882,8 @@ resting = !resting to_chat(src, span_notice("You are now [resting ? "resting" : "getting up"].")) + allowtilttime = world.time + TILT_INCAPACITATED_WAITTIME + how_tilted = 0 update_canmove() //called when the mob receives a bright flash @@ -1162,7 +1164,8 @@ else unbuckle_mob(L) L.Stun(5) - + if(!canmove) + allowtilttime = world.time + TILT_INCAPACITATED_WAITTIME return canmove // Mob holders in these slots will be spilled if the mob goes prone. diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index bcf8ebdc377..c117e4619ea 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -270,6 +270,8 @@ default behaviour is: pixel_y = default_pixel_y layer = initial(layer) plane = initial(plane) + how_tilted = 0 + update_transform() if(pulling) // we were pulling a thing and didn't lose it during our move. var/pull_dir = get_dir(src, pulling) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 7d4e59284a1..087b98120ba 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1189,6 +1189,28 @@ pixel_x++ is_shifted = TRUE +/mob/verb/tiltcounterclock() + set hidden = TRUE + if(world.time <= allowtilttime) //This is a sloppy "wait" fix to work around tilting durring the get-up animation + return FALSE + if(!canface() || incapacitated(INCAPACITATION_ALL)) + return FALSE + if(how_tilted >= -maximum_tilt) + transform = turn(transform, -5) + how_tilted = how_tilted - 5 + is_shifted = TRUE + +/mob/verb/tiltclock() + set hidden = TRUE + if(world.time <= allowtilttime) //This is a sloppy "wait" fix to work around tilting durring the get-up animation + return FALSE + if(!canface() || incapacitated(INCAPACITATION_ALL)) + return FALSE + if(how_tilted <= maximum_tilt) + transform = turn(transform, 5) + how_tilted = how_tilted + 5 + is_shifted = TRUE + /mob/verb/planeup() set hidden = TRUE if(!canface()) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index ddad47e0d6a..8397b7aa6ef 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -117,8 +117,11 @@ var/resting = 0 //Carbon var/lying = 0 var/lying_prev = 0 - var/is_shifted = FALSE // VoreStation Edit; pixel shifting + var/is_shifted = FALSE // VoreStation Edit; pixel shifting + tilting + var/how_tilted = 0 + var/maximum_tilt = 45 var/canmove = 1 + var/allowtilttime = 0 //This is the waiting timer for getting up after falling, lying, buckling, or otherwise being animated. //Allows mobs to move through dense areas without restriction. For instance, in space or out of holder objects. var/incorporeal_move = 0 //0 is off, 1 is normal, 2 is for ninjas. var/list/pinned = list() // List of things pinning this creature to walls (see living_defense.dm) @@ -273,6 +276,7 @@ var/datum/click_intercept var/datum/focus //What receives our keyboard inputs. src by default + /// dict of custom stat tabs with data var/list/list/misc_tabs = list() diff --git a/interface/skin.dmf b/interface/skin.dmf index eee5c5f8f80..d2d0e2fef1a 100644 --- a/interface/skin.dmf +++ b/interface/skin.dmf @@ -92,6 +92,12 @@ macro "borghotkeymode" elem name = "CTRL+SHIFT+EAST" command = "shifteast" + elem + name = "SHIFT+EAST" + command = "tiltclock" + elem + name = "SHIFT+WEST" + command = "tiltcounterclock" elem name = "INSERT" command = "a-intent right" @@ -373,6 +379,12 @@ macro "macro" elem "ctrlshifteast" name = "CTRL+SHIFT+EAST" command = "shifteast" + elem "tiltclock" + name = "SHIFT+EAST" + command = "tiltclock" + elem "tiltcounterclock" + name = "SHIFT+WEST" + command = "tiltcounterclock" elem "insert" name = "INSERT" command = "a-intent right" @@ -612,6 +624,12 @@ macro "hotkeymode" elem "ctrlshifteast" name = "CTRL+SHIFT+EAST" command = "shifteast" + elem "tiltclock" + name = "SHIFT+EAST" + command = "tiltclock" + elem "tiltcounterclock" + name = "SHIFT+WEST" + command = "tiltcounterclock" elem "insert" name = "INSERT" command = "a-intent right" @@ -920,6 +938,12 @@ macro "borgmacro" elem "ctrlshifteast" name = "CTRL+SHIFT+EAST" command = "shifteast" + elem "tiltclock" + name = "SHIFT+EAST" + command = "tiltclock" + elem "tiltcounterclock" + name = "SHIFT+WEST" + command = "tiltcounterclock" elem "insert" name = "INSERT" command = "a-intent right"