{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorBehaviorTreeFlags**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorBehaviorTreeFlags ======
Behavior element behavior adding flags support to behavior tree support.
Behavior adds behavior tree actions and conditions to an ECBehaviorBehaviorTree allowing scripts and behavior trees to set, clear and check flags.
====== Instance Counts ======
This behavior can be added multiple times to an element for each ECBehaviorBehaviorTree. Each instance creates an own set of behavior tree actions, conditions and flags.
====== Element Class Properties ======
Element class properties have the prefix ''behaviorTreeFlags.'' or ''behaviorTreeFlags({id}).'' if id is not empty.
====== Events ======
This behavior has no events.
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions.
===== flags.set =====
Set a flag. As parameter use ''flag'' to select the flag to set. Use optional parameter ''clear'' to clear flag. This action immediately returns and does not require a rule identifier.
This is an example of using this action:
arrived at target
This is an example of using this action to clear flag:
arrived at target
===== flags.check =====
Checks if flag is set. Use as parameter ''flag'' to select the flag to check. Use as optional parameter ''cleared'' to check for flag to be cleared instead of set. Use the optional parameter ''wait'' to wait until the flag is set or cleared. If not waiting the action returns immediately with ''BTResult.success'' if the flag is set otherwise ''BTResult.failure''. If waiting the action keeps running until the flags becomes set or cleared then returns ''BTResult.success''. A flag that has not been used so far is in cleared state. Use the optional parameter ''reset'' to toggle the flag if condition is finished. Hence if ''reset'' is used and the flag is set it is reset. This can be used for waiting and not waiting.
This is an example of using this action to check if a flag is set right now:
arrived at target
This is an example of using this action to check if a flag is cleared right now:
arrived at target
This is an example of using this action waiting until the flag is set:
arrived at target
This is an example of using this action waiting until the flag is set and then clear it:
arrived at target
====== Behavior Tree Conditions ======
This behavior adds these behavior tree conditions.
===== flags.state =====
Determines if flag is set. Use as parameter ''flag'' to select the flag to check. Use optional parameter ''flags.cleared'' to check if the flag is cleared instead of set.
This is an example of an action that can only run if the flag ''arrived at target'' is set:
arrived at target
flags.state
This is an example of an action that can only run if the flag ''arrived at target'' is cleared:
arrived at target
flags.state
====== Required Behaviors ======
* [[behavior_behaviortree|ECBehaviorBehaviorTree]]
====== Optional Behaviors ======
This behavior does not support optional behaviors.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorBehaviorTreeFlags.html,ECBehaviorBehaviorTreeFlags~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Set flags in behavior tree or game scripts that can be used to track states.
====== Element Class Example ======
This example defines an element which supports setting flags in behavior trees.
class MyElement extends BehaviorElementClass
public var ECBehaviorBehaviorTree behaviorTree
public var ECBehaviorBehaviorTreeFlags behaviorTreeFlags
func new()
behaviorTree = ECBehaviorBehaviorTree.new(this)
behaviorTreeFlags = ECBehaviorBehaviorTreeFlags.new(this, behaviorTree)
end
end
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
second
value
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]