Ammo/Inventory Weirdness - UCC 2.3.5 UIS 1.1.8

DMC

New member
I am having an issue with the UCC UIS integration where:
I make a crossbow & bolt pickup
1 crossbow and 15 bolts
it goes to inventory on interact
if I equip the crossbow the ammo will disappear
if I drop the ammo, equip the crossbow, then pick up the ammo, it will reload
I increased the ammo count to 100
I then equipped the crossbow,
ended up with 145 ammo in inventory and 5 in the clip

When the pickup was only 15 ammo, all the ammo disappeared from inventory
if I did not drop it first, without any being loaded into the weapon
If I picked them up, drop ammo, then equip, then pick up ammo and press r
then it reloads without forgetting ammo
If I increase to 100 ammo in pickup it will not loose ammo but it will put 5 in clip and then add 45 to the pool in inventory
If I pick up the 100 ammo and bow then drop ammo then equip bow then pick up ammo then reload it works correctly

Yeah like it is assuming that it is an assault rifle
which I have booked it as for now but why would it drive ammo count?
Well, I say that because the assault rifle in demo has 50 round clip and 45 is added to inventory

Naturally, it follows If you pick up no ammo, then you will not have any ammo
Where the inclusion of a single ammo will also result in no ammo(edited)

:D

Increasing the ammo pickup to 50 ammo, with the clip still 50 will give you one clip of 50 with no extra ammo

and reducing the clip size back to 5 with 50 ammo picked up works correctly

I assign the assault rifle index, but I made it through the item creation process

... picking up another 100 ammo pickup it stacks correctly in inventory, but it does not show the new total in the UCC heads up
Well, until you empty the clip, then it updates on reload... but is the correct number
 
Last edited:
In UCC the ammo is determined by the "Consumable Item Definition" and the "Clip Size" on the Item prefab.

In the Integration we use the AmmoData Item Attribute instead. This way if you drop the weapon it keeps the ammo for the next person that picksit up.

In both cases the ammo is removed from the Inventory and stored inside the weapon clip when you recharage. So you're satement
if I equip the crossbow the ammo will disappear"
is normal behavior. It doesn't disapear completely, it was just moved from the Inventory to inside the weapon.

As for the next statement:
if I drop the ammo, equip the crossbow, then pick up the ammo, it will reload
I increased the ammo count to 100
I then equipped the crossbow,
ended up with 145 ammo in inventory and 5 in the clip
That sounds like a bug. My guess is that something is making the system mix up the UCC and Integration way of counting the ammo amount. So it might be setting the AmmoData Clip and then it sets the UCC clip and vice versa, adding or removing extra ammo.

I tested your use case on the pistol of the demo scene and saw something odd, it didn't add extra ammo though, it removed more ammo than it should have.

I will add more unit tests to test the ammo, see if I can catch theis weird issue.

Could you let me know the values you have as "ClipSize" on your CrossBows Item prefab inside the "Shootable Weapon" component. And also the "Clip Size" inside the AmmoData Item Attribute. This way I can make a special edge case unit test with those values and see if I can replicate it and then fix it.

EDIT: Can you double check what versions of the integration asset you are using? make sure to check inside our editor managers. The Integration version can be found inside the UIS->Integrations tab
 
Last edited:
I was able to fix the issue that I had with the pistol ammo in the integration demo.
I wasn't able to replicate your issue though, they might not be related.

Could you try changing this function in the CharacterInventoryBridge:
Code:
/// <summary>
/// Removes the ItemIdentifier from the inventory.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to remove.</param>
/// <param name="slotID">The ID of the slot.</param>
/// <param name="amount">The amount of the ItemIdentnfier that should be removed.</param>
/// <param name="drop">Should the item be dropped when removed?</param>
public virtual void BaseRemoveItem(IItemIdentifier itemIdentifier, int slotID, int amount, bool drop)
{
    //In the integration a weapon is removed when it is unequipped,
    //the ammo should stay on the weapon no matter whether it is unequipped or dropped.
    var dropConsumableItem = false;
    var item = GetItem(itemIdentifier, slotID);
    if(item != null) {
        dropConsumableItem = item.DropConsumableItems;
        item.DropConsumableItems = false;
    }
    base.RemoveItem(itemIdentifier, slotID, amount, drop);
    if(item != null) {
        item.DropConsumableItems = dropConsumableItem;
    }
}

