diff --git a/citadel.dme b/citadel.dme index ddf1becd964..d075fe47f8d 100644 --- a/citadel.dme +++ b/citadel.dme @@ -792,8 +792,8 @@ #include "code\datums\browser\listpicker.dm" #include "code\datums\browser\preflikepicker.dm" #include "code\datums\combo\combo.dm" -#include "code\datums\combo\combo_holder.dm" #include "code\datums\combo\combo_set.dm" +#include "code\datums\combo\combo_tracker.dm" #include "code\datums\components\_component.dm" #include "code\datums\components\anti_magic.dm" #include "code\datums\components\connect_loc_behalf.dm" @@ -1108,7 +1108,7 @@ #include "code\game\click\rig.dm" #include "code\game\click\telekinesis.dm" #include "code\game\click\melee\melee_combo.dm" -#include "code\game\click\melee\melee_combo_holder.dm" +#include "code\game\click\melee\melee_combo_tracker.dm" #include "code\game\click\melee\melee_combo_set.dm" #include "code\game\content\enigmas\unsorted\cursedform.dm" #include "code\game\content\enigmas\unsorted\deadringer.dm" diff --git a/code/datums/combo/combo_set.dm b/code/datums/combo/combo_set.dm index 2520fe01817..8073ea9a494 100644 --- a/code/datums/combo/combo_set.dm +++ b/code/datums/combo/combo_set.dm @@ -9,7 +9,7 @@ * * ## Hey! Listen! * - * * A design flaw in how /datum/combo_holder works means that combo sets and their internal combos **will** be hard referenced + * * A design flaw in how /datum/combo_tracker works means that combo sets and their internal combos **will** be hard referenced * and there's currently no way to inform holders to clear ref when we're being deleted. For now. * A component signal system will be added later. For now, until we need to start deleting these / runtime-generating, * please store combo sets in global variables. diff --git a/code/datums/combo/combo_holder.dm b/code/datums/combo/combo_tracker.dm similarity index 92% rename from code/datums/combo/combo_holder.dm rename to code/datums/combo/combo_tracker.dm index 9e5ddd64274..60ecab24d33 100644 --- a/code/datums/combo/combo_holder.dm +++ b/code/datums/combo/combo_tracker.dm @@ -6,7 +6,7 @@ * * todo: unit test this shit */ -/datum/combo_holder +/datum/combo_tracker /// current stored key sequence, first to last /// * this is not a lazy list var/list/stored = list() @@ -16,7 +16,7 @@ var/tmp/list/datum/combo/sec_possible var/tmp/sec_position -/datum/combo_holder/proc/reset() +/datum/combo_tracker/proc/reset() stored = list() sec_set = null sec_possible = null @@ -33,11 +33,11 @@ * * * a shorter combo will always mask a longer one if it is present at any point in the longer one */ -/datum/combo_holder/proc/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set) as /datum/combo +/datum/combo_tracker/proc/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set) as /datum/combo stored += inbound return evaluate_via_tail_match(combo_set) -/datum/combo_holder/proc/evaluate_via_tail_match(datum/combo_set/combo_set) as /datum/combo +/datum/combo_tracker/proc/evaluate_via_tail_match(datum/combo_set/combo_set) as /datum/combo if(!stored) return var/datum/combo/found @@ -89,7 +89,7 @@ * * @return list(datum/combo/resolved, position, finished, list/datum/combo/possible) */ -/datum/combo_holder/proc/evaluate_inbound_via_stateful_exclusive_chain(inbound, datum/combo_set/combo_set) +/datum/combo_tracker/proc/evaluate_inbound_via_stateful_exclusive_chain(inbound, datum/combo_set/combo_set) // reset if we changed combos if(combo_set != sec_set) sec_set = combo_set diff --git a/code/game/click/item_attack.dm b/code/game/click/item_attack.dm index 54d106e7ddd..bb06fcd043e 100644 --- a/code/game/click/item_attack.dm +++ b/code/game/click/item_attack.dm @@ -49,7 +49,7 @@ avoid code duplication. This includes items that may sometimes act as a standard /mob/living/get_attack_speed_legacy(obj/item/using_item) var/speed = base_attack_cooldown if(istype(using_item)) - speed = using_item.melee_click_cd_cooldown * using_iwztem.melee_click_cd_multiply + speed = using_item.melee_click_cd_base * using_item.melee_click_cd_multiply for(var/datum/modifier/M in modifiers) if(!isnull(M.attack_speed_percent)) speed *= M.attack_speed_percent diff --git a/code/game/click/melee/melee_combo_holder.dm b/code/game/click/melee/melee_combo_holder.dm deleted file mode 100644 index 2cb8d7c87b9..00000000000 --- a/code/game/click/melee/melee_combo_holder.dm +++ /dev/null @@ -1,6 +0,0 @@ -//* This file is explicitly licensed under the MIT license. *// -//* Copyright (c) 2024 Citadel Station Developers *// - -/datum/combo_holder/melee - -/datum/combo_holder/melee/intent_based diff --git a/code/game/click/melee/melee_combo_tracker.dm b/code/game/click/melee/melee_combo_tracker.dm new file mode 100644 index 00000000000..0014c7bd810 --- /dev/null +++ b/code/game/click/melee/melee_combo_tracker.dm @@ -0,0 +1,36 @@ +//* This file is explicitly licensed under the MIT license. *// +//* Copyright (c) 2024 Citadel Station Developers *// + +/datum/combo_tracker/melee + /// if set, we automatically clear ourselves if nothing happens for this time + var/continuation_timeout = 3 SECONDS + var/tmp/continuation_timeout_active = FALSE + var/tmp/continuation_last + +/datum/combo_tracker/melee/New(continuation_timeout) + if(!isnull(continuation_timeout)) + src.continuation_timeout = continuation_timeout + +/datum/combo_tracker/melee/proc/keep_alive() + continuation_last = world.time + if(!continuation_timeout_active) + on_timeout() + +/datum/combo_tracker/melee/proc/on_timeout() + continuation_timeout_active = FALSE + var/remaining_time = continuation_last - (world.time - continuation_timeout) + if(remaining_time < 0) + reset() + return + addtimer(CALLBACK(src, PROC_REF(on_timeout)), remaining_time) + continuation_timeout_active = TRUE + +/datum/combo_tracker/melee/evaluate_inbound_via_tail_match(inbound, datum/combo_set/combo_set) + keep_alive() + return ..() + +/datum/combo_tracker/melee/evaluate_inbound_via_stateful_exclusive_match(inbound, datum/combo_set/combo_set) + keep_alive() + return ..() + +/datum/combo_tracker/melee/intent_based