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
@@ -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()