Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally for random accuracy I tried using to simply get a a random position in the rectangle encompassing the target's image, but that gave unfair advantage to elongated ships(like most empire ships) when facing the enemy.
I ended up creating a method that more or less follows the shape and orientation of the target. When the space objects are loaded at the start, a rectangle size is calculated that is encompassing the trimmed images of the object. This rectangle is then used when aiming at targets. First get a random point in that rectangle then rotate the point around the object's center to follow the orientation of the target image and use that point as on offset when aiming. This of course has little effect on objects that fit in a square.
(Maybe using an oval area based on the trimmed rectangle to get the random point could work better.)
Here's a video showing this with the Thorin, the green dots used for debugging are showing the positions projectiles are aiming at:
Thorin test
I also added some fluctuation to the weapon delays when firing. This gives it more "realistic(?)" feeling that was missing in open-ig. When a weapon fires a random multiplier between 0.5-1.5 is applied to the cooldown. I tried smaller ranges but they did not have the desired effect.
Some videos to illustrate:
Original for reference
This PR
OpenIG-master
Some additional videos with no sound:
Large battle this PR(with debug dots)
Large battle OG IG