This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| dragengine:modules:dragonscript:behavior_behaviortree [2025/03/13 18:30] – ↷ Links adapted because of a move operation dragonlord | dragengine:modules:dragonscript:behavior_behaviortree [2026/10/11 15:05] (current) – dragonlord | ||
|---|---|---|---|
| Line 36: | Line 36: | ||
| See also: | See also: | ||
| - | * [[dragengine: | + | * [[dragengine: |
| ====== Instance Counts ====== | ====== Instance Counts ====== | ||
| Line 49: | Line 49: | ||
| * Type: string | * Type: string | ||
| * Default Value: empty string | * Default Value: empty string | ||
| - | * Expected File Type: '' | + | * Expected File Type: '' |
| - | * Example (*.deeclass) <code xml>< | + | * Example (*.deeclass) <code xml>< |
| ===== run ===== | ===== run ===== | ||
| Line 71: | Line 71: | ||
| ===== behaviorTreeRestarted ===== | ===== behaviorTreeRestarted ===== | ||
| Behavior tree has been restarted. | Behavior tree has been restarted. | ||
| + | |||
| + | |||
| + | ====== Behavior Tree Actions ====== | ||
| + | |||
| + | This behavior adds these behavior tree actions. | ||
| + | |||
| + | ===== element.set ===== | ||
| + | |||
| + | Set owner element parameters. | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |visible|true, | ||
| + | |touchable|true, | ||
| + | |||
| + | This is an example of using this action to fully hide the owner element: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== element.update ===== | ||
| + | |||
| + | Update owner element. | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |dispose| |Dispose of owner element. Make sure this is the last action run in a transition or state. Running actions afterwards can lead to problems.| | ||
| + | |log|string|Print a log message using Element.log() function.| | ||
| + | |||
| + | This is an example of using this action to dispose element: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== gameWorld ===== | ||
| + | |||
| + | Runs action from game world behavior [[gwbehavior_btsm|GWBehaviorBTSM]]. Game world behaviors can add behavior tree actions to GWBehaviorBTSM similar to how element class behaviors can add behavior tree actions to this behavior. This allows behavior trees to access actions specific to a game world. The action is run as if it has been added to this behavior. All parameters defined in the action are passed to the game world actionndition with the addition of the parameter '' | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |action|string|Name of action to run.| | ||
| + | |||
| + | This is an example of using this action to spawn a new element: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ====== Behavior Tree Conditions ====== | ||
| + | |||
| + | This behavior adds these behavior tree conditions. | ||
| + | |||
| + | ===== element.check ===== | ||
| + | |||
| + | Evaluate owner element parameters. | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |element.visible|true, | ||
| + | |element.touchable|true, | ||
| + | |element.inGameWorld|true, | ||
| + | |element.hasParent|true, | ||
| + | |||
| + | This is an example of using this condition to check if the element is visible, touchable, in a game world and not parented to another element: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== gameWorld ===== | ||
| + | |||
| + | Evaluate condition from game world behavior [[gwbehavior_btsm|GWBehaviorBTSM]]. Game world behaviors can add behavior tree conditions to GWBehaviorBTSM similar to how element class behaviors can add behavior tree conditions to this behavior. This allows behavior trees to access conditions specific to a game world. The condition is evaluated as if it has been added to this behavior. All parameters defined in the condition are passed to the game world condition with the addition of the parameter '' | ||
| + | |||
| + | ^Parameter^Value^Description^ | ||
| + | |gameWorld.condition|string|Name of condition to evaluate.| | ||
| + | |||
| + | This is an example of using this condition to evaluate a game state: | ||
| + | <code xml> | ||
| + | <action name=' | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| ====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
| Line 104: | Line 199: | ||
| func new() | func new() | ||
| var ECBehaviorBehaviorTree btbehavior = ECBehaviorBehaviorTree.new(this) | var ECBehaviorBehaviorTree btbehavior = ECBehaviorBehaviorTree.new(this) | ||
| - | btbehavior.getPath().setValue("/ | + | btbehavior.getPath().setValue("/ |
| btbehavior.getRun().setValue(true) | btbehavior.getRun().setValue(true) | ||
| | | ||
| Line 122: | Line 217: | ||
| func new() | func new() | ||
| var ECBehaviorBehaviorTree btSpecific = ECBehaviorBehaviorTree.new(this, | var ECBehaviorBehaviorTree btSpecific = ECBehaviorBehaviorTree.new(this, | ||
| - | btSpecific.getPath().setValue("/ | + | btSpecific.getPath().setValue("/ |
| btSpecific.getRun().setValue(true) | btSpecific.getRun().setValue(true) | ||
| | | ||
| var ECBehaviorBehaviorTree btIdle = ECBehaviorBehaviorTree.new(this, | var ECBehaviorBehaviorTree btIdle = ECBehaviorBehaviorTree.new(this, | ||
| - | btIdle.getPath().setValue("/ | + | btIdle.getPath().setValue("/ |
| btIdle.getRun().setValue(true) | btIdle.getRun().setValue(true) | ||
| | | ||
| Line 142: | Line 237: | ||
| func new() | func new() | ||
| var ECBehaviorBehaviorTree btree = ECBehaviorBehaviorTree.new(this) | var ECBehaviorBehaviorTree btree = ECBehaviorBehaviorTree.new(this) | ||
| - | btSpecific.getPath().setValue("/ | + | btSpecific.getPath().setValue("/ |
| // | // | ||
| | | ||
| Line 154: | Line 249: | ||
| func new() | func new() | ||
| // load behavior tree to use. this is not required but allows to use different | // load behavior tree to use. this is not required but allows to use different | ||
| - | // behavior trees for different AI routines. if not used the "/ | + | // behavior trees for different AI routines. if not used the "/ |
| // would be used as defined in MyElementClass. | // would be used as defined in MyElementClass. | ||
| var BehaviorTree btree = BaseGameApp.getApp().getLoaders() \ | var BehaviorTree btree = BaseGameApp.getApp().getLoaders() \ | ||
| - | .getBehaviorTree().loadFromFile("/ | + | .getBehaviorTree().loadFromFile("/ |
| | | ||
| // create context. BAAIBehaviorTree requires a BTContextAI subclass hence we can | // create context. BAAIBehaviorTree requires a BTContextAI subclass hence we can | ||
| Line 206: | Line 301: | ||
| < | < | ||
| <!-- set element properties. omit property prefix if used inside behavior tag --> | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
| - | <string name=' | + | <string name=' |
| </ | </ | ||
| | | ||