Leading projectile fire?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Leading projectile fire?

Post by Deadlock989 »

Following this, which I thought was a bug, but now pretty sure it isn't:

viewtopic.php?f=29&t=70151

Having experimented some more I've discovered that lead_target_for_projectile_speed works the opposite way around to what I thought. In vanilla, worms use it with a value of 0.3375 to fire just ahead of the player. I tried that value for my energy projectile turrets and was getting fire at absurd angles, yards and yards ahead of the target, so I thought, I'll reduce the value. That made things worse.

I now think that actually, it's based on a value of 1.0 for no lead at all. Reducing the value from that gives you an increasing lead.

The value isn't documented - clearly there's some relationship with the speed of the projectile and range here. Does anyone have any insight into how that works? I ended up with a value of 0.5 for my projectiles, and they hit by leading from the target much better now, even at a range of 40-50. Suspiciously, the projectiles have a maximum speed of 1 and accelerate up from 0.1, so the average speed is pretty close to 0.5 ... is that a coincidence or not?
Image

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Leading projectile fire?

Post by Deadlock989 »

Deadlock989 wrote:
Fri May 03, 2019 1:26 pm
... is that a coincidence or not?
It's not. The value directly relates to projectile speed. Where that's defined depends on the type (projectile or stream) but for projectiles it's straightforward. If your bullets move with a speed of 1.5 then you set the lead to 1.5 as well and the turrets become pretty much unerring.

This assumes constant projectile speed. If they accelerate, rocket or torpedo style, you have more of a problem, but you can reckon it by working out the average likely speed based on range, acceleration rate and maximum speed. You can make that easier for yourself by jigging the maximum speed to occur near the edge of maximum range. This can help.

Another irritant is that the leading doesn't take any slowdown stickers applied to the target into account. If the target is moving, the lead will be applied as if the target is moving at its top movement rate, regardless of what speed it is actually moving. Fixed in 0.17.38
Image

Post Reply

Return to “Modding help”