diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index fe468104c16..f5c9edb9bf1 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,18 @@ if(gravitystate) for(var/mob/living/carbon/human/M in SubA) thunk(M) + for(var/mob/M1 in SubA) + M1.make_floating(0) + else + for(var/mob/M in SubA) + if(M.Check_Dense_Object() && istype(src,/mob/living/carbon/human/)) + 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 + H.make_floating(0) + else + H.make_floating(1) + else + M.make_floating(1) /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/game/turfs/turf.dm b/code/game/turfs/turf.dm index 8168a34f0c5..80a70d5c049 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -130,6 +130,8 @@ else if(!istype(src, /turf/space)) M:inertia_dir = 0 + var/mob/M1 = M + M1.make_floating(0) ..() var/objects = 0 for(var/atom/A as mob|obj|turf|area in range(1)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index feee1b00f4c..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 @@ -679,6 +679,40 @@ note dizziness decrements automatically in the mob's Life() proc. pixel_x = old_x pixel_y = old_y + +//handles up-down floaty effect in space +/mob/proc/make_floating(var/n) + + floatiness = n + + if(floatiness && !is_floating) + start_floating() + else if(!floatiness && is_floating) + stop_floating() + +/mob/proc/start_floating() + + is_floating = 1 + + 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 + + + /mob/Stat() ..() diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index 86f3724fb55..f781616120f 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -99,11 +99,15 @@ 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 var/is_jittery = 0 var/jitteriness = 0//Carbon + var/is_floating = 0 + var/floatiness = 0 var/charges = 0.0 var/nutrition = 400.0//Carbon diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 9310155160b..ee7ae00560e 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -402,15 +402,34 @@ ///For moving in space ///Return 1 for movement 0 for none /mob/proc/Process_Spacemove(var/check_drift = 0) - //First check to see if we can do things - if(restrained()) + + if(!Check_Dense_Object()) //Nothing to push off of so end here + make_floating(1) return 0 - /* - if(istype(src,/mob/living/carbon)) - if(src.l_hand && src.r_hand) - return 0 - */ + if(istype(src,/mob/living/carbon/human/)) + 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) + else + make_floating(1) + + if(restrained()) //Check to see if we can do things + return 0 + + //Check to see if we slipped + if(prob(Process_Spaceslipping(5))) + src << "\blue You slipped!" + src.inertia_dir = src.last_move + step(src, src.inertia_dir) + return 0 + //If not then we can reset inertia and move + inertia_dir = 0 + return 1 + +/mob/proc/Check_Dense_Object() //checks for anything to push off in the vicinity. also handles magboots on gravity-less floors tiles var/dense_object = 0 for(var/turf/turf in oview(1,src)) @@ -418,7 +437,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 @@ -449,21 +469,7 @@ dense_object++ break - //Nothing to push off of so end here - if(!dense_object) - return 0 - - - - //Check to see if we slipped - if(prob(Process_Spaceslipping(5))) - src << "\blue You slipped!" - src.inertia_dir = src.last_move - step(src, src.inertia_dir) - return 0 - //If not then we can reset inertia and move - inertia_dir = 0 - return 1 + return dense_object /mob/proc/Process_Spaceslipping(var/prob_slip = 5)