mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
## About The Pull Request <img width="911" height="517" alt="image" src="https://github.com/user-attachments/assets/631d5254-95a4-42d5-ae07-f58a815a1976" /> Adds the surplus energy sword. This is found in the black market with a reasonable probability of being stocked but at a pretty high cost. The weapon otherwise functions as an energy sword, but with a significantly lower amount of damage if you're not hitting someone who is in a compromised position; such as being prone, staggered, attacked from behind or incapacitated (like stuns). After 20 hits, you need to recharge the sword by clicking it with the right mouse button. After an interaction timer, the weapon recharges to full. You can do this early if you'd like. Energy swords default to WEIGHT_CLASS_HUGE while active. ## Why It's Good For The Game I've seen a few folk complain about a lack of particularly interesting and potent melee weapons that might be floating around to find and acquire. It'd also be somewhat funny for an actual traitor to have to get through a pack of goons wielding shitty knockoffs of their own energy sword. This was actually my first ever idea for a PR back when I was first starting the game but had absolutely no idea as to how to code or anything. I was hardstuck on this for a long ass time. Now I guess I'm doing it because I was reminded abotu that fact. ## Changelog 🆑 add: Adds the surplus energy sword; the mall katana of the future. It cuts like shit, but if you're desperate enough, you could kill someone with it. Just remember to keep it charged. balance: Energy swords are huge objects while activated. /🆑 --------- Co-authored-by: ATH1909 <42606352+ATH1909@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
86 lines
3.3 KiB
Plaintext
86 lines
3.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
|
|
/// Hitsound that overrides our current hitsound if defined.
|
|
var/alt_hitsound = null
|
|
// Old values before we overrode them
|
|
var/base_continuous = null
|
|
var/base_simple = null
|
|
var/base_sharpness = NONE
|
|
var/base_hitsound = null
|
|
|
|
/datum/component/alternative_sharpness/Initialize(alt_sharpness, verbs_continuous = null, verbs_simple = null, force_mod = 0, required_trait = null, alt_hitsound = 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
|
|
src.alt_hitsound = alt_hitsound
|
|
base_continuous = weapon.attack_verb_continuous
|
|
base_simple = weapon.attack_verb_simple
|
|
base_hitsound = weapon.hitsound
|
|
|
|
/datum/component/alternative_sharpness/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_PRE_ATTACK_SECONDARY, PROC_REF(on_secondary_attack))
|
|
RegisterSignal(parent, COMSIG_TRANSFORMING_ON_TRANSFORM, PROC_REF(on_transform))
|
|
|
|
/datum/component/alternative_sharpness/UnregisterFromParent()
|
|
. = ..()
|
|
UnregisterSignal(parent, list(
|
|
COMSIG_ITEM_PRE_ATTACK_SECONDARY,
|
|
COMSIG_TRANSFORMING_ON_TRANSFORM,
|
|
))
|
|
|
|
/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
|
|
|
|
if(!isnull(alt_hitsound))
|
|
source.hitsound = alt_hitsound
|
|
|
|
// 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
|
|
weapon.hitsound = base_hitsound
|
|
|
|
// If our weapon is transforming, we listen for the transformation to adjust our base_hitsound as needed so we're not caught out by the callback adding inappropriate values.
|
|
/datum/component/alternative_sharpness/proc/on_transform(obj/item/source, mob/user, active)
|
|
SIGNAL_HANDLER
|
|
|
|
base_continuous = source.attack_verb_continuous
|
|
base_simple = source.attack_verb_simple
|
|
base_sharpness = source.sharpness
|
|
base_hitsound = source.hitsound
|