Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorEvaluate
Behavior element behavior evaluating trigger expression.
Fires and resets a trigger target depending on the evaluation state of a trigger expression. Optionally pulses trigger target instead of just firing it.
This behavior can be used multiple times on an element to add multiple triggers. Use the behavior identifier to tell them apart.
Element class properties have the prefix evaluate.
or evaluate({id}).
if id is not empty.
Trigger to evaluate.
evaluate.trigger
or evaluate({id}).trigger
<string name='evaluate.trigger'>@switchOnVent & @powerEnabled</string>
Fires target if trigger evaluates to true otherwise resets it.
evaluate.target
or evaluate({id}).target
<string name='evaluate.target'>ventOn</string>
Pulse target instead of toggle fired state.
evaluate.pulse
or evaluate({id}).pulse
false
<boolean name='evaluate.pulse'>true</boolean>
Trigger expression changed to true.
Trigger expression changed to false.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace evaluate
with evaluate(id)
.
Check one or more evaluate trigger parameters. Action succeeds if all parameter value matches their respective evaluate trigger parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a evaluate trigger parameter matches (or not).
Parameter | Value | Description |
---|---|---|
trigger | true , false | Trigger expression evaluates to true or false |
target.fired | true , false | Target is in fired or reset state |
target.everFired | true , false | Target has been fired at least once or never |
wait | If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled |
This is an example of using this action:
<sequence> <action name='evaluate.check'> <parameter name='target.fired'>false</parameter> <parameter name='target.everFired'>false</parameter> </action> <!-- actions here run only if target is in reset state and has been never fired yet --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace evaluate
with evaluate(id)
.
Check one or more evaluate trigger parameters. Conditions returns true if all parameter value match their respective evaluate trigger parameter. This condition is typically used to run an action or sequence of actions as long as evaluate trigger conditions are true.
Parameter | Value | Description |
---|---|---|
evaluate.trigger | true , false | Trigger expression evaluates to true or false |
evaluate.target.fired | true , false | Target is in fired or reset state |
evaluate.target.everFired | true , false | Target has been fired at least once or never |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='evaluate.target.fired'>false</parameter> <parameter name='evaluate.target.everFired'>false</parameter> <condition>evaluate.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events. If behavior has non-empty identifier replace evaluate
with evaluate(id)
.
Trigger expression changed to true.
Trigger expression changed to false.
This behavior requires no other behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which evaluates trigger.
class MyElement extends BehaviorElementClass public var ECBehaviorEvaluate evaluate func new() evaluate = ECBehaviorEvaluate.new(this) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorEvaluate'> <!-- optional: use BaseGameApp trigger table. game can add more supported values. default is 'default' --> <string name='triggerTable'>default</string> <!-- optional: identifier of ECBehaviorTriggered to synchronize with or empty string to not synchronize. default is empty string. --> <string name='trigger.synchronize'>other</string> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.target'>ventOn</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorEvaluate' id='second'/> </elementClass>