Sometime ago, in the forum they asked about making the balls bounce when touching the sea at low angles.
That time the idea was rejected, as (IIRC) the preliminar investigation on the code seemed to indicate that this could not be possible.
Well, time to "eat the red pill" again.
The balls are created by the function (in AIBalls.c)
<i>Ball_AddBall(aref aCharacter, float fX, float fY, float fZ, float fSpeedV0, float fDirAng, float fHeightAng, float fCannonDirAng)</i>
did you notice that we are giving as parameters the position (fX,fY, fZ) the speed (fSpeedV0) and the angle (fDirAng and fHeightAng) ?
Also, there is an event associated to the collision of a ball with the sea (also in AIBalls.c)
<i>void Ball_WaterHitEvent()
{
int iCharacterIndex;
float x, y, z, vx, vy, vz;
iCharacterIndex = GetEventData();
x = GetEventData();
y = GetEventData();
z = GetEventData();
vx = GetEventData();
vy = GetEventData();
vz = GetEventData();
//if(iCharacterIndex != -1) trace("for char " + Characters[iCharacterIndex].id + " and ship " + Characters[iCharacterIndex].ship.name + " waterhit at " + x +","+y+","+z+" and v"+vx+","+vy+","+vz);
//SendMessage(&BallSplash, "lffffff", MSG_BALLSPLASH_ADD, x, y, z, 0.0, 0.0, 0.0); // vx, vy, vz
SendMessage(&BallSplash, "lffffff", MSG_BALLSPLASH_ADD, x, y, z, vx, vy, vz);
Play3DSound("ball_splash", x, y, z);
}
</i>
So. what if we add some code to void Ball_WaterHitEvent()...
- check the angle of impact with the sea (this is the hardest part, we should to calculate knowing the original angle and speed, and calculating the distance between the landing point from the original point)
- if the angle is low enough (and we should to consider the waves)
- then add a new ball - x,y,and z we get from the event data, speed and angle can be calculated.
Ale hop, bouncing balls <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" />
Now, we just need some coder-hero to do it
That time the idea was rejected, as (IIRC) the preliminar investigation on the code seemed to indicate that this could not be possible.
Well, time to "eat the red pill" again.
The balls are created by the function (in AIBalls.c)
<i>Ball_AddBall(aref aCharacter, float fX, float fY, float fZ, float fSpeedV0, float fDirAng, float fHeightAng, float fCannonDirAng)</i>
did you notice that we are giving as parameters the position (fX,fY, fZ) the speed (fSpeedV0) and the angle (fDirAng and fHeightAng) ?
Also, there is an event associated to the collision of a ball with the sea (also in AIBalls.c)
<i>void Ball_WaterHitEvent()
{
int iCharacterIndex;
float x, y, z, vx, vy, vz;
iCharacterIndex = GetEventData();
x = GetEventData();
y = GetEventData();
z = GetEventData();
vx = GetEventData();
vy = GetEventData();
vz = GetEventData();
//if(iCharacterIndex != -1) trace("for char " + Characters[iCharacterIndex].id + " and ship " + Characters[iCharacterIndex].ship.name + " waterhit at " + x +","+y+","+z+" and v"+vx+","+vy+","+vz);
//SendMessage(&BallSplash, "lffffff", MSG_BALLSPLASH_ADD, x, y, z, 0.0, 0.0, 0.0); // vx, vy, vz
SendMessage(&BallSplash, "lffffff", MSG_BALLSPLASH_ADD, x, y, z, vx, vy, vz);
Play3DSound("ball_splash", x, y, z);
}
</i>
So. what if we add some code to void Ball_WaterHitEvent()...
- check the angle of impact with the sea (this is the hardest part, we should to calculate knowing the original angle and speed, and calculating the distance between the landing point from the original point)
- if the angle is low enough (and we should to consider the waves)
- then add a new ball - x,y,and z we get from the event data, speed and angle can be calculated.
Ale hop, bouncing balls <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" /> <img src="style_emoticons/<#EMO_DIR#>/bounce.gif" style="vertical-align:middle" emoid=":b:" border="0" alt="bounce.gif" />
Now, we just need some coder-hero to do it
