Jump to content

patching .STO files to accept more item types


Recommended Posts

I have a bit of hackneyed code that was donated, and then adapted, and TBH I'm not really sure how it works. Apparently, it is messing up various .STO files from various old "mega" mods like TDD, RoT, etc. I have no idea what it is about those .STO files that makes them disagree with this code, and I have no idea what this code is doing to mess them up.


So, I think it's finally time to reach out for some help. The goal here is, for any store that buys weapons, expand the list of purchased items to include bastard swords (type = 69), greatswords (type = 57), and clubs (type = 44).


Here is the code at the moment. Can anyone spot what's wrong with it? Or a better way to achieve this?


COPY_EXISTING_REGEXP    ~.*\.sto~    override
    READ_SHORT    0x8    type
    READ_LONG    0x2c    buy_off
    READ_LONG    0x30    buy_num
    SET    buy_add = 0    //    Number of categories to add, to update offsets
    SET    add_category = 0    //    Initialize check variable
    FOR    (i = 0; i < 3; ++i)    BEGIN    SET $add_category(~%i%~) = 1    END    //    Initialize check variable
    FOR    (i = 0; i < buy_num; ++i)    BEGIN
        READ_BYTE    (buy_off + i * 0x4)    category
        PATCH_MATCH    category WITH
            15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 WHEN add_category = 0    BEGIN    // Match any Weapon Categories
            69    BEGIN    //    Match Bastard Sword Category / No Unnecessary Duplication
                SET add_category_0 = 0
            57    BEGIN    //    Match Greatsword Category / No Unnecessary Duplication
                SET add_category_1 = 0
            44    BEGIN    //    Match Club Category / No Unnecessary Duplication
                SET add_category_2 = 0
    //    Add categories
    PATCH_IF    add_category    BEGIN
        PATCH_IF    add_category_0    BEGIN
            INSERT_BYTES    (buy_off + buy_num * 0x4)    0x4
            WRITE_BYTE    (buy_off + buy_num * 0x4)    69
        PATCH_IF    add_category_1    BEGIN
            INSERT_BYTES    (buy_off + buy_num * 0x4)    0x4
            WRITE_BYTE    (buy_off + buy_num * 0x4)    57
        PATCH_IF    add_category_2    BEGIN    
            INSERT_BYTES    (buy_off + buy_num * 0x4)    0x4
            WRITE_BYTE    (buy_off + buy_num * 0x4)    44
        //    Update offsets
        WRITE_LONG    0x30    (THIS + buy_add)
        READ_LONG    0x34    items_off
        PATCH_IF    items_off >= buy_off    BEGIN    
            WRITE_LONG    0x34    (THIS + buy_add)
        READ_LONG    0x4c    drink_off
        PATCH_IF    drink_off >= buy_off    BEGIN
            WRITE_LONG    0x4c    (THIS + buy_add)
        READ_LONG    0x70    cures_off
        PATCH_IF    cures_off >= buy_off    BEGIN
            WRITE_LONG    0x70    (THIS + buy_add)
Link to comment

I believe these three lines like this at the end:

WRITE_LONG    0x34    (THIS + buy_add)

should be

WRITE_LONG    0x34    (THIS + (buy_add * 0x04))

buy_add is the number of categories it has added, and each one pushes the other offsets back by 0x04.


Tweaks has code that lets you do it via array, if you'd like an alternative.

Link to comment

I have seen the effect of this code in many stores in my EET install as well, not only old mega mods but also newer versions of mods are affected. I saw it for Drittr Saga EET version, Grey Clan, the new TDDz, RoT, the new EET DSotSC, etc. It only affects some sto-files, not all added by those mods. The result is that those stores are empty and in NI all items to sell appear as Null. (some offset seems to be wrong)

I found the intact versions of the stores always in the backup folder of one of the mods in your signature, but I guess you know that already,

Edited by Roxanne
Link to comment

That looks like my fault, but CamDawg has the right answer. Looking it now, I'm surprised it wasn't causing me any problems, unless all vanilla store files just happen to have item types listed last.

This seems to be the source of it. Stores that have no issue with the tweak are those that have purchased item types last. The ones that get *shoplifted* are the ones that have the list of itmes to sell in the end.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...