From 4e6d1f3d7006fdc4cc700b3a5f98ef795a4c1037 Mon Sep 17 00:00:00 2001 From: Rukofamicom Date: Tue, 3 Sep 2024 22:15:49 -0500 Subject: [PATCH 1/3] Removes limit on posibrains, adds name randomizer --- code/__HELPERS/mobs.dm | 12 ++++++++++++ code/_globalvars/lists/mobs.dm | 2 +- code/modules/mob/living/brain/posibrain.dm | 7 +------ code/modules/mob/living/silicon/robot/robot.dm | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 3a763818771b6..2c0166382de24 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -775,6 +775,18 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) return TRUE return FALSE +//// Special handler for cyborg naming to ensure no cyborgs ever take a name that has already been used. Prevents "respawning" when the same player takes two posibrains. +/mob/proc/apply_cyborg_name(preference_type, client/C) + + //This name has already been taken, refuse to pass it on and return false + if(preference_type in GLOB.cyborg_name_list) + to_chat(C.mob, "Cyborg name randomized. Cyborg name already used this round by another character.") + return FALSE + + //Name is original, add it to the list to prevent it from being used again. + GLOB.cyborg_name_list += preference_type + return apply_pref_name(preference_type, C) + /proc/view_or_range(distance = world.view , center = usr , type) switch(type) if("view") diff --git a/code/_globalvars/lists/mobs.dm b/code/_globalvars/lists/mobs.dm index 73b9a2c418b4a..4daa7b969bfd6 100644 --- a/code/_globalvars/lists/mobs.dm +++ b/code/_globalvars/lists/mobs.dm @@ -52,7 +52,7 @@ GLOBAL_LIST_EMPTY(mob_config_movespeed_type_lookup) GLOBAL_LIST_EMPTY(emote_list) -GLOBAL_LIST_EMPTY(posi_key_list) +GLOBAL_LIST_EMPTY(cyborg_name_list) GLOBAL_LIST_INIT(construct_radial_images, list( CONSTRUCT_JUGGERNAUT = image(icon = 'icons/mob/cult.dmi', icon_state = "juggernaut"), diff --git a/code/modules/mob/living/brain/posibrain.dm b/code/modules/mob/living/brain/posibrain.dm index 826fade383784..4fba144a59161 100644 --- a/code/modules/mob/living/brain/posibrain.dm +++ b/code/modules/mob/living/brain/posibrain.dm @@ -94,9 +94,6 @@ GLOBAL_VAR(posibrain_notify_cooldown) return FALSE if(is_occupied() || QDELETED(brainmob) || QDELETED(src) || QDELETED(user)) return FALSE - if(user.ckey in GLOB.posi_key_list) - to_chat(user, "Positronic brain spawns limited to 1 per round.") - return FALSE if(!(GLOB.ghost_role_flags & GHOSTROLE_SILICONS)) to_chat(user, "Central Command has temporarily outlawed posibrain sentience in this sector...") return FALSE @@ -108,9 +105,7 @@ GLOBAL_VAR(posibrain_notify_cooldown) return FALSE if(brainmob.suiciding) //clear suicide status if the old occupant suicided. brainmob.set_suicide(FALSE) - var/ckey = user.ckey - if(transfer_personality(user)) - GLOB.posi_key_list += ckey + transfer_personality(user) var/datum/job/posibrain/pj = SSjob.GetJob(JOB_NAME_POSIBRAIN) pj.remove_posi_slot(src) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 1715cb7dd0177..3bb095ecb8ba0 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -297,7 +297,7 @@ if(custom_name) changed_name = custom_name if(changed_name == "" && C && C.prefs.read_character_preference(/datum/preference/name/cyborg) != DEFAULT_CYBORG_NAME) - if(apply_pref_name(/datum/preference/name/cyborg, C)) + if(apply_cyborg_name(/datum/preference/name/cyborg, C)) return //built in camera handled in proc if(!changed_name) changed_name = get_standard_name() From 26302b90677d6a8bffbf6efb817b2c765a344020 Mon Sep 17 00:00:00 2001 From: Rukofamicom Date: Fri, 6 Sep 2024 18:23:33 -0500 Subject: [PATCH 2/3] Update mobs.dm --- code/__HELPERS/mobs.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 2c0166382de24..33e106da38d9f 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -777,14 +777,15 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) //// Special handler for cyborg naming to ensure no cyborgs ever take a name that has already been used. Prevents "respawning" when the same player takes two posibrains. /mob/proc/apply_cyborg_name(preference_type, client/C) + var/name = C?.prefs?.read_character_preference(preference_type) //This name has already been taken, refuse to pass it on and return false - if(preference_type in GLOB.cyborg_name_list) + if(name in GLOB.cyborg_name_list) to_chat(C.mob, "Cyborg name randomized. Cyborg name already used this round by another character.") return FALSE //Name is original, add it to the list to prevent it from being used again. - GLOB.cyborg_name_list += preference_type + GLOB.cyborg_name_list += name return apply_pref_name(preference_type, C) /proc/view_or_range(distance = world.view , center = usr , type) From 149015abda5a52b1a2f66a7b50dacb9e5b756645 Mon Sep 17 00:00:00 2001 From: Rukofamicom Date: Sun, 8 Sep 2024 13:40:56 -0500 Subject: [PATCH 3/3] Reworks the whole thing --- code/__HELPERS/mobs.dm | 26 ++++++++++++------- code/modules/jobs/job_types/_job.dm | 2 +- code/modules/mob/living/brain/MMI.dm | 2 ++ .../modules/mob/living/silicon/robot/robot.dm | 8 ++++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 33e106da38d9f..96bba3a97a2dd 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -775,18 +775,24 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) return TRUE return FALSE -//// Special handler for cyborg naming to ensure no cyborgs ever take a name that has already been used. Prevents "respawning" when the same player takes two posibrains. -/mob/proc/apply_cyborg_name(preference_type, client/C) - var/name = C?.prefs?.read_character_preference(preference_type) +/// Special handler for cyborg naming to check if cyborg name preferences match a name that has already been used. Returns TRUE if preferences are good to use and FALSE if not. +/mob/proc/check_cyborg_name(client/C, obj/item/mmi/mmi) + var/name = C?.prefs?.read_character_preference(/datum/preference/name/cyborg) + + //Name is original, add it to the list to prevent it from being used again and return TRUE + if(!(name in GLOB.cyborg_name_list)) + GLOB.cyborg_name_list += name + mmi.original_name = name + return TRUE - //This name has already been taken, refuse to pass it on and return false - if(name in GLOB.cyborg_name_list) - to_chat(C.mob, "Cyborg name randomized. Cyborg name already used this round by another character.") - return FALSE + //Name is not original, but is this the original user of the name? If so we still return TRUE but do not need to add it to the list + else if(name == mmi.original_name) + return TRUE - //Name is original, add it to the list to prevent it from being used again. - GLOB.cyborg_name_list += name - return apply_pref_name(preference_type, C) + //This name has already been taken and this is not the original user, return FALSE + else + to_chat(C.mob, "Cyborg name already used this round by another character, your name has been randomized") + return FALSE /proc/view_or_range(distance = world.view , center = usr , type) switch(type) diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index c988a8c2d53c6..afca5d40d7dd4 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -504,5 +504,5 @@ mmi.brainmob.real_name = organic_name //the name of the brain inside the cyborg is the robotized human's name. mmi.brainmob.name = organic_name // If this checks fails, then the name will have been handled during initialization. - if(player_client.prefs.read_character_preference(/datum/preference/name/cyborg) != DEFAULT_CYBORG_NAME) + if(player_client.prefs.read_character_preference(/datum/preference/name/cyborg) != DEFAULT_CYBORG_NAME && check_cyborg_name(player_client, mmi)) apply_pref_name(/datum/preference/name/cyborg, player_client) diff --git a/code/modules/mob/living/brain/MMI.dm b/code/modules/mob/living/brain/MMI.dm index 143c013c4aefa..3c44231a81026 100644 --- a/code/modules/mob/living/brain/MMI.dm +++ b/code/modules/mob/living/brain/MMI.dm @@ -13,6 +13,8 @@ var/datum/ai_laws/laws = new() var/force_replace_ai_name = FALSE var/overrides_aicore_laws = FALSE // Whether the laws on the MMI, if any, override possible pre-existing laws loaded on the AI core. + ///Used to reserve an "original" cyborg name. When this mmi first becomes a cyborg, their name will be stored here in case of deconstruction. + var/original_name /obj/item/mmi/Initialize(mapload) . = ..() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 3bb095ecb8ba0..293a5332830ce 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -297,8 +297,12 @@ if(custom_name) changed_name = custom_name if(changed_name == "" && C && C.prefs.read_character_preference(/datum/preference/name/cyborg) != DEFAULT_CYBORG_NAME) - if(apply_cyborg_name(/datum/preference/name/cyborg, C)) - return //built in camera handled in proc + if(check_cyborg_name(C, mmi)) + if(apply_pref_name(/datum/preference/name/cyborg, C)) + return //built in camera handled in proc + else + //Failed the vibe check on name theft, time to randomize it + changed_name = get_standard_name() if(!changed_name) changed_name = get_standard_name()