Further tweak smooth movement

This commit is contained in:
Aronai Sieyes
2020-05-02 19:20:54 -04:00
parent c442ddff4c
commit 0b18d17a07
12 changed files with 147 additions and 190 deletions

View File

@@ -2,7 +2,7 @@
/datum/riding
var/next_vehicle_move = 0 // Used for move delays
var/vehicle_move_delay = 2 // Tick delay between movements, lower = faster, higher = slower
var/vehicle_move_delay = 2 // Decisecond delay between movements, lower = faster, higher = slower
var/keytype = null // Can give this a type to require the rider to hold the item type inhand to move the ridden atom.
var/nonhuman_key_exemption = FALSE // If true, nonhumans who can't hold keys don't need them, like borgs and simplemobs.
var/key_name = "the keys" // What the 'keys' for the thing being rided on would be called.
@@ -97,11 +97,13 @@
if(world.time < next_vehicle_move)
return
next_vehicle_move = world.time + vehicle_move_delay
if(keycheck(user))
if(!Process_Spacemove(direction) || !isturf(ridden.loc))
return
ridden.Move(get_step(ridden, direction))
ridden.Move(get_step(ridden, direction), direction, vehicle_move_delay)
handle_vehicle_layer()
handle_vehicle_offsets()

View File

@@ -65,7 +65,7 @@
return ..()
////////////////////////////////////////
/atom/movable/Move(atom/newloc, direct = 0)
/atom/movable/Move(atom/newloc, direct = 0, movetime)
// Didn't pass enough info
if(!loc || !newloc)
return FALSE
@@ -104,6 +104,7 @@
var/dest_z = get_z(newloc)
// Do The Move
glide_for(movetime)
loc = newloc
. = TRUE
@@ -145,6 +146,7 @@
// place due to a Crossed, Bumped, etc. call will interrupt
// the second half of the diagonal movement, or the second attempt
// at a first half if step() fails because we hit something.
glide_for(movetime)
if (direct & NORTH)
if (direct & EAST)
if (step(src, NORTH) && moving_diagonally)
@@ -197,7 +199,7 @@
// If we moved, call Moved() on ourselves
if(.)
Moved(oldloc, direct, FALSE)
Moved(oldloc, direct, FALSE, movetime)
// Update timers/cooldown stuff
move_speed = world.time - l_move_time
@@ -205,20 +207,26 @@
last_move = direct // The direction you last moved
// set_dir(direct) //Don't think this is necessary
//Called after a successful Move(). By this point, we've already moved
/atom/movable/proc/Moved(atom/old_loc, direction, forced = FALSE, movetime)
// Handle any buckled mobs on this movable
if(has_buckled_mobs())
handle_buckled_mob_movement(oldloc,direct)
//VOREStation Add
else if(. && riding_datum)
handle_buckled_mob_movement(old_loc, direction, movetime)
if(riding_datum)
riding_datum.handle_vehicle_layer()
riding_datum.handle_vehicle_offsets()
//VOREStation Add End
//Called after a successful Move(). By this point, we've already moved
/atom/movable/proc/Moved(atom/old_loc, direction, forced = FALSE)
return TRUE
/atom/movable/set_dir(newdir)
. = ..(newdir)
if(riding_datum)
riding_datum.handle_vehicle_offsets()
/atom/movable/relaymove(mob/user, direction)
. = ..()
if(riding_datum)
riding_datum.handle_ride(user, direction)
// Make sure you know what you're doing if you call this, this is intended to only be called by byond directly.
// You probably want CanPass()
/atom/movable/Cross(atom/movable/AM)
@@ -252,17 +260,17 @@
A.Bumped(src)
A.last_bumped = world.time
/atom/movable/proc/forceMove(atom/destination)
/atom/movable/proc/forceMove(atom/destination, direction, movetime)
. = FALSE
if(destination)
. = doMove(destination)
. = doMove(destination, direction, movetime)
else
CRASH("No valid destination passed into forceMove")
/atom/movable/proc/moveToNullspace()
return doMove(null)
/atom/movable/proc/doMove(atom/destination)
/atom/movable/proc/doMove(atom/destination, direction, movetime)
var/atom/oldloc = loc
var/area/old_area = get_area(oldloc)
var/same_loc = oldloc == destination
@@ -271,7 +279,8 @@
var/area/destarea = get_area(destination)
// Do The Move
last_move = 0
glide_for(movetime)
last_move = isnull(direction) ? 0 : direction
loc = destination
// Unset this in case it was set in some other proc. We're no longer moving diagonally for sure.
@@ -349,6 +358,15 @@
for(var/item in src) // Notify contents of Z-transition. This can be overridden IF we know the items contents do not care.
var/atom/movable/AM = item
AM.onTransitZ(old_z,new_z)
/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)
/////////////////////////////////////////////////////////////////
//called when src is thrown into hit_atom

View File

@@ -176,10 +176,11 @@
add_fingerprint(user)
return M
/atom/movable/proc/handle_buckled_mob_movement(atom/old_loc, direct)
/atom/movable/proc/handle_buckled_mob_movement(atom/old_loc, direct, movetime)
for(var/A in buckled_mobs)
var/mob/living/L = A
L.forceMove(loc, direct)
if(!L.Move(loc, direct, movetime))
L.forceMove(loc, direct, movetime)
L.last_move = last_move
L.inertia_dir = last_move

View File

@@ -145,13 +145,13 @@
playsound(src, 'sound/effects/roll.ogg', 100, 1)
/obj/structure/bed/chair/office/handle_buckled_mob_movement(atom/new_loc, direction)
/obj/structure/bed/chair/office/handle_buckled_mob_movement(atom/new_loc, direction, movetime)
for(var/A in buckled_mobs)
var/mob/living/occupant = A
occupant.buckled = null
occupant.Move(src.loc)
occupant.Move(loc, direction, movetime)
occupant.buckled = src
if (occupant && (src.loc != occupant.loc))
if (occupant && (loc != occupant.loc))
if (propelled)
for (var/mob/O in src.loc)
if (O != occupant)

View File

@@ -165,9 +165,6 @@ var/const/enterloopsanity = 100
else if(!is_space())
M.inertia_dir = 0
M.make_floating(0)
if(isliving(M))
var/mob/living/L = M
L.handle_footstep(src)
var/objects = 0
if(A && (A.flags & PROXMOVE))

View File

@@ -91,10 +91,12 @@
if(!old_T.Adjacent(newloc))
return MOVEMENT_FAILED
. = SelfMove(newloc) ? MOVEMENT_SUCCESSFUL : MOVEMENT_FAILED
var/delay_will_be = movement_delay()
. = SelfMove(newloc, get_dir(loc,newloc), delay_will_be) ? MOVEMENT_SUCCESSFUL : MOVEMENT_FAILED
if(. == MOVEMENT_SUCCESSFUL)
set_dir(get_dir(old_T, newloc))
// Apply movement delay.
// Player movement has more factors but its all in the client and fixing that would be its own project.
setMoveCooldown(movement_delay())
setMoveCooldown(delay_will_be)
return

View File

