From 670bda0e292d1a72d977bb8060882097ff9ab16c Mon Sep 17 00:00:00 2001 From: Hatterhat Date: Wed, 3 Aug 2022 06:01:35 -0500 Subject: [PATCH] it works --- code/modules/mob/mob_helpers.dm | 13 +++++++++++++ code/modules/projectiles/gun.dm | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 8595839831..224fc73405 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -250,7 +250,20 @@ It's fairly easy to fix if dealing with single letters but not so much with comp animate(pixel_x=rand(min,max), pixel_y=rand(min,max), time=1) animate(pixel_x=oldx, pixel_y=oldy, time=1) +/proc/directional_recoil(mob/M, strength=1, angle = 0) + if(!M || !M.client) + return + var/client/C = M.client + var/recoil_x = -sin(angle)*4*strength + rand(-strength, strength) + var/recoil_y = -cos(angle)*4*strength + rand(-strength, strength) + animate(C, pixel_x=recoil_x, pixel_y=recoil_y, time=1, easing=SINE_EASING|EASE_OUT, flags=ANIMATION_PARALLEL|ANIMATION_RELATIVE) + addtimer(CALLBACK(GLOBAL_PROC, /proc/recoil_recover, M), 2) +/proc/recoil_recover(mob/M) + if(!M || !M.client) + return + var/client/C = M.client + animate(C, pixel_x=0, pixel_y=0, time=3, easing=SINE_EASING|EASE_IN) /proc/findname(msg) if(!istext(msg)) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index 3210ad2d15..765a5b50c9 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -159,7 +159,7 @@ /obj/item/gun/proc/shoot_live_shot(mob/living/user, pointblank = FALSE, mob/pbtarget, message = 1, stam_cost = 0) if(recoil) - shake_camera(user, recoil + 1, recoil) + directional_recoil(user, recoil*5, Get_Angle(user, pbtarget)) // the *5 is a placeholder. the recoil goes hard if(stam_cost) //CIT CHANGE - makes gun recoil cause staminaloss var/safe_cost = clamp(stam_cost, 0, user.stamina_buffer)*(firing && burst_size >= 2 ? 1/burst_size : 1)