Author Topic: Retrieving a struct from an object  (Read 369 times)

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Retrieving a struct from an object
« on: August 30, 2011, 06:25:27 pm »


                 I'm curious if this can even be done.

  Essentially, I want to be able to retrieve the data stored in the CombatInfo struct on the PC.

   A simple way to retrieve things like base AB modifier would be extremely useful for certain things, like a properly calculated disarm check.
 
  An ability to write directly to the struct would be even better. but just read access to it would be a nice start.

  Does anyone know of a way to go about this?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #1 on: August 30, 2011, 06:55:44 pm »


               How is the data that populates the struct stored? In my understanding, you can not store a struct on an object, but rather you have to store all the pieces as ints, floats, strings, or objects. If I am wrong I would be very happy to hear it. Once you load this data into the struct however it is easy to return the struct entire from a function.

So as to your question I assume that it is this particular struct you are trying to access. To do so I think you need to find the functions buried in the scripts that were written to organize the struct in the first place. As to that I don't know where they are.

You could however create your own version of the same struct, and write your own custom functions to populate it.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #2 on: August 30, 2011, 07:08:25 pm »


               

henesua wrote...

How is the data that populates the struct stored? In my understanding, you can not store a struct on an object, but rather you have to store all the pieces as ints, floats, strings, or objects. If I am wrong I would be very happy to hear it. Once you load this data into the struct however it is easy to return the struct entire from a function.


It's not on the object so much as it is on the bic save character file.  I have no clue on how to access it.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #3 on: August 30, 2011, 07:30:30 pm »


               The numbers stored in that struct in the bic seem to be the ones displayed on the character sheet, which would mean they're stored somewhere the engine can rapidly access them.

 I suppose someone might be able to trace the functions that run when the character is initially loaded to find what reads them, and where they're stored, but that's well beyond what I know how to do.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #4 on: August 30, 2011, 07:34:39 pm »


               Why not just make your own struct and set of functions? Is there any data that you are unable to access? It seems to me that with regards to PC stats every one is accessible by standard functions. You could pull all this off and fill your own struct. Additional modifiers can be determined by a sweep through PC feats correct?

Or am I missing the point in that you didn't want to have to recreate the wheel?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #5 on: August 30, 2011, 07:58:34 pm »


               Checking an existing int is almost always going to be more efficient than recalculating what went into it to begin with.

 It's a similar issue with things like GetMetamagicFeat().  It's data either stored on the PC, or on the module but in a way directly referencing the PC.  A way to access and manipulate these "hidden" data types would open up a huge number of scripting possibilities.
               
               

               
            

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Retrieving a struct from an object
« Reply #6 on: August 31, 2011, 09:05:15 am »


               Check the list of functions in nwnx_funcs. Only NWNX can access this data, so if there are such functions, they'll be in nwnx_funcs.