Turret shells fly through asteroids
Turret shells fly through asteroids
Hi, I'm making a mod that adds a new turret in particular. It works fine on the ground, it hits both running and flying enemies. But if you put it on a space platform, but its projectiles don't touch the asteroids. What, theoretically, could be the problem?
Re: Turret shells fly through asteroids
You could post your Mod (or at least the Turret prototype code) so we can see the problem in action.
Are you using table.deepcopy to create a Gun Turret clone, or instantiating the entire prototype by hand? At a guess, ProjectileAttackParameters has optional properties lead_target_for_projectile_speed/delay, which default to 0. If these are not set then I believe that turrets will “dumbly” aim for where the enemy Is, rather than where it is Going. The asteroids move quite a bit, so they need to lead their shots.
Good Luck!
-Eugene
Are you using table.deepcopy to create a Gun Turret clone, or instantiating the entire prototype by hand? At a guess, ProjectileAttackParameters has optional properties lead_target_for_projectile_speed/delay, which default to 0. If these are not set then I believe that turrets will “dumbly” aim for where the enemy Is, rather than where it is Going. The asteroids move quite a bit, so they need to lead their shots.
Good Luck!
-Eugene
Re: Turret shells fly through asteroids
I can't post the mod yet, it's still too raw, but I can give attack_parameters to this turret. And I'm writing her prototype manually.
attack_parameters =
{
type = "projectile",
cooldown = 120,
range = 60,
min_range = 12,
range_mode = "center-to-bounding-box",
turn_range = 1/3,
projectile_center = {0,0},
projectile_creation_distance = 1.75,
lead_target_for_projectile_speed = 0.5,
ammo_category = "photon-torpedo",
ammo_type =
{
energy_consumption = "5MJ",
--category = "photon-torpedo",
-- target_type = "entity",
action =
{
type = "direct",
action_delivery =
{
type = "projectile",
projectile = "photon-torpedo",
starting_speed = 1,
direction_deviation = 0,
source_effects =
{
entity_name = "photon-muzzle",
type = "create-explosion"
},
}
}
}
},
attack_parameters =
{
type = "projectile",
cooldown = 120,
range = 60,
min_range = 12,
range_mode = "center-to-bounding-box",
turn_range = 1/3,
projectile_center = {0,0},
projectile_creation_distance = 1.75,
lead_target_for_projectile_speed = 0.5,
ammo_category = "photon-torpedo",
ammo_type =
{
energy_consumption = "5MJ",
--category = "photon-torpedo",
-- target_type = "entity",
action =
{
type = "direct",
action_delivery =
{
type = "projectile",
projectile = "photon-torpedo",
starting_speed = 1,
direction_deviation = 0,
source_effects =
{
entity_name = "photon-muzzle",
type = "create-explosion"
},
}
}
}
},
Re: Turret shells fly through asteroids
I will also post the properties of the projectile used in the turret.eugenekay wrote: Fri Apr 24, 2026 12:41 pm You could post your Mod (or at least the Turret prototype code) so we can see the problem in action.
Are you using table.deepcopy to create a Gun Turret clone, or instantiating the entire prototype by hand? At a guess, ProjectileAttackParameters has optional properties lead_target_for_projectile_speed/delay, which default to 0. If these are not set then I believe that turrets will “dumbly” aim for where the enemy Is, rather than where it is Going. The asteroids move quite a bit, so they need to lead their shots.
Good Luck!
-Eugene
{
name = "photon-torpedo",
type = "projectile",
flags = {"not-on-map"},
acceleration = 0,
direction_only = true,
hidden = true,
collision_box = {{-0.5, -0.5}, {0.5, 0.5}},
force_condition = "not-same",
height = 1,
hit_at_collision_position = true,
action = {
type = "direct",
action_delivery = {
target_effects = {
{
entity_name = "photon-hit",
type = "create-entity"
},
{
entity_name = "photon-shock",
type = "create-entity"
},
{
damage = {
amount = 180,
type = "explosion"
},
type = "damage"
},
{
check_buildability = true,
entity_name = "small-scorchmark",
type = "create-entity"
},
{
type = "invoke-tile-trigger",
repeat_count = 1
},
{
type = "destroy-decoratives",
from_render_layer = "decorative",
to_render_layer = "object",
include_soft_decoratives = true, -- soft decoratives are decoratives with grows_through_rail_path = true
include_decals = false,
invoke_decorative_trigger = true,
decoratives_with_trigger_only = false, -- if true, destroys only decoratives that have trigger_effect set
radius = 3.5 -- large radius for demostrative purposes
},
{
action = {
action_delivery = {
target_effects = {
{
damage = {
amount = 240,
type = "explosion"
},
type = "damage"
},
{
entity_name = "explosion",
type = "create-entity"
}
},
type = "instant"
},
radius = 4,
type = "area"
},
type = "nested-result"
}
},
type = "instant"
},
},
}
Re: Turret shells fly through asteroids
All I found was what the problem was: due to the fact that my projectiles flew cleanly in a straight line without deviations. I added the acceleration and turn_speed parameters and everything worked. Thank you so much for your help!eugenekay wrote: Fri Apr 24, 2026 12:41 pm You could post your Mod (or at least the Turret prototype code) so we can see the problem in action.
Are you using table.deepcopy to create a Gun Turret clone, or instantiating the entire prototype by hand? At a guess, ProjectileAttackParameters has optional properties lead_target_for_projectile_speed/delay, which default to 0. If these are not set then I believe that turrets will “dumbly” aim for where the enemy Is, rather than where it is Going. The asteroids move quite a bit, so they need to lead their shots.
Good Luck!
-Eugene
Re: Turret shells fly through asteroids
Hooray!
Looking forward to trying a new (interesting?) Turret mod when it is ready.
Looking forward to trying a new (interesting?) Turret mod when it is ready.
Re: Turret shells fly through asteroids
Do you know the IR3 mod? You'll see it on the new version in a couple of months.eugenekay wrote: Fri Apr 24, 2026 4:49 pm Hooray!
Looking forward to trying a new (interesting?) Turret mod when it is ready.![]()

