var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-") /datum/preferences var/dress_mob = TRUE /datum/category_item/player_setup_item/general/body name = "Body" sort_order = 3 /datum/category_item/player_setup_item/general/body/load_character(var/savefile/S) S["species"] >> pref.species S["hair_red"] >> pref.r_hair S["hair_green"] >> pref.g_hair S["hair_blue"] >> pref.b_hair S["facial_red"] >> pref.r_facial S["facial_green"] >> pref.g_facial S["facial_blue"] >> pref.b_facial S["skin_tone"] >> pref.s_tone S["skin_red"] >> pref.r_skin S["skin_green"] >> pref.g_skin S["skin_blue"] >> pref.b_skin S["hair_style_name"] >> pref.h_style S["facial_style_name"] >> pref.f_style S["eyes_red"] >> pref.r_eyes S["eyes_green"] >> pref.g_eyes S["eyes_blue"] >> pref.b_eyes S["b_type"] >> pref.b_type S["disabilities"] >> pref.disabilities S["organ_data"] >> pref.organ_data S["rlimb_data"] >> pref.rlimb_data pref.preview_icon = null /datum/category_item/player_setup_item/general/body/save_character(var/savefile/S) S["species"] << pref.species S["hair_red"] << pref.r_hair S["hair_green"] << pref.g_hair S["hair_blue"] << pref.b_hair S["facial_red"] << pref.r_facial S["facial_green"] << pref.g_facial S["facial_blue"] << pref.b_facial S["skin_tone"] << pref.s_tone S["skin_red"] << pref.r_skin S["skin_green"] << pref.g_skin S["skin_blue"] << pref.b_skin S["hair_style_name"] << pref.h_style S["facial_style_name"] << pref.f_style S["eyes_red"] << pref.r_eyes S["eyes_green"] << pref.g_eyes S["eyes_blue"] << pref.b_eyes S["b_type"] << pref.b_type S["disabilities"] << pref.disabilities S["organ_data"] << pref.organ_data S["rlimb_data"] << pref.rlimb_data /datum/category_item/player_setup_item/general/body/sanitize_character(var/savefile/S) if(!pref.species || !(pref.species in playable_species)) pref.species = "Human" pref.r_hair = sanitize_integer(pref.r_hair, 0, 255, initial(pref.r_hair)) pref.g_hair = sanitize_integer(pref.g_hair, 0, 255, initial(pref.g_hair)) pref.b_hair = sanitize_integer(pref.b_hair, 0, 255, initial(pref.b_hair)) pref.r_facial = sanitize_integer(pref.r_facial, 0, 255, initial(pref.r_facial)) pref.g_facial = sanitize_integer(pref.g_facial, 0, 255, initial(pref.g_facial)) pref.b_facial = sanitize_integer(pref.b_facial, 0, 255, initial(pref.b_facial)) pref.s_tone = sanitize_integer(pref.s_tone, -185, 34, initial(pref.s_tone)) pref.r_skin = sanitize_integer(pref.r_skin, 0, 255, initial(pref.r_skin)) pref.g_skin = sanitize_integer(pref.g_skin, 0, 255, initial(pref.g_skin)) pref.b_skin = sanitize_integer(pref.b_skin, 0, 255, initial(pref.b_skin)) pref.h_style = sanitize_inlist(pref.h_style, hair_styles_list, initial(pref.h_style)) pref.f_style = sanitize_inlist(pref.f_style, facial_hair_styles_list, initial(pref.f_style)) pref.r_eyes = sanitize_integer(pref.r_eyes, 0, 255, initial(pref.r_eyes)) pref.g_eyes = sanitize_integer(pref.g_eyes, 0, 255, initial(pref.g_eyes)) pref.b_eyes = sanitize_integer(pref.b_eyes, 0, 255, initial(pref.b_eyes)) pref.b_type = sanitize_text(pref.b_type, initial(pref.b_type)) pref.disabilities = sanitize_integer(pref.disabilities, 0, 65535, initial(pref.disabilities)) if(!pref.organ_data) pref.organ_data = list() if(!pref.rlimb_data) pref.rlimb_data = list() // Moved from /datum/preferences/proc/copy_to() /datum/category_item/player_setup_item/general/body/copy_to_mob(var/mob/living/carbon/human/character) // Copy basic values character.r_eyes = pref.r_eyes character.g_eyes = pref.g_eyes character.b_eyes = pref.b_eyes character.h_style = pref.h_style character.r_hair = pref.r_hair character.g_hair = pref.g_hair character.b_hair = pref.b_hair character.f_style = pref.f_style character.r_facial = pref.r_facial character.g_facial = pref.g_facial character.b_facial = pref.b_facial character.r_skin = pref.r_skin character.g_skin = pref.g_skin character.b_skin = pref.b_skin character.s_tone = pref.s_tone character.h_style = pref.h_style character.f_style = pref.f_style character.b_type = pref.b_type // Destroy/cyborgize organs and limbs. for(var/name in list(BP_HEAD, BP_L_HAND, BP_R_HAND, BP_L_ARM, BP_R_ARM, BP_L_FOOT, BP_R_FOOT, BP_L_LEG, BP_R_LEG, BP_GROIN, BP_TORSO)) var/status = pref.organ_data[name] var/obj/item/organ/external/O = character.organs_by_name[name] if(O) if(status == "amputated") O.remove_rejuv() else if(status == "cyborg") if(pref.rlimb_data[name]) O.robotize(pref.rlimb_data[name]) else O.robotize() for(var/name in list(O_HEART,O_EYES,O_BRAIN)) var/status = pref.organ_data[name] if(!status) continue var/obj/item/organ/I = character.internal_organs_by_name[name] if(I) if(status == "assisted") I.mechassist() else if(status == "mechanical") I.robotize() return /datum/category_item/player_setup_item/general/body/content(var/mob/user) . = list() if(!pref.preview_icon) pref.update_preview_icon() user << browse_rsc(pref.preview_icon, "previewicon.png") var/mob_species = all_species[pref.species] . += "
Body " . += "(®)" . += "
" . += "Species: [pref.species]
" . += "Blood Type: [pref.b_type]
" if(has_flag(mob_species, HAS_SKIN_TONE)) . += "Skin Tone: [-pref.s_tone + 35]/220
" . += "Needs Glasses: [pref.disabilities & NEARSIGHTED ? "Yes" : "No"]
" . += "Limbs: Adjust Reset
" . += "Internal Organs: Adjust
" //display limbs below var/ind = 0 for(var/name in pref.organ_data) var/status = pref.organ_data[name] var/organ_name = null switch(name) if(BP_TORSO) organ_name = "torso" if(BP_GROIN) organ_name = "groin" if(BP_HEAD) organ_name = "head" if(BP_L_ARM) organ_name = "left arm" if(BP_R_ARM) organ_name = "right arm" if(BP_L_LEG) organ_name = "left leg" if(BP_R_LEG) organ_name = "right leg" if(BP_L_FOOT) organ_name = "left foot" if(BP_R_FOOT) organ_name = "right foot" if(BP_L_HAND) organ_name = "left hand" if(BP_R_HAND) organ_name = "right hand" if(O_HEART) organ_name = "heart" if(O_EYES) organ_name = "eyes" if(O_BRAIN) organ_name = "brain" if(status == "cyborg") ++ind if(ind > 1) . += ", " var/datum/robolimb/R if(pref.rlimb_data[name] && all_robolimbs[pref.rlimb_data[name]]) R = all_robolimbs[pref.rlimb_data[name]] else R = basic_robolimb . += "\t[R.company] [organ_name] prosthesis" else if(status == "amputated") ++ind if(ind > 1) . += ", " . += "\tAmputated [organ_name]" else if(status == "mechanical") ++ind if(ind > 1) . += ", " . += "\tSynthetic [organ_name]" else if(status == "assisted") ++ind if(ind > 1) . += ", " switch(organ_name) if("heart") . += "\tPacemaker-assisted [organ_name]" if("voicebox") //on adding voiceboxes for speaking skrell/similar replacements . += "\tSurgically altered [organ_name]" if("eyes") . += "\tRetinal overlayed [organ_name]" if("brain") . += "\tAssisted-interface [organ_name]" else . += "\tMechanically assisted [organ_name]" if(!ind) . += "\[...\]

