mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 06:32:56 +00:00
* Refactors memories to be less painful to add and apply, moves memory detail / text to memory subtypes. Adds some new memories to demonstrate. (#72110) 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. Makes it way simpler to add new memories. Maybe we'll get some more fun ones now? 🆑 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. /🆑 * Modular! Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Funce <funce.973@gmail.com>
96 lines
3.8 KiB
Plaintext
96 lines
3.8 KiB
Plaintext
/**
|
|
* # engraved component!
|
|
*
|
|
* component for walls that applies an engraved overlay and lets you examine it to read a story (+ art element yay)
|
|
* new creations will get a high art value, cross round scrawlings will get a low one.
|
|
* MUST be a component, though it doesn't look like it. SSPersistence demandeth
|
|
*/
|
|
/datum/component/engraved
|
|
///the generated story string
|
|
var/engraved_description
|
|
///whether this is a new engraving, or a persistence loaded one.
|
|
var/persistent_save
|
|
///what random icon state should the engraving have
|
|
var/icon_state_append
|
|
///The story value of this piece.
|
|
var/story_value
|
|
|
|
/datum/component/engraved/Initialize(engraved_description, persistent_save, story_value)
|
|
. = ..()
|
|
if(!isclosedturf(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/turf/closed/engraved_wall = parent
|
|
|
|
src.engraved_description = engraved_description
|
|
src.persistent_save = persistent_save
|
|
src.story_value = story_value
|
|
|
|
var/beauty_value
|
|
switch(story_value)
|
|
if(STORY_VALUE_KEY)
|
|
beauty_value = 0 // what is this
|
|
if(STORY_VALUE_SHIT)
|
|
beauty_value = rand(-50, 50) //Ugly or mediocre at best
|
|
if(STORY_VALUE_NONE)
|
|
beauty_value = rand(0, 100) //No inherent value
|
|
if(STORY_VALUE_MEH)
|
|
beauty_value = rand(100, 200) //Its an okay tale
|
|
if(STORY_VALUE_OKAY)
|
|
beauty_value = rand(150, 300) //Average story! most things are like this
|
|
if(STORY_VALUE_AMAZING)
|
|
beauty_value = rand(300, 600)//Really impactful stories, seeing a lost limb, losing a loved pet.
|
|
if(STORY_VALUE_LEGENDARY)
|
|
beauty_value = rand(500, 800) //Almost always a good story! this is for memories you can barely ever get, killing megafauna, doing ultimate feats!
|
|
|
|
engraved_wall.AddElement(/datum/element/art, beauty_value / ENGRAVING_BEAUTY_TO_ART_FACTOR)
|
|
if(persistent_save)
|
|
engraved_wall.AddElement(/datum/element/beauty, beauty_value)
|
|
else
|
|
engraved_wall.AddElement(/datum/element/beauty, beauty_value / ENGRAVING_PERSISTENCE_BEAUTY_LOSS_FACTOR) //Old age does them harm
|
|
icon_state_append = rand(1, 2)
|
|
//must be here to allow overlays to be updated
|
|
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_update_overlays))
|
|
engraved_wall.update_appearance()
|
|
|
|
/datum/component/engraved/Destroy(force, silent)
|
|
if(!parent)
|
|
return ..()
|
|
parent.RemoveElement(/datum/element/art)
|
|
//must be here to allow overlays to be updated
|
|
UnregisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS)
|
|
if(!QDELING(parent))
|
|
var/atom/parent_atom = parent
|
|
parent_atom.update_appearance()
|
|
return ..() //call this after since we null out the parent
|
|
|
|
/datum/component/engraved/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
|
|
//supporting component transfer means putting these here instead of initialize
|
|
SSpersistence.wall_engravings += src
|
|
ADD_TRAIT(parent, TRAIT_NOT_ENGRAVABLE, TRAIT_GENERIC)
|
|
|
|
/datum/component/engraved/UnregisterFromParent()
|
|
UnregisterSignal(parent, COMSIG_PARENT_EXAMINE)
|
|
//supporting component transfer means putting these here instead of destroy
|
|
SSpersistence.wall_engravings -= src
|
|
REMOVE_TRAIT(parent, TRAIT_NOT_ENGRAVABLE, TRAIT_GENERIC)
|
|
|
|
/// Used to maintain the acid overlay on the parent [/atom].
|
|
/datum/component/engraved/proc/on_update_overlays(atom/parent_atom, list/overlays)
|
|
SIGNAL_HANDLER
|
|
|
|
overlays += mutable_appearance('icons/turf/wall_overlays.dmi', "engraving[icon_state_append]")
|
|
|
|
///signal called on parent being examined
|
|
/datum/component/engraved/proc/on_examine(datum/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
examine_list += span_boldnotice(engraved_description)
|
|
|
|
///returns all the information SSpersistence needs in a list to load up this engraving on a future round!
|
|
/datum/component/engraved/proc/save_persistent()
|
|
var/list/saved_data = list()
|
|
saved_data["story"] = engraved_description
|
|
saved_data["story_value"] = story_value
|
|
|
|
return list(saved_data)
|