March 31, 2015

Tutorial: Making a Telepath Tactics Campaign, Part 15

<< Continued from Part 14

A. Using SetStat with numerical stats

Now that we’ve covered the basics of creating custom variables, altering their values, and using them to impact dialogue trees, it’s time to talk about doing these same things with character stats!

Character stats consist of character-specific information such as maximum health, current level, strength, elemental resistances, class name, and scores of other things. Remember how we used SetVal to modify the values of custom numerical variables? We can use SetStat to modify character stats in much the same way!

SetStat has four parameters: Character Name, Stat, Operation, and Amount. Character Name is the name of a character currently on the battlefield, using a space between first and last name (you can an ID tag here instead). Operation and Amount function in exactly the same way they do in SetVal. The one parameter here that we haven’t seen yet is Stat; this tells the game which stat to modify. The Stat parameter can be any of the following:

    • Army – the army number of the army the character belongs to (0 for the player’s army, 1 for the enemy, etc.)
    • Level
    • Exp  experience points.
    • Damage  health lost.
    • Health – current health.
    • Max Health
    • Drain  energy below maximum.
    • Energy  current energy.
    • Max Energy
    • Strength
    • Psy Power
    • Psy Defense
    • Steps Left  steps remaining that the character can move this turn.
    • Speed
    • Accuracy
    • Dodge
    • Counter Limit  maximum number of counterattacks a character can perform per turn.
    • Perception  number of spaces the character can see through fog of war.
    • Pierce Res.
    • Slash Res.
    • Crush Res.
    • Mental Res.
    • Heat Res.
    • Cold Res.
    • Light Res.
    • Shadow Res.
    • Poison Res.
    • Y Coord  number of spaces down from the top edge of the battlefield the character is standing.
    • X Coord  number of spaces right from the left edge of the battlefield the character is standing.
    • Done  0 if a character can still act, 1 if it can’t. (If it’s another player’s turn, then this is a legacy value from the character’s owner’s last turn.)
    • Attacked  0 if the character hasn’t attacked since the start of the character’s last turn, and 1 if the character has. (“EndTurn” or “CanMove” attacks set this to 1; “Unlimited” and “UseOnce” attacks don’t affect this stat.)
    • Countered  number of counterattacks launched since start of the character’s last turn.

So, for example, suppose that Tobias Funke attains a prestige class, and we want to increase his accuracy and maximum health by 10 and 5, respectively, to reflect that change. We’d accomplish that like this:

SetStat   Tobias Funke,Accuracy,+,10

SetStat   Tobias Funke,Max Health,+,5

Or suppose that Ann Veal wanders into a teleporter square, and we want her to instantly reappear in the space at coordinates 10 , 10. We’d use the following actions:

SetStat   Ann Veal,Y Coord,=,10

SetStat   Ann Veal,X Coord,=,10

Note that any modifications we make to base stats with SetStat are permanent, and will affect the character going forward in the campaign! (Damage, Drain, Done, Attacked, Countered, Steps Left, Y Coord, and X Coord are temporary counters rather than base stats, so modifications to those via SetStat won’t carry over into future scenes.)

Also note that with the exception of the Army and coordinate stats, the act of modifying any these stats via SetStat is “quiet”–it won’t bring up any visual indication of what’s happened, so we have to make note of it in dialogue (or create a pop-up via SpawnFloatingText) if we want to player to know it’s happened. Some of the stats above (like Damage and Experience) have alternative script actions you can use to let the player see what’s happening visually (see e.g. DamageChar and GiveExp).

B. Using SetStat with string stats

In addition to all those value stats we listed above, there are also a handful of string stats that SetStat can be used to alter! The method we use to alter these is slightly different, however.

SetStat uses five parameters to edit a string stat: Character Name, Stat, Nothing, 0, and String. Nothing and 0 are basically just us ignoring the Operation and Amount parameters from before. Character Name is the same as before; String is the new string we want to set our stat to. The Stat parameter can be any of the following:

    • Class – use the new character class name for the String parameter.
    • Direction – the direction the character is facing. Use Up, Down, Left, Right or None for the String parameter.
    • MoveType – use land, swimming or flying for the String parameter.
    • Name – use first and last name delimited with a colon for the String parameter.
    • Portrait – use the portrait name (minus its .png file extension) for the String parameter.
    • Race – use the race name for the String parameter.
    • Sex – use Male, Female, Either, or None for the String parameter.
    • Sprite – use the sprite type for the String parameter.

So, for example: suppose that Tobias attains the Blue Man prestige class, and we want to change his class name to reflect that change.

SetStat   Tobias Funke,Class,,0,Blue Man

That would do the trick.

C. Special characters in dialogue: -STAT:-

Stats have their own version of -STR:- and -VAL:-, called -STAT:-. This is a special character that you can use to display the value of a character stat in dialogue.

-STAT:- follows the formula -STAT:Character Name,Stat-. Just substitute the character’s name and the name of the stat, and the special character will be replaced with the value of that stat! So, for example–at the start of the game, this dialogue…

Ann Veal is level -STAT:Ann Veal,Level-.

