From ded00d42aa19ae7ee91a17847937a9a8538e88dd Mon Sep 17 00:00:00 2001 From: Antoonij <42318445+Antoonij@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:17:22 +0100 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20x10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/__DEFINES/dcs/signals.dm | 3 ++ code/__HELPERS/mobs.dm | 28 ++++------ .../living/carbon/human/species/machine.dm | 53 ++++++++++++++----- code/modules/surgery/organs/subtypes/wryn.dm | 20 +++---- 4 files changed, 64 insertions(+), 40 deletions(-) diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index aa521e47314..c3c684d5838 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -1200,3 +1200,6 @@ /// Source: /mob/living/simple_animal/borer, listening in datum/antagonist/borer #define COMSIG_BORER_ENTERED_HOST "borer_on_enter" // when borer entered host #define COMSIG_BORER_LEFT_HOST "borer_on_leave" // when borer left host + +/// Source: /proc/random_hair_style (mob/living/carbon/human/human, valid_hairstyles, h_style, robohead) +#define COMSIG_RANDOM_HAIR_STYLE "random_hair_style" diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 3e7dd8622dc..b7b613fbfed 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -46,33 +46,23 @@ return pick(valid_picks) -/proc/random_hair_style(gender, species = SPECIES_HUMAN, datum/robolimb/robohead, mob/living/carbon/human/H) +/proc/random_hair_style(gender, species = SPECIES_HUMAN, datum/robolimb/robohead, mob/living/carbon/human/human) var/h_style = "Bald" var/list/valid_hairstyles = list() for(var/hairstyle in GLOB.hair_styles_public_list) - var/datum/sprite_accessory/S = GLOB.hair_styles_public_list[hairstyle] + var/datum/sprite_accessory/style = GLOB.hair_styles_public_list[hairstyle] - if(hairstyle == "Bald") //Just in case. - valid_hairstyles += hairstyle + if(!LAZYIN(style.species_allowed, species)) continue - if(gender == S.unsuitable_gender) + + if(gender == style.unsuitable_gender) continue - if(species == SPECIES_MACNINEPERSON) //If the user is a species who can have a robotic head... - if(!robohead) - robohead = GLOB.all_robolimbs["Morpheus Cyberkinetics"] - if((species in S.species_allowed) && robohead.is_monitor && ((S.models_allowed && (robohead.company in S.models_allowed)) || !S.models_allowed)) //If this is a hair style native to the user's species, check to see if they have a head with an ipc-style screen and that the head's company is in the screen style's allowed models list. - valid_hairstyles += hairstyle //Give them their hairstyles if they do. - else - if(!robohead.is_monitor && (SPECIES_HUMAN in S.species_allowed)) /*If the hairstyle is not native to the user's species and they're using a head with an ipc-style screen, don't let them access it. - But if the user has a robotic humanoid head and the hairstyle can fit humans, let them use it as a wig. */ - valid_hairstyles += hairstyle - else //If the user is not a species who can have robotic heads, use the default handling. - if(species in S.species_allowed) //If the user's head is of a species the hairstyle allows, add it to the list. - valid_hairstyles += hairstyle + + LAZYADD(valid_hairstyles, hairstyle) - if(valid_hairstyles.len) - h_style = pick(valid_hairstyles) + h_style = safepick(valid_hairstyles) + SEND_SIGNAL(human, COMSIG_RANDOM_HAIR_STYLE, valid_hairstyles, h_style, robohead) return h_style diff --git a/code/modules/mob/living/carbon/human/species/machine.dm b/code/modules/mob/living/carbon/human/species/machine.dm index c12df2472d3..61cbee3f279 100644 --- a/code/modules/mob/living/carbon/human/species/machine.dm +++ b/code/modules/mob/living/carbon/human/species/machine.dm @@ -102,17 +102,18 @@ JOB_MIN_AGE_COMMAND = 15, ) -/datum/species/machine/on_species_gain(mob/living/carbon/human/H) +/datum/species/machine/on_species_gain(mob/living/carbon/human/human) . = ..() - var/datum/action/innate/change_monitor/monitor = locate() in H.actions + var/datum/action/innate/change_monitor/monitor = locate() in human.actions + if(!monitor) monitor = new - monitor.Grant(H) - monitor = new() - monitor.Grant(H) + monitor.Grant(human) + var/datum/atom_hud/data/human/medical/advanced/medhud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - medhud.remove_from_hud(H) - add_verb(H, list( + medhud.remove_from_hud(human) + + add_verb(human, list( /mob/living/carbon/human/proc/emote_ping, /mob/living/carbon/human/proc/emote_beep, /mob/living/carbon/human/proc/emote_buzz, @@ -120,14 +121,40 @@ /mob/living/carbon/human/proc/emote_yes, /mob/living/carbon/human/proc/emote_no)) + RegisterSignal(human, COMSIG_RANDOM_HAIR_STYLE, PROC_REF(handle_random_hairstyle)) + +/datum/species/machine/proc/handle_random_hairstyle( + mob/living/carbon/human/human, + valid_hairstyles, + h_style, + datum/robolimb/robohead + ) + SIGNAL_HANDLER + + if(!robohead) + robohead = GLOB.all_robolimbs["Morpheus Cyberkinetics"] + + for(var/hairstyle in GLOB.hair_styles_public_list) + var/datum/sprite_accessory/style = GLOB.hair_styles_public_list[hairstyle] -/datum/species/machine/on_species_loss(mob/living/carbon/human/H) + if(robohead.is_monitor && ((style.models_allowed && (robohead.company in S.models_allowed)) || !style.models_allowed)) + LAZYADD(valid_hairstyles, hairstyle) + + else + if(!robohead.is_monitor && (SPECIES_HUMAN in style.species_allowed)) // Let use them as wigs + LAZYADD(valid_hairstyles, hairstyle) + + h_style = safepick(valid_hairstyles) + +/datum/species/machine/on_species_loss(mob/living/carbon/human/human) . = ..() - var/datum/action/innate/change_monitor/monitor = locate() in H.actions - monitor?.Remove(H) + var/datum/action/innate/change_monitor/monitor = locate() in human.actions + monitor?.Remove(human) + var/datum/atom_hud/data/human/medical/advanced/medhud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED] - medhud.add_to_hud(H) - remove_verb(H, list( + medhud.add_to_hud(human) + + remove_verb(human, list( /mob/living/carbon/human/proc/emote_ping, /mob/living/carbon/human/proc/emote_beep, /mob/living/carbon/human/proc/emote_buzz, @@ -135,6 +162,8 @@ /mob/living/carbon/human/proc/emote_yes, /mob/living/carbon/human/proc/emote_no)) + UnregisterSignal(human, COMSIG_RANDOM_HAIR_STYLE) + // Allows IPC's to change their monitor display /datum/action/innate/change_monitor name = "Change Monitor" diff --git a/code/modules/surgery/organs/subtypes/wryn.dm b/code/modules/surgery/organs/subtypes/wryn.dm index cf3b48d8fc4..715c11a37a0 100644 --- a/code/modules/surgery/organs/subtypes/wryn.dm +++ b/code/modules/surgery/organs/subtypes/wryn.dm @@ -16,20 +16,22 @@ return ..(carbon) -/obj/item/organ/internal/wryn/hivenode/insert(mob/living/carbon/human/M, special = ORGAN_MANIPULATION_DEFAULT) +/obj/item/organ/internal/wryn/hivenode/insert(mob/living/carbon/human/human, special = ORGAN_MANIPULATION_DEFAULT) . = ..() - M.add_language(LANGUAGE_WRYN) - var/obj/item/organ/external/head/head_organ = M.get_organ(BODY_ZONE_HEAD) + human.add_language(LANGUAGE_WRYN) + var/obj/item/organ/external/head/head_organ = human.get_organ(BODY_ZONE_HEAD) + head_organ.h_style = hair_style - M.update_hair() + human.update_hair() -/obj/item/organ/internal/wryn/hivenode/remove(mob/living/carbon/human/M, special = ORGAN_MANIPULATION_DEFAULT) - M.remove_language(LANGUAGE_WRYN) - var/obj/item/organ/external/head/head_organ = M.get_organ(BODY_ZONE_HEAD) +/obj/item/organ/internal/wryn/hivenode/remove(mob/living/carbon/human/human, special = ORGAN_MANIPULATION_DEFAULT) + human.remove_language(LANGUAGE_WRYN) + var/obj/item/organ/external/head/head_organ = human.get_organ(BODY_ZONE_HEAD) head_organ.h_style = "Bald" - M.update_hair() - . = ..() + human.update_hair() + + return ..() /obj/item/organ/internal/wryn/glands species_type = /datum/species/wryn