This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:behaviortrees [2025/03/13 18:30] – ↷ Page moved and renamed from formats:modules:debtree:xml_behavior_tree_file_.debtree to dragengine:modules:dragonscript:behaviortrees dragonlord | dragengine:modules:dragonscript:behaviortrees [2025/06/12 17:01] (current) – [File Format (*.debt)] dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
- | ====== Behavior | + | ====== Behavior |
- | The behavior tree file format is recognized by the LoadBehaviorTree script class. The file is an XML file with a simple structure to define a behavior tree using XML. | + | Behavior trees are structured |
- | + | ||
- | Behavior trees are structured | + | |
Each can also have one or more conditions assigned. Before each run of the rule the conditions are evaluated. If any of the conditions evaluates to false the rule fails. Only the conditions of the active rule are evaluated. The conditions of the parent rule are only evaluated if the active node returns anything else but '' | Each can also have one or more conditions assigned. Before each run of the rule the conditions are evaluated. If any of the conditions evaluates to false the rule fails. Only the conditions of the active rule are evaluated. The conditions of the parent rule are only evaluated if the active node returns anything else but '' | ||
Line 70: | Line 68: | ||
The main use for this rule is to force waiting until a rule conditions fails. | The main use for this rule is to force waiting until a rule conditions fails. | ||
- | ====== | + | Since this rules returns '' |
+ | <code xml> | ||
+ | <running id=' | ||
+ | </ | ||
+ | |||
+ | ===== Yield ===== | ||
+ | |||
+ | Returns '' | ||
+ | |||
+ | This rule causes the behavior tree to yield processing for one frame update to continue with the next rule the next time it is run. This rule prevents endless choice loops. Choice loops happen if all rules in a looping choice are not applying. The last rule has to be a rule returning '' | ||
+ | |||
+ | This rule can also be used to add single frame delays in a behavior tree, for example to ensure actors are not running actions too fast. | ||
+ | |||
+ | Since this rules can return '' | ||
+ | <code xml> | ||
+ | <yield id=' | ||
+ | </ | ||
+ | |||
+ | ====== File Format (*.debt) ====== | ||
+ | |||
+ | The behavior tree file format is recognized by the LoadBehaviorTree script class. The file is an XML file with a simple structure to define a behavior tree using XML. See [[https:// | ||
<uml> | <uml> | ||
@startuml | @startuml | ||
Line 81: | Line 100: | ||
|failure|| | |failure|| | ||
|running|| | |running|| | ||
+ | |yield|| | ||
|subtree| | |subtree| | ||
} | } | ||
Line 101: | Line 121: | ||
|failure|| | |failure|| | ||
|running|| | |running|| | ||
+ | |yield|| | ||
|subtree| | |subtree| | ||
} | } | ||
Line 115: | Line 136: | ||
|failure|| | |failure|| | ||
|running|| | |running|| | ||
+ | |yield|| | ||
|subtree| | |subtree| | ||
} | } | ||
Line 139: | Line 161: | ||
} | } | ||
behaviorTree --> running | behaviorTree --> running | ||
+ | |||
+ | object " | ||
+ | <# | ||
+ | |condition| | ||
+ | |conditionMode| | ||
+ | } | ||
+ | behaviorTree --> yield | ||
+ | |||
+ | object " | ||
+ | <# | ||
+ | |condition| | ||
+ | |conditionMode| | ||
+ | } | ||
+ | behaviorTree --> subtree | ||
@enduml | @enduml | ||
Line 154: | Line 190: | ||
|failure|Add failure rule|0..N|-| | |failure|Add failure rule|0..N|-| | ||
|running|Add running rule|0..N|-| | |running|Add running rule|0..N|-| | ||
+ | |yield|Add yield rule|0..N|-| | ||
|subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | |subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | ||
Line 162: | Line 199: | ||
^Attribute^Description^Occurance^Default^ | ^Attribute^Description^Occurance^Default^ | ||
|name|Name of action to run.|Required|-| | |name|Name of action to run.|Required|-| | ||
+ | |id|Rule identifier. Required for actions potentially returning '' | ||
+ | |doNotFail|If action fails return '' | ||
^Tag^Description^Occurance^Default^ | ^Tag^Description^Occurance^Default^ | ||
Line 181: | Line 220: | ||
^Attribute^Description^Occurance^Default^ | ^Attribute^Description^Occurance^Default^ | ||
|loop|Loop sequence.|Optional|'' | |loop|Loop sequence.|Optional|'' | ||
+ | |id|Rule identifier. Used to support persistance. If identifier starts with '' | ||
|doNotFail|If sequence fails return '' | |doNotFail|If sequence fails return '' | ||
Line 200: | Line 240: | ||
|failure|Add failure rule|0..N|-| | |failure|Add failure rule|0..N|-| | ||
|running|Add running rule|0..N|-| | |running|Add running rule|0..N|-| | ||
+ | |yield|Add yield rule|0..N|-| | ||
|subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | |subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | ||
Line 208: | Line 249: | ||
^Attribute^Description^Occurance^Default^ | ^Attribute^Description^Occurance^Default^ | ||
|loop|Loop choice.|Optional|'' | |loop|Loop choice.|Optional|'' | ||
+ | |id|Rule identifier. Used to support persistance. If identifier starts with '' | ||
|doNotFail|If choice fails return '' | |doNotFail|If choice fails return '' | ||
Line 227: | Line 269: | ||
|failure|Add failure rule|0..N|-| | |failure|Add failure rule|0..N|-| | ||
|running|Add running rule|0..N|-| | |running|Add running rule|0..N|-| | ||
+ | |yield|Add yield rule|0..N|-| | ||
|subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | |subtree|Load behavior tree using path from tag text content. Subtree is added to the behavior tree as a sequence rule containing the loaded behavior tree|0..N|-| | ||
Line 264: | Line 307: | ||
Adds a running rule. | Adds a running rule. | ||
+ | |||
+ | ^Attribute^Description^Occurance^Default^ | ||
+ | |id|Rule identifier. Required to support persistance. If identifier starts with '' | ||
+ | |||
+ | ^Tag^Description^Occurance^Default^ | ||
+ | |parameter|< | ||
+ | * '' | ||
+ | </ | ||
+ | |condition|Add condition. Condition name is text content of node|0..N|-| | ||
+ | |conditionMode|< | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | </ | ||
+ | |||
+ | ===== yield ===== | ||
+ | |||
+ | Adds a yield rule. | ||
+ | |||
+ | ^Attribute^Description^Occurance^Default^ | ||
+ | |id|Rule identifier. Required to support persistance. If identifier starts with '' | ||
^Tag^Description^Occurance^Default^ | ^Tag^Description^Occurance^Default^ |