Table of Contents

,

Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorConversationActor

ECBehaviorConversationActor

Behavior adding conversation actor support to actors.

Provides ConversationActor with basic properties set depending on what behaviors are present before this behavior. In addition supports for other behaviors to modify and extend the ConversationActor namely adding game and condition commands or modify sub title boxes using istener support.

Basic ConversationActor is set up like this:

This behavior does not update itself automatically during thinking because locomotion handling in actors needs a specific order to work correctly:

ECBehaviorConversationActor.updateLocomotion() has to be called before calling Locomotion.update() since the HeadLookAtPlayback modifies the locomotion goal parameters.

ECBehaviorConversationActor.updateAnimator() has to be called before applying animations since playback instances use the base animator instance controllers as input.

It is possible to use this behavior on non-actor elements. In this case add first a behavior providing animator support and assign it to the behavior. Then this behavior will register and update in the right time. Supports ECBehaviorActorAnimated, ECBehaviorAnimated or ECBehaviorTwoStateAnimated for this use-case.

Bone Name Remapping

Behavior supports re-mapping bone names in response to ConversationActor.getMatrix() and ConversationActor.getInverseMatrix() . Define bone mappings using setBoneMapping(). The mappings are persistent until changed. Bone mappings are useful for various situations including the following ones:

See also:

Instance Counts

This behavior can be used multiple times on an element to add multiple custom colors to mainpulate. Use the behavior identifier to tell them apart.

Element Class Properties

Element class properties have the prefix convoActor. .

id

Set unique identifier of conversation actor.

aliasId

Set alias identifier of conversation actor. Has to be unique inside the same conversation playback. Allows to add any actor with a known alias. For example the game can have conversation actors with id merchant1 and merchant2. While talking to one of the two they can be added with the alias npc. This way conversation scripts can refer to this actor using id npc without needing to know which actor it is actually or they can use the actual id of the actor. Game scripts can use custom alias instead of this one.

name

Set unicode display name.

subtitleSelector

Set subtitle selector. This allows to add designer selector to the game gui theme to style conversation panels shown for this conversation actor.

headRotatorBone

Set head rotator bone. Using a head rotator bone improves the head and eye look-at handling. Typically this is the head bone.

headRotatorOffset

Set head rotator offset. If headRotatorBone is used the offset is relative this bone. Otherwise the offset is relative to the element coordinate system.

registerConvoActor

Set to register conversation actor in game world. Allows game scripts to locate conversation actors by identifier without needing to know which element they belong to.

Events

This behavior has these events:

wait

Return true if actor is doing something blocking if conversation actions wait for this actor.

enterConversation

Actor entered conversation.

leaveConversation

Actor left conversation.

modifySubTitleText

Modify sub title text created by behavior. Multiple listeners can modify sub title text by either modifying the widget pass to the listener or creating a new one.

Behavior Tree Actions

This behavior adds these behavior tree actions.

Behavior Tree Conditions

This behavior adds these behavior tree conditions.

conversationActor.inConversation

Determines if conversation actor is in a conversation.

This is an example of an action that can only run if the actor is in a conversation:

<action name='myAction' id='doing something'>
  <condition>conversationActor.inConversation</condition>
</action>

conversationActor.notInConversation

Determines if conversation actor is not in a conversation.

This is an example of an action that can only run if the actor is not in a conversation:

<action name='myAction' id='doing something'>
  <condition>conversationActor.notInConversation</condition>
</action>

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorConversationActor.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

This example defines an element which has a conversation actor.

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  public var ECBehaviorColliderAI colliderAI
  public var ECBehaviorLocomotion locomotion
  public var ECBehaviorParameterTable parameterTable
  public var ECBehaviorActorAnimated actorAnimated
  public var ECBehaviorBehaviorTree behaviorTree
  public var ECBehaviorConversationActor conversationActor
  func new()
    component = ECBehaviorComponent.new(this, null)
    collider = ECBehaviorCollider.new(this, component)
    colliderAI = ECBehaviorColliderAI.new(this, collider)
    locomotion = ECBehaviorLocomotion.new(this, colliderAI)
    parameterTable = ECBehaviorParameterTable.new(this)
    behaviorTree = ECBehaviorBehaviorTree.new(this)
    actorAnimated = ECBehaviorActorAnimated.new(this, component, locomotion)
    conversationActor = ECBehaviorConversationActor.new(this)
    conversationActor.setActorAnimated(actorAnimated)
    conversationActor.setLocomotion(locomotion)
    conversationActor.setParameterTable(parameterTable)
    conversationActor.addBehaviorTree(behaviorTree)
  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='ECBehaviorColliderAI'/>
  <behavior type='ECBehaviorLocomotion'/>
  <behavior type='ECBehaviorParameterTable'/>
  <behavior type='ECBehaviorActorAnimated'/>
  <behavior type='ECBehaviorBehaviorTree'/>
 
  <behavior type='ECBehaviorConversationActor'>
    <!-- optional: use actor animated with id instead of empty string -->
    <string name='actorAnimated'>second</string>
 
    <!-- optional: use animated with id instead of empty string -->
    <string name='animated'>second</string>
 
    <!-- optional: use two state animated with id instead of empty string -->
    <string name='twoStateAnimated'>second</string>
 
    <!-- optional: add behavior trees. default adds behavior tree with empty string if present. -->
    <list name='behaviorTrees'>
      <!-- add behavior with empty identifier -->
      <string/>
 
      <!-- add behavior with 'default' identifier -->
      <string>default</string>
    </list>
 
    <!-- optional: use BaseGameApp subtitle theme. game can add more supported values.
                   default is 'default'. also supported is value 'path:/path/to/theme.guitheme' -->
    <string name='subtitleTheme'>default</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.name'>value</string>
  </behavior>
</elementClass>

Live Examples