How to Make a Party Member Quest/Dialog Tree
Greetings and salutations to ye, fellow LFers!
I bringeth ye a tutorial on something which I think a lot of people who try to make recruit mods sadly fall short of being able to do, which is a shame, considering how simple it really is.
In this tutorial, i'll be showing you how to set up one of those fancy dialog trees like the vanilla party members have, which allow you to progress through their personal quests and conversations as you level up your character.
Basically, we'll be doing this using two globals,one of which will keep track of how far the quest has progressed and the other will keep track of what level you were last time you spoke to the NPC.
Firstly you'll need to go into KotOR Tool and find the globalcat.2da file. This is the file which contains all the globals used in the game. What you need to do, is add two new rows for your new globals. You can call them whatever you want, it doesn't make too much of a difference.
For the Row Label field, just add 1 onto the line before. As I said, the name can be whatever you like, but I recommend using something which people will be able to automatically assosciate with your mod. As for the type, you need to set it to Number. If you set it to Boolean, this won't work, as a Boolean can only have one of two values; True or False. A Number can have a LOT more than two values, which are equal to an integer, such as 1, 2, 3, etc.
Here are the ones I added for my example:
As you can probably tell, MF_KRIS_QUEST will be used to keep track of how far into the conversation you've progressed and MF_KRIS_LEVEL will keep track of what level you were last time the quest progressed.
Oh, and if you're wondering where the KRIS part came from, i'm using the name from a recruit mod I attempted to make when I first started modding, which had you recruit a Jedi named Krisalis. Ironically enough, it was because I was unable to do what i'm going to teach in this tutorial that I had to scrap the mod idea.
Anyway, onto the meat of this tutorial; the scripting!
I won't be showing you how to actually recruit your NPC, as i'm assuming you know how to do that already. If not, there's an excellent tutorial here
which should help you along.
Right, so before I show you how to check the globals to see how far the quest has progressed and whether or not to allow conversation nodes to activate, i'll show you how to actually set the values of the globals which you created.
This is easily achieveable using some simple scripting commands. Here is a basic script which will set the value of your first global (which tracks the progress of the quest) to 1, which will basically mean the first step in the quest has been taken. It will also show you how to set the value of the global which tracks your level throughout the quest to whatever level your character is at the time of the script firing.
Here we go:
int nLevel = GetHitDice(GetFirstPC()); // The value of the nLevel variable will be equal to your characters current level, which is always an integer.
SetGlobalNumber("MF_KRIS_QUEST", 1); // As you can probable tell, this line will set the value of the MF_KRIS_QUEST global to 1.
SetGlobalNumber("MF_KRIS_LEVEL", nLevel ); // Again, as you can most likely see, this will set the value of the MF_KRIS_LEVEL global to whatever the value of nLevel is.
That wasn't as painful as you thought it would be, was it?
Now, onto the next script; the one which will actually be used to check the values of your globals and determine whether conversation nodes are available, and whether events can happen yet.
This script is surprisingly simple too. As you're about to see, it uses a simple mathematical calculation to decide whether to return a TRUE or FALSE result.
I'll add comments to each line of the script to explain what's happening, just like in the first one.
int nQuest = GetGlobalNumber("MF_KRIS_QUEST"); // As you've probably worked out by now, nQuest will be the value of the MF_KRIS_QUEST global.
int nQuestLvl = GetGlobalNumber("MF_KRIS_LEVEL"); // nQuestLvl will be the value of the MF_KRIS_LEVEL variable.
int nLevel = GetHitDice(GetFirstPC()); // nLevel will be equal to the current level of your character.
if ((nQuest == 1) && (nLevel > nQuestLvl)) // Here's the calculation I mentioned. Basically, it works out whether the value of nQuest is equal to 1 and your current level is greater than the value of nQuestLvl.
return TRUE; // If the above conditions ARE met, then your result is TRUE. This means that the conversation node/event can activate/take place.
return FALSE; // If the conditions set by the calculation are NOT met, then you get a FALSE result. This means that the conversation node/event can NOT take place.
If you want copies of my scripts without my comments in, they'll be attached at the bottom of the post for you to download and look at.
Now all you need to do is replicate these scripts a bunch of times, depending on how long your quest is going to be! Obviously you'll need to set the values to different integers as you progress, otherwise you'll end up with a quest that won't progress at all.
Well, I think i've most likely bored you enough by now!
So, go forth and recruit!