beancounter Posted October 1, 2004 Share Posted October 1, 2004 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!): void main() { // make sure the PC is the only one who can trigger this script // otherwise if you spawn a creature the system will get in a infinite loop // of creating new creatures! object oEntering = GetEnteringObject(); object JawaTest = GetObjectByTag("rh_jawa_69"); if (GetIsPC(oEntering)) { // Check if the Jawa Guard exists - if he does not then create him if (GetIsObjectValid(JawaTest) == FALSE) { ExecuteScript("rhshopspawn", OBJECT_SELF); } } // Now we need to launch the original script ExecuteScript("k_ptat17_enter2", OBJECT_SELF); } Save this script as the On Enter script - k_ptat17_enter.nss in your override directory. Next compile all of your scripts and you are done! When you enter the area the script will check and see if the Jawa exists - if he does the script will just run the standard Bioware script, if he does not then the script will run the rhspawn script and then run the standard Bioware script. 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. Link to comment Share on other sites More sharing options...
Darth333 Posted October 1, 2004 Share Posted October 1, 2004 Good to see you Beancounter! This is a quality post The Executescript function is indeed more than very useful. I am sure T7 will add it to his Do you want to mod SW-Kotor? Then start here sticky [ Darth333 uses force persuade on T7nowhere ] Link to comment Share on other sites More sharing options...
T7nowhere Posted October 1, 2004 Share Posted October 1, 2004 [Yes, I want to add this thread. wait what happend ofcourse I want to add this thread.] Yup the executescript is very handy, the first person I ever saw use it was Gameunlimited, and then shosey. Whose npc spwn script I used resently I really prefer this method over the script from being fired from the dialog. But that also has it's uses. This same method is also used in Holowan Plug-in to spawn the protical droid and the spawn the switch to enter shosey's Ebon Hawk Basement. Hey beancounter if you have anymore tips like this please post them Im sure many will find them helpfull. Link to comment Share on other sites More sharing options...
RedHawke Posted October 2, 2004 Share Posted October 2, 2004 Cool info to know beancounter. Just one thing, you 'mospelled' my name... that's RedHawke, with an 'e'! EDIT: beancounter I tried to compile that script and it give a syntax error at the second 'if' statement. Link to comment Share on other sites More sharing options...
T7nowhere Posted October 2, 2004 Share Posted October 2, 2004 Hmm. well coding still gives me a head ach but the script I used to spawn my little Bat Merchant was from Shosey's extreme pazzak Link to comment Share on other sites More sharing options...
RedHawke Posted October 2, 2004 Share Posted October 2, 2004 ^^^^ It gives me a headache too, maybe TK102 will fly in and save the day! Link to comment Share on other sites More sharing options...
beancounter Posted October 2, 2004 Author Share Posted October 2, 2004 Sorry about that everyone. I have edited my script in the original post - it does work now. And I fixed a couple of misspelling. That's what happens when I work all day in one computer language and then try to write a script for KOTOR - I mix up the syntax. Link to comment Share on other sites More sharing options...
tk102 Posted October 2, 2004 Share Posted October 2, 2004 Yeah, in C, those If statements like to have their conditionals enclosed by paranthesis. Also it's easy to mix up the assignment operator (=) with the equality comparison operator (==). And Beancounter, I like scripting posts, they make me happy. Link to comment Share on other sites More sharing options...
RedHawke Posted October 3, 2004 Share Posted October 3, 2004 ^^^^ Just tried it out beancounter, very nice! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.