Jump to content


SUPPORT TOPIC File Information

  • Submitted: Apr 02 2011 08:08 PM
  • Last Updated: Apr 13 2011 11:05 AM
  • File Size: 5.3MB
  • Views: 10768
  • Downloads: 607
  • Approved by: Hassat Hunter
  • Approved on: 13 April 2011 - 11:23 AM
  • TSLRCM Compatible: Yes

Download Populate Function 2.81

* * * * * 3 Votes

This script will allow you to easily populate an area using random number generation based on your specifications. It eliminates the need to find countless co-ordinates. You only need to find four co-ordinates to populate an area with as many NPCs as you like. (The engine really hates it if you go over 120). You can also choose whether to set them to walk randomly or not. You can use your own waypoints. I reccommend using this function in an on enter script.

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(0, 0, 0, 0, 0, Tag);
^ ^ ^ ^ ^ ^
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.

Use and distribution

Feel free to use this in any mod at all. If you wish to modify the script then feel free to but LEAVE THE RANDOM NUMBER GENERATION FUNCTION IN TACT. It was not created by me and is essential to the smooth running of the populate function. If you modify the script and want to distribute it then please contact me first through either Holowan Labs or Deadly Stream - TimBob12 or by email - timbothompson@gmail.com. If you do redistribute then you will be required to credit bead-v for the creation of the random number generation script.


There is an additional random generation script that was created by bead-v and, unlike the in game function, it supports negative numbers making it perfect for location generation.


The populate function and example script were created by me, TimBob12 and the random number generation script was created by bead-v. I'd also like to thank everyone who helped in the creation of this function specifically:

Darth Insidious
Varsity Puppet

A Final Note

I hope this eases your Module Creation and you enjoy using this.

What's New in Version 2.81 (See full changelog)

  • 2.81 Minor Bug Fix
  • 2.8 Removed the ability to set whether NPCs walk or not as it was causing issues. NPCs now walk randomly as default. Will add this feature when fixed.
  • 2.7 Added the ability to set whether NPC randomly walks or not.
  • 2.5 Fixed Random Walking


Screenshots Screenshots Screenshots

Just to say that the screenshots are of Shadows of the Empire which is still currently being worked on and is not availbale.
Apr 02 2011 08:38 PM
Definitely give this a try TB...should be a really useful tool.
Excellent idea, impressive work! I hope everyone working on expansions and total conversions takes advantage of this.
beautifull job...more interesting aport

beautifull job...more interesting aport

Do you mean a port for K1. It should work in K1 with no changes. Haven't tested it though.

Other files you may be interested in ..

Random Files

24 user(s) are online (in the past 15 minutes)

4 members, 19 guests, 1 anonymous users

SplashDMG, AndiCRIMSON, babido, N-DReW25