maltron66

Need help on the populate function

Recommended Posts

Hey guys! It’s me again! But this time, I’m back with a more serious issue that needs to be taken care of (well, the issue here is more complex than modifying .2da files or item equipping or finding why my game  wouldn’t get rid of some old force powers when I started a new game on a fresh installation). This time, I need some help regarding a script function. The “populate” function, to be precise. In case you don’t know what I’m referring to (although I’m pretty sure that everyone knows), the “populate” function is a function that allows you to fill an area with a number of NPC’s. It was created by TimBob12 (bead-v is also credited for the creation of the random number generation script). I really feel like making some scripts to fill areas in K2 that feel kinda empty. But I can’t get the damn thing to work. That’s where you experienced scripters come in. But since I don’t want to be a complete freeloader and ask you guys to just fix my script… first, let me show you what I’ve come up with so far. This is going to be a long thread, so bear with me here.

First off, TimBob12 says that you must place the “populate.nss” file (I believe that most of you know what this script looks like, if not I can upload it here) into the override folder of your game and then add the line:

#include “populate”

…at the beginning of any script you want to make that needs to use the populate.nss to function. So I dump the “populate.nss” file into the override. So far so good.

Then, Timbob12 says that you must lay an imaginary square over the area where you want to spawn the NPC’s in, so you must find the coordinates of the 4 corners. So I used the “FindMe” force power included in glovemaster’s “Handy Force Powers” mod to get the coordinates.

These are coordinates:

 

Module: 209tel

> x: -16.60695

> y: -21.34457

> z: 0.00000

> Orientation: 152.50148

> Bearing: 2.66165

 

Module: 209tel

> x: -16.61303

> y: -36.33560

> z: 0.00000

> Orientation: 229.96750

> Bearing: -2.26950

 

Module: 209tel

> x: -3.46961

> y: -36.34074

> z: 0.00000

> Orientation: 336.61649

> Bearing: -0.40812

 

Module: 209tel

> x: -3.87654

> y: -21.34748

> z: 0.00000

> Orientation: 74.13472

> Bearing: 1.29389

 

(In case you were wondering, these are coordinates recorded from the Czerka Offices in Telos. Specifically, they are the coordinates of the 4 corners of the room where Jana Lorso is.)

Timbob12 says that you don’t actually need the z, Orientation and Bearing coordinates, just the x’s and y’s and not all of them. You only need to find the highest and the lowest values for the x’s and the y’s. Then, you must create a line in your script where you declare the template and the amount of NPC’s you want to spawn and specify the x and y coordinates of the imaginary square you want to spawn them in.

This is the line:

Populate(0,                   0,            0,               0,             0,             Tag,  TRUE);

                 ^                     ^             ^                ^              ^                 ^

           int Amount  int xMin  int xMax  int yMin  int yMax   string Tag

 

So, now that I’ve given you the background of the situation, it’s time to show you what I’ve done so far.

This is what my original script looked like:

 

#include "populate"

void main()

{

string Tag = "czerka_employ001";

Populate(4, -16.61303, -3.46961, -36.34074, -21.34457, Tag, TRUE);

}

 

(What I seek to do here is spawn 4 Czerka Employees inside Lorso’s office.)

So I paste this on the KOTOR Tool’s Text Editor, hit “compile” and the machine starts loading all the necessary .nss files to perform the operation. All is fine, until the following error message appears:

“Error: Type mismatch in parameter 2 in call to “Populate”.”

After some time, I figured out that, what the machine didn’t “like” was the decimals. Since I had declared all values to be integer-type, they shouldn’t have any decimals or the script wouldn’t be compiled.

So after that, I fixed my script, which is what I have now:

 

#include "populate"

void main()

{

string Tag = "czerka_employ001";

Populate(4, -16, -3, -36, -21, Tag, TRUE);

}

 

One would think that this looks fine, but now the machine is giving me a different error message:

“Error: Too many arguments specified in call to “Populate”.”

This is the point where I’m stuck now. I have no idea what this message means, and I do not know how to fix whatever problem’s causing it.

And now, this is the part where you must step in and tell me what I’m doing wrong and tell me how to fix it.

Ideas?

Share this post


Link to post
Share on other sites

Okay, removed the TRUE parameter aaand it works! Once again, thank you Fair Strides! Hmm... you say that this TRUE parameter is nowhere in the example.nss script? That doesn't seem to be the case for me: there actually is a TRUE parameter in my example.nss file. Maybe I added it there myself back when I first started messing around with the populate function and then I forgot to delete it and I kept this TRUE parameter there the whole time. But I highly doubt that I would edit the original file, let alone throw a random parameter in there whose parameter's purpose beats me (dunno what that TRUE parameter is supposed to do). But then again, if you say that there ISN'T a TRUE parameter in timbob12's example.nss script and that's final... it's probably my doing. Anyway, thanks again! And sorry for taking me this long to reply!

Share this post


Link to post
Share on other sites

A quick way to check is to open populate.nss and check the listed parameters for the Populate function. Regardless of whatever is in the example.nss, the populate.nss's layout is law in regards to the parameters needed.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.