Schall Ammo Turrets


Adds turrets covering most existing ammo. Currently includes: minigun turret, sniper turret, rocket turret, autocannon turret, cannon turrets, flamethrower turret - propane gas. (Locale: English, Deutsch, 正體中文, 简体中文, Русский, Português Brasileiro)

Content
3 years ago
0.16 - 1.1
10.8K
Combat

b [Solved] Crash upon loading a game with the just released 0.17.3 (Conflict with Rampant Arsenal)

4 years ago

Just updated the mod and upon loading the map it now crashes with:

Error while applying migration: Schall Ammo Turrets: SchallAmmoTurrets_0.17.3.lua

...allAmmoTurrets__/migrations/SchallAmmoTurrets_0.17.3.lua:37: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
        ...allAmmoTurrets__/migrations/SchallAmmoTurrets_0.17.3.lua:37: in main chunk"
4 years ago

Can you download and use the older version Schall Ammo Turrets 0.17.2, then check if the tech "Physical projectile damage 1 to 7" and "Stronger explosives 1 to 7" all exist in the tech tree?
If they are present, can you also check if "Gun turret damage +x%" modifier exist in each "Physical projectile damage 1 to 7" tech?

4 years ago

I actually just finished migrating the server by just replacing the turret_modifier[tech_lv] expressions on lines 37 and 39 with (turret_modifier[tech_lv] or 1). Reverting back to the distribution version still works since the altered migration is already applied. I do recall seeing those technologies, I just don't recall of what tiers they were.

I'm curious as to the point of this migration though, if the research uses standard factorio technology modifiers then it should apply dynamically without calculating it manually? Just calling force.reset_technology_effects() should be sufficient for the game to recalculate it all significantly faster and fully correctly.

4 years ago

At least as of the altered migration with the latest version all 7 levels of each exist, unsure about before.

4 years ago

We have Stronger explosives 1 already researched (so that existed previously at least), and it applied 25% damage bonus to grenades and such things, which is listed as 25% in the bonus screen. So it all looks right.

4 years ago

By replacing as "(turret_modifier[tech_lv] or 1)", in some of the "Stronger explosives X" tech you will actually have "Rocket turret damage: +100%". This will be too much. Please check if this exist in some of the levels.
Within "Stronger explosives" techs, "Rocket turret damage: +x" should be 10% (lv 1-2), 20% (lv 3-5), 40% (lv 6), 70% (lv 7).
These values come exactly from corresponding "Gun turret damage: +x". Want to know if some other mods may have interfered with this.
Anyway, I will think of some better ways to avoid potential conflicts with other mods in such situation. (Maybe I will just hardcode these in next version.)

The reason of not calling "force.reset_technology_effects()" is because of my experience in using some other mods before. This command may remove those recipes, effects, modifiers, etc, which are introduced by script but not traditional data.raw code. For example, "Creative Mode 0.16" tab will be removed by this command. (Not sure about current versions.) So compatible with other mods are reduced.
I read this somewhere ago (forgot where), so I learned it by heart. But I can give this up, if it ends up causing more trouble than what it benefits.

4 years ago

The reason of not calling "force.reset_technology_effects()" is because of my experience in using some other mods before. This command may remove those recipes, effects, modifiers, etc, which are introduced by script but not traditional data.raw code.

Any mod that controls values that way is purely setup to fail. Quite a few mods call force.reset_technology_effects().

By replacing as "(turret_modifier[tech_lv] or 1)", in some of the "Stronger explosives X" tech you will actually have "Rocket turret damage: +100%". This will be too much. Please check if this exist in some of the levels.

  • Currently Schall's Rocket Turrets have a +10% Damage bonus.
  • Currently "Stronger explosives 1" is researched (and was researched before the update and migration), the second one is not yet research.
  • Currently Grenades have a +25% damage bonus.

The reason of not calling "force.reset_technology_effects()" is because of my experience in using some other mods before. This command may remove those recipes, effects, modifiers, etc, which are introduced by script but not traditional data.raw code. For example, "Creative Mode 0.16" tab will be removed by this command. (Not sure about current versions.) So compatible with other mods are reduced.
I read this somewhere ago (forgot where), so I learned it by heart. But I can give this up, if it ends up causing more trouble than what it benefits.

Checking in the current modpack for calls to reset_technology_effects shows that all these mods call it on quite a few various occasions:

  • angelsbioprocessing
  • angelspetrochem
  • angelsrefining
  • angelssmelting
  • AsphaltRoads
  • boblogistics
  • bobplates
  • CharcoalBurner
  • CompressedFluids
  • OverMods
  • pycoalprocessing
  • PyCoalTBaA
  • SantasNixieTubeDisplay
  • scattergun_turret
  • WhistleStopFactories

In addition, I do have Creative Mode for testing here in SP before deploying to the server and accessing it's Creative Items tab is trivial via its switch in its menu.

So it looks like quite a variety of mods call force.reset_technology_effects() on a variety of conditions (some upon every load, every configuration change, etc...) so if some script did assume that the engine's determination of the bonuses was not correct then it seems that they would fail pretty poorly.

Within "Stronger explosives" techs, "Rocket turret damage: +x" should be 10% (lv 1-2), 20% (lv 3-5), 40% (lv 6), 70% (lv 7).

Indeed they are.

These values come exactly from corresponding "Gun turret damage: +x". Want to know if some other mods may have interfered with this.

Does not appear so, no mod but Schall's mods are listed as having touched those.

The migration script appears to be iterating over the physical-projectile-damage-# technologies, looking for the turret-attack effect type for gun-turret's, then storing that modified value in the table under the given tech level. it then iterates over stronger-explosives-#, seemingly looking for the highest researched technology of it from 1 to 7 and setting the binding named dmg_bonus for each of those technologies. At the end of this loop it then calls force.set_turret_attack_modifier("Schall-rocket-turret", dmg_bonus), and this is the part that seems superfluous as force.reset_technology_effects() will handle that properly and correctly already. As for why the turret_modifier[tech_lv] is nil just means that the value must not be found in the physical-projectile-damage-1 technologyasstronger-explosives-1is the only researched one, and checking thephysical-projectile-damage-1technology seems to have an upgrade for bullet damage flat out, but nothing forgun-turretspecifically (it does however have upgrades forgun-turret-2and others though). Checking this modpack for any mod that touches"gun-turret"as a modifier turret_id appears to be this mod as well as Rampant Arsenal, which removes thegun-turretmodifier from thephysical-projectile-damage-#researches and puts them on a dedicatedgun-turret-damage-#` research.

Thus it appears that Rampant Arsenal is just moving the modifier that your migration is looking for to a dedicated research.

In addition, a noticed bug is the line elseif tech_lv == 7 then in the migration, that will unconditionally add the value of tech level 7 since it is not testing if tech.researched is true first like the first conditional is, so the corresponding force.set_turret_attack_modifier("Schall-rocket-turret", dmg_bonus) call would be too high anyway if this migration worked to start with (which it does not seem it will considering the host of mods that are already calling force.reset_technology_effects() on updates and other events anyway).

4 years ago
(updated 4 years ago)

Thanks for spending effort to find the cause.

The reason of not calling "force.reset_technology_effects()" is because of my experience in using some other mods before. This command may remove those recipes, effects, modifiers, etc, which are introduced by script but not traditional data.raw code.

Any mod that controls values that way is purely setup to fail. Quite a few mods call force.reset_technology_effects().

OK, I will consider this in the future. Not worth bringing problem to my own.

As for why the turret_modifier[tech_lv] is nil just means that the value must not be found in the physical-projectile-damage-1 technologyasstronger-explosives-1is the only researched one, and checking thephysical-projectile-damage-1technology seems to have an upgrade for bullet damage flat out, but nothing forgun-turretspecifically (it does however have upgrades forgun-turret-2` and others though).

Not entirely correct. Line 9-19 try to read from force.technologies, which exist for ALL tech no matter it is researched or not. This part tries to read from all 'physical-projectile-damage-*' tech about the 'modifier' of vanilla gun turret 'turret_id == "gun-turret"', which is assumed to present as of vanilla 0.17. Any mod removing any of these will cause the crash you mentioned.

Checking this modpack for any mod that touches "gun-turret" as a modifier turret_id appears to be this mod as well as Rampant Arsenal, which removes the gun-turret modifier from the physical-projectile-damage-# researches and puts them on a dedicated gun-turret-damage-# research.

Thus it appears that Rampant Arsenal is just moving the modifier that your migration is looking for to a dedicated research.

Now you found the exactly and the only cause of the crash: Rampant Arsenal moving the attack modifier of vanilla "gun-turret".
This crash is not entirely bad actually... Because this highlights the rocket turret will not benefit from any damage bonus from the tech. I am now thinking of a solution, where the values will be correct while still consistent with other mods like Rampant Arsenal. Simply calling 'force.reset_technology_effects()' is NOT enough, because 'data.raw.technologies["physical-projectile-damage-*"]' is not having the values that I want to copy from, if it is already modified by other mods. Maybe I will just assume everything vanilla, ignoring consistency with mods modifying that...

In addition, a noticed bug is the line elseif tech_lv == 7 then in the migration, that will unconditionally add the value of tech level 7 since it is not testing if tech.researched is true first like the first conditional is, so the corresponding force.set_turret_attack_modifier("Schall-rocket-turret", dmg_bonus) call would be too high anyway if this migration worked to start with (which it does not seem it will considering the host of mods that are already calling force.reset_technology_effects() on updates and other events anyway).

No, it won't. Can you see the 'math.max(0,tech.level-7)' part of line 39? It just unconditionally adding "zero" to the value if tech level is below 7.
tech.researched is always false for ANY infinite tech (as of my finding in 0.16.51, when I was messing with this in creating Schall Starting Tech), using it in condition will render an incorrect logic.

EDIT: If you have applied '(turret_modifier[tech_lv] or 1)', you will get +100% damage bonus to rocket turret EVERY level. After reaching level 6, you will get a brutal +600%... Try using 0.1 or 0.2 instead for the moment.

4 years ago

EDIT: If you have applied '(turret_modifier[tech_lv] or 1)', you will get +100% damage bonus to rocket turret EVERY level. After reaching level 6, you will get a brutal +600%... Try using 0.1 or 0.2 instead for the moment.

It didn't seem to make any difference, it's always 0.25% in game. I'm betting it's because some other mod is calling force.reset_technology_effects(), thus resetting any of those effects back to what the technology itself defines.

4 years ago

If 0.25% or 25%, I guess another mod(s) have completely taken over and overwritten the values (not just reset_technology_effects()). Because I copied from the vanilla turret upgrades values, which neither have 0.25% nor 25%.

4 years ago

I have rewritten the turret damage bonus part (together with migrations). So correct damage bonus should apply even if other mods removed tech effects of "gun-turret". Available as version 0.17.4.

4 years ago

Awesome! Thanks much!

New response