Skip to content

Commit

Permalink
Merge pull request #64 from DopplerShift13/flavor-text
Browse files Browse the repository at this point in the history
Roleplay essentials: flavor text & records
  • Loading branch information
CliffracerX authored Sep 24, 2024
2 parents 6d7ed4e + 399bcd6 commit df021d7
Show file tree
Hide file tree
Showing 31 changed files with 942 additions and 10 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/~doppler_defines/preferences.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define MAX_FLAVOR_SHORT_DESC_LEN 250
#define MAX_FLAVOR_EXTENDED_DESC_LEN 4096

#define PREFERENCE_CATEGORY_DOPPLER_LORE "doppler_lore"

#define READ_PREFS(target, pref) (target.client?.prefs?.read_preference(/datum/preference/pref))
8 changes: 8 additions & 0 deletions code/__DEFINES/~doppler_defines/text.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/proc/prefix_a_or_an(text)
var/start = LOWER_TEXT(text[1])
if(!start)
return "a"
if(start == "a" || start == "e" || start == "i" || start == "o" || start == "u")
return "an"
else
return "a"
12 changes: 10 additions & 2 deletions code/datums/records/manifest.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GLOBAL_DATUM_INIT(manifest, /datum/manifest, new)
if(readied_player.new_character)
log_manifest(readied_player.ckey, readied_player.new_character.mind, readied_player.new_character)
if(ishuman(readied_player.new_character))
inject(readied_player.new_character)
inject(readied_player.new_character, readied_player.client) // DOPPLER EDIT, old code: inject(readied_player.new_character)
CHECK_TICK

/// Gets the current manifest.
Expand Down Expand Up @@ -98,7 +98,7 @@ GLOBAL_DATUM_INIT(manifest, /datum/manifest, new)


/// Injects a record into the manifest.
/datum/manifest/proc/inject(mob/living/carbon/human/person)
/datum/manifest/proc/inject(mob/living/carbon/human/person, client/person_client) // DOPPLER EDIT: records & flavor text
set waitfor = FALSE
if(!(person.mind?.assigned_role.job_flags & JOB_CREW_MANIFEST))
return
Expand Down Expand Up @@ -131,6 +131,7 @@ GLOBAL_DATUM_INIT(manifest, /datum/manifest, new)
// Locked specifics
locked_dna = record_dna,
mind_ref = person.mind,
age_chronological = person_client?.prefs.read_preference(/datum/preference/numeric/chronological_age), // DOPPLER EDIT ADDITION
)

new /datum/record/crew(
Expand All @@ -152,6 +153,13 @@ GLOBAL_DATUM_INIT(manifest, /datum/manifest, new)
minor_disabilities = person.get_quirk_string(FALSE, CAT_QUIRK_MINOR_DISABILITY, from_scan = TRUE),
minor_disabilities_desc = person.get_quirk_string(TRUE, CAT_QUIRK_MINOR_DISABILITY),
quirk_notes = person.get_quirk_string(TRUE, CAT_QUIRK_NOTES),
// DOPPLER EDIT BEGIN - records & flavor text
past_general_records = person_client?.prefs.read_preference(/datum/preference/text/past_general_records),
past_medical_records = person_client?.prefs.read_preference(/datum/preference/text/past_medical_records),
past_security_records = person_client?.prefs.read_preference(/datum/preference/text/past_security_records),
exploitable_records = person_client?.prefs.read_preference(/datum/preference/text/exploitable_records),
age_chronological = person_client?.prefs.read_preference(/datum/preference/numeric/chronological_age),
// DOPPLER EDIT END
)

/// Edits the rank and trim of the found record.
Expand Down
24 changes: 22 additions & 2 deletions code/datums/records/record.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
physical_status = PHYSICAL_ACTIVE,
mental_status = MENTAL_STABLE,
quirk_notes,
// DOPPLER EDIT START - records & flavor text
past_general_records = "",
past_medical_records = "",
past_security_records = "",
exploitable_records = "",
age_chronological = 18,
// DOPPER EDIT END
)
. = ..()
src.lock_ref = lock_ref
Expand All @@ -118,7 +125,13 @@
src.physical_status = physical_status
src.mental_status = mental_status
src.quirk_notes = quirk_notes

