From 88fd7c44cc9b4e2c3583cd55f0866e6a3e230e5f Mon Sep 17 00:00:00 2001 From: phil235 Date: Thu, 23 Apr 2015 23:18:35 +0200 Subject: [PATCH] Changes clown/mime naming to use preferences. Player will now choose their mime/clown name in the main preference screen and save it, instead of at roundstart. Adding a config file for random mime names. --- code/__HELPERS/unsorted.dm | 77 ++++++++++++++------- code/_globalvars/lists/names.dm | 1 + code/modules/client/preferences.dm | 24 ++++++- code/modules/client/preferences_savefile.dm | 4 ++ config/names/mime.txt | 24 +++++++ 5 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 config/names/mime.txt diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 0b5b128540a..2a460de2215 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -362,43 +362,72 @@ Turf and target are seperate in case you want to teleport some distance from a t //Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame() -//Last modified by Carn + /mob/proc/rename_self(var/role, var/allow_numbers=0) - spawn(0) - var/oldname = real_name + var/oldname = real_name + var/time_passed = world.time + var/newname + var/loop = 1 + var/loop_safety = 0 - var/time_passed = world.time - var/newname + if(role == "clown" || role == "mime") + while(loop && loop_safety < 5) + if(role == "clown") + if(client && client.prefs.clown_name && !loop_safety) + newname = client.prefs.clown_name + else + newname = pick(clown_names) - for(var/i=1,i<=3,i++) //we get 3 attempts to pick a suitable name. - newname = input(src,"You are a [role]. Would you like to change your name to something else?", "Name change",oldname) as text - if((world.time-time_passed)>300) - return //took too long - newname = reject_bad_name(newname,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters. + if(role == "mime") + if(client && client.prefs.mime_name && !loop_safety) + newname = client.prefs.mime_name + else + newname = pick(mime_names) for(var/mob/living/M in player_list) if(M == src) continue if(!newname || M.real_name == newname) - newname = null + loop++ // name is already taken so we roll again break - if(newname) - break //That's a suitable name! - src << "Sorry, that [role]-name wasn't appropriate, please try another. It's possibly too long/short, has bad characters or is already taken." + loop-- + loop_safety++ - if(!newname) //we'll stick with the oldname then - return + if(newname) + fully_replace_character_name(oldname,newname) + return - if(cmptext("ai",role)) - if(isAI(src)) - oldname = null//don't bother with the records update crap + else + spawn(0) + for(var/i=1,i<=3,i++) //we get 3 attempts to pick a suitable name. + newname = input(src,"You are a [role]. Would you like to change your name to something else?", "Name change",oldname) as text + if((world.time-time_passed)>300) + return //took too long + newname = reject_bad_name(newname,allow_numbers) //returns null if the name doesn't meet some basic requirements. Tidies up a few other things like bad-characters. - if(cmptext("cyborg",role)) - if(isrobot(src)) - var/mob/living/silicon/robot/A = src - A.custom_name = newname + for(var/mob/living/M in player_list) + if(M == src) + continue + if(!newname || M.real_name == newname) + newname = null + break + if(newname) + break //That's a suitable name! + src << "Sorry, that [role]-name wasn't appropriate, please try another. It's possibly too long/short, has bad characters or is already taken." - fully_replace_character_name(oldname,newname) + if(!newname) //we'll stick with the oldname then + return + + if(cmptext("ai",role)) + if(isAI(src)) + oldname = null//don't bother with the records update crap + + if(cmptext("cyborg",role)) + if(isrobot(src)) + var/mob/living/silicon/robot/A = src + A.custom_name = newname + + fully_replace_character_name(oldname,newname) diff --git a/code/_globalvars/lists/names.dm b/code/_globalvars/lists/names.dm index ab101d76c6e..edaa74eab14 100644 --- a/code/_globalvars/lists/names.dm +++ b/code/_globalvars/lists/names.dm @@ -8,6 +8,7 @@ var/list/first_names_male = file2list("config/names/first_male.txt") var/list/first_names_female = file2list("config/names/first_female.txt") var/list/last_names = file2list("config/names/last.txt") var/list/clown_names = file2list("config/names/clown.txt") +var/list/mime_names = file2list("config/names/mime.txt") var/list/verbs = file2list("config/names/verbs.txt") diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 8c058c98459..90880ed484d 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -60,6 +60,8 @@ datum/preferences var/eye_color = "000" //Eye color var/datum/species/pref_species = new /datum/species/human() //Mutant race var/mutant_color = "FFF" //Mutant race skin color + var/clown_name = "Bozo" + var/mime_name = "Mime" //Mob preview var/icon/preview_icon_front = null @@ -92,6 +94,8 @@ datum/preferences /datum/preferences/New(client/C) blood_type = random_blood_type() ooccolor = normal_ooc_colour + clown_name = pick(clown_names) + mime_name = pick(mime_names) if(istype(C)) if(!IsGuestKey(C.key)) load_path(C.ckey) @@ -233,6 +237,10 @@ datum/preferences dat += "" + dat += "

Special Names:

" + dat += "Clown: [clown_name]
" + dat += "Mime: [mime_name]
" + dat += "" @@ -302,7 +310,7 @@ datum/preferences dat += "" //user << browse(dat, "window=preferences;size=560x560") - var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 640, 680) + var/datum/browser/popup = new(user, "preferences", "
Character Setup
", 640, 720) popup.set_content(dat) popup.open(0) @@ -753,6 +761,20 @@ datum/preferences var/new_backbag = input(user, "Choose your character's style of bag:", "Character Preference") as null|anything in backbaglist if(new_backbag) backbag = backbaglist.Find(new_backbag) + if("clown_name") + var/new_clown_name = reject_bad_name( input(user, "Choose your character's clown name:", "Character Preference") as text|null ) + if(new_clown_name) + clown_name = new_clown_name + else + user << "Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ." + + if("mime_name") + var/new_mime_name = reject_bad_name( input(user, "Choose your character's mime name:", "Character Preference") as text|null ) + if(new_mime_name) + mime_name = new_mime_name + else + user << "Invalid name. Your name should be at least 2 and at most [MAX_NAME_LEN] characters long. It may only contain the characters A-Z, a-z, -, ' and ." + else switch(href_list["preference"]) if("publicity") diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 604bbd57069..c80790dca4f 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -187,6 +187,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["socks"] >> socks S["backbag"] >> backbag S["mutant_color"] >> mutant_color + S["clown_name"] >> clown_name + S["mime_name"] >> mime_name //Jobs S["userandomjob"] >> userandomjob @@ -274,6 +276,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car S["backbag"] << backbag S["species"] << pref_species.name S["mutant_color"] << mutant_color + S["clown_name"] << clown_name + S["mime_name"] << mime_name //Jobs S["userandomjob"] << userandomjob diff --git a/config/names/mime.txt b/config/names/mime.txt new file mode 100644 index 00000000000..14845a89b40 --- /dev/null +++ b/config/names/mime.txt @@ -0,0 +1,24 @@ +Mr. Beret +Mime +Mr. Mime +Mr. Mute +Silence +Silencio +Quiet +Silent Sorrow +Silent Knight +Silent Night +Untouchable +Unspeakable +Mute +Marcel Mime +Marcel +Pantomime +Omerta +Lemon Mime +Invisible Man +Transparency +Quiet Riot +Silent Majority +Wall Runner +Oui Oui \ No newline at end of file