Writing a script to spawn multiple NPCS

4 posts in this topic

Hey everyone!


Those that know me will know I'm currently in the midst of my final entry in my K2 adaption series, and for a specific scene I'm looking into spawning multiple NPCs in one location. I'll let these pictures explain...






As you can see from the images, I have multiple NPCs planned to be in this scene. The Mandalorians can be of any colour and the Republic soldiers would preferably be a mixture of race, rank, gender, etc. However, if spawning multiple duplicates of the Republic Soldier with the helmet is easy, I'd be happy with that. Two of Talia's guards (not the masked Vaklu version) are also required to be at the front either side of the walkway up to the throne area.


I'm at a complete loss at where to begin with this process, as I am fairly new to scripting and most of my knowledge consists of writing animation scripts to fire on party members. I have briefly dabbled in spawning NPCs, but not to this scale. I am unsure as to whether this would be a fairly straight-forward procedure, or whether creating a clone of the Royal Palace module would be the best way to go about it.


Any advice/help would be greatly appreciated!

Share this post

Link to post
Share on other sites

I'm not the best suited to answer your question, but since it hasn't been directly addressed, I thought I would give what advice I have. 


Yes, I would make a copy of the module and edit it from there, depending upon how much you wanted to change that scene. If you wanted to trigger different scripts and have the scene play out with different movements at different times with newly added extra NPCs, then I would make a copy, but if you are just changing/adding a few units and keeping the overrall scene in tact, then it wouldn't be beneficial to create a copy. 


Either way, I would extract the all of the 506OND_s.rim files and all of the 506OND.rim. 


You can go into the 506.GIT file and use the KGFF editor to change the CREATURES list within the module.

You can open the appearance.2da file within kotor tool, then change appearance number within the Creatues list to match that new appearance. Knowing the 2da appearance numbers for the NPCs is very helpful!


Now you've reskinned old NPCs, then you can use the extracted .UTC files from the _s.rim folder to change the weapons they have equipped. 


Remember you have to use the Kotor TOol ERF function to put all of the edited files and whatever unedited files you need/want back inside, then output that as a .MOD file and throw it in the Modules Folder of K2, and warp to that location to test. 




You can also add creatures to the CREATURES list of the GIT file, to add those extra NPCs.


Here's what I do to find those coordinates in game. I take screenshots. 

I'll go to that area, use the whereami armband (you can find that in the downloads section), then take a screenshot of those coordinates. This trick can be helpful for scripting units into place as well. Additionally, you could just write it out by hand.

  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now