Scripting questions: reading and writing data; data types

Freeform discussion about anything related to modding Transcendence.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Karl wrote:1. Are there any general functions for reading and writing information to items and classes of items?
Unfortunately, this is very difficult right now. The item type definitions (which are expressed as XML in the source files) are loaded into much more efficient C++ structures at the beginning of the game. Furthermore, those C++ structures have no set methods (since they are only initialized from XML) and have no capability for saving themselves. That means that even if you could change any of the structures, they would lose all the changes across a game save/restore.

The only parts of an item that are mutable are the parts that are associated with an item instance:

A pointer to the item type
16-bits for a count (the number of items)
8-bits for flags (damaged is the only flag implemented)
8-bits for install location (forward armor, rear armor, etc.)
8-bits for charges (for credit cards, disposable missile launcher, etc)
16-bits for enhancements (effect of barrels, crystals, etc.)

I believe there are functions to get/set all of these fields (although they may not be very consistent).

Short term, you might experiment with (shpEnhanceItem). I'll post a separate message with documentation.
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Very interesting. So right now item modification is limited to a fixed-width 16-bit field accessed by shpEnhanceItem, and changing that system would require alot of work... so there better be a damn good reason to do so.

This does mean that any fancier methods of item modification are pretty much out unless they can be worked into the current system... or a really, REALLY compelling reason given to change the system. :twisted:

p.s. And I can see why the data structure is so compact and why there'd be a hesitation to store more data in an item instance: since the game has to keep track of hundreds, even thousands of item instances, any increase in the size of an item instance would mean a significant increase in the amount of memory the game uses and a jump in the size of saved game files.
~
[Grabs a box of batteries.] The power is mine! MINE! Ah hahaha! AHHHH HAHAHA!
Post Reply