diff --git a/code/__DEFINES/movement.dm b/code/__DEFINES/movement.dm index 93d5eb9816..5390077637 100644 --- a/code/__DEFINES/movement.dm +++ b/code/__DEFINES/movement.dm @@ -14,3 +14,13 @@ GLOBAL_VAR_INIT(glide_size_multiplier, 1.0) /// The whole result is then clamped to within the range above. /// Not very readable but it works #define DELAY_TO_GLIDE_SIZE(delay) (clamp(((32 / max((delay) / world.tick_lag, 1)) * GLOB.glide_size_multiplier), MIN_GLIDE_SIZE, MAX_GLIDE_SIZE)) + +/// Enables smooth movement +#define SMOOTH_MOVEMENT + +/// Set appearance flags in vars +#ifdef SMOOTH_MOVEMENT + #define SET_APPEARANCE_FLAGS(flags) appearance_flags = (flags | LONG_GLIDE) +#else + #define SET_APPEARANCE_FLAGS(flags) appearance_flags = flags +#endif diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 5a16e7f7cf..8df787aecd 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -1,7 +1,7 @@ /atom/movable layer = OBJ_LAYER glide_size = 8 - appearance_flags = TILE_BOUND|PIXEL_SCALE + SET_APPEARANCE_FLAGS(TILE_BOUND | PIXEL_SCALE) var/last_move = null var/last_move_time = 0 var/anchored = FALSE @@ -305,8 +305,6 @@ /atom/movable/proc/set_glide_size(target = 8, recursive = TRUE) // SEND_SIGNAL(src, COMSIG_MOVABLE_UPDATE_GLIDE_SIZE, target) glide_size = target - if(ismob(src) && src:client) - to_chat(world, "DEBUG: [src] ([REF(src)]) setting glide size to [target]") for(var/m in buckled_mobs) var/mob/buckled_mob = m diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index b71521121b..241cd6be93 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -31,6 +31,7 @@ var/datum/preferences/prefs = null var/last_turn = 0 var/move_delay = 0 + var/last_move = 0 var/area = null /// Last time we Click()ed. No clicking twice in one tick! diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index ef65addbf8..df7ed66169 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -3,7 +3,7 @@ real_name = "Unknown" icon = 'icons/mob/human.dmi' icon_state = "caucasian_m" - appearance_flags = KEEP_TOGETHER|TILE_BOUND|PIXEL_SCALE + SET_APPEARANCE_FLAGS(KEEP_TOGETHER|TILE_BOUND|PIXEL_SCALE) /mob/living/carbon/human/Initialize() add_verb(src, /mob/living/proc/mob_sleep) diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 6a8241277c..ba2399b831 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -16,9 +16,6 @@ attack_hand_unwieldlyness = CLICK_CD_MELEE attack_hand_speed = 0 - /// Was our last move diagonal - var/last_move_diagonal = FALSE - /// What receives our keyboard input. src by default. var/datum/focus diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 16c1508b1e..c467605f37 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -96,9 +96,6 @@ if((direction & (direction - 1)) && mob.loc == n) //moved diagonally successfully add_delay *= 2 - mob.last_move_diagonal = TRUE - else - mob.last_move_diagonal = FALSE mob.set_glide_size(DELAY_TO_GLIDE_SIZE(add_delay), FALSE) move_delay += add_delay if(.) // If mob is null here, we deserve the runtime @@ -109,6 +106,8 @@ if(AM && AM.density && !SEND_SIGNAL(L, COMSIG_COMBAT_MODE_CHECK, COMBAT_MODE_ACTIVE) && !ismob(AM)) L.setDir(turn(L.dir, 180)) + last_move = world.time + SEND_SIGNAL(mob, COMSIG_MOB_CLIENT_MOVE, src, direction, n, oldloc, add_delay) /// Process_Grab(): checks for grab, attempts to break if so. Return TRUE to prevent movement. diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index b1631a9821..e45d88c0e1 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -224,6 +224,18 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if((diff > 0) && client) if(client.move_delay > world.time + 1.5) client.move_delay -= diff + var/timeleft = world.time - client.move_delay + var/elapsed = world.time - client.last_move + var/glide_size_current = glide_size + if((timeleft <= 0) || (elapsed > 20)) + set_glide_size(16, TRUE) + return + var/pixels_moved = glide_size_current * elapsed * (1 / world.tick_lag) + // calculate glidesize needed to move to the next tile within timeleft deciseconds + var/ticks_allowed = timeleft / world.tick_lag + var/pixels_per_tick = pixels_moved / ticks_allowed + set_glide_size(pixels_per_tick * GLOB.glide_size_multiplier, TRUE) + /// Get the move speed modifiers list of the mob /mob/proc/get_movespeed_modifiers()