View Tags

March 17, 2015

Tutorial: Making a Telepath Tactics Campaign, Part 10

<< Continued from Part 9

A. Adding and removing character tags with script actions

As we discussed in Part 6B, a character tag is just data that we add to a character to change how the game sees her. Adding (or removing) a character tag is how we change the AI behavior of that character in the game.

Now as it happens, there are script actions that let us add and remove tags on the fly, meaning that we can actually change the AI behavior of characters dynamically during battle! That is what we are now going to learn how to do.

There are two primary script actions that let us add tags to characters, AddTag and AddTagToArmy; and by the same token, there are two primary actions that let us remove tags from characters, RemoveTag and RemoveTagFromArmy.

AddTag adds a new character tag to a unique, named character or object on the battlefield. There are at least two parameters: Character Name and Tag Type, then an extra parameter for every tag parameter required for use with that Tag Type.

      • Usage example: AddTag   Ann Veal,LevelUp,2 will tag Ann Veal so that she silently gains two levels the next time she spawns in a scene.

AddTagToArmy adds a new character tag to every character in a given army. There are at least two parameters: Army Number and Tag Type, then an extra parameter for every tag parameter required for use with that Tag Type.

RemoveTag removes a character tag from a unique, named character or object on the battlefield. There are two parameters: Character Name and Tag Type.

RemoveTagFromArmy removes a character tag from every character in a given army. There are two parameters: Army Number and Tag Type.

One thing we might do with these actions is set up a map with a lot Passive enemies, then add an OnTurn dialogue trigger for some turn late in the battle with RemoveTagFromArmy in branch 0 and the parameters 1,Passive. (This will remove Passive tags from all the characters in army 1 when that turn is reached, causing them to rush the player.)

Using the additional dialogue triggers we covered last time, we can also trigger events like this based on what’s occurring on the battlefield. For example:

  • You can use OnCharDeath with the enemy general to trigger dialogue with AddTagToArmy and the parameters 1,Passive, simulating the enemy’s fear and loss of morale at their leader’s death.
  • You can use OnCharAttacked with the enemy general to trigger dialogue with RemoveTagFromArmy and the parameters 1,Passive so as to make the enemy rush in to defend their leader.
  • You can use OnMoveComplete to have enemies lose their passive status after one of them gets triggered into moving and attacking.
  • You can combine RemoveTagFromArmy with OnOpeningDoor or OnReachingSpace to have the enemy hang back only until the player reaches a certain spot on the battlefield.

These are just a few possible examples–there are many more things you can do with the add and remove tag actions as well!

“But Craig,” you ask, “what about only affecting particular enemies? AddTagToArmy and RemoveTagFromArmy affect entire armies, while AddTag and RemoveTag only target characters with unique names–and most enemies don’t have unique names! How do I add tags to / remove tags from discrete groups of enemies?” Good question! This is where the ID tag comes in handy.

B. Using the ID tag with script actions

As I mentioned back in Part 6B, the ID character tag allows us to run scripts on particular enemies even when those enemies don’t have a unique name. This, in turn, lets us remove tags from (or add tags to) particular, discrete groups of generic enemies.

We assign the ID tag to particular enemies using the Edit Character function of the map editor, as we did in Part 6B. To target a character with a particular ID in a script action, we then use ID[x] in place of Character Name in the action’s parameters.

For example: suppose that there’s a Generic Blandit whom we’ve tagged ID,1 that we now want to remove a Passive tag from. All we have to do is use the RemoveTag action with parameters ID[1],Passive. The game will then look for the character with an ID of 1, target him with the RemoveTag action, and strip him of his Passive tag!

Tutorial 10B - Removing Tags with IDs
We can put multiple AddTag or RemoveTag actions in the same dialogue branch, each referencing different character IDs, to affect a group of enemies. On the right, you can see an example taken from an early battle in the main campaign–this makes it so a particular group of enemies loses Passive status as soon as any character named Bloodbeard’s Bandit moves.

In fact, this technique is good for more than just adding and removing tags–you can use this technique with literally any script action that calls for a character’s name in its parameters. (You could, for instance, rotate the Generic Blandit tagged with ID 1 to face Ann Veal using RotateCharToFace and the parameters ID[1],Ann Veal.)

Tutorial 10B - Removing Tags with IDs 2
Not only can you use ID tags in lieu of character names in script action parameters, you can also use ID tags in dialogue triggers as well! Just stick ID[x] wherever a character name would be used. On the left, for example, you can see some dialogue that is triggered by any attack launched by the character tagged ID,4.

Tutorial 10B - Removing Tags with IDs 3
What’s more, you can use a character’s ID tag in lieu of a speaker name. This substitutes the correct character name in the dialogue, but also causes the particular character whose ID you used to be highlighted and centered on the screen. Here, for example, is the dialogue branch where a particular member of the Coria Dogs taunts Emma during the first battle in the city of Coria. Although this character does not have a unique name, we nonetheless ensure that he or she is the one to deliver that line every time the level is played!

The possibilities are endless!

C. More character tags

Now that we’re getting a sense of how to use character tags in combination with dialogue to script enemy behavior on the battlefield, let’s talk about a few more character tags we didn’t cover before:

TargetValue – an AI tag that can be used on potential targets for the AI; this affects how likely they are to be chosen as attack targets. TargetValue has one parameter: a number (including decimals) that acts as a value multiplier. A higher value (higher than 1) means that characters controlled by the AI are more likely to choose this character as a target for skills and attacks, while a lower value (between 0 and 1) means that the character is more likely to be ignored.

IgnoreArmy – an AI tag used directly on AI-controlled characters. It has one parameter: a non-negative integer corresponding to an existing army number. This causes the tagged character to ignore the existence of all characters belonging to that particular army; characters of that army will be treated neither as enemies nor allies.

TreatAsArmy – an AI tag used on destructible objects to make the AI treat them as if they were characters belonging to a particular army. It has one parameter: a non-negative integer corresponding to an existing army number. Set it to 0, and the enemy will treat the object as if it were a member of the player’s army, and assign it a target value for potential attacks accordingly; set it to 1, and the enemy will treat it as if it were an ally.

Certain characters (e.g. those with healing abilities, or those who are the subject of a Protect Char condition) automatically have a higher-than-normal target value for the AI. Others (destructible objects in particular) automatically have a lower-than-normal target value. You can adjust those values up or down as you see fit using the TargetValue tag.

TreatAsArmy can be used to get the AI to attack destructible objects on the battlefield. (You don’t need to use this with player-created objects, as those are already automatically flagged as potential targets for attack.) As you might imagine, this is the tag I use to get thieves to attack treasure chests. IgnoreArmy, in turn, is the tag I use to make those same thieves ignore the player in their pursuit of treasure! There’s a particular three-army setup that I use to make this work; we’ll get into that later.

That should do it for now. Experiment a bit with using a combination of character tags and script actions to manipulate events during battle, then we’ll move on! When we return, we will talk about how to make characters recruitable during battle, and how to remove characters from the player’s army roster. After that, we’llcover battles with more than 2 armies, then move on to cover setting variables and using them to affect the way dialogue trees play out. See you next time!

Continued in Part 11 >>