Files
Bubberstation/code/datums/components/spill.dm
MrMelbert acb96fee1d Refactors memories to be less painful to add and apply, moves memory detail / text to memory subtypes. Adds some new memories to demonstrate. (#72110)
## About The Pull Request

So, a huge issue with memories and - what I personally believe is the
reason why not many have been added since their inception is - they're
very annoying to add!

Normally, adding subtypes of stuff like traumas or hallucinations are as
easy as doing just that, adding a subtype.

But memories used this factory argument passing method combined with
holding all their strings in a JSON file which made it just frustrating
to add, debug, or just mess with.

It also made it much harder to organize new memories keep it clean for
stuff like downstreams.

So I refactored it. Memories are now handled on a subtype by subtype
basis, instead of all memories being a `/datum/memory`.

Any variety of arguments can be passed into memories like addcomponent
(KWARGS) so each subtype can have their own `new` parameters.

This makes it much much easier to add a new memory. All you need to do
is make your subtype and add it somewhere. Don't need to mess with jsons
or defines or anything.

To demonstrate this, I added a few memories. Some existing memories had
their story values tweak to compensate.

## Why It's Good For The Game

Makes it way simpler to add new memories. Maybe we'll get some more fun
ones now?

## Changelog

🆑 Melbert
add: Roundstart captains will now memorize the code to the spare ID
safe.
add: Traitors will now memorize the location and code to their uplink.
add: Heads of staff winning a revolution will now get a memory of their
success.
add: Heads of staff and head revolutionaries who lose their respective
sides of the revolution also get a memory of their failure.
add: Completing a ritual of knowledge as a heretic grants you a quality
memory.
add: Successfully defusing a bomb now grants you a cool memory. Failing
it will also grant you a memory, though you will likely not be alive to
see it.
add: Planting bombs now increase their memory quality depending on how
cool the bomb is.
refactor: Memories have been refactored to be much easier to add.
/🆑
2023-01-03 11:23:31 -08:00

72 lines
2.1 KiB
Plaintext

// This component is for forcing strange things into your pocket that fall out if you fall down
// Yes this exists purely for the spaghetti meme
/datum/component/spill
can_transfer = TRUE
var/preexisting_slot_flags
var/list/droptext
var/list/dropsound
var/drop_memory
// droptext is an arglist for visible_message
// dropsound is a list of potential sounds that gets picked from
/datum/component/spill/Initialize(list/_droptext, list/_dropsound, _drop_memory)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
if(_droptext && !islist(_droptext))
_droptext = list(_droptext)
droptext = _droptext
if(_dropsound && !islist(_dropsound))
_dropsound = list(_dropsound)
dropsound = _dropsound
drop_memory = _drop_memory
/datum/component/spill/PostTransfer()
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/spill/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(equip_react))
RegisterSignal(parent, COMSIG_ITEM_DROPPED, PROC_REF(drop_react))
var/obj/item/master = parent
preexisting_slot_flags = master.slot_flags
master.slot_flags |= ITEM_SLOT_POCKETS
/datum/component/spill/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
var/obj/item/master = parent
if(!(preexisting_slot_flags & ITEM_SLOT_POCKETS))
master.slot_flags &= ~ITEM_SLOT_POCKETS
/datum/component/spill/proc/equip_react(obj/item/source, mob/equipper, slot)
SIGNAL_HANDLER
if(slot & (ITEM_SLOT_LPOCKET|ITEM_SLOT_RPOCKET))
RegisterSignal(equipper, COMSIG_LIVING_STATUS_KNOCKDOWN, PROC_REF(knockdown_react), TRUE)
else
UnregisterSignal(equipper, COMSIG_LIVING_STATUS_KNOCKDOWN)
/datum/component/spill/proc/drop_react(obj/item/source, mob/dropper)
SIGNAL_HANDLER
UnregisterSignal(dropper, COMSIG_LIVING_STATUS_KNOCKDOWN)
/datum/component/spill/proc/knockdown_react(mob/living/fool, amount)
SIGNAL_HANDLER
if(amount <= 0)
return
var/obj/item/master = parent
fool.dropItemToGround(master)
if(droptext)
fool.visible_message(arglist(droptext))
if(dropsound)
playsound(master, pick(dropsound), 30)
if(drop_memory)
fool.add_mob_memory(drop_memory)