Refactored underwear to use datum/sprite_accessory/underwear similar to hair and facial_hair.

People may select any underwear (regardless of gender) at a dresser, but not in preferences.
random_underwear(gender) will return a random pair of underwear suitable for your gender.
Removed an unused variable in sprite_accessory

The new_player preferences screen now randomizes character slots for which there is no data (so no more bald, fat, white guys in diapers greeting new players)
datum/preferences character settings are randomised at New().
replaced /datum/preferences/proc/randomize_appearance_for(human/H) with /datum/preferences/proc/random_character(), it does the same stuff without the copying to a mob. Basically, now when you want to make a random character you just do var/datum/preferences/A = new(); A.copy_to(human_mob), randomisation of appearance and name will already be done. Easy.

Reworked the savefile updating/versioning code to make it easier to work with. I've used it to update underwear preferences to the new system as an example.

Signed-off-by: carnie <elly1989@rocketmail.com>
This commit is contained in:
carnie
2013-03-28 11:11:40 +00:00
parent 2c9283dd05
commit 5ca166cae0
23 changed files with 387 additions and 212 deletions
+17 -33
View File
@@ -22,14 +22,15 @@ var/global/list/portals = list() //for use by portals
//Preferences stuff
//Hairstyles
var/global/list/hair_styles_list = list() //stores /datum/sprite_accessory/hair indexed by name
var/global/list/hair_styles_male_list = list()
var/global/list/hair_styles_female_list = list()
var/global/list/hair_styles_male_list = list() //stores only hair names
var/global/list/hair_styles_female_list = list() //stores only hair names
var/global/list/facial_hair_styles_list = list() //stores /datum/sprite_accessory/facial_hair indexed by name
var/global/list/facial_hair_styles_male_list = list()
var/global/list/facial_hair_styles_female_list = list()
var/global/list/facial_hair_styles_male_list = list() //stores only hair names
var/global/list/facial_hair_styles_female_list = list() //stores only hair names
//Underwear
var/global/list/underwear_m = list("White", "Grey", "Green", "Blue", "Black", "Mankini", "Love-Hearts", "Black2", "Grey2", "Stripey", "Kinky", "Red", "None") //Curse whoever made male/female underwear diffrent colours
var/global/list/underwear_f = list("Red", "White", "Yellow", "Blue", "Black", "Thong", "Babydoll", "Baby-Blue", "Green", "Pink", "Kinky", "Tankini", "None")
var/global/list/underwear_all = list() //stores /datum/sprite_accessory/underwear indexed by name
var/global/list/underwear_m = list() //stores only underwear name
var/global/list/underwear_f = list() //stores only underwear name
//Backpacks
var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel")
@@ -38,34 +39,17 @@ var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel")
//////////////////////////
/proc/make_datum_references_lists()
var/list/paths
//Hair - Initialise all /datum/sprite_accessory/hair into an list indexed by hair-style name
paths = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
for(var/path in paths)
var/datum/sprite_accessory/hair/H = new path()
hair_styles_list[H.name] = H
switch(H.gender)
if(MALE) hair_styles_male_list += H.name
if(FEMALE) hair_styles_female_list += H.name
else
hair_styles_male_list += H.name
hair_styles_female_list += H.name
//Facial Hair - Initialise all /datum/sprite_accessory/facial_hair into an list indexed by facialhair-style name
paths = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
for(var/path in paths)
var/datum/sprite_accessory/facial_hair/H = new path()
facial_hair_styles_list[H.name] = H
switch(H.gender)
if(MALE) facial_hair_styles_male_list += H.name
if(FEMALE) facial_hair_styles_female_list += H.name
else
facial_hair_styles_male_list += H.name
facial_hair_styles_female_list += H.name
//hair
init_sprite_accessory_subtypes(/datum/sprite_accessory/hair, hair_styles_list, hair_styles_male_list, hair_styles_female_list)
//facial hair
init_sprite_accessory_subtypes(/datum/sprite_accessory/facial_hair, facial_hair_styles_list, facial_hair_styles_male_list, facial_hair_styles_female_list)
//underwear
init_sprite_accessory_subtypes(/datum/sprite_accessory/underwear, underwear_all, underwear_m, underwear_f)
//Surgeries
paths = typesof(/datum/surgery) - /datum/surgery
for(var/path in paths)
for(var/path in typesof(/datum/surgery))
if(path == /datum/surgery)
continue
var/datum/surgery/S = new path()
surgeries_list[S.name] = S
+6
View File
@@ -1,3 +1,9 @@
/proc/random_underwear(gender)
switch(gender)
if(MALE) return pick(underwear_m)
if(FEMALE) return pick(underwear_f)
else return pick(underwear_all)
proc/random_hair_style(gender)
switch(gender)
if(MALE) return pick(hair_styles_male_list)
+1 -1
View File
@@ -14,7 +14,7 @@
/proc/sanitize_inlist(value, list/List, default)
if(value in List) return value
if(default) return default
if(List && List.len)return List[1]
if(List && List.len)return pick(List)
+2 -2
View File
@@ -77,7 +77,7 @@
//Hair
var/hair = 0
if(!character.h_style)
character.h_style = "Bald"
character.h_style = random_hair_style(character.gender)
var/hrange = round(4095 / hair_styles_list.len)
var/index = hair_styles_list.Find(character.h_style)
@@ -87,7 +87,7 @@
//Facial Hair
var/beard = 0
if(!character.f_style)
character.f_style = "Shaved"
character.f_style = random_facial_hair_style(character.gender)
var/f_hrange = round(4095 / facial_hair_styles_list.len)
index = facial_hair_styles_list.Find(character.f_style)
+1 -1
View File
@@ -35,7 +35,7 @@
I.Blend(rgb(- src.lumens, -src.lumens, -src.lumens), ICON_SUBTRACT)
I.Blend(new /icon('icons/mob/human.dmi', "mouth_m_s"), ICON_OVERLAY)
I.Blend(new /icon('icons/mob/human.dmi', "underwear1_m_s"), ICON_OVERLAY)
I.Blend(new /icon('icons/mob/underwear.dmi', "Mens White"), ICON_OVERLAY)
var/icon/U = new /icon('icons/mob/human_face.dmi', "hair_a_s")
U.Blend(rgb(src.h_r, src.h_g, src.h_b), ICON_ADD)
+5 -12
View File
@@ -10,18 +10,11 @@
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.gender == MALE)
var/new_undies = input(user, "Select your underwear", "Changing") as null|anything in underwear_m
if(!in_range(src, usr))//no tele-grooming
return
if(new_undies)
H.underwear = underwear_m.Find(new_undies)
else
var/new_undies = input(user, "Select your underwear", "Changing") as null|anything in underwear_f
if(!in_range(src, usr))
return
if(new_undies)
H.underwear = underwear_f.Find(new_undies)
var/new_undies = input(user, "Select your underwear", "Changing") as null|anything in underwear_all
if(!in_range(src, user))//no tele-grooming
return
if(new_undies)
H.underwear = new_undies
add_fingerprint(H)
H.update_body()
+1 -7
View File
@@ -391,13 +391,7 @@ client/proc/one_click_antag()
new_character.gender = pick(MALE,FEMALE)
var/datum/preferences/A = new()
A.randomize_appearance_for(new_character)
if(new_character.gender == MALE)
new_character.real_name = "[pick(first_names_male)] [pick(last_names)]"
else
new_character.real_name = "[pick(first_names_female)] [pick(last_names)]"
new_character.name = new_character.real_name
new_character.age = rand(17,45)
A.copy_to(new_character)
new_character.dna.ready_dna(new_character)
new_character.key = G_found.key
+3 -6
View File
@@ -304,14 +304,11 @@ Traitors and the like can also be revived with the previous role mostly intact.
else
new_character.gender = pick(MALE,FEMALE)
var/datum/preferences/A = new()
A.randomize_appearance_for(new_character)
new_character.real_name = G_found.real_name
A.real_name = G_found.real_name
A.copy_to(new_character)
if(!new_character.real_name)
if(new_character.gender == MALE)
new_character.real_name = capitalize(pick(first_names_male)) + " " + capitalize(pick(last_names))
else
new_character.real_name = capitalize(pick(first_names_female)) + " " + capitalize(pick(last_names))
new_character.real_name = random_name(new_character.gender)
new_character.name = new_character.real_name
if(G_found.mind && !G_found.mind.active)
+25 -22
View File
@@ -24,7 +24,6 @@ datum/preferences
//doohickeys for savefiles
var/path
var/default_slot = 1 //Holder so it doesn't default to slot 1, rather the last one used
var/savefile_version = 0
//non-preference stuff
var/warns = 0
@@ -45,7 +44,7 @@ datum/preferences
var/gender = MALE //gender of character (well duh)
var/age = 30 //age of character
var/b_type = "A+" //blood type (not-chooseable)
var/underwear = 1 //underwear type
var/underwear = "Nude" //underwear type
var/backbag = 2 //backpack type
var/h_style = "Bald" //Hair type
var/r_hair = 0 //Hair color
@@ -91,11 +90,17 @@ datum/preferences
if(istype(C))
if(!IsGuestKey(C.key))
load_path(C.ckey)
if(load_preferences())
if(load_character())
return
gender = pick(MALE, FEMALE)
var/loaded_preferences_successfully = load_preferences()
if(loaded_preferences_successfully)
if(load_character())
return
//we couldn't load character data so just randomize the character appearance + name
random_character() //let's create a random character then - rather than a fat, bald and naked man.
real_name = random_name(gender)
if(!loaded_preferences_successfully)
save_preferences()
save_character() //let's save this new random character so it doesn't keep generating new ones.
return
/datum/preferences
proc/ShowChoices(mob/user)
@@ -157,12 +162,7 @@ datum/preferences
dat += "<b>Blood Type:</b> [b_type]<BR>"
dat += "<b>Skin Tone:</b><BR><a href='?_src_=prefs;preference=s_tone;task=input'>[-s_tone + 35]/220</a><BR>"
if(gender == MALE)
dat += "<b>Underwear:</b><BR><a href ='?_src_=prefs;preference=underwear;task=input'>[underwear_m[underwear]]</a><BR>"
else
dat += "<b>Underwear:</b><BR><a href ='?_src_=prefs;preference=underwear;task=input'>[underwear_f[underwear]]</a><BR>"
dat += "<b>Underwear:</b><BR><a href ='?_src_=prefs;preference=underwear;task=input'>[underwear]</a><BR>"
dat += "<b>Backpack:</b><BR><a href ='?_src_=prefs;preference=bag;task=input'>[backbaglist[backbag]]</a><BR>"
@@ -497,7 +497,7 @@ datum/preferences
if("f_style")
f_style = random_facial_hair_style(gender)
if("underwear")
underwear = rand(1,underwear_m.len)
underwear = random_underwear(gender)
if("eyes")
r_eyes = rand(0,255)
g_eyes = rand(0,255)
@@ -507,7 +507,7 @@ datum/preferences
if("bag")
backbag = rand(1,3)
if("all")
randomize_appearance_for() //no params needed
random_character()
if("input")
switch(href_list["preference"])
@@ -561,7 +561,7 @@ datum/preferences
var/new_underwear = input(user, "Choose your character's underwear:", "Character Preference") as null|anything in underwear_options
if(new_underwear)
underwear = underwear_options.Find(new_underwear)
underwear = new_underwear
if("eyes")
var/new_eyes = input(user, "Choose your character's eye colour:", "Character Preference") as color|null
@@ -591,6 +591,8 @@ datum/preferences
gender = FEMALE
else
gender = MALE
underwear = random_underwear(gender)
if("hear_adminhelps")
toggles ^= SOUND_ADMINHELP
@@ -636,7 +638,10 @@ datum/preferences
load_character()
if("changeslot")
load_character(text2num(href_list["num"]))
if(!load_character(text2num(href_list["num"])))
random_character()
real_name = random_name(gender)
save_character()
if("tab")
if (href_list["tab"])
@@ -645,9 +650,9 @@ datum/preferences
ShowChoices(user)
return 1
proc/copy_to(mob/living/carbon/human/character, safety = 0)
proc/copy_to(mob/living/carbon/human/character)
if(be_random_name)
real_name = random_name()
real_name = random_name(gender)
if(config.humans_need_surnames)
var/firstspace = findtext(real_name, " ")
@@ -679,21 +684,19 @@ datum/preferences
character.b_facial = b_facial
character.s_tone = s_tone
character.h_style = h_style
character.f_style = f_style
if(underwear > underwear_m.len || underwear < 1)
underwear = 1 //I'm sure this is 100% unnecessary, but I'm paranoid... sue me.
character.underwear = underwear
if(backbag > 3 || backbag < 1)
backbag = 1 //Same as above
character.backbag = backbag
/*
//Debugging report to track down a bug, which randomly assigned the plural gender to people.
if(character.gender in list(PLURAL, NEUTER))
if(isliving(src)) //Ghosts get neuter by default
message_admins("[character] ([character.ckey]) has spawned with their gender as plural or neuter. Please notify coders.")
character.gender = MALE
*/
+115 -39
View File
@@ -1,51 +1,108 @@
//This is the lowest supported version, anything below this is completely obsolete and the entire savefile will be wiped.
#define SAVEFILE_VERSION_MIN 8
#define SAVEFILE_VERSION_MAX 8
//handles converting savefiles to new formats
//MAKE SURE YOU KEEP THIS UP TO DATE!
//If the sanity checks are capable of handling any issues. Only increase SAVEFILE_VERSION_MAX,
//this will mean that savefile_version will still be over SAVEFILE_VERSION_MIN, meaning
//this savefile update doesn't run everytime we load from the savefile.
//This is mainly for format changes, such as the bitflags in toggles changing order or something.
//if a file can't be updated, return 0 to delete it and start again
//if a file was updated, return 1
/datum/preferences/proc/savefile_update()
if(savefile_version < 8) //lazily delete everything + additional files so they can be saved in the new format
for(var/ckey in preferences_datums)
var/datum/preferences/D = preferences_datums[ckey]
if(D == src)
var/delpath = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/"
if(delpath && fexists(delpath))
fdel(delpath)
break
return 0
//This is the current version, anything below this will attempt to update (if it's not obsolete)
#define SAVEFILE_VERSION_MAX 9
if(savefile_version == SAVEFILE_VERSION_MAX) //update successful.
save_preferences()
save_character()
return 1
return 0
/*//This will allow you to print savefiles
/client/verb/read_savefile(client/C in clients)
var/savefile/S = new /savefile(prefs.path)
S.ExportText("/",file("savefile.txt"))
*/
/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
This proc checks if the current directory of the savefile S needs updating
It is to be used by the load_character and load_preferences procs.
(S.cd=="/" is preferences, S.cd=="/character[integer]" is a character slot, etc)
if the current directory's version is below SAVEFILE_VERSION_MIN it will simply wipe everything in that directory
(if we're at root "/" then it'll just wipe the entire savefile, for instance.)
if its version is below SAVEFILE_VERSION_MAX but above the minimum, it will load data but later call the
respective update_preferences() or update_character() proc.
Those procs allow coders to specify format changes so users do not lose their setups and have to redo them again.
Failing all that, the standard sanity checks are performed. They simply check the data is suitable, reverting to
initial() values if necessary.
*/
/datum/preferences/proc/savefile_needs_update(savefile/S)
var/savefile_version
S["version"] >> savefile_version
if(savefile_version < SAVEFILE_VERSION_MIN)
S.dir.Cut()
return -2
if(savefile_version < SAVEFILE_VERSION_MAX)
return savefile_version
return -1
/datum/preferences/proc/update_preferences(current_version)
return
//should this proc get fairly long (say 3 versions long),
//just increase SAVEFILE_VERSION_MIN so it's not as far behind
//SAVEFILE_VERSION_MAX and then delete any obsolete if clauses
//from this proc.
//It's only really meant to avoid annoying frequent players
//if your savefile is 3 months out of date, then 'tough shit'.
/datum/preferences/proc/update_character(current_version)
if(current_version < 9) //an example, underwear were an index for a hardcoded list, converting to a string
if(gender == MALE)
switch(underwear)
if(1) underwear = "Mens White"
if(2) underwear = "Mens Grey"
if(3) underwear = "Mens Green"
if(4) underwear = "Mens Blue"
if(5) underwear = "Mens Black"
if(6) underwear = "Mankini"
if(7) underwear = "Mens Hearts Boxer"
if(8) underwear = "Mens Black Boxer"
if(9) underwear = "Mens Grey Boxer"
if(10) underwear = "Mens Striped Boxer"
if(11) underwear = "Mens Kinky"
if(12) underwear = "Mens Red"
if(13) underwear = "Nude"
else
switch(underwear)
if(1) underwear = "Ladies Red"
if(2) underwear = "Ladies White"
if(3) underwear = "Ladies Yellow"
if(4) underwear = "Ladies Blue"
if(5) underwear = "Ladies Black"
if(6) underwear = "Ladies Thong"
if(7) underwear = "Babydoll"
if(8) underwear = "Ladies Baby-Blue"
if(9) underwear = "Ladies Green"
if(10) underwear = "Ladies Pink"
if(11) underwear = "Ladies Kinky"
if(12) underwear = "Tankini"
if(13) underwear = "Nude"
/*
if(current_version < 10) //would be the step to upgrade 9 to 10
//do stuff
if(current_version < 11) //and so on...
//more stuff
*/
return
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
if(!ckey) return
path = "data/player_saves/[copytext(ckey,1,2)]/[ckey]/[filename]"
savefile_version = SAVEFILE_VERSION_MAX
/datum/preferences/proc/load_preferences()
if(!path) return 0
if(!fexists(path)) return 0
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/"
S["version"] >> savefile_version
//Conversion
if(!savefile_version || !isnum(savefile_version) || savefile_version < SAVEFILE_VERSION_MIN || savefile_version > SAVEFILE_VERSION_MAX)
if(!savefile_update()) //handles updates
savefile_version = SAVEFILE_VERSION_MAX
save_preferences()
save_character()
return 0
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//general preferences
S["ooccolor"] >> ooccolor
@@ -55,6 +112,10 @@
S["default_slot"] >> default_slot
S["toggles"] >> toggles
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_preferences(needs_update) //needs_update = savefile_version if we need an update (positive integer)
//Sanitize
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog))
@@ -71,7 +132,7 @@
if(!S) return 0
S.cd = "/"
S["version"] << savefile_version
S["version"] << SAVEFILE_VERSION_MAX //updates (or failing that the sanity checks) will ensure data is not invalid at load. Assume up-to-date
//general preferences
S["ooccolor"] << ooccolor
@@ -94,7 +155,11 @@
if(slot != default_slot)
default_slot = slot
S["default_slot"] << slot
S.cd = "/character[slot]"
var/needs_update = savefile_needs_update(S)
if(needs_update == -2) //fatal, can't load any data
return 0
//Character
S["OOC_Notes"] >> metadata
@@ -130,12 +195,24 @@
S["job_engsec_med"] >> job_engsec_med
S["job_engsec_low"] >> job_engsec_low
//try to fix any outdated data if necessary
if(needs_update >= 0)
update_character(needs_update) //needs_update == savefile_version if we need an update (positive integer)
//Sanitize
metadata = sanitize_text(metadata, initial(metadata))
real_name = reject_bad_name(real_name)
if(!real_name) real_name = random_name()
if(!real_name) real_name = random_name(gender)
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
gender = sanitize_gender(gender)
if(gender == MALE)
h_style = sanitize_inlist(h_style, hair_styles_male_list)
f_style = sanitize_inlist(f_style, facial_hair_styles_male_list)
underwear = sanitize_inlist(underwear, underwear_m)
else
h_style = sanitize_inlist(h_style, hair_styles_female_list)
f_style = sanitize_inlist(f_style, facial_hair_styles_female_list)
underwear = sanitize_inlist(underwear, underwear_f)
age = sanitize_integer(age, AGE_MIN, AGE_MAX, initial(age))
r_hair = sanitize_integer(r_hair, 0, 255, initial(r_hair))
g_hair = sanitize_integer(g_hair, 0, 255, initial(g_hair))
@@ -144,12 +221,9 @@
g_facial = sanitize_integer(g_facial, 0, 255, initial(g_facial))
b_facial = sanitize_integer(b_facial, 0, 255, initial(b_facial))
s_tone = sanitize_integer(s_tone, -185, 34, initial(s_tone))
h_style = sanitize_inlist(h_style, hair_styles_list, initial(h_style))
f_style = sanitize_inlist(f_style, facial_hair_styles_list, initial(f_style))
r_eyes = sanitize_integer(r_eyes, 0, 255, initial(r_eyes))
g_eyes = sanitize_integer(g_eyes, 0, 255, initial(g_eyes))
b_eyes = sanitize_integer(b_eyes, 0, 255, initial(b_eyes))
underwear = sanitize_integer(underwear, 1, underwear_m.len, initial(underwear))
backbag = sanitize_integer(backbag, 1, backbaglist.len, initial(backbag))
userandomjob = sanitize_integer(userandomjob, 0, 1, initial(userandomjob))
@@ -170,6 +244,8 @@
var/savefile/S = new /savefile(path)
if(!S) return 0
S.cd = "/character[default_slot]"
S["version"] << SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date.
//Character
S["OOC_Notes"] << metadata
+2 -6
View File
@@ -341,14 +341,10 @@ ________________________________________________________________________________
/proc/create_space_ninja(turf/spawnturf)
var/mob/living/carbon/human/new_ninja = new(spawnturf)
var/ninja_title = pick(ninja_titles)
var/ninja_name = pick(ninja_names)
new_ninja.gender = pick(MALE, FEMALE)
var/datum/preferences/A = new()//Randomize appearance for the ninja.
A.randomize_appearance_for(new_ninja)
new_ninja.real_name = "[ninja_title] [ninja_name]"
new_ninja.dna.ready_dna(new_ninja)
A.real_name = "[pick(ninja_titles)] [pick(ninja_names)]"
A.copy_to(new_ninja)
new_ninja.equip_space_ninja()
return new_ninja
@@ -23,7 +23,7 @@
var/age = 30 //Player's age (pure fluff)
var/b_type = "A+" //Player's bloodtype (Not currently used, just character fluff)
var/underwear = 1 //Which underwear the player wants
var/underwear = "Nude" //Which underwear the player wants
var/backbag = 2 //Which backpack type the player has chosen. Nothing, Satchel or Backpack.
//Equipment slots
@@ -233,10 +233,12 @@ Please contact me on #coderbus IRC. ~Carn x
lying_icon.Blend(new/icon('icons/mob/human_face.dmi', "lips_[lip_style]_l"), ICON_OVERLAY)
//Underwear
if(underwear >0 && underwear < underwear_m.len)
if(!fat && !skeleton)
stand_icon.Blend(new /icon('icons/mob/human.dmi', "underwear[underwear]_[g]_s"), ICON_OVERLAY)
lying_icon.Blend(new /icon('icons/mob/human.dmi', "underwear[underwear]_[g]_l"), ICON_OVERLAY)
if(underwear && !fat && !skeleton)
var/datum/sprite_accessory/underwear/U = underwear_all[underwear]
if(U)
stand_icon.Blend(new /icon(U.icon, "[U.icon_state]_s"), ICON_OVERLAY)
lying_icon.Blend(new /icon(U.icon, "[U.icon_state]_l"), ICON_OVERLAY)
if(update_icons) update_icons()
+4 -6
View File
@@ -116,7 +116,7 @@
src << "\blue Now teleporting."
observer.loc = O.loc
if(client.prefs.be_random_name)
client.prefs.real_name = random_name()
client.prefs.real_name = random_name(gender)
observer.real_name = client.prefs.real_name
observer.name = observer.real_name
observer.key = key
@@ -309,11 +309,9 @@
new_character.lastarea = get_area(loc)
if(ticker.random_players)
new_character.gender = pick(MALE, FEMALE)
client.prefs.real_name = random_name()
client.prefs.randomize_appearance_for(new_character)
else
client.prefs.copy_to(new_character)
client.prefs.random_character()
client.prefs.real_name = random_name(gender)
client.prefs.copy_to(new_character)
src << sound(null, repeat = 0, wait = 0, volume = 85, channel = 1) // MAD JAMS cant last forever yo
@@ -1,22 +1,19 @@
datum/preferences
//The mob should have a gender you want before running this proc. Will run fine without H
proc/randomize_appearance_for(var/mob/living/carbon/human/H)
if(H)
if(H.gender == MALE)
gender = MALE
else
gender = FEMALE
proc/random_character(gender_override)
if(gender_override)
gender = gender_override
else
gender = pick(MALE,FEMALE)
underwear = random_underwear(gender)
s_tone = random_skin_tone()
h_style = random_hair_style(gender)
f_style = random_facial_hair_style(gender)
randomize_hair_color("hair")
randomize_hair_color("facial")
randomize_eyes_color()
underwear = rand(1,underwear_m.len)
backbag = 2
age = rand(AGE_MIN,AGE_MAX)
if(H)
copy_to(H,1)
proc/randomize_hair_color(var/target = "hair")
@@ -144,8 +141,10 @@ datum/preferences
else
preview_icon.Blend(rgb(-s_tone, -s_tone, -s_tone), ICON_SUBTRACT)
if (underwear < underwear_m.len)
preview_icon.Blend(new /icon('icons/mob/human.dmi', "underwear[underwear]_[g]_s"), ICON_OVERLAY)
if(underwear)
var/datum/sprite_accessory/underwear/U = underwear_all[underwear]
if(U)
preview_icon.Blend(new /icon(U.icon, "[U.icon_state]_s"), ICON_OVERLAY)
var/icon/eyes_s = new/icon("icon" = 'icons/mob/human_face.dmi', "icon_state" = "eyes_s")
eyes_s.Blend(rgb(r_eyes, g_eyes, b_eyes), ICON_ADD)
+163 -30
View File
@@ -16,29 +16,36 @@
from doing this unless you absolutely know what you are doing, and have defined a
conversion in savefile.dm
*/
/proc/init_sprite_accessory_subtypes(prototype, list/L, list/male, list/female)
if(!istype(L)) L = list()
if(!istype(male)) male = list()
if(!istype(female)) female = list()
for(var/path in typesof(prototype))
if(path == prototype) continue
var/datum/sprite_accessory/D = new path()
if(D.icon_state) L[D.name] = D
else L += D.name
switch(D.gender)
if(MALE) male += D.name
if(FEMALE) female += D.name
else
male += D.name
female += D.name
return L
/datum/sprite_accessory
var/icon //the icon file the accessory is located in
var/icon_state //the icon_state of the accessory
var/name //the preview name of the accessory
var/gender = NEUTER //Determines if the accessory will be skipped or included in random hair generations
var/icon // the icon file the accessory is located in
var/icon_state // the icon_state of the accessory
var/preview_state // a custom preview state for whatever reason
var/name // the preview name of the accessory
// Determines if the accessory will be skipped or included in random hair generations
var/gender = NEUTER
/*
////////////////////////////
/ =--------------------= /
/ == Hair Definitions == /
/ =--------------------= /
////////////////////////////
*/
//////////////////////
// Hair Definitions //
//////////////////////
/datum/sprite_accessory/hair
icon = 'icons/mob/human_face.dmi' // default icon for all hairs
short
@@ -263,25 +270,19 @@
bald
name = "Bald"
icon_state = "bald"
icon_state = null
gender = MALE
/*
///////////////////////////////////
/ =---------------------------= /
/ == Facial Hair Definitions == /
/ =---------------------------= /
///////////////////////////////////
*/
/////////////////////////////
// Facial Hair Definitions //
/////////////////////////////
/datum/sprite_accessory/facial_hair
icon = 'icons/mob/human_face.dmi'
gender = MALE // barf (unless you're a dorf, dorfs dig chix /w beards :P)
shaved
name = "Shaved"
icon_state = "bald"
icon_state = null
gender = NEUTER
watson
@@ -347,3 +348,135 @@
dwarf
name = "Dwarf Beard"
icon_state = "facial_dwarf"
///////////////////////////
// Underwear Definitions //
///////////////////////////
/datum/sprite_accessory/underwear
icon = 'icons/mob/underwear.dmi'
nude
name = "Nude"
icon_state = null
gender = NEUTER
male_white
name = "Mens White"
icon_state = "male_white"
gender = MALE
male_grey
name = "Mens Grey"
icon_state = "male_grey"
gender = MALE
male_green
name = "Mens Green"
icon_state = "male_green"
gender = MALE
male_blue
name = "Mens Blue"
icon_state = "male_blue"
gender = MALE
male_black
name = "Mens Black"
icon_state = "male_black"
gender = MALE
male_mankini
name = "Mankini"
icon_state = "male_mankini"
gender = MALE
male_hearts
name = "Mens Hearts Boxer"
icon_state = "male_hearts"
gender = MALE
male_blackalt
name = "Mens Black Boxer"
icon_state = "male_blackalt"
gender = MALE
male_greyalt
name = "Mens Grey Boxer"
icon_state = "male_greyalt"
gender = MALE
male_stripe
name = "Mens Striped Boxer"
icon_state = "male_stripe"
gender = MALE
male_kinky
name = "Mens Kinky"
icon_state = "male_kinky"
gender = MALE
male_red
name = "Mens Red"
icon_state = "male_red"
gender = MALE
female_red
name = "Ladies Red"
icon_state = "female_red"
gender = FEMALE
female_white
name = "Ladies White"
icon_state = "female_white"
gender = FEMALE
female_yellow
name = "Ladies Yellow"
icon_state = "female_yellow"
gender = FEMALE
female_blue
name = "Ladies Blue"
icon_state = "female_blue"
gender = FEMALE
female_black
name = "Ladies Black"
icon_state = "female_black"
gender = FEMALE
female_thong
name = "Ladies Thong"
icon_state = "female_thong"
gender = FEMALE
female_babydoll
name = "Babydoll"
icon_state = "female_babydoll"
gender = FEMALE
female_babyblue
name = "Ladies Baby-Blue"
icon_state = "female_babyblue"
gender = FEMALE
female_green
name = "Ladies Green"
icon_state = "female_green"
gender = FEMALE
female_pink
name = "Ladies Pink"
icon_state = "female_pink"
gender = FEMALE
female_kinky
name = "Ladies Kinky"
icon_state = "female_kinky"
gender = FEMALE
female_tankini
name = "Tankini"
icon_state = "female_tankini"
gender = FEMALE
@@ -66,17 +66,9 @@
new_mob.universal_speak = 1*/
if("human")
new_mob = new /mob/living/carbon/human(M.loc)
if(M.gender == MALE)
new_mob.gender = MALE
new_mob.name = pick(first_names_male)
else
new_mob.gender = FEMALE
new_mob.name = pick(first_names_female)
new_mob.name += " [pick(last_names)]"
new_mob.real_name = new_mob.name
var/datum/preferences/A = new() //Randomize appearance for the human
A.randomize_appearance_for(new_mob)
A.copy_to(new_mob)
var/mob/living/carbon/human/H = new_mob
if(H.dna)
+7 -6
View File
@@ -102,13 +102,14 @@ var/global/sent_strike_team = 0
var/commando_rank = pick("Corporal", "Sergeant", "Staff Sergeant", "Sergeant 1st Class", "Master Sergeant", "Sergeant Major")
var/commando_name = pick(last_names)
new_commando.gender = pick(MALE, FEMALE)
var/datum/preferences/A = new()//Randomize appearance for the commando.
A.randomize_appearance_for(new_commando)
new_commando.real_name = "[!leader_selected ? commando_rank : commando_leader_rank] [commando_name]"
new_commando.age = !leader_selected ? rand(23,35) : rand(35,45)
if(leader_selected)
A.age = rand(35,45)
A.real_name = "[commando_leader_rank] [commando_name]"
else
A.real_name = "[commando_rank] [commando_name]"
A.real_name = "[!leader_selected ? commando_rank :
A.copy_to(new_commando)
new_commando.dna.ready_dna(new_commando)//Creates DNA.
+8 -16
View File
@@ -765,16 +765,8 @@ var/global/datum/tension/tension_master
//First we spawn a dude.
var/mob/living/carbon/human/new_character = new(pick(latejoin))//The mob being spawned.
new_character.gender = pick(MALE,FEMALE)
var/datum/preferences/A = new()
A.randomize_appearance_for(new_character)
if(new_character.gender == MALE)
new_character.real_name = "[pick(first_names_male)] [pick(last_names)]"
else
new_character.real_name = "[pick(first_names_female)] [pick(last_names)]"
new_character.name = new_character.real_name
new_character.age = rand(17,45)
A.copy_to(new_character)
new_character.dna.ready_dna(new_character)
new_character.key = G_found.key
@@ -787,14 +779,14 @@ var/global/datum/tension/tension_master
var/syndicate_commando_rank = pick("Corporal", "Sergeant", "Staff Sergeant", "Sergeant 1st Class", "Master Sergeant", "Sergeant Major")
var/syndicate_commando_name = pick(last_names)
new_syndicate_commando.gender = pick(MALE, FEMALE)
var/datum/preferences/A = new()//Randomize appearance for the commando.
A.randomize_appearance_for(new_syndicate_commando)
new_syndicate_commando.real_name = "[!syndicate_leader_selected ? syndicate_commando_rank : syndicate_commando_leader_rank] [syndicate_commando_name]"
new_syndicate_commando.name = new_syndicate_commando.real_name
new_syndicate_commando.age = !syndicate_leader_selected ? rand(23,35) : rand(35,45)
if(syndicate_leader_selected)
A.real_name = "[syndicate_commando_leader_rank] [syndicate_commando_name]"
A.age = rand(35,45)
else
A.real_name = "[syndicate_commando_rank] [syndicate_commano_name]"
A.copy_to(new_syndicate_commando)
new_syndicate_commando.dna.ready_dna(new_syndicate_commando)//Creates DNA.
+9
View File
@@ -49,6 +49,15 @@ should be listed in the changelog upon commit tho. Thanks. -->
<!-- To take advantage of the pretty new format (well it was new when I wrote this anyway), open the "add-to-changelog.html" file in any browser and add the stuff and then generate the html code and paste it here -->
<div class="commit sansserif">
<h2 class="date">28 March 2013</h2>
<h3 class="author">Carnie updated:</h3>
<ul class="changes bgimages16">
<li class="tweak">Empty character slots in your preferences screen will now randomize. So they won't initialise as bald, diaper-clad, white-guys.</li>
<li class="tweak">Reworked the savefile versioning/updating code. Your preferences data is less likely to be lost.</li>
</ul>
</div>
<div class="commit sansserif">
<h2 class="date">14 March 2013</h2>
<h3 class="author">Major_sephiroth updated:</h3>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 71 KiB