" else . += "

" . += "
Preview
" . += "
" . += "
[pref.dress_mob ? "Hide equipment" : "Show equipment"]" . += "
" . += "Hair
" if(has_flag(mob_species, HAS_HAIR_COLOR)) . += "Change Color
__
" . += " Style: [pref.h_style]
" . += "
Facial
" if(has_flag(mob_species, HAS_HAIR_COLOR)) . += "Change Color
__
" . += " Style: [pref.f_style]
" if(has_flag(mob_species, HAS_EYE_COLOR)) . += "
Eyes
" . += "Change Color
__

" if(has_flag(mob_species, HAS_SKIN_COLOR)) . += "
Body Color
" . += "Change Color
__

" . = jointext(.,null) /datum/category_item/player_setup_item/general/body/proc/has_flag(var/datum/species/mob_species, var/flag) return mob_species && (mob_species.appearance_flags & flag) /datum/category_item/player_setup_item/general/body/OnTopic(var/href,var/list/href_list, var/mob/user) var/datum/species/mob_species = all_species[pref.species] if(href_list["random"]) pref.randomize_appearance_and_body_for() return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["blood_type"]) var/new_b_type = input(user, "Choose your character's blood-type:", "Character Preference") as null|anything in valid_bloodtypes if(new_b_type && CanUseTopic(user)) pref.b_type = new_b_type return TOPIC_REFRESH else if(href_list["show_species"]) // Actual whitelist checks are handled elsewhere, this is just for accessing the preview window. var/choice = input("Which species would you like to look at?") as null|anything in playable_species if(!choice) return pref.species_preview = choice SetSpecies(preference_mob()) pref.alternate_languages.Cut() // Reset their alternate languages. Todo: attempt to just fix it instead? return TOPIC_HANDLED else if(href_list["set_species"]) user << browse(null, "window=species") if(!pref.species_preview || !(pref.species_preview in all_species)) return TOPIC_NOACTION var/prev_species = pref.species pref.species = href_list["set_species"] if(prev_species != pref.species) if(!(pref.biological_gender in mob_species.genders)) pref.set_biological_gender(mob_species.genders[1]) //grab one of the valid hair styles for the newly chosen species var/list/valid_hairstyles = list() for(var/hairstyle in hair_styles_list) var/datum/sprite_accessory/S = hair_styles_list[hairstyle] if(pref.biological_gender == MALE && S.gender == FEMALE) continue if(pref.biological_gender == FEMALE && S.gender == MALE) continue if(!(pref.species in S.species_allowed)) continue valid_hairstyles[hairstyle] = hair_styles_list[hairstyle] if(valid_hairstyles.len) pref.h_style = pick(valid_hairstyles) else //this shouldn't happen pref.h_style = hair_styles_list["Bald"] //grab one of the valid facial hair styles for the newly chosen species var/list/valid_facialhairstyles = list() for(var/facialhairstyle in facial_hair_styles_list) var/datum/sprite_accessory/S = facial_hair_styles_list[facialhairstyle] if(pref.biological_gender == MALE && S.gender == FEMALE) continue if(pref.biological_gender == FEMALE && S.gender == MALE) continue if(!(pref.species in S.species_allowed)) continue valid_facialhairstyles[facialhairstyle] = facial_hair_styles_list[facialhairstyle] if(valid_facialhairstyles.len) pref.f_style = pick(valid_facialhairstyles) else //this shouldn't happen pref.f_style = facial_hair_styles_list["Shaved"] //reset hair colour and skin colour pref.r_hair = 0//hex2num(copytext(new_hair, 2, 4)) pref.g_hair = 0//hex2num(copytext(new_hair, 4, 6)) pref.b_hair = 0//hex2num(copytext(new_hair, 6, 8)) pref.s_tone = 0 reset_limbs() // Safety for species with incompatible manufacturers; easier than trying to do it case by case. var/datum/species/S = all_species[pref.species] pref.age = max(min(pref.age, S.max_age), S.min_age) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["hair_color"]) if(!has_flag(mob_species, HAS_HAIR_COLOR)) return TOPIC_NOACTION var/new_hair = input(user, "Choose your character's hair colour:", "Character Preference", rgb(pref.r_hair, pref.g_hair, pref.b_hair)) as color|null if(new_hair && has_flag(mob_species, HAS_HAIR_COLOR) && CanUseTopic(user)) pref.r_hair = hex2num(copytext(new_hair, 2, 4)) pref.g_hair = hex2num(copytext(new_hair, 4, 6)) pref.b_hair = hex2num(copytext(new_hair, 6, 8)) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["hair_style"]) var/list/valid_hairstyles = list() for(var/hairstyle in hair_styles_list) var/datum/sprite_accessory/S = hair_styles_list[hairstyle] if(!(pref.species in S.species_allowed)) continue valid_hairstyles[hairstyle] = hair_styles_list[hairstyle] var/new_h_style = input(user, "Choose your character's hair style:", "Character Preference", pref.h_style) as null|anything in valid_hairstyles if(new_h_style && CanUseTopic(user)) pref.h_style = new_h_style return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["facial_color"]) if(!has_flag(mob_species, HAS_HAIR_COLOR)) return TOPIC_NOACTION var/new_facial = input(user, "Choose your character's facial-hair colour:", "Character Preference", rgb(pref.r_facial, pref.g_facial, pref.b_facial)) as color|null if(new_facial && has_flag(mob_species, HAS_HAIR_COLOR) && CanUseTopic(user)) pref.r_facial = hex2num(copytext(new_facial, 2, 4)) pref.g_facial = hex2num(copytext(new_facial, 4, 6)) pref.b_facial = hex2num(copytext(new_facial, 6, 8)) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["eye_color"]) if(!has_flag(mob_species, HAS_EYE_COLOR)) return TOPIC_NOACTION var/new_eyes = input(user, "Choose your character's eye colour:", "Character Preference", rgb(pref.r_eyes, pref.g_eyes, pref.b_eyes)) as color|null if(new_eyes && has_flag(mob_species, HAS_EYE_COLOR) && CanUseTopic(user)) pref.r_eyes = hex2num(copytext(new_eyes, 2, 4)) pref.g_eyes = hex2num(copytext(new_eyes, 4, 6)) pref.b_eyes = hex2num(copytext(new_eyes, 6, 8)) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["skin_tone"]) if(!has_flag(mob_species, HAS_SKIN_TONE)) return TOPIC_NOACTION var/new_s_tone = input(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference", (-pref.s_tone) + 35) as num|null if(new_s_tone && has_flag(mob_species, HAS_SKIN_TONE) && CanUseTopic(user)) pref.s_tone = 35 - max(min( round(new_s_tone), 220),1) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["skin_color"]) if(!has_flag(mob_species, HAS_SKIN_COLOR)) return TOPIC_NOACTION var/new_skin = input(user, "Choose your character's skin colour: ", "Character Preference", rgb(pref.r_skin, pref.g_skin, pref.b_skin)) as color|null if(new_skin && has_flag(mob_species, HAS_SKIN_COLOR) && CanUseTopic(user)) pref.r_skin = hex2num(copytext(new_skin, 2, 4)) pref.g_skin = hex2num(copytext(new_skin, 4, 6)) pref.b_skin = hex2num(copytext(new_skin, 6, 8)) return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["facial_style"]) var/list/valid_facialhairstyles = list() for(var/facialhairstyle in facial_hair_styles_list) var/datum/sprite_accessory/S = facial_hair_styles_list[facialhairstyle] if(pref.biological_gender == MALE && S.gender == FEMALE) continue if(pref.biological_gender == FEMALE && S.gender == MALE) continue if(!(pref.species in S.species_allowed)) continue valid_facialhairstyles[facialhairstyle] = facial_hair_styles_list[facialhairstyle] var/new_f_style = input(user, "Choose your character's facial-hair style:", "Character Preference", pref.f_style) as null|anything in valid_facialhairstyles if(new_f_style && has_flag(mob_species, HAS_HAIR_COLOR) && CanUseTopic(user)) pref.f_style = new_f_style return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["reset_limbs"]) reset_limbs() return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["limbs"]) var/list/limb_selection_list = list("Left Leg","Right Leg","Left Arm","Right Arm","Left Foot","Right Foot","Left Hand","Right Hand","Full Body") // Full prosthetic bodies without a brain are borderline unkillable so make sure they have a brain to remove/destroy. var/datum/species/current_species = all_species[pref.species] if(!current_species.has_organ["brain"]) limb_selection_list -= "Full Body" else if(pref.organ_data[BP_TORSO] == "cyborg") limb_selection_list |= "Head" var/organ_tag = input(user, "Which limb do you want to change?") as null|anything in limb_selection_list if(!organ_tag || !CanUseTopic(user)) return TOPIC_NOACTION var/limb = null var/second_limb = null // if you try to change the arm, the hand should also change var/third_limb = null // if you try to unchange the hand, the arm should also change // Do not let them amputate their entire body, ty. var/list/choice_options = list("Normal","Amputated","Prosthesis") switch(organ_tag) if("Left Leg") limb = BP_L_LEG second_limb = BP_L_FOOT if("Right Leg") limb = BP_R_LEG second_limb = BP_R_FOOT if("Left Arm") limb = BP_L_ARM second_limb = BP_L_HAND if("Right Arm") limb = BP_R_ARM second_limb = BP_R_HAND if("Left Foot") limb = BP_L_FOOT third_limb = BP_L_LEG if("Right Foot") limb = BP_R_FOOT third_limb = BP_R_LEG if("Left Hand") limb = BP_L_HAND third_limb = BP_L_ARM if("Right Hand") limb = BP_R_HAND third_limb = BP_R_ARM if("Head") limb = BP_HEAD choice_options = list("Prosthesis") if("Full Body") limb = BP_TORSO third_limb = BP_GROIN choice_options = list("Normal","Prosthesis") var/new_state = input(user, "What state do you wish the limb to be in?") as null|anything in choice_options if(!new_state || !CanUseTopic(user)) return TOPIC_NOACTION switch(new_state) if("Normal") if(limb == BP_TORSO) for(var/other_limb in BP_ALL - BP_TORSO) pref.organ_data[other_limb] = null pref.rlimb_data[other_limb] = null pref.organ_data[limb] = null pref.rlimb_data[limb] = null if(third_limb) pref.organ_data[third_limb] = null pref.rlimb_data[third_limb] = null if("Amputated") if(limb == BP_TORSO) return pref.organ_data[limb] = "amputated" pref.rlimb_data[limb] = null if(second_limb) pref.organ_data[second_limb] = "amputated" pref.rlimb_data[second_limb] = null if("Prosthesis") var/tmp_species = pref.species ? pref.species : "Human" var/list/usable_manufacturers = list() for(var/company in chargen_robolimbs) var/datum/robolimb/M = chargen_robolimbs[company] if(!(limb in M.parts)) continue if(tmp_species in M.species_cannot_use) continue usable_manufacturers[company] = M if(!usable_manufacturers.len) return var/choice = input(user, "Which manufacturer do you wish to use for this limb?") as null|anything in usable_manufacturers if(!choice) return pref.rlimb_data[limb] = choice pref.organ_data[limb] = "cyborg" if(second_limb) pref.rlimb_data[second_limb] = choice pref.organ_data[second_limb] = "cyborg" if(third_limb && pref.organ_data[third_limb] == "amputated") pref.organ_data[third_limb] = null if(limb == BP_TORSO) for(var/other_limb in BP_ALL - BP_TORSO) if(pref.organ_data[other_limb]) continue pref.organ_data[other_limb] = "cyborg" pref.rlimb_data[other_limb] = choice if(!pref.organ_data[O_BRAIN]) pref.organ_data[O_BRAIN] = "assisted" for(var/internal_organ in list(O_HEART,O_EYES)) pref.organ_data[internal_organ] = "mechanical" return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["organs"]) var/organ_name = input(user, "Which internal function do you want to change?") as null|anything in list("Heart", "Eyes", "Brain") if(!organ_name) return var/organ = null switch(organ_name) if("Heart") organ = O_HEART if("Eyes") organ = O_EYES if("Brain") if(pref.organ_data[BP_HEAD] != "cyborg") user << "You may only select an assisted or synthetic brain if you have a full prosthetic body." return organ = "brain" var/list/organ_choices = list("Normal","Assisted","Mechanical") if(pref.organ_data[BP_TORSO] == "cyborg") organ_choices -= "Normal" var/new_state = input(user, "What state do you wish the organ to be in?") as null|anything in organ_choices if(!new_state) return switch(new_state) if("Normal") pref.organ_data[organ] = null if("Assisted") pref.organ_data[organ] = "assisted" if("Mechanical") pref.organ_data[organ] = "mechanical" return TOPIC_REFRESH else if(href_list["disabilities"]) var/disability_flag = text2num(href_list["disabilities"]) pref.disabilities ^= disability_flag return TOPIC_REFRESH_UPDATE_PREVIEW else if(href_list["toggle_clothing"]) pref.dress_mob = !pref.dress_mob return TOPIC_REFRESH_UPDATE_PREVIEW return ..() /datum/category_item/player_setup_item/general/body/proc/reset_limbs() for(var/organ in pref.organ_data) pref.organ_data[organ] = null while(null in pref.organ_data) pref.organ_data -= null for(var/organ in pref.rlimb_data) pref.rlimb_data[organ] = null while(null in pref.rlimb_data) pref.rlimb_data -= null /datum/category_item/player_setup_item/general/body/proc/SetSpecies(mob/user) if(!pref.species_preview || !(pref.species_preview in all_species)) pref.species_preview = "Human" var/datum/species/current_species = all_species[pref.species_preview] var/dat = "" dat += "