Let me know if it makes any difference.

If you still have issues please do send me a screen shot of your ShootableWeapon & ShootableWeaponAmmoBinding component on your item prefab and also a screenshot of your AmmoData Item Attribute. I might be able to spot something that's off
 
I don't know...

I add one to 40, 41...
This time not 26 left, 27...
 
Last edited:
I guess I missed one of your posts.

I think you could be right about it mixing the methods/classes, because I remember when I installed this time, it was before you fixed the install order, and I installed them in reverse to get around a different problem, which could maybe be causing this problem.
Installed UIS, then UCC, then Integration.

It is possible I did not get the correct overwrites. So I will redo the project, again..

As for this one, which is maybe made moot by the above. (well, it kind of seems like it is not moot since you are having a problem with pistol.)

The ammo is not placed in the weapon when the count is one of those lower figures.
It disappears completely.
No ammo in inventory.
No ammo in the weapon.

"I tested your use case on the pistol of the demo scene and saw something odd, it didn't add extra ammo though, it removed more ammo than it should have."

I think this could apply to this scenario, especially if it is a fixed amount which worked, followed by odd amounts that didn't.
Here, it very probably could be subtracting 50, then adding the extra back to inventory, 45.
My thought was that it was treating it like the demo assault rifle on some level, then it was apply the values over top of that.

Was it that it took more than it should when you reduced the clip size?
If so, perhaps the order of execution did not apply the addition to add it back.

I made the crossbow using the editor, and I applied the index for rifle to utilize the animation, which I will switch (my game does not have assault rifles).
Is there anything in UCC that applies these values simply by using that id?
If so, it could be treating it like an assault rifle, then treating it like my crossbow.

I am still learning this system, and I do not know it inside and out.
I really only have somewhat pointless speculation about the types of scenarios that could result in the behavior.
If it is being compressed with other values, encrypted and decrypted by inconsistent methods.
Stored bitwise with a flawed method..
idk.

Modified by more than one method seems very plausible.

I think, perhaps, it is key not to forget:
If I drop the ammo, equip the weapon, and then pick the ammo up, it works correctly.
I could be wrong and just have not tested enough to find the problem that might also exist here
but I presently do not think so.

If I pick up weapon and ammo, and equip the weapon, the ammo behaves aberrantly.
If I drop ammo, equip weapon, pick up ammo, reload, it reloads without error.

Yeah, so having tested again with a pickup of 20 ammo.
If the ammo is dropped and then the weapon is equipped, perhaps the offending methods have resolved.
Now, picking up the ammo and pressing r will reload correctly.

The issue, from memory, is also true if the ammo and the weapon separate pickups, naturally, as it seems to have something to do with resolving the weapon, rather than it's ammo, inventory, etc...

If there is ammo in the inventory when the weapon is initially equipped, this issue seems to occur.
 
Last edited:
As a heads up, and a bit off topic:

Do you have a project in which all your tools have been successfully integrated; BT, UIS, UCC & Opsive Controller Packs?

Also, if so, can there be a Ultimate Opsive Pack with a fully integrated demo scene :devilish:
or perhaps, could I possibly just have a package of the fully integrated controller so I can cheat :D

In either case, in which order would you recommend installation and integration of each tool?
What is the path of least resistance here?

I am also integrating MalberS HAP, the Full Pixel Crushers line...
Possibly Polaris for flight...

I'm getting a bit worried...

Only, if this is going to possibly be an issue, this order:
What will bringing in the agility packs do to the UCC UIS integration?
What would bringing UIS in do to to the UCC agility integrations?
 
