Forum rules - please read before posting.

Giving multiple inventory items only gives one -> 1.72.4

I've been told by my players a bug on last updated version, and I've been able to reproduce the bug:

unity 2019 3.15f1
AC 1.72.4

Previous actionlist that worked well, have stopped working (well).
When giving multiple items of the same type, it only gives one.

Iventory item type;: Can carry multiple (yes), place in various slots (yes)

If giving an specific quantity, for example 2, it gives one.
If I put the action two times to give 1, I can get 2.

In some previous versions worked well. ( I can't tell exactly last version that worked well, but quite sure in 1.71x worked well)

Comments

  • edited January 2021

    I would need more specific details of your settings.

    Can you share screenshots of the exact properties of a typical item, as well as the Action(s) that don't work?

  • I send you a pic via private message.

    I'm wondering if Slot Capacity has anything to do with it.

    I'm aware you changed some stuff about how Inventory worked (in fact there were very needed updates for me, like non interactable inventory boxes only to show items but allow to mouse over).

    In the past I also had some problems when Reducing count of numbers in more than one unit, But I didn't say nothing and just fix it removing one by one.

    But with this problem I have to go thru a lot of code to fix every instance of it.

  • Apologies for the trouble. Naturally, I'll address this bug - please let me know if encounter others so I can do the same there as well.

  • Recreated. This'll be addressed in the next release, but you should be able to fix it manually by opening ActionInventorySet.cs, and replacing its Run function with the following:

    public override float Run ()
    {
        if (KickStarter.runtimeInventory)
        {
            if (!setAmount)
            {
                amount = 1;
            }
    
            int _playerID = -1;
            if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow && !KickStarter.settingsManager.shareInventory && setPlayer)
            {
                _playerID = playerID;
            }
    
            switch (invAction)
            {
                case InvAction.Add:
                    InvItem linkedItem = KickStarter.inventoryManager.GetItem (invID);
                    if (linkedItem == null) return 0f;
    
                    int maxAmount = (linkedItem.canCarryMultiple) ? linkedItem.maxCount : -1;
                    if (setAmount && maxAmount > 0 && amount > maxAmount)
                    {
                        int localAmount = amount;
                        while (localAmount > maxAmount)
                        {
                            AddItem (_playerID, maxAmount);
                            localAmount -= maxAmount;
                        }
                        if (localAmount > 0)
                        {
                            AddItem (_playerID, localAmount);
                        }
                    }
                    else
                    {
                        AddItem (_playerID, amount);
                    }
                    break;
    
                case InvAction.Remove:
                    if (removeLast)
                    {
                        KickStarter.runtimeInventory.SetNull ();
                        KickStarter.runtimeInventory.PlayerInvCollection.Delete (KickStarter.runtimeInventory.LastSelectedInstance);
                    }
                    else
                    {
                        if (InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance) && KickStarter.runtimeInventory.SelectedInstance.ItemID == invID)
                        {
                            KickStarter.runtimeInventory.SetNull ();
                        }
    
                        if (_playerID >= 0)
                        {
                            if (setAmount)
                            {
                                KickStarter.runtimeInventory.RemoveFromOtherPlayer (invID, amount, _playerID);
                            }
                            else
                            {
                                KickStarter.runtimeInventory.RemoveFromOtherPlayer (invID, _playerID);
                            }
                        }
                        else
                        {
                            if (setAmount)
                            {
                                KickStarter.runtimeInventory.PlayerInvCollection.Delete (invID, amount);
                            }
                            else
                            {
                                KickStarter.runtimeInventory.PlayerInvCollection.DeleteAllOfType (invID);
                            }
                        }
                    }
                    break;
    
                case InvAction.Replace:
                    if (InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance) && KickStarter.runtimeInventory.SelectedInstance.ItemID == invIDReplace)
                    {
                        KickStarter.runtimeInventory.SetNull ();
                    }
                    KickStarter.runtimeInventory.Replace (invID, invIDReplace, amount);
                    break;
            }
        }
        return 0f;
    }
    
    private void AddItem (int _playerID, int _amount)
    {
        if (_playerID >= 0 && KickStarter.saveSystem.CurrentPlayerID != _playerID)
        {
            KickStarter.runtimeInventory.AddToOtherPlayer (new InvInstance (invID, _amount), _playerID, addToFront);
        }
        else
        {
            if (addToFront)
            {
                KickStarter.runtimeInventory.PlayerInvCollection.Insert (new InvInstance (invID, _amount), 0);
            }
            else
            {
                KickStarter.runtimeInventory.PlayerInvCollection.Add (new InvInstance (invID, _amount));
            }
        }
    }
    
  • Fixed, thanks.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.