From 29a8c2eee6f87482433125189edf084d99e8269c Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Thu, 23 Jul 2020 12:47:21 -0700 Subject: [PATCH] flushed --- code/modules/mob/clickdelay.dm | 15 +++++++++++---- code/modules/mob/living/living_defense.dm | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/code/modules/mob/clickdelay.dm b/code/modules/mob/clickdelay.dm index c634b04f15..d570650789 100644 --- a/code/modules/mob/clickdelay.dm +++ b/code/modules/mob/clickdelay.dm @@ -52,8 +52,9 @@ * * ignore_mod - ignores next action adjust and mult * * considered_action - Defaults to TRUE - If TRUE, sets last_action to world.time. * * immediate - defaults to TRUE - if TRUE, writes to cached/last_attack_immediate instead of last_attack. This ensures it can't collide with any delay checks in the actual attack. + * * flush - defaults to FALSE - Use this while using this proc outside of clickcode to ensure everything is set properly. This should never be set to TRUE if this is called from clickcode. */ -/mob/proc/DelayNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE, immediate = TRUE) +/mob/proc/DelayNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE, immediate = TRUE, flush = FALSE) if(immediate) if(considered_action) last_action_immediate = world.time @@ -62,7 +63,10 @@ if(considered_action) last_action = world.time next_action = max(next_action, world.time + (ignore_mod? amount : (amount * GetActionCooldownMod() + GetActionCooldownAdjust()))) - hud_used?.clickdelay?.mark_dirty() + if(flush) + FlushCurrentAction() + else + hud_used?.clickdelay?.mark_dirty() /** * Get estimated time of next attack. @@ -79,7 +83,7 @@ /** * Sets our next action to. The difference is DelayNextAction cannot reduce next_action under any circumstances while this can. */ -/mob/proc/SetNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE, immediate = TRUE) +/mob/proc/SetNextAction(amount = 0, ignore_mod = FALSE, considered_action = TRUE, immediate = TRUE, flush = FALSE) if(immediate) if(considered_action) last_action_immediate = world.time @@ -88,7 +92,10 @@ if(considered_action) last_action = world.time next_action = world.time + (ignore_mod? amount : (amount * GetActionCooldownMod() + GetActionCooldownAdjust())) - hud_used?.clickdelay?.mark_dirty() + if(flush) + FlushCurrentAction() + else + hud_used?.clickdelay?.mark_dirty() /** * Checks if we can do another action. diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 0d9c0288cc..03273e999f 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -215,7 +215,7 @@ //proc to upgrade a simple pull into a more aggressive grab. /mob/living/proc/grippedby(mob/living/carbon/user, instant = FALSE) if(user.grab_state < GRAB_KILL) - user.DelayNextAction(CLICK_CD_GRABBING) + user.DelayNextAction(CLICK_CD_GRABBING, flush = TRUE) playsound(src, 'sound/weapons/thudswoosh.ogg', 50, 1, -1) if(user.grab_state) //only the first upgrade is instantaneous