Gun Equipment


Mode add automatic guns applyable to equipment grid. Mode was originaly contained in Coal Powered mode and was extracted because of possible complexity.

Content
2 years ago
1.0 - 1.1
33.5K
Combat

i [Ideas collecting] High CPU usage

3 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.

3 years ago

Thanks for mention. I'll do some tests.

3 years ago

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

3 years ago

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

I did not understand!

3 years ago

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

3 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!

3 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.

3 years ago
(updated 3 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
3 years ago

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

3 years ago
(updated 3 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

3 years ago

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

3 years ago

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

3 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.

3 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
3 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.

3 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.

3 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