Jump to content

Home

Creating A New NPC in a custom module


HK-42

Recommended Posts

Hey, Do any of yall know where I can find a tutorial on making a new alien NPC with dialog, a store(already got the utm and this script:

 

// ST: st_startstore.nss

void main() {
object oStore = GetObjectByTag("m_954_001");
       object oSpeaker = GetPCSpeaker();

if (!GetIsObjectValid(oStore))
	oStore = CreateObject(OBJECT_TYPE_STORE, "m_954_001", GetLocation(OBJECT_SELF));

if (GetIsObjectValid(oStore))
	DelayCommand(0.5, OpenStore(oStore, oSpeaker));
}

)

 

and spawn him in a custom module?

 

PS: Also is there something wrong with this script?

 

Thanks!

Link to comment
Share on other sites

If you create a new module, you need a .git file anyway. If that npc is supposed to be in the module from the beginning, then the best way is to place him there via the .git file (like other objects, such as doors, placeables, etc) instead of running a script to spawn him.

Link to comment
Share on other sites

If you create a new module, you need a .git file anyway. If that npc is supposed to be in the module from the beginning, then the best way is to place him there via the .git file (like other objects, such as doors, placeables, etc) instead of running a script to spawn him.

 

hmm well the module is already made by someone else im just adding a merchant to it.

Link to comment
Share on other sites

/* Possible Object types:
OBJECT_TYPE_CREATURE 
OBJECT_TYPE_ITEM          
OBJECT_TYPE_TRIGGER    
OBJECT_TYPE_DOOR        
OBJECT_TYPE_WAYPOINT 
OBJECT_TYPE_PLACEABLE
OBJECT_TYPE_STORE  */

// for the 3 floats in the function below
// you can use the X, Y, Z coordintates from
// the whereami cheat code
vector vPosition=Vector(0.0, 0.0, 0.0);

location lWhereToSpawn=Location(vPosition,0.0);

CreateObject( OBJECT_TYPE_CREATURE,
"object_template",lWhereToSpawn);

Time to explain the different parts of the code.

 

vector vPosition=Vector is where you put the x y z coordinates you get with the Whereami band. If you didn't know where this is, use the Whereami Band, and, go into your journal tab. In there, go to the Feedback, and you'll find the x y z there, along with the Orientation and Bearing. You can ignore the Orientation fields for this script, as they are used in placing things in a git file.

 

 

location lWhereToSpawn=Location(vPosition,0.0) lWhereToSpawn is used later in the script, to help place the item. The coordinates are for the bearing. Put what you got for the bearing here.

 

The rest you should be able to figure out.

Link to comment
Share on other sites

/* Possible Object types:
OBJECT_TYPE_CREATURE 
OBJECT_TYPE_ITEM          
OBJECT_TYPE_TRIGGER    
OBJECT_TYPE_DOOR        
OBJECT_TYPE_WAYPOINT 
OBJECT_TYPE_PLACEABLE
OBJECT_TYPE_STORE  */

// for the 3 floats in the function below
// you can use the X, Y, Z coordintates from
// the whereami cheat code
vector vPosition=Vector(0.0, 0.0, 0.0);

location lWhereToSpawn=Location(vPosition,0.0);

CreateObject( OBJECT_TYPE_CREATURE,
"object_template",lWhereToSpawn);

Time to explain the different parts of the code.

 

vector vPosition=Vector is where you put the x y z coordinates you get with the Whereami band. If you didn't know where this is, use the Whereami Band, and, go into your journal tab. In there, go to the Feedback, and you'll find the x y z there, along with the Orientation and Bearing. You can ignore the Orientation fields for this script, as they are used in placing things in a git file.

 

 

location lWhereToSpawn=Location(vPosition,0.0) lWhereToSpawn is used later in the script, to help place the item. The coordinates are for the bearing. Put what you got for the bearing here.

 

The rest you should be able to figure out.

 

so:

vector vPosition=Vector(-51.96494, 29.39132, 9.66545);

location lWhereToSpawn=Location(vPosition,-0.85296);

CreateObject( n_bith,
"object_template",lWhereToSpawn);

 

what do I put for object_template? sorry very new to scripting

Link to comment
Share on other sites

forgot to mention that part. object_template is for the tag/resref (advised you make them the same) of your character file. So, if your characters tag/resref is jedi_01, in place of object_template, you put jedi_01

 

thanks so this is my final:

vector vPosition=Vector(-51.96494, 29.39132, 9.66545);

location lWhereToSpawn=Location(vPosition,-0.85296);

CreateObject( OBJECT_TYPE_CREATURE,
"n_bith",lWhereToSpawn);

 

this right?

Link to comment
Share on other sites

thanks so this is my final:

vector vPosition=Vector(-51.96494, 29.39132, 9.66545);

location lWhereToSpawn=Location(vPosition,-0.85296);

CreateObject( OBJECT_TYPE_CREATURE,
"n_bith",lWhereToSpawn);

 

