Files
Bubberstation/code/game/objects/items/broom.dm
John Willard 333bef46fe Improves jousting and gives it to more weapons (#76321)
## About The Pull Request

I was reading over components and saw one called jousting, I vividly
remember it being mentioned every so often but I've never seen it
in-game. Turns out the SINGLE case for it is when you are using a spear
on a borg. The code itself was also very over the place, making it a
little confusing to figure out what it did.

I tried cleaning the file up as much as I could, and since I wanted to
see this in-game more often, I made some player-facing changes too:

- You can now joust from any vehicle, not just borgs (Secway, ATV,
scooter, Charger holoparasite)
- Added jousting to the broom, pitchfork, captain's sabre, and energy
sword while active (ONLY esword, NOT desword).
- Added examine text to indicate this feature exists.

Extra notes:
Esword gains half the damage increase and half the knockdown chance than
other ways of jousting
Broom only gets 25% damage increase from jousting, since the broom is
already pretty strong I thought it would be better off as something used
mostly to knockdown.
Spears have to travel a longer distance than other weapons to get their
jousting benefits (since it's supposed to be a ghetto weapon)
Jousting now takes the minimum distance needed into account when
handling knockdown chance & damage dealt, so travelling 5 tiles will no
longer be 100% chance of knockdown if you need a minimum distance of 3
tiles to joust (it will instead be 40%, since you've only traveled 2
tiles in 'jousting' mode).

## Why It's Good For The Game

This is an underused component and I thought it would bring some pretty
cool interactions, especially for Holoparasite & Janitors, as a new way
to use vehicles to your advantage when it's otherwise seen as just a
slowdown.

## Changelog

🆑
balance: Jousting now works on anything you're buckled to, not just
Cyborgs.
balance: Brooms, Pitchforks, the Captain's Sabre, and Energy swords can
now be used for jousting.
balance: Spears need to travel a longer distance to joust now.
balance: Jousting's knockdown and damage now only gets stronger after
you've traveled the minimum tiles needed to joust.
/🆑
2023-07-01 21:52:08 +00:00

108 lines
3.2 KiB
Plaintext

/// Max number of atoms a broom can sweep at once
#define BROOM_PUSH_LIMIT 20
/obj/item/pushbroom
name = "push broom"
desc = "This is my BROOMSTICK! It can be used manually or braced with two hands to sweep items as you move. It has a telescopic handle for compact storage."
icon = 'icons/obj/janitor.dmi'
icon_state = "broom0"
base_icon_state = "broom"
lefthand_file = 'icons/mob/inhands/equipment/custodial_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/custodial_righthand.dmi'
force = 8
throwforce = 10
throw_speed = 3
throw_range = 7
w_class = WEIGHT_CLASS_NORMAL
attack_verb_continuous = list("sweeps", "brushes off", "bludgeons", "whacks")
attack_verb_simple = list("sweep", "brush off", "bludgeon", "whack")
resistance_flags = FLAMMABLE
/obj/item/pushbroom/Initialize(mapload)
. = ..()
AddComponent(/datum/component/jousting, damage_boost_per_tile = 1)
AddComponent(/datum/component/two_handed, \
force_unwielded = 8, \
force_wielded = 12, \
icon_wielded = "[base_icon_state]1", \
wield_callback = CALLBACK(src, PROC_REF(on_wield)), \
unwield_callback = CALLBACK(src, PROC_REF(on_unwield)), \
)
/obj/item/pushbroom/update_icon_state()
icon_state = "[base_icon_state]0"
return ..()
/**
* Handles registering the sweep proc when the broom is wielded
*
* Arguments:
* * source - The source of the on_wield proc call
* * user - The user which is wielding the broom
*/
/obj/item/pushbroom/proc/on_wield(obj/item/source, mob/user)
to_chat(user, span_notice("You brace the [src] against the ground in a firm sweeping stance."))
RegisterSignal(user, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(sweep))
/**
* Handles unregistering the sweep proc when the broom is unwielded
*
* Arguments:
* * source - The source of the on_unwield proc call
* * user - The user which is unwielding the broom
*/
/obj/item/pushbroom/proc/on_unwield(obj/item/source, mob/user)
UnregisterSignal(user, COMSIG_MOVABLE_PRE_MOVE)
/obj/item/pushbroom/afterattack(atom/A, mob/user, proximity)
. = ..()
if(!proximity)
return
sweep(user, A)
return . | AFTERATTACK_PROCESSED_ITEM
/**
* Attempts to push up to BROOM_PUSH_LIMIT atoms from a given location the user's faced direction
*
* Arguments:
* * user - The user of the pushbroom
* * A - The atom which is located at the location to push atoms from
*/
/obj/item/pushbroom/proc/sweep(mob/user, atom/A)
SIGNAL_HANDLER
var/turf/current_item_loc = isturf(A) ? A : A.loc
if (!isturf(current_item_loc))
return
var/turf/new_item_loc = get_step(current_item_loc, user.dir)
var/list/items_to_sweep = list()
var/i = 1
for (var/obj/item/garbage in current_item_loc.contents)
if(garbage.anchored)
continue
items_to_sweep += garbage
i++
if(i > BROOM_PUSH_LIMIT)
break
SEND_SIGNAL(new_item_loc, COMSIG_TURF_RECEIVE_SWEEPED_ITEMS, src, user, items_to_sweep)
if(!length(items_to_sweep))
return
for (var/obj/item/garbage in items_to_sweep)
garbage.Move(new_item_loc, user.dir)
playsound(loc, 'sound/weapons/thudswoosh.ogg', 30, TRUE, -1)
/obj/item/pushbroom/cyborg
name = "cyborg push broom"
/obj/item/pushbroom/cyborg/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_NODROP, CYBORG_ITEM_TRAIT)
#undef BROOM_PUSH_LIMIT