Hi I'm trying to get AutoReloadType.Pickup to work properly.
Before reading any further, please refer to this thread: https://opsive.com/forum/index.php?threads/autoreloadtype-equip-has-wrong-enum-value.9691/ where it seems like AutoReloadType.Pickup triggers reloading on every Equip, therefore making it seem like it's working on Pickup, but once you fix the enum value of AutoReloadType.Equip it no longer works.
If I pickup a weapon, then this triggers OnPickupItemIdentifier where itemIdentifier is the weapon identifier. However, In Reload.cs, this calls
This means that the weapon is actually being sent as the ammoItemIdentifier and not the weaponItemIdentifier, which causes subsequent calls to GenericReloader.ShouldReload to fail because the ammoItemIdentifier is the weapon and not the ammo identifier. It never is called where the itemIdentifier is the ammo identifier because in CharacterInventoryBridge.cs and OnAddItemToInventory:
causes an early return because my ammo is added to the Default collection which is not in BridgeItemCollections. According to the tooltip, BridgeItemCollections should only contain the equippable item collections. As a result, this doesn't cause base.AddItemIdentifierAmount to trigger, which is responsible for calling InventoryBase.PickupItem, which eventually calls Reload.OnTryReload.
Even if we send the weapon identifier properly as weaponItemIdentifier, then we still don't know what the ammo identifier should be. What's the best way to fix this? I can think of a few:
Before reading any further, please refer to this thread: https://opsive.com/forum/index.php?threads/autoreloadtype-equip-has-wrong-enum-value.9691/ where it seems like AutoReloadType.Pickup triggers reloading on every Equip, therefore making it seem like it's working on Pickup, but once you fix the enum value of AutoReloadType.Equip it no longer works.
If I pickup a weapon, then this triggers OnPickupItemIdentifier where itemIdentifier is the weapon identifier. However, In Reload.cs, this calls
C#:
OnTryReload(-1, null, itemIdentifier, immediatePickup, true);
This means that the weapon is actually being sent as the ammoItemIdentifier and not the weaponItemIdentifier, which causes subsequent calls to GenericReloader.ShouldReload to fail because the ammoItemIdentifier is the weapon and not the ammo identifier. It never is called where the itemIdentifier is the ammo identifier because in CharacterInventoryBridge.cs and OnAddItemToInventory:
C#:
if (!m_BridgeItemCollections.Contains(destinationItemCollection)) { return; }
causes an early return because my ammo is added to the Default collection which is not in BridgeItemCollections. According to the tooltip, BridgeItemCollections should only contain the equippable item collections. As a result, this doesn't cause base.AddItemIdentifierAmount to trigger, which is responsible for calling InventoryBase.PickupItem, which eventually calls Reload.OnTryReload.
Even if we send the weapon identifier properly as weaponItemIdentifier, then we still don't know what the ammo identifier should be. What's the best way to fix this? I can think of a few:
- Add the ammo definition as a property of the ReloaderModule that can be assigned in the editor, and retrieve it from IReloadableItem.ReloadableItemModule.
- Add a IAmmoModule interface that has a AmmoItemDefinition, have all AmmoModules implement IAmmoModule, and add AmmoItemModule to IReloadableItem.
- Another approach?
Last edited: