ai_behavior 
Abstract class for an action an AI can take. Can range from movement to grabbing a nearby weapon.
Vars | |
| action_cooldown | Cooldown between actions performances, defaults to the value of CLICK_CD_MELEE because that seemed like a nice standard for the speed of AI behavior |
|---|---|
| behavior_flags | Flags for extra behavior |
| goap_weight | A multiplier applied to the behavior's goap_score(). |
| required_distance | What distance you need to be from the target to perform the action. |
| search_radius_override | If >0, overrides controller.target_search_radius |
| sub_behaviors | Behaviors to add upon a successful setup |
Procs | |
| clear_movement_target | Clear the controller's movement target only if it was us who last set it |
| finish_action | Called when the action is finished. This needs the same args as perform
besides the default ones. This should be used to clear up the blackboard of
any unnecessary or obsolete data, and update the state of the pawn if
necessary once we know whether or not the AI action was successful.
succeeded is TRUE or FALSE depending on whether
/datum/ai_behavior/proc/perform returns AI_BEHAVIOR_SUCCEEDED or
AI_BEHAVIOR_FAILED. |
| get_best_target_by_distance_score | Returns the best target by scoring the distance of each possible target. Takes a list to insert the path into, so it can be handed back and re-used. |
| get_cooldown | Returns the delay to use for this behavior in the moment. The default
behavior cooldown is CLICK_CD_MELEE, but can be customized; for example,
you may want a mob crawling through vents to move slowly and at a random
pace between pipes. |
| goap_filter_targets | Filter through potential targets to find real targets. |
| goap_get_ideal_target | Returns the ideal target for this behavior. |
| goap_get_potential_targets | Returns a list of potential targets to filter through. |
| goap_is_valid_target | Returns TRUE if the given atom is a valid target for this behavior. |
| goap_precondition | Executed before goap_score(), to see if the behavior should even be considered. |
| goap_score | Returns a numerical value that is essentially a priority for planner behaviors. |
| next_behavior | Returns a behavior to perform after this one, or null if continuing this one |
| perform | Called by the AI controller when this action is performed. This will
typically require consulting the blackboard for information on the specific
actions desired from this behavior, by passing the relevant blackboard data
keys to this proc. Returns a combination of AI_BEHAVIOR_DELAY or
[AI_BEHAVIOR_INSTANT], determining whether or not a cooldown occurs, and
AI_BEHAVIOR_SUCCEEDED or AI_BEHAVIOR_FAILED. The behavior's
finish_action proc is given TRUE or FALSE depending on whether or not the
return value of perform is marked as successful or unsuccessful. |
| score_distance | Helper for scoring something based on the distance between it and the pawn. By default, returns a value between 100 and -INFINITY, where 100 is a distance of 0 steps. A distance equal to target_search_radius is zero. A distance greater than target_search_radius is negative. |
| set_movement_target | Helper proc to ensure consistency in setting the source of the movement target |
| setup | Called by the AI controller when first being added. Additional arguments depend on the behavior type. For example, if the behavior involves attacking a mob, you may require an argument naming the blackboard key which points to the target. Return FALSE to cancel. |
Var Details
action_cooldown 
Cooldown between actions performances, defaults to the value of CLICK_CD_MELEE because that seemed like a nice standard for the speed of AI behavior
behavior_flags 
Flags for extra behavior
goap_weight 
A multiplier applied to the behavior's goap_score().
required_distance 
What distance you need to be from the target to perform the action.
search_radius_override 
If >0, overrides controller.target_search_radius
sub_behaviors 
Behaviors to add upon a successful setup
Proc Details
clear_movement_target
Clear the controller's movement target only if it was us who last set it
finish_action
Called when the action is finished. This needs the same args as perform
besides the default ones. This should be used to clear up the blackboard of
any unnecessary or obsolete data, and update the state of the pawn if
necessary once we know whether or not the AI action was successful.
succeeded is TRUE or FALSE depending on whether
/datum/ai_behavior/proc/perform returns AI_BEHAVIOR_SUCCEEDED or
AI_BEHAVIOR_FAILED.
get_best_target_by_distance_score
Returns the best target by scoring the distance of each possible target. Takes a list to insert the path into, so it can be handed back and re-used.
get_cooldown
Returns the delay to use for this behavior in the moment. The default
behavior cooldown is CLICK_CD_MELEE, but can be customized; for example,
you may want a mob crawling through vents to move slowly and at a random
pace between pipes.
goap_filter_targets
Filter through potential targets to find real targets.
goap_get_ideal_target
Returns the ideal target for this behavior.
goap_get_potential_targets
Returns a list of potential targets to filter through.
goap_is_valid_target
Returns TRUE if the given atom is a valid target for this behavior.
goap_precondition
Executed before goap_score(), to see if the behavior should even be considered.
goap_score
Returns a numerical value that is essentially a priority for planner behaviors.
next_behavior
Returns a behavior to perform after this one, or null if continuing this one
perform
Called by the AI controller when this action is performed. This will
typically require consulting the blackboard for information on the specific
actions desired from this behavior, by passing the relevant blackboard data
keys to this proc. Returns a combination of AI_BEHAVIOR_DELAY or
[AI_BEHAVIOR_INSTANT], determining whether or not a cooldown occurs, and
AI_BEHAVIOR_SUCCEEDED or AI_BEHAVIOR_FAILED. The behavior's
finish_action proc is given TRUE or FALSE depending on whether or not the
return value of perform is marked as successful or unsuccessful.
score_distance
Helper for scoring something based on the distance between it and the pawn. By default, returns a value between 100 and -INFINITY, where 100 is a distance of 0 steps. A distance equal to target_search_radius is zero. A distance greater than target_search_radius is negative.
set_movement_target
Helper proc to ensure consistency in setting the source of the movement target
setup
Called by the AI controller when first being added. Additional arguments depend on the behavior type. For example, if the behavior involves attacking a mob, you may require an argument naming the blackboard key which points to the target. Return FALSE to cancel.