• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Bouncing balls !?

kblack

Landlubber
Storm Modder
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 :)
 
Sounds like a fun idea. And it sounds possible as well. Nice. <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
How would we handel the new range and damage factors here? there would be consciderable energy loss so maybe half damage? Also is this in effect replacing the origional shot with a newly generated one at the point of impact with the water or can its trajectory be changed at the impact site?
 
<!--quoteo(post=149076:date=May 24 2006, 05:32 PM:name=Jason Maffettone)--><div class='quotetop'>QUOTE(Jason Maffettone @ May 24 2006, 05:32 PM) [snapback]149076[/snapback]</div><div class='quotemain'><!--quotec-->
How would we handel the new range and damage factors here? there would be consciderable energy loss so maybe half damage? Also is this in effect replacing the origional shot with a newly generated one at the point of impact with the water or can its trajectory be changed at the impact site?
<!--QuoteEnd--></div><!--QuoteEEnd-->


You'll have to invoque Balls_AddBall with a new set of parameters, being x,y, and z the values assigned by GetEventData().

About changing damage, IIRC the damage is calculated using:
1 - distance
2 - attitude (i.e. raking)
3 - cannon that has fired

1 will change, as distance will be calculated from the water hit point
2 will maintain... if it's raking, it will be raking after bouncing
3 is the most difficult: either you define a new cannon type (i.e WATER_CANNON). Either you add a new attribute to Balls object to indicate that it's a "bouncing" ball.

HTH
 
Back
Top