From 4fefb9aa276eb3b8cb5cec8502cd8bbf2234990b Mon Sep 17 00:00:00 2001 From: Iamgoofball Date: Fri, 20 Jul 2018 16:23:15 -0700 Subject: [PATCH] Adds juice to picking up stuff (#39231) * Adds juice to picking up stuff Stolen completely from https://github.com/OracleStation/OracleStation/pull/1072 * perfection * Pickup animation now tweens to the correct spot if you move * mutable appearance --- code/game/atoms_movable.dm | 36 +++++++++++++++++++++++++++++++++++ code/modules/mob/inventory.dm | 2 ++ 2 files changed, 38 insertions(+) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 9ebcfbca285..02706035380 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -771,3 +771,39 @@ if(anchored || throwing) return FALSE return TRUE + + +/obj/item/proc/do_pickup_animation(atom/target) + set waitfor = FALSE + var/mutable_appearance/I = new(icon = src, loc = loc, layer = layer + 0.1) + I.plane = GAME_PLANE + I.transform *= 0.75 + I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA + var/turf/T = get_turf(src) + var/direction + var/to_x = 0 + var/to_y = 0 + + flick_overlay(I, GLOB.clients, 6) + var/static/matrix/M = new + M.Turn(pick(-30, 30)) + + animate(I, transform = M, time = 1) + sleep(1) + animate(I, transform = matrix(), time = 1) + sleep(1) + if(!QDELETED(T) && !QDELETED(target)) + direction = get_dir(T, target) + if(direction & NORTH) + to_y = 32 + else if(direction & SOUTH) + to_y = -32 + if(direction & EAST) + to_x = 32 + else if(direction & WEST) + to_x = -32 + if(!direction) + to_y = 16 + animate(I, alpha = 175, pixel_x = to_x, pixel_y = to_y, time = 3, easing = CUBIC_EASING) + sleep(1) + animate(I, alpha = 0, time = 1) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 58b3d8704bc..3498281a552 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -172,6 +172,8 @@ /mob/proc/put_in_hand(obj/item/I, hand_index, forced = FALSE) if(forced || can_put_in_hand(I, hand_index)) + if(isturf(I.loc)) + I.do_pickup_animation(src) if(hand_index == null) return FALSE if(get_item_for_held_index(hand_index) != null)