Omnidirectional turrets shoots at a leading position, <OnFireWeapon> does not provide the math done by omnidirectional code (as George showed us the code long time ago: http://wiki.neurohack.com/transcendence ... obably_old)
So, slow firing omnidirectional <OnFireWeapon> are useless.
I have a good working example of code that provides leading shot angles for omnidirectional turrets with <OnFireWeapon>.
Even with the approximations, the code works well enough to shot down a Hornet (fastest ship in the game) with a speed 40 weapon. (average kinetic or missile slow weapon)
The math:
![Image](https://dl.dropbox.com/u/720869/arctan.png)
Let's consider a triangle as in figure:
a= distance traveled by the target ship, when the projectile will hit it.
b= distance between source-target
We have to predict the position of the Hornet, this is done with an approximation: we consider that the distance of the Hornet will remain nearly the same when the projectile will reach it.
so the time will be t=b/Vp
where V is the velocity of the projectile
we then multiply this time by the speed of the target Vt
Vt*t= a
we now have a !! (with an approximation)
we can now do the trigonometry
arctan(a/b)=theta, that is the angle we need !
the arctan function has been found on a website that resolved the problem with a polynomial approximation that works for small numbers and returns the number in degrees (exactly what we need)
Finally we just sum the resulting angle with the angle of the aFireAngle given by the <OnFireWeapon> and we have a fully working leading shot! (you can barely see the shot circled in red in the image, sorry, that's the best screenshot i could take)
The mod!
I uploaded the example code here:
http://xelerus.de/index.php?s=mod&id=709
Have fun tinkering with it
![Very Happy :D](./images/smilies/icon_biggrin.gif)