Player Resource Consortium


Author Topic: Adding a Passive Feat to the PRC [How-To Guide]  (Read 422 times)

0 Members and 1 Guest are viewing this topic.

July 25, 2019, 12:55:15 PM

To add a feat to the PRC, you'll need several things:
  • A compiling PRC and PRC SVN repository. There's already guides out there on this, so I'll assume you have it.
  • A competent text editor. I use Textpad. This will edit all files mentioned.
  • feat.2da, in the 2das folder of the SVN
  • prc_consortium.tlk.xml, in the tlk folder of the SVN
  • prc_feat_const.nss, in the include folder of the SVN
  • prc_feats.nss, in the scripts folder of the SVN

The example feat we're going to add is Theocrat from Races of Faerun. It's a boring feat that adds +2 Diplomacy (Persuade in NWN), and +2 Knowledge (Lore, in NWN), but it's an easy example of the basics of adding a passive feat.

Open prc_consortium.tlk.xml, and find an open spot. There's a big gap around number 12940, so we'll go there.
A feat needs two TLK entries, one for the feat name, and one for the feat description.
Feat names look like this in the tlk.xml file:
Code: [Select]
<entry id="12941" lang="en" sex="m">Theocrat</entry> 
Note that the only two things that matter are the entry id, which should always be one higher than the previous item in the list and never match with another one, and the text between the > and <, which is what players will see in game.

Now we repeat the process for the feat description:
Code: [Select]
<entry id="12942" lang="en" sex="m">Type of Feat: General
Prerequisite: None
Benefit: You gain a +2 bonus on Persuade and Lore
Use: Automatic</entry>

With both the name and the description in place, we're finished with prc_consortium.tlk.xml.

Next, we open feat.2da. Now, how I normally go about adding a new passive feat is I go find another feat that's almost the same, and simply copy the text over an empty line, but since this is a guide, I'll go into a little more detail here.

Up at the top of feat.2da, there's a number of column headings. For a passive feat like Theocrat, there's a few that matter: LABEL, FEAT, DESCRIPTION, ICON, and ALLCLASSESCANUSE. And that's it. The rest of the columns actually don't help us out at all.

First, we need to find a blank row, one that isn't in one of the reserves, which are labelled with ###RESERVED at the top and bottom. There's a nice safe empty space at the bottom of the document, starting with row 24284.

Now we start filling this line out with what we need. LABEL is internal text for the human editing the file, and cannot have spaces in it. We put "Theocrat" here, without the quotes. Next is FEAT, which is the name text we added to prc_consortium.tlk.xml earlier. What is done to add a tlk entry to a 2da is to grab the line number (remember, ours are 12941 for the name and 12942 for the description), and add 16777216 to them. This tells NWN to look at the custom tlk, and not the Bioware tlk. We do that, and put 16790157 in the FEAT column, and 16790158 in the DESCRIPTION column. Next, we need an icon, which is what players see in game. Rather than create a new one, I always just grab an existing one from elsewhere in the 2da. Since Theocrat is vaguely religious, we'll put ife_X1Court (Courteous Magocracy) into the ICON column. Finally, ALLCLASSESCANUSE. This column is pretty easy. 1 is yes, 0 is no. Everyone can use Theocrat, so we put a 1 there.

With the columns filled out, we're done with feat.2da.

Now we go to prc_feat_const.nss. This gives the feat we just created a nice name for the rest of the PRC to reference. In here, we organize things by the book that they came from, so scroll down until it says "// Races of Faerun". You'll see a couple feats defined here. Below the bottom one, we're going to add:
Code: [Select]
const int FEAT_THEOCRAT                        = 24284;
This is now the clean name we can reference anywhere inside the PRC. We use these because a number doesn't tell us whether it's a feat, a spell, a class, or something else, whereas FEAT_THEOCRAT tells us it's a feat, and which feat it is. It also means if we ever have to move something, we can change a single constant file (prc_feat_const.nss), and everything else updates automatically.

And that's all we need to do with this file, so save it.

Finally, we're going over to prc_feats.nss. This file is a little bit complicated, because it controls a whole bunch of different feat types, but the important thing is this is what tells the game engine to apply all the bonuses from PRC passive feats. The particular function that does this is called "PRCFeat_AddCompositeBonuses". In PRC terms, a CompositeBonus allows us to stack multiple benefits together, so for instance, if a player has two different feats that grant +2 to Lore, they get the total of +4 they should, instead of +2 if they were applied separately. Either way, don't worry about how it works, just trust that it does.

Which means we're going to use it to apply the bonus to Persuade and to Lore. Which ends up looking like the little snippet of code below. We'll find an open space inside the PRCFeat_AddCompositeBonuses function (and definitely don't break up any of the existing if statements), and plop it in there.

Code: [Select]
    if(GetHasFeat(FEAT_THEOCRAT, oPC))
        SetCompositeBonus(oSkin, "TheocratPers", 2, ITEM_PROPERTY_SKILL_BONUS, SKILL_PERSUADE);
        SetCompositeBonus(oSkin, "TheocratLore", 2, ITEM_PROPERTY_SKILL_BONUS, SKILL_LORE);

And that's it. We save the last of our four files, compile it, and next time we play NWN with the PRC, Theocrat will be an available feat for us.
« Last Edit: July 25, 2019, 01:33:32 PM by Stratovarius »
That is not dead which can eternal lie.
And with strange aeons even death may die.