Last edited:
So I see that your Clip Size on the Item component is set to 50 but on your AmmoData it is set to 5. I'll try to set those values in to see if I can replicate your issue in some unit tests. I'll make sure to test the "If there is ammo in the inventory when the weapon is initially equipped, this issue seems to occur." use case you talked about.
Setting both clipSize to the same value should give you better results but I don't think that will solve the underlying issue.

Note that the pistol issue I had is now completely fixed with the code chage I sent you previously so it seems that wasn't related at all.

I don't think the issue has anything to do with the way you installed UCC and UIS it must have something to do with the ShootableWeaponAmmoBinding. You could try setting some Debug.Logs inside to know if the binding is being set properly and when. You can add a few other Debug.Logs in the BridgeEquippableProcessing to check the clip size a different steps of the equipment process. That might give us an idea of where to look considering I wasn't able to reproduce your error so far.
I also noticed that your Ammo Name in your AmmoData did not match the Ammo ItemDefinition Name, I doubt that had anything to do with the issue though.

Also could you send me your Integration version, to be sure we have the same, it should be v2.0.3:
1629098341410.png
it should work with UCC 2.3.5 of course.


We are working on a project called the "Adventure Kit" which combines UCC, UIS an multiple UCC packs (agility&climb). It will also include integrations with BD and the Dialogue System from Pixel Crushers.
The "Adventure kit" project is the project where I make all the improvements on the UCC/UIS integration. Our plan is to realse it before the end of this year.

When we export UCC or UIS it bundles up the shared folder. But some shared files aren't required in UIS so they are removed during export. Sometimes we mess something up and export the wrong shared file with wither UCC or UIS. If that's the case installing UCC or UIS in a different order causes issues. If that's the case you should report it as a bug and we'll export it again and make a small update.

I hope that helps clear things up.

I'll let you know as soon as I have implemented my unit tests for your use case and see if I'm able to replicate the issue.
 
"So I see that your Clip Size on the Item component is set to 50 but on your AmmoData it is set to 5."

Setting the value of 50 to 5 caused the ammo not to be removed when equipping the bow, without dropping the ammo, but still added ammo, 15; 5 in clip and 30 remaining from a pickup of 20.

A pickup of 50 returns 5 in clip and 90 in inventory.

...it is doubling the inventory it seems; returning the remainder twice.
 
I checked my unit tests and your use case is already part of the tests I run. And it works just fine.
I also tested in my project demo scene it works fine.
And I also tested after downloading the released UCC and UIS + the integration in a new project.


Could you go to the demo scene pickup the pistol and equip it. When you pickup the pistol it should come with 200 ammo. After equipping there should be 12 inside the pistol and 188 left in the inventory.
Can you double check that's the case?

It's really hard for me to find the issue when I can't replicate it. I will ask you to double check your asset versions again within our own editors (don't look at the package manager).

If you can't find anything I will have to ask you to send us your project at support@opsive.com so that we can have a look ourselves. If possible send us the bare minimum project that reproduces the issue.
I'm verry sorry that this issue is taking so long to debug.
 
"Could you go to the demo scene pickup the pistol and equip it."

I made my crossbow using the item creation process from the video and the rifle animation index.

In the demo, everything works as it should.

"I'm verry sorry that this issue is taking so long to debug."
No worries.
It is most probably just a wiring issue in that scene.
Especially since everything behaves correctly in the demo.
Going to Nolan and changing the ammo count in his loadout to 20 results in an on equip of 20.

"It's really hard for me to find the issue when I can't replicate it."
It is a thing that happened, in this case, but it seems it might not be a thing that happens.
Execution order...
idk.

My present theory is that we are being Unity'd.
 
Since it works in your demo scene then I doubt it has anything to do with execution order since that would affect the entire project in the same way.
I will ask you to send us a minimal scene that reproduces the error (no need to include UCC, UIS or the integration since we know that we have the same version). You can send us that scene at support@opsive.com. Hopefully I can reproduce the error there and come to the bottom of this issue.

Just out of curiosity, I'm wondering if the item isn't the problem but the character is. Double check that the components on your character makes sense. if possible duplicate it and try out that character in the demo scene (disable Nolan, and convert your character to use the demo database). That might give us another trail to pickup on.
 
Top