From d64a922437e581c90914f8824074abc1161dc29f Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Mon, 18 May 2020 22:30:27 -0400 Subject: [PATCH] Refactor spacemoves --- code/_onclick/hud/skybox.dm | 6 ++-- code/game/area/Space Station 13 areas.dm | 1 + code/game/turfs/space/space.dm | 9 ++---- code/game/turfs/turf.dm | 30 ------------------ code/modules/mob/living/living.dm | 40 ++++++++++++++++++++---- code/modules/mob/mob_movement.dm | 8 ++--- 6 files changed, 44 insertions(+), 50 deletions(-) diff --git a/code/_onclick/hud/skybox.dm b/code/_onclick/hud/skybox.dm index affeef8893..f055ea8693 100644 --- a/code/_onclick/hud/skybox.dm +++ b/code/_onclick/hud/skybox.dm @@ -49,9 +49,9 @@ if(old_z != new_z) client?.update_skybox(TRUE) -/mob/doMove() - if((. = ..())) - client?.update_skybox() +/mob/Moved() + . = ..() + client?.update_skybox() /mob/set_viewsize() . = ..() diff --git a/code/game/area/Space Station 13 areas.dm b/code/game/area/Space Station 13 areas.dm index 067f71a6e2..6caf76a982 100755 --- a/code/game/area/Space Station 13 areas.dm +++ b/code/game/area/Space Station 13 areas.dm @@ -25,6 +25,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station requires_power = 1 always_unpowered = 1 dynamic_lighting = 0 + has_gravity = 0 power_light = 0 power_equip = 0 power_environ = 0 diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index 793942ecbe..0094ab1983 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -134,15 +134,10 @@ return /turf/space/Entered(var/atom/movable/A) - ..() - - if (!A || src != A.loc) - return - - inertial_drift(A) + . = ..() if(edge && ticker?.mode) - A.touch_map_edge() + A?.touch_map_edge() /turf/space/proc/Sandbox_Spacemove(atom/movable/A as mob|obj) var/cur_x diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 1357c71106..e93380d791 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -142,20 +142,6 @@ turf/attackby(obj/item/weapon/W as obj, mob/user as mob) sleep(2) O.update_transform() -/turf/Entered(var/atom/movable/A, var/old_loc) - . = ..() - - if(ismob(A)) - var/mob/M = A - if(M.lastarea?.has_gravity == 0) - inertial_drift(M) - if(M.flying) //VORESTATION Edit Start. This overwrites the above is_space without touching it all that much. - inertial_drift(M) - M.make_floating(1) //VOREStation Edit End. - else if(!is_space()) - M.inertia_dir = 0 - M.make_floating(0) - /turf/CanPass(atom/movable/mover, turf/target) if(!target) return FALSE @@ -224,22 +210,6 @@ turf/attackby(obj/item/weapon/W as obj, mob/user as mob) /turf/proc/is_plating() return 0 -/turf/proc/inertial_drift(atom/movable/A as mob|obj) - if(!(A.last_move)) return - if((istype(A, /mob/) && src.x > 1 && src.x < (world.maxx) && src.y > 1 && src.y < (world.maxy))) - var/mob/M = A - if(M.Process_Spacemove(1)) - M.inertia_dir = 0 - return - spawn(5) - if((M && !(M.anchored) && !(M.pulledby) && (M.loc == src))) - if(M.inertia_dir) - step(M, M.inertia_dir) - return - M.inertia_dir = M.last_move - step(M, M.inertia_dir) - return - /turf/proc/levelupdate() for(var/obj/O in src) O.hide(O.hides_under_flooring() && !is_plating()) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 61d937644f..ac4d7a1f37 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -826,19 +826,18 @@ default behaviour is: handle_footstep(loc) if(pulling) // we were pulling a thing and didn't lose it during our move. + var/pull_dir = get_dir(src, pulling) + if(pulling.anchored || !isturf(pulling.loc)) stop_pulling() - return - - var/pull_dir = get_dir(src, pulling) - if(get_dist(src, pulling) > 1 || (moving_diagonally != SECOND_DIAG_STEP && ((pull_dir - 1) & pull_dir))) // puller and pullee more than one tile away or in diagonal position + + else if(get_dist(src, pulling) > 1 || (moving_diagonally != SECOND_DIAG_STEP && ((pull_dir - 1) & pull_dir))) // puller and pullee more than one tile away or in diagonal position // If it is too far away or across z-levels from old location, stop pulling. if(get_dist(pulling.loc, oldloc) > 1 || pulling.loc.z != oldloc?.z) stop_pulling() - return // living might take damage from drags - if(isliving(pulling)) + else if(isliving(pulling)) var/mob/living/M = pulling M.dragged(src, oldloc) @@ -846,6 +845,35 @@ default behaviour is: if(pulling && get_dist(src, pulling) > 1) // the pullee couldn't keep up stop_pulling() + if(!isturf(loc)) + return + else if(lastarea?.has_gravity == 0) + inertial_drift() + //VOREStation Edit Start + else if(flying) + inertial_drift() + make_floating(1) + //VOREStation Edit End + else if(!isspace(loc)) + inertia_dir = 0 + make_floating(0) + +/mob/living/proc/inertial_drift() + if(x > 1 && x < (world.maxx) && y > 1 && y < (world.maxy)) + if(Process_Spacemove(1)) + inertia_dir = 0 + return + + var/locthen = loc + spawn(5) + if(!anchored && !pulledby && loc == locthen) + var/stepdir = inertia_dir ? inertia_dir : last_move + if(!stepdir) + return + var/turf/T = get_step(src, stepdir) + if(!T) + return + Move(T, stepdir, 5) /mob/living/proc/handle_footstep(turf/T) return FALSE diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index c76b7fcb4c..2da05bc4de 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -391,9 +391,9 @@ //Check to see if we slipped if(prob(Process_Spaceslipping(5)) && !buckled) - to_chat(src, "You slipped!") - src.inertia_dir = src.last_move - step(src, src.inertia_dir) + to_chat(src, "You slipped!") + inertia_dir = last_move + step(src, src.inertia_dir) // Not using Move for smooth glide here because this is a 'slip' so should be sudden. return 0 //If not then we can reset inertia and move inertia_dir = 0 @@ -405,7 +405,7 @@ var/shoegrip for(var/turf/turf in oview(1,src)) - if(istype(turf,/turf/space)) + if(isspace(turf)) continue if(istype(turf,/turf/simulated/floor)) // Floors don't count if they don't have gravity