TimBob12 Posted April 2, 2011 Share Posted April 2, 2011 Populate Function 2.81 - STABLE AND WORKING Available from same download link 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 #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. 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. Screenshots Show spoiler (hidden content - requires Javascript to show) Show spoiler (hidden content - requires Javascript to show) Show spoiler (hidden content - requires Javascript to show) Show spoiler (hidden content - requires Javascript to show) Download Link - http://deadlystream.com/forum/files/file/45-populate-function/ Link to comment Share on other sites More sharing options...
newbiemodder Posted April 2, 2011 Share Posted April 2, 2011 Great jobe TB....you put a lot of effort into creating this...thanks to all his helpers too. Link to comment Share on other sites More sharing options...
logan23 Posted April 2, 2011 Share Posted April 2, 2011 Awesome! pure awesome! 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. Thanks again for building this. Link to comment Share on other sites More sharing options...
harark1 Posted April 2, 2011 Share Posted April 2, 2011 Thanks will help so much. Link to comment Share on other sites More sharing options...
JediExile Posted April 2, 2011 Share Posted April 2, 2011 VERY cool idea, TB! Thank you for sharing, this will help so much. Link to comment Share on other sites More sharing options...
Viado Onasi Posted April 2, 2011 Share Posted April 2, 2011 very cool! Link to comment Share on other sites More sharing options...
Canderis Posted April 5, 2011 Share Posted April 5, 2011 THANK YOU. This is going to be so helpful! Link to comment Share on other sites More sharing options...
Lord of Hunger Posted April 5, 2011 Share Posted April 5, 2011 This is going to be one of the best modding tools ever made. Thank you TimBob for revolutionizing KOTOR modding! Link to comment Share on other sites More sharing options...
harark1 Posted April 6, 2011 Share Posted April 6, 2011 AHHH! Script won't work. Need help. Link to comment Share on other sites More sharing options...
TimBob12 Posted April 6, 2011 Author Share Posted April 6, 2011 What doesnt work? Link to comment Share on other sites More sharing options...
harark1 Posted April 6, 2011 Share Posted April 6, 2011 OK I followed the example script to create my own but every time I try to compile it kotor tool finds probelms with the populate.nss script. (17) error: syntax error at "bool" (23) error: syntax error at "while" (38) error: syntax error at "if" Also here is a copy of my script if you see anything ovisouly wrong please point it out. #include "populate" void main() { Tag = "n_com1 ; Populate(10, 32.88562, 53.56025, -39.01687, 22.53749,Tag , TRUE); } Link to comment Share on other sites More sharing options...
TimBob12 Posted April 7, 2011 Author Share Posted April 7, 2011 There are a couple of things wrong with your script. One isn't your fault. #include "populate" void main() { Tag = "n_com1" ; //YOU FORGOT THE SECOND QUOTATION HERE Populate(10, 33, 54, -39, 23,Tag , TRUE); } For the random number generation to work the numbers you put in have to be integers ie no decimals. I forgot to mention that. also you can use the code tags for declaring code. Link to comment Share on other sites More sharing options...
harark1 Posted April 9, 2011 Share Posted April 9, 2011 Ah that explains it. trying again. Edit: Yeah it is still reading the probelms with your populate script. My script works now but that still isn't. Link to comment Share on other sites More sharing options...
TimBob12 Posted April 9, 2011 Author Share Posted April 9, 2011 Can you post your new script again and the populate script that you downloaded in case I distributed the wrong one(That would be imbarrasing) Link to comment Share on other sites More sharing options...
harark1 Posted April 10, 2011 Share Posted April 10, 2011 My script: #include "populate" void main() { Tag = "n_com1" ; Populate(10, 32, 53, -39, 22,Tag , TRUE); } Your Script: //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); 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)); if(Walk == TRUE) { AssignCommand(NPC, ActionRandomWalk()); } } } //Created by TimBob12 Link to comment Share on other sites More sharing options...
TimBob12 Posted April 11, 2011 Author Share Posted April 11, 2011 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 AssignCommand(NPC, ActionRandomWalk()); with a // before the line. Waiting for new version to be reviewed at deadly stream. Will be on same download link. Link to comment Share on other sites More sharing options...
TimBob12 Posted April 13, 2011 Author Share Posted April 13, 2011 Version 2.81 available to download now from the same download link. It is a stable and working version. Link to comment Share on other sites More sharing options...
Nick Vader Posted May 3, 2011 Share Posted May 3, 2011 This really is top notch. Now modules seem to fly past as they're done superfast. A major "thank you" for this utility man. Link to comment Share on other sites More sharing options...
TimBob12 Posted May 4, 2011 Author Share Posted May 4, 2011 Im just glad people can make use of it Link to comment Share on other sites More sharing options...
newbiemodder Posted May 14, 2011 Share Posted May 14, 2011 TB - How do I modify your example script 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. Link to comment Share on other sites More sharing options...
harark1 Posted May 14, 2011 Share Posted May 14, 2011 I just copied the line multiple times and input a different npc tag in each line. Link to comment Share on other sites More sharing options...
newbiemodder Posted May 14, 2011 Share Posted May 14, 2011 I tried that but I get errors..."tag" defined multiple times in the same scope..... I even tried with a simpler one creature tag spawn in a smaller area...script compiles but nothing spawned. Link to comment Share on other sites More sharing options...
TimBob12 Posted May 15, 2011 Author Share Posted May 15, 2011 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. Link to comment Share on other sites More sharing options...
newbiemodder Posted May 15, 2011 Share Posted May 15, 2011 yeah, 5 should do it I think....thanks....take your time Link to comment Share on other sites More sharing options...
harark1 Posted May 16, 2011 Share Posted May 16, 2011 Here is how I did my script. I was able to fill an entire module of 7 different charcter types(I think 7). #include "populate" void main() { Populate(2, 32, 53, -39, 22, "n_com1"); Populate(2, 32, 53, -39, 22, "n_com"); Populate(3, 32, 53, -39, 22, "n_com2"); Populate(2, 32, 53, -39, 22, "n_com7"); Populate(1, 32, 53, -39, 22, "n_com3"); Populate(3, 32, 53, -39, 22, "n_com4"); Populate(3, 32, 53, -39, 22, "n_com5"); Populate(3, 32, 53, -39, 22, "n_com6"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.