Fixes Morph Being Borked + Additional Features for Morph and C.M.A.

Before it wouldn't update skin colour or eye colour, and ended up breaking the sprite such that C.M.A wouldn't have an effect on it after.

Now it works perfectly fine, C.M.A works just fine too before and after

STAGE 2: Refactors Morph

So you change gender first and thus can actually access male beard styles, then you choose hair style and hair colour, then beard style and beard colour, then skin tone or body colour at the very end.

STAGE 3
Adds Head Accessory, Head Accessory colour, marking style and body accessory to Morph and C.M.A.
This commit is contained in:
KasparoVy
2016-05-03 01:50:16 -04:00
parent 8cca627918
commit 9015f11f41
7 changed files with 350 additions and 66 deletions
+5 -1
View File
@@ -76,7 +76,11 @@
#define APPEARANCE_FACIAL_HAIR_COLOR 128
#define APPEARANCE_EYE_COLOR 256
#define APPEARANCE_ALL_HAIR APPEARANCE_HAIR|APPEARANCE_HAIR_COLOR|APPEARANCE_FACIAL_HAIR|APPEARANCE_FACIAL_HAIR_COLOR
#define APPEARANCE_ALL 511
#define APPEARANCE_HEAD_ACCESSORY 512
#define APPEARANCE_MARKINGS 1024
#define APPEARANCE_BODY_ACCESSORY 2048
#define APPEARANCE_ALL_BODY APPEARANCE_ALL_HAIR|APPEARANCE_HEAD_ACCESSORY|APPEARANCE_MARKINGS|APPEARANCE_BODY_ACCESSORY
#define APPEARANCE_ALL 4095
// Intents
#define I_HELP "help"
+86 -56
View File
@@ -39,69 +39,99 @@
var/mob/living/carbon/human/M=usr
var/obj/item/organ/external/head/head_organ = M.get_organ("head")
var/new_facial = input("Please select facial hair color.", "Character Generation",rgb(head_organ.r_facial, head_organ.g_facial, head_organ.b_facial)) as null|color
if(new_facial)
head_organ.r_facial = hex2num(copytext(new_facial, 2, 4))
head_organ.g_facial = hex2num(copytext(new_facial, 4, 6))
head_organ.b_facial = hex2num(copytext(new_facial, 6, 8))
var/new_hair = input("Please select hair color.", "Character Generation",rgb(head_organ.r_hair, head_organ.g_hair, head_organ.b_hair)) as null|color
if(new_facial)
head_organ.r_hair = hex2num(copytext(new_hair, 2, 4))
head_organ.g_hair = hex2num(copytext(new_hair, 4, 6))
head_organ.b_hair = hex2num(copytext(new_hair, 6, 8))
var/new_eyes = input("Please select eye color.", "Character Generation",rgb(M.r_eyes,M.g_eyes,M.b_eyes)) as null|color
if(new_eyes)
M.r_eyes = hex2num(copytext(new_eyes, 2, 4))
M.g_eyes = hex2num(copytext(new_eyes, 4, 6))
M.b_eyes = hex2num(copytext(new_eyes, 6, 8))
var/new_tone = input("Please select skin tone level: 1-220 (1=albino, 35=caucasian, 150=black, 220='very' black)", "Character Generation", "[35-M.s_tone]") as null|text
if (!new_tone)
new_tone = 35
M.s_tone = max(min(round(text2num(new_tone)), 220), 1)
M.s_tone = -M.s_tone + 35
// hair
var/list/all_hairs = subtypesof(/datum/sprite_accessory/hair)
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
qdel(H) // delete the hair after it's all done
var/new_style = input("Please select hair style", "Character Generation", head_organ.h_style) as null|anything in hairs
// if new style selected (not cancel)
if (new_style)
head_organ.h_style = new_style
// facial hair
var/list/all_fhairs = subtypesof(/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)
qdel(H)
new_style = input("Please select facial style", "Character Generation", head_organ.f_style) as null|anything in fhairs
if(new_style)
head_organ.f_style = new_style
var/new_gender = alert(usr, "Please select gender.", "Character Generation", "Male", "Female")
if (new_gender)
if(new_gender == "Male")
M.change_gender(MALE)
else
M.change_gender(FEMALE)
var/new_eyes = input("Please select eye color.", "Character Generation", rgb(M.r_eyes,M.g_eyes,M.b_eyes)) as null|color
if(new_eyes)
M.r_eyes = hex2num(copytext(new_eyes, 2, 4))
M.g_eyes = hex2num(copytext(new_eyes, 4, 6))
M.b_eyes = hex2num(copytext(new_eyes, 6, 8))
M.change_eye_color(M.r_eyes, M.g_eyes, M.b_eyes)
// hair
var/list/valid_hairstyles = M.generate_valid_hairstyles()
var/new_style = input("Please select hair style", "Character Generation", head_organ.h_style) as null|anything in valid_hairstyles
// if new style selected (not cancel)
if (new_style)
head_organ.h_style = new_style
var/new_hair = input("Please select hair color.", "Character Generation", rgb(head_organ.r_hair, head_organ.g_hair, head_organ.b_hair)) as null|color
if(new_hair)
head_organ.r_hair = hex2num(copytext(new_hair, 2, 4))
head_organ.g_hair = hex2num(copytext(new_hair, 4, 6))
head_organ.b_hair = hex2num(copytext(new_hair, 6, 8))
// facial hair
var/list/valid_facial_hairstyles = M.generate_valid_facial_hairstyles()
new_style = input("Please select facial style", "Character Generation", head_organ.f_style) as null|anything in valid_facial_hairstyles
if(new_style)
head_organ.f_style = new_style
var/new_facial = input("Please select facial hair color.", "Character Generation", rgb(head_organ.r_facial, head_organ.g_facial, head_organ.b_facial)) as null|color
if(new_facial)
head_organ.r_facial = hex2num(copytext(new_facial, 2, 4))
head_organ.g_facial = hex2num(copytext(new_facial, 4, 6))
head_organ.b_facial = hex2num(copytext(new_facial, 6, 8))
//Head accessory.
if(head_organ.species.bodyflags & HAS_HEAD_ACCESSORY)
var/list/valid_head_accessories = M.generate_valid_head_accessories()
var/new_head_accessory = input("Please select head accessory style", "Character Generation", head_organ.ha_style) as null|anything in valid_head_accessories
if(new_head_accessory)
head_organ.ha_style = new_head_accessory
var/new_head_accessory_colour = input("Please select head accessory colour.", "Character Generation", rgb(head_organ.r_headacc, head_organ.g_headacc, head_organ.b_headacc)) as null|color
if(new_head_accessory_colour)
head_organ.r_headacc = hex2num(copytext(new_head_accessory_colour, 2, 4))
head_organ.g_headacc = hex2num(copytext(new_head_accessory_colour, 4, 6))
head_organ.b_headacc = hex2num(copytext(new_head_accessory_colour, 6, 8))
//Body markings.
if(M.species.bodyflags & HAS_MARKINGS)
var/list/valid_markings = M.generate_valid_markings()
var/new_marking = input("Please select marking style", "Character Generation", M.m_style) as null|anything in valid_markings
if(new_marking)
M.m_style = new_marking
var/new_marking_colour = input("Please select marking colour.", "Character Generation", rgb(M.r_markings, M.g_markings, M.b_markings)) as null|color
if(new_marking_colour)
M.r_markings = hex2num(copytext(new_marking_colour, 2, 4))
M.g_markings = hex2num(copytext(new_marking_colour, 4, 6))
M.b_markings = hex2num(copytext(new_marking_colour, 6, 8))
//Body accessory.
if(M.species.tail && M.species.bodyflags & HAS_TAIL)
var/list/valid_body_accessories = M.generate_valid_body_accessories()
if(valid_body_accessories.len > 1) //By default valid_body_accessories will always have at the very least a 'none' entry populating the list, even if the user's species is not present in any of the list items.
var/new_body_accessory = input("Please select body accessory style", "Character Generation", M.body_accessory) as null|anything in valid_body_accessories
if(new_body_accessory)
M.body_accessory = body_accessory_by_name[new_body_accessory]
//Skin tone.
if(M.species.bodyflags & HAS_SKIN_TONE)
var/new_tone = input("Please select skin tone level: 1-220 (1=albino, 35=caucasian, 150=black, 220='very' black)", "Character Generation", "[M.s_tone]") as null|text
if (!new_tone)
new_tone = 35
M.s_tone = 35 - max(min(round(text2num(new_tone)), 220), 1)
//Skin colour.
if(M.species.bodyflags & HAS_SKIN_COLOR)
var/new_body_colour = input("Please select body colour.", "Character Generation", rgb(M.r_skin, M.g_skin, M.b_skin)) as null|color
if(new_body_colour)
M.r_skin = hex2num(copytext(new_body_colour, 2, 4))
M.g_skin = hex2num(copytext(new_body_colour, 4, 6))
M.b_skin = hex2num(copytext(new_body_colour, 6, 8))
M.force_update_limbs()
M.regenerate_icons()
M.check_dna()
M.update_dna()
M.visible_message("\blue \The [src] morphs and changes [M.get_visible_gender() == MALE ? "his" : M.get_visible_gender() == FEMALE ? "her" : "their"] appearance!", "\blue You change your appearance!", "\red Oh, god! What the hell was that? It sounded like flesh getting squished and bone ground into a different shape!")
+1
View File
@@ -17,6 +17,7 @@
if(!AC)
AC = new(src, user)
AC.name = "SalonPro Nano-Mirror™"
AC.flags = APPEARANCE_ALL_BODY
ui_users[user] = AC
AC.ui_interact(user)
@@ -70,6 +70,57 @@
update_fhair()
return 1
/mob/living/carbon/human/proc/change_head_accessory(var/head_accessory_style)
var/obj/item/organ/external/head/H = get_organ("head")
if(!head_accessory_style)
return
if(H.ha_style == head_accessory_style)
return
if(!(head_accessory_style in head_accessory_styles_list))
return
H.ha_style = head_accessory_style
update_head_accessory()
return 1
/mob/living/carbon/human/proc/change_markings(var/marking_style)
if(!marking_style)
return
if(src.m_style == marking_style)
return
if(!(marking_style in marking_styles_list))
return
src.m_style = marking_style
update_markings()
return 1
/mob/living/carbon/human/proc/change_body_accessory(var/body_accessory_style)
var/found
if(!body_accessory_style)
return
if(src.body_accessory)
if(src.body_accessory.name == body_accessory_style)
return
for(var/B in body_accessory_by_name)
if(B == body_accessory_style)
src.body_accessory = body_accessory_by_name[body_accessory_style]
found = 1
if(!found)
return
update_tail_layer()
return 1
/mob/living/carbon/human/proc/reset_hair()
reset_head_hair()
reset_facial_hair()
@@ -131,6 +182,30 @@
update_fhair()
return 1
/mob/living/carbon/human/proc/change_head_accessory_color(var/red, var/green, var/blue)
var/obj/item/organ/external/head/H = get_organ("head")
if(red == H.r_headacc && green == H.g_headacc && blue == H.b_headacc)
return
H.r_headacc = red
H.g_headacc = green
H.b_headacc = blue
update_head_accessory()
return 1
/mob/living/carbon/human/proc/change_marking_color(var/red, var/green, var/blue)
if(red == r_markings && green == g_markings && blue == b_markings)
return
r_markings = red
g_markings = green
b_markings = blue
update_markings()
return 1
/mob/living/carbon/human/proc/change_skin_color(var/red, var/green, var/blue)
if(red == r_skin && green == g_skin && blue == b_skin || !(species.bodyflags & HAS_SKIN_COLOR))
return
@@ -176,9 +251,9 @@
/mob/living/carbon/human/proc/generate_valid_hairstyles()
var/list/valid_hairstyles = new()
var/obj/item/organ/external/head/H = get_organ("head")
for(var/hairstyle in hair_styles_list)
var/datum/sprite_accessory/S = hair_styles_list[hairstyle]
var/obj/item/organ/external/head/H = organs_by_name["head"]
if(gender == MALE && S.gender == FEMALE)
continue
@@ -210,9 +285,9 @@
/mob/living/carbon/human/proc/generate_valid_facial_hairstyles()
var/list/valid_facial_hairstyles = new()
var/obj/item/organ/external/head/H = get_organ("head")
for(var/facialhairstyle in facial_hair_styles_list)
var/datum/sprite_accessory/S = facial_hair_styles_list[facialhairstyle]
var/obj/item/organ/external/head/H = organs_by_name["head"]
if(gender == MALE && S.gender == FEMALE)
continue
@@ -242,3 +317,47 @@
valid_facial_hairstyles += facialhairstyle
return valid_facial_hairstyles
/mob/living/carbon/human/proc/generate_valid_head_accessories()
var/list/valid_head_accessories = new()
var/obj/item/organ/external/head/H = get_organ("head")
for(var/head_accessory in head_accessory_styles_list)
var/datum/sprite_accessory/S = head_accessory_styles_list[head_accessory]
if(!(H.species.name in S.species_allowed)) //If the user's head is not of a species the head accessory style allows, skip it. Otherwise, add it to the list.
continue
valid_head_accessories += head_accessory
return valid_head_accessories
/mob/living/carbon/human/proc/generate_valid_markings()
var/list/valid_markings = new()
var/obj/item/organ/external/head/H = get_organ("head")
for(var/marking in marking_styles_list)
var/datum/sprite_accessory/S = marking_styles_list[marking]
if(!(species.name in S.species_allowed)) //If the user's head is not of a species the marking style allows, skip it. Otherwise, add it to the list.
continue
if(H.species.flags & ALL_RPARTS) //If the user is a species that can have a robotic head...
var/datum/robolimb/robohead = all_robolimbs[H.model]
if(!(S.models_allowed && (robohead.company in S.models_allowed))) //Make sure they don't get markings incompatible with their head.
continue
valid_markings += marking
return valid_markings
/mob/living/carbon/human/proc/generate_valid_body_accessories()
var/list/valid_body_accessories = new()
for(var/B in body_accessory_by_name)
var/datum/body_accessory/A = body_accessory_by_name[B]
if(check_rights(R_ADMIN, 1, src))
valid_body_accessories = body_accessory_by_name.Copy()
else
if(!istype(A))
valid_body_accessories += "None" //The only null entry should be the "None" option.
continue
if(!(species.name in A.allowed_species)) //If the user is not of a species the body accessory style allows, skip it. Otherwise, add it to the list.
continue
valid_body_accessories += B
return valid_body_accessories
@@ -1898,22 +1898,22 @@
icon_state = "markings_tiger"
/datum/sprite_accessory/body_markings/tigerhead
name = "Tiger Body + Head"
name = "Tiger Body and Head"
species_allowed = list("Unathi", "Tajaran", "Vulpkanin")
icon_state = "markings_tigerhead"
/datum/sprite_accessory/body_markings/tigerheadface_taj
name = "Tajaran Tiger Body + Head + Face"
name = "Tajaran Tiger Body, Head and Face"
species_allowed = list("Tajaran")
icon_state = "markings_tigerheadface_taj"
/datum/sprite_accessory/body_markings/tigerheadface_vulp
name = "Vulpkanin Tiger Body + Head + Face"
name = "Vulpkanin Tiger Body, Head and Face"
species_allowed = list("Vulpkanin")
icon_state = "markings_tigerheadface_vulp"
/datum/sprite_accessory/body_markings/tigerheadface_una
name = "Unathi Tiger Body + Head + Face"
name = "Unathi Tiger Body, Head and Face"
species_allowed = list("Unathi")
icon_state = "markings_tigerheadface_una"
+87 -2
View File
@@ -6,6 +6,9 @@
var/list/valid_species = list()
var/list/valid_hairstyles = list()
var/list/valid_facial_hairstyles = list()
var/list/valid_head_accessories = list()
var/list/valid_marking_styles = list()
var/list/valid_body_accessories = list()
var/check_whitelist
var/list/whitelist
@@ -89,6 +92,41 @@
if(owner.change_eye_color(r_eyes, g_eyes, b_eyes))
update_dna()
return 1
if(href_list["head_accessory"])
if(can_change_head_accessory() && (href_list["head_accessory"] in valid_head_accessories))
if(owner.change_head_accessory(href_list["head_accessory"]))
update_dna()
return 1
if(href_list["head_accessory_color"])
if(can_change_head_accessory())
var/new_head_accessory = input("Please select head accessory color.", "Head Accessory Color", rgb(head_organ.r_headacc, head_organ.g_headacc, head_organ.b_headacc)) as color|null
if(new_head_accessory && can_still_topic(state))
var/r_headacc = hex2num(copytext(new_head_accessory, 2, 4))
var/g_headacc = hex2num(copytext(new_head_accessory, 4, 6))
var/b_headacc = hex2num(copytext(new_head_accessory, 6, 8))
if(owner.change_head_accessory_color(r_headacc, g_headacc, b_headacc))
update_dna()
return 1
if(href_list["marking"])
if(can_change_markings() && (href_list["marking"] in valid_marking_styles))
if(owner.change_markings(href_list["marking"]))
update_dna()
return 1
if(href_list["marking_color"])
if(can_change_markings())
var/new_markings = input("Please select marking color.", "Marking Color", rgb(owner.r_markings, owner.g_markings, owner.b_markings)) as color|null
if(new_markings && can_still_topic(state))
var/r_markings = hex2num(copytext(new_markings, 2, 4))
var/g_markings = hex2num(copytext(new_markings, 4, 6))
var/b_markings = hex2num(copytext(new_markings, 6, 8))
if(owner.change_marking_color(r_markings, g_markings, b_markings))
update_dna()
return 1
if(href_list["body_accessory"])
if(can_change_body_accessory() && (href_list["body_accessory"] in valid_body_accessories))
if(owner.change_body_accessory(href_list["body_accessory"]))
update_dna()
return 1
return 0
@@ -109,6 +147,14 @@
data["change_skin_tone"] = can_change_skin_tone()
data["change_skin_color"] = can_change_skin_color()
data["change_eye_color"] = can_change(APPEARANCE_EYE_COLOR)
data["change_head_accessory"] = can_change_head_accessory()
if(data["change_head_accessory"])
var/head_accessory_styles[0]
for(var/head_accessory_style in valid_head_accessories)
head_accessory_styles[++head_accessory_styles.len] = list("headaccessorystyle" = head_accessory_style)
data["head_accessory_styles"] = head_accessory_styles
data["head_accessory_style"] = head_organ.ha_style
data["change_hair"] = can_change(APPEARANCE_HAIR)
if(data["change_hair"])
var/hair_styles[0]
@@ -125,8 +171,29 @@
data["facial_hair_styles"] = facial_hair_styles
data["facial_hair_style"] = head_organ.f_style
data["change_markings"] = can_change_markings()
if(data["change_markings"])
var/marking_styles[0]
for(var/marking_style in valid_marking_styles)
marking_styles[++marking_styles.len] = list("markingstyle" = marking_style)
data["marking_styles"] = marking_styles
data["marking_style"] = owner.m_style
data["change_body_accessory"] = can_change_body_accessory()
if(data["change_body_accessory"])
var/body_accessory_styles[0]
for(var/body_accessory_style in valid_body_accessories)
body_accessory_styles[++body_accessory_styles.len] = list("bodyaccessorystyle" = body_accessory_style)
data["body_accessory_styles"] = body_accessory_styles
var/datum/body_accessory/BA
if(owner.body_accessory)
BA = owner.body_accessory.name
data["body_accessory_style"] = BA
data["change_head_accessory_color"] = can_change_head_accessory()
data["change_hair_color"] = can_change(APPEARANCE_HAIR_COLOR)
data["change_facial_hair_color"] = can_change(APPEARANCE_FACIAL_HAIR_COLOR)
data["change_marking_color"] = can_change_markings()
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "appearance_changer.tmpl", "[src]", 800, 450, state = state)
@@ -147,10 +214,22 @@
/datum/nano_module/appearance_changer/proc/can_change_skin_color()
return owner && (flags & APPEARANCE_SKIN) && (owner.species.bodyflags & HAS_SKIN_COLOR)
/datum/nano_module/appearance_changer/proc/can_change_head_accessory()
return owner && (flags & APPEARANCE_HEAD_ACCESSORY) && (head_organ.species.bodyflags & HAS_HEAD_ACCESSORY)
/datum/nano_module/appearance_changer/proc/can_change_markings()
return owner && (flags & APPEARANCE_MARKINGS) && (owner.species.bodyflags & HAS_MARKINGS)
/datum/nano_module/appearance_changer/proc/can_change_body_accessory()
return owner && (flags & APPEARANCE_BODY_ACCESSORY) && (owner.species.bodyflags & HAS_TAIL)
/datum/nano_module/appearance_changer/proc/cut_and_generate_data()
// Making the assumption that the available species remain constant
valid_hairstyles.Cut()
valid_facial_hairstyles.Cut()
valid_facial_hairstyles.Cut()
valid_head_accessories.Cut()
valid_marking_styles.Cut()
valid_body_accessories.Cut()
generate_data()
/datum/nano_module/appearance_changer/proc/generate_data()
@@ -160,4 +239,10 @@
valid_species = owner.generate_valid_species(check_whitelist, whitelist, blacklist)
if(!valid_hairstyles.len || !valid_facial_hairstyles.len)
valid_hairstyles = owner.generate_valid_hairstyles()
valid_facial_hairstyles = owner.generate_valid_facial_hairstyles()
valid_facial_hairstyles = owner.generate_valid_facial_hairstyles()
if(!valid_head_accessories.len)
valid_head_accessories = owner.generate_valid_head_accessories()
if(!valid_marking_styles.len)
valid_marking_styles = owner.generate_valid_markings()
if(!valid_body_accessories.len)
valid_body_accessories = owner.generate_valid_body_accessories()
+46 -1
View File
@@ -23,7 +23,7 @@
</div>
{{/if}}
{{if data.change_eye_color || data.change_skin_tone || data.change_skin_color || data.change_hair_color || data.change_facial_hair_color}}
{{if data.change_eye_color || data.change_skin_tone || data.change_skin_color || data.change_head_accessory_color || data.change_hair_color || data.change_facial_hair_color || data.change_marking_color}}
<div class="item">
<div class="itemLabelNarrow">
Colors:
@@ -38,12 +38,31 @@
{{if data.change_skin_color}}
{{:helper.link('Change skin color', null, { 'skin_color' : 1})}}
{{/if}}
{{if data.change_head_accessory_color}}
{{:helper.link('Change head accessory color', null, { 'head_accessory_color' : 1})}}
{{/if}}
{{if data.change_hair_color}}
{{:helper.link('Change hair color', null, { 'hair_color' : 1})}}
{{/if}}
{{if data.change_facial_hair_color}}
{{:helper.link('Change facial hair color', null, { 'facial_hair_color' : 1})}}
{{/if}}
{{if data.change_marking_color}}
{{:helper.link('Change marking color', null, { 'marking_color' : 1})}}
{{/if}}
</div>
</div>
{{/if}}
{{if data.change_head_accessory}}
<div class="item">
<div class="itemLabelNarrow">
Head accessory styles:
</div>
<div class="itemContentWide">
{{for data.head_accessory_styles}}
{{:helper.link(value.headaccessorystyle, null, { 'head_accessory' : value.headaccessorystyle}, null, data.head_accessory_style == value.headaccessorystyle ? 'selected' : null)}}
{{/for}}
</div>
</div>
{{/if}}
@@ -73,3 +92,29 @@
</div>
</div>
{{/if}}
{{if data.change_markings}}
<div class="item">
<div class="itemLabelNarrow">
Marking styles:
</div>
<div class="itemContentWide">
{{for data.marking_styles}}
{{:helper.link(value.markingstyle, null, { 'marking' : value.markingstyle}, null, data.marking_style == value.markingstyle ? 'selected' : null)}}
{{/for}}
</div>
</div>
{{/if}}
{{if data.change_body_accessory}}
<div class="item">
<div class="itemLabelNarrow">
Body accessory styles:
</div>
<div class="itemContentWide">
{{for data.body_accessory_styles}}
{{:helper.link(value.bodyaccessorystyle, null, { 'body_accessory' : value.bodyaccessorystyle}, null, data.body_accessory_style == value.bodyaccessorystyle ? 'selected' : null)}}
{{/for}}
</div>
</div>
{{/if}}