From 75fe8d46a3ad0ee50b53bfb6394fb110e191319b Mon Sep 17 00:00:00 2001 From: DGamerL Date: Sat, 6 Jul 2024 02:37:55 +0200 Subject: [PATCH] We love signals in this household --- .../items/weapons/melee/energy_melee_weapons.dm | 16 ++++++++++++++++ code/game/objects/items/weapons/whetstone.dm | 11 +---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/code/game/objects/items/weapons/melee/energy_melee_weapons.dm b/code/game/objects/items/weapons/melee/energy_melee_weapons.dm index e047ea965b6..17e8f399314 100644 --- a/code/game/objects/items/weapons/melee/energy_melee_weapons.dm +++ b/code/game/objects/items/weapons/melee/energy_melee_weapons.dm @@ -26,6 +26,11 @@ . = ..() force_off = initial(force) //We want to check this only when initializing, not when swapping, so sharpening works. throwforce_off = initial(throwforce) + RegisterSignal(src, COMSIG_ITEM_SHARPEN_ACT, PROC_REF(try_sharpen)) + +/obj/item/melee/energy/Destroy() + . = ..() + UnregisterSignal(src, COMSIG_ITEM_SHARPEN_ACT) /obj/item/melee/energy/attack(mob/living/target, mob/living/carbon/human/user) var/nemesis_faction = FALSE @@ -88,6 +93,17 @@ /obj/item/melee/energy/get_heat() return active * 3500 +/obj/item/melee/energy/proc/try_sharpen(obj/item/item, amount, max_amount) + if(force_on > initial(force_on) || force_on > max_amount) + return COMPONENT_BLOCK_SHARPEN_MAXED + throwforce_on = clamp(throwforce_on + amount, 0, max_amount) + throwforce_off = clamp(throwforce_off + amount, 0, max_amount) + force_on = clamp(force_on + amount, 0, max_amount) + force_off = clamp(force_off + amount, 0, max_amount) + if(active) + force += amount + return COMPONENT_SHARPEN_APPLIED + /obj/item/melee/energy/axe name = "energy axe" desc = "An energised battle axe." diff --git a/code/game/objects/items/weapons/whetstone.dm b/code/game/objects/items/weapons/whetstone.dm index c4b7f7a6e5b..7c21ddda9c8 100644 --- a/code/game/objects/items/weapons/whetstone.dm +++ b/code/game/objects/items/weapons/whetstone.dm @@ -31,15 +31,6 @@ if((signal_out & COMPONENT_BLOCK_SHARPEN_ALREADY) || (I.force > initial(I.force) && !(signal_out & COMPONENT_SHARPEN_APPLIED))) //No sharpening stuff twice to_chat(user, "[I] has already been refined before. It cannot be sharpened further!") return - if(istype(I, /obj/item/melee/energy)) - var/obj/item/melee/energy/E = I - if(E.force_on > initial(E.force_on)) - to_chat(user, "[E] is much too powerful to sharpen further!") - return - E.throwforce_on = clamp(E.throwforce_on + increment, 0, max) - E.throwforce_off = clamp(E.throwforce_off + increment, 0, max) - E.force_on = clamp(E.force_on + increment, 0, max) - E.force_off = clamp(E.force_off + increment, 0, max) if(!(signal_out & COMPONENT_SHARPEN_APPLIED)) //If the item has a relevant component and COMPONENT_BLOCK_SHARPEN_APPLIED is returned, the item only gets the throw force increase I.force = clamp(I.force + increment, 0, max) @@ -49,7 +40,7 @@ set_sharpness(TRUE) I.throwforce = clamp(I.throwforce + increment, 0, max) I.name = "[prefix] [I.name]" - playsound(get_turf(src), usesound, 50, 1) + playsound(get_turf(src), usesound, 50, TRUE) name = "worn out [name]" desc = "[desc] At least, it used to." used = TRUE