From 48a15bb2c4eb8fd0bdde29e328ffbaa5bc48dfd5 Mon Sep 17 00:00:00 2001 From: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:02:08 +0200 Subject: [PATCH] Adds a Throwing Animation (#14680) --- code/modules/mob/animations.dm | 26 ++++++++++++++++++++++++++ code/modules/mob/inventory.dm | 4 ++++ html/changelogs/throwing_animation.yml | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 html/changelogs/throwing_animation.yml diff --git a/code/modules/mob/animations.dm b/code/modules/mob/animations.dm index a17c24713b3..0a3278c53ef 100644 --- a/code/modules/mob/animations.dm +++ b/code/modules/mob/animations.dm @@ -268,3 +268,29 @@ note dizziness decrements automatically in the mob's Life() proc. set_dir(D) spintime -= speed return + +// Mob Throwing Animation +/proc/animate_throw(atom/A) + var/ipx = A.pixel_x + var/ipy = A.pixel_y + var/mpx = 0 + var/mpy = 0 + + if(A.dir & NORTH) + mpy += 3 + else if(A.dir & SOUTH) + mpy -= 3 + if(A.dir & EAST) + mpx += 3 + else if(A.dir & WEST) + mpx -= 3 + + var/x = mpx + ipx + var/y = mpy + ipy + + animate(A, pixel_x = x, pixel_y = y, time = 0.6, easing = EASE_OUT) + + var/matrix/M = matrix(A.transform) + animate(transform = turn(A.transform, (mpx - mpy) * 4), time = 0.6, easing = EASE_OUT) + animate(pixel_x = ipx, pixel_y = ipy, time = 0.6, easing = EASE_IN) + animate(transform = M, time = 0.6, easing = EASE_IN) \ No newline at end of file diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index ecfa3766693..47365f63ca6 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -423,6 +423,10 @@ var/list/slot_equipment_priority = list( \ playsound(src, 'sound/effects/throw.ogg', volume, TRUE, -1) item.throw_at(target, item.throw_range, item.throw_speed, src) + + // Animate the mob throwing. + animate_throw(src) + return TRUE return FALSE diff --git a/html/changelogs/throwing_animation.yml b/html/changelogs/throwing_animation.yml new file mode 100644 index 00000000000..84523af9c44 --- /dev/null +++ b/html/changelogs/throwing_animation.yml @@ -0,0 +1,6 @@ +author: SleepyGemmy + +delete-after: True + +changes: + - rscadd: "Adds a throwing animation." \ No newline at end of file