mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 02:32:10 +00:00
* Monkey subtree breakup refactor! (#61741) Splitting up monkey ai into subtrees allows me to make a punpun ai after this pr is merged, makes stopping planning matter for the AI subtrees, and more generic subtrees that can be used by most ais It also gets rid of bad practices like setting blackboards in the ai controller. * Monkey subtree breakup refactor! Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
47 lines
1.6 KiB
Plaintext
47 lines
1.6 KiB
Plaintext
//this file has procs that help ais think good. used by behaviors mostly
|
|
|
|
|
|
/// Returns either the best weapon from the given choices or null if held weapons are better
|
|
/proc/GetBestWeapon(datum/ai_controller/controller, list/choices, list/held_weapons)
|
|
var/gun_neurons_activated = controller.blackboard[BB_MONKEY_GUN_NEURONS_ACTIVATED]
|
|
var/top_force = 0
|
|
var/obj/item/top_force_item
|
|
for(var/obj/item/item as anything in held_weapons)
|
|
if(!item)
|
|
continue
|
|
if(HAS_TRAIT(item, TRAIT_NEEDS_TWO_HANDS) || controller.blackboard[BB_MONKEY_BLACKLISTITEMS][item])
|
|
continue
|
|
if(gun_neurons_activated && istype(item, /obj/item/gun))
|
|
// We have a gun, why bother looking for something inferior
|
|
// Also yes it is intentional that pawns dont know how to pick the best gun
|
|
return item
|
|
if(item.force > top_force)
|
|
top_force = item.force
|
|
top_force_item = item
|
|
|
|
for(var/obj/item/item as anything in choices)
|
|
if(!item)
|
|
continue
|
|
if(HAS_TRAIT(item, TRAIT_NEEDS_TWO_HANDS) || controller.blackboard[BB_MONKEY_BLACKLISTITEMS][item])
|
|
continue
|
|
if(gun_neurons_activated && istype(item, /obj/item/gun))
|
|
return item
|
|
if(item.force <= top_force)
|
|
continue
|
|
top_force_item = item
|
|
top_force = item.force
|
|
|
|
return top_force_item
|
|
|
|
///returns if something can be consumed, drink or food
|
|
/proc/IsEdible(obj/item/thing)
|
|
if(!istype(thing))
|
|
return FALSE
|
|
if(IS_EDIBLE(thing))
|
|
return TRUE
|
|
if(istype(thing, /obj/item/reagent_containers/food/drinks/drinkingglass))
|
|
var/obj/item/reagent_containers/food/drinks/drinkingglass/glass = thing
|
|
if(glass.reagents.total_volume) // The glass has something in it, time to drink the mystery liquid!
|
|
return TRUE
|
|
return FALSE
|