Reloading small amounts - calculating ammo remainders

Basically I’m trying to manage ammo in a reload function, using variables for MaxMagAmmo, MaxBackpackAmmo, CurrentMagAmmo, and CurrentBackpackAmmo. I’ve also created a function that’ll return the current fired ammo from the clip so I can do partial reloads.

My issue is when I start to run low on Ammo. I started with the blueprint below, which worked fine except that I always get the clip fully loaded even if I don’t have a full clips worth in the backpack (because of the circled node).

So then I thought I should use some compare ints, and do a few more calculations before setting any values:

And that almost works - the backpack gets set correctly but the mag doesn’t. For example, in a 20 round mag, with 20 rounds in the backpack, I fire off 8 rounds. So I have 12/20. Reload, I get 20/12 (correct). I fire off 7 rounds, I’m at 13/12.Reload again and I SHOULD be at 20/5. Instead, I’m at 18/5 (magammo incorrectly reduced by 2).

I feel like I’m waaay overcomplicating this. Is there a simpler way to run these checks with these variables?

Quick update on this for anyone looking for a simple, stable ammo counter using BPs - the blueprint demo’d here in the first third or so of the video worked perfectly for me:

[][1]

[1]: