lfnetwork.com mark read register faq members calendar

Thread: How to recruit an npc in less than 10 steps
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 07-16-2004, 10:57 PM   #1
Darth333's Avatar
Status: Administrator
Join Date: Feb 2004
Location: In my secret dungeon...
Posts: 8,295
10 year veteran! 
Arrow How to recruit an npc in less than 10 steps

1. Tools:

Check the Getting started with modding: Tools + downloads to get the tools and basic instructions on how to use them.

  • Kotor tool
  • Gff editor (I'll use Bioware's GFFeditor for this mod) edit (10-03-2004): you can do most of this job with Kotor tool now
  • Graphic application that supports the .tga extension ( to add a portrait to the party selection table: otherwise, you can recruit the npc but his portrait will be black)
  • Notepad
  • Script compiler - there is one included with Kotor tool

(out of scope of this tutorial) Make your custom dialogue: use tk102's very practical and flexible DLGeditor.

2. Making the mod:

step 1 --> extract the .utc file for the future recruit:
  • Select the npc you want to recruit. Extract the corresponding .utc file. Since it is easier to work with an example, I will use Dustil (you can download the mod at http://www.pcgamemods.com/u/3451/. I included the source code in the download. I strongly suggest that you follow this tutorial with the mod in hand.

    For Dustil, I extracted: kor35_dustil.utc
  • Then rename the .utc file: for dustil, I used p_dustil.utc. The name doesn't matter as it won't appear in the game. You could name it blabla.utc and it would work, as long as it is a unique name (not used by the game) that does ot exceed 16 chararacters. However, I recommend you use a name that will permit to identify the file easily. The reason why the name has to be unique is that it you simply use g_sithtroop002.utc (for a sith trooper), you'll end up overwriting every single g_sithtroop002.utc file in the game. Not only you'll have a ton of new friends (you'll see later, we will change the faction and behavior of the npc to that of a party member) but the game will crash when you reach certain points.

step 2 --> edit the utc file for the future recruit:

You have 2 options here - GFF editor (old school) and Kotor tool - I use Bioware's GFF editor for the present tutorial -

screenshot - the letters on the screenshot correspong to the steps a to h described hereinbelow.

Open the .utc file with GFFeditor and check the following fields:

(note, the present tutorial covers only the basics of making a recruitment mod. You can edit class, feats, inventory, etc. in the utc file but it is not covered here)..
  • a) AppearanceType: the number in this field corresponds to your npc's appearance row number in the appearance.2da file. For Dustil, it is row no. 432. Put the number corresponding to the appearance of the npc you want.
  • b) then go down to the conversation field: type the name of the dlg file (without the extension) of the npc. Per example, for dustil I wrote p_ductilc, which is the name of the .dlg file that will be used by Dustil once he is recruited.
  • c) FactionID field: set it to 2 which is the faction id for party members.

    The other possible factions are listed in nwscript.nss but they are useless for a recruitment mod.
  • d) FirstName: This is the name that will appear on top of your npc's head when you play the game. If you want to change the npc's first name (useful for custom made npcs) , put -1 in the top box (this means you are not referring to an entry no. in the .tlk file) and , if you have the English version of the game, 1 in the lower box. For other laguages, type one of the following numbers in the lower box:

    Language ID
    English 0
    French 1
    German 2
    Italian 3
    Spanish 4
    Polish 5
    Korean 128
    Chinese Traditional 129
    Chinese Simplified 130
    Japanese 131
  • e) you may also alter the ForcePoints and GoodEvil fields ( for force points, take your npc's level into consideration and for GoodEvil:100 is 100% good and 0 is 100% evil )
  • f) Last name: works the same way as as first name but it is the last name of your npc...
  • g) PortraitID: this number in this field corresponds to the row of your npc's portrait in the portaits.2da file (this will be used to make the portrait appear in the party selection table) .
  • h) the scripts: this will define your npc's behavior. You want your npc to follow your pc and to react like a party member and not like an ennemy during battles, etc... This step is very important: I have seen countless recruitment mods that omitted this step with the result that the npc wouldn't follow or would even turn on the PC in certain cases.

    Replace k_hen_blahblah by k_def_blahblah as follows in the following fields:

    ScriptAttacked --> k_hen_attacked01
    ScriptDamaged --> k_hen_damage01
    ScriptDialogue --> k_hen_dialogue01
    ScriptEndRound --> k_hen_combend01
    ScriptHeartbeat --> k_hen_heartbt01
    ScriptonBlocked -->k_hen_blocked01
    ScriptonNotice --> k_hen_percept01
    ScriptSpawn --> k_hen_spawn01

    Delete the entries in the other script fields.
  • i) go to the tag field: type the tag of the npc you want to replace: A common error is tu use a custom tag: do not do this - you have to use one of the tags below- or the game will crash at certain points if it doesn't find the original npc when this npc was supposed to talk or do something. You'll also end up with multiple "copies" of you custom npc inside the Ebon Hawk if you use a custom tag.

    T3M4: T3M4
    Canderous: Cand
    Mission: Mission
    Jolee: Jolee
    Juhani: Juhani
    HK-47: HK47
    Bastila: Bastila
    Carth: Carth
    Zaalbar: Zaalbar
  • j) go to the TemplateResRef field and type a custom Template ResRef for your new npc: could be new_npc (i recommend using a name that will allow you to regognize the npc easily - it will not be seen in game but if you type hlf_f8fsrdfs you'll have probelms remembering what to type later on...).
  • k) save the .utc file with the same name as what appears in your Template ResRef field and close the utc file.

