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
+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)