mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 13:37:58 +01:00
51 lines
19 KiB
HTML
51 lines
19 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../"><link rel="stylesheet" href="dmdoc.css"><title>/datum/ai_behavior - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a> — <a href="datum/ai_behavior.html#var">Var Details</a> - <a href="datum/ai_behavior.html#proc">Proc Details</a></header><main><h1>ai_behavior <aside>/<a href="datum.html">datum</a>/<a href="datum/ai_behavior.html">ai_behavior</a></aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L2"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 2"></a></h1><p>Abstract class for an action an AI can take. Can range from movement to grabbing a nearby weapon.</p><table class="summary" cellspacing="0"><tr><td colspan="2"><h2>Vars</h2></td></tr><tr><th><a href="datum/ai_behavior.html#var/action_cooldown">action_cooldown</a></th><td>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</td></tr><tr><th><a href="datum/ai_behavior.html#var/behavior_flags">behavior_flags</a></th><td>Flags for extra behavior</td></tr><tr><th><a href="datum/ai_behavior.html#var/goap_weight">goap_weight</a></th><td>A multiplier applied to the behavior's goap_score().</td></tr><tr><th><a href="datum/ai_behavior.html#var/required_distance">required_distance</a></th><td>What distance you need to be from the target to perform the action.</td></tr><tr><th><a href="datum/ai_behavior.html#var/search_radius_override">search_radius_override</a></th><td>If >0, overrides controller.target_search_radius</td></tr><tr><th><a href="datum/ai_behavior.html#var/sub_behaviors">sub_behaviors</a></th><td>Behaviors to add upon a successful setup</td></tr><tr><td colspan="2"><h2>Procs</h2></td></tr><tr><th><a href="datum/ai_behavior.html#proc/clear_movement_target">clear_movement_target</a></th><td>Clear the controller's movement target only if it was us who last set it</td></tr><tr><th><a href="datum/ai_behavior.html#proc/finish_action">finish_action</a></th><td>Called when the action is finished. This needs the same args as <code>perform</code>
|
||
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.
|
||
<code>succeeded</code> is <code>TRUE</code> or <code>FALSE</code> depending on whether
|
||
<a href="datum/ai_behavior.html#proc/perform" title="/datum/ai_behavior">/datum/ai_behavior/proc/perform</a> returns <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_SUCCEEDED" title="AI_BEHAVIOR_SUCCEEDED">AI_BEHAVIOR_SUCCEEDED</a> or
|
||
<a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_FAILED" title="AI_BEHAVIOR_FAILED">AI_BEHAVIOR_FAILED</a>.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/get_best_target_by_distance_score">get_best_target_by_distance_score</a></th><td>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.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/get_cooldown">get_cooldown</a></th><td>Returns the delay to use for this behavior in the moment. The default
|
||
behavior cooldown is <code>CLICK_CD_MELEE</code>, but can be customized; for example,
|
||
you may want a mob crawling through vents to move slowly and at a random
|
||
pace between pipes.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_filter_targets">goap_filter_targets</a></th><td>Filter through potential targets to find real targets.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_get_ideal_target">goap_get_ideal_target</a></th><td>Returns the ideal target for this behavior.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_get_potential_targets">goap_get_potential_targets</a></th><td>Returns a list of potential targets to filter through.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_is_valid_target">goap_is_valid_target</a></th><td>Returns TRUE if the given atom is a valid target for this behavior.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_precondition">goap_precondition</a></th><td>Executed before goap_score(), to see if the behavior should even be considered.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/goap_score">goap_score</a></th><td>Returns a numerical value that is essentially a priority for planner behaviors.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/next_behavior">next_behavior</a></th><td>Returns a behavior to perform after this one, or null if continuing this one</td></tr><tr><th><a href="datum/ai_behavior.html#proc/perform">perform</a></th><td>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 <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_DELAY" title="AI_BEHAVIOR_DELAY">AI_BEHAVIOR_DELAY</a> or
|
||
[AI_BEHAVIOR_INSTANT], determining whether or not a cooldown occurs, and
|
||
<a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_SUCCEEDED" title="AI_BEHAVIOR_SUCCEEDED">AI_BEHAVIOR_SUCCEEDED</a> or <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_FAILED" title="AI_BEHAVIOR_FAILED">AI_BEHAVIOR_FAILED</a>. The behavior's
|
||
<code>finish_action</code> proc is given TRUE or FALSE depending on whether or not the
|
||
return value of <code>perform</code> is marked as successful or unsuccessful.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/score_distance">score_distance</a></th><td>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.</td></tr><tr><th><a href="datum/ai_behavior.html#proc/set_movement_target">set_movement_target</a></th><td>Helper proc to ensure consistency in setting the source of the movement target</td></tr><tr><th><a href="datum/ai_behavior.html#proc/setup">setup</a></th><td>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.</td></tr></table><h2 id="var">Var Details</h2><h3 id="var/action_cooldown"><aside class="declaration">var </aside>action_cooldown <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L12"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 12"></a></h3><p>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</p><h3 id="var/behavior_flags"><aside class="declaration">var </aside>behavior_flags <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L8"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 8"></a></h3><p>Flags for extra behavior</p><h3 id="var/goap_weight"><aside class="declaration">var </aside>goap_weight <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L14"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 14"></a></h3><p>A multiplier applied to the behavior's goap_score().</p><h3 id="var/required_distance"><aside class="declaration">var </aside>required_distance <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L4"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 4"></a></h3><p>What distance you need to be from the target to perform the action.</p><h3 id="var/search_radius_override"><aside class="declaration">var </aside>search_radius_override <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L6"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 6"></a></h3><p>If >0, overrides controller.target_search_radius</p><h3 id="var/sub_behaviors"><aside class="declaration">var </aside>sub_behaviors <aside>– /list</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L17"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 17"></a></h3><p>Behaviors to add upon a successful setup</p><h2 id="proc">Proc Details</h2><h3 id="proc/clear_movement_target"><aside class="declaration">proc </aside>clear_movement_target<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L70"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 70"></a></aside></h3><p>Clear the controller's movement target only if it was us who last set it</p><h3 id="proc/finish_action"><aside class="declaration">proc </aside>finish_action<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, succeeded, ...) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L52"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 52"></a></aside></h3><p>Called when the action is finished. This needs the same args as <code>perform</code>
|
||
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.
|
||
<code>succeeded</code> is <code>TRUE</code> or <code>FALSE</code> depending on whether
|
||
<a href="datum/ai_behavior.html#proc/perform" title="/datum/ai_behavior">/datum/ai_behavior/proc/perform</a> returns <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_SUCCEEDED" title="AI_BEHAVIOR_SUCCEEDED">AI_BEHAVIOR_SUCCEEDED</a> or
|
||
<a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_FAILED" title="AI_BEHAVIOR_FAILED">AI_BEHAVIOR_FAILED</a>.</p><h3 id="proc/get_best_target_by_distance_score"><aside class="declaration">proc </aside>get_best_target_by_distance_score<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, /list/targets, set_path) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L134"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 134"></a></aside></h3><p>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.</p><h3 id="proc/get_cooldown"><aside class="declaration">proc </aside>get_cooldown<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/cooldown_for) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L30"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 30"></a></aside></h3><p>Returns the delay to use for this behavior in the moment. The default
|
||
behavior cooldown is <code>CLICK_CD_MELEE</code>, but can be customized; for example,
|
||
you may want a mob crawling through vents to move slowly and at a random
|
||
pace between pipes.</p><h3 id="proc/goap_filter_targets"><aside class="declaration">proc </aside>goap_filter_targets<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L93"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 93"></a></aside></h3><p>Filter through potential targets to find real targets.</p><h3 id="proc/goap_get_ideal_target"><aside class="declaration">proc </aside>goap_get_ideal_target<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, set_path) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L88"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 88"></a></aside></h3><p>Returns the ideal target for this behavior.</p><h3 id="proc/goap_get_potential_targets"><aside class="declaration">proc </aside>goap_get_potential_targets<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L101"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 101"></a></aside></h3><p>Returns a list of potential targets to filter through.</p><h3 id="proc/goap_is_valid_target"><aside class="declaration">proc </aside>goap_is_valid_target<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, /<a href="atom.html">atom</a>/target) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L105"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 105"></a></aside></h3><p>Returns TRUE if the given atom is a valid target for this behavior.</p><h3 id="proc/goap_precondition"><aside class="declaration">proc </aside>goap_precondition<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L80"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 80"></a></aside></h3><p>Executed before goap_score(), to see if the behavior should even be considered.</p><h3 id="proc/goap_score"><aside class="declaration">proc </aside>goap_score<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L84"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 84"></a></aside></h3><p>Returns a numerical value that is essentially a priority for planner behaviors.</p><h3 id="proc/next_behavior"><aside class="declaration">proc </aside>next_behavior<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, success) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L76"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 76"></a></aside></h3><p>Returns a behavior to perform after this one, or null if continuing this one</p><h3 id="proc/perform"><aside class="declaration">proc </aside>perform<aside>(seconds_per_tick, /<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, ...) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L41"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 41"></a></aside></h3><p>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 <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_DELAY" title="AI_BEHAVIOR_DELAY">AI_BEHAVIOR_DELAY</a> or
|
||
[AI_BEHAVIOR_INSTANT], determining whether or not a cooldown occurs, and
|
||
<a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_SUCCEEDED" title="AI_BEHAVIOR_SUCCEEDED">AI_BEHAVIOR_SUCCEEDED</a> or <a href="code/__DEFINES/ai/ai_defines.html#define/AI_BEHAVIOR_FAILED" title="AI_BEHAVIOR_FAILED">AI_BEHAVIOR_FAILED</a>. The behavior's
|
||
<code>finish_action</code> proc is given TRUE or FALSE depending on whether or not the
|
||
return value of <code>perform</code> is marked as successful or unsuccessful.</p><h3 id="proc/score_distance"><aside class="declaration">proc </aside>score_distance<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, /<a href="atom.html">atom</a>/target) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L196"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 196"></a></aside></h3><p>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.</p><h3 id="proc/set_movement_target"><aside class="declaration">proc </aside>set_movement_target<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, /<a href="atom.html">atom</a>/target, /<a href="datum.html">datum</a>/<a href="datum/ai_movement.html">ai_movement</a>/new_movement) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L66"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 66"></a></aside></h3><p>Helper proc to ensure consistency in setting the source of the movement target</p><h3 id="proc/setup"><aside class="declaration">proc </aside>setup<aside>(/<a href="datum.html">datum</a>/<a href="datum/ai_controller.html">ai_controller</a>/controller, ...) <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/datums/ai/ai_behavior.dm#L23"><img src="git.png" width="16" height="16" title="code/datums/ai/ai_behavior.dm 23"></a></aside></h3><p>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.</p></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/8a8a00a2a9bec485351e5f219982b7315d3504fa">8a8a00a</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html> |