step 3 --> the script:

This is the script that will tell your game to recruit your npc.

Open notepad and paste the following script:
void main()
   AddAvailableNPCByTemplate(7, "p_dustil");
In RemoveAvailableNPC, number 7 will replave t3m4, for other npcs, use one of the following slot numbers:

HK_47 = 3
T3_M4 = 7

In AddAvailableNPCByTemplate(7, "p_dustil"), also replace number 7 by the slot number of the npc you want to replace and replace p_dustil by the TemplateResRef you used in the .utc file.

Save the script as "recruit_npc.nss" (or whatever name you wish as long as it has a .nss extension - for dustil , the script is: 'dus_recruit.nss' - ) and compile your script. For instructions and troubleshooting concerning the script compiler, read this thread: http://www.lucasforums.com/showthread.php?t=143681 COMPILING YOUR SCRIPT IS MANDATORY. YOU CANNOT BYPASS THIS - it takes only 2-3 seconds to do.

Once compiled, you should now have an new .ncs file - example the dustil mod gives you 'dus_recruit.ncs' .

You could also give the player the option to recruit whoever he wants by making various dialogue options. Rough example:

PC replies:
1. ok, come with me, i have a droid to replace (attach script to replace t3-m4) (and why not add the obligation for the pc to sell the droid to a merchant first - conditional script - to make place on the Ebon hawk )
2. ok, come with me, you'll take the place of my wookie slave (attach script here)
3. ok, come with me, you'll certainly be more useful than a 14 yrs old girl for this "mission"... (attach script to replace Mission)

step 4 --> attach the script to a conversation:

To recruit your npc, you need to attach the script somewhere in order to fire it. The best bet is to attach it to a conversation (dlg file).

This tutorial uses tk102's DLGeditor - link provided at the top of this post -

Open the dlg the dialogue editor and select and entry or a reply. In the field where it says Script that fires when spoken, type the name of your script without the extension and in the field entitled script. Per example, in the Dustil mod, the recruit script is attached to Entry no. 104 in the kor39_utharwynn.dlg file.

step 5 --> edit the apprearance of your npc:

If you want your npc to be able to wear armors and robes, you have to edit the appearance.2da file with Kotor Tool.
I suggest you follow the BIFs section in T7's tutorial concerning editing appearance.2da: http://www.map-review.com/index.php?...ial_view&id=28
In any event, look at what i did in the appearance.2da file for the Dustil mod: compare row 432 in the original file and the file included in my mod download. I edited the columns from modela to texj so that my custom recruit can wear armor.

step 6 --> take a photo of your npc :

You can now test your mod. Go to the game and test it, recruit your npc, select your new npc in the party selection table and take screenshot of your npc while in game and edit your screenshot with a graphic application such as photoshpop, paint shop pro or GIMP (it has to support the .tga extension) and make a 64 or 256 pixels square, per example, and save at 32 bits.

Save your image as po_blahblah.tga ( for dustil, i used po_dustil.tga)

Then, go to the portrait.2da file and add a new row:
If you don't know how to add a new row to a.2da file, look at this thread: http://www.lucasforums.com/showthrea...hreadid=130290

In the baseref column, type the name of your .tga file (po_blahblah) without the extension. Then, in the "appearance number", "appearance_f" and "appearance_s" colums, enter the row number of the appearance.2da file corresponding to the appearance of your npc. Race, normally it's 6 but check the "Race" field in your npc's .utc file just in case. screenshot of portraits.2da modifications in the dustil mod

