mirror of
https://github.com/KabKebab/GS13.git
synced 2026-07-10 23:47:16 +01:00
Dynamic glidespeed
ported from yogstation
This commit is contained in:
+33
-15
@@ -29,7 +29,7 @@
|
||||
var/list/client_mobs_in_contents // This contains all the client mobs within this container
|
||||
var/list/acted_explosions //for explosion dodging
|
||||
glide_size = 8
|
||||
appearance_flags = TILE_BOUND|PIXEL_SCALE
|
||||
appearance_flags = TILE_BOUND|PIXEL_SCALE|LONG_GLIDE
|
||||
var/datum/forced_movement/force_moving = null //handled soley by forced_movement.dm
|
||||
var/floating = FALSE
|
||||
var/movement_type = GROUND //Incase you have multiple types, you automatically use the most useful one. IE: Skating on ice, flippers on water, flying over chasm/space, etc.
|
||||
@@ -191,19 +191,21 @@
|
||||
|
||||
/atom/movable/proc/Move_Pulled(atom/A)
|
||||
if(!pulling)
|
||||
return
|
||||
return FALSE
|
||||
if(pulling.anchored || !pulling.Adjacent(src))
|
||||
stop_pulling()
|
||||
return
|
||||
return FALSE
|
||||
if(isliving(pulling))
|
||||
var/mob/living/L = pulling
|
||||
if(L.buckled && L.buckled.buckle_prevents_pull) //if they're buckled to something that disallows pulling, prevent it
|
||||
stop_pulling()
|
||||
return
|
||||
return FALSE
|
||||
if(A == loc && pulling.density)
|
||||
return
|
||||
if(!Process_Spacemove(get_dir(pulling.loc, A)))
|
||||
return
|
||||
return FALSE
|
||||
var/move_dir = get_dir(pulling.loc, A)
|
||||
if(!Process_Spacemove(move_dir))
|
||||
return FALSE
|
||||
pulling.Move(get_step(pulling.loc, move_dir), move_dir, glide_size)
|
||||
step(pulling, get_dir(pulling.loc, A))
|
||||
|
||||
|
||||
@@ -235,7 +237,7 @@
|
||||
// Here's where we rewrite how byond handles movement except slightly different
|
||||
// To be removed on step_ conversion
|
||||
// All this work to prevent a second bump
|
||||
/atom/movable/Move(atom/newloc, direct=0)
|
||||
/atom/movable/Move(atom/newloc, direct=0, glide_size_override = 0)
|
||||
. = FALSE
|
||||
if(!newloc || newloc == loc)
|
||||
return
|
||||
@@ -278,7 +280,7 @@
|
||||
//
|
||||
////////////////////////////////////////
|
||||
|
||||
/atom/movable/Move(atom/newloc, direct)
|
||||
/atom/movable/Move(atom/newloc, direct, glide_size_override = 0)
|
||||
var/atom/movable/pullee = pulling
|
||||
var/turf/T = loc
|
||||
if(pulling)
|
||||
@@ -291,6 +293,9 @@
|
||||
if(!loc || !newloc)
|
||||
return FALSE
|
||||
var/atom/oldloc = loc
|
||||
//Early override for some cases like diagonal movement
|
||||
if(glide_size_override)
|
||||
set_glide_size(glide_size_override)
|
||||
|
||||
if(loc != newloc)
|
||||
if (!(direct & (direct - 1))) //Cardinal move
|
||||
@@ -364,19 +369,32 @@
|
||||
var/pull_dir = get_dir(src, pulling)
|
||||
//puller and pullee more than one tile away or in diagonal position
|
||||
if(get_dist(src, pulling) > 1 || (moving_diagonally != SECOND_DIAG_STEP && ((pull_dir - 1) & pull_dir)))
|
||||
pulling.Move(T, get_dir(pulling, T)) //the pullee tries to reach our previous position
|
||||
pulling.Move(T, get_dir(pulling, T), glide_size) //the pullee tries to reach our previous position
|
||||
if(pulling && get_dist(src, pulling) > 1) //the pullee couldn't keep up
|
||||
stop_pulling()
|
||||
|
||||
if(pulledby && moving_diagonally != FIRST_DIAG_STEP && get_dist(src, pulledby) > 1)//separated from our puller and not in the middle of a diagonal move.
|
||||
pulledby.stop_pulling()
|
||||
|
||||
//glide_size strangely enough can change mid movement animation and update correctly while the animation is playing
|
||||
//This means that if you don't override it late like this, it will just be set back by the movement update that's called when you move turfs.
|
||||
if(glide_size_override)
|
||||
set_glide_size(glide_size_override)
|
||||
|
||||
|
||||
|
||||
last_move = direct
|
||||
setDir(direct)
|
||||
if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc,direct)) //movement failed due to buckled mob(s)
|
||||
if(. && has_buckled_mobs() && !handle_buckled_mob_movement(loc, direct, glide_size_override)) //movement failed due to buckled mob(s)
|
||||
return FALSE
|
||||
|
||||
/atom/movable/proc/set_glide_size(target = 8)
|
||||
SEND_SIGNAL(src, COMSIG_MOVABLE_UPDATE_GLIDE_SIZE, target)
|
||||
glide_size = target
|
||||
|
||||
for(var/atom/movable/AM in buckled_mobs)
|
||||
AM.set_glide_size(target)
|
||||
|
||||
//Called after a successful Move(). By this point, we've already moved
|
||||
/atom/movable/proc/Moved(atom/OldLoc, Dir, Forced = FALSE)
|
||||
SEND_SIGNAL(src, COMSIG_MOVABLE_MOVED, OldLoc, Dir, Forced)
|
||||
@@ -645,16 +663,16 @@
|
||||
SSthrowing.currentrun[src] = TT
|
||||
TT.tick()
|
||||
|
||||
/atom/movable/proc/handle_buckled_mob_movement(newloc,direct)
|
||||
/atom/movable/proc/handle_buckled_mob_movement(newloc, direct, glide_size_override)
|
||||
for(var/m in buckled_mobs)
|
||||
var/mob/living/buckled_mob = m
|
||||
if(!buckled_mob.Move(newloc, direct))
|
||||
if(!buckled_mob.Move(newloc, direct, glide_size_override))
|
||||
forceMove(buckled_mob.loc)
|
||||
last_move = buckled_mob.last_move
|
||||
inertia_dir = last_move
|
||||
buckled_mob.inertia_dir = last_move
|
||||
return 0
|
||||
return 1
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/atom/movable/proc/force_pushed(atom/movable/pusher, force = MOVE_FORCE_DEFAULT, direction)
|
||||
return FALSE
|
||||
|
||||
@@ -554,10 +554,12 @@
|
||||
var/move_result = 0
|
||||
var/oldloc = loc
|
||||
if(internal_damage & MECHA_INT_CONTROL_LOST)
|
||||
set_glide_size(DELAY_TO_GLIDE_SIZE(step_in))
|
||||
move_result = mechsteprand()
|
||||
else if(dir != direction && (!strafe || occupant.client.keys_held["Alt"]))
|
||||
move_result = mechturn(direction)
|
||||
else
|
||||
set_glide_size(DELAY_TO_GLIDE_SIZE(step_in))
|
||||
move_result = mechstep(direction)
|
||||
if(move_result || loc != oldloc)// halfway done diagonal move still returns false
|
||||
use_power(step_energy_drain)
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
buckled_mobs |= M
|
||||
M.update_canmove()
|
||||
M.throw_alert("buckled", /obj/screen/alert/restrained/buckled)
|
||||
M.set_glide_size(glide_size)
|
||||
post_buckle_mob(M)
|
||||
|
||||
SEND_SIGNAL(src, COMSIG_MOVABLE_BUCKLE, M, force)
|
||||
@@ -87,6 +88,7 @@
|
||||
buckled_mob.anchored = initial(buckled_mob.anchored)
|
||||
buckled_mob.update_canmove()
|
||||
buckled_mob.clear_alert("buckled")
|
||||
buckled_mob.set_glide_size(DELAY_TO_GLIDE_SIZE(buckled_mob.total_multiplicative_slowdown()))
|
||||
buckled_mobs -= buckled_mob
|
||||
SEND_SIGNAL(src, COMSIG_MOVABLE_UNBUCKLE, buckled_mob, force)
|
||||
|
||||
|
||||
@@ -129,12 +129,13 @@
|
||||
|
||||
if(current_tube == null)
|
||||
setDir(next_dir)
|
||||
Move(get_step(loc, dir), dir) // Allow collisions when leaving the tubes.
|
||||
Move(get_step(loc, dir), dir, DELAY_TO_GLIDE_SIZE(exit_delay)) // Allow collisions when leaving the tubes.
|
||||
break
|
||||
|
||||
last_delay = current_tube.enter_delay(src, next_dir)
|
||||
sleep(last_delay)
|
||||
setDir(next_dir)
|
||||
set_glide_size(DELAY_TO_GLIDE_SIZE(last_delay + exit_delay))
|
||||
forceMove(next_loc) // When moving from one tube to another, skip collision and such.
|
||||
|
||||
if(current_tube && current_tube.should_stop_pod(src, next_dir))
|
||||
|
||||
Reference in New Issue
Block a user