lfnetwork.com mark read register faq members calendar

Thread: Request for help decompiling scripts
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 03-15-2006, 03:48 AM   #1
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
Request for help decompiling scripts

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!
Achilles is offline   you may: quote & reply,
Old 03-15-2006, 07:17 AM   #2
Tupac Amaru
Junior Member
 
Tupac Amaru's Avatar
 
Join Date: Mar 2005
Location: Tahuantinsuyu
Posts: 273
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:

Code:
if ((int11 = FindSubString(string1, "[") >= 0)) {
Replace it with:
Code:
if ((int11 = FindSubString(string1, "[")) >= 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.

Quote:
Originally Posted by Achilles
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).

Last edited by Tupac Amaru; 03-15-2006 at 09:23 AM.
Tupac Amaru is offline   you may: quote & reply,
Old 03-15-2006, 11:25 AM   #3
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
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!
Achilles is offline   you may: quote & reply,
Old 03-15-2006, 03:16 PM   #4
Tupac Amaru
Junior Member
 
Tupac Amaru's Avatar
 
Join Date: Mar 2005
Location: Tahuantinsuyu
Posts: 273
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.
Tupac Amaru is offline   you may: quote & reply,
Old 03-15-2006, 05:28 PM   #5
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
Quote:
Originally Posted by Tupac Amaru
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.
Achilles is offline   you may: quote & reply,
Old 03-15-2006, 09:48 PM   #6
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
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!
Achilles is offline   you may: quote & reply,
Old 03-16-2006, 08:06 AM   #7
Tupac Amaru
Junior Member
 
Tupac Amaru's Avatar
 
Join Date: Mar 2005
Location: Tahuantinsuyu
Posts: 273
Here's the source for all five scripts:

Code:
// 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);
}
Code:
// 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);
}
Code:
// 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();
}
Code:
// 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);
}
Code:
// 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:
Code:
                        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:
Code:
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.
Tupac Amaru is offline   you may: quote & reply,
Old 03-16-2006, 12:05 PM   #8
Achilles
Dapper Chimp
 
Achilles's Avatar
 
Join Date: May 2004
Posts: 8,204
Helpful! Veteran Modder Forum Veteran 
Wow, that was very kind of you. Thanks again for all your help!
Achilles is offline   you may: quote & reply,
Old 03-16-2006, 12:29 PM   #9
stoffe
Mostly dormant
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,834
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Tupac Amaru
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 ).


mt
stoffe is offline   you may: quote & reply,
Old 03-16-2006, 02:53 PM   #10
Tupac Amaru
Junior Member
 
Tupac Amaru's Avatar
 
Join Date: Mar 2005
Location: Tahuantinsuyu
Posts: 273
Quote:
Originally Posted by stoffe -mkb-
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.
Tupac Amaru is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Request for help decompiling scripts

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:29 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.