mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 00:27:31 +01:00
11d82b7995
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. Improving old code. And I want to be able to pet mobroaches while holding them too. 🆑 qol: You can now interact with held mobs in more ways beside wearing them. /🆑
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
/*
|
|
* An element for making tools fragile, giving them a chance of
|
|
* "snapping into tiny pieces" after they've been used.
|
|
*/
|
|
|
|
/datum/element/easily_fragmented
|
|
element_flags = ELEMENT_BESPOKE
|
|
argument_hash_start_idx = 2
|
|
|
|
var/break_chance
|
|
|
|
/datum/element/easily_fragmented/Attach(datum/target, break_chance)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
src.break_chance = break_chance
|
|
|
|
RegisterSignal(target, COMSIG_ITEM_AFTERATTACK, PROC_REF(on_afterattack))
|
|
RegisterSignal(target, COMSIG_ITEM_TOOL_ACTED, PROC_REF(on_tool_use))
|
|
|
|
/datum/element/easily_fragmented/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, list(COMSIG_ITEM_AFTERATTACK, COMSIG_ITEM_TOOL_ACTED))
|
|
|
|
/datum/element/easily_fragmented/proc/on_afterattack(datum/source, atom/target, mob/user, list/modifiers)
|
|
SIGNAL_HANDLER
|
|
try_break(source, user)
|
|
|
|
/datum/element/easily_fragmented/proc/on_tool_use(datum/source, atom/target, mob/user, tool_type, result)
|
|
SIGNAL_HANDLER
|
|
try_break(source, user)
|
|
|
|
/datum/element/easily_fragmented/proc/try_break(obj/item/source, mob/user)
|
|
if(prob(break_chance))
|
|
user.visible_message(span_danger("[user]'s [source.name] snap[source.p_s()] into tiny pieces in [user.p_their()] hand."))
|
|
source.deconstruct(disassembled = FALSE)
|