" // Table within a table for alignment, also allows you to easily add more colomns.
HTML += ""
var/index = -1
//The job before the current job. I only use this to get the previous jobs color when I'm filling in blank rows.
var/datum/job/lastJob
for(var/datum/job/job in job_master.occupations)
index += 1
if((index >= limit) || (job.title in splitJobs))
if((index < limit) && (lastJob != null))
//If the cells were broken up by a job in the splitJob list then it will fill in the rest of the cells with
//the last job's selection color. Creating a rather nice effect.
for(var/i = 0, i < (limit - index), i += 1)
HTML += "|   |   | "
HTML += " | "
index = 0
HTML += "| "
var/rank = job.title
lastJob = job
if(jobban_isbanned(user, rank))
HTML += "[rank] | \[BANNED] | "
continue
if((job_civilian_low & ASSISTANT) && (rank != "Assistant"))
HTML += "[rank] | "
continue
if((rank in command_positions) || (rank == "AI"))//Bold head jobs
HTML += "[rank]"
else
HTML += "[rank]"
HTML += ""
HTML += ""
if(rank == "Assistant")//Assistant is special
if(job_civilian_low & ASSISTANT)
HTML += " \[Yes]"
else
HTML += " \[No]"
HTML += " | "
continue
if(GetJobDepartment(job, 1) & job.flag)
HTML += " \[High]"
else if(GetJobDepartment(job, 2) & job.flag)
HTML += " \[Medium]"
else if(GetJobDepartment(job, 3) & job.flag)
HTML += " \[Low]"
else
HTML += " \[NEVER]"
HTML += ""
HTML += "|
"
HTML += ""
user << browse(null, "window=preferences")
user << browse(HTML, "window=mob_occupation;size=[width]x[height]")
return
proc/SetJob(mob/user, role)
var/datum/job/job = job_master.GetJob(role)
if(!job)
user << browse(null, "window=mob_occupation")
ShowChoices(user)
return
if(role == "Assistant")
if(job_civilian_low & job.flag)
job_civilian_low &= ~job.flag
else
job_civilian_low |= job.flag
SetChoices(user)
return 1
if(GetJobDepartment(job, 1) & job.flag)
SetJobDepartment(job, 1)
else if(GetJobDepartment(job, 2) & job.flag)
SetJobDepartment(job, 2)
else if(GetJobDepartment(job, 3) & job.flag)
SetJobDepartment(job, 3)
else//job = Never
SetJobDepartment(job, 4)
SetChoices(user)
return 1
proc/GetJobDepartment(var/datum/job/job, var/level)
if(!job || !level) return 0
switch(job.department_flag)
if(CIVILIAN)
switch(level)
if(1)
return job_civilian_high
if(2)
return job_civilian_med
if(3)
return job_civilian_low
if(MEDSCI)
switch(level)
if(1)
return job_medsci_high
if(2)
return job_medsci_med
if(3)
return job_medsci_low
if(ENGSEC)
switch(level)
if(1)
return job_engsec_high
if(2)
return job_engsec_med
if(3)
return job_engsec_low
return 0
proc/SetJobDepartment(var/datum/job/job, var/level)
if(!job || !level) return 0
switch(level)
if(1)//Only one of these should ever be active at once so clear them all here
job_civilian_high = 0
job_medsci_high = 0
job_engsec_high = 0
return 1
if(2)//Set current highs to med, then reset them
job_civilian_med |= job_civilian_high
job_medsci_med |= job_medsci_high
job_engsec_med |= job_engsec_high
job_civilian_high = 0
job_medsci_high = 0
job_engsec_high = 0
switch(job.department_flag)
if(CIVILIAN)
switch(level)
if(2)
job_civilian_high = job.flag
job_civilian_med &= ~job.flag
if(3)
job_civilian_med |= job.flag
job_civilian_low &= ~job.flag
else
job_civilian_low |= job.flag
if(MEDSCI)
switch(level)
if(2)
job_medsci_high = job.flag
job_medsci_med &= ~job.flag
if(3)
job_medsci_med |= job.flag
job_medsci_low &= ~job.flag
else
job_medsci_low |= job.flag
if(ENGSEC)
switch(level)
if(2)
job_engsec_high = job.flag
job_engsec_med &= ~job.flag
if(3)
job_engsec_med |= job.flag
job_engsec_low &= ~job.flag
else
job_engsec_low |= job.flag
return 1
proc/process_link(mob/user, list/link_tags)
if(!usr)
return
if(link_tags["occ"])
if(link_tags["cancel"])
user << browse(null, "window=\ref[user]occupation")
return
else if(link_tags["job"])
SetJob(user, link_tags["job"])
else
if(job_master)
SetChoices(user)
return 1
if(link_tags["real_name"])
var/new_name
switch(link_tags["real_name"])
if("input")
new_name = copytext( (input(user, "Please select a name:", "Character Generation") as text) ,1,MAX_NAME_LEN)
var/list/bad_characters = list("_", "\"", "<", ">", ";", "\[", "\]", "{", "}", "|", "\\","0","1","2","3","4","5","6","7","8","9")
for(var/c in bad_characters)
new_name = dd_replacetext(new_name, c, "")
if(!new_name || (new_name == "Unknown") || (new_name == "floor") || (new_name == "wall") || (new_name == "r-wall"))
alert("Invalid name. Don't do that!")
return
//Carn: To fix BYOND text-parsing errors caused by people using dumb capitalisation in their names.
var/tempname
for(var/N in dd_text2list(new_name, " "))
if(N && tempname) //if both aren't null strings
tempname += " "
tempname += capitalize(lowertext(N))
new_name = tempname
if("random")
randomize_name()
if(new_name)
real_name = new_name
if(link_tags["age"])
switch(link_tags["age"])
if("input")
var/new_age = input(user, "Please select type in age: 15-45", "Character Generation") as num
if(new_age)
age = max(min(round(text2num(new_age)), 45), 15)
if("random")
age = rand (20, 45)
if(link_tags["OOC"])
var/tempnote = ""
tempnote = copytext(sanitize(input(user, "Please enter your OOC Notes!:", "OOC notes" , metadata) as text),1,MAX_MESSAGE_LEN)
if(tempnote)
metadata = tempnote
return
if(link_tags["b_type"])
switch(link_tags["b_type"])
if("input")
var/new_b_type = input(user, "Please select a blood type:", "Character Generation") as null|anything in list( "A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-" )
if(new_b_type)
b_type = new_b_type
if("random")
b_type = pickweight ( list ("A+" = 31, "A-" = 7, "B+" = 8, "B-" = 2, "AB+" = 2, "AB-" = 1, "O+" = 40, "O-" = 9))
if(link_tags["hair"])
switch(link_tags["hair"])
if("input")
var/new_hair = input(user, "Please select hair color.", "Character Generation") as color
if(new_hair)
r_hair = hex2num(copytext(new_hair, 2, 4))
g_hair = hex2num(copytext(new_hair, 4, 6))
b_hair = hex2num(copytext(new_hair, 6, 8))
if("random")
randomize_hair_color("hair")
if(link_tags["facial"])
switch(link_tags["facial"])
if("input")
var/new_facial = input(user, "Please select facial hair color.", "Character Generation") as color
if(new_facial)
r_facial = hex2num(copytext(new_facial, 2, 4))
g_facial = hex2num(copytext(new_facial, 4, 6))
b_facial = hex2num(copytext(new_facial, 6, 8))
if("random")
randomize_hair_color("facial")
if(link_tags["eyes"])
switch(link_tags["eyes"])
if("input")
var/new_eyes = input(user, "Please select eye color.", "Character Generation") as color
if(new_eyes)
r_eyes = hex2num(copytext(new_eyes, 2, 4))
g_eyes = hex2num(copytext(new_eyes, 4, 6))
b_eyes = hex2num(copytext(new_eyes, 6, 8))
if("random")
randomize_eyes_color()
if(link_tags["s_tone"])
switch(link_tags["s_tone"])
if("random")
randomize_skin_tone()
if("input")
var/new_tone = input(user, "Please select skin tone level: 1-220 (1=albino, 35=caucasian, 150=black, 220='very' black)", "Character Generation") as num
if(new_tone)
s_tone = max(min(round(new_tone), 220), 1)
s_tone = -s_tone + 35
if(link_tags["h_style"])
switch(link_tags["h_style"])
// New and improved hair selection code, by Doohl
if("random") // random hair selection
randomize_hair(gender) // call randomize_hair() proc with var/gender parameter
// see preferences_setup.dm for proc
if("input") // input hair selection
// Generate list of hairs via typesof()
var/list/all_hairs = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
// List of hair names
var/list/hairs = list()
// loop through potential hairs
for(var/x in all_hairs)
var/datum/sprite_accessory/hair/H = new x // create new hair datum based on type x
hairs.Add(H.name) // add hair name to hairs
del(H) // delete the hair after it's all done
// prompt the user for a hair selection, the selection being anything in list hairs
var/new_style = input(user, "Select a hair style", "Character Generation") as null|anything in hairs
// if new style selected (not cancel)
if(new_style)
h_style = new_style
for(var/x in all_hairs) // loop through all_hairs again. Might be slightly CPU expensive, but not significantly.
var/datum/sprite_accessory/hair/H = new x // create new hair datum
if(H.name == new_style)
hair_style = H // assign the hair_style variable a new hair datum
break
else
del(H) // if hair H not used, delete. BYOND can garbage collect, but better safe than sorry
if(link_tags["ooccolor"])
var/ooccolor = input(user, "Please select OOC colour.", "OOC colour") as color
if(ooccolor)
src.ooccolor = ooccolor
if(link_tags["toggleadminhelpsound"])
src.sound_adminhelp = !src.sound_adminhelp
if(link_tags["f_style"])
switch(link_tags["f_style"])
// see above for commentation. This is just a slight modification of the hair code for facial hairs
if("random")
randomize_facial(gender)
if("input")
var/list/all_fhairs = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
var/list/fhairs = list()
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/H = new x
fhairs.Add(H.name)
del(H)
var/new_style = input(user, "Select a facial hair style", "Character Generation") as null|anything in fhairs
if(new_style)
f_style = new_style
for(var/x in all_fhairs)
var/datum/sprite_accessory/facial_hair/H = new x
if(H.name == new_style)
facial_hair_style = H
break
else
del(H)
if(link_tags["gender"])
if(gender == MALE)
gender = FEMALE
else
gender = MALE
if(link_tags["UI"])
switch(UI_style)
if("Midnight")
UI_style = "Orange"
if("Orange")
UI_style = "old"
if("old")
UI_style = "Midnight"
else
UI_style = "Midnight"
if(link_tags["midis"])
midis = !midis
if(link_tags["ghost_ears"])
ghost_ears = !ghost_ears
if(link_tags["ghost_sight"])
ghost_sight = !ghost_sight
if(link_tags["underwear"])
switch(link_tags["underwear"])
if("inputmale")
var/tempUnderwear = input(user, "Please select your underwear colour:", "Character Generation") as null|anything in underwear_m
if(tempUnderwear)
underwear = underwear_m.Find(tempUnderwear)
if("inputfemale")
var/tempUnderwear = input(user, "Please select your underwear colour:", "Character Generation") as null|anything in underwear_f
if(tempUnderwear)
underwear = underwear_f.Find(tempUnderwear)
if("random")
if(prob (75))
underwear = pick(1,2,3,4,5)
else
underwear = 6
if(link_tags["backbag_type"])
switch(link_tags["backbag_type"])
if("input")
var/tempBag = input(user, "Please pick a backpack type:", "Character Generation") as null|anything in backbaglist
if(tempBag)
backbag = backbaglist.Find(tempBag)
if("random")
backbag = pick(1,2,3)
if(link_tags["be_special"])
src.be_special^=(1< 6 || 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
character.update_face()
character.update_body()
if(!safety)//To prevent run-time errors due to null datum when using randomize_appearance_for()
spawn(10)
if(character&&character.client)
setup_client(character.client)
proc/copy_to_observer(mob/dead/observer/character)
spawn(10)
if(character && character.client)
setup_client(character.client)
proc/setup_client(var/client/C)
if(C)
C.sound_adminhelp = src.sound_adminhelp
C.midis = src.midis
C.ooccolor = src.ooccolor
C.be_alien = be_special & BE_ALIEN
C.be_pai = be_special & BE_PAI
if(isnull(src.ghost_ears)) src.ghost_ears = 1 //There were problems where the default was null before someone saved their profile.
C.ghost_ears = src.ghost_ears
C.ghost_sight = src.ghost_sight
#undef UI_OLD
#undef UI_NEW
|