logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
bic parsing/editting in C
Goto page 1, 2  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Tue Jan 25, 2005 11:36    Post subject: bic parsing/editting in C Reply with quote

This is the only app I know of that has done it Angelo Cossa's racial system. Does anyone have the source code for this project?

Would be redundant if someone is making a C* conversion of Red Golem's Java system (see Telstar's post here).

Would be interested in writing one if necessary, but not sure where to start. Can someone point me to a C* ITP parse/edit library?

Obvious uses would be to pull base values (abilities, skill ranks) directly from the bic. Can be done from NWNscript, but the best system I've come up with is to copy the object (player in my case), strip items and effects, then delay command whatever check code so that the copy's effects will update (and still not sure that I have all the feats that make changes that GetSkillRank() will include). That took maybe 20 hours of code and testing to make, but it's still an expensive way to do it and still requires tracking of selections by level persistently since there's no way to review the level history (track classes, figure out the new one on level up and same for stats and skills...getting less confident in my NWN code now, lol). Again, much easier just to go to the last entry in the level table and pull the data from there.

Somewhat easy to build a subrace system with a few basic editting functions (either pass commands to NWNx to perform or pull character mod templates from another file and apply them). Or make your own leveling system...

Of course after 2 years of cursing the darkness, is it too late to light a candle?
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
Papillon
x-man


Joined: 28 Dec 2004
Posts: 1060
Location: Germany

PostPosted: Tue Jan 25, 2005 13:36    Post subject: Reply with quote

What about nwnx-leto ?
_________________
Papillon
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Tue Jan 25, 2005 14:38    Post subject: Reply with quote

With RCO/SCO for NWNx, it's becoming less attractive to have another app running in the chain of passing information/commands NWN-> NWNx-> LETO-Moneo/Unicorn and vice versa. Also think dragonsong said there's some commands that will break going from Moneo to his new language...but the interface is probably fast enough not to worry about.

OK, I'll start messing with NWNx-LETO then Laughing but would like to know if the source for any NWNx modules is available.
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
JeroenB



Joined: 31 Dec 2004
Posts: 228
Location: Netherlands

PostPosted: Tue Jan 25, 2005 16:38    Post subject: Reply with quote

Yes, all plugins for NWNX must be open source. That's because it is released under the GPL.
Back to top
View user's profile Send private message Visit poster's website
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Tue Jan 25, 2005 19:40    Post subject: Reply with quote

Sorry, meant the source for an NWNx module as described in the first post. Angelo didn't put the source in the package on NWVault Sad
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
Primogenitor



Joined: 08 Jan 2005
Posts: 88

PostPosted: Tue Jan 25, 2005 20:09    Post subject: Reply with quote

Id have to say Letoscript is the way to do it, but then I'm probably a bit biased as Ive used it for ages Very Happy One place to start if letoscript is looking too daunting is to pull my letoscript includes from the ConvoCC ( http://nwvault.ign.com/Files/scripts/data/1097822211000.shtml ) or from my script compilation ( http://nwvault.ign.com/Files/scripts/data/1089893598000.shtml ) The advantage if those is that you can do NWscript like:

StackedLetoscript(SetWings(3));
StackedLetoscript(AdjustAbility(ABILITY_DEXTERITY, 6));
RunStackedLetoscriptOnObject(oPC);

and it does the rest (booting the player, changing the bic, etc) for you. And then once you have letoscript, you can do all sorts of other things too. Change names for example Smile At the moment it is based of build 18 and Dragonsong will probably have an updated version soon (or sometime this year at least Wink ) but because its all in includes, Ill probably release an updated version and you can just swap one include for another.

DAR is the original subrace system that used letoscript, but thats broken since 1.64 when bioware stopped PCs having special abilities.

Oh, and one major problem with copying the PC is that the epic ability geats (e.g Great Strength X) are applied again to the copy. Damn bioware script bugs Rolling Eyes
Back to top
View user's profile Send private message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Tue Jan 25, 2005 21:52    Post subject: Reply with quote

I've been playing with modifying a char bic file as a plugin to add wings to a character. So far I have found it's not to hard to parse through the file to find the location of interest. In this case the wings value.

