In case anyone stumbles upon this, with the same issue. I found a way around this. It includes a dummy turret entity, some hidden technologies and a control script to automatically research these technologies. Feel free to use the code below.
data-final-fixes.lua
Code: Select all
if data.raw.technology["physical-projectile-damage-1"] and data.raw.technology["physical-projectile-damage-7"] then
local turret_list = {}
for _, turret in pairs(data.raw["ammo-turret"]) do
table.insert(turret_list, turret.name)
end
data:extend({
{
name = "ammo-turret-dummy",
type = "ammo-turret",
icons = {
{
icon = "__base__/graphics/icons/gun-turret.png",
icon_mipmaps = 4,
},
{
icon = "__core__/graphics/icons/technology/effect-constant/effect-constant-damage.png",
icon_mipmaps = 2,
}
},
icon_size = 64,
localised_description = {"", "\n"},
attack_parameters = {type = "projectile", range = 0, cooldown = 0},
call_for_help_radius = 0,
folded_animation = data.raw["ammo-turret"][turret_list[1]].folded_animation,
automated_ammo_count= 0,
inventory_size = 0,
}
})
local tech_list = {
{name = "physical-projectile-damage-1", value = 0.1},
{name = "physical-projectile-damage-2", value = 0.1},
{name = "physical-projectile-damage-3", value = 0.2},
{name = "physical-projectile-damage-4", value = 0.2},
{name = "physical-projectile-damage-5", value = 0.2},
{name = "physical-projectile-damage-6", value = 0.4},
{name = "physical-projectile-damage-7", value = 0.7},
}
for _, tech in pairs(tech_list) do
local visible_tech = data.raw.technology[tech.name]
local hidden_tech = table.deepcopy(visible_tech)
hidden_tech.name = "hidden-"..tech.name
hidden_tech.effects = {}
for _, turret in pairs(turret_list) do
table.insert(hidden_tech.effects, {type = "turret-attack", turret_id = turret, modifier = tech.value})
for i, effect in pairs(visible_tech.effects) do
if effect.type == "turret-attack" and effect.turret_id == turret then
table.remove(visible_tech.effects, i)
end
end
end
hidden_tech.hidden = true
data:extend({hidden_tech})
if visible_tech and visible_tech.effects then
table.insert(visible_tech.effects, {type = "turret-attack", turret_id = "ammo-turret-dummy", modifier = tech.value})
end
end
for i, turret in pairs(turret_list) do
if data.raw["ammo-turret"][turret].flags then
table.insert(data.raw["ammo-turret"][turret].flags, "hidden")
else
data.raw["ammo-turret"][turret].flags = {"hidden"}
end
end
for i, turret in pairs(turret_list) do
local description = data.raw["ammo-turret"]["ammo-turret-dummy"].localised_description
if i == 1 then
table.insert(description, 2, "\n[font=heading-1][entity="..turret.."] [.font]")
table.insert(description, 3, {"entity-name."..turret})
elseif i < 10 then
table.insert(description, i*2, "\n\n[font=heading-1][entity="..turret.."] [.font]")
table.insert(description, i*2+1, {"entity-name."..turret})
else
local size = table_size(turret_list)-9
table.remove(description, 20)
table.insert(description, 20, "\n\n and "..size.." more")
break
end
end
end
control.lua
Code: Select all
local tech_list = {
"physical-projectile-damage-1",
"physical-projectile-damage-2",
"physical-projectile-damage-3",
"physical-projectile-damage-4",
"physical-projectile-damage-5",
"physical-projectile-damage-6",
"physical-projectile-damage-7",
}
local function fix_turret_modifiers(force)
for _, tech in pairs(tech_list) do
if force.technologies[tech] and force.technologies["hidden-"..tech] then
if tech == "physical-projectile-damage-7" then
force.technologies["hidden-physical-projectile-damage-7"].level = force.technologies[tech].level
else
force.technologies["hidden-"..tech].researched = force.technologies[tech].researched
end
end
end
end
script.on_event(defines.events.on_research_finished, function(event)
fix_turret_modifiers(event.research.force)
end)
script.on_event(defines.events.on_technology_effects_reset, function(event)
for _, force in pairs(game.forces) do
fix_turret_modifiers(force)
end
end)