[current_species.name] \[change\]


" dat += "" dat += "" dat += "" dat += "" dat += "" dat += "
[current_species.blurb]" if("preview" in icon_states(current_species.icobase)) usr << browse_rsc(icon(current_species.icobase,"preview"), "species_preview_[current_species.name].png") dat += "

" dat += "Language: [current_species.language]
" dat += "" if(current_species.spawn_flags & SPECIES_CAN_JOIN) dat += "
Often present on human stations." if(current_species.spawn_flags & SPECIES_IS_WHITELISTED) dat += "
Whitelist restricted." if(!current_species.has_organ[O_HEART]) dat += "
Does not have a circulatory system." if(!current_species.has_organ[O_LUNGS]) dat += "
Does not have a respiratory system." if(current_species.flags & NO_SCAN) dat += "
Does not have DNA." if(current_species.flags & NO_PAIN) dat += "
Does not feel pain." if(current_species.flags & NO_SLIP) dat += "
Has excellent traction." if(current_species.flags & NO_POISON) dat += "
Immune to most poisons." if(current_species.appearance_flags & HAS_SKIN_TONE) dat += "
Has a variety of skin tones." if(current_species.appearance_flags & HAS_SKIN_COLOR) dat += "
Has a variety of skin colours." if(current_species.appearance_flags & HAS_EYE_COLOR) dat += "
Has a variety of eye colours." if(current_species.flags & IS_PLANT) dat += "
Has a plantlike physiology." dat += "

" var/restricted = 0 if(config.usealienwhitelist) //If we're using the whitelist, make sure to check it! if(!(current_species.spawn_flags & SPECIES_CAN_JOIN)) restricted = 2 else if((current_species.spawn_flags & SPECIES_IS_WHITELISTED) && !is_alien_whitelisted(preference_mob(),current_species)) restricted = 1 if(restricted) if(restricted == 1) dat += "You cannot play as this species.
If you wish to be whitelisted, you can make an application post on the forums.

" else if(restricted == 2) dat += "You cannot play as this species.
This species is not available for play as a station race..

" if(!restricted || check_rights(R_ADMIN, 0)) dat += "\[select\]" dat += "
" user << browse(dat, "window=species;size=700x400")