Scripting Tip: the power of ExecuteScript command
Using the ExecuteScript command I have found that you can easily modify almost any script, regardless if there is any source script available. Now, this will not let you directly modify the main script but you can adjust the script indirectly. This is especially useful when you want to add your own scripts to the original ones without changing the original script.
To demonstrate how it is done I will change one of my favorite mods: Redhawke's awesome Weebul's Jawa shop. In the original mod the jawa and sign post are created when you talk to the Czerka mechanic. A cool idea, but I thought it did not flow smoothly - the shop just appeared out of nowhere. Now Redhawke could have just changed the .mod file, but there are a number of issues with this, so adding a custom NPC is best done by script. However, I want this mod to be in effect as soon as I enter the area. I do not want to have to talk to someone to create it.
For the purpose of this walk through I am assuming you have already downloaded and installed Redhawke's Mod. Once you have installed the mod you should delete the Czerka Mechanic dialog file(tat17_05mecha_01.dlg) from your overrides, because it will no longer be necessary.
Every module has a script that runs every time you enter a area. It is called the On Enter script. It is how Bioware spawns in the various messengers in the game, such as Xor, Bandon and Calo Nord. In the case of Redhawke's Mod the On Enter script is k_ptat17_enter.ncs. Unfortunately, their is no uncompiled script(the nss file) available and it is a big file so modifying it directly is just about impossible. Or is it? I am going to show just how easy it is to add Redhawke's shop using the On Enter script while keeping the original Bioware script intact.
The first thing you have to do is rename the original script ncs file. Using Kotor Tool you need to extract k_ptat17_enter.ncs to your overrides directory and then rename it using Windows Explorer. I choose to use the name k_ptat17_enter2.ncs, but you could call it whatever you want just make sure it ends in .ncs. Now go create your own script - one that spawns a new NPC, waypoint, door or whatever you want to do. Since I am using Redhawke's mod this part is already done - he used the script rhshopspawn.ncs to add the shop. Next, you need to create one more script to tie your custom script in with the original one. Here is the script I am going to use(make sure you pay attention to the comments!):
To improve compatability the k_ptat17_enter script should only contain the two ExecuteScript commands, and you should do the checks in the "rhspawn" script. This way if you wanted to merge your mod with another mod that uses the same On Enter script all you would have to do is copy over the Execute Script command from the other mod into yours.
You could also run a standard Bioware script first and then execute your own script - this way your own script could modify the effect of the original script. I think this is a pretty easy way to mod those scripts where there is no source code available. I just wanted to share this handy command with everyone because I think there are a number of places this would be very useful.
|All times are GMT -4. The time now is 03:25 AM.|
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
LFNetwork, LLC ©2002-2011 - All rights reserved.