mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-26 09:03:37 +00:00
* Cows can eat wheat off the ground. If cows see wheat on the ground, they'll try to go eat it (+ moonicorns with galaxy thistle) (#69253) About The Pull Request Cows are now grazers, they love eatin' wheat and it even heals them if hurt. If they see it just on the ground, they might eat it all! Careful, botanists! While tamed, cows won't eat off the ground if they're busy ferrying you around. FYI: this is going to conflict with #69247 and so thiss should not be merged until that is Why It's Good For The Game Wanted to add this with the original port of cows to basic mobs, didn't have the TECH to do so. Now I do, now it's done. I also wanted it ready for the future where mice and rats are ported, so they'd seek out cheese to eat. I also also think it's a neat way for a cow to heal. * Cows can eat wheat off the ground. If cows see wheat on the ground, they'll try to go eat it (+ moonicorns with galaxy thistle) Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
75 lines
2.8 KiB
Plaintext
75 lines
2.8 KiB
Plaintext
/**find and set
|
|
* Finds an item near themselves, sets a blackboard key as it. Very useful for ais that need to use machines or something.
|
|
* if you want to do something more complicated than find a single atom, change the search_tactic() proc
|
|
* cool tip: search_tactic() can set lists
|
|
*/
|
|
/datum/ai_behavior/find_and_set
|
|
action_cooldown = 2 SECONDS
|
|
|
|
/datum/ai_behavior/find_and_set/perform(delta_time, datum/ai_controller/controller, set_key, locate_path, search_range)
|
|
. = ..()
|
|
var/find_this_thing = search_tactic(controller, locate_path, search_range)
|
|
if(find_this_thing)
|
|
controller.blackboard[set_key] = WEAKREF(find_this_thing)
|
|
finish_action(controller, TRUE)
|
|
else
|
|
finish_action(controller, FALSE)
|
|
|
|
/datum/ai_behavior/find_and_set/proc/search_tactic(datum/ai_controller/controller, locate_path, search_range)
|
|
return locate(locate_path) in oview(search_range, controller.pawn)
|
|
|
|
/**
|
|
* Variant of find and set that fails if the living pawn doesn't hold something
|
|
*/
|
|
/datum/ai_behavior/find_and_set/pawn_must_hold_item
|
|
|
|
/datum/ai_behavior/find_and_set/pawn_must_hold_item/search_tactic(datum/ai_controller/controller)
|
|
var/mob/living/living_pawn = controller.pawn
|
|
if(!living_pawn.get_num_held_items())
|
|
return //we want to fail the search if we don't have something held
|
|
return ..()
|
|
|
|
/**
|
|
* Variant of find and set that also requires the item to be edible. checks hands too
|
|
*/
|
|
/datum/ai_behavior/find_and_set/edible
|
|
|
|
/datum/ai_behavior/find_and_set/edible/search_tactic(datum/ai_controller/controller, locate_path, search_range)
|
|
var/mob/living/living_pawn = controller.pawn
|
|
var/list/food_candidates = list()
|
|
for(var/held_candidate as anything in living_pawn.held_items)
|
|
if(!held_candidate || !IsEdible(held_candidate))
|
|
continue
|
|
food_candidates += held_candidate
|
|
|
|
var/list/local_results = locate(locate_path) in oview(search_range, controller.pawn)
|
|
for(var/local_candidate in local_results)
|
|
if(!IsEdible(local_candidate))
|
|
continue
|
|
food_candidates += local_candidate
|
|
if(food_candidates.len)
|
|
return pick(food_candidates)
|
|
|
|
/**
|
|
* Variant of find and set that only checks in hands, search range should be excluded for this
|
|
*/
|
|
/datum/ai_behavior/find_and_set/in_hands
|
|
|
|
/datum/ai_behavior/find_and_set/in_hands/search_tactic(datum/ai_controller/controller, locate_path)
|
|
var/mob/living/living_pawn = controller.pawn
|
|
return locate(locate_path) in living_pawn.held_items
|
|
|
|
/**
|
|
* Variant of find and set that takes a list of things to find.
|
|
*/
|
|
/datum/ai_behavior/find_and_set/in_list
|
|
|
|
/datum/ai_behavior/find_and_set/in_list/search_tactic(datum/ai_controller/controller, locate_paths, search_range)
|
|
var/list/found = list()
|
|
for(var/locate_path in locate_paths)
|
|
var/single_locate = ..(controller, locate_path, search_range)
|
|
if(single_locate)
|
|
found += single_locate
|
|
if(found.len)
|
|
return pick(found)
|