mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-27 22:17:32 +01:00
Converts mice to basic mobs (#29928)
* Converts mice to basic mobs * Larger only targetting strat * Oops. * Linters * Code review suggestions * Linters * Merge conflict resolution * Snakes * Oops * Clogged Disposals * Updates persistent client * Linters --------- Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
This commit is contained in:
co-authored by
warriorstar-orion
parent
db555b4c28
commit
7caf75b37b
@@ -43,6 +43,8 @@
|
||||
speech_commands = list("heel", "follow")
|
||||
///the behavior we use to follow
|
||||
var/follow_behavior = /datum/ai_behavior/pet_follow_friend
|
||||
/// should we activate immediately if we're doing nothing else and gain a friend?
|
||||
var/activate_on_befriend = FALSE
|
||||
|
||||
/datum/pet_command/follow/set_command_active(mob/living/parent, mob/living/commander)
|
||||
. = ..()
|
||||
@@ -55,6 +57,17 @@
|
||||
controller.queue_behavior(follow_behavior, BB_CURRENT_PET_TARGET)
|
||||
return SUBTREE_RETURN_FINISH_PLANNING
|
||||
|
||||
/datum/pet_command/follow/add_new_friend(mob/living/tamer)
|
||||
. = ..()
|
||||
var/mob/living/parent = locateUID(parent_uid)
|
||||
if(!parent)
|
||||
return
|
||||
if(activate_on_befriend && !parent.ai_controller.blackboard_key_exists(BB_ACTIVE_PET_COMMAND))
|
||||
try_activate_command(tamer)
|
||||
|
||||
/// Like follow but start active
|
||||
/datum/pet_command/follow/start_active
|
||||
activate_on_befriend = TRUE
|
||||
/**
|
||||
* # Pet Command: Use ability
|
||||
* Use an an ability that does not require any targets
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/// This component lets you make specific mobs tameable by feeding them
|
||||
/datum/component/tameable
|
||||
/// If true, this atom can only be domesticated by one person
|
||||
var/unique
|
||||
/// Starting success chance for taming.
|
||||
var/tame_chance
|
||||
/// Added success chance after every failed tame attempt.
|
||||
var/bonus_tame_chance
|
||||
/// Current chance to tame on interaction
|
||||
var/current_tame_chance
|
||||
|
||||
/datum/component/tameable/Initialize(food_types, tame_chance, bonus_tame_chance, unique = TRUE)
|
||||
if(!ismob(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
|
||||
if(tame_chance)
|
||||
src.tame_chance = tame_chance
|
||||
src.current_tame_chance = tame_chance
|
||||
if(bonus_tame_chance)
|
||||
src.bonus_tame_chance = bonus_tame_chance
|
||||
src.unique = unique
|
||||
|
||||
if(food_types && !HAS_TRAIT(parent, TRAIT_MOB_EATER))
|
||||
parent.AddElement(/datum/element/basic_eating, food_types_ = food_types)
|
||||
|
||||
RegisterSignal(parent, COMSIG_MOB_ATE, PROC_REF(try_tame))
|
||||
|
||||
/datum/component/tameable/proc/try_tame(atom/source, obj/item/food, mob/living/attacker)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(isnull(attacker) || already_friends(attacker))
|
||||
return
|
||||
|
||||
var/inform_tamer = FALSE
|
||||
if(prob(current_tame_chance)) // note: lack of feedback message is deliberate, keep them guessing unless they're an expert!
|
||||
on_tame(source, attacker, food, inform_tamer)
|
||||
else
|
||||
current_tame_chance += bonus_tame_chance
|
||||
|
||||
/// Check if the passed mob is already considered one of our friends
|
||||
/datum/component/tameable/proc/already_friends(mob/living/potential_friend)
|
||||
if(!isliving(parent))
|
||||
return FALSE // Figure this out when we actually need it
|
||||
var/mob/living/living_parent = parent
|
||||
var/living_parent_id = living_parent.UID()
|
||||
return living_parent.faction.Find(living_parent_id)
|
||||
|
||||
/// Ran once taming succeeds
|
||||
/datum/component/tameable/proc/on_tame(mob/source, mob/living/tamer, obj/item/food, inform_tamer = FALSE)
|
||||
SIGNAL_HANDLER
|
||||
source.tamed(tamer, food)//Run custom behavior if needed
|
||||
|
||||
if(isliving(parent) && isliving(tamer))
|
||||
INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living, befriend), 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 = tgui_input_text(tamer, "Choose your pet's name!", "Name pet", animal.name, MAX_NAME_LEN)
|
||||
if(QDELETED(animal) || chosen_name == animal.name)
|
||||
return
|
||||
if(!chosen_name)
|
||||
to_chat(tamer, "<span class='warning'>Please enter a valid name.</span>")
|
||||
rename_pet(animal, tamer)
|
||||
return
|
||||
animal.rename_character(animal.name, chosen_name)
|
||||
Reference in New Issue
Block a user