A. Special characters in dialogue: -STR:-
Welcome back! Now that we know how to create and set variables, it’s time to make those variables actually impact the game.
The first way we can make custom variables impact the game is to display them in dialogue. How? Easy! There are special characters that let us display the contents of a custom variable in dialogue.
For example, let’s take the string variable AlliedWith from Part 12. In dialogue, we can use -STR:AlliedWith- to have the faction the player is allied with displayed. So if AlliedWith is set to Tony Wonder, for instance, this dialogue…
Who are we allied with, again? -STR:AlliedWith-?
Who are we allied with, again? Tony Wonder?
Or if AlliedWith is set to Barry Zuckercorn instead, it’ll display as:
Who are we allied with, again? Barry Zuckercorn?
Get the idea? The makes the dialogue adapt to whatever string the variable currently contains! Super handy.
B. Special characters in dialogue: -VAL:-
There’s a special character for numerical variables as well: -VAL:x–. Just replace the x with the name of a numerical variable, and it’ll display the value of the variable in place of the special character. Thus, this dialogue…
Ann’s mood rating is currently -VAL:AnnEmotion-.
…will display in-game as…
Ann’s mood rating is currently 10.
…or whatever number AnnEmotion happens to be at that moment! (Whenever the value of AnnEmotion updates, so will the dialogue when you return to this branch.)
“Okay Craig,” you say, “that’s cool. But what about having the game run different script actions based on the state of a variable?” That’s supported too! Let’s get into that now.
C. Using IfStringGoTo
We can check to see if string variables are set to a certain value–and if they are, immediately switch to a different dialogue branch. This lets us customize the dialogue branches the player sees based upon what a string is set to. (And we can then put other script actions on those branches to further affect the game!)
The script action that lets us change branches based on what string a variable contains is called IfStringGoTo:
IfStringGoTo immediately switches to a different dialogue branch if a custom string variable contains a particular string. There are three parameters: Variable Name, String, and Branch. Variable Name tells the game what custom string variable to check; String tells it what string match against; and Branch tells it which dialogue branch to switch to if the game finds a match.
But it could be used for a whole lot of other things, too! Those other branches we go to might have actions affecting the items in the player’s inventory, or result in particular characters joining (or leaving) the group. The only limit is our creativity.
We’re not limited to using string variables, either–we can actually do this same thing with numerical variables. We’ll learn how to do that next.
D. Using IfValGoTo
The procedure for switching branches based upon numerical variables is similar to what we just did with string variables! Numerical variables use IfValGoTo, which is identical to IfStringGoTo except for one thing: IfValGoTo doesn’t necessarily need an exact match between the variable and the amount.
IfValGoTo has four parameters: Variable Name, Mode of Comparison, Amount, and Branch. Variable Name tells the game what custom numerical variable to compare; Mode of Comparison tells the game how to compare the variable’s value to the amount; Amount is the amount to compare the custom variable to; and Branch says which conversation branch to switch to if the comparison returns true.
In other words, the the way you choose to compare the numerical variable with the “amount” parameter determines whether it returns true and switches branches. The options for Mode of Comparison are:
- = (true if there’s an exact match between variable value and amount)
- g (true if the variable value is greater than amount)
- l (true if the variable value is less than amount)
- g= (true if the variable value is greater than or equal to amount)
- l= (true if the variable value is less or equal to than amount)
Don’t worry–this will all make sense in a second. Suppose that we want to go branch 1 if AnnEmotion is less than 0, branch 2 if AnnEmotion is equal to 0, or branch 3 if AnnEmotion is greater than 0. We would use the following script actions:
Read literally, these say:
If AnnEmotion is less than 0, go to branch 1.
If AnnEmotion is equal to 0, go to branch 2.
If AnnEmotion is greater than 0, go to branch 3.
The second parameter is what tells the game “less than/equal to/greater than.” The fourth parameter then tells the game what branch to go to if the custom variable ends up being (less than/equal to/greater than) the amount in parameter 3.
That’s it for this part! Next up, we’ll learn all about the SetStat script action. Then once that’s done, we’ll get into some other aspects of modding the game that we haven’t discussed yet (items, attacks, objects, character portraits, character animations, etc.) See you next time!