From e7fbf37fca5acbd608fefe418159f42c216fff6d Mon Sep 17 00:00:00 2001 From: nemvar <47324920+nemvar@users.noreply.github.com> Date: Sat, 3 Aug 2019 04:51:25 +0200 Subject: [PATCH] Turns gloves of the north star functionality into a component. (#45557) About The Pull Request title. Why It's Good For The Game The goal of this is to get rid of the Touch hook for gloves. Currently the only other thing that uses this proc is ninja gloves which I will try to remove at a later date. Changelog cl code: Gloves of the North Star functionality is now handled by a component. /cl --- code/datums/components/punchcooldown.dm | 29 +++++++++++++++++++ code/modules/clothing/gloves/miscellaneous.dm | 17 ++--------- tgstation.dme | 1 + 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 code/datums/components/punchcooldown.dm diff --git a/code/datums/components/punchcooldown.dm b/code/datums/components/punchcooldown.dm new file mode 100644 index 00000000000..d42a8fd00dc --- /dev/null +++ b/code/datums/components/punchcooldown.dm @@ -0,0 +1,29 @@ +///Your favourite Jojoke. Used for the gloves of the north star. +/datum/component/wearertargeting/punchcooldown + signals = list(COMSIG_HUMAN_MELEE_UNARMED_ATTACK) + mobtype = /mob/living/carbon + proctype = .proc/reducecooldown + valid_slots = list(SLOT_GLOVES) + ///The warcry this generates + var/warcry = "AT" + +/datum/component/wearertargeting/punchcooldown/Initialize() + . = ..() + if(. == COMPONENT_INCOMPATIBLE) + return + RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, .proc/changewarcry) + +///Called on COMSIG_HUMAN_MELEE_UNARMED_ATTACK. Yells the warcry and and reduces punch cooldown. +/datum/component/wearertargeting/punchcooldown/proc/reducecooldown(mob/living/carbon/M, atom/target) + if(M.a_intent == INTENT_HARM && isliving(target)) + M.changeNext_move(CLICK_CD_RAPID) + if(warcry) + M.say(warcry, ignore_spam = TRUE, forced = "north star warcry") + +///Called on COMSIG_ITEM_ATTACK_SELF. Allows you to change the warcry. +/datum/component/wearertargeting/punchcooldown/proc/changewarcry(datum/source, mob/user) + var/input = stripped_input(user,"What do you want your battlecry to be? Max length of 6 characters.", ,"", 7) + if(!QDELETED(src) && !QDELETED(user) && !user.Adjacent(parent)) + return + if(input) + warcry = input diff --git a/code/modules/clothing/gloves/miscellaneous.dm b/code/modules/clothing/gloves/miscellaneous.dm index d402fa65228..9930318f09d 100644 --- a/code/modules/clothing/gloves/miscellaneous.dm +++ b/code/modules/clothing/gloves/miscellaneous.dm @@ -62,18 +62,7 @@ icon_state = "rapid" item_state = "rapid" transfer_prints = TRUE - var/warcry = "AT" -/obj/item/clothing/gloves/rapid/Touch(mob/living/target,proximity = TRUE) - var/mob/living/M = loc - - if(M.a_intent == INTENT_HARM) - M.changeNext_move(CLICK_CD_RAPID) - if(warcry) - M.say("[warcry]", ignore_spam = TRUE, forced = "north star warcry") - .= FALSE - -/obj/item/clothing/gloves/rapid/attack_self(mob/user) - var/input = stripped_input(user,"What do you want your battlecry to be? Max length of 6 characters.", ,"", 7) - if(input) - warcry = input +/obj/item/clothing/gloves/rapid/ComponentInitialize() + . = ..() + AddComponent(/datum/component/wearertargeting/punchcooldown) diff --git a/tgstation.dme b/tgstation.dme index d92f94a7a9d..078f02c6dc7 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -382,6 +382,7 @@ #include "code\datums\components\orbiter.dm" #include "code\datums\components\paintable.dm" #include "code\datums\components\plumbing.dm" +#include "code\datums\components\punchcooldown.dm" #include "code\datums\components\rad_insulation.dm" #include "code\datums\components\radioactive.dm" #include "code\datums\components\remote_materials.dm"