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 1/5] 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()
From 97f56a1c65e0e1836b8314748ed763ff235d633b Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Tue, 30 Mar 2021 16:06:49 -0400
Subject: [PATCH 2/5] bugfixing my code
---
code/datums/spell.dm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/datums/spell.dm b/code/datums/spell.dm
index 34efb2e14fa..85dd4ee4d72 100644
--- a/code/datums/spell.dm
+++ b/code/datums/spell.dm
@@ -148,7 +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)
+ addtimer(CALLBACK(src, .proc/cast_cooldown), 1 SECONDS)
switch(charge_type)
if("recharge")
charge_counter = 0 //doesn't start recharging until the targets selecting ends
@@ -450,7 +450,7 @@ 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
+/obj/effect/proc_holder/spell/proc/cast_cooldown()
is_casting = FALSE
/obj/effect/proc_holder/spell/targeted/click/proc/attempt_auto_target(mob/user)
From e37825f99af99fda5d227958b217f3fdc5dace70 Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Tue, 30 Mar 2021 16:08:19 -0400
Subject: [PATCH 3/5] Update code/datums/spell.dm
Co-authored-by: SteelSlayer <42044220+SteelSlayer@users.noreply.github.com>
---
code/datums/spell.dm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/datums/spell.dm b/code/datums/spell.dm
index 85dd4ee4d72..c42ba602773 100644
--- a/code/datums/spell.dm
+++ b/code/datums/spell.dm
@@ -470,7 +470,7 @@ 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)
- if (!is_casting)
+ if(!is_casting)
revert_cast(user)
return TRUE
From a94c650021b64779a5c855a146819343aa3d2535 Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Tue, 30 Mar 2021 16:13:27 -0400
Subject: [PATCH 4/5] actually makes this fix work as intented
---
code/datums/spell.dm | 1 +
1 file changed, 1 insertion(+)
diff --git a/code/datums/spell.dm b/code/datums/spell.dm
index 85dd4ee4d72..0363836cfe3 100644
--- a/code/datums/spell.dm
+++ b/code/datums/spell.dm
@@ -149,6 +149,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell))
if(start_recharge)
addtimer(CALLBACK(src, .proc/cast_cooldown), 1 SECONDS)
+ is_casting = TRUE
switch(charge_type)
if("recharge")
charge_counter = 0 //doesn't start recharging until the targets selecting ends
From b6f334f92fe0090d96123c412ee16663784807e8 Mon Sep 17 00:00:00 2001
From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
Date: Sun, 4 Jul 2021 23:44:44 -0400
Subject: [PATCH 5/5] applys correct fix
---
code/datums/spell.dm | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/code/datums/spell.dm b/code/datums/spell.dm
index 31d88d397bb..6590876ea2f 100644
--- a/code/datums/spell.dm
+++ b/code/datums/spell.dm
@@ -108,7 +108,6 @@ 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'
@@ -148,8 +147,6 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell))
return 0
if(start_recharge)
- addtimer(CALLBACK(src, .proc/cast_cooldown), 1 SECONDS)
- is_casting = TRUE
switch(charge_type)
if("recharge")
charge_counter = 0 //doesn't start recharging until the targets selecting ends
@@ -451,9 +448,6 @@ 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))
@@ -471,8 +465,7 @@ 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)
- if(!is_casting)
- revert_cast(user)
+ revert_cast(user)
return TRUE
var/list/targets = list()
@@ -510,8 +503,8 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell))
revert_cast(user)
return FALSE
- perform(targets, user = user, make_attack_logs = create_logs)
remove_ranged_ability(user)
+ perform(targets, user = user, make_attack_logs = create_logs)
return TRUE
/* Checks if a target is valid