From 2d468e9c2d40921fb89cf66079ba3dbc98a8fe1c Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 31 Jan 2023 14:54:11 +0100 Subject: [PATCH] [MIRROR] Implements functionality for variable weapon attack and secondary weapon attack speeds. [MDB IGNORE] (#19048) Implements functionality for variable weapon attack and secondary weapon attack speeds. (#72959) ## About The Pull Request The click cooldown after attacking with a weapon can now be controlled with a var. A var can also be set for secondary attack cooldown, if unset it is the same as the weapon's normal attack speed. The two weapons who already had hardcoded mechanics to achieve this effect (see: The Stinger, Hyper Frequency Blade) have been converted to this system. ## Why It's Good For The Game Future varying of weapon qualities and admin shenanigans. ## Changelog :cl: code: Greater support for variability in weapon attack speed admin: Admins are now able to grief you by hitting you with a toolbox 10 times in one second. /:cl: Co-authored-by: itseasytosee <55666666+itseasytosee@users.noreply.github.com> --- code/__DEFINES/combat.dm | 1 + code/_onclick/item_attack.dm | 9 ++++++--- code/game/objects/items.dm | 4 ++++ code/game/objects/items/melee/misc.dm | 2 +- code/game/objects/items/weaponry.dm | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/combat.dm b/code/__DEFINES/combat.dm index 75c5187528a..9791b05b158 100644 --- a/code/__DEFINES/combat.dm +++ b/code/__DEFINES/combat.dm @@ -86,6 +86,7 @@ #define CLICK_CD_THROW 8 #define CLICK_CD_RANGE 4 #define CLICK_CD_RAPID 2 +#define CLICK_CD_HYPER_RAPID 1 #define CLICK_CD_CLICK_ABILITY 6 #define CLICK_CD_BREAKOUT 100 #define CLICK_CD_HANDCUFFED 10 diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index be5c39ba9e9..d0db123981c 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -158,7 +158,7 @@ /mob/living/attackby(obj/item/attacking_item, mob/living/user, params) if(..()) return TRUE - user.changeNext_move(CLICK_CD_MELEE) + user.changeNext_move(attacking_item.attack_speed) return attacking_item.attack(src, user, params) /mob/living/attackby_secondary(obj/item/weapon, mob/living/user, params) @@ -166,7 +166,10 @@ // Normal attackby updates click cooldown, so we have to make up for it if (result != SECONDARY_ATTACK_CALL_NORMAL) - user.changeNext_move(CLICK_CD_MELEE) + if(weapon.secondary_attack_speed) + user.changeNext_move(weapon.secondary_attack_speed) + else + user.changeNext_move(weapon.attack_speed) return result @@ -229,7 +232,7 @@ return if(item_flags & NOBLUDGEON) return - user.changeNext_move(CLICK_CD_MELEE) + user.changeNext_move(attack_speed) user.do_attack_animation(attacked_atom) attacked_atom.attacked_by(src, user) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index b745b5f53cd..8443ebd0058 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -131,6 +131,10 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e var/armour_penetration = 0 ///Whether or not our object is easily hindered by the presence of armor var/weak_against_armour = FALSE + /// The click cooldown given after attacking. Lower numbers means faster attacks + var/attack_speed = CLICK_CD_MELEE + /// The click cooldown on secondary attacks. Lower numbers mean faster attacks. Will use attack_speed if undefined. + var/secondary_attack_speed ///In deciseconds, how long an item takes to equip; counts only for normal clothing slots, not pockets etc. var/equip_delay_self = 0 ///In deciseconds, how long an item takes to put on another person diff --git a/code/game/objects/items/melee/misc.dm b/code/game/objects/items/melee/misc.dm index c73eb2c6b84..51ecb2f4070 100644 --- a/code/game/objects/items/melee/misc.dm +++ b/code/game/objects/items/melee/misc.dm @@ -162,6 +162,7 @@ w_class = WEIGHT_CLASS_BULKY sharpness = SHARP_EDGED throwforce = 10 + attack_speed = CLICK_CD_RAPID block_chance = 20 armour_penetration = 65 attack_verb_continuous = list("slashes", "stings", "prickles", "pokes") @@ -172,7 +173,6 @@ . = ..() if(!proximity) return - user.changeNext_move(CLICK_CD_RAPID) if(iscarbon(target)) var/mob/living/carbon/carbon_target = target carbon_target.reagents.add_reagent(/datum/reagent/toxin, 4) diff --git a/code/game/objects/items/weaponry.dm b/code/game/objects/items/weaponry.dm index 7f55ea29de4..c3ee34603ef 100644 --- a/code/game/objects/items/weaponry.dm +++ b/code/game/objects/items/weaponry.dm @@ -980,6 +980,7 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301 bare_wound_bonus = 50 throwforce = 25 throw_speed = 4 + attack_speed = CLICK_CD_HYPER_RAPID embedding = list("embed_chance" = 100) block_chance = 25 sharpness = SHARP_EDGED @@ -1044,7 +1045,6 @@ for further reading, please see: https://github.com/tgstation/tgstation/pull/301 update_icon(UPDATE_ICON_STATE) /obj/item/highfrequencyblade/proc/slash(atom/target, mob/living/user, params) - user.changeNext_move(0.1 SECONDS) user.do_attack_animation(target, "nothing") var/list/modifiers = params2list(params) var/damage_mod = 1