From 2d890ff085048c4acfeb5ee45a51ece319f98d16 Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Fri, 9 Feb 2024 11:56:15 -0500 Subject: [PATCH] [MIRROR] settlers can rename their pets (#867) * settlers can rename their pets (#81190) ## About The Pull Request settlers can now rename their tamed pets ## Why It's Good For The Game adds another fun and harmless interaction between settlers and their pets ## Changelog :cl: add: settlers can rename their pets /:cl: --------- Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> * settlers can rename their pets --------- Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/datums/components/tameable.dm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/code/datums/components/tameable.dm b/code/datums/components/tameable.dm index 3da6d616149..67325b489d3 100644 --- a/code/datums/components/tameable.dm +++ b/code/datums/components/tameable.dm @@ -70,18 +70,28 @@ return living_parent.faction.Find(REF(potential_friend)) ///Ran once taming succeeds -/datum/component/tameable/proc/on_tame(datum/source, mob/living/tamer, atom/food, inform_tamer = FALSE) +/datum/component/tameable/proc/on_tame(atom/source, mob/living/tamer, atom/food, inform_tamer = FALSE) SIGNAL_HANDLER after_tame?.Invoke(tamer, food)//Run custom behavior if needed if(isliving(parent) && isliving(tamer)) - var/mob/living/tamed = parent - INVOKE_ASYNC(tamed, TYPE_PROC_REF(/mob/living, befriend), tamer) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living, befriend), tamer) if(inform_tamer) - var/atom/atom_parent = source - atom_parent.balloon_alert(tamer, "tamed") + source.balloon_alert(tamer, "tamed") + if(HAS_TRAIT(tamer, TRAIT_SETTLER)) + INVOKE_ASYNC(src, PROC_REF(rename_pet), source, tamer) if(unique) qdel(src) else current_tame_chance = tame_chance + +/datum/component/tameable/proc/rename_pet(mob/living/animal, mob/living/tamer) + var/chosen_name = sanitize_name(tgui_input_text(tamer, "Choose your pet's name!", "Name pet", animal.name, MAX_NAME_LEN), allow_numbers = TRUE) + if(QDELETED(animal) || chosen_name == animal.name) + return + if(!chosen_name) + to_chat(tamer, span_warning("Please enter a valid name.")) + rename_pet(animal, tamer) + return + animal.fully_replace_character_name(animal.name, chosen_name)