Ammo Count Not Updating After Weapon Use

Nicky_g_

Member
Hello Sangemdoko!

I've created a custom drop ability that successfully takes an item (a golf ball in my case) and places it on the ground. The item is deducted from my inventory as expected. What doesn't work is that the Unloaded Count of the Slot Item Monitor of the Opsive.UltimateCharacterController.UI namespace doesn't update unless I change weapons or use a weapon. I am using the UCC monitor and not a custom made one. Here is a video highlighting the issue.

Attached is the custom ability I created which is based off the drop ability. Warning: it is an extremely ugly script.

Thank you!
 

Attachments

  • dropGolfBall.txt
    13.2 KB · Views: 1
Thank you for reporting this bug. I was able to replicate it in the integration demo scene. Turns out when the item was removed using the UIS way, the integration wasn't sending the "OnInventoryAdjustItemIdentifierAmount" event that the ItemMonitor listens to.

So I added the following code to the CharacterInventoryBridge:

At the end of the Awake( ) function you'll want to add this:
Code:
EventHandler.RegisterEvent<ItemInfo>(m_Inventory, EventNames.c_Inventory_OnRemove_ItemInfo, OnRemoveItemFromInventory);

The OnRemoveItemFromInventory function is this:

Code:
        /// <summary>
        /// An Item has been removed from the Inventory.
        /// </summary>
        /// <param name="itemInfo">The info that describes the item.</param>
        private void OnRemoveItemFromInventory(ItemInfo itemInfo)
        {
#if DEBUG_BRIDGE
            Debug.Log("Item Removed or Moved in Inventory: " + itemInfo,gameObject);
#endif
            if (m_AmmoItemCollections.Contains(itemInfo.ItemCollection)) {
                // Notify those interested that an item has been adjusted.
                var remaining = GetItemIdentifierAmount(itemInfo.Item);
                EventHandler.ExecuteEvent<IItemIdentifier, int>(m_GameObject, "OnInventoryAdjustItemIdentifierAmount", itemInfo.Item, remaining);
                if (m_OnAdjustItemIdentifierAmountEvent != null) {
                    m_OnAdjustItemIdentifierAmountEvent.Invoke(itemInfo.Item, remaining);
                }
            }
        }

This change will be part of the next update
 
I've spent the last few days updating my project to the latest version of UIS and UCC. I've incorporated your code into CharacterInventoryBridge but m_AmmoItemCollections isn't defined so I'm unable to test it with my project . What is m_AmmoItemCollections?
 
Sorry,
m_AmmoItemCollections is a group of ItemCollections where your ammo is stored. It's change that another user requested because he had his ammo spread out in multiple collections. That change will be part of the next update.
In the released version there is only one Item Collection for the Ammo. m_AmmoItemCollection.

Code:
//Instead of this
if (m_AmmoItemCollections.Contains(itemInfo.ItemCollection)) {

//Use this
if(m_AmmoItemCollection == itemInfo.ItemCollection) {

I hope that fixes your issue
 
Top