diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm
index fe468104c16..1019aed79c2 100644
--- a/code/game/area/areas.dm
+++ b/code/game/area/areas.dm
@@ -299,6 +299,7 @@
var/area/oldarea = L.lastarea
if((oldarea.has_gravity == 0) && (newarea.has_gravity == 1) && (L.m_intent == "run")) // Being ready when you change areas gives you a chance to avoid falling all together.
thunk(L)
+ L.make_floating(0)
L.lastarea = newarea
@@ -326,6 +327,8 @@
if(gravitystate)
for(var/mob/living/carbon/human/M in SubA)
thunk(M)
+ for(var/mob/M1 in SubA)
+ M1.make_floating(0)
/area/proc/thunk(mob)
if(istype(mob,/mob/living/carbon/human/)) // Only humans can wear magboots, so we give them a chance to.
diff --git a/code/game/objects/structures/stool_bed_chair_nest/alien_nests.dm b/code/game/objects/structures/stool_bed_chair_nest/alien_nests.dm
index a45e2436b80..f215123b27a 100644
--- a/code/game/objects/structures/stool_bed_chair_nest/alien_nests.dm
+++ b/code/game/objects/structures/stool_bed_chair_nest/alien_nests.dm
@@ -16,6 +16,7 @@
"[user.name] pulls you free from the gelatinous resin.",\
"You hear squelching...")
buckled_mob.pixel_y = 0
+ buckled_mob.old_y = 0
unbuckle()
else
buckled_mob.visible_message(\
@@ -25,6 +26,7 @@
spawn(1200)
if(user && buckled_mob && user.buckled == src)
buckled_mob.pixel_y = 0
+ buckled_mob.old_y = 0
unbuckle()
src.add_fingerprint(user)
return
@@ -52,6 +54,7 @@
M.dir = src.dir
M.update_canmove()
M.pixel_y = 6
+ M.old_y = 6
src.buckled_mob = M
src.add_fingerprint(user)
return
diff --git a/code/game/objects/structures/stool_bed_chair_nest/bed.dm b/code/game/objects/structures/stool_bed_chair_nest/bed.dm
index 9874c91fd1b..d4f9356c563 100644
--- a/code/game/objects/structures/stool_bed_chair_nest/bed.dm
+++ b/code/game/objects/structures/stool_bed_chair_nest/bed.dm
@@ -195,6 +195,7 @@
if ( !ismob(M) || (get_dist(src, user) > 1) || (M.loc != src.loc) || user.restrained() || user.lying || user.stat || M.buckled || istype(usr, /mob/living/silicon/pai) )
return
M.pixel_y = 6
+ M.old_y = 6
density = 1
icon_state = "up"
..()
@@ -204,6 +205,7 @@
if(buckled_mob)
if(buckled_mob.buckled == src) //this is probably unneccesary, but it doesn't hurt
buckled_mob.pixel_y = 0
+ buckled_mob.old_y = 0
buckled_mob.anchored = initial(buckled_mob.anchored)
buckled_mob.buckled = null
buckled_mob.update_canmove()
diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm
index 419973a9565..e264395b15f 100644
--- a/code/modules/mob/mob.dm
+++ b/code/modules/mob/mob.dm
@@ -661,8 +661,8 @@ note dizziness decrements automatically in the mob's Life() proc.
// Typo from the oriignal coder here, below lies the jitteriness process. So make of his code what you will, the previous comment here was just a copypaste of the above.
/mob/proc/jittery_process()
- var/old_x = pixel_x
- var/old_y = pixel_y
+ //var/old_x = pixel_x
+ //var/old_y = pixel_y
is_jittery = 1
while(jitteriness > 100)
// var/amplitude = jitteriness*(sin(jitteriness * 0.044 * world.time) + 1) / 70
@@ -670,8 +670,8 @@ note dizziness decrements automatically in the mob's Life() proc.
// pixel_y = amplitude * cos(0.008 * jitteriness * world.time)
var/amplitude = min(4, jitteriness / 100)
- pixel_x = rand(-amplitude, amplitude)
- pixel_y = rand(-amplitude/3, amplitude/3)
+ pixel_x = old_x + rand(-amplitude, amplitude)
+ pixel_y = old_y + rand(-amplitude/3, amplitude/3)
sleep(1)
//endwhile - reset the pixel offsets to zero
@@ -683,22 +683,35 @@ note dizziness decrements automatically in the mob's Life() proc.
//handles up-down floaty effect in space
/mob/proc/make_floating(var/n)
- floatiness = n // store what will be new value
+ floatiness = n
if(floatiness && !is_floating)
- spawn(0)
- floating_process()
+ start_floating()
+ else if(!floatiness && is_floating)
+ stop_floating()
+
+/mob/proc/start_floating()
-/mob/proc/floating_process()
is_floating = 1
- while(floatiness)
- var/amplitude = 2
- var/frequency = 10
- pixel_y = amplitude * sin(frequency * world.time)
- sleep(1)
- //endwhile - reset the pixel offsets to zero
+
+ var/amplitude = 2 //maximum displacement from original position
+ var/period = 36 //time taken for the mob to go up >> down >> original position, in deciseconds. Should be multiple of 4
+
+ var/top = old_y + amplitude
+ var/bottom = old_y - amplitude
+ var/half_period = period / 2
+ var/quarter_period = period / 4
+
+ animate(src, pixel_y = top, time = quarter_period, easing = SINE_EASING | EASE_OUT, loop = -1) //up
+ animate(pixel_y = bottom, time = half_period, easing = SINE_EASING, loop = -1) //down
+ animate(pixel_y = old_y, time = quarter_period, easing = SINE_EASING | EASE_IN, loop = -1) //back
+
+/mob/proc/stop_floating()
+ animate(src, pixel_y = old_y, time = 5, easing = SINE_EASING | EASE_IN) //halt animation
+ //reset the pixel offsets to zero
is_floating = 0
- pixel_y = 0
+
+
/mob/Stat()
..()
diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm
index a252b55e658..f781616120f 100644
--- a/code/modules/mob/mob_defines.dm
+++ b/code/modules/mob/mob_defines.dm
@@ -99,6 +99,8 @@
var/bodytemperature = 310.055 //98.7 F
+ var/old_x = 0
+ var/old_y = 0
var/drowsyness = 0.0//Carbon
var/dizziness = 0//Carbon
var/is_dizzy = 0
diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm
index 90eca448475..87babf9a7e0 100644
--- a/code/modules/mob/mob_movement.dm
+++ b/code/modules/mob/mob_movement.dm
@@ -415,7 +415,8 @@
continue
if(istype(src,/mob/living/carbon/human/)) // Only humans can wear magboots, so we give them a chance to.
- if((istype(turf,/turf/simulated/floor)) && (src.lastarea.has_gravity == 0) && !(istype(src:shoes, /obj/item/clothing/shoes/magboots) && (src:shoes:flags & NOSLIP)))
+ var/mob/living/carbon/human/H = src
+ if((istype(turf,/turf/simulated/floor)) && (src.lastarea.has_gravity == 0) && !(istype(H.shoes, /obj/item/clothing/shoes/magboots) && (H.shoes.flags & NOSLIP)))
continue
@@ -452,7 +453,8 @@
return 0
if(istype(src,/mob/living/carbon/human/))
- if(istype(src:shoes, /obj/item/clothing/shoes/magboots) && (src:shoes.flags & NOSLIP)) //magboots + dense_object = no floaty effect
+ var/mob/living/carbon/human/H = src
+ if(istype(H.shoes, /obj/item/clothing/shoes/magboots) && (H.shoes.flags & NOSLIP)) //magboots + dense_object = no floaty effect
make_floating(0)
else
make_floating(1)