Skip to content

Commit

Permalink
Less jerky vehicles, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
FunnyMan3595 committed Feb 2, 2025
1 parent 327f1cc commit 1a1c019
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion code/datums/components/riding/riding_vehicle.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// For any /obj/tgvehicle's that can be ridden

/// For making timers not accidentally skip an extra tick.
#define EPSILON (world.tick_lag * 0.1)

/datum/component/riding/vehicle/Initialize(mob/living/riding_mob, force = FALSE, ride_check_flags = (RIDER_NEEDS_LEGS | RIDER_NEEDS_ARMS), potion_boost = FALSE)
if(!istgvehicle(parent))
return COMPONENT_INCOMPATIBLE
Expand Down Expand Up @@ -75,7 +78,12 @@

step(movable_parent, direction)
last_move_diagonal = ((direction & (direction - 1)) && (movable_parent.loc == next))
COOLDOWN_START(src, vehicle_move_cooldown, (last_move_diagonal ? 2 : 1) * vehicle_move_delay)
if(last_move_diagonal)
movable_parent.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay, 1) * 0.5)
COOLDOWN_START(src, vehicle_move_cooldown, 2 * vehicle_move_delay - EPSILON)
else
movable_parent.set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay, 1))
COOLDOWN_START(src, vehicle_move_cooldown, vehicle_move_delay - EPSILON)

if(QDELETED(src))
return
Expand Down Expand Up @@ -187,3 +195,5 @@
override_allow_spacemove = TRUE
return
override_allow_spacemove = FALSE

#undef EPSILON
1 change: 1 addition & 0 deletions code/modules/vehicle/tg_vehicles/tg_vehicles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
desc = "Yell at coding chat."
icon = 'icons/obj/tgvehicles.dmi'
icon_state = null
appearance_flags = LONG_GLIDE
max_integrity = 300
armor = list(MELEE = 30, BULLET = 30, LASER = 30, ENERGY = 0, BOMB = 30, RAD = 0, FIRE = 60, ACID = 60)
density = TRUE
Expand Down
5 changes: 4 additions & 1 deletion code/modules/vehicle/vehicle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
icon = 'icons/obj/vehicles.dmi'
icon_state = null
density = TRUE
appearance_flags = LONG_GLIDE
anchored = FALSE
can_buckle = TRUE
buckle_lying = FALSE
Expand Down Expand Up @@ -186,11 +187,13 @@
var/turf/next = get_step(src, direction)
if(!Process_Spacemove(direction) || !isturf(loc))
return
Move(get_step(src, direction), direction, delay)
Move(get_step(src, direction), direction)

if((direction & (direction - 1)) && (loc == next)) //moved diagonally
set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay + GLOB.configuration.movement.human_delay, 1) * 0.5)
last_move_diagonal = TRUE
else
set_glide_size(MOVEMENT_ADJUSTED_GLIDE_SIZE(vehicle_move_delay + GLOB.configuration.movement.human_delay, 1))
last_move_diagonal = FALSE

if(has_buckled_mobs())
Expand Down

0 comments on commit 1a1c019

Please sign in to comment.