Currently, I'm stuck as I can't figure out why I can't write a new value to the wings entry in the file. Tracing through my code and looking at the file with a hex viewer I appear to be hitting the right location, but I can't get the plugin to actually write a new value. I can even change the value in the hex viewer that my code is trying to change, the character has wings in game. Just can't seem to get the code to do it.

And yes, I'm booting the charater off the server before I try to change the value. If someone would like to assist me in this I could write my plugin to be more general in what you want to read or change on a character bic file.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
dragonsong



Joined: 08 Jan 2005
Posts: 19
Location: Salinas, CA

PostPosted: Wed Jan 26, 2005 8:12    Post subject: Reply with quote

I've always been happy to assist others in their endeavors at writing a BIC engine, in whatever language. (Even helped write the foundation for a Perl engine once. That was a neat exercise. Smile )

I have some sagely advice to give, though: be prepared for a project of considerably proportions. Writing a simple GFF engine is one thing, but it gets real complex real quick. I'm flattered if others recommend Leto(Script) because they like it. If I'm going to recommend LetoScript myself, it's because I think it'll save most people the experience of tearing out most their hair and spending weeks and weeks developing a new engine from scratch. Very Happy

I know, I know, I should have written Leto in C. Sometimes I still think about it. For a few minutes.

Okay, pontificating aside.

Lokey: Unicorn will eventually supplant Moneo is every functional aspect. Perhaps the only thing that won't come over are the FPT functions, but those will be obsoleted by NWNX's SCORCO plugins. Build 23 (due this weekend) should mark a point where very, very few things you could do in Phoenix you still can't do in Unicorn. There are also now about 5 ways to do anything you could, before.

But tell me what you mean by "another app running" as far as the NWNx hook chain? The only thing really extra about NWNX-Leto is the C++ -> Delphi bridge, which means one extra DLL and very little overhead (proven). Or do you mean you're looking for a standalone app? (Moneo is?)

I want to accomodate you finding the best solution for your needs, and I can tell you if NWNX-Leto is not it, if you tell me exactly what you're trying to do. Smile

