TES CS Function/Variable Conditions
Dialogue Tutorial
Part 3: Function/Variable Conditions
<< Back to Greetings <<
The most powerful and flexible section of the Speaker Conditions area is the Function/Variable section. This lets you specify up to six different conditions in addition to race, sex class and so on. For now we'll just look at a couple of these that are especially useful for greetings; we'll look at a lot more later, when we get into quests.
First, though, an overview of what's in that area.
|
Function/Variable List Items
These items return a numerical value which can be compared to another number using standard numerical comparators. If the comparison is true, the condition succeeds; if it is false, it fails.
There are six entries in the Function/Variable list. Each one has the following structure:
|
List 1
|
List 2
|
Comparator
|
Numeric Value
|
Each of these except the last is a drop-down list. The contents of the List 2 depend on what you choose in List 1. I've included the complete list of possibilities in Appendix 1.
|
We'll be looking at many of these later on. Here are the ones we'll be looking at in this section:
|
NotRace: Race
|
This is true if the speaker is not of this race.
|
|
NotID: ID
|
This is true if the speaker is not this person.
|
|
Global: Random100
|
Picks a random number between 0 and 100.
|
|
Global: PCRace
|
A number corresponding to PC's race: 1 Argonian, 2 Breton, 3 Dark Elf, 4 High Elf, 5 Imperial, 6 Khajiit, 7 Nord, 8 Orc, 9 Redguard, 10 Woodelf
|
|
Function: Same Sex
|
This is 1 if the speaker and the player are of the same gender and 0 otherwise.
|
|
Function: Talked to PC
|
This is 1 if the speaker has ever talked to the player and 0 otherwise.
|
Talked to PC
All of the greetings we've added so far are "welcomes". These are appropriate the first time the player talks to an NPC, but should only be said once. Let's make sure that happens.
You have now added a condition which says "say this only if the NPC has never talked to the player before". So after the NPC has said this the first time, they should revert to their default Morrowind greetings. Start the game and test this.
Now we need some more custom greetings for after you've talked to them once...
Not Race, PC Race
We've established that Neverland is a Breton town, so let's give the local non-Bretons something to say about that. Of course, they'll only feel comfortable saying it to somebody who isn't a Breton.
-
Select the record after the three new greetings. (This way the "welcome" greetings will always be said on a first encounter.)
-
Right-click, and choose "New".
-
Hello again, %PCName. It's nice to see an %PCRace face around here -- I sure get tired of Bretons. Oh, they're nice enough, but I always get the feeling they think they're a little bit smarter than us.
-
Add the following conditions to your new greeting:
Cell: Neverland
Disp: 40
Function/Variable: Not Race | Breton | = | 1 ("Anyone but a Breton can say this")
Function/Variable: Global | PCRace | != | 2 ("They'll only say it to someone who isn't a Breton")
Same Sex
How about a little innocent flirting? Here's something for characters of the opposite sex from the player.
-
Add this greeting below the "Not Race" greeting (that one will have priority):
Oh, you're still here, %PCName. Are you going to be free later on? I could show you the sights...
-
Add the following conditions to your new greeting:
Cell: Neverland
Disp: 40
Function/Variable: Function | Same Sex | = | 0 ("Only someone of the opposite sex can say this")
Random greetings
Finally, let's pick a random greeting for everyone in Neverland who doesn't meet one of the conditions already accounted for. This will prevent Neverlanders from using any of the general Morrowind greetings. By randomizing, we can prevent things from getting too repetitive.
Since these will be the "catch-all" greetings, they should go below all the others you've added.
-
Start by making new entries for each of these greetings. Here are five you can use, or make up your own if you prefer. Start by adding the Cell: Neverland and Disp: 40 conditions to all these greetings.
Still here? I'm surprised.
Don't fall in the canals -- that's where we dump our garbage.
Nothing ever changes here. Of course, in some ways that's a good thing: for instance, the bartender never runs out of flin.
Hey, have you heard the one about the %PCRace and the %Race? They go into a bar, and... whoops, you're %PCRace, aren't you? Never mind!
Hello there, %PCName. Enjoying your stay?
-
Now we'll add some conditions to all except the last... that one will be the "catch-all", that will be used if none of the others has been used first (and thus effectively prevent Neverlanders from using standard Morrowind greetings).
-
For the first one, we'll use the Function/Variable condition Global | Random100 | < | 20. The global variable Random100 is a random number between 0 and 99 that changes with each frame. By checking to see if it's less than 20, we're saying that we want a 20% or 1 in 5 chance of producing this greeting.
-
If we get to the second one, we know our random number is in the range 20-99. There are only four greetings left, and we still want an equal chance among all of them. So this time the condition should be Global | Random100 | < | 40.
-
Using the same logic, the third one gets the condition Global | Random100 | < | 60. This one needs another condition as well: we don't want the bartender to say it, since he would be talking about himself. To avoid this, we can use another Function/Variable condition: NotID, which means "anybody except this person can say it". The bartender's ID is DT_Pourboire, so we'll add the condition NotID | Pourboire | = | 1. If you're talking to Pourboire and he gets this far down the list, he'll just go down to the next one.
-
Now there are only two left, so we use the condition Global | Random100 | < | 80. And we need another condition on this one too: it wouldn't be very funny if someone said it to someone of the same race. This isn't too likely since we've already provided another greeting for people of the same race, but that one doesn't apply to Bretons, and we wouldn't want a Breton NPC saying this to a Breton player. So let's add the condition Function | Same Race | = | 0.
-
We could use Global | Random100 | < | 100 for the last one, but that would be silly... it would always be met. So we simply don't use any additional conditions here.
|
Conditions to use for random info/response items
If you want to pick a random greeting or response with equal probability among a number of different items, you need to use a different filter for each item. That's because the number of responses you're choosing among keeps decreasing as you go down the list. The value you compare the random number to should increase in steps of 100/n, where n is the number of responses you have.
|
Responses
|
Values
|
|
2
|
50, none
|
|
3
|
33, 67, none
|
|
4
|
25, 50, 75, none
|
... and so on.
|
Enough! Save and test.
If you like, you can experiment with rearranging the greetings you've got to see what effect that has; and you can add more greetings with different conditions.
>> On to Topics >>