User Tools

Site Tools


dragengine:modules:dragonscript:behavior_actortransmission

ECBehaviorActorTransmission

Behavior adding support for sub title transmission to actor.

For doing sub title text output conversation scripts have to be used. This allow for the highest control over the conversation. For first person only self conversation or receiving transmissions using conversation scripts can be cumbersome. For this situation this behavior provides a simpler solution.

The behavior acts similar to CActionActorSpeak.executeSubTitle() in that it supports creating and adding a series of sub titles for an actor as if a conversation is used. Since no conversation is used the actor is free to be controlled by the player.

This behavior uses ECBehaviorConversationActor. Calls createSubTitleText() to create sub title as if a conversation creates it. This way the same look and feel is used. Adds a listener to cause the actor to wait in conversations if such sub titles are running. This feature is by default disabled and can be enabled to avoid conversation script sub titles showing at the same time as sub titles driven by this behavior.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix transmission..

waitInConversation

If enabled causes conversation scripts to wait for the transmission to end.

  • Full name: transmission.waitInConversation
  • Type: boolean
  • Default Value: false
  • Example (*.deeclass)
    <boolean name='transmission.waitInConversation'>true</boolean>

style

Style identifier to use. Same as style identifiers used in sub title boxes.

  • Full name: transmission.style
  • Type: string
  • Default Value: null
  • Example (*.deeclass)
    <string name='transmission.style'>think</string>

timeout

Timeout in seconds to display individual transmission parts.

  • Full name: transmission.timeout
  • Type: float
  • Default Value: 5
  • Example (*.deeclass)
    <string name='transmission.timeout'>ik.height</string>

clearEnterConversation

Set clear transmission upon entering conversation.

  • Full name: transmission.clearEnterConversation
  • Type: boolean
  • Default Value: false
  • Example (*.deeclass)
    <boolean name='transmission.clearEnterConversation'>true</boolean>

Events

This behavior has no events.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace actorTransmission with actorTransmission(id).

actorTransmission.set

Set one or more actor transmission parameters.

ParameterValueDescription
waitInConversationtrue, falseEnable wait in conversation
clearEnterConversationtrue, falseClear transmission on enter conversation

This is an example of using this action:

<action name='actorTransmission.set'>
  <parameter name='waitInConversation'>true</parameter>
</action>

actorTransmission.transmission

Start transmissions.

ParameterValueDescription
skip Skip current transmission part and show the next part if present
clear Clear all transmission parts
pausefloatAdd a pause to the transmission
textstringAdd text part to transmission
text.stylestringStyle to use for text. If absent uses style set in behavior
text.timeoutfloatTime in seconds to display text. If absent uses timeout set in behavior

This is an example of using this action:

<action name='actorTransmission.set'>
  <parameter name='clear'/>
  <parameter name='text'>Text shown to the player in a transmission box.</parameter>
</action>

actorTransmission.check

Check one or more actor transmission parameters. Action succeeds if all parameter value matches their respective actor transmission parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a actor transmission parameter matches (or not).

ParameterValueDescription
waitInConversationtrue, falseWait in conversation is enabled
clearEnterConversationtrue, falseClear transmission on enter conversation
runningtrue, falseTransmission is running
parts.lessintegerCount of remaining parts in transmission is less than integer value
parts.greaterintegerCount of remaining parts in transmission is greater than integer value
remainingDisplayTime.lessfloatRemaining part display time is less than value seconds
remainingDisplayTime.greaterfloatRemaining part display time is greater than value seconds
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='actorTransmission.check'>
    <parameter name='running'>true</parameter>
    <parameter name='remainingDisplayTime.less'>3</parameter>
  </action>
  <!-- actions here run only if transmission is running with less than 3 seconds remaining for the current part -->
</sequence>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace actorTransmission with actorTransmission(id).

actorTransmission.check

Check one or more actor transmission parameters. Conditions returns true if all parameter value match their respective actor transmission parameter. This condition is typically used to run an action or sequence of actions as long as actor transmission conditions are true.

ParameterValueDescription
actorTransmission.waitInConversationtrue, falseWait in conversation is enabled
actorTransmission.clearEnterConversationtrue, falseClear transmission on enter conversation
actorTransmission.runningtrue, falseTransmission is running
actorTransmission.parts.lessintegerCount of remaining parts in transmission is less than integer value
actorTransmission.parts.greaterintegerCount of remaining parts in transmission is greater than integer value
actorTransmission.remainingDisplayTime.lessfloatRemaining part display time is less than value seconds
actorTransmission.remainingDisplayTime.greaterfloatRemaining part display time is greater than value seconds

This is an example of using this condition:

<action name='myAction' id='doing something'>
  <parameter name='actorTransmissionrunning'>true</parameter>
  <parameter name='actorTransmissionremainingDisplayTime.less'>3</parameter>
  <condition>actorTransmission.check</condition>
</action>

State Machine Actions

State Machine Conditions

State Machine Events

This behavior sends these state machine events. If behavior has non-empty identifier replace actorTransmission with actorTransmission(id).

actorTransmission.start

Transmission started. Send if a pause or text part is added while the part count is 0.

actorTransmission.part

Next part in a transmission is shown.

actorTransmission.finished

Last part in the transmission finished.

Required Behaviors

Optional Behaviors

Persistency

This behavior supports persistency. These parameters are persisted:

  • Wait in conversation flag
  • Remaining display time
  • Array of transmission parts remaining to be displayed
  • Sub title widget being displayed right now

API Documentation

ECBehaviorActorTransmission.

Since DragonScript Module Version 1.7

Use Cases

  • Display single-line shouts of actors examining objects
  • Display short notifications to player like touching a trigger
  • Display true NPC communications

Element Class Example

pin Dragengine.Scenery

class ObjectElementClass extends BaseActorClass
   public var ECBehaviorActorTransmission actorTransmission
   
   public func new() super("ExampleObject")
     // the base actor class creates a conversation actor behavior we can use
     
     // create actor transmission behavior. uses the BaseGameApp created subtitle box.
     actorTransmission = ECBehaviorActorTransmission.new(this, getConversationActor())
   end
end

class ExampleAction extends BAAFirstPerson
   public var ECBehaviorActorTransmission.Instance actorTransmission
   
   public func new()
   end
   
   // store the behavior so we can use it
   protected func void initBehaviors()
      super.initBehaviors()
      actorTransmission = ECBehaviorActorTransmission.getInstanceIn(actor)
   end
   
   // at some point trigger a transmission to the player. this example shows a
   // transmission with two parts. any number of parts can be used but shorter
   // is usually better. for longer transmissions better use conversation
   // scripts since there you have much more possibilities.
   public func void showTransmission(String text1, String text2)
      // clear transmission if one is running. you can use isRunning() to check
      actorTransmission.clear()
      
      // add two parts to the transmission. transmission starts as soon as one
      // part is present and ends once all parts have been shown
      actorTransmission.addPart(UnicodeString.newFromUTF8(text1))
      actorTransmission.addPart(UnicodeString.newFromUTF8(text2))
   end
end

Behavior Factory

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='ECBehaviorConversationActor'/>
 
  <behavior type='ECBehaviorActorTransmission'>
    <!-- optional: use BaseGameApp sub title. game can add more supported values.
                   default is 'default' -->
    <string name='subTitle'>default</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 -->
    <float name='.timeout'>3</float>
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_actortransmission.txt · Last modified: 2025/05/04 13:44 by dragonlord