Files
Bubberstation/code/datums/components/alternative_sharpness.dm
SmArtKar 7ddc30783a Adds better attack animations and alternate attack modes (#88418)
## About The Pull Request

This is the first PR in a series attempting to modernize our damage and
armor, both from a code and a gameplay perspective. This part implements
unique attack animations, adds alternate attack modes for items and
fixes some minor oversights.

Items now have unique attack animation based on their sharpness - sharp
items are now swung in an arc, while pointy items are thrust forward.
This change is ***purely visual***, this is not swing combat. (However,
this does assign icon rotation data to many items, which should help
swing combat later down the line).

Certain items like knives and swords now have secondary attacks - right
clicks will perform stabbing attacks instead of slashing for a chance to
leave piercing wounds, albeit with slightly lower damage - trying to
stick a katana through someone won't get you very far!

https://github.com/user-attachments/assets/1f92bbcd-9aa1-482f-bc26-5e84fe2a07e1

Turns out that spears acted as oversized knives this entire time, being
SHARP_EDGED instead of SHARP_POINTY - in order for their animations to
make sense, they're now once again pointy (according to comment,
originally they were made sharp because piercing wounds weren't very
threatening, which is no longer the case)

Another major change is that structure damage is now influenced by armor
penetration - I am not sure if this is intentional or not, but attacking
item's AP never applied to non-mob damage.

Additionally, also fixes an issue where attack verbs for you and
everyone else may differ.
2024-12-17 12:35:52 -06:00

61 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, params)
SIGNAL_HANDLER
if (alt_attacking || (required_trait && !HAS_TRAIT(source, required_trait)))
return
alt_attacking = TRUE
source.force += 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.force -= force_mod
weapon.attack_verb_continuous = base_continuous
weapon.attack_verb_simple = base_simple
weapon.sharpness = base_sharpness