Basic mobs core implementation and cow migration. (#28667)

* Basic mobs core implementation and cow migration.

* fix whitespace

* uncomfortable fix for null weirdness

* update updatepaths script number

* lewc review 1

* fix delta

* Update code/datums/ai/basic_mobs/basic_ai_behaviors/tipped_reaction.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
This commit is contained in:
warriorstar-orion
2025-04-05 07:35:42 -04:00
committed by GitHub
parent b012f18d9a
commit c820499f90
80 changed files with 1493 additions and 272 deletions
@@ -0,0 +1,43 @@
/// Similar to finding a target but looks for food types in the blackboard.
/datum/ai_planning_subtree/find_food
/// Behavior we use to find the food
var/datum/ai_behavior/finding_behavior = /datum/ai_behavior/find_and_set/in_list
/// Key of foods list
var/food_list_key = BB_BASIC_FOODS
/// Key where we store our food
var/found_food_key = BB_TARGET_FOOD
/// Key holding any emotes we play after eating food
var/emotes_blackboard_list = BB_EAT_EMOTES
/// Key where we store our search range
var/search_range = BB_SEARCH_RANGE
/datum/ai_planning_subtree/find_food/select_behaviors(datum/ai_controller/controller, seconds_per_tick)
var/list/foods_list = controller.blackboard[food_list_key]
if(!length(foods_list))
CRASH("the types of food has not been supplied in the [food_list_key] key!")
if(controller.blackboard[BB_NEXT_FOOD_EAT] > world.time)
return
if(!controller.blackboard_key_exists(found_food_key))
controller.queue_behavior(finding_behavior, found_food_key, foods_list, controller.blackboard[BB_SEARCH_RANGE])
return
controller.queue_behavior(/datum/ai_behavior/interact_with_target/eat_food, found_food_key, emotes_blackboard_list)
return SUBTREE_RETURN_FINISH_PLANNING
/datum/ai_behavior/interact_with_target/eat_food
/// default list of actions we take after eating
var/list/food_actions = list(
"eats up happily!",
"chomps with glee!",
)
/datum/ai_behavior/interact_with_target/eat_food/perform(seconds_per_tick, datum/ai_controller/controller, target_key, emotes_blackboard_list)
. = ..()
if(. & AI_BEHAVIOR_FAILED)
return
var/list/emotes_to_pick = controller.blackboard[emotes_blackboard_list] || food_actions
if(!length(emotes_to_pick))
return
var/mob/living/living_pawn = controller.pawn
living_pawn.custom_emote(EMOTE_VISIBLE, pick(emotes_to_pick))
@@ -0,0 +1,63 @@
/datum/ai_planning_subtree/random_speech
/// The chance of an emote occurring each second
var/speech_chance = 0
/// Hearable emotes
var/list/emote_hear = list()
/// Unlike speak_emote, the list of things in this variable only show by themselves with no spoken text. IE: Ian barks, Ian yaps
var/list/emote_see = list()
/// Possible lines of speech the AI can have
var/list/speak = list()
/// The sound effects associated with this speech, if any
var/list/sound = list()
/// The possible verbs used to perform the speech, if any. Defaults to "says" elsewhere in code.
var/list/speak_verbs = list()
/datum/ai_planning_subtree/random_speech/New()
. = ..()
if(speak)
speak = string_list(speak)
if(sound)
sound = string_list(sound)
if(emote_hear)
emote_hear = string_list(emote_hear)
if(emote_see)
emote_see = string_list(emote_see)
if(speak_verbs)
speak_verbs = string_list(speak_verbs)
/datum/ai_planning_subtree/random_speech/select_behaviors(datum/ai_controller/controller, seconds_per_tick)
if(!SPT_PROB(speech_chance, seconds_per_tick))
return
speak(controller)
/// Actually perform an action
/datum/ai_planning_subtree/random_speech/proc/speak(datum/ai_controller/controller)
var/audible_emotes_length = length(emote_hear)
var/non_audible_emotes_length = length(emote_see)
var/speak_lines_length = length(speak)
var/total_choices_length = audible_emotes_length + non_audible_emotes_length + speak_lines_length
if(total_choices_length == 0)
return
var/random_number_in_range = rand(1, total_choices_length)
var/sound_to_play = length(sound) > 0 ? pick(sound) : null
if(random_number_in_range <= audible_emotes_length)
controller.queue_behavior(/datum/ai_behavior/perform_emote, pick(emote_hear), sound_to_play)
else if(random_number_in_range <= (audible_emotes_length + non_audible_emotes_length))
controller.queue_behavior(/datum/ai_behavior/perform_emote, pick(emote_see))
else
var/speak_verb = "says"
if(length(speak_verbs))
speak_verb = pick(speak_verbs)
controller.queue_behavior(/datum/ai_behavior/perform_speech, pick(speak), sound_to_play, speak_verb)
/datum/ai_planning_subtree/random_speech/cow
speech_chance = 2
speak = list("Moo?", "Moo", "MOOOOOO")
speak_verbs = list("moos", "moos hauntingly")
sound = list('sound/creatures/cow.ogg')
emote_hear = list("brays.")
emote_see = list("shakes her head.")
@@ -0,0 +1,10 @@
///used by cows
/datum/ai_planning_subtree/tip_reaction
/datum/ai_planning_subtree/tip_reaction/select_behaviors(datum/ai_controller/controller, seconds_per_tick)
. = ..()
var/tip_reacting = controller.blackboard[BB_BASIC_MOB_TIP_REACTING]
if(!tip_reacting)
return
controller.queue_behavior(/datum/ai_behavior/tipped_reaction, BB_BASIC_MOB_TIPPER, BB_BASIC_MOB_TIP_REACTING)
return SUBTREE_RETURN_FINISH_PLANNING //no point in trying, boy. you're TIPPED.