Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Spawning a npc on the Endar Spire

Page: 1 of 1
 Seamhainn
06-08-2007, 2:58 AM
#1
Hello!

I am a noob, and this is a noob question. I tried this a couple of weeks ago, but, though I got help (and read the tutorials), I could not do it.

I want to spawn a npc on the Endar Spire after the pc wakes up. It would be great if I could get a step-by-step help what to do to accomplish that.

This is just a personal mod to get started with modding.

So any help with what to do, where to look at, and which tools to use are highly appriciated.

Sorry if I annoy some oldtimers with a beginners request.

Take care
 tk102
06-08-2007, 3:52 AM
#2
Hi there. Welcome to modding. That's a good first goal.

There are two ways to get an NPC into the game. One way is to edit the module itself so that the game knows where to put everything when the module is loaded. But that's overly complicated for what you intend. The second and much simpler way is to write a script that spawns the NPC.

So you'll have to write the script, compile the script, and then figure out how to trigger the script in the game. (more on this stuff later)

But we should back up. You'll need a creature template that the script will reference when it fires. So if you haven't done so, download KotOR Tool from http://kotortool.starwarsknights.com). Once you have KotOR Tool, launch it and in the treeview, browse to KotOR I -> Templates -> Blueprint, Character and double-click on any .utc file that you like. This will bring up KotOR Tool's Creature Editor. From here you can specify the appearance of the NPC, change its name, Inventory, whatever. When you're done editing, click the Save button, name the file mynpc.utc and save it into your Override folder.

Okay now you have a creature template. Time to write the script. Copy and paste this into notepad:
void main() {
location locMe=GetLocation(GetFirstPC());
CreateObject(OBJECT_TYPE_CREATURE, "mynpc", locMe);
}
Now we need to compile the script. Save this file as myspawner.nss into the same directory as KotOR Tool. Open a command prompt in the KotOR Tool directory and type:
nwnnsscomp -c myspawner.nss
This will create myspawner.ncs. Move myspawner.ncs into your Override folder.

Finally we need to get the game to fire the script. The easiest way is through a dialog. Trask's introductory dialog would work fine for this. In KotOR Tool browse to KotOR I -> RIMs -> Modules -> end_m01aa_s.rim -> Dialog and double click on end_trask01.dlg. This will bring up KotOR Tool's Dialog Editor (which only works for KotOR 1, btw). You can use any node in the dialog to attach your script. It's best to choose one that will only get said one time (so you don't get an army of jawas as you ask Trask to repeat himself)... Under Root there is a node labeled [OWNER] and inside that node is another labeled [CONTINUE]. Highlight the [CONTINUE] node and notice how there is nothing in the "Script to run for this node" textbox? That means you can put your script right there. Type "myspawner" in that textbox. Now save the end_trask01.dlg into your Override.

That's all. Try launching a new game to see how it works for you. As you get comfortable with these game mechanics, you'll want to do more and there will be more details to address. Hopefully this will get your feet wet enough that the tutorials will start making more sense. :)
 Seamhainn
