mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-01 20:11:52 +00:00
## About The Pull Request People can now pet held mothroaches and pugs if they want to, or use items on them, hopefully without causing many issues. After all, it only took about a couple dozen lines of code to make... ...Oh, did the 527 files changed or the 850~ lines added/removed perhaps catch your eye? Made you wonder if I accidentally pushed the wrong branch? or skewed something up big time? Well, nuh uh. I just happen to be fed up with the melee attack chain still using stringized params instead of an array/list. It was frankly revolting to see how I'd have had to otherwise call `list2params` for what I'm trying to accomplish here, and make this PR another tessera to the immense stupidity of our attack chain procs calling `params2list` over and over and over instead of just using that one call instance from `ClickOn` as an argument. It's 2025, honey, wake up! I also tried to replace some of those single letter vars/args but there are just way too many of them. ## Why It's Good For The Game Improving old code. And I want to be able to pet mobroaches while holding them too. ## Changelog 🆑 qol: You can now interact with held mobs in more ways beside wearing them. /🆑
61 lines
2.3 KiB
Plaintext
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, list/modifiers)
|
|
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
|