Where can I find ALL obj_data offsets?

Discussion in 'Fallout General Modding' started by Zorchar, Aug 26, 2021.

  1. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
    Hi, guys.

    I wanted to post this question on sfall's github, but I'm not sure that's even a thing :)

    I know you can find these offsets for set_object_data in define_extra.h:
    Code:
    // common object data offsets
    #define OBJ_DATA_ID                 (0x00)
    #define OBJ_DATA_TILENUM            (0x04)
    #define OBJ_DATA_CUR_FRM            (0x18) // current frame number
    #define OBJ_DATA_ROTATION           (0x1C)
    #define OBJ_DATA_FID                (0x20)
    #define OBJ_DATA_ELEVATION          (0x28)
    #define OBJ_DATA_PID                (0x64)
    #define OBJ_DATA_CID                (0x68) // combat ID, used for savegame
    #define OBJ_DATA_SID                (0x78) // script ID
    #define OBJ_DATA_SCRIPT_INDEX       (0x80) // script index number in scripts.lst
    // items
    #define OBJ_DATA_CUR_CHARGES        (0x3C) // for key items it's the key code
    // critters
    #define OBJ_DATA_COMBAT_STATE       (0x3C) // flags: 1 - combat, 2 - target is out of range, 4 - flee
    #define OBJ_DATA_CUR_ACTION_POINT   (0x40)
    #define OBJ_DATA_DAMAGE_LAST_TURN   (0x48)
    #define OBJ_DATA_WHO_HIT_ME         (0x54) // current target of the critter
    
    My question is: Where can I find more offsets?
    More specifically, is there an offset which can make a unique ID weapon unusable(making it have 0 ammo capacity, changing type, active status)?

    To be clear, I don't want to use proto_data. Only object_data.
     
  2. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
  3. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
    Thanks. I had a feeling you would be first to help me out:)

    Unfortunately, I didn't manage to find any other offsets, besides this one, which is said to be unused:
    Code:
    long unused[8]; // offset 0x44
    
    However, right above this line there's another line that might be useful for me, yet no offset is mentioned
    Code:
    // current type of ammo loaded in magazine
    long ammoPid;
    
    Can you give me an example of an offset mentioned in the link above? I don't seem to understand where to find them.
     
  4. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
    Take the first few as an example:
    Code:
    // common object data offsets
    #define OBJ_DATA_ID                 (0x00)
    #define OBJ_DATA_TILENUM            (0x04)
    #define OBJ_DATA_CUR_FRM            (0x18) // current frame number
    #define OBJ_DATA_ROTATION           (0x1C)
    #define OBJ_DATA_FID                (0x20)
    #define OBJ_DATA_ELEVATION          (0x28)
    
    And the GameObject structure:
    Code:
    struct GameObject {
       long id;
       long tile;
       long x;
       long y;
       long sx;
       long sy;
       long frm; // current frame
       long rotation;
       long artFid;
       long flags;
       long elevation;
    ...
    
    Offsets start from 0 (0x00), so you get OBJ_DATA_ID from the first "long id".
    Each "long" data type is 4 bytes in size, so the next "long tile" (OBJ_DATA_TILENUM) is at offset 0x04.
    Check documents about structures and unions in C++ for details if you can't figure out the rest.
     
  5. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
    Ok
    Okay, I think I got it. The ammopid offset should therefore be 0x40, since the long before that is "charges" which is offser 0x3c, right?

    As far as I can tell, this is the only extra offset that is given in relation to items in this document, which is not mentioned in define_extra.h.

    However, I have another sort of related question. I'll understand if the answer will be "Check documents about structures and unions in C++ for details", but I want to make sure first:).

    This code:
    Code:
    struct ItemButtonItem {
    GameObject* item;
    union {
    long flags;
    struct {
    char cantUse;
    char itsWeapon;
    ...
    
    says something about "item" and "cantuse" which I think can be very helpful to me.
    How can I set this kind of data? Is there a command in ssl like "set_object_data" or something?
     
  6. NovaRain

    NovaRain Casual Modder Modder

    Mar 10, 2007
  7. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
  8. Velizar

    Velizar First time out of the vault

    28
    Jul 17, 2019
    I don't know exactly how to do this in SSL, but I do know that in the ProtoManager, this is a boolean in FlagsExt, which is a bit set.

    upload_2021-8-26_22-19-33.png

    It's possible that there is an analogous "flags" field in SSL which is also a set of bits.
     
  9. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018

    Thanks for replying.

    These flage are proto flags. So, are you saying I should find "something similar" in regards to object flags?
    TBH, I didn't quite understand what you mean. Probably because I lack the necessary knowledge.
    Also, what do you mean by "this" in this is a boolean in flags-ext. Is it the bit that decides if the item is usable or not?

    If you could perhaps explain differently, it would be awesome.
     
  10. Velizar

    Velizar First time out of the vault

    28
    Jul 17, 2019
    The "Use" checkbox is what you're trying to toggle programmatically, right?
    upload_2021-8-26_22-43-5.png

    In .pro files, this is stored as a single bit which is in flags_ext.
    I'm saying that hopefully there are equivalent flags in SSL too, defined as a constant in a header, and they might be a bitset too.
    I'll see if I can find it


    Edit: Sorry my bad - I just read your original post, and it looks like I misunderstood! What I posted wasn't about weapons at all. For weapons there's another solution.
     
    Last edited: Aug 26, 2021
  11. Velizar

    Velizar First time out of the vault

    28
    Jul 17, 2019
    This works on a proto: get_proto_data(pid, PROTO_WP_MAG_SIZE)
    So... does the following code work for your purposes: set_object_data(uid, PROTO_WP_MAG_SIZE, 0)
     
  12. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
    Thanks for explaining, got it.

    Unfortunately, it doesn't work.

    I'm starting to think the only solution, other than changing the proto itself, is to change the worn/wielded status of the object, and forcing the item to unwield itself. This is because I assume that objects only have data that isn't relevant for the proto itself. So tile, current ammo, wielded/worn etc'.

    EDIT: Unless, of course, I oould find out how to make the item slot itself not show the firing options. If that is even possible at the moment. (Same as you don't have the reload option if magazine is full.)
     
    Last edited: Aug 26, 2021
  13. Velizar

    Velizar First time out of the vault

    28
    Jul 17, 2019
    I have another idea: in your original post, we see that this field exists
    #define OBJ_DATA_PID (0x64)
    So, you could change the object's PID to a PID which is a broken version of the gun.
    Alternatively, remove the object and then add an object with the other PID in the inventory to achieve the same result.

    That would be straightforward if you only had one or two weapons which have this effect of becoming unusable. If instead you want to have it on many guns, then maybe you can also add the new proto dynamically? Though I don't remember right now whether sfall had that functionality.
     
  14. Zorchar

    Zorchar Still Mildly Glowing

    289
    Jun 18, 2018
    Thanks for the suggestions. That was my thought process exactly. I want to save me the strenuous work of adding many protos, so adding them one by one is a last resort. Plus, the dynamic way of changing the object can be a standalone mod, which adds tons of compatability with other mods.
    Also, protos can't currently be created dynamically (I got that information from Mr. Stalin when asking about an item weight mod.)

    I might try to add a generic broken weapon proto, replacing the broken weapon with it(while the weapon "breaks" in-game), making it a unique ID object, and changing the msg and frm according to which weapon was broken etc'.
     
    Last edited: Aug 28, 2021