March 15, 2015

Tutorial: Making a Telepath Tactics Campaign, Part 9

<< Continued from Part 8

A. Using ChangeCondition

Welcome back! As promised, it’s now time to discuss changing battle conditions using script actions. Battle conditions, as you may recall from Part 5B, govern basic settings and rules for the battlefield. Using the ChangeCondition script action, we can actually change these settings and rules on the fly during a battle! It’s super easy; all we have to do is call ChangeCondition with the very same parameters we would use if we were defining the condition with a <Condition> tag.

Suppose, for example, that we wanted the battlefield to fall under a fog of war during a battle to represent reduced visibility. To make this happen mid-battle, we’d just create a new OnTurn dialogue, add a ChangeCondition action to branch 0, then set the action’s parameters to Fog of War,true.

We can use this same technique to change most of a level’s conditions, including global lighting, weather effects, and other things. Since we’re talking about battle conditions again, let’s cover some of the conditions that we skipped over last time–conditions we can fruitfully change using ChangeCondition:

Exploration Mode – one parameter, true or false. If set to true, the player’s characters can move around continuously without ever ending the player’s turn–and at the same time, most character attacks become unavailable. (This is the sort of condition you might set to true in towns, puzzle rooms, or other non-combat areas.)

Fatigue – fatigue represents the percentage of characters’ maximum energy that will be missing when they first appear on the battlefield. If an army has 0.4 fatigue, for instance, its characters will spawn with 60% of their maximum energy; and if that same army has 0.8 fatigue, its characters will spawn with only 20% of their maximum energy.

Takes two parameters: Army Number and Starting Fatigue Level. Army Number is the army whose fatigue you want to set (or you can use -1 to affect all armies on the battlefield); Starting Fatigue Level is a number between 0 and 1.

Global Lighting – this sets the basic lighting for a level and all the characters within it. It has one parameter, the Lighting Preset Name–you can use any of the following: Cave, Daylight, Dawn, Evening, Grayscale, Indoors, LavaDark, LavaLight, Night, Overcast, Sepia, or Custom.

(If Custom is used as the lighting preset name, then there are three extra parameters: Red, Green and Blue, each with a value between 0 and 1.)

Kill-All Victory – one parameter, true or false. By default, this is true, which means the game will end the battle as soon as it detects that no enemies remain on the battlefield. If you set this condition to false, the game will not end the battle just because no enemies remain on the battlefield. (Make sure you provide an alternate way of ending the battle if you do this, or the player will be stuck on this level forever!)

Permadeath – one parameter, true or false. By default, this is true, which means that characters who die are automatically removed from the player’s army roster so they can’t be used in future battles. If set to false, characters that reach 0 health will remain in the player’s roster for use in future battles.

Weather – Creates a weather overlay.  Takes one parameter, Weather Type: Rain, Snow, Fire, Embers, or Pollen.

There are a few more conditions than these, conditions which allow us to create battles with more than 2 armies! However, that is a topic that deserves its own tutorial section–we’ll return to that later. For now, let’s talk about ways to end battles and change scenes such that we can actually make proper use of Kill-All Victory and Exploration Mode.

B. Ending battles through dialog

By default, all battles end when all characters belonging to all enemy armies are dead, and not one second before. However, as mentioned above, we can turn this behavior off by turning off Kill-All Victory or enabling Exploration Mode. But what then? How do we end the battle? Aside from using the Protect Char condition, there are a bunch of ways to end battles without all enemies dying–and all of them involve dialogue replies or script actions:

  • The EndBattle reply type. When the player clicks the associated reply, this ends the battle and brings up the victory splash screen indicating that the player won.
  • The LoseBattle reply type. When the player clicks the associated reply, this ends the battle and brings up the defeat splash screen indicating that the player lost.
  • The NextScene reply type. When the player clicks the associated reply, this immediately takes the player to the scene designated in this scene’s nextbattle attribute, skipping the victory splash screen.
  • The NextScene script action. This works exactly like the NextScene reply type, except that it takes effect immediately instead of waiting for the player to click a reply.
  • The NewScene reply type. When the player clicks the associated reply, this immediately takes the player to a scene defined in the reply’s parameter. (For instance: clicking a reply with reply type NewScene and the parameter NorthernMarch will end the conversation and immediately load the map NorthernMarch.xml.)
  • The NewScene script action. This works exactly like the NewScene reply type, except that it takes effect immediately instead of waiting for the player to click a reply.

We can use these in concert with dialogue to end battles based upon conversation choices. More than that, though, we can use the game’s dialog triggers to create even more imaginative win and loss conditions.

C. More dialogue triggers

So far we’ve only talked about the OnTurn trigger, but there are a whole bunch of different triggers that allow us to start dialogue at different points–dialogue that can then be used to alter battlefield conditions, or even make the player win or lose the battle!

OnLoaded – takes no parameters. Causes dialog to trigger the moment the level is fully loaded. Use this with various script actions, followed by the EndConvImmediately action to alter the level before the player can see it happening.

