Gun Equipment


Mode add automatic guns applyable to equipment grid.

Content
4 days ago
1.0 - 2.0
40.5K
Combat Armor

i [Ideas collecting] High CPU usage

4 years ago

I was having a conversation on this thread: 'https://forums.factorio.com/viewtopic.php?f=49&t=89942&p=514408' about a performance issue I was having, and your mod was cited, as it looks like it consumes a lot of CPU time.
Although my problem was not this mod, it might be worth taking a look at if it can be optimized.

Thanks.

4 years ago

Thanks for mention. I'll do some tests.

4 years ago

Seems to be less, but needs to be run on same configuration.

4 years ago

Seems to be less, but needs to be run on same configuration.

I did not understand!

4 years ago

Try to run same save if you reach same time values.

4 years ago

I tested now with the version 0.0.12:

mod-GunEquipment: 0.840/0.425/2.729

These data are very stable and vary little around these numbers!

4 years ago

Then it looks same like before, is slightly more, but i could be because of more types of magazines, which are now indicated.

4 years ago
(updated 4 years ago)

Main issues:

  • checking of all ammo types in each tick
    Ideas:

    • check first previously loaded ammo if exist in main inventory
  • checking all weapons in all grids (characters, vehicles) in every tick

Finished:

  • cache of vehicles is created after load of save (no longer needed to find it on map)
  • cache ammo types is created after load of save
4 years ago

can you segment the check? it's not strictly nescecary to check every tick.

4 years ago
(updated 4 years ago)

If you want to shoot from every gun on full fire rate, is not very easy split-up each entity to single tick.
Is needed to compare multiple scenarios to find a bottleneck:

  • full equipped character (1, 3 and more)
  • single/half/full equipped spidertron (1, 3 and more and mix of characters)
  • any other vehicles (not needed bud ideal to know)

  • all ideally on same pc same save with well internet connection

4 years ago

But why the high cpu usage without anything hapenning? I'm not even close of any enemies...

4 years ago

Can't you load 1.5 magazines, and reload at 0.5 magazine left?

4 years ago

That makes no sence, more in case you have some reload time to load new one. That mechanic will not work in that case because of grid entity replacement.

4 years ago

But why the high cpu usage without anything hapenning? I'm not even close of any enemies...

There are multiple loops:

  • [1] for each entity (character, vehicle)
    • if grid
    • [2] for each equipment
      • if match "personal-turret-%magazine_name%-equipment-reload-%ammo_in_magazine%"
        • check if energy is full then replace with %ammo_in_magazine% energy
      • else if "personal-turret-*-equipment" and with zero energy
        • [3] for each magazine (top damage first * cached)
          • if exists in inventory
          • reload (if time needed to reload, reloading equipment placed) and break magazine loop
4 years ago

I really don't understand why increasing the magazine size to allow for less frequent reloads to allow for less frequent reload checks is not an option.

4 years ago

I got it now, you mean 'double loading' per every 2nd tick or ?

I thing its easy to split reloading of vehicles and characters or do it in every second tick, but it makes no sence in term of lose of magazines. This topic is also open, we do not have any possibility to manage returning of rest ammo. If you give more magazines inside, you will loose it all.

4 years ago

that loss is rather insignificant on the larger scale of things.

After looking more into how Schall gun pods work, it has a shortcut that unloads all of the gun pods while refunding the ammo.

New response