We love signals in this household

This commit is contained in:
DGamerL
2024-07-06 02:37:55 +02:00
parent 220152ac02
commit 75fe8d46a3
2 changed files with 17 additions and 10 deletions
@@ -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."
+1 -10
View File
@@ -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, "<span class='warning'>[I] has already been refined before. It cannot be sharpened further!</span>")
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, "<span class='warning'>[E] is much too powerful to sharpen further!</span>")
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