From efe5b709b0f5f3aca61061e446c7db3766e6a190 Mon Sep 17 00:00:00 2001 From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> Date: Tue, 30 Mar 2021 15:26:24 -0400 Subject: [PATCH] Squashing cast/refund bug adds a new bool var and a 1 second timer to ensure that refund_cast doesnt fire if the spell was actually cast correctly. --- code/datums/spell.dm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/datums/spell.dm b/code/datums/spell.dm index db668cd609a..34efb2e14fa 100644 --- a/code/datums/spell.dm +++ b/code/datums/spell.dm @@ -108,6 +108,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) var/spell_level = 0 //if a spell can be taken multiple times, this raises var/level_max = 4 //The max possible level_max is 4 var/cooldown_min = 0 //This defines what spell quickened four timeshas as a cooldown. Make sure to set this for every spell + var/is_casting = FALSE var/overlay = 0 var/overlay_icon = 'icons/obj/wizard.dmi' @@ -147,6 +148,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) return 0 if(start_recharge) + addtimer(CALLBACK(src, /obj/effect/proc_holder/spell/proc/cast_cooldown), 1 SECONDS) switch(charge_type) if("recharge") charge_counter = 0 //doesn't start recharging until the targets selecting ends @@ -448,6 +450,9 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) else to_chat(user, "[src] is not ready to be used yet.") +/obj/effect/proc_holder/spell/proc/cast_cooldown + is_casting = FALSE + /obj/effect/proc_holder/spell/targeted/click/proc/attempt_auto_target(mob/user) var/atom/target for(var/atom/A in view_or_range(range, user, selection_type)) @@ -465,7 +470,8 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) /obj/effect/proc_holder/spell/targeted/click/InterceptClickOn(mob/living/user, params, atom/A) if(..() || !cast_check(TRUE, TRUE, user)) remove_ranged_ability(user) - revert_cast(user) + if (!is_casting) + revert_cast(user) return TRUE var/list/targets = list()