From f02491f3b46d82b96e11a51cb0276a882219a89f Mon Sep 17 00:00:00 2001 From: Hopek Date: Mon, 9 Dec 2019 19:18:12 -0600 Subject: [PATCH] Animates dab emote --- code/__HELPERS/matrices.dm | 27 +++++++++++++++++++++ yogstation/code/modules/mob/living/emote.dm | 3 +++ 2 files changed, 30 insertions(+) diff --git a/code/__HELPERS/matrices.dm b/code/__HELPERS/matrices.dm index e12d753d20fd..c17428b4619a 100644 --- a/code/__HELPERS/matrices.dm +++ b/code/__HELPERS/matrices.dm @@ -27,6 +27,33 @@ //doesn't have an object argument because this is "Stacking" with the animate call above //3 billion% intentional +/atom/proc/DabAnimation(speed = 1, loops = 1, direction = 1 , hold_seconds = 0 , angle = 1 , stay = FALSE) // Hopek 2019 + // By making this in atom/proc everything in the game can potentially dab. You have been warned. + if(hold_seconds > 9999) // if you need to hold a dab for more than 2 hours intentionally let me know. + return + if(hold_seconds > 0) + hold_seconds = hold_seconds * 10 // Converts seconds to deciseconds + if(angle == 1) //if angle is 1: random angle. Else take angle + angle = rand(25,50) + if(direction == 1) // direciton:: 1 for random pick, 2 for clockwise , 3 for anti-clockwise + direction = pick(2,3) + if(direction == 3) // if 3 then counter clockwise + angle = angle * -1 + if(speed == 1) // if speed is 1 choose random speed from list + speed = rand(3,5) + + // dab matrix here + var/matrix/DAB_COMMENCE = matrix(transform) + var/matrix/DAB_RETURN = matrix(transform) + DAB_COMMENCE.Turn(angle) // dab angle to matrix + + // Dab animation + animate(src, transform = DAB_COMMENCE, time = speed, loops ) // dab to hold angle + if(hold_seconds > 0) + sleep(hold_seconds) // time to hold the dab before going back + if(!stay) // if stay param is true dab doesn't return + animate(src, transform = DAB_RETURN, time = speed * 1.5, loops ) // reverse dab to starting position , slower + //Dumps the matrix data in format a-f /matrix/proc/tolist() . = list() diff --git a/yogstation/code/modules/mob/living/emote.dm b/yogstation/code/modules/mob/living/emote.dm index 4057a8c9d662..ee6e02e506e4 100644 --- a/yogstation/code/modules/mob/living/emote.dm +++ b/yogstation/code/modules/mob/living/emote.dm @@ -70,4 +70,7 @@ . = ..() if(. && ishuman(user)) var/mob/living/carbon/human/H = user + var/light_dab_angle = rand(35,55) + var/light_dab_speed = rand(3,7) + H.DabAnimation(angle = light_dab_angle , speed = light_dab_speed) H.adjustOrganLoss(ORGAN_SLOT_BRAIN, 5)