this right?

 

It looks right. (If he is facing the wrong way, try putting the bearing coordinate as 0.0 again.) But, there is only one way to test it out...

Now, throw that into the KOTORTool Text Editor (paste isn't done by right click in there, in case you didn't know. Its in the Edit menu), save it as a .nss file (call it anything you want as long as it is less then 16 characters. Do something simple like bith_spawn), and in script, press the game your making the script for (KOTOR 2 in your case) and click compile. Hopefully it'll compile correctly. Now, open up the DLGEditor, find a dialog that is activated when you enter that module, and, in the action script section of a line, put the name of your script (using my example, bith_spawn), click another line just to be sure, and save. Now, see if your script runs!

Link to comment
Share on other sites

It looks right. (If he is facing the wrong way, try putting the bearing coordinate as 0.0 again.) But, there is only one way to test it out...

Now, throw that into the KOTORTool Text Editor (paste isn't done by right click in there, in case you didn't know. Its in the Edit menu), save it as a .nss file (call it anything you want as long as it is less then 16 characters. Do something simple like bith_spawn), and in script, press the game your making the script for (KOTOR 2 in your case) and click compile. Hopefully it'll compile correctly. Now, open up the DLGEditor, find a dialog that is activated when you enter that module, and, in the action script section of a line, put the name of your script (using my example, bith_spawn), click another line just to be sure, and save. Now, see if your script runs!

 

hmm didnt get this on my last script:

bith_spawn(6): Error: Syntax Error at "CreateObject"

Compilation Aborted With errors

 

EDIT: Also on dialog I might have to create some because the only dialog in the module is packed into the module(i believe) so unless I extract it off KT from 954cor.mod there is no dialog. Would it work if I did that?

Link to comment
Share on other sites

Try this:

 

object oBith = CreateObject( OBJECT_TYPE_CREATURE, "n_bith", lWhereToSpawn );

 

- Star Admiral

 

thanks, it works now just the dialog, ill try to extract it off the module.

 

EDIT: Didnt work will have to somehow find another way...

Link to comment
Share on other sites

inside the utc? No.

 

Well, you'll have to set it to do that. I found it easier to put it in using the KGFF, but you can use KTool's Creature Editor. All you have to do is make the dialog, and in the conversation field in the KTool's creature editor, put the name of the dialog file you saved (without the .dlg extension)

Link to comment
Share on other sites

Spawn the NPC like you did before, without adding anything to the dialog file. If you use KT, you add the dlg file name in the textbox under the Conversation heading. Look at the screenshot for an example.

 

dialogrc2.th.jpg

 

- Star Admiral

 

the npc never spawned and I know about the dialog its just the npc does not spawn.

Link to comment
Share on other sites

As I understand it, you put the spawning script in the dialog file, right? But since the dialog will only trigger when you talk to the NPC, and the NPC will only spawn when triggered by the dialog, we end up going in circles. You'll need to trigger the spawning script when the module is loaded, not within the dialog file.

 

- Star Admiral

Link to comment
Share on other sites

As I understand it, you put the spawning script in the dialog file, right? But since the dialog will only trigger when you talk to the NPC, and the NPC will only spawn when triggered by the dialog, we end up going in circles. You'll need to trigger the spawning script when the module is loaded, not within the dialog file.

 

- Star Admiral

 

I put it in the soliders dialog. How do I add it to the module?

Link to comment
Share on other sites

First, open up KT. Expand KOTOR II, then RIMs, then Modules. Locate the module you wish to spawn the NPC in. Let's pretend it's 003EBO. Expand 003EBO.rim, then Static Area Info. Double-click on the file 003ebo.are. In the text file that opens, scroll all the way down. Locate the line "Label: OnEnter". Look to the right for the entry "Value: xxxxxx". The xxxxxx is the name of the on enter script you need to use. Then, follow this tutorial to proceed with implementing the spawning script.

 

- Star Admiral

Link to comment
Share on other sites

First, open up KT. Expand KOTOR II, then RIMs, then Modules. Locate the module you wish to spawn the NPC in. Let's pretend it's 003EBO. Expand 003EBO.rim, then Static Area Info. Double-click on the file 003ebo.are. In the text file that opens, scroll all the way down. Locate the line "Label: OnEnter". Look to the right for the entry "Value: xxxxxx". The xxxxxx is the name of the on enter script you need to use. Then, follow this tutorial to proceed with implementing the spawning script.

 

- Star Admiral

 

Since its a custom module it is not in the KT Rims. That should be helpful for another mod though.

Link to comment
Share on other sites

In that case, use KT's Module Editor. Navigate to the folder where you have saved the custom module files and open it. I haven't tried using it but that should be the way to go.

 

Note: I'm not sure whether KT can correctly modify the module files without corrupting them. I know for a fact that you can't use KT's DLG editor. Make sure you save a backup of the custom module before editing it, else you might lose some valuable data.

 

- Star Admiral

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...