Have you ever noticed that chainshot really doesn't work very well in the game? I've been working on the code to find out why and have come up with a few things.
The first thing we did was increase the range a bit, which is already in the build. At least you can fire manualy and expect to have some target effect now.
But automatic fire is pretty abysmal. I found a lot of instances where larger ships were given the same height numbers as smaller ships in the ships_init file, so autoaimed chainshot would always hit too low on these. Initial tweaks were to simply multiply the aiming height values by a set factor, but that wasn't working either, even after changes to the ships_init file.
So I had a look at the code where the aiming point is calculated. I couldn't figure out what the programmers intended until I had a quick look at the original game code, which was dirt simple. Height.Knippels.Y was how high on the target the guns aimed, and Height.Knippels.DY was the variance, such that the shot would hit between Y-DY and Y+DY randomly. The Y and DY variables are in yards.
Ok, that's simple enough, but with USE_REAL_CANNONS you'd still end up firing your guns almost straight up if you were right next to a larger enemy ship. That was the reason the Cannons_GetFireHeight() function was changed by previous modders. Unfortunately, it looks like they tried to add a range test, then started tweaking numbers until they got an effect they wanted, and the final result makes no sense. I have no idea what effect DY actually has with the current code. And it looks like the cannon ranges are given in feet, while everything else is in yards, making the calculations that much further off because that didn't seem to be taken into account.
So I simplified it again, using the original effect of Y plus or minus DY, then adjusted for minimum range and maximum elevations on the guns (5 degrees for real cannons). I'm also using the boxsize.y value for the actual target ship height (for chainshot) instead of the incorrect Y and DY values from ships_init, so that even if the numbers are wrong in ships_init the game will still fire at sails properly. I've calculated a minimum range for the firing height, based on the max elevation of the cannons (depending on the USE_REAL_CANNONS settings), and if you're under the minimum range your cannons will aim lower.
The final effect is that chainshot is now quite lethal. At least for sails. If an enemy ship decides to use chainshot against you, expect to take considerable sail damage at higher difficulties. I've seen sail values as low as 18% on enemy ships before they surrendered. It's not difficult to get enemy sails down to around 30%, and it's amusing to note that an enemy will surrender the instant your guns are loaded and ready to fire.
A side effect of changing the code is that roundshot will generally hit the hull now, instead of right on the waterline with half the shot missing. I've still got some tweaking and testing, but at least I can justify the math now.
We may end up having to tweak the overall damage multipliers to account for better aiming, but I think that's already in the user settings so it shouldn't be too difficult.
Hook
The first thing we did was increase the range a bit, which is already in the build. At least you can fire manualy and expect to have some target effect now.
But automatic fire is pretty abysmal. I found a lot of instances where larger ships were given the same height numbers as smaller ships in the ships_init file, so autoaimed chainshot would always hit too low on these. Initial tweaks were to simply multiply the aiming height values by a set factor, but that wasn't working either, even after changes to the ships_init file.
So I had a look at the code where the aiming point is calculated. I couldn't figure out what the programmers intended until I had a quick look at the original game code, which was dirt simple. Height.Knippels.Y was how high on the target the guns aimed, and Height.Knippels.DY was the variance, such that the shot would hit between Y-DY and Y+DY randomly. The Y and DY variables are in yards.
Ok, that's simple enough, but with USE_REAL_CANNONS you'd still end up firing your guns almost straight up if you were right next to a larger enemy ship. That was the reason the Cannons_GetFireHeight() function was changed by previous modders. Unfortunately, it looks like they tried to add a range test, then started tweaking numbers until they got an effect they wanted, and the final result makes no sense. I have no idea what effect DY actually has with the current code. And it looks like the cannon ranges are given in feet, while everything else is in yards, making the calculations that much further off because that didn't seem to be taken into account.
So I simplified it again, using the original effect of Y plus or minus DY, then adjusted for minimum range and maximum elevations on the guns (5 degrees for real cannons). I'm also using the boxsize.y value for the actual target ship height (for chainshot) instead of the incorrect Y and DY values from ships_init, so that even if the numbers are wrong in ships_init the game will still fire at sails properly. I've calculated a minimum range for the firing height, based on the max elevation of the cannons (depending on the USE_REAL_CANNONS settings), and if you're under the minimum range your cannons will aim lower.
The final effect is that chainshot is now quite lethal. At least for sails. If an enemy ship decides to use chainshot against you, expect to take considerable sail damage at higher difficulties. I've seen sail values as low as 18% on enemy ships before they surrendered. It's not difficult to get enemy sails down to around 30%, and it's amusing to note that an enemy will surrender the instant your guns are loaded and ready to fire.
A side effect of changing the code is that roundshot will generally hit the hull now, instead of right on the waterline with half the shot missing. I've still got some tweaking and testing, but at least I can justify the math now.
We may end up having to tweak the overall damage multipliers to account for better aiming, but I think that's already in the user settings so it shouldn't be too difficult.
Hook