mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
Melee attack chain now has a list passed along with it, `attack_modifiers`, which you can stick force modifiers to change the resulting attack This is basically a soft implementation of damage packets until a more definitive pr, but one that only applies to item attack chain, and not unarmed attacks. This change was done to facilitate a baton refactor - batons no longer hack together their own attack chain, and are now integrated straight into the real attack chain. This refactor itself was done because batons don't send any attack signals, which has been annoying in the past (for swing combat). 🆑 Melbert refactor: Batons have been refactored again. Baton stuns now properly count as an attack, when before it was a nothing. Report any oddities, particularly in regards to harmbatonning vs normal batonning. refactor: The method of adjusting item damage mid-attack has been refactored - some affected items include the Nullblade and knives. Report any strange happenings with damage numbers. refactor: A few objects have been moved to the new interaction chain - records consoles, mawed crucible, alien weeds and space vines, hedges, restaurant portals, and some mobs - to name a few. fix: Spears only deal bonus damage against secure lockers, not all closet types (including crates) /🆑
60 lines
2.3 KiB
Plaintext
60 lines
2.3 KiB
Plaintext
/// Allows items to have different sharpness for right click attacks
|
|
/datum/component/alternative_sharpness
|
|
/// Sharpness we change the attack to
|
|
var/alt_sharpness = NONE
|
|
/// Overrides for continuous attack verbs when performing an alt attack
|
|
var/verbs_continuous = null
|
|
/// Overrides for simple attack verbs when performing an alt attack
|
|
var/verbs_simple = null
|
|
/// Value by which we offset our force during the attack
|
|
var/force_mod = 0
|
|
/// Are we currently performing an alt attack?
|
|
var/alt_attacking = FALSE
|
|
/// Trait required for us to trigger
|
|
var/required_trait = null
|
|
// Old values before we overrode them
|
|
var/base_continuous = null
|
|
var/base_simple = null
|
|
var/base_sharpness = NONE
|
|
|
|
/datum/component/alternative_sharpness/Initialize(alt_sharpness, verbs_continuous = null, verbs_simple = null, force_mod = 0, required_trait = null)
|
|
if (!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/obj/item/weapon = parent
|
|
src.alt_sharpness = alt_sharpness
|
|
src.verbs_continuous = verbs_continuous
|
|
src.verbs_simple = verbs_simple
|
|
src.force_mod = force_mod
|
|
src.required_trait = required_trait
|
|
base_continuous = weapon.attack_verb_continuous
|
|
base_simple = weapon.attack_verb_simple
|
|
|
|
/datum/component/alternative_sharpness/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_PRE_ATTACK_SECONDARY, PROC_REF(on_secondary_attack))
|
|
|
|
/datum/component/alternative_sharpness/proc/on_secondary_attack(obj/item/source, atom/target, mob/user, list/modifiers, list/attack_modifiers)
|
|
SIGNAL_HANDLER
|
|
|
|
if (alt_attacking || (required_trait && !HAS_TRAIT(source, required_trait)))
|
|
return
|
|
|
|
alt_attacking = TRUE
|
|
MODIFY_ATTACK_FORCE(attack_modifiers, force_mod)
|
|
base_sharpness = source.sharpness
|
|
source.sharpness = alt_sharpness
|
|
if (!isnull(verbs_continuous))
|
|
source.attack_verb_continuous = verbs_continuous
|
|
|
|
if (!isnull(verbs_simple))
|
|
source.attack_verb_simple = verbs_simple
|
|
|
|
// I absolutely despise this but this is geniunely the best way to do this without creating and hooking up to a dozen signals and still risking failure edge cases
|
|
addtimer(CALLBACK(src, PROC_REF(disable_alt_attack)), 1)
|
|
|
|
/datum/component/alternative_sharpness/proc/disable_alt_attack()
|
|
var/obj/item/weapon = parent
|
|
alt_attacking = FALSE
|
|
weapon.attack_verb_continuous = base_continuous
|
|
weapon.attack_verb_simple = base_simple
|
|
weapon.sharpness = base_sharpness
|