diff --git a/baystation12.dme b/baystation12.dme index a1074dc190..f9650c3fce 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1056,6 +1056,7 @@ #include "code\modules\mining\satchel_ore_boxdm.dm" #include "code\modules\mining\drilling\drill.dm" #include "code\modules\mining\drilling\scanner.dm" +#include "code\modules\mob\animations.dm" #include "code\modules\mob\death.dm" #include "code\modules\mob\emote.dm" #include "code\modules\mob\hear_say.dm" diff --git a/code/modules/mob/animations.dm b/code/modules/mob/animations.dm new file mode 100644 index 0000000000..8deca57d18 --- /dev/null +++ b/code/modules/mob/animations.dm @@ -0,0 +1,164 @@ +/* +adds a dizziness amount to a mob +use this rather than directly changing var/dizziness +since this ensures that the dizzy_process proc is started +currently only humans get dizzy + +value of dizziness ranges from 0 to 1000 +below 100 is not dizzy +*/ + +/mob/var/dizziness = 0//Carbon +/mob/var/is_dizzy = 0 + +/mob/proc/make_dizzy(var/amount) + if(!istype(src, /mob/living/carbon/human)) // for the moment, only humans get dizzy + return + + dizziness = min(1000, dizziness + amount) // store what will be new value + // clamped to max 1000 + if(dizziness > 100 && !is_dizzy) + spawn(0) + dizzy_process() + + +/* +dizzy process - wiggles the client's pixel offset over time +spawned from make_dizzy(), will terminate automatically when dizziness gets <100 +note dizziness decrements automatically in the mob's Life() proc. +*/ +/mob/proc/dizzy_process() + is_dizzy = 1 + while(dizziness > 100) + if(client) + var/amplitude = dizziness*(sin(dizziness * 0.044 * world.time) + 1) / 70 + client.pixel_x = amplitude * sin(0.008 * dizziness * world.time) + client.pixel_y = amplitude * cos(0.008 * dizziness * world.time) + + sleep(1) + //endwhile - reset the pixel offsets to zero + is_dizzy = 0 + if(client) + client.pixel_x = 0 + client.pixel_y = 0 + +// jitteriness - copy+paste of dizziness +/mob/var/is_jittery = 0 +/mob/var/jitteriness = 0//Carbon +/mob/proc/make_jittery(var/amount) + if(!istype(src, /mob/living/carbon/human)) // for the moment, only humans get dizzy + return + + jitteriness = min(1000, jitteriness + amount) // store what will be new value + // clamped to max 1000 + if(jitteriness > 100 && !is_jittery) + spawn(0) + jittery_process() + + +// 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 + is_jittery = 1 + while(jitteriness > 100) +// var/amplitude = jitteriness*(sin(jitteriness * 0.044 * world.time) + 1) / 70 +// pixel_x = amplitude * sin(0.008 * jitteriness * world.time) +// pixel_y = amplitude * cos(0.008 * jitteriness * world.time) + + var/amplitude = min(4, jitteriness / 100) + 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 + is_jittery = 0 + pixel_x = old_x + pixel_y = old_y + + +//handles up-down floaty effect in space +/mob/var/is_floating = 0 +/mob/var/floatiness = 0 + +/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 + +/atom/movable/proc/do_attack_animation(atom/A) + world << "[src].do_attack_animation([A])" + + var/pixel_x_diff = 0 + var/pixel_y_diff = 0 + var/direction = get_dir(src, A) + switch(direction) + if(NORTH) + pixel_y_diff = 8 + if(SOUTH) + pixel_y_diff = -8 + if(EAST) + pixel_x_diff = 8 + if(WEST) + pixel_x_diff = -8 + if(NORTHEAST) + pixel_x_diff = 8 + pixel_y_diff = 8 + if(NORTHWEST) + pixel_x_diff = -8 + pixel_y_diff = 8 + if(SOUTHEAST) + pixel_x_diff = 8 + pixel_y_diff = -8 + if(SOUTHWEST) + pixel_x_diff = -8 + pixel_y_diff = -8 + animate(src, pixel_x = pixel_x + pixel_x_diff, pixel_y = pixel_y + pixel_y_diff, time = 2) + animate(pixel_x = initial(pixel_x), pixel_y = initial(pixel_y), time = 2) + +/mob/do_attack_animation(atom/A) + ..() + is_floating = 0 // If we were without gravity, the bouncing animation got stopped, so we make sure we restart the bouncing after the next movement. + +/mob/proc/spin(spintime, speed) + spawn() + var/D = dir + while(spintime >= speed) + sleep(speed) + switch(D) + if(NORTH) + D = EAST + if(SOUTH) + D = WEST + if(EAST) + D = SOUTH + if(WEST) + D = NORTH + set_dir(D) + spintime -= speed + return diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index c37dce2824..80902ddaa9 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -777,20 +777,3 @@ default behaviour is: return ..() -/mob/living/carbon/proc/spin(spintime, speed) - spawn() - var/D = dir - while(spintime >= speed) - sleep(speed) - switch(D) - if(NORTH) - D = EAST - if(SOUTH) - D = WEST - if(EAST) - D = SOUTH - if(WEST) - D = NORTH - set_dir(D) - spintime -= speed - return diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index e9cae30755..370ecce03a 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -615,111 +615,6 @@ for(var/mob/M in viewers()) M.see(message) -/* -adds a dizziness amount to a mob -use this rather than directly changing var/dizziness -since this ensures that the dizzy_process proc is started -currently only humans get dizzy - -value of dizziness ranges from 0 to 1000 -below 100 is not dizzy -*/ -/mob/proc/make_dizzy(var/amount) - if(!istype(src, /mob/living/carbon/human)) // for the moment, only humans get dizzy - return - - dizziness = min(1000, dizziness + amount) // store what will be new value - // clamped to max 1000 - if(dizziness > 100 && !is_dizzy) - spawn(0) - dizzy_process() - - -/* -dizzy process - wiggles the client's pixel offset over time -spawned from make_dizzy(), will terminate automatically when dizziness gets <100 -note dizziness decrements automatically in the mob's Life() proc. -*/ -/mob/proc/dizzy_process() - is_dizzy = 1 - while(dizziness > 100) - if(client) - var/amplitude = dizziness*(sin(dizziness * 0.044 * world.time) + 1) / 70 - client.pixel_x = amplitude * sin(0.008 * dizziness * world.time) - client.pixel_y = amplitude * cos(0.008 * dizziness * world.time) - - sleep(1) - //endwhile - reset the pixel offsets to zero - is_dizzy = 0 - if(client) - client.pixel_x = 0 - client.pixel_y = 0 - -// jitteriness - copy+paste of dizziness - -/mob/proc/make_jittery(var/amount) - if(!istype(src, /mob/living/carbon/human)) // for the moment, only humans get dizzy - return - - jitteriness = min(1000, jitteriness + amount) // store what will be new value - // clamped to max 1000 - if(jitteriness > 100 && !is_jittery) - spawn(0) - jittery_process() - - -// 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 - is_jittery = 1 - while(jitteriness > 100) -// var/amplitude = jitteriness*(sin(jitteriness * 0.044 * world.time) + 1) / 70 -// pixel_x = amplitude * sin(0.008 * jitteriness * world.time) -// pixel_y = amplitude * cos(0.008 * jitteriness * world.time) - - var/amplitude = min(4, jitteriness / 100) - 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 - is_jittery = 0 - 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 792517c6d0..897c5181da 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -108,12 +108,6 @@ 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