This Populate function allows you to get four co-ordinates and randomly spawn any number of NPCs. It was designed to ease the process of creating modules. All information is included in the README.
This saves you having to create individual entries in the .git file. I think this should save a lot of time in Total Conversion Mods as people do not have to spend a lot of time populating areas. A few versions of this function spawning different NPCs and its done.
The screenshots are from SOTE posted with permission from HarIII
Thank you to everyone that helped but especially:
Bead-V
Darth Insidious
Varsity Puppet
Installation and Use
You need to place the "populate.nss" script in your K2 Override. (This will probably work with K1 but I cannot confirm that). To use the function add the line
Code:
#include "populate"
at the beginning of your script.
Then you will need to lay an imaginary square over the area where you want to spawn in. Then find the co-ordinates of the four corners using D3's Whereami armband. Write down what you get and work out the smallest X value and the largest X Value and then do the same with the Y Co-ordinates. Then include this in the main function of your script.
Code:
Populate(Amount, xMin, xMax, yMin, yMax, Tag);
Amount = The number of NPCs of the specified tag to spawn.
xMin = The smallest X value
xMax = The largest X Value
yMin = The smallest Y Value
yMax = The largest Y Value
Tag = The tag of the NPC you want to spawn.
Edit: Oh with you want it to work for kotor1, i believe you have to compile the script in kotor1 option in kotortools.
If it does then it should then be ready for kotor1 use.
"Hey! You talk to her with a bit of respect in your voice or you'll end this conversation minus a few teeth! Got it?" -Carth Onasi
"Are you an angel? Aw, I'm just kidding. That's the worst line I've ever used. Hope some poor kid doesn't start using it." -Atton Rand
//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"
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, bool Walk)
{
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);
I have uploaded a new version without the choice of walking as it was causing issues. NPcs will now walk as DEFAULT. This can be changed by commenting out
Code:
AssignCommand(NPC, ActionRandomWalk());
with a // before the line.
Waiting for new version to be reviewed at deadly stream. Will be on same download link.
void main() {
string Tag = "ch_guard_1"; //Declare the tag of the NPC you want to spawn
Populate(20, -28, 21, 69, 121, Tag, TRUE); //This is the bit that does all the spawning
For multiple npc tags? I want to spawn 4-5 different npc's on the onenter script. I'm a scripting idiot and don't know the correct syntax.
Who's more foolish, the fool or the fool that follows?
Just exactly what is a head-piece to the Staff of Ra?
I will have to modify the script but I have a pretty good idea of how to do it and will have a look asap. I might be able to use random numbers. How many NPCs at a time do you think? 5? You'd be able to have 5 or less then.
Sorry for the late reply by the way. I have been away for the weekend and had no access to a computer other than my phone and I felt that I would not be able to give an adequate reply.
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
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.
I will be frankly honest... I haven't a clue why this is happening. Harak1 can you open up populate.nss in your overide and PM Me what it says please so I can make a few checks. Thanks.
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.
TimBob my characters seem to be spawning at random numbers, and I can't tell why! I used this script as my OnEnter script:
Quote:
#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...
}
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);
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!!!!!!!
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?