Separate Ammo Inventory

jkaczmar

Member
Hi, I'm trying to figure out the best way to have a "separate" inventory for ammo. I've attached a screenshot of the type of setup I'm trying to achieve. I understand how to use Tabbed interfaces to only show selected items (e.g. Weapon tab, Armor tab, Ammo tab, etc.), but I'm trying to achieve a slightly different effect:

  • I want the ammo to show separately (perhaps a second Inventory grid, but I'm having problems getting the ammo to show up in my first attempt at this).
  • I don't want the ammo to take up slots that would be used for things like guns, materials, consumables, etc. Therefore, the standard tabbed interface doesn't quite work.
  • I want to cap the total number of ammo that can be carried by type (e.g. 300 pistol ammo max, 50 sniper ammo max). I think I understand how to do this using ItemRestrictions and StackSizeLimit on the Item.
With that in mind, would the approach look something like this?

  • Separate inventory grid for ammo, perhaps even one inventory grid for each ammo type?
  • An Item Collection per ammo type (Pistol Ammo Item Collection of Purpose ???). One question I have is how to use Purpose effectively.
  • Item Restrictions on a Per Category basis tied to Item Collection. For example, Main would have a restriction of no ammo. Pistol Ammo would have restrictions of only Pistol Ammo, etc.)?
Thanks in advance for any ideas you have on how to achieve this.
 

Attachments

  • ammo screenshot (1).png
    ammo screenshot (1).png
    220.9 KB · Views: 3
Adding an idea to this that seems to be working, but can you please review and let me know if you my approach seems like it has any holes in it:

  • Add Item Collections for each Ammo type (Pistol, Rifle, Shotgun, etc.)
  • Mark all of these Item Collections hidden.
  • Have AmmoData on the weapon pull from the appropriate Item collection for that weapon.
  • Put an Item Restriction on Main so it can't accept ammo.
  • Put an Item Restriction on each ammo Item Collection to only accept that kind of ammo.
  • Put StackSizeLimit item restrictions on each Ammo Item Collection so that the player can carry more or less of that type of ammo as appropriate.
  • Add some custom code to the bottom of the UI to show the counts for the hidden Ammo items as well as Ammo max so that the user can see at a glance how much ammo they have.
Does this seem like a sensible way to do this or am I causing problems for myself down the road?
 
Looks good to me.
The part I'm not sure if necessary is having one ItemCollection per ammot type. Can each ammo type have multiple items inside? Or is there only one ammo item per ammo type?
If there is only one then I believe you can set a stacksizelimit per item by using the stackSizeLimit ItemDefinition Attribute. and have all your Ammo items in a single ItemCollection. Might be easier to manage.

As for the UI. InventoryGrids are mainly there for grids that have each element have the same size, and for scrolling through many items.

Looking at your UI screenshot, I would suggest either using ItemSlotCollectionView (a.k.a equipment panels) Or making your own custom ItemViewSlotsContainer UI. If you know how to code its a great way to make custom UI layouts and you get all the benefits of using ItemViewSlots compared to making something custom from scratch.

I hope that helps :)

One question I have is how to use Purpose effectively.

Purpose is something that came on the first release of UIS. I keep it for backwards compatibility. But if I ever make a major update to UIS I'd probably remove it. Leave it to None, and use the itemCollection name to do whatever you need.
 
You were right, I was over complicating it with too many ItemCollections. I ended up using the PM integration to get the stack size and current ammo count for each weapon. You have done a good job with the PM integration and I'm a bit faster with it. Everything works great. As always, thanks for the help!
 
Back
Top