…will substitute the value of Ann Veal’s Level stat, and therefore read:

Ann Veal is level 1.

(It will, of course, display a higher number after she’s leveled up.)

D. Using SetStatByVal

Remember SetValByVal? As it turns out, we can also SetStatByVal!

SetStatByVal has four parameters: Character Name, Stat, Operation, and Custom Variable Name.

Suppose, for instance, that we want to affect Ann Veal’s energy level based on her mood.  We could do something like the following:

SetStatByVal   Ann Veal,Drain,-,AnnEmotion

This will reduce the Drain–the amount of energy that Ann Veal is missing out of her maximum energy–by the value of AnnEmotion. (If her emotion score is negative, then it will cause her Drain to increase instead!)

E. Using SetValByStat

It doesn’t stop there. We can also use SetValByStat to perform mathematical operations using the value of character stats.

SetValByStat has four parameters: Custom Variable Name, Operation, Character Name, and Stat.

Suppose that we want to display the amount of experience a character has left to gain before they level. On its own, the Experience stat only displays how many experience points a character has, not how many the character needs to reach 100. To get the experience points remaining, we must use SetValByStat to alter a value using that stat!

SetVal   ExperienceNeeded,=,100

SetValByStat   ExperienceNeeded,-,Ann Veal,Exp

This literally takes Ann Veal’s current experience total and subtracts it from 100, giving us the experience points she needs to level up and storing it in the numerical variable ExperienceNeeded. We could then use this to supplement our dialogue from earlier:

Ann Veal is level -STAT:Ann Veal,Level-. She needs -VAL:ExperienceNeeded- to level up.

F. Using SetStatByStat

Finally, we can use SetStatByStat to set a character’s stat by reference to another stat (either her own, or a stat belonging to an entirely different character).

SetStatByStat has five parameters: Character Name, Stat, Operation, Second Character Name, and Second Stat. (This only works with numerical stats.)

So, let’s say we have a character on the battlefield named J. Walter Weatherman. J. Walter Weatherman can be recruited by characters of multiple different armies, and we want to set his Army stat equal to the Army stat of whoever is talking to him when that happens.

SetStatByStat   J. Walter Weatherman,Army,=,-FNAME-,Army

That will do it!

“Whoa whoa whoa,” you say. “What the heck is -FNAME-? Is that another special character we haven’t talked about yet?” It is indeed! In dialogue that’s triggered by a particular character (e.g. OnTalk or OnReachingSpace), we can have the game substitute the triggering character’s full name by using -FNAME-. We’ll talk about -FNAME- (and all the other special characters we haven’t used yet) more later. For now, let’s finish up by talking about using character stats to alter the course of dialogue trees.

G. Using IfStatGoTo

We covered IfStringGoTo and IfValGoTo last time; it probably isn’t going to come as a surprise at this point that we also have access to IfStatGoTo.

IfStatGoTo immediately switches us to a different conversation branch if one of a character’s stats has a certain value. There are five parameters: Character Name, Stat, Mode of Comparison, Amount, and Branch. Just as with IfValGoTo, Mode of Comparison tells the game how to compare the stat’s value to the Amount; Branch tells it which conversation branch to switch to if the comparison returns true.

The options for Mode of Comparison are the same as with IfValGoTo:

    • =  (true if there’s an exact match between the stat value and amount)
    • g  (true if the stat value is greater than amount)
    • l  (true if the stat value is less than amount)
    • g= (true if the stat value is greater than or equal to amount)
    • l= (true if the stat value is less or equal to than amount)

For string stats, use the string you want to compare it to in place of the Mode of Comparison parameter, and leave the Amount parameter blank! For example:

IfStatGoTo   Tobias Funke,MoveType,swimming,,6

This reads: if Tobias Funke’s MoveType is swimming, switch the dialogue tree to branch 6.

The options for the Stat parameter here are all the same as with SetStat above, with one addition: you can append BASE with a space to the front of certain stats to get the stat’s base value (i.e. ignoring temporary modifiers from items or other buffs).

For example:

IfStatGoTo   Ann Veal,BASE Strength,g=,5,2

If Ann Veal is present on the battlefield and has a Strength greater than or equal to 5 (ignoring any items or other effects which may have given her a temporary Strength boost/penalty), it will switch the conversation to branch 2. If you use this, however…

IfStatGoTo   Ann Veal,Strength,g=,5,2

…any strength boost she gets from equipped weapons will count toward determining whether her strength is greater than or equal to 5.

The list of stats that support the use of BASE are as follows: Max Health, Max Energy, Strength, Psy Power, Psy Defense, Speed, Accuracy, Dodge, Counter Limit, Perception, and all of the resistance stats.

 

Phew, all right! That was a lot of stuff. That should do it for our discussion of script actions relating to stat modification. There’s a little more that we didn’t cover here, but I think this is enough for now. You can, of course, always consult the manual for more info on this stuff.

Next up, we’ll learn how to create new items, then tackle coding stand-alone scripts and making items run those scripts when they’re used. See you next time!


Continued in Part 16 >>