// DOPPLER EDIT START
src.past_general_records = past_general_records
src.past_medical_records = past_medical_records
src.past_security_records = past_security_records
src.exploitable_records = exploitable_records
src.age_chronological = age_chronological
// DOPPLER EDIT END
GLOB.manifest.general += src

/datum/record/crew/Destroy()
Expand Down Expand Up @@ -152,10 +165,12 @@
/// Locked specific
datum/dna/locked_dna,
datum/mind/mind_ref,
age_chronological = 18, // DOPPLER EDIT ADDITION
)
. = ..()
src.locked_dna = locked_dna
src.mind_ref = WEAKREF(mind_ref)
src.age_chronological = age_chronological // DOPPLER EDIT ADDITION
species_type = locked_dna.species.type

GLOB.manifest.locked += src
Expand Down Expand Up @@ -249,12 +264,17 @@
var/obj/item/paper/printed_paper = new
var/final_paper_text = "<center><b>SR-[print_count]: [header]</b></center><br>"

final_paper_text += "Name: [name]<br>Gender: [gender]<br>Age: [age]<br>"
final_paper_text += "Name: [name]<br>Gender: [gender]<br>Age: [age]<br> Chronological Age: [age_chronological]<br>" // DOPPLER EDIT: chronological age
if(alias != name)
final_paper_text += "Alias: [alias]<br>"

final_paper_text += "Species: [species]<br>Fingerprint: [fingerprint]<br>Wanted Status: [wanted_status]<br><br>"

// DOPPLER EDIT - records & flavour text
if(past_general_records != "")
final_paper_text += "<br><B>General Records:</B>"
final_paper_text += "<br>[past_general_records]<br>"
// DOPPLER EDIT END
final_paper_text += "<center><B>Security Data</B></center><br><br>"

final_paper_text += "Crimes:<br>"
Expand Down
5 changes: 5 additions & 0 deletions code/game/machinery/computer/records/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
rank = target.rank,
species = target.species,
trim = target.trim,
// DOPPLER EDIT BEGIN - records & flavor text
past_medical_records = target.past_medical_records,
past_general_records = target.past_general_records,
age_chronological = target.age_chronological,
// DOPPLER EDIT END
))

data["records"] = records
Expand Down
5 changes: 5 additions & 0 deletions code/game/machinery/computer/records/security.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@
species = target.species,
trim = target.trim,
wanted_status = target.wanted_status,
// DOPPLER EDIT BEGIN - records & flavor text
past_general_records = target.past_general_records,
past_security_records = target.past_security_records,
age_chronological = target.age_chronological,
// DOPPLER EDIT END
))

