mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 11:37:40 +01:00
Merge pull request #13367 from Arokha/aro-glide2
Fix up smooth movement issues
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/atom/movable
|
||||
layer = 3
|
||||
appearance_flags = TILE_BOUND
|
||||
glide_size = 8 // Default, adjusted when mobs move based on their movement delays
|
||||
var/last_move = null
|
||||
var/anchored = 0
|
||||
var/move_resist = MOVE_RESIST_DEFAULT
|
||||
@@ -131,13 +132,14 @@
|
||||
/atom/movable/proc/setLoc(var/T, var/teleported=0)
|
||||
loc = T
|
||||
|
||||
/atom/movable/Move(atom/newloc, direct = 0)
|
||||
/atom/movable/Move(atom/newloc, direct = 0, movetime)
|
||||
if(!loc || !newloc) return 0
|
||||
var/atom/oldloc = loc
|
||||
|
||||
if(loc != newloc)
|
||||
glide_for(movetime)
|
||||
if(!(direct & (direct - 1))) //Cardinal move
|
||||
. = ..()
|
||||
. = ..(newloc, direct) // don't pass up movetime
|
||||
else //Diagonal move, split it into cardinal moves
|
||||
moving_diagonally = FIRST_DIAG_STEP
|
||||
var/first_step_dir
|
||||
@@ -203,7 +205,7 @@
|
||||
src.move_speed = world.time - src.l_move_time
|
||||
src.l_move_time = world.time
|
||||
|
||||
if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct)) //movement failed due to buckled mob
|
||||
if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct, movetime)) //movement failed due to buckled mob
|
||||
. = 0
|
||||
|
||||
// Called after a successful Move(). By this point, we've already moved
|
||||
@@ -216,6 +218,15 @@
|
||||
update_parallax_contents()
|
||||
return TRUE
|
||||
|
||||
// Change glide size for the duration of one movement
|
||||
/atom/movable/proc/glide_for(movetime)
|
||||
if(movetime)
|
||||
glide_size = world.icon_size/max(DS2TICKS(movetime), 1)
|
||||
spawn(movetime)
|
||||
glide_size = initial(glide_size)
|
||||
else
|
||||
glide_size = initial(glide_size)
|
||||
|
||||
// Previously known as HasEntered()
|
||||
// This is automatically called when something enters your square
|
||||
/atom/movable/Crossed(atom/movable/AM, oldloc)
|
||||
@@ -428,10 +439,10 @@
|
||||
/atom/movable/proc/water_act(volume, temperature, source, method = REAGENT_TOUCH) //amount of water acting : temperature of water in kelvin : object that called it (for shennagins)
|
||||
return TRUE
|
||||
|
||||
/atom/movable/proc/handle_buckled_mob_movement(newloc,direct)
|
||||
/atom/movable/proc/handle_buckled_mob_movement(newloc,direct,movetime)
|
||||
for(var/m in buckled_mobs)
|
||||
var/mob/living/buckled_mob = m
|
||||
if(!buckled_mob.Move(newloc, direct))
|
||||
if(!buckled_mob.Move(newloc, direct, movetime))
|
||||
forceMove(buckled_mob.loc)
|
||||
last_move = buckled_mob.last_move
|
||||
inertia_dir = last_move
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
T = get_step(T, direct)
|
||||
console.jump_on_click(src, T)
|
||||
return
|
||||
return ..(n,direct)
|
||||
return ..()
|
||||
|
||||
// Other computer monitors.
|
||||
/obj/machinery/computer/security/telescreen
|
||||
|
||||
@@ -400,7 +400,9 @@
|
||||
var/turf/newloc = G.affecting.loc
|
||||
if(isturf(oldloc) && isturf(newloc))
|
||||
SpinAnimation(5,1)
|
||||
glide_for(6) // This and the glide_for below are purely arbitrary. Pick something that looks aesthetically pleasing.
|
||||
forceMove(newloc)
|
||||
G.glide_for(6)
|
||||
G.affecting.forceMove(oldloc)
|
||||
message = "<B>[src]</B> flips over [G.affecting]!"
|
||||
else
|
||||
|
||||
@@ -511,7 +511,7 @@
|
||||
|
||||
return
|
||||
|
||||
/mob/living/Move(atom/newloc, direct)
|
||||
/mob/living/Move(atom/newloc, direct, movetime)
|
||||
if(buckled && buckled.loc != newloc) //not updating position
|
||||
if(!buckled.anchored)
|
||||
return buckled.Move(newloc, direct)
|
||||
@@ -544,7 +544,7 @@
|
||||
var/mob/living/M = pulling
|
||||
if(M.lying && !M.buckled && (prob(M.getBruteLoss() * 200 / M.maxHealth)))
|
||||
M.makeTrail(T)
|
||||
pulling.Move(T, get_dir(pulling, T)) // the pullee tries to reach our previous position
|
||||
pulling.Move(T, get_dir(pulling, T), movetime) // the pullee tries to reach our previous position
|
||||
if(pulling && get_dist(src, pulling) > 1) // the pullee couldn't keep up
|
||||
stop_pulling()
|
||||
|
||||
|
||||
@@ -495,7 +495,7 @@ Pass a positive integer as an argument to override a bot's default speed.
|
||||
if(!path)
|
||||
return 0
|
||||
if(path.len > 1)
|
||||
step_towards(src, path[1])
|
||||
Move(path[1], get_dir(src, path[1]), BOT_STEP_DELAY)
|
||||
if(get_turf(src) == path[1]) //Successful move
|
||||
increment_path()
|
||||
tries = 0
|
||||
|
||||
@@ -143,8 +143,10 @@
|
||||
move_delay = world.time
|
||||
mob.last_movement = world.time
|
||||
|
||||
delay = TICKS2DS(-round(-(DS2TICKS(delay)))) //Rounded to the next tick in equivalent ds
|
||||
|
||||
if(locate(/obj/item/grab, mob))
|
||||
move_delay = max(move_delay, world.time + 7)
|
||||
delay += 7
|
||||
var/list/L = mob.ret_grab()
|
||||
if(istype(L, /list))
|
||||
if(L.len == 2)
|
||||
@@ -153,14 +155,14 @@
|
||||
if(M)
|
||||
if((get_dist(mob, M) <= 1 || M.loc == mob.loc))
|
||||
var/turf/prev_loc = mob.loc
|
||||
. = ..()
|
||||
. = mob.SelfMove(n, direct, delay)
|
||||
if(M && isturf(M.loc)) // Mob may get deleted during parent call
|
||||
var/diag = get_dir(mob, M)
|
||||
if((diag - 1) & diag)
|
||||
else
|
||||
diag = null
|
||||
if((get_dist(mob, M) > 1 || diag))
|
||||
step(M, get_dir(M.loc, prev_loc))
|
||||
M.Move(prev_loc, get_dir(M.loc, prev_loc), delay)
|
||||
else
|
||||
for(var/mob/M in L)
|
||||
M.other_mobs = 1
|
||||
@@ -168,12 +170,10 @@
|
||||
M.animate_movement = 3
|
||||
for(var/mob/M in L)
|
||||
spawn(0)
|
||||
step(M, direct)
|
||||
return
|
||||
M.Move(get_step(M,direct), direct, delay)
|
||||
spawn(1)
|
||||
M.other_mobs = null
|
||||
M.animate_movement = 2
|
||||
return
|
||||
|
||||
else if(mob.confused)
|
||||
var/newdir = 0
|
||||
@@ -186,11 +186,8 @@
|
||||
if(newdir)
|
||||
direct = newdir
|
||||
n = get_step(mob, direct)
|
||||
|
||||
delay = TICKS2DS(-round(-(DS2TICKS(delay)))) //Rounded to the next tick in equivalent ds
|
||||
mob.glide_size = world.icon_size/max(DS2TICKS(delay),1) //Down to whatever decimal
|
||||
|
||||
. = ..()
|
||||
. = mob.SelfMove(n, direct, delay)
|
||||
mob.setDir(direct)
|
||||
|
||||
if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully
|
||||
@@ -214,8 +211,8 @@
|
||||
O.on_mob_move(direct, mob)
|
||||
|
||||
|
||||
|
||||
|
||||
/mob/proc/SelfMove(turf/n, direct, movetime)
|
||||
return Move(n, direct, movetime)
|
||||
|
||||
///Process_Grab()
|
||||
///Called by client/Move()
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
bed = null
|
||||
. = ..()
|
||||
if(bed && get_dist(oldloc, loc) <= 2)
|
||||
bed.Move(oldloc)
|
||||
bed.Move(oldloc, get_dir(bed, oldloc), (last_move_diagonal? 2 : 1) * (vehicle_move_delay + config.human_delay))
|
||||
bed.dir = Dir
|
||||
if(bed.has_buckled_mobs())
|
||||
for(var/m in bed.buckled_mobs)
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
origin_tech = "materials=3;engineering=4"
|
||||
|
||||
/obj/vehicle/janicart/Move(atom/OldLoc, Dir)
|
||||
..()
|
||||
. = ..()
|
||||
if(floorbuffer)
|
||||
var/turf/tile = loc
|
||||
if(isturf(tile))
|
||||
|
||||
@@ -153,7 +153,8 @@
|
||||
unbuckle_mob(user)
|
||||
return
|
||||
|
||||
if(world.time < last_vehicle_move + ((last_move_diagonal? 2 : 1) * (vehicle_move_delay + config.human_delay)))
|
||||
var/delay = (last_move_diagonal? 2 : 1) * (vehicle_move_delay + config.human_delay)
|
||||
if(world.time < last_vehicle_move + delay)
|
||||
return
|
||||
last_vehicle_move = world.time
|
||||
|
||||
@@ -161,7 +162,7 @@
|
||||
var/turf/next = get_step(src, direction)
|
||||
if(!Process_Spacemove(direction) || !isturf(loc))
|
||||
return
|
||||
step(src, direction)
|
||||
Move(get_step(src, direction), direction, delay)
|
||||
|
||||
if((direction & (direction - 1)) && (loc == next)) //moved diagonally
|
||||
last_move_diagonal = TRUE
|
||||
@@ -185,7 +186,7 @@
|
||||
to_chat(user, "<span class='warning'>You'll need the keys in one of your hands to drive [src].</span>")
|
||||
|
||||
|
||||
/obj/vehicle/Move(NewLoc, Dir = 0, step_x = 0, step_y = 0)
|
||||
/obj/vehicle/Move(NewLoc, Dir = 0, movetime)
|
||||
. = ..()
|
||||
handle_vehicle_layer()
|
||||
handle_vehicle_offsets()
|
||||
|
||||
Reference in New Issue
Block a user