Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorInteractionElement
Behavior element behavior adding support to store an interaction element.
This behavior allows to store for a longer time an element found by another behavior. For example ECBehaviorLookAt is able to locate an element. By storing this element in this behavior another behavior, state machine or behavior tree can use this found element to interact with it.
This behavior is able to persist and restore the element. This is though only possible as long as the element is part of a game world. Hence while leaving a game world the interact element is cleared. It is also possible the element is stored longer than it exists in the game world. After loading it is thus possible the interact element can not be resolved. Behaviors, state machines and behavior trees using this interact element behavior have to be prepared for the interact element to be null after loading.
This behavior can be used multiple times on an element to add multiple interaction elements to mainpulate. Use the behavior identifier to tell them apart.
Element class properties have the prefix interactionElement.
or interactionElement({id}).
if id is not empty.
This behavior supports no events:
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace interactionElement
with interactionElement(id)
.
Update interaction element.
Parameter | Value | Description |
---|---|---|
interact | string | Interact with stored element. If element is absent action fails. Runs interaction with name value. If interaction with name value is absent fails action. If interaction returns false fails action. Otherwise action succeeds. |
interact.parameters | string | Optional parameters to use with interaction . |
assign | string | Assign stored interaction element to another ECBehaviorInteractionElement with identifier value |
clear | string | Clear stored interaction element |
This is an example of using this action:
<action name='interactionElement.update'> <parameter name='interact'>frob</parameter> </action>
Check one or more interaction element parameters. Action succeeds if all parameter value matches their respective interaction element parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a interaction element parameter matches (or not).
Parameter | Value | Description |
---|---|---|
set | true , false | Interaction element is stored |
interact.name | string | Name of interaction |
interact.has | true , false | Interaction element is stored and interaction with name interaction.name is present |
interact.query | true , false | Interact with stored element and test result. Condition is true if interaction element is stored, interaction with name interaction.name is present and interaction returns true. It is recommended to use here only interactions without side effects (hence query interactions). |
interact.parameters | string | Optional parameters to use with interaction.query . |
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='interactionElement.check'> <parameter name='interact.query'>true</parameter> <parameter name='interact.name'>limitedUse.notEmpty</parameter> </action> <!-- actions here run only if interaction element is present and has uses left --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace interactionElement
with interactionElement(id)
.
Check one or more interaction element parameters. Conditions returns true if all parameter value match their respective interaction element parameter. This condition is typically used to run an action or sequence of actions as long as interaction element conditions are true.
Parameter | Value | Description |
---|---|---|
interactionElement.set | true , false | Interaction element is stored |
interactionElement.interact.name | string | Name of interaction |
interactionElement.interact.has | true , false | Interaction element is stored and interaction with name interaction.name is present |
interactionElement.interact.query | true , false | Interact with stored element and test result. Condition is true if interaction element is stored, interaction with name interaction.name is present and interaction returns true. It is recommended to use here only interactions without side effects (hence query interactions). |
interactionElement.interact.parameters | string | Optional parameters to use with interaction.query |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='interactionElement.interact.query'>true</parameter> <parameter name='interactionElement.interact.name'>limitedUse.notEmpty</parameter> <condition>interactionElement.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends no state machine events.
This behavior requires no other behaviors.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.26
This example defines an element which contains a interaction element.
class MyElement extends BehaviorElementClass public var ECBehaviorInteractionElement interactionElement func new() interactionElement = ECBehaviorInteractionElement.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='ECBehaviorInteractionElement'> <!-- optional: add behavior trees. default adds all behavior trees. --> <list name='behaviorTrees'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> <!-- optional: add state machines. default adds all state machines. --> <list name='stateMachines'> <string/> <!-- add behavior with empty identifier --> <string>default</string> <!-- add behavior with 'default' identifier --> </list> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorInteractionElement' id='second'/> </elementClass>