mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-11 17:35:05 +00:00
## About The Pull Request Implements half of this (with some minor changes):  The ultimate goal of this is to split our attack chain in two: - One for non-combat item interactions - Health analyzer scanning - using tools on stuff - surgery - Niche other interactions - One for combat attacking - Item hit thing, item deal damage. - Special effects on attack would go here. This PR begins this by broadining tool act into item interact. Item interact is a catch-all proc ran at the beginning of attack chain, before `pre_attack` and such, that handles the first part of the chain. This allows us to easily catch item interaction and cancel the attack part of the chain by using deliberate bitflag return values, rather than `TRUE` / `FALSE`*. *Because right now, `TRUE` = `cancel attack`, no matter what, which is unclear to people. Instead of moving as much as possible to the new proc in this PR, I started by doing some easy, obvious things. More things can be moved in the future, or technically they don't even need to move in a lot of cases. ## Changelog 🆑 Melbert refactor: Refactored some methods of items interacting with other objects or mobs, such as surgery and health analzyers. Report if anything seems wrong /🆑
75 lines
2.8 KiB
Plaintext
75 lines
2.8 KiB
Plaintext
/**
|
|
* Adding this element to an atom will have it automatically render an overlay.
|
|
* The overlay can be specified in new as the first paramter; if not set it defaults to rust_overlay's rust_default
|
|
*/
|
|
/datum/element/rust
|
|
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH_ON_HOST_DESTROY // Detach for turfs
|
|
argument_hash_start_idx = 2
|
|
/// The rust image itself, since the icon and icon state are only used as an argument
|
|
var/image/rust_overlay
|
|
|
|
/datum/element/rust/Attach(atom/target, rust_icon = 'icons/effects/rust_overlay.dmi', rust_icon_state = "rust_default")
|
|
. = ..()
|
|
if(!isatom(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
if(!rust_overlay)
|
|
rust_overlay = image(rust_icon, rust_icon_state)
|
|
ADD_TRAIT(target, TRAIT_RUSTY, ELEMENT_TRAIT(type))
|
|
RegisterSignal(target, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(apply_rust_overlay))
|
|
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(handle_examine))
|
|
RegisterSignals(target, list(COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)), PROC_REF(secondary_tool_act))
|
|
// Unfortunately registering with parent sometimes doesn't cause an overlay update
|
|
target.update_appearance()
|
|
|
|
/datum/element/rust/Detach(atom/source)
|
|
. = ..()
|
|
UnregisterSignal(source, COMSIG_ATOM_UPDATE_OVERLAYS)
|
|
UnregisterSignal(source, COMSIG_ATOM_EXAMINE)
|
|
UnregisterSignal(source, list(COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_WELDER), COMSIG_ATOM_SECONDARY_TOOL_ACT(TOOL_RUSTSCRAPER)))
|
|
REMOVE_TRAIT(source, TRAIT_RUSTY, ELEMENT_TRAIT(type))
|
|
source.update_appearance()
|
|
|
|
/datum/element/rust/proc/handle_examine(datum/source, mob/user, list/examine_text)
|
|
SIGNAL_HANDLER
|
|
|
|
examine_text += span_notice("[source] is very rusty, you could probably <i>burn</i> or <i>scrape</i> it off.")
|
|
|
|
/datum/element/rust/proc/apply_rust_overlay(atom/parent_atom, list/overlays)
|
|
SIGNAL_HANDLER
|
|
|
|
if(rust_overlay)
|
|
overlays += rust_overlay
|
|
|
|
/// Because do_after sleeps we register the signal here and defer via an async call
|
|
/datum/element/rust/proc/secondary_tool_act(atom/source, mob/user, obj/item/item)
|
|
SIGNAL_HANDLER
|
|
|
|
INVOKE_ASYNC(src, PROC_REF(handle_tool_use), source, user, item)
|
|
return ITEM_INTERACT_BLOCKING
|
|
|
|
/// We call this from secondary_tool_act because we sleep with do_after
|
|
/datum/element/rust/proc/handle_tool_use(atom/source, mob/user, obj/item/item)
|
|
switch(item.tool_behaviour)
|
|
if(TOOL_WELDER)
|
|
if(!item.tool_start_check(user, amount=1))
|
|
return
|
|
|
|
user.balloon_alert(user, "burning off rust...")
|
|
|
|
if(!item.use_tool(source, user, 5 SECONDS))
|
|
return
|
|
user.balloon_alert(user, "burned off rust")
|
|
Detach(source)
|
|
return
|
|
|
|
|
|
if(TOOL_RUSTSCRAPER)
|
|
if(!item.tool_start_check(user))
|
|
return
|
|
user.balloon_alert(user, "scraping off rust...")
|
|
if(!item.use_tool(source, user, 2 SECONDS))
|
|
return
|
|
user.balloon_alert(user, "scraped off rust")
|
|
Detach(source)
|
|
return
|