Ah, right. Forgot about the multiple ricochets.
Well, assuming ricochets don't change the direction component of the velocity vector, the above method will still work no matter how many ricochets. It's the magnitude that's the problem. But it seems to me you could, assuming the dispersion is not too great in elevation, assume that the balls will all ricochet about the same time, and dock velocity (mag) of _all_ the balls after the first ricochet.
But again how would you tell _which_ balls had ricochet'd more than once?
Heck, that's the real problem, indeed.
Well, OK. Why not do a 2D distance call (current vs. ship) and, if beyond, say, 1.5x max range of the ship's guns, declare the ball to be dead and don't spawn a new one? (And otherwise do). Just make a WAG as to speed.
In sum, AFAI can tell, it's not the direction but the speed that's the problem--wait! Inspiration striketh.
Make the new direction some small frnd() from the original direction, but _don't_ try to save it, calculate a new direction _again_ on the next bounce; if the frnd() variation is small enough it'll all come out in the wash (because you're always checking vs original position) even though you still get the `semi-random`-direction bit.
Well, not quite; you could get `self-reinforcing` direction changes--but you'd have to be very (un)lucky in your successive frnd()s....
----
Right, what I'm saying is you store the fire direction _at the time of fire_, and you compute which gun battery is firing at _that_ time and correct for it in your number when you have _both_ ship position and ball starting position, and _then_ store that attribute as part of the firing character, and then check that attribute when the other ship is hit.
---
Yep, and I agree with you in cursing such lack.
But what I'm saying is, storing one attribute generalized for all balls shot at one time, while not ideal, is better'n nothing. My point for the former is that (I hope and trust) variations between balls will all shake out in the end--i.e. be "close enough for gubmint work"--and in the second, that you store the data at firing--wait.
What if you fire both chasers and a broadside at the same time!
Dang.
Well, the above method (for the latter problem) would work OK only if you fired only 1 arc at a time, because cannon balls can't be distinguished from one another.
Wait!
(LOL, this post must have the record for `second-third`-`fourth-nth` thougts...)
You don't need to distinguish between cannon balls, because you can check the aspect of both ships _vs the quadrants in which they appear_.
I.e. you don't just check the respective angles between ships, you check their positions too.
I.e. if the opponent ship is in the 1st (straight ahead) or 3rd (straight abaft) quadrant of the firing ship, then we may deduce that we are firing chasers and thus compute striking angle accordingly.
More math, but it should (I /think/...) work.
And in fact you can use the same method to determine what caliber gun to use, if you wish differing chaser and broadside armament.
All credit to Mehrunes, who first proposed this approach. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid="

" border="0" alt="par-ty.gif" />