Refactors Temporal Scarring, changes how it works, removes longtimer quirk (#52688)

* changes temporal scarring

* hhh why is there no ckey

* note

* oops

* fixed
This commit is contained in:
Ryll Ryll
2020-08-10 16:29:27 -03:00
committed by GitHub
parent 04c7734c31
commit b7ae6fc64d
10 changed files with 156 additions and 119 deletions
+3 -11
View File
@@ -133,13 +133,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/hearted_until
/// Agendered spessmen can choose whether to have a male or female bodytype
var/body_type
/// If we have persistent scars enabled
var/persistent_scars = TRUE
/// We have 5 slots for persistent scars, if enabled we pick a random one to load (empty by default) and scars at the end of the shift if we survived as our original person
var/list/scars_list = list("1" = "", "2" = "", "3" = "", "4" = "", "5" = "")
/// Which of the 5 persistent scar slots we randomly roll to load for this round, if enabled. Actually rolled in [/datum/preferences/proc/load_character(slot)]
var/scars_index = 1
/datum/preferences/New(client/C)
parent = C
@@ -1721,12 +1716,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
persistent_scars = !persistent_scars
if("clear_scars")
to_chat(user, "<span class='notice'>All scar slots cleared. Please save character to confirm.</span>")
scars_list["1"] = ""
scars_list["2"] = ""
scars_list["3"] = ""
scars_list["4"] = ""
scars_list["5"] = ""
var/path = "data/player_saves/[user.ckey[1]]/[user.ckey]/scars.sav"
fdel(path)
to_chat(user, "<span class='notice'>All scar slots cleared.</span>")
if("hear_midis")
toggles ^= SOUND_MIDI
@@ -291,7 +291,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if(newtype)
pref_species = new newtype
scars_index = rand(1,5)
//Character
READ_FILE(S["real_name"], real_name)
@@ -326,11 +325,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
READ_FILE(S["feature_moth_wings"], features["moth_wings"])
READ_FILE(S["feature_moth_markings"], features["moth_markings"])
READ_FILE(S["persistent_scars"] , persistent_scars)
READ_FILE(S["scars1"], scars_list["1"])
READ_FILE(S["scars2"], scars_list["2"])
READ_FILE(S["scars3"], scars_list["3"])
READ_FILE(S["scars4"], scars_list["4"])
READ_FILE(S["scars5"], scars_list["5"])
if(!CONFIG_GET(flag/join_with_mutant_humans))
features["tail_human"] = "none"
features["ears"] = "none"
@@ -422,11 +416,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
features["moth_markings"] = sanitize_inlist(features["moth_markings"], GLOB.moth_markings_list, "None")
persistent_scars = sanitize_integer(persistent_scars)
scars_list["1"] = sanitize_text(scars_list["1"])
scars_list["2"] = sanitize_text(scars_list["2"])
scars_list["3"] = sanitize_text(scars_list["3"])
scars_list["4"] = sanitize_text(scars_list["4"])
scars_list["5"] = sanitize_text(scars_list["5"])
joblessrole = sanitize_integer(joblessrole, 1, 3, initial(joblessrole))
//Validate job prefs
@@ -484,12 +473,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
WRITE_FILE(S["feature_moth_wings"] , features["moth_wings"])
WRITE_FILE(S["feature_moth_markings"] , features["moth_markings"])
WRITE_FILE(S["persistent_scars"] , persistent_scars)
WRITE_FILE(S["scars1"] , scars_list["1"])
WRITE_FILE(S["scars2"] , scars_list["2"])
WRITE_FILE(S["scars3"] , scars_list["3"])
WRITE_FILE(S["scars4"] , scars_list["4"])
WRITE_FILE(S["scars5"] , scars_list["5"])
//Custom names
for(var/custom_name_id in GLOB.preferences_custom_names)
+3 -10
View File
@@ -331,6 +331,9 @@
to_chat(humanc, "<span class='userdanger'><i>THERE CAN BE ONLY ONE!!!</i></span>")
humanc.make_scottish()
humanc.increment_scar_slot()
humanc.load_persistent_scars()
if(GLOB.summon_guns_triggered)
give_guns(humanc)
if(GLOB.summon_magic_triggered)
@@ -432,16 +435,6 @@
is_antag = TRUE
client.prefs.copy_to(H, antagonist = is_antag, is_latejoiner = transfer_after)
var/cur_scar_index = client.prefs.scars_index
if(client.prefs.persistent_scars && client.prefs.scars_list["[cur_scar_index]"])
var/scar_string = client.prefs.scars_list["[cur_scar_index]"]
var/valid_scars = ""
for(var/scar_line in splittext(scar_string, ";"))
if(H.load_scar(scar_line))
valid_scars += "[scar_line];"
client.prefs.scars_list["[cur_scar_index]"] = valid_scars
client.prefs.save_character()
client.prefs.copy_to(H, antagonist = is_antag)
H.dna.update_dna_identity()
@@ -176,7 +176,24 @@
if(isclothing(wear_mask) && (wear_mask.clothing_flags & SCAN_REAGENTS))
return TRUE
/// For use formatting all of the scars this human has for saving for persistent scarring
/// When we're joining the game in [/mob/dead/new_player/proc/create_character], we increment our scar slot then store the slot in our mind datum.
/mob/living/carbon/human/proc/increment_scar_slot()
var/check_ckey = ckey || client?.ckey
if(!check_ckey || !mind || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[check_ckey[1]]/[check_ckey]/scars.sav"
var/index = mind.current_scar_slot
if (!index)
if(fexists(path))
var/savefile/F = new /savefile(path)
index = F["current_index"] || 1
else
index = 1
mind.current_scar_slot = (index % PERSISTENT_SCAR_SLOTS) + 1 || 1
/// For use formatting all of the scars this human has for saving for persistent scarring, returns a string with all current scars/missing limb amputation scars for saving or loading purposes
/mob/living/carbon/human/proc/format_scars()
var/list/missing_bodyparts = get_missing_limbs()
if(!all_scars && !length(missing_bodyparts))
@@ -200,7 +217,50 @@
return
var/obj/item/bodypart/the_part = get_bodypart("[scar_data[SCAR_SAVE_ZONE]]")
var/datum/scar/scaries = new
return scaries.load(the_part, scar_data[SCAR_SAVE_VERS], scar_data[SCAR_SAVE_DESC], scar_data[SCAR_SAVE_PRECISE_LOCATION], text2num(scar_data[SCAR_SAVE_SEVERITY]))
return scaries.load(the_part, scar_data[SCAR_SAVE_VERS], scar_data[SCAR_SAVE_DESC], scar_data[SCAR_SAVE_PRECISE_LOCATION], text2num(scar_data[SCAR_SAVE_SEVERITY]), text2num(scar_data[SCAR_SAVE_BIOLOGY]))
/// Read all the scars we have at the designated slot, verify they're good (or dump them if they're old/wrong format), create them on the user, and write the scars that passed muster back to the file
/mob/living/carbon/human/proc/load_persistent_scars()
if(!ckey || !mind || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[ckey[1]]/[ckey]/scars.sav"
if (!fexists(path))
return FALSE
var/savefile/F = new /savefile(path)
if(!F)
return
var/index = mind.current_scar_slot || F["current_index"] || 1
var/scar_string = F["scar[index]"]
var/valid_scars = ""
for(var/scar_line in splittext(sanitize_text(scar_string), ";"))
if(load_scar(scar_line))
valid_scars += "[scar_line];"
WRITE_FILE(F["scar[index]"], sanitize_text(valid_scars))
/// Save any scars we have to our designated slot, then write our current slot so that the next time we call [/mob/living/carbon/human/proc/increment_scar_slot] (the next round we join), we'll be there
/mob/living/carbon/human/proc/save_persistent_scars(nuke=FALSE)
if(!ckey || !mind || !client?.prefs.persistent_scars)
return
var/path = "data/player_saves/[ckey[1]]/[ckey]/scars.sav"
var/savefile/F = new /savefile(path)
var/index = mind.current_scar_slot || F["current_index"] || 1
if(nuke)
WRITE_FILE(F["scar[index]"], "")
return
for(var/k in all_wounds)
var/datum/wound/iter_wound = k
iter_wound.remove_wound() // so we can get the scars for open wounds
var/valid_scars = format_scars()
WRITE_FILE(F["scar[index]"], sanitize_text(valid_scars))
WRITE_FILE(F["current_index"], sanitize_integer(index))
/mob/living/carbon/human/get_biological_state()
return dna.species.get_biological_state()