[boskid][2.0.55] AmmoItemPrototype reload_time is ignored with inventory ammo

Bugs which we just recently fixed in our development version and will reach you in the next release.
User avatar
Fishbus
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

[boskid][2.0.55] AmmoItemPrototype reload_time is ignored with inventory ammo

Post by Fishbus »

For any mods that use reload_time for ammo magazines, it is ignored when the player has extra same-type ammo in their inventory.

For example, my SMG has 50 stacks equipped and 300 in the inventory. If my magazine has a 5 second reload when a magazine is depleted, this is ignored because there is still 300 stacks in the inventory which ammo is currently depleted from.
Once all the 300 stacks in the inventory have been consumed, the reload_time will now work as it is now reading from the equipped ammo.

I'm not sure how long this has been going on for, but it seems noticeable only recently (about month or 2).

Cheers
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3950
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.55] AmmoItemPrototype reload_time is ignored with inventory ammo

Post by boskid »

Hm... I see this was working fine in 2.0.47 and fails in 2.0.55. I was able to pinpoint exactly where this behavior change came from: in 2.0.47 there was a bug in item stack transfer logic that was unable to top-up a full stack of ammo that was missing couple of bullets (this transfer was also unable to top-up remaining science pack in a full stack of science pack), and it turns out this feature was working because of this bug existing. For 2.0.55 there was a change that fixed the item stack transfer logic to properly top-up the ammo however that means the shooter logic when shooting tries to fill the ammo from inventory after every shoot and it manages to run into the top-up code as it was supposed to from the beginning. I can attempt to fix this by disabling the transfer from inventory to the magazine if the magazine has count equal to the stack size which will prevent the top-up from happening and the reload_time will resume working, but this feature of reload_time in general is implemented on weak assumptions because ammo items can merge in various scenarios so it is possible to swap ammo in various ways to avoid the reload time from triggering.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3950
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.55] AmmoItemPrototype reload_time is ignored with inventory ammo

Post by boskid »

Ok, this is now fixed for 2.0.56: i made the ammo to be refilled only when count of items in ammo stack is reduced.
User avatar
Fishbus
Burner Inserter
Burner Inserter
Posts: 14
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Re: [boskid][2.0.55] AmmoItemPrototype reload_time is ignored with inventory ammo

Post by Fishbus »

Thanks for the quick reply and fix!

I know it's basically held together with sticks and twine at this point and completely optional; but it's much appreciated that you still support it - as it's a fun mechanic in the mods that use it.

Cheers
Post Reply

Return to “Resolved for the next release”