how to remove only ammo of the equipped weapon

treshold82

New member
I'm using external inventory system and currently adding ammo works with inventory as adding specific weapons.
Currently my problem is that i would like to remove just ammo of the weapon :
I have bow and arrow equipped in my character sheet and if i remove only arrows i would like to empty ammo of the opsive inventory too,
but if I use
inventory.RemoveItem , it doesn't work on consumableitemtype i think.
In my debug I see BowArrow is itemtype to be removed and amount is 2 for example but nothing happens.

How would I remove only ammo of the weapon?
I tried to look up shootable weapon how it does consume ammo but couldnt find direct answer yet - so any pointers could help thx :)
 
Okay I made a progress with inventory.UseItem(myArrow, amount)
Only problem is that how do I remove the "loaded" ammo.
I have bow and if I equip 1 arrow it goes straight to as loaded one. If i now remove Arrow from inventory with inventory.UseItem - it doesnt remove the "loaded" one.
 
hmm one workaround could be to remove Bow same time if i remove arrows and put it back immediately :D
I tried to study those methods which are used in inventorybase when item is removed and all consumable along it but no luck yet.
 
There is Inventory.RemoveItemType but that'll only remove the consumable amount within the inventory. You'll instead need to use the IUsableItem.RemoveConsumableItemTypeCount method in order to remove it on the ItemAction. If you do a search within the code you can see an example of this method's use.

one workaround could be to remove Bow same time if i remove arrows and put it back immediately
Hah, nice workaround :)
 
There is Inventory.RemoveItemType but that'll only remove the consumable amount within the inventory. You'll instead need to use the IUsableItem.RemoveConsumableItemTypeCount method in order to remove it on the ItemAction. If you do a search within the code you can see an example of this method's use.


Hah, nice workaround :)
hehe i managed to get working that IUsableItem.RemoveConsumableItemTypeCount so no need for workarounds

Thanks!
now i only need to fiddle with disabling shootable arrow when arrows are reduced to zero and 1 arrow is "loaded" :D but i saw methods in shootableweapon so i hope its easy.
 
Top