06-11-2007, 4:22 AM
#3
Okay, this is what I did. I loaded the p_bastila.utc file. I saved it to the override folder and named it n_basvis.utc. (I want that the pc gets a vision of Bastila early in the game, she says some lines and that's that.) I copied your script, renamed mynpc to n_basvis and saved it as basvis1.nss (though it shows up as a textfile!). I typed in the command at the prompt and get the message: Error: Unable to open input file "basvis1.nss".

What did I do wrong (I have the German version if that is important)?

Thanks!
 Mindtwistah
06-11-2007, 5:05 AM
#4
tk102, you should write a book about modding or something. You just answered 4 of my questions about modding.

Edit: can you tell me how to do it the hard way, a.k.a. edit the module file? I want to spawn my NPC on the Ebon Hawk, and then choose if I want to kill him or have him there. If I kill him, I don't want him to keep respawning.
What should I do?
 tk102
06-11-2007, 9:34 AM
#5
(though it shows up as a textfile!). I typed in the command at the prompt and get the message: Error: Unable to open input file "basvis1.nss".
Notepad likes to append ".txt" to the end of anything you write in it. There are two ways to avoid this.

1. When saving your file in Notepad, wrap it in quotes: "basvis1.nss"
2. When saving your file in Notepad, first change the file filter from "Text files (*.txt)" to "All Files (*.*)"

Windows has an annoying feature that hides file extensions of known file types like .txt, making this a relatively common problem. What's worse is that it allows spammers to trick folks into launching their email attachments.

To disable this feature and view all file extensions:
In Windows Explorer choose Tools: Folder Options...: View and uncheck the option that says "Hide Extensions for Known File Types". (I hope these English instructions help you on your German system.) Once that's off, you'll able to spot the difference between basvis1.nss.txt and basvis1.nss immediately.

@Mindtwistah: Glad this was helpful for you. I don't think you'd need to create a module for the scenario you're describing as it can all be done via scripting. In any case, I would ask you create a new thread so not to hijack this one. :)
 Seamhainn
06-12-2007, 1:37 AM
#6
I DID IT! Thank you very much, tk102!

Some things to consider though. Kotor Tools loads the dialogues with the english sign set. Which means we Germans have those signs: д, ц, ь. These are supstituted by ?, / and such. So after saving the changed dialogue some words have those signs in them. To make it short: it might not be wise to make a dialogue-fired script for non-english versions ;-) . (I am happy with the result nonetheless! Thanks again!)

My questions are:

Whats the difficult way to go to spawn a npc (module-generated I guess)?

If I talk to Bastila she (of course) has all the lines when first talking to her on Taris. What must I do to create my own dialogue (or where can I look up those things)? I assume its wise to strip the utc (?) file of all Bastila-related stuff.

Just for curiosities sake:
What does nss/nsc (file) stand for?
What does utc (file) stand for?
As the scripts are object oriented (I assume), what does "Void Main" do/mean?

Thanks and take care!
 tk102
06-12-2007, 2:18 AM
#7
I DID IT! Thank you very much, tk102!:emodanc:
Kotor Tools loads the dialogues with the english sign set.
You may have more luck using DLGEditor, a different dialog editor (also works for TSL), that you can download from http://www.starwarsknights.com/tools.php). I suggested using KotOR Tool to begin with since it's less overwhelming when you're first starting out.

My questions are:
Whats the difficult way to go to spawn a npc (module-generated I guess)?
The basic steps:
1. Extract all the files from the *.rim and the *_s.rim module that you want into a folder (eg. end_m01aa.rim and end_m01aa_s.rim).
2. Create a new .utc file that you want to add and put it into this folder (like you did previously.)
3. Use KGFF to edit the .git file from the module. You will be adding a new Struct to the CreatureList -- this info will contain the creature template's filename (i.e. TemplateResRef), its coordinates, and its orientation.
4. Repackage all the files into a MOD file named the same as the .rim (eg. end_m01aa.MOD) and place this file into the Modules folder (not the Override folder)

If I talk to Bastila she (of course) has all the lines when first talking to her on Taris. What must I do to create my own dialogue (or where can I look up those things)? I assume its wise to strip the utc (?) file of all Bastila-related stuff.Specifically, you'll want to change the Conversation field of the .utc file. You can create a new dialog tree using DLGEditor or KotOR Tool. Dialogs can be basic or complex so you might want to read some of the tutorials or the readme that comes with DLGEditor. You'll save the dialog as a *.dlg file into the Override folder with a name 16 characters or less and try to make it unique. Then place the name of this dialog (without the .dlg extension) into the Conversation field of your custom .utc file.

Just for curiosities sake:
What does nss/nsc (file) stand for?
"NWScript, Source" file and "NWScript, Compiled" file. NWScript is named after Neverwinter Nights, whose Aurora game engine was the predecessor to the Odyssey engine used by KotOR.

