Floating effect now uses animate() instead of pixel_y while loop thingy.

Distinct actions that indefinitely change a mob's pixel_y or pixel_x, like strapping someone to a roller bed, should also alter new variables old_y or old_x accordingly. This means that floating and jittering animations no longer interfere, as the animations use old_x/old_y as the "base" position.

Entering areas with gravity from areas without grabity now removes floating effect.
This commit is contained in:
RavingManiac
2014-09-30 22:37:48 +08:00
parent 918520df83
commit c4875e7d36
6 changed files with 42 additions and 17 deletions
+3
View File
@@ -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.
@@ -16,6 +16,7 @@
"<span class='notice'>[user.name] pulls you free from the gelatinous resin.</span>",\
"<span class='notice'>You hear squelching...</span>")
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
@@ -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()
+28 -15
View File
@@ -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()
..()
+2
View File
@@ -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
+4 -2
View File
@@ -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)