Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorAnnouncer
Behavior element behavior adding announcer support.
Behavior uses an Announcer to play back announcer files. The speaker created by the Announcer instance is added to the game world.
If the ECBehaviorCollider is present the announcer speaker is attached. The speaker is attached to the named bone if defined otherwise it is attached statically.
This behavior contains a property to set the announcement text. Other behaviors can change this text at runtime to make this alter the announcement. Changing the announcement text will stop playing back the current announcement.
This behavior can be added multiple times to an element. Each instance creates one announcer speaker attached to the element collider which can be individually modified. To distinguish the announcers each instance has an identifier which can be used to retrieve a specific instance.
Element class properties have the prefix announcer.
or announcer({id}).
if id is not empty.
Path to announcer file to load.
announcer.path
or announcer({id}).path
*.announcer.xml
<string name='announcer.path'>speaker.announcer.xml</string>
Speaker type.
announcer.type
or announcer({id}).type
Allowed Values:
Value | Description |
---|---|
point | Omnidirectional. |
directed | Directed. |
point
<string name='announcer.type'>directed</string>
Speaker volume.
announcer.volume
or announcer({id}).volume
1
0
<float name='announcer.volume'>0.8</float>
Speaker range in meters. Speaker is inaudible beyond range.
announcer.range
or announcer({id}).range
30
0
<float name='announcer.range'>20</float>
Roll off. Value 1
is realistic (normal) roll-off. Values larger than 1
reduce volume faster near the sound source. Values smaller than 1
reduce volume faster near the sound range.
announcer.rollOff
or announcer({id}).rollOff
1
0
<float name='announcer.rollOff'>1.5</float>
Distance offset for attenuation calculation. For use by distance sounds. Offsets the true distance to the sound source for attenuation calculation to make the sound appear coming from far away. Requires increasing the volume to compensate for the distance increased attenuation.
announcer.distanceOffset
or announcer({id}).distanceOffset
0
0
<float name='announcer.distanceOffset'>500</float>
Speaker shape.
announcer.shape
or announcer({id}).shape
<string name='announcer.shape'>box:position,0,0.5,0:extends,2,1,0.5</string>
Announcement text.
announcer.text
or announcer({id}).text
<string name='announcer.text'>This is an announcement.</string>
Position to attach resource to collider.
announcer.position
or announcer({id}).position
<vector name='announcer.position' x='0' y='0' z='0.1'/>
Orientation to attach resource to collider in degrees.
announcer.orientation
or announcer({id}).orientation
<vector name='announcer.orientation' x='30' y='0' z='0'/>
Bone to attach resource to. If empty string attach to collider.
announcer.bone
or announcer({id}).bone
<string name='announcer.bone'>attach</string>
Play announcement whenever trigger evaluates to true.
announcer.trigger
or announcer({id}).trigger
<string name='announcer.trigger'>@switchOnVent & @powerEnabled</string>
Start playing back announcement.
Stop playing back announcement.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace announcer
with announcer(id)
.
Start or stop announcing.
Parameter | Value | Description |
---|---|---|
text | string | Text to announce. If not set uses the last text. |
text.translate | string | Text to announce using TranslationManager to look up translation entry. If not set uses the last text. |
stop | If present stop announcement instead of starting it |
This is an example of using this action:
<action name='announcer.announce'> <parameter name='text.translated'>announcer.welcome</parameter> </action>
Check one or more announcer parameters. Action succeeds if all parameter value matches their respective announcer parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a announcer parameter matches (or not).
Parameter | Value | Description |
---|---|---|
announcing | true , false | Announcer is announcing |
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='announcer.check'> <parameter name='announcing'>true</parameter> </action> <!-- actions here run only if announcer is announcing --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace announcer
with announcer(id)
.
Check one or more announcer parameters. Conditions returns true if all parameter value match their respective announcer parameter. This condition is typically used to run an action or sequence of actions as long as announcer conditions are true.
Parameter | Value | Description |
---|---|---|
announcer.announcing | true , false | Announcer is announcing |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='announcer.announcing'>true</parameter> <condition>announcer.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 announcer
with announcer(id)
.
Start playing back announcement.
Stop playing back announcement.
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 supports playing announcements.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorAnnouncer announcer func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) announcer = ECBehaviorAnnouncer.new(this, collider) 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='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorAnnouncer'> <!-- optional: set layer mask (default '2' meaning BaseGameApp.WorldLayerBit.audio). list of bits to set. --> <string name='layerMask'>0 1 4</string> <!-- optional: use BaseGameApp trigger table. game can add more supported values --> <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='.text'>This is an announcement.</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorAnnouncer' id='second'/> </elementClass>