Accurate auto turrets
This mod calculates an ideal firing vector based on own position, target position, own velocity, target velocity and projectile velocity for turrets that are not controlled by a player (auto targeting, attack my target).
It works on player owned ships and only if the target is a ship.
Should work with all kinds of weapons including instant hit weapons like railguns or lasers.
This does not guarantee a hit, instead it just greatly improves hit rate compared to vanilla targeting.
Weapons are not 100% accurate which makes it impossible to have 100% hit rate when the target is far away, also
this cannot predict whether the target changes its speed while the bullet is already flying (obviously). Higher distance to target means bigger impact on hit rate if its speed changes.
– This was my first time working with lua and Avorion modding. If you encounter any issues please let me know so i can look into it
– Due to constraints when solving the quadratic equation which is necessary to calculate firing vector this won’t work when the relative velocity between target and own ship is bigger than the projectile velocity (solution for the equation would be complex in this case)
– Avorion resets entity scripts when you enter a new sector which also resets the saved turret array and thus temporarily disables this mod. The mod refreshes the turret array every ~10s to combat this so don’t worry when the mod seems to be doing nothing right after entering a sector.