Turret shells fly through asteroids

Place to get help with not working mods / modding interface.
Vano0o0o
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Mar 14, 2026 3:16 pm
Contact:

Turret shells fly through asteroids

Post by Vano0o0o »

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?
eugenekay
Smart Inserter
Smart Inserter
Posts: 1049
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Turret shells fly through asteroids

Post by eugenekay »

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
Vano0o0o
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Mar 14, 2026 3:16 pm
Contact:

Re: Turret shells fly through asteroids

Post by Vano0o0o »

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"
},
}
}
}
},
Vano0o0o
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Mar 14, 2026 3:16 pm
Contact:

Re: Turret shells fly through asteroids

Post by Vano0o0o »

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
I will also post the properties of the projectile used in the turret.
{
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"
},
},
}
Vano0o0o
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Mar 14, 2026 3:16 pm
Contact:

Re: Turret shells fly through asteroids

Post by Vano0o0o »

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
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
Smart Inserter
Smart Inserter
Posts: 1049
Joined: Tue May 15, 2018 2:14 am
Contact:

Re: Turret shells fly through asteroids

Post by eugenekay »

Hooray!

Looking forward to trying a new (interesting?) Turret mod when it is ready. :-)
Vano0o0o
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Mar 14, 2026 3:16 pm
Contact:

Re: Turret shells fly through asteroids

Post by Vano0o0o »

eugenekay wrote: Fri Apr 24, 2026 4:49 pm Hooray!

Looking forward to trying a new (interesting?) Turret mod when it is ready. :-)
Do you know the IR3 mod? You'll see it on the new version in a couple of months.
Post Reply

Return to “Modding help”