What does utc (file) stand for?"Uniform(?) Template, Creature"
As the scripts are object oriented (I assume), what does "Void Main" do/mean?The scripts are very similar to C programming language. "void" describes what the function returns -- that is, nothing. Main is the name of the function, and is always the entry point for normal, non-conditional scripts. Conditional scripts used in dialogs begin "int StartingConditional()" because they return an integer value (interpreted as true or false) to tell the game whether certain responses should be available or not.

For more information you can also read Bioware's documentation here (http://nwn.bioware.com/developers). :)
 Mindtwistah
06-12-2007, 6:36 AM
#8
The basic steps:
1. Extract all the files from the *.rim and the *_s.rim module that you want into a folder (eg. end_m01aa.rim and end_m01aa_s.rim).
2. Create a new .utc file that you want to add and put it into this folder (like you did previously.)
3. Use KGFF to edit the .git file from the module. You will be adding a new Struct to the CreatureList -- this info will contain the creature template's filename (i.e. TemplateResRef), its coordinates, and its orientation.
4. Repackage all the files into a MOD file named the same as the .rim (eg. end_m01aa.MOD) and place this file into the Modules folder (not the Override folder)



I've done that but it doesn't work. I entered the template ResRef for the creature, the x,y,z position and the x,y orientation but the NPC still doesn't show up. Do I need to enter some kind of script or something first?
 tk102
06-12-2007, 9:40 AM
#9
Forgot to mention to keep in mind that once you visit the module, it becomes part of your savegame. So any changes you repack into a .mod file will only be apparent if you've never entered that area before.
 Seamhainn
06-12-2007, 9:54 AM
#10
:emodanc:

The basic steps:
1. Extract all the files from the *.rim and the *_s.rim module that you want into a folder (eg. end_m01aa.rim and end_m01aa_s.rim).
2. Create a new .utc file that you want to add and put it into this folder (like you did previously.)
3. Use KGFF to edit the .git file from the module. You will be adding a new Struct to the CreatureList -- this info will contain the creature template's filename (i.e. TemplateResRef), its coordinates, and its orientation.
4. Repackage all the files into a MOD file named the same as the .rim (eg. end_m01aa.MOD) and place this file into the Modules folder (not the Override folder)



I did 1 and 2. How do I add a new Struct (Struct ID: 4 I assume)? I can copy a Struct with the Edit menue, but not paste it. How can I repackage the files?

Thanks and take care
 tk102
06-12-2007, 10:04 AM
#11
You can paste it by right-clicking on the CreatureList list field and choosing Paste.

You can repackage the files using either KotOR Tool's ERF/Mod Builder (Tools -> Open ERF/MOD builder) or by using stoffe's ERF/RIM builder from http://www.starwarsknights.com/tools.php) (here's the thread link) (http://www.lucasforums.com/showthread.php?t=165051) I prefer the latter, IIRC. :p
 Seamhainn
06-12-2007, 10:43 AM
#12
Windows shows end_m01aa.MOD as a "Filmclip" file? Can that be???

I'll try it out tonight.

Thanks and take care!
 Mindtwistah
06-12-2007, 11:56 AM
#13
Oh foolish me. I forgot to set the STRUCT ID to 4 :P

Now it works.
 Hunter-Killer
06-13-2007, 5:45 AM
#14
What is the name of the NPC your making? (just curious)
 Mindtwistah
06-13-2007, 5:53 AM
#15
Who me? Davik. The mod is already out: http://www.lucasforums.com/showthread.php?t=179392)
 Seamhainn
06-13-2007, 7:59 AM
#16
I don't dare to ask, but I do it anyway: Can someone explain how to create a dialogue and which traps avoid? And, yes, I did look up the tutorials and such.

Thanks and take care
 Mindtwistah
06-13-2007, 8:30 AM
#17
Just open up dlg editor and press "new reply" or new entry". Then you press "save as" and save your dialog.
Page: 1 of 1