Achilles Posted March 15, 2006 Share Posted March 15, 2006 Hi all, I was hoping to prevail upon some of the resident scripting geniuses for a little help. I'm working with 5 scripts: k_fab_spawn01_sm.ncs = OnSpawn for the ritual leader in Dxun Tomb (411DXN) k_def_spawn01_ni.ncs = OnSpawn for Nihilus on the Ravager (852NIH) k_def_spawn01_si.ncs = OnSpawn for Sion in Trayus Academy (903MAL) k_def_light_si_h.ncs = OnSpawn for the Sith Lord on Sky Ramp (504OND) k_def_light_si_j.ncs = OnSpawn for the Sith Apprentices on Sky Ramp (504OND) I tried using the code provided by JdNoa, however in each of these cases DeNCS ran into problems so the code won't work (at least that's what the readme says...assuming that I'm reading it correctly). Looking at the code the applicaton was able to decipher, it looks like most of it is comprised of include files. I think I recognize k_inc_treas_k2, but the rest of it is beyond me. If I'm looking at it correctly, it would appear that I could probably take the code at the end and compile it using the include(s) to get it to work. Unfortunately, as I mentioned I don't know which includes to use (this is where the begging for help comes), and I don't know if it will actually work (guidance, pretty please?). To complicate matters even futher, the last two scripts listed (k_def_light_si_h.ncs & k_def_light_si_j.ncs) aren't included in the download provided by JdNoa and I DeNCS returns a failed message whenever I try. As for these two, I am submitting a blatant request for someone to decipher these for me (again with the pretty please). As for the 1st three I'm willing to try to figure it out on my own with some help, but if someone is willing to do those as well, I won't turn the offer down. Thanks in advance! Link to comment Share on other sites More sharing options...
Tupac Amaru Posted March 15, 2006 Share Posted March 15, 2006 Most of the time the compare errors from DeNCS are minor issues. A bracket of one code line in the file generated by DeNCS is misplaced. Find this line: if ((int11 = FindSubString(string1, "[") >= 0[color=Red])[/color]) { Replace it with: if ((int11 = FindSubString(string1, "[")[color=Red])[/color] >= 0) { and the scripts will compile to the same as the original. That was the problem with the three scripts in Jd's archive at least. Can't help with the two that are missing from the archive. Unfortunately, as I mentioned I don't know which includes to use (this is where the begging for help comes), and I don't know if it will actually work (guidance, pretty please?).In case you want to use include files for more readable code: The function that contained the troublesome line looks like PlaceCritterTreasure from k_inc_treas_k2. Other important include files for spawn scripts are k_inc_generic which also includes k_inc_gensupport and k_inc_walkways. Most of the subs from DeNCS seem to be GN_SetSpawnInCondition, GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ) - the empty function, easy to recognize, GN_SetListeningPatterns() and GN_WalkWayPoints(). To see if the script still equals the original, have nwnsscomp decompile your script and the original. Then compare the bytecodes with a text comparison tool (WinMerge or some other). Link to comment Share on other sites More sharing options...
Achilles Posted March 15, 2006 Author Share Posted March 15, 2006 Thanks for the reply. Unfortunately, your advice re: the bracket isn't going to work for all three. It looks like it's going to save the day for the Nihilus and Sion scripts, but I can't find that line in the Ritual Leader script. Any more ideas? I appreciate the help! Link to comment Share on other sites More sharing options...
Tupac Amaru Posted March 15, 2006 Share Posted March 15, 2006 That's weird. The line should be near the end of function sub2 in k_fab_spawn01_sm. Search the script for FindSubString. For the other two files, it is in sub6. Link to comment Share on other sites More sharing options...
Achilles Posted March 15, 2006 Author Share Posted March 15, 2006 Search the script for FindSubString.Yeah, I thought to try that too and it didn't work. I'll double check when I get home. I may have grabbed the wrong script or something when I tried it this morning. Link to comment Share on other sites More sharing options...
Achilles Posted March 16, 2006 Author Share Posted March 16, 2006 Tupac Amaru, You were right, I was looking at the wrong script. Looks like I'll be able to get the first three working thanks to you. I appreciate your help. As for the last two, would someone with the ability to decode this stuff be willing to take a look at them? Please and thank you in advance! Link to comment Share on other sites More sharing options...
Tupac Amaru Posted March 16, 2006 Share Posted March 16, 2006 Here's the source for all five scripts: // k_fab_spawn01_sm.nss in 411DXN #include "k_inc_generic" #include "k_inc_treas_sp" void main() { GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DEATH); PlaceCritterTreasure(OBJECT_SELF, 1, 244); GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); GN_WalkWayPoints(); SetLocalNumber(OBJECT_SELF, 11, 6); SetLocalBoolean(OBJECT_SELF, 60, TRUE); } // k_def_spawn01_ni.nss in 852NIH #include "k_inc_generic" #include "k_inc_treas_sp" void main() { GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED); GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DEATH); GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); SetLocalNumber(OBJECT_SELF, 11, 6); SetGlobalNumber("000_RareItemChance", 100); PlaceCritterTreasure(OBJECT_SELF, 1, 244); GN_WalkWayPoints(); SetNPCAIStyle(OBJECT_SELF, SW_FLAG_MALAK_AI_ON); } // k_def_spawn01_si.nss in 903MAL #include "k_inc_generic" #include "k_inc_treas_sp" void main() { GN_SetSpawnInCondition(SW_FLAG_EVENT_ON_DAMAGED); GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); SetLocalNumber(OBJECT_SELF, 11, 6); SetGlobalNumber("000_RareItemChance", 100); PlaceCritterTreasure(OBJECT_SELF, 2, 240); GN_WalkWayPoints(); } // k_def_light_si_h.nss in 504OND #include "k_inc_generic" #include "k_inc_treas_sp" void main() { SetGlobalNumber("000_RareItemChance", 100); PlaceTreasureJedi(OBJECT_SELF, Random(3)+1); GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); GN_WalkWayPoints(); SetLocalNumber(OBJECT_SELF, 11, 6); } // k_def_light_si_j.nss in 504OND #include "k_inc_generic" #include "k_inc_treas_sp" void main() { PlaceTreasureJedi(OBJECT_SELF, Random(4)-2); GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); GN_WalkWayPoints(); SetLocalNumber(OBJECT_SELF, 11, 6); } What is important here is that these scripts don't use the standard treasure include file k_inc_treas_k2. They use a slightly modified version I have named k_inc_treas_sp (sp for special, unimaginative as I am). Open k_inc_treas_k2.nss in Kotor Tool, go to the function GetTreasureSpecific and search for this code block: else { switch (nItemType) { case 141: nItemLevel = (nItemLevel - 3)/3; // no number 6 if(nItemLevel == 6) nItemLevel = 5; sItemLevel = IntToString(nItemLevel); if(nItemLevel < 10) sItemLevel = "0" + sItemLevel; break; case 142: nItemLevel = (nItemLevel - 3)/3; // no number 6 if(nItemLevel == 6) nItemLevel = 5; sItemLevel = IntToString(nItemLevel); if(nItemLevel < 10) sItemLevel = "0" + sItemLevel; break; case 143: nItemLevel = (nItemLevel - 3)/3; // no number 6 if(nItemLevel == 6) nItemLevel = 5; sItemLevel = IntToString(nItemLevel); if(nItemLevel < 10) sItemLevel = "0" + sItemLevel; break; In all three cases there is a comment "no number 6" followed by an if-statement: if(nItemLevel == 6) nItemLevel = 5; Simply remove that if-statement, save the modified file as k_inc_treas_sp.nss and compile the five spawn scripts with it. These cases 141-143 are used for getting a lightsabre as loot, I'd say. I have no idea why it was done this way or in which way it will behave differently than the normal treasure script. Link to comment Share on other sites More sharing options...
Achilles Posted March 16, 2006 Author Share Posted March 16, 2006 Wow, that was very kind of you. Thanks again for all your help! Link to comment Share on other sites More sharing options...
stoffe Posted March 16, 2006 Share Posted March 16, 2006 These cases 141-143 are used for getting a lightsabre as loot, I'd say. I have no idea why it was done this way or in which way it will behave differently than the normal treasure script. I have noticed this in a few other cases as well, where individual scripts have apparently been compiled with a k_inc_generic.nss include file that doesn't exactly match the one included in the game data, with a few statements missing here and there. My guess would be that they have just compiled that script before the game was finished, after which changes have been made to the include file and they have forgotten to recompile all scripts with the most recent include files. In this case it'd probably be safe to recompile the script with the released includes instead (though it's useful for comparison purposes to keep copies of the older versions of the includes around as well ). Link to comment Share on other sites More sharing options...
Tupac Amaru Posted March 16, 2006 Share Posted March 16, 2006 My guess would be that they have just compiled that script before the game was finished, after which changes have been made to the include file and they have forgotten to recompile all scripts with the most recent include files. In this case it'd probably be safe to recompile the script with the released includes instead (though it's useful for comparison purposes to keep copies of the older versions of the includes around as well ). That seems a likely explanation. The treasure include file these scripts currently use is bugged. The additional lines in k_inc_treas_k2 prevent you from getting lightsabre number 6 as loot for a good reason: There are no template files for #6. The incorrect include file was also used for one container in Vogga's treasure chamber. Make an unlucky roll and you won't get a lightsabre. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.