mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-28 01:51:46 +00:00
## About The Pull Request - Afterattack is a very simple proc now: All it does is this, and all it's used for is for having a convenient place to put effects an item does after a successful attack (IE, the attack was not blocked)  - An overwhelming majority of afterattack implementations have been moved to `interact_with_atom` or the new `ranged_interact_with_atom` I have manually tested many of the refactored procs but there was 200+ so it's kinda hard ## Why It's Good For The Game Afterattack is one of the worst parts of the attack chain, as it simultaneously serves as a way of doing random interactions NOT AT ALL related to attacks (despite the name) while ALSO serving as the defacto way to do a ranged interaction with an item This means careless coders (most of them) may throw stuff in afterattack without realizing how wide reaching it is, which causes bugs. By making two well defined, separate procs for handing adjacent vs ranged interactions, it becomes WAY WAY WAY more easy to develop for. If you want to do something when you click on something else and you're adjacent, use `interact_with_atom` If you want to do something when you click on something else and you're not adjacent, use 'ranged_interact_with_atom` This does result in some instances of boilerplate as shown here:  But I think it's acceptable, feel free to oppose if you don't I'm sure we can think of another solution ~~Additionally it makes it easier to implement swing combat. That's a bonus I guess~~ ## Changelog 🆑 Melbert refactor: Over 200 item interactions have been refactored to use a newer, easier-to-use system. Report any oddities with using items on other objects you may see (such as surgery, reagent containers like cups and spray bottles, or construction devices), especially using something at range (such as guns or chisels) refactor: Item-On-Modsuit interactions have changed slightly. While on combat mode, you will attempt to "use" the item on the suit instead of inserting it into the suit's storage. This means being on combat mode while the suit's panel is open will block you from inserting items entirely via click (but other methods such as hotkey, clicking on the storage boxes, and mousedrop will still work). refactor: The detective's scanner will now be inserted into storage items if clicked normally, and will scan the storage item if on combat mode /🆑
115 lines
3.6 KiB
Plaintext
115 lines
3.6 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/service/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/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
|
|
sweep(user, interacting_with)
|
|
return NONE // I guess
|
|
|
|
/**
|
|
* 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/atom)
|
|
SIGNAL_HANDLER
|
|
|
|
do_sweep(src, user, atom, user.dir)
|
|
|
|
/**
|
|
* Sweep objects in the direction we're facing towards our direction
|
|
* Arguments
|
|
* * broomer - The object being used for brooming
|
|
* * user - The person who is brooming
|
|
* * target - The object or tile that's target of a broom click or being moved into
|
|
* * sweep_dir - The directions in which we sweep objects
|
|
*/
|
|
/proc/do_sweep(obj/broomer, mob/user, atom/target, sweep_dir)
|
|
var/turf/current_item_loc = isturf(target) ? target : target.loc
|
|
if (!isturf(current_item_loc))
|
|
return
|
|
var/turf/new_item_loc = get_step(current_item_loc, sweep_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, broomer, user, items_to_sweep)
|
|
|
|
if(!length(items_to_sweep))
|
|
return
|
|
|
|
for (var/obj/item/garbage in items_to_sweep)
|
|
garbage.Move(new_item_loc, sweep_dir)
|
|
|
|
playsound(current_item_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
|