PDA

View Full Version : Adding an NPC?


Astor
06-22-2008, 10:55 AM
Okay, so i'm thinking about adding an NPC for my mod, and that they will then give the player an item. So, I have a few questions:

1. nevermind, figured it out

2. How do allow them to have a conversation with the player?

3. How do I get them to give an item to the player?

I have looked through the tutorials, but I'm not too good with understanding scripting, so I thought i'd just ask.

Thanks, Astor.

JediMaster76
06-22-2008, 04:18 PM
Alright, you'll have to do something like this (forgive me, I'm not at my KoTOR computer right now, unable to check it...)

This would be used for making the NPC talk...
void main()
{
oPC = ( GetFirstPC());
oNPC = GetObjectByTag("insertNPCtaghere");
AssignCommand(oNPC,ActionStartConversation(oPC,"my_dlg"));
}


... make sure to add the dialog field in the .utc file and give it the same name as the "my_dlg" above!

This would be to give your player an item, simply insert it into the dialog somewhere...


void main()
{
object oItem=CreateItemOnObject( "item_template", GetFirstPC());
}

Astor
06-22-2008, 04:28 PM
Thanks, JediMaster. I'll give it a whirl when I can work out how to get the NPC to actually appear...

Exile007
06-22-2008, 04:31 PM
Alright, you'll have to do something like this (forgive me, I'm not at my KoTOR computer right now, unable to check it...)

This would be used for making the NPC talk...
void main()
{
oPC = ( GetFirstPC());
oNPC = GetObjectByTag("insertNPCtaghere");
AssignCommand(oNPC,ActionStartConversation(oPC,"my_dlg"));
}


It should actually be


object oPC=GetFirstPC();
object oNPC=GetObjectByTag("npc_tag");


everything else is correct though. ;)

JediMaster76
06-22-2008, 04:32 PM
Heh. I knew I got something wrong ;) Thanks for the help, Exile.

Astor
06-23-2008, 05:15 AM
So, am I right in guessing that I save these as new scripts, and then add them to the .utc file?

Or do I need to do something else?

Istorian
06-23-2008, 07:03 AM
You need to save the scripts, compile them, and the script that will start the conversation should be put in a trigger, and teh other one should be put in a dialogue note like "Take this with you. It will help you in your quest"

That's what I've done. :xp:

If anyone has another idea, post it.

Seamhainn
06-23-2008, 07:21 AM
Ahem, it all depends on what you want to accomplish:

If the NPC shall be in the module from the beginning the PC enters that said module, you should add your new NPC to the .git file. If your new NPC is spawned by a dialogue or anything else it is okay, too.

The other question is, shall your NPC initiate the conversation by itself if the PC approaches that NPC, or shall the PC initiate the conversation (as it is usually the case) by clicking on your NPC. If it is the first, you'll have to make a Trigger (which must also be put into the .git file and needs scripting), if it is the latter the engine does everything for you (simply put).

In any case you have to do a new dialogue file for your NPC which starts either way.

I suggest you do it step by step (spawn your NPC first), then decide how the conversation shall be initiated, then do the dialogue and last make the script which gives the PC the desired stuff.

Keep in mind though, if you spawn the NPC via the .git file, you always have to enter the module anew if you want to test your accomplishments.

Astor
06-23-2008, 10:46 AM
Thank you, Seamhainn, that just about make sense :).

I think that the conversation will only activate after the PC selects the NPC, as I don't to take on too much.

But at the moment i'm having trouble with the NPC spawning. I've got the location right (in large part thanks to your anatomy of a .git file), but it doesn't show up. It'll only show up at the moment if I replace an existing NPC, which I'd like to avoid if possible.

I've added a new slot for the NPC, placed his location, and altered the resref to match the one in the .utc file, and placed it in my override, but it still doesn't show up. Is there something else I need to do?

Seamhainn
06-23-2008, 11:05 AM
Erm, there are so many possebilities:

- You extracted all the files from the original module.
- You copy an existing .utc, change the name of the .utc file, and change First and Last Name (optional) and Tag in the Basic Header and TemplateResRef (I always change both so there are no confusions) in the Advanced Header.
- You add your entry appropiately in your .git file under character with the correct coordinates as explained in the tutorial you mentioned.
- You create a .mod file.
- You toss your .mod file into your modules folder (!).
- You make sure that your PC has never (!) entered your module before when you test it out.

After that we can fiddle with the conversation and the script to give stuff to the PC if you like.

If you still have difficulties, send me a PM, and I am sure, we can solve your problem. But it is importent for the learning curve that you take that action as a last resort :-) .

EDIT: In retrospect: If the NPC does show up if you replace an existing one, I assume that something is wrong with your coordinates maybe.

Astor
06-24-2008, 06:01 AM
I just have one more question...

What files do I need to create a .mod file, other than the .git file? Do I extract everything from both 202TEL and 202TEL_s?

Seamhainn
06-24-2008, 06:08 AM
Yes, you need everything!

Astor
06-24-2008, 06:23 AM
Apologies once again, but a noobish problem and question follow...

So i've built the mod file, using the 202TEL and 202TEL_s rim files, and placed it in the modules folder. But there's a problem.

As I need to reload the module from scratch to test, I need to go through the arrest scenes and everything at the start of Telos. The first scene in the docking bay runs fine, but when it gets to the holding cells, the PC is trapped in the force cage, and Grenn doesn't initiate dialog (which he is supposed to carry on the story).

All i've done is place the modified .git file and the .utc for my NPC into the .mod file, not change anything else. I've tried building the .mod file twice and same problem. What could be the problem?

Thanks, Astor.

Da_Man_2423
06-24-2008, 06:30 AM
Apologies once again, but a noobish problem and question follow...

So i've built the mod file, using the 202TEL and 202TEL_s rim files, and placed it in the modules folder. But there's a problem.

As I need to reload the module from scratch to test, I need to go through the arrest scenes and everything at the start of Telos. The first scene in the docking bay runs fine, but when it gets to the holding cells, the PC is trapped in the force cage, and Grenn doesn't initiate dialog (which he is supposed to carry on the story).

All i've done is place the modified .git file and the .utc for my NPC into the .mod file, not change anything else. I've tried building the .mod file twice and same problem. What could be the problem?

Thanks, Astor.

You included ALL the other files that are originally in that module right? When building you're .mod file? Make sure you didn't miss any.

Astor
06-24-2008, 06:36 AM
I believe so - I extracted all files from both .rim files. Is there something else I might be missing?

Da_Man_2423
06-24-2008, 06:39 AM
Don't custom compiled scripts go in the override folder? Or if you're just reusing the same ones...I'm not sure though.

Seamhainn
06-24-2008, 06:42 AM
- As per my anatomy tutorial you should create a new empty folder somewhere.
- Extract everything from 202TEL and 202TEL_s into that folder. This folder now should contain pretty many files.
- Open the .git file with K-GFF in that said folder and add your new character.
- Place/copy/add your new .utc file into that folder.
- Create a .mod file with KotOR-Tool (that file is usually placed in the K2 folder of the KT-directory).
- Copy the .mod file from there to your modules folder of KotOR.
- Enter the new module or warp to it, and make sure that you have never-ever entered your new module before from the save or warp point (!).

If it still does not work as intended, don't hasitate to contact me via PN (send me the .git and .utc files, and I'll have a look into it). Although I don't have K2 on this computer, unfortunately, I promise you that we'll get it to work ;-) .