OnTalk – this allows for player-triggered conversations. It takes two parameters: the name of one character, and the name of a second character. When one character is adjacent to the other, the Talk option will appear in the actions box. If the player clicks it, it will trigger the conversation. (If you want any character to be able to initiate the conversation, you can use -ANY- for the first parameter.)

OnReachingSpace – this triggers a conversation as soon as a character reaches a defined space on the battlefield. It takes between two and four parameters: the Y coordinate, the X coordinate, the name of the character that triggers the conversation (if it can only be triggered by a particular character), and the team number of the character who triggers the conversation (if it can only be triggered by a character of a particular team).

      • Usage example: OnReachingSpace 4,6 will trigger the conversation when any character ends a move on the coordinates 4,6.
      • Usage example: OnReachingSpace 4,6,Ann Veal will trigger the conversation when Ann Veal (and only Ann Veal) ends a move on the coordinates 4,6.
      • Usage example: OnReachingSpace 4,6,,0 will trigger the conversation when any character on team 0 (the player’s team) ends a move on the coordinates 4,6.

OnOpeningDoor – this triggers a conversation as soon as a door at a defined space on the battlefield is opened. It takes two parameters: the Y coordinate of the door, and the X coordinate of the door.

OnLockedDoor – this triggers a conversation as soon as a character attempts to open a locked door at a defined space on the battlefield without having a key. (If the player has a key, the door will be opened, which means it’ll activate an OnOpeningDoor trigger instead.) It takes two parameters: the Y coordinate of the door, and the X coordinate of the door.

OnUsing – don’t worry about this just yet; this is used with things like buttons and switches. We’ll talk about use triggers later!

OnGrab – this triggers a conversation as soon as a character grabs an item sack on the battlefield. It takes up to five parameters: the name of the character that must grab the item sack to trigger the conversation (if it can only be triggered by a particular character), the team number of the character who must trigger the conversation (if it can only be triggered by a character of a particular team), the sack’s Y coordinate (if that matters), the sack’s X coordinate (if that matters), and the name of an item that the sack must contain to trigger the conversation (if it can only be triggered by a sack containing a particular item).

Note that all of this particular trigger’s parameters are optional. To have the game ignore team number or sack Y or X coordinates, use -1; to ignore character name or item name, use -ANY-.

      • Usage example: OnGrab -ANY-,0,-1,-1,Bandages will trigger the conversation when any character from army 0 grabs an item sack anywhere on the battlefield, just so long as the sack contains Bandages.

OnCharAttacked – displays some dialog right before an attack is executed. Most of the time, this takes two parameters. To trigger dialogue when a unique, named character is attacked, use these parameters: turn number and character name, including spaces. (This is what you’ll use for boss taunts: “You think you can hurt me? Laughable!” and such.) If you want the dialogue to trigger on any turn where the specified character or class of character is attacked, make sure to use -1 for the turn number parameter.

There are three more optional parameters for this trigger, but for the sake of simplicity, we’ll skip those here. They’re detailed in the manual if you want to use this trigger with destructible objects, or have it only be triggered by particular attackers.

OnCharDeath – this is what you’ll use for death monologues: “Lo, I have been slain!” and such. Most of the time, this takes two parameters. To trigger dialogue upon the death of a unique, named character, use two parameters: turn number and character name, including spaces. If you want the dialogue to trigger on any turn where the specified character or class of character is attacked, make sure to use -1 for the turn number parameter.

There are three more optional parameters for this trigger, but for the sake of simplicity, we’ll skip those here. They’re detailed in the manual if you want to use this trigger with destructible objects, or have it only be triggered by particular attackers.

OnLevel – this triggers a conversation when a character levels up. Takes two parameters: the name of a character whose level-up triggers the dialog, and the level they must be reaching to trigger the dialog. Use -ANY- for the first parameter if it doesn’t matter which character is leveling up; and use -1 for the second parameter if it doesn’t matter what level they’re reaching.

OnStat and OnVal – don’t worry about these just yet. We’ll get to them once we’ve covered custom variables.

OnCharSelect – it can use up to two optional parameters: Turn Number and Character Name, including spaces. If no parameters are specified, it will trigger the conversation as soon as the player selects any character.

OnMoveComplete – it can use up to two optional parameters: Turn Number and Character Name, including spaces. If no parameters are specified, it will trigger the conversation the first time any character finishes moving to any space.

OnAttackSelect – this triggers a conversation when a character selects an attack. Takes three parameters: turn number, the name of a character whose attack selection triggers the dialog, and the attack they must select to trigger the dialog. Use -ANY- for either of the latter two parameters if they don’t matter; use -1 for the first parameter if turn number doesn’t matter.

Phew, okay! That’s a whole lot of stuff, so feel free to pause at this point and experiment with using different triggers. When you’re done, we’ll move on and talk about using script actions to add and remove character tags.


Continued in Part 10 >>