Xildjian: Do you know for sure your plugin is opening the file and editing it? (The file's last-modified changes?) Does the file get changed at all? Could you possibly build an offline version that you can use to test without NWNX? (Testing NWNX-Leto with a live running server was always such a pain in the rump that I developed an offline version of NWNX-Leto, even.)
_________________
- dragonsong
Back to top
View user's profile Send private message Visit poster's website
Lokey



Joined: 02 Jan 2005
Posts: 158

PostPosted: Wed Jan 26, 2005 9:57    Post subject: Reply with quote

Have Moneo and NWNx-LETO now and Alia for good measure Laughing That and I should probably worry less about CPU...bandwidth is the limiting factor for many things NWN, at least here at NS (when there's time use those Player/DM Client Apps that came with the toolset). You can have a few ms to make the impossible possible DS Wink

For now thinking player subraces and bic querying for base values. I've seen Primogenitor's posts on weathersong as well and should grab his PRC subrace implementation. See if I come up with something that could be vaguely useful. Next might be PnP polymorphing (i.e. possible to cast spells if you have hands and voice), and much cursing at Bioware for ripping out adding monster abilities to PCs probably.

Updated my versions of all things NWNx today (I was still in the dark ages of 2004) and have everything running nicely along with NWNx-LETO now, the above shouldn't take long to do for at least a proof of concept and be less hacky than my work-arounds in NWScript.

On the C side, there's a gff structure declared in one of Fast French's files (NWNxFF), but didn't follow too much where it was going (looking for something else, and comments in Francais are a hurdle for me).

-----

Xildjian, could you be assigning a data type that doesn't match the field? I.e. signed int when the field is defined as unsigned? Quick check in Alia: DS says it should be a byte as opposed to int.
_________________
Neversummer PW NWNx powered mayhem Wink
Back to top
View user's profile Send private message
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Wed Jan 26, 2005 15:33    Post subject: Reply with quote

dragonsong: Yea I can very easily see how playing with bic file can become an overwhellming experience. This is why I'm trying to keep the stuff I'm interested in pretty simple, and I define simple a just going in and changing a value that doesn't require having to load the entire file, recalculate all the offsets, and write the file out again. That's more time and effort I don't want to really put in.

So far my approach has been to use what I know about the bic format, I search for a specific label, find out what it's index is, then search the field section for the field that uses a lable at that index. Seems to be a nice quick simple way to search the file without having to load the entire file.

As for my current boggle: Yes, I'm pretty sure I'm opening the file and finding the correct location. Or at least debug info I print to a log file matches what I see in the file with a hex viewer. I haven't done anything outside of nwn as I have so far been successful doing things I game, but now might be a good time to try this approach.

As for the datatypes: The value I'm trying to write is defined as a UINT8 or unsigned char if you prefer primitives. I have even tried a UINT32 as the wings setting is defined within the context of their field structure which is as 32 bit area. (going off bioware's gff file format http://nwn.bioware.com/developers/) .

My current theory on what is happening is that the file is not getting opened as read/write in binary (r+b). And, I'm not sure how to test for this. My fwrite returns a 1 for 1 byte written tho. I know this is going to be something really simple I overlooked to be giving me this much trouble, it always is.

Would anyone object to taking a look at the code if I post the file? Maybe I've been looking at it for to long and just need another set of eyes.

Thanks for the help.
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
dragonsong



Joined: 08 Jan 2005
Posts: 19
Location: Salinas, CA

PostPosted: Thu Jan 27, 2005 17:39    Post subject: Reply with quote

Xildjian wrote:
So far my approach has been to use what I know about the bic format, I search for a specific label, find out what it's index is, then search the field section for the field that uses a lable at that index. Seems to be a nice quick simple way to search the file without having to load the entire file.


That's definitely the way to do it. Very Happy

Quote:
Would anyone object to taking a look at the code if I post the file? Maybe I've been looking at it for to long and just need another set of eyes.


I wouldn't even mind looking at it. (I need practice with C to update nwnx_leto.dll, anyhow. :p )
_________________
- dragonsong
Back to top
View user's profile Send private message Visit poster's website
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Fri Jan 28, 2005 5:19    Post subject: Reply with quote

dragonsong wrote:
I wouldn't even mind looking at it. (I need practice with C to update nwnx_leto.dll, anyhow. :p )

Sweet thanks!

I posted what I have so far at:
http://home.comcast.net/~xildjian/Wings.zip

I don't claim to be a code guru, only smarter than the average bear.
Hopefully I'll get a chance to play more this weekend, and get it working.
FYI I am running this on the current nwnx2 v2.6.1

Any feedback would be most appreciated Smile
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
dragonsong



Joined: 08 Jan 2005
Posts: 19
Location: Salinas, CA

PostPosted: Fri Jan 28, 2005 6:25    Post subject: Reply with quote

Code:

            if(strncmp(labels[cnt], "Wings", 9) == 0)


I think you meant 5. Very Happy
_________________
- dragonsong
Back to top
View user's profile Send private message Visit poster's website
Xildjian



Joined: 08 Jan 2005
Posts: 100

PostPosted: Fri Jan 28, 2005 15:33    Post subject: Reply with quote

dragonsong wrote:
Code:

            if(strncmp(labels[cnt], "Wings", 9) == 0)


I think you meant 5. Very Happy


Thanks I believe that was incorrect. However, that wasn't the smoking gun. My log still shows the exact same thing as before, so that change really didn't have any affect, but the code is more correct now tho so thanks! Smile
_________________
Member Shadow of Iniquity development team
Back to top
View user's profile Send private message
dragonsong



Joined: 08 Jan 2005
Posts: 19
Location: Salinas, CA

PostPosted: Fri Jan 28, 2005 16:53    Post subject: Reply with quote

Really...? Odd. Your log shouldn't have even been getting as far as "FieldWithWings: X" - and now it should. I did notice something else potentially dangerous:

Code:

                fwrite(&value, sizeof(UINT8), 1, fh);


Careful. You need to write out 4 bytes, because all Fields are 12 bytes long. So if the data represents a UINT8, you must store the data in such a variable, but when writing it, either cast or have fwrite ensure all of 32 bits get written.

The C way of handling this tricky aspect of GFF is a union. In Delphi, I use a type of record the simulates the same thing. But if you're only editing Wings, you don't need to worry about that yet. Smile

I don't have my C compiler on hand this week, but if we're still poking at this after the weekend, I'll compile and start looking at the hex, myself.
_________________
- dragonsong
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group