diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index f334b28da76..ad68a08bd98 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -256,15 +256,30 @@ holdingitems -= O qdel(O) -/obj/machinery/reagentgrinder/proc/shake_for(duration) - var/offset = prob(50) ? -2 : 2 - var/old_pixel_x = pixel_x - animate(src, pixel_x = pixel_x + offset, time = 0.2, loop = -1) //start shaking - addtimer(CALLBACK(src, .proc/stop_shaking, old_pixel_x), duration) +/obj/machinery/reagentgrinder/proc/start_shaking() + var/static/list/transforms + if(!transforms) + var/matrix/M1 = matrix() + var/matrix/M2 = matrix() + var/matrix/M3 = matrix() + var/matrix/M4 = matrix() + M1.Translate(-1, 0) + M2.Translate(0, 1) + M3.Translate(1, 0) + M4.Translate(0, -1) + transforms = list(M1, M2, M3, M4) + animate(src, transform=transforms[1], time=0.4, loop=-1) + animate(transform=transforms[2], time=0.2) + animate(transform=transforms[3], time=0.4) + animate(transform=transforms[4], time=0.6) -/obj/machinery/reagentgrinder/proc/stop_shaking(old_px) - animate(src) - pixel_x = old_px +/obj/machinery/reagentgrinder/proc/shake_for(duration) + start_shaking() //start shaking + addtimer(CALLBACK(src, .proc/stop_shaking), duration) + +/obj/machinery/reagentgrinder/proc/stop_shaking() + update_appearance() + animate(src, transform = matrix()) /obj/machinery/reagentgrinder/proc/operate_for(time, silent = FALSE, juicing = FALSE) shake_for(time / speed)