Jump to content

Home

Populate Function


TimBob12

Recommended Posts

That's how I thought it should work but I never got round to test it. I have the script ready I just need to test it which I'll do tomorrow as its getting late and I have an exam tomorrow. I will also test hararks method if I get round to it :)

Link to comment
Share on other sites

This is my script

 

#include "populate"

void main() { 

Populate(15, 8, 121, -10, 103, "522_man1"); 
Populate(15, 8, 121, -10, 103, "522_man2");   
Populate(15, 8, 121, -10, 103, "522_man3"); 
Populate(15, 8, 121, -10, 103, "522_fem1"); 
Populate(15, 8, 121, -10, 103, "522_fem2"); 
Populate(15, 8, 121, -10, 103, "522_fem3"); 



}

 

Doesn't work. I even changed the coords above to a much smaller area and no go

 

Seems to compile fine....beginning to think that this some crazy glitch that sometimes happens when modding.

 

Edit, I used the debugging technique from the tutorials and the script is being read onenter...so...

Link to comment
Share on other sites

No idea but this populate function does seem to have a few glitches. I've noticed something but i wasn't sure if it was my doing until today. It seems not to obey the number of each charcter put in, i put 3 of a charcter that has an ithorian model in the script, in game I counted 5 ithorians and only one charcter type has the ithorian model. Little confused but its timbob's scripting hopefully he knows.

Link to comment
Share on other sites

  • 4 weeks later...

Hasn't but in theory it should work with no problems although some users have experienced problems that only some people seem to get. It works for like 80% of people. I just haven't had the time to confirm for K1. Should work fine though.

Link to comment
Share on other sites

TimBob my characters seem to be spawning at random numbers, and I can't tell why! I used this script as my OnEnter script:

 

#include "populate"

void main() {

Populate( 3, -62, -26, -80, -76, "gmember");

Populate( 3, -62, -26, -80, -76, "gmember2");

Populate( 3, -62, -26, -80, -76, "gmember3");

ActionStartConversation(GetFirstPC(),"guardtalk"); //this line has nothing to do with your script, by the way...

}

Link to comment
Share on other sites

  • 5 months later...

//Feel free to use this script in any mod

//Feel free to modify this script but please ask me before / if you distribute it.

 

#include "k_inc_generic"

#include "k_inc_utility"

#include "populate"

 

 

int RandomInt(int iMax=1, int iMin=0) //Created by bead-v. Thank You

{

int Malo = iMin;

if(iMin>iMax) Malo=iMax;

int iRandom = Malo + Random(abs(iMax-iMin));

return iRandom;

}

 

 

void Populate(int Amount, int xMin, int xMax, int yMin, int yMax, string Tag)

{

 

 

int AutoInc = 0;

 

while(AutoInc<Amount)

{

AutoInc++;

 

int x = RandomInt(xMax, xMin);

int y = RandomInt(yMax, yMin);

float z = 0.0;

int Orient = Random(360);

 

float x1 = IntToFloat(x);

float y1 = IntToFloat(y);

float Orient1 = IntToFloat(Orient);

 

object NPC = CreateObject(OBJECT_TYPE_CREATURE, Tag, Location(Vector(x1,y1,z), Orient1));

 

 

 

}

}

 

 

//Created by TimBob12

 

I really dont get it. So where do i replace my coordinates, xmin, ymin ect. Do i replace those with my coordinates. And for amount do i put the amount of people i want to spawn and copy it over amount? Where else do i have to put numbers :( im lost but i need this or ill be mapping nearly 100 people!!!!!!!

Link to comment
Share on other sites

  • 1 month later...

I've tried doing this with multiple populate lines:

Populate(5, 6, 9, 12, 15, Tag1);
Populate(7, 5, 12, 14, 19, Tag2);

 

And put the script in the OnEnter function. Whenever I try to use it, the game crashes. I'm guessing that this is due to the amount of processing power it uses, so is there a better way to do this?

Link to comment
Share on other sites

  • 8 months later...

I tried using the populate function without success... but, looking at the populate.nss script, I figured out why. I was using an Obsidian UTC, which meant that the tag and template were different. So, when I specified the UTC's tag instead of its template the creature would never spawn, because the CreateObject function used within populate.nss' code requires the template of a creature to spawn it. So the example was a bit misleading, but, still an excellent function.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...