Conversation plots and scripting

From Dragon Age Toolset Wiki
Jump to: navigation, search
Conversation topics

The plots and scripting tab under the conversation editor has many powerful features:

Conversation plots and scripting.png

To make a line dependent on the condition of the world at large, and to allow a line to have an effect on the world at large, plots and scripts are employed.

Since the effect of a script is seldom obvious at a glance, a "scripting comments" text field is available for keeping notes for your reference.

Conditional display of a line

Conversation plots and scripting condition.png

Using plots

The "condition" section of the plots and scripting tab is used to determine whether this line will be run at all. To make the line depend on the status of a particular plot, select the plot in question from the plot dropdown list (or if it's not already in the dropdown list click on the ellipses button (Ellipsis.png) to select from all available plots). Then pick one of the flags used within that plot, and set whether the condition needs to be true or false for the line to be displayed.

A common example of this sort of conditional conversation would be a quest giver, who has different responses to give the player before and after the quest in question has been accepted. Another example might be a character whose attitude toward the player changes when the player has performed a particular task, for good or for ill. Or if the player has learned some important new piece of information, he may now be able to ask a question that he wouldn't otherwise have known to ask.

Using scripts

To make a line in a conversation depend on a more complex condition, or on some condition that is not easily kept track of using plot resources, you can use a script instead. Using scripts and using plots are mutually exclusive here, so if you want to use information derived from both you'll need to write your script to account for plot flags.

Some examples of scripted conditions that conversations might use are: differing NPC responses depending on the player's race or gender, differing options depending on what skills the player has, or lines that change depending on the time of day.

To use a script, select it from the script dropdown menu (or from the list of all scripts opened by the ellipsis button if it's not already there).

Scripts associated with conversations take the form

int StartingConditional()
    return 1;

If the script returns true the line will display, otherwise it will not.

The last line in a block of multiple NPC lines should always be non-scripted (and without a comment). This ensures that the dialogue always drops to a default line if the scripts break. For example:

A writer creates two PC lines, one for a male and one for a female. Only the first of the 2 lines needs an "if PC is male/female" script. The other line is assigned the correct result by default without a script.

A script called by a line of the conversation can be passed an integer as a parameter, which is retrieved by the function GetConversationEntryParameter. Note that as of November 18 this function is not currently functional. A patch will be needed for the game executable to repair this.

Generic conditions

Since there are several extremely common conditions that are checked for when writing dialog, a number of "generic" plot flags are available for use. An event script is connected with the generic plots described below that does the work of determining what the state of any given plot flag is.

To check a player's class, race, or gender, use the generic plot "gen00pt_class_race_gend" in the plot conditionon section. The following flags are available:

  • GEN_RACE_ELF - true if the player's character is an elf, false otherwise.
  • GEN_RACE_HUMAN - true if the player's character is a human, false otherwise.
  • GEN_RACE_DWARF - true if the player's character is a dwarf, false otherwise.
  • GEN_GENDER_MALE - true if the player's character is male, false otherwise.
  • GEN_GENDER_FEMALE - true if the player's character is female, false otherwise.
  • GEN_CLASS_* - one flag for each base class, is "true" if the character has this class and "false" otherwise

To select a random chance of picking a line, you can use the "gen00pt_random" plot's flags. This is commonly used for ambient banter, or for providing the player with random tidbits of interesting information that are not strictly necessary to complete the adventure. Important note: ensure that the last line in a group of random selections has no condition.

There are two sets of flags in the gen00pt_random plot. The first and most basic set are:

  • GEN_R5 - 5% chance of evaluating "true"
  • GEN_R10 - 10% chance of evaluating "true"
  • GEN_R25 - 25% chance of evaluating "true"
  • GEN_R30 - 30% chance of evaluating "true"
  • GEN_R33 - 33% chance of evaluating "true"
  • GEN_R50 - 50% chance of evaluating "true"

In addition to these, there are a series of "lines left" flags that make it easier to set up a series of random lines to be spoken with equal probability.

The format of the LINES_LEFT flags is GEN_RAND_RXX Where XX is the total number of random elements left in the series of randoms after the current line. Naturally, GEN_RAND_LINES_LEFT_01 has a 50% chance of being chosen. The very last dialogue line does not need a condition. For the statistically-minded, the probabilities are:

  • GEN_RAND_LINES_LEFT_15: 6.25%
  • GEN_RAND_LINES_LEFT_14: 6.67%
  • GEN_RAND_LINES_LEFT_13: 7.14%
  • GEN_RAND_LINES_LEFT_12: 7.69%
  • GEN_RAND_LINES_LEFT_11: 8.33%
  • GEN_RAND_LINES_LEFT_10: 9.09%
  • GEN_RAND_LINES_LEFT_09: 10.00%
  • GEN_RAND_LINES_LEFT_08: 11.11%
  • GEN_RAND_LINES_LEFT_07: 12.50%
  • GEN_RAND_LINES_LEFT_06: 14.29%
  • GEN_RAND_LINES_LEFT_05: 16.67%
  • GEN_RAND_LINES_LEFT_04: 20.00%
  • GEN_RAND_LINES_LEFT_03: 25.00%
  • GEN_RAND_LINES_LEFT_02: 33.33%
  • GEN_RAND_LINES_LEFT_01: 50.00%

Actions triggered by a line

Conversation plots and scripting action.png

A line can also be set to modify a plot flag when it is reached, or to run a script whose purpose is to modify the state of the world in some way.

Setting and clearing plot flags is very similar to how plots are handled in the condition section, except instead of the condition "is true/false" for a plot flag you select whether the flag is to be set or cleared when this line is reached.

Scripted actions should work as usual, and trigger as follows:

  • For PC lines: the moment the player clicks on the line.
  • For NPC lines: the moment the NPC starts playing his line.

This type of scripting will be used mostly for rewarding the player, taking/giving items and setting plot flags.

When taking or giving items, the script should not play an animation — it should just switch the items. The cinematic layer should take care of the visuals.

Generic actions

For ease of use, several actions that are commonly called in dialog have had generic scripts written to perform them with the script being triggered by setting plot flags on a dummy plot named "gen00pt_generic_actions". To use them, simply set this plot in the "plot" field of the action section and pick the appropriate plot flag to trigger the associated code. The generic actions available are:

  • GEN_AUTOSAVE - triggers an autosave
  • GEN_CURE_PC_INJURIES - removes all injuries from party members
  • GEN_DIALOG_FADE_IN - !!script doesn't appear to have code associated with this flag!!
  • GEN_DIALOG_FADE_OUT - !!script doesn't appear to have code associated with this flag!!
  • GEN_EXIT_DESTROY - conversation owner walks to an object tagged with "wp_exit_generic" (generally a waypoint) and is destroyed.
  • GEN_OPEN_ENCHANTING - opens the item upgrade GUI.
  • GEN_OPEN_STORE - opens a merchant whose tag is "store_" + the tag of the conversation's owner (eg, if blacksmith_steve owns the conversation, it opens the merchant tagged store_blacksmith_steve).
  • GEN_OWNER_DIES - conversation owner drops dead.
  • GEN_OWNER_DISAPPEARS - conversation owner immediately vanishes (is destroyed).
  • GEN_OWNER_MOVES_HOME - conversation owner walks back to its "home" point in the area (by default, where it was initially placed).
  • GEN_OWNER_TURNS_HOSTILE - conversation owner turns hostile and attacks the player.
  • GEN_TEAM_TURNS_HOSTILE - all members of the conversation owner's team turn hostile.
  • GEN_TEAM_WALKS_TO_EXIT - as with GEN_EXIT_DESTROY, but for all members of the conversation owner's team.

!!These two flags are defined for the generic action plot but appear to be conditionals instead, look into what they're for!!

Lines That Only Show Up Once

Conversation plots and scripting line settings.png

At the bottom of this window is the "line settings" section. Visibility determines whether the line is seen only once in a game or once in a conversation.

Once-in-a-conversation lines are useful when a conversation loops back on itself, for example if the conversation is being used to make a clarification hub that provides information to a player and you don't want the player to keep being presented with the option to ask questions that he's already just asked moments ago.

Once-in-a-game lines are useful for presenting information that it wouldn't make sense for a character to repeat a second time if a new conversation is started again with him later, but for which using plot-based conditionals would be unweildy.

This section also has the "ambient" flag. The ambient flag prevents the default conversation cinematics from operating, leaving the camera view where it was and instead putting the text of the spoken line hovering over the head of the object that spoke it. This is intended for use when generating background conversations for the player to "overhear", or that is a quick one-line response to player interaction that doesn't require a full-blown conversation to play out.

Root node plots and scripting

A "Plots and Scripting" tab is also available in the root node of the conversation:

Conversation root plots and scripting.png

This is somewhat simpler than the plots and scripting tabs for child nodes, but functions in a very similar manner. It has no "condition" section, just a section called "Conversation End" that is analogous to an "action" section above. The difference is that this action section will be triggered whenever the conversation ends, by whatever path. This is helpful for preventing errors and saving time when crafting a conversation that is always supposed to have the same effect on the world when it's over but that has many different conversation end nodes scattered throughout it.

Comments and complex logic

Conversations can be documented using comment lines (for example, at the start of each major branch).

Comment lines are coded by entering a scripting comment with no dialogue.

The comment appears in green text when viewing the conversation in the toolset.

Comments aren't spoken in game, but they can be conditional.

This fact can be exploited to implement complex logic such as "if (condition 1) (if (condition 2) say X else say Y)". Condition 1 is placed on a comment line, which is followed by dialogue lines X (condition 2) and Y (unconditional).

See the OC party banter conversation for a good example.

Language: English  • русский