@@ -1639,3 +1639,32 @@
msg += get_display_species()
return msg
/mob/living/carbon/human/pull_damage()
if(((health - halloss) <= config.health_threshold_softcrit))
for(var/name in organs_by_name)
var/obj/item/organ/external/e = organs_by_name[name]
if(!e)
continue
if((e.status & ORGAN_BROKEN && (!e.splinted || (e.splinted && e.splinted in e.contents && prob(30))) || e.status & ORGAN_BLEEDING) && (getBruteLoss() + getFireLoss() >= 100))
return 1
else
return ..()
// Drag damage is handled in a parent
/mob/living/carbon/human/dragged(var/mob/living/dragger, var/oldloc)
if(prob(getBruteLoss() * 200 / maxHealth))
var/bloodtrail = 1
if(species?.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((vessel.get_reagent_amount("blood")/species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
vessel.remove_reagent("blood", 1)
if(bloodtrail)
if(istype(loc, /turf/simulated))
var/turf/T = loc
T.add_blood(src)
. = ..()

View File

@@ -224,6 +224,8 @@
// Handle footstep sounds
/mob/living/carbon/human/handle_footstep(var/turf/T)
if(!istype(T))
return
if(is_incorporeal())
return
if(!config.footstep_volume || !T.footstep_sounds || !T.footstep_sounds.len)

View File

@@ -777,117 +777,62 @@ default behaviour is:
to_chat(usr, "OOC Metadata is not supported by this server!")
//VOREStation Edit End - Making it so SSD people have prefs with fallback to original style.
/mob/living/Move(a, b, flag)
if (buckled && buckled.loc != a) //not updating position
if(istype(buckled, /mob)) //If you're buckled to a mob, a la slime things, keep on rolling.
return buckled.Move(a, b)
else //Otherwise, no running around for you.
// Almost all of this handles pulling movables behind us
/mob/living/Move(atom/newloc, direct, movetime)
if(buckled && buckled.loc != newloc) //not updating position
if(!buckled.anchored)
return buckled.Move(newloc, direct)
else
return 0
var/atom/movable/pullee = pulling
// Prior to our move it's already too far away
if(pullee && get_dist(src, pullee) > 1)
stop_pulling()
// Shenanigans!
if(pullee && !isturf(pullee.loc) && pullee.loc != loc)
log_debug("[src]'s pull on [pullee] was broken despite [pullee] being in [pullee.loc]. Pull stopped manually.")
stop_pulling()
// Can't pull with no hands
if(restrained())
stop_pulling()
// Will move our mob (probably)
. = ..() // Moved() called at this point if successful
var/t7 = 1
if (restrained())
for(var/mob/living/M in range(src, 1))
if ((M.pulling == src && M.stat == 0 && !( M.restrained() )))
t7 = null
if ((t7 && (pulling && ((get_dist(src, pulling) <= 1 || pulling.loc == loc) && (client && client.moving)))))
var/turf/T = loc
. = ..()
if (pulling && pulling.loc)
if(!( isturf(pulling.loc) ))
stop_pulling()
return
/////
if(pulling && pulling.anchored)
stop_pulling()
return
if (!restrained())
var/diag = get_dir(src, pulling)
if ((diag - 1) & diag)
else
diag = null
if ((get_dist(src, pulling) > 1 || diag))
if (isliving(pulling))
var/mob/living/M = pulling
var/atom/movable/t = M.pulling
M.stop_pulling()
if(!istype(M.loc, /turf/space))
var/area/A = get_area(M)
if(A.has_gravity)
//this is the gay blood on floor shit -- Added back -- Skie
if (M.lying && (prob(M.getBruteLoss() / 6)))
var/bloodtrail = 1 //Checks if it's possible to even spill blood
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.species.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((H.vessel.get_reagent_amount("blood")/H.species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
H.vessel.remove_reagent("blood", 1)
if(bloodtrail)
var/turf/location = M.loc
if(istype(location, /turf/simulated))
location.add_blood(M)
//pull damage with injured people
if(prob(25))
M.adjustBruteLoss(1)
visible_message("<span class='danger'>\The [M]'s [M.isSynthetic() ? "state worsens": "wounds open more"] from being dragged!</span>")
if(M.pull_damage())
if(prob(25))
M.adjustBruteLoss(2)
visible_message("<span class='danger'>\The [M]'s [M.isSynthetic() ? "state" : "wounds"] worsen terribly from being dragged!</span>")
var/turf/location = M.loc
if (istype(location, /turf/simulated))
var/bloodtrail = 1 //Checks if it's possible to even spill blood
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.species.flags & NO_BLOOD)
bloodtrail = 0
else
var/blood_volume = round((H.vessel.get_reagent_amount("blood")/H.species.blood_volume)*100)
if(blood_volume < BLOOD_VOLUME_SURVIVE)
bloodtrail = 0 //Most of it's gone already, just leave it be
else
H.vessel.remove_reagent("blood", 1)
if(bloodtrail)
if(istype(location, /turf/simulated))
location.add_blood(M)
if(get_dist(pulling.loc, T) > 1 || pulling.loc.z != T.z)
M.stop_pulling()
else
step(pulling, get_dir(pulling.loc, T))
if(t)
M.start_pulling(t)
else
if (pulling)
if (istype(pulling, /obj/structure/window))
var/obj/structure/window/W = pulling
if(W.is_fulltile())
for(var/obj/structure/window/win in get_step(pulling,get_dir(pulling.loc, T)))
stop_pulling()
if(get_dist(pulling.loc, T) > 1 || pulling.loc.z != T.z) // This is needed or else pulled objects can't get pushed away.
stop_pulling()
else
step(pulling, get_dir(pulling.loc, T))
else
stop_pulling()
. = ..()
if(pulledby && moving_diagonally != FIRST_DIAG_STEP && get_dist(src, pulledby) > 1) //seperated from our puller and not in the middle of a diagonal move
pulledby.stop_pulling()
if(s_active && !(s_active in contents) && get_turf(s_active) != get_turf(src)) //check !( s_active in contents ) first so we hopefully don't have to call get_turf() so much.
s_active.close(src)
/mob/living/proc/dragged(var/mob/living/dragger, var/oldloc)
var/area/A = get_area(src)
if(lying && !buckled && pull_damage() && A.has_gravity && (prob(getBruteLoss() * 200 / maxHealth)))
adjustBruteLoss(2)
visible_message("<span class='danger'>\The [src]'s [isSynthetic() ? "state" : "wounds"] worsen terribly from being dragged!</span>")
/mob/living/Moved(var/oldloc, direct, forced, movetime)
. = ..()
handle_footstep(loc)
var/atom/movable/pullee = pulling
if(pulling && pulling == pullee) // we were pulling a thing and didn't lose it during our move.
if(pulling.anchored)
stop_pulling()
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
// living might take damage from drags
if(isliving(pulling))
var/mob/living/M = pulling
M.dragged(src, oldloc)
pulling.Move(oldloc, 0, movetime) // the pullee tries to reach our previous position
if(pulling && get_dist(src, pulling) > 1) // the pullee couldn't keep up
stop_pulling()
/mob/living/proc/handle_footstep(turf/T)
return FALSE

View File

@@ -516,15 +516,6 @@
/mob/proc/pull_damage()
if(ishuman(src))
var/mob/living/carbon/human/H = src
if(H.health - H.halloss <= config.health_threshold_softcrit)
for(var/name in H.organs_by_name)
var/obj/item/organ/external/e = H.organs_by_name[name]
if(e && H.lying)
if((e.status & ORGAN_BROKEN && (!e.splinted || (e.splinted && e.splinted in e.contents && prob(30))) || e.status & ORGAN_BLEEDING) && (H.getBruteLoss() + H.getFireLoss() >= 100))
return 1
break
return 0
/mob/MouseDrop(mob/M as mob)

View File

@@ -279,9 +279,8 @@
n = get_step(my_mob, direct)
total_delay = TICKS2DS(-round(-(DS2TICKS(total_delay)))) //Rounded to the next tick in equivalent ds
var/glide_size = WORLD_ICON_SIZE/max(DS2TICKS(total_delay), 1) //Down to whatever decimal
my_mob.setMoveCooldown(total_delay)
. = my_mob.SelfMove(n, direct, glide_size)
. = my_mob.SelfMove(n, direct, total_delay)
// If we have a grab
var/list/grablist = my_mob.ret_grab()
@@ -292,23 +291,19 @@
if(grablist.len == 1)
var/mob/M = grablist[1]
if(!my_mob.Adjacent(M)) //Oh no, we moved away
M.glide_size = glide_size
step(M, get_dir(M, pre_move_loc)) //Have them step towards where we were
M.Move(pre_move_loc, get_dir(M, pre_move_loc), total_delay) //Have them step towards where we were
// It's a grab chain
else
for(var/mob/M in grablist)
my_mob.other_mobs = 1
M.other_mobs = 1 //Has something to do with people being able or unable to pass a chain of mobs
M.animate_movement = 3
//Ugly!
spawn(0) //Step
M.glide_size = glide_size
step(M, direct)
M.Move(pre_move_loc, get_dir(M, pre_move_loc), total_delay)
spawn(1) //Unstep
M.other_mobs = null
M.animate_movement = 2
spawn(1) //Unset
my_mob.other_mobs = null
@@ -323,9 +318,8 @@
// We're not in the middle of a move anymore
moving = 0
/mob/proc/SelfMove(turf/n, direct, glide_size = 8)
src.glide_size = glide_size
return Move(n, direct)
/mob/proc/SelfMove(turf/n, direct, movetime)
return Move(n, direct, movetime)
///Process_Incorpmove
///Called by client/Move()

View File

@@ -66,54 +66,30 @@
/obj/vehicle/unbuckle_mob(mob/living/buckled_mob, force = FALSE)
. = ..(buckled_mob, force)
for(var/mob/M in buckled_mobs)
buckled_mob.update_water()
if(riding_datum)
riding_datum.restore_position(buckled_mob)
riding_datum.handle_vehicle_offsets() // So the person in back goes to the front.
/obj/vehicle/set_dir(newdir)
..(newdir)
if(riding_datum)
riding_datum.handle_vehicle_offsets()
/obj/vehicle/Move(var/newloc, var/direction, var/movetime)
if(world.time < l_move_time + move_delay) //This AND the riding datum move speed limit?
return
//MOVEMENT
/obj/vehicle/relaymove(mob/user, direction)
if(riding_datum)
riding_datum.handle_ride(user, direction)
/obj/vehicle/Moved()
. = ..()
if(riding_datum)
riding_datum.handle_vehicle_layer()
riding_datum.handle_vehicle_offsets()
/obj/vehicle/Move()
if(world.time > l_move_time + move_delay)
var/old_loc = get_turf(src)
if(mechanical && on && powered && cell.charge < charge_use)
turn_off()
return
var/init_anc = anchored
anchored = 0
if(!..())
anchored = init_anc
return 0
set_dir(get_dir(old_loc, loc))
anchored = init_anc
. = ..()
if(mechanical && on && powered)
cell.use(charge_use)
//Dummy loads do not have to be moved as they are just an overlay
//See load_object() proc in cargo_trains.dm for an example
if(load && !istype(load, /datum/vehicle_dummy_load))
//Also mobs are buckled to the vehicle and get moved in atom/movable/Move's call to take care of that
if(load && !(load in buckled_mobs) && !istype(load, /datum/vehicle_dummy_load))
load.forceMove(loc)
load.set_dir(dir)
return 1
else
return 0
/obj/vehicle/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/hand_labeler))