Giter Club home page Giter Club logo

Comments (7)

jjsat avatar jjsat commented on August 30, 2024

This is broken with original engine too, starting with 2.70. The verb interface is unusable on >= 2.70 but you can bring up an alternate inventory with the TAB key to reproduce the bug.

from ags.

jjsat avatar jjsat commented on August 30, 2024

When a character passes an inventory object the game first adds the inventory item to the new character. This is not done with a function call but with directly writing to game.chars[x].inv[y]. This works fine, but the new engine also has an option to sort the inventory window which is handled in the charextras struct. Apparently the old game.chars.inv indicates whether a character has an item but charextras handles whether the item is shown in the inventory. Because it is never updated in this game, it doesn't show the new item.

I don't know how to fix this in a general way. Due to the way this game is written a call to update_invorder() in Character_LoseInventory() seems to help here but in general this doesn't work.

from ags.

 avatar commented on August 30, 2024

@jjsat

This is not done with a function call but with directly writing to game.chars[x].inv[y]

After I rewrote script interpreter there's now a way to catch direct reads/writes to object members from script and remap them, or even call a function instead. We may experiment with this and see if this will help here.

from ags.

 avatar commented on August 30, 2024

The general idea is this. You override ReadInt16 and WriteInt16 virtual functions in CCCharacter class ("CharacterInfo::inv" array is type short), and put there something like:

void CCCharacter::WriteInt16(const char *address, intptr_t offset, int16_t val)
{
     if (offset >= A && offset < B )
     {
         SetInventoryItemCount ( (CharacterInfo*)address, (offset - A) >> 1 /* item id */, val /* new quantity*/  );
     }
     else
     {
         *(int16_t*)(address + offset) = val;
     }
 }

from ags.

jjsat avatar jjsat commented on August 30, 2024

Wow, very nice! This works for me. Calling Character_SetInventoryItemCount() does not update the inventory display and UpdateInventory() has to be called too.

    void WriteInt16(const char *address, intptr_t offset, int16_t val)
    {
        *(int16_t*)(address + offset) = val;

        const int invoffset = 112;//offsetof(CharacterInfo, inv);
        if (offset >= invoffset && offset < (invoffset + MAX_INV * sizeof(short)))
        {
            update_invorder();
        }
    }

from ags.

jjsat avatar jjsat commented on August 30, 2024

Should be fixed in commit 3e16b55.

from ags.

 avatar commented on August 30, 2024

This was fixed, alright, so - closing.

from ags.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.