March 23, 2015

Tutorial: Making a Telepath Tactics Campaign, Part 11

<< Continued from Part 10

A. Recruiting new characters in a cut scene

There are two ways to add characters to the player’s army roster: using an XML tag in a cut scene, or using a script action. Let’s talk about adding characters in a cut scene using the XML tag first.

Remember how we used the <NewRoster> XML tag in Introduction.xml to create the player’s starting army roster? There’s another XML tag that lets us add more characters to the roster in the exact same way: <AddToRoster>. To use this, we just need to create a cut scene and replace the <NewRoster> tag with <AddToRoster>.

Copy Introduction.xml, then paste it as a new file and rename it. Next, edit the narration. I’ve created a new character, a mentalist named Gob Bluth, in CharClasses.xml. He’s the one I want to add, so I’ll rename this XML file Recruiting Gob.xml and change the narration accordingly:

Off in the distance, 80s hair band Europe’s hit single “The Final Countdown” plays, growing gradually louder as you approach. Finally, a magician appears past a curve in the road; spotting you, he releases a dove from inside his sleeve. It flops to the ground, already dead. “Damn,” he mutters.

Tutorial 11A - Recruiting with AddToRoster
image-3815
Finally, in <AddToRoster>, we include the names of the characters we want to add (using a forward slash to delimit first and last names, just as we did with <NewRoster>):

<AddToRoster>Gob/Bluth</AddToRoster>

Then we just take the player there using the nextbattle attribute of the scene prior, and that’s that.

B. Recruiting new characters with a script action

But what if we don’t want to use a cut scene? What if we want to recruit a character during a battle instead? For that, we’ll need to use a script action! The script action that lets us add a character to the player’s army roster is called RecruitChar.

There is only one required parameter for RecruitChar: the character’s name, with first and last name delimited with a colon (:). Thus,

RecruitChar   Gob:Bluth

will add Gob Bluth to the player’s army roster.

C. Recruiting enemies in battle

You can use RecruitChar in combination with the OnTalk trigger to turn characters already on the battlefield to the player’s side.

Suppose, for example, that we were to place Gob Bluth onto the battlefield as part of army 1; that would make him an AI-controlled enemy. We can allow characters to talk to him, however, by creating dialogue using the following trigger:

OnTalk   -ANY-,Gob Bluth

That will let any character initiate a conversation with him. (If you want to limit it to a particular character, just use that character’s name in place of “-ANY-“.)

image-3816
Now we create our dialogue as normal, and include the RecruitChar script action. However, we can’t stop there: while RecruitChar will add Gob to the player’s army roster going forward, it won’t change his behavior during this battle! To do that, we have to add one more script action:

SetStat   Gob Bluth,Army,=,0

This will change his army affiliation right then and there, swapping his palette and turning him over to the player’s control. (The SetStat action is super powerful–it can be used to change dozens of things about characters during a battle, not just their army affiliation. We’ll almost certainly be returning to it later!)

D. Dismissing characters

Finally, we come to dismissing characters. Sometimes a character needs to leave the player’s army. We can dismiss characters from the player’s army roster in two ways: by using the <RemoveFromRoster> XML tag in a cut scene, or by running the DismissChar script action. These both work in the exact same way as <AddToRoster> and RecruitChar above.

That’s it for now, folks! When we return, we’ll discuss how to create battles with more than 2 armies, then learn how to set and use custom variables. See you next time!


Continued in Part 12 >>