Save and close (before saving, just click on another row you'll loose your new row).

Finally, open the .utc file with GFF editor and in the field entitled portraitID, and check the number of the row you just added to the portrait.2da file (per example 41).

Step 7 --> eliminate "twins" :

If you are recruiting an npc that is already used by the game, you may want to use an additional script or you may end up with twins. If you look at step 1 of this tutorial, you'll remember that we extracted the original .utc and renamed it. For the game these are two different objects, even if they have the same appearance. So when you recruit the npc, the original npc will still be there and you'll end up with 'twins". In order to avoid this, you can use the following script which will destroy the original npc on place: (note: don't look for this in the Dustil mod, it's not there. I made him run away instead of destroying him on place )

void main() 
object oGoodbye;
oGoodbye = GetObjectByTag("my_npc_tag");
SetGlobalFadeOut(1.0, 0.5);    
DelayCommand(1.0, DestroyObject(oGoodbye));
oGoodbye = GetObjectByTag("my_npc_tag"); (leave the quotes there) and replace my_npc_tag by the tag of the original npc in the the game. To get the tag, open the .utc file of the original npc in the game with a GFF editor or Kotor tool (for Dustil the .utc file is named kor35_dustil.utc) and check the tag field. The name of the .utc file does not always correspond to the tag field so always check.

Save your script with a .nss extension, compile and attach to dialog (do this at the very end of the conversation with the original npc or you'll ran into trouble if he disappears permanently before the end of the conversation ).

Additional stuff:

What you can do with a recruit mod is infinite. You can add sound, conditions upon which the npc will be recruited, sidequests, journal entries, experience points, etc. : these have all been covered at holowan labs so explore the other tutorials if you want to add more stuff.

There is only one more thing I will add: If you want to recruit a custom npc and want to spawn him somewhere before recruiting it.

You need another custom .utc file. Extract a .utc file from a similar npc in the game (not the apperance but in characteristics - it's easier to simply change the appearance number than re-edit all the stats). This is a new npc for the game so give it a new name. For the purpose of this tutorial , we will call it not_recruited_yet.utc

a) Change the AppearanceType filed to the row number you wish in appearance.2da
b) then go down to the conversation field: type the name of the custom .dlg file (without the extension) . Per example, not_recruited_speaks
c) FactionID field: set it to 5 which is neutral (if you set it to 1 -ennemy - you'll only have a battle and no dialog so no possibility to recruit).
d) FirstName: This is the name that will appear on top of your npc's head when you paly the game. Refer to the 1st part of this tutorial
e) Last name: works the same way as as first name but it is the last name of your npc...
f) the scripts that define the npc's behavior should be already set if you did not first extracted an original party member .utc
g) go to the tag field: type a custom tag. example "not_yet_recruited"
j) go to the TemplateResRef field and type a custom Template ResRef : you can use the same name as the tag, "not_yet_recruited"
k) save and close the utc file

Spawning: you can use the script below or one of the other solutions proposed in this thread: http://www.lucasforums.com/showthread.php?t=143536

Spawn script: paste in notepad, make appropriate changes, save as a .nss file and compile:
void main() 
//do a whereami cheat to get the coordinates of the location 
//where you want the npc to spawn
float x=0.00f;  
float y=0.00f;
float z=0.00f;
//unless you want something specific, forget about orientation
float r=0.0f;
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);
 //insert your npc tag instead of my_creature_resref. Don't remove the quotes and do not exceed 16 chars.
object oNPC=CreateObject(OBJECT_TYPE_CREATURE,"my_creature_resref",locNPC);
object oPC=GetFirstPC();
//replace my_dlg by the name of the dlg file the npc is supposed to use
If you don't know how to do a "whereami" cheat: Go on the spot where you want to spawn the npc with your PC, open the cheat console and type "whereami" without quotes. Press enter and the coordinates (XYZ) of the location will appear right under the cheat console.

Attach the script to a mandatory conversation branch located in the same module you want to spawn the npc . You can also use the module on enter event to spawn you custom npc (see: http://www.lucasforums.com/showthread.php?t=143536) - there are multiple other ways of doing it but this is the most simple way: the idea here is to get you started -

Feedback always appreciated. If you feel some points are not clear or if i forgot something, just say so and I'll complete the tutorial.
Darth333 is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Star Wars Gamer > Community > The Star Forge > Knights of the Old Republic series > Holowan Laboratories > Tutorials > Tutorials: General Tutorials + Tools > How to recruit an npc in less than 10 steps

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 11:20 AM.

Powered by vBulletin®
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.