data["records"] = records
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ ADMIN_VERB(spawn_debug_full_crew, R_DEBUG, "Spawn Debug Full Crew", "Creates a f
// Finally, ensure the minds are tracked and in the manifest.
SSticker.minds += character.mind
if(ishuman(character))
GLOB.manifest.inject(character)
GLOB.manifest.inject(character, character.client) // DOPPLER EDIT, old code: GLOB.manifest.inject(character)

number_made++
CHECK_TICK
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/admingame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ADMIN_VERB(respawn_character, R_ADMIN, "Respawn Character", "Respawn a player th
if(!record_found && (new_character.mind.assigned_role.job_flags & JOB_CREW_MEMBER))
//Power to the user!
if(tgui_alert(new_character,"Warning: No data core entry detected. Would you like to announce the arrival of this character by adding them to various databases, such as medical records?",,list("No","Yes")) == "Yes")
GLOB.manifest.inject(new_character)
GLOB.manifest.inject(new_character, new_character.client) // DOPPLER EDIT, old code: GLOB.manifest.inject(new_character)

if(tgui_alert(new_character,"Would you like an active AI to announce this character?",,list("No","Yes")) == "Yes")
announce_arrival(new_character, new_character.mind.assigned_role.title)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/dead/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
SSquirks.AssignQuirks(humanc, humanc.client)

if(humanc) // Quirks may change manifest datapoints, so inject only after assigning quirks
GLOB.manifest.inject(humanc)
GLOB.manifest.inject(humanc, humanc.client) // DOPPLER EDIT, old code: GLOB.manifest.inject(humanc)

var/area/station/arrivals = GLOB.areas_by_type[/area/station/hallway/secondary/entry]
if(humanc && arrivals && !arrivals.power_environ) //arrivals depowered
Expand Down
9 changes: 9 additions & 0 deletions code/modules/mob/living/carbon/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
var/t_is = p_are()

. = list()
// DOPPLER EDIT BEGIN - flavor text
if (dna.features["flavor_short_desc"])
. += "[dna.features["flavor_short_desc"]] [get_extended_description_href("\[👁️\]")]"
ADD_NEWLINE_IF_NECESSARY(.)
if (dna.features["custom_species_name"])
. += "[t_He] [t_is] [prefix_a_or_an(dna.features["custom_species_name"])] <em>[get_species_description_href(dna.features["custom_species_name"])]</em> of [dna.species.name] physiology."
else
. += "[t_He] [t_is] [prefix_a_or_an(dna.species.name)] [get_species_description_href(dna.species.name)]."
// DOPPLER EDIT END
. += get_clothing_examine_info(user)
// give us some space between clothing examine and the rest
ADD_NEWLINE_IF_NECESSARY(.)
Expand Down
16 changes: 16 additions & 0 deletions code/modules/mob/living/silicon/robot/examine.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
/// DOPPLER ADDITION START, Adds a newline to the examine list if the above entry is not empty and it is not the first element in the list
#define ADD_NEWLINE_IF_NECESSARY(list) if(length(list) > 0 && list[length(list)]) { list += "" }
// DOPPLER ADDITION END

/mob/living/silicon/robot/examine(mob/user)
. = list()
if(desc)
. += "[desc]"

// DOPPLER EDIT BEGIN: flavor text
var/short_desc = READ_PREFS(src, text/silicon_short_desc)
if (short_desc)
. += "[short_desc] [get_extended_description_href("\[👁️\]")]"
ADD_NEWLINE_IF_NECESSARY(.)
var/custom_model_name = READ_PREFS(src, text/silicon_model_name)
if (custom_model_name)
. += "It is [prefix_a_or_an(custom_model_name)] <em>[get_species_description_href(custom_model_name)]</em> model construct."
// DOPPLER EDIT END

var/model_name = model ? "\improper [model.name]" : "\improper Default"
. += "It is currently <b>\a [model_name]-type</b> cyborg."

Expand Down Expand Up @@ -48,3 +62,5 @@
. += span_deadsay("It looks like its system is corrupted and requires a reset.")

. += ..()

#undef ADD_NEWLINE_IF_NECESSARY
7 changes: 7 additions & 0 deletions modular_doppler/flavortext_and_records/code/defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/mob/living/carbon/human
/// Chronological age.
var/age_chronological = 30

/mob/living/silicon/robot
/// Chronological age
var/age_chronological = 30
151 changes: 151 additions & 0 deletions modular_doppler/flavortext_and_records/code/examine.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
/mob/living procs for both humans and silicons
*/

/mob/living/proc/get_extended_description_href(input_text)
// Provides a href link with the `full_desc` arg, to be consumed by a Topic override (intended for flavour text descriptions)
return "<a href='?src=[REF(src)];full_desc=1;examine_time=[world.time]'>[input_text]</a>"

/mob/living/proc/get_species_description_href(input_text)
// Provides a href link with the `species_info` arg, to be consumed by a Topic override (intended for species/model descriptions)
return "<a href='?src=[REF(src)];species_info=1;examine_time=[world.time]'>[input_text]</a>"

/mob/living/proc/compile_examined_text(short_desc, extended_desc, headshot, ooc_notes)
// Compiles the full examined description because I HATE code duplication
var/full_examine = span_slightly_larger(separator_hr("<em>[src]</em>"))

full_examine += "<div class='large_img_by_text_container'>"
if (length(headshot)) // apply headshot
full_examine += "<img src='[headshot]' alt='[src.name]'>"
full_examine += "<div class='img_text'>"
full_examine += jointext(list(
"<i>[trim(short_desc)]</i><br>",
trim(extended_desc)
), "<br>")
full_examine += "</div></div>"
if (length(ooc_notes))
full_examine += span_slightly_larger(separator_hr("<em>OOC Notes</em>"))
full_examine += "<div class='ooc_notes'>"
full_examine += trim(ooc_notes)
full_examine += "</div>"

return full_examine

/mob/living/proc/compile_species_info_text(species_name, species_desc, is_model = FALSE)
// Compiles the species description block, with a switch for synthetic/model stuff, because I REALLY hate code duplication
var/header_prefix = is_model ? "Model" : "Species"
var/full_examine = span_slightly_larger(separator_hr("<em>[header_prefix]: [species_name]</em>"))

full_examine += trim(species_desc)

return full_examine

/*
CARBONS (AKA FLESHBAGS)
*/
/mob/living/carbon/human/examine_title(mob/user, thats = FALSE)
. = ..()
var/skipface = (wear_mask && (wear_mask.flags_inv & HIDEFACE)) || (head && (head.flags_inv & HIDEFACE))

var/species_visible
var/species_name_string
if(skipface || get_visible_name() == "Unknown")
species_visible = FALSE
else
species_visible = TRUE

if(!species_visible)
species_name_string = ""
else if (dna.features["custom_species_name"])
species_name_string = ", [prefix_a_or_an(dna.features["custom_species_name"])] <EM>[dna.features["custom_species_name"]]</EM>"
else
species_name_string = ", [prefix_a_or_an(dna.species.name)] <EM>[dna.species.name]</EM>"

. += species_name_string

/mob/living/carbon/human/Topic(href, href_list)
. = ..()

if (href_list["full_desc"])
// scuffed not-tgui flavor text stuff
var/mob/viewer = usr
var/can_see = (viewer in viewers(src))

if (HAS_TRAIT(src, TRAIT_UNKNOWN))
to_chat(viewer, span_notice("You can't discern a thing about them!"))
return

if (can_see)
var/short_desc = src.dna.features["flavor_short_desc"]
var/extended_desc = src.dna.features["flavor_extended_desc"]
var/headshot_url = src.dna.features["headshot_url"]
var/ooc_notes = src.dna.features["ooc_notes"]

var/full_examine = compile_examined_text(short_desc, extended_desc, headshot_url, ooc_notes)

to_chat(viewer, examine_block(span_info(full_examine)))
return
else
to_chat(viewer, span_notice("You're too far away to get a good look at [src]!"))
return
else if (href_list["species_info"])
// return a blurb detailing their species
var/mob/viewer = usr
var/can_see = (viewer in viewers(src))
if (can_see)
var/species_name = src.dna.features["custom_species_name"] ? src.dna.features["custom_species_name"] : src.dna.species.name
var/species_desc = src.dna.features["custom_species_desc"] ? src.dna.features["custom_species_desc"] : src.dna.species.get_species_description()

var/full_examine = compile_species_info_text(species_name, species_desc, FALSE)

to_chat(viewer, examine_block(span_info(full_examine)))
return
/*
SILICONS (AKA HORRIBLE RUSTBUCKETS)
*/

/mob/living/silicon/robot/examine_title(mob/user, thats)
. = ..()

// much simpler for silicons since disguises aren't really a thing... for now
var/model_name = READ_PREFS(src, text/silicon_model_name)
if (model_name)
. += ", [prefix_a_or_an(model_name)] <EM>[model_name]</EM>"


/mob/living/silicon/robot/Topic(href, href_list)
. = ..()

if (href_list["full_desc"])
var/mob/viewer = usr
var/can_see = (viewer in viewers(src))

if (HAS_TRAIT(src, TRAIT_UNKNOWN))
to_chat(viewer, span_notice("You can't discern a thing about them!"))
return

if (can_see)
var/short_desc = READ_PREFS(src, text/silicon_short_desc)
var/extended_desc = READ_PREFS(src, text/silicon_extended_desc)
var/headshot_url = READ_PREFS(src, text/headshot/silicon)
var/ooc_notes = READ_PREFS(src, text/ooc_notes)

var/full_examine = compile_examined_text(short_desc, extended_desc, headshot_url, ooc_notes)

to_chat(viewer, examine_block(span_info(full_examine)))
return
else
to_chat(viewer, span_notice("You're too far away to get a good look at [src]!"))
return
else if (href_list["species_info"])
var/mob/viewer = usr
var/can_see = (viewer in viewers(src))

if (can_see)
var/model_name = READ_PREFS(src, text/silicon_model_name)
var/model_desc = READ_PREFS(src, text/silicon_model_desc)

var/full_examine = compile_species_info_text(model_name, model_desc, TRUE)

to_chat(viewer, examine_block(span_info(full_examine)))
return
Loading

0 comments on commit df021d7

Please sign in to comment.