From d2f21ef06b86995646cd0745aea37d9e85b810b7 Mon Sep 17 00:00:00 2001 From: X0-11 Date: Fri, 2 Feb 2024 01:59:08 +0000 Subject: [PATCH 1/3] code fix --- code/_onclick/item_attack.dm | 2 +- code/modules/halo/misc/melee_strikes.dm | 35 +++++++++++-------------- code/modules/halo/weapons/_lunging.dm | 2 +- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 97845c710a998..f1dfebcc8a58f 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -26,7 +26,7 @@ avoid code duplication. This includes items that may sometimes act as a standard //I would prefer to rename this to attack(), but that would involve touching hundreds of files. /obj/item/proc/resolve_attackby(atom/A, mob/user, var/click_params) add_fingerprint(user) - if(has_melee_strike(user)) + if(has_melee_strike(user,1)) return melee_strike.do_pre_strike(user,A,src,click_params) return A.attackby(src, user, click_params) diff --git a/code/modules/halo/misc/melee_strikes.dm b/code/modules/halo/misc/melee_strikes.dm index d460629a6e614..b3d8bde574027 100644 --- a/code/modules/halo/misc/melee_strikes.dm +++ b/code/modules/halo/misc/melee_strikes.dm @@ -31,29 +31,38 @@ /obj/item/New() if(melee_strikes) + verbs += /obj/item/proc/verb_swap_stances + melee_strikes += null //Purposefully added, so the stance-switch system can allow you to switch to no-stance for lunges and such. for(var/type in melee_strikes) if(isnull(type)) continue var/strike = new type melee_strikes -= type melee_strikes += strike - melee_strikes += null //Purposefully added, so the stance-switch system can allow you to switch to no-stance for lunges and such. . = ..() -/obj/item/proc/has_melee_strike(var/mob/user) +/obj/item/proc/has_melee_strike(var/mob/user,var/active_only = 0) if(isnull(melee_strikes)) - return null + return 0 + if(ishuman(user)) + var/mob/living/carbon/human/h = user + if(src in list(h.l_hand,h.r_hand) && has_melee_strike(user)) + verbs += /obj/item/proc/verb_swap_stances + else + verbs -= /obj/item/proc/verb_swap_stances if(isnull(melee_strike)) melee_strike = melee_strikes[1] if(!isnull(melee_strike)) melee_strike.strike_active(user) + else if (active_only) //If the caller only wants a true result if we have an *active* melee strike, + return 0 //stop here (because we don't, and can't acquire one in the first step) - return melee_strike + return 1 /obj/item/proc/verb_swap_stances() set name = "Swap Stances" set category = "Object" - var/mob/living/carbon/human/user = usr + var/mob/living/user = usr if(!istype(user)) return if(user.stat) return @@ -73,20 +82,6 @@ return stance_curr.strike_active(user) -/obj/item/equipped(var/mob/living/carbon/human/user) - . = ..() - if(src in list(user.l_hand,user.r_hand) && has_melee_strike(user)) - verbs |= /obj/item/proc/verb_swap_stances - else - verbs -= /obj/item/proc/verb_swap_stances - -/obj/item/dropped(mob/user as mob) - . = ..() - if(src in list(user.l_hand,user.r_hand) && has_melee_strike(user)) - verbs |= /obj/item/proc/verb_swap_stances - else - verbs -= /obj/item/proc/verb_swap_stances - //Most elements of melee strikes should do nothing extra if set to null. /datum/melee_strike var/list/strike_verbs = null //Replacement attack verbs. @@ -101,7 +96,7 @@ //These set a max timeframe on chaining, otherwise it reverts back to a base strike type. var/chain_timeframe = 2 SECONDS var/chain_expire_at = 0 - var/chain_base_strike = null //Typepath. + var/chain_base_strike = null //Typepath.to reset a chain back to. /datum/melee_strike/proc/strike_active(var/mob/user) if(strike_switch_text) //Combos may want to keep this quiet. diff --git a/code/modules/halo/weapons/_lunging.dm b/code/modules/halo/weapons/_lunging.dm index a995754655a49..9c80d0d3da92c 100644 --- a/code/modules/halo/weapons/_lunging.dm +++ b/code/modules/halo/weapons/_lunging.dm @@ -62,7 +62,7 @@ /obj/item/afterattack(var/atom/target,var/mob/user,var/is_adjacent,var/click_params) . = ..() - if(has_melee_strike() && (is_adjacent || (melee_strike.strike_range >= get_dist( get_turf(user),target)))) + if(has_melee_strike(user,1) && (is_adjacent || (melee_strike.strike_range >= get_dist( get_turf(user),target)))) melee_strike.do_pre_strike(user,target,src,click_params) else do_lunge(target,user,is_adjacent,click_params) \ No newline at end of file From 3928d59db86533ee57d60b46db623a97e4822105 Mon Sep 17 00:00:00 2001 From: X0-11 Date: Fri, 2 Feb 2024 02:11:37 +0000 Subject: [PATCH 2/3] update --- code/modules/halo/misc/melee_strikes.dm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/code/modules/halo/misc/melee_strikes.dm b/code/modules/halo/misc/melee_strikes.dm index b3d8bde574027..5d1330dae53f4 100644 --- a/code/modules/halo/misc/melee_strikes.dm +++ b/code/modules/halo/misc/melee_strikes.dm @@ -41,8 +41,8 @@ melee_strikes += strike . = ..() -/obj/item/proc/has_melee_strike(var/mob/user,var/active_only = 0) - if(isnull(melee_strikes)) +/obj/item/proc/has_melee_strike(var/mob/user,var/skip_firststrike_set) + if(!melee_strikes || melee_strikes.len == 0) return 0 if(ishuman(user)) var/mob/living/carbon/human/h = user @@ -54,8 +54,6 @@ melee_strike = melee_strikes[1] if(!isnull(melee_strike)) melee_strike.strike_active(user) - else if (active_only) //If the caller only wants a true result if we have an *active* melee strike, - return 0 //stop here (because we don't, and can't acquire one in the first step) return 1 @@ -79,8 +77,8 @@ melee_strike = stance_curr if(stance_curr == null) to_chat(user,"You return to your normal weapon stance.") - return - stance_curr.strike_active(user) + else + stance_curr.strike_active(user) //Most elements of melee strikes should do nothing extra if set to null. /datum/melee_strike From f30f4d8e5b222930c35915f25888a15dd8604977 Mon Sep 17 00:00:00 2001 From: X0-11 Date: Fri, 2 Feb 2024 02:19:56 +0000 Subject: [PATCH 3/3] why was i using that proc for this --- code/_onclick/item_attack.dm | 2 +- code/modules/halo/misc/melee_strikes.dm | 7 +++++-- code/modules/halo/weapons/_lunging.dm | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index f1dfebcc8a58f..c6f70a8f36571 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -26,7 +26,7 @@ avoid code duplication. This includes items that may sometimes act as a standard //I would prefer to rename this to attack(), but that would involve touching hundreds of files. /obj/item/proc/resolve_attackby(atom/A, mob/user, var/click_params) add_fingerprint(user) - if(has_melee_strike(user,1)) + if(has_melee_strike_active()) return melee_strike.do_pre_strike(user,A,src,click_params) return A.attackby(src, user, click_params) diff --git a/code/modules/halo/misc/melee_strikes.dm b/code/modules/halo/misc/melee_strikes.dm index 5d1330dae53f4..dbb969930c299 100644 --- a/code/modules/halo/misc/melee_strikes.dm +++ b/code/modules/halo/misc/melee_strikes.dm @@ -41,13 +41,16 @@ melee_strikes += strike . = ..() -/obj/item/proc/has_melee_strike(var/mob/user,var/skip_firststrike_set) +/obj/item/proc/has_melee_strike_active() + return melee_strike + +/obj/item/proc/has_melee_strike(var/mob/user) if(!melee_strikes || melee_strikes.len == 0) return 0 if(ishuman(user)) var/mob/living/carbon/human/h = user if(src in list(h.l_hand,h.r_hand) && has_melee_strike(user)) - verbs += /obj/item/proc/verb_swap_stances + verbs |= /obj/item/proc/verb_swap_stances else verbs -= /obj/item/proc/verb_swap_stances if(isnull(melee_strike)) diff --git a/code/modules/halo/weapons/_lunging.dm b/code/modules/halo/weapons/_lunging.dm index 9c80d0d3da92c..91682477e2214 100644 --- a/code/modules/halo/weapons/_lunging.dm +++ b/code/modules/halo/weapons/_lunging.dm @@ -62,7 +62,7 @@ /obj/item/afterattack(var/atom/target,var/mob/user,var/is_adjacent,var/click_params) . = ..() - if(has_melee_strike(user,1) && (is_adjacent || (melee_strike.strike_range >= get_dist( get_turf(user),target)))) + if(has_melee_strike_active() && (is_adjacent || (melee_strike.strike_range >= get_dist( get_turf(user),target)))) melee_strike.do_pre_strike(user,target,src,click_params) else do_lunge(target,user,is_adjacent,click_params) \ No newline at end of file