Files
Bubberstation/code/datums/ai/_ai_behavior.dm
Emmett Gaines 4367cb09bd Adds new wrinkles to monkey brains (#58631)
This does a variety of improvements to monkey ai that I got drawn into after fixing a relatively simple bug with monkeys and guns. This pr is in support of #58565 so that in the rare chance pun pun gets a gun, they know how to use it. Previously #16630 made it so monkeys could use guns but semi-recently that was broken. Now that's fixed and in addition some other monkey ai capabilities were enhanced, read the changelog for the full list.
2021-05-04 08:32:31 +01:00

27 lines
1.2 KiB
Plaintext

///Abstract class for an action an AI can take, can range from movement to grabbing a nearby weapon.
/datum/ai_behavior
///What distance you need to be from the target to perform the action
var/required_distance = 1
///Flags for extra behavior
var/behavior_flags = NONE
///Cooldown between actions performances
var/action_cooldown = 0
/// Called by the ai controller when first being added. Additional arguments depend on the behavior type.
/// Return FALSE to cancel
/datum/ai_behavior/proc/setup(datum/ai_controller/controller, ...)
return TRUE
///Called by the AI controller when this action is performed
/datum/ai_behavior/proc/perform(delta_time, datum/ai_controller/controller, ...)
controller.behavior_cooldowns[src] = world.time + action_cooldown
return
///Called when the action is finished.
/datum/ai_behavior/proc/finish_action(datum/ai_controller/controller, succeeded)
controller.current_behaviors.Remove(src)
controller.behavior_args -= type
if(behavior_flags & AI_BEHAVIOR_REQUIRE_MOVEMENT) //If this was a movement task, reset our movement target.
controller.current_movement_target = null
controller.ai_movement.stop_moving_towards(controller)