mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
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. /🆑
73 lines
2.8 KiB
Plaintext
73 lines
2.8 KiB
Plaintext
/**
|
|
* ### Soul Stealer component!
|
|
*
|
|
* Component that attaches to items, making lethal swings with them steal the victims soul, storing it inside the item.
|
|
* Used in the cult bastard sword!
|
|
*/
|
|
/datum/component/soul_stealer
|
|
var/obj/item/soulstone/soulstone_type
|
|
/// List of soulstones captured by this item.
|
|
var/list/obj/item/soulstone/soulstones = list()
|
|
|
|
/datum/component/soul_stealer/Initialize(soulstone_type = /obj/item/soulstone/anybody/purified)
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.soulstone_type = soulstone_type
|
|
|
|
/datum/component/soul_stealer/Destroy()
|
|
QDEL_LIST(soulstones) // We own these, so we'll also just get rid of them. Any souls inside will die, this is fine.
|
|
return ..()
|
|
|
|
/datum/component/soul_stealer/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
|
|
RegisterSignal(parent, COMSIG_ITEM_AFTERATTACK, PROC_REF(on_afterattack))
|
|
RegisterSignal(parent, COMSIG_ITEM_INTERACTING_WITH_ATOM, PROC_REF(try_transfer_soul))
|
|
|
|
/datum/component/soul_stealer/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ATOM_EXAMINE, COMSIG_ITEM_AFTERATTACK, COMSIG_ITEM_INTERACTING_WITH_ATOM))
|
|
|
|
///signal called on parent being examined
|
|
/datum/component/soul_stealer/proc/on_examine(datum/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
|
|
examine_list += span_notice("It will steal the soul of anyone it defeats in battle.")
|
|
|
|
var/num_souls = length(soulstones)
|
|
switch(num_souls)
|
|
if(0)
|
|
examine_list += span_notice("It has not consumed any souls yet.")
|
|
if(1 to 9)
|
|
examine_list += span_notice("There are <b>[num_souls]</b> souls trapped within it.")
|
|
if(10 to INFINITY)
|
|
examine_list += span_notice("A staggering <b>[num_souls]</b> souls have been claimed by it! And it hungers for more!")
|
|
|
|
/datum/component/soul_stealer/proc/on_afterattack(obj/item/source, atom/target, mob/living/user, list/modifiers)
|
|
SIGNAL_HANDLER
|
|
|
|
if(ishuman(target))
|
|
INVOKE_ASYNC(src, PROC_REF(try_capture), target, user)
|
|
|
|
/datum/component/soul_stealer/proc/try_transfer_soul(obj/item/source, mob/user, atom/target, list/modifiers)
|
|
SIGNAL_HANDLER
|
|
|
|
if(istype(target, /obj/structure/constructshell) && length(soulstones))
|
|
var/obj/item/soulstone/soulstone = soulstones[1]
|
|
INVOKE_ASYNC(soulstone, TYPE_PROC_REF(/obj/item/soulstone, transfer_to_construct), target, user)
|
|
if(QDELETED(soulstone)) // successful transfer (transfer deletes us)
|
|
soulstones -= soulstone
|
|
else if(!length(soulstone.contents)) // something fucky happened
|
|
qdel(soulstone)
|
|
soulstones -= soulstone
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/datum/component/soul_stealer/proc/try_capture(mob/living/carbon/human/victim, mob/living/captor)
|
|
if(victim.stat == CONSCIOUS)
|
|
return
|
|
var/obj/item/soulstone/soulstone = new soulstone_type(parent)
|
|
soulstone.attack(victim, captor)
|
|
if(!length(soulstone.contents)) // failed
|
|
qdel(soulstone)
|
|
return
|
|
soulstones += soulstone
|