Hi Sailors,
I was unhappy with my schooner running slower abeam than before the wind, so I imported the real sailing mod from the POTC build series into AOP.
What you need:
Supermod v1.1 with updates 1 and 2
new sinking system mod and officers fix
Then just replace the AIShip.c in the Program/sea_ai folder.
Of course you can also replace the functions by hand, if your AIShip.c is otherwise different than this one (only changed things between Hawkeye --> and Hawkeye <---).
Have fun with it and feel free to play with the values in Ships_ini.c (the fWindAgainstSpeed is the key value) in case your fav vessel does not behave like she should. (I only made sure, the schooner and the big square riggers are identical, especially the barque is a little different in this one because of her value of 3, should perhaps be 1 or 2 like other square riggers)
Also, the mysterious function RS_GetRigTypeDivisor() from the POTC Build mods is _not_ modelled in this piece, since I don't know, how the engine is behaving. Needs testing, I think...
Please do write comments, or improve it yourselves.
And of course I don't claim credits for this one, since it was just copying and some minor fixing.
All thanks to NK, I think he wrote the original functions.
edit:
Hmm, can't seem to find the file. Maybe I post the code itself:
You have to change the AIShip.c between the lines:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
if (fWindDotShip >= 0.0)
<!--c2--></div><!--ec2-->
and
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
fMaxSpeedZ = fMaxSpeedZ * (0.75 - fWindDotShip/3 - pow(abs(fWindDotShip), fWindAgainstSpeed));
<!--c2--></div><!--ec2-->
or just comment them out.
Then insert:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
// Hawkeye -->
// okay, here is the REAL_SAILING stuff
// first get best point and closest point based on that fWindAgainstSpeed thingy
// doing that with a simple linear formula and the values of the Schooner and the big square riggers from POTC as fix points:
float fClosestPoint = (0.45 / 7) - 0.25 - (0.45 / 7) * fWindAgainstSpeed;
float fBestPoint = (0.5 / 7) + 0.75 - (0.5 / 7) * fWindAgainstSpeed;
// that way, the Schooner and the big ships will sail as in POTC and the others will differ a bit due to fWindAgainstSpeed in Ships_init.c
// beware: fWindDotShip != fOffWind from POTC!!
// (fWindDotShip is 0 when wind from abeam, 1 when running before wind
// while fOffWind was 0.5 when from abeam and 1 when before wind)
// calculate max speed scalar running before wind (linear function of fWindAgainstSpeed)
float fRBWMax = -0.01371 * fWindAgainstSpeed + 0.9187;
// calculate max speed scalar on a beam reach (lin fct(fWAS))
float fBeam = 0.09171 * fWindAgainstSpeed + 0.4263;
// calc min speed scalar on tack (again lin fct)
float fTackSpeed = 0.03386 * fWindAgainstSpeed + 0.3741;
// all prev speed scalars are calculated so that resulting scalars for Schooner and big ships will be the same as in POTC,
// others not necessarily equal, but in same order of magnitude, as the physicist says
// okay, that is the fore play, now I will just copy the code of the original REAL_SAILING mod
// with some changes to account for different fOffWind thingy
// (fOffWind_POTC = 0.5 * (fWindDotShip_AOP - 1)
// also had to replace the defines (RS_CP_OFFSET and RS_BACKWIND) with the actual values 0.04 (doubled because of different angles) resp. -0.25
// (otherwise the ENGINE.EXE would not run the code on my machine)
//begin speedscalar calcs
float fTempSpeedZ = 1.0; // PRS3 and below
//reorganized we only do one b2r calc.
if(fWindDotShip > fBestPoint) fTempSpeedZ = Bring2Range(1.0, fRBWMax, fBestPoint, 1.0, fWindDotShip); //scale speedscalar between best point of sail and running before the wind
else
{
if(fWindDotShip > 0) fTempSpeedZ = Bring2Range(fBeam, 1.0, 0, fBestPoint, fWindDotShip); //scale speedscalar between beam reach and best point of sail
else
{
if(fWindDotShip > fClosestPoint + 0.04) fTempSpeedZ = Bring2Range(fTackSpeed, fBeam, fClosestPoint + 0.04, 0, fWindDotShip); //fixed by Hook
//scale speedscalar between closest point of sail and beam reach.
else
{
if(fWindDotShip > fClosestPoint - 0.04) fTempSpeedZ = Bring2Range(0.0, fTackSpeed, fClosestPoint - 0.04, fClosestPoint + 0.04, fWindDotShip); //ramp quickly from 0 to min speed with wind
else //if(fOffWind <= fClosestPoint - RS_CP_OFFSET). Because that's the only thing it _can_ be.
{
if (fClosestPoint < -0.4) fTempSpeedZ = Bring2Range(-0.25, 0.0, 0.0, fClosestPoint - 0.04, fWindDotShip); //allow backwards travel
else fTempSpeedZ = 0.0; //if not square rigged, can't be pushed back
}
}
}
}
//end speedscalar calcs
// and finally adjust fMaxSpeedZ
fMaxSpeedZ = fMaxSpeedZ * fTempSpeedZ;
// JK <--
<!--c2--></div><!--ec2-->
That's it.
I was unhappy with my schooner running slower abeam than before the wind, so I imported the real sailing mod from the POTC build series into AOP.
What you need:
Supermod v1.1 with updates 1 and 2
new sinking system mod and officers fix
Then just replace the AIShip.c in the Program/sea_ai folder.
Of course you can also replace the functions by hand, if your AIShip.c is otherwise different than this one (only changed things between Hawkeye --> and Hawkeye <---).
Have fun with it and feel free to play with the values in Ships_ini.c (the fWindAgainstSpeed is the key value) in case your fav vessel does not behave like she should. (I only made sure, the schooner and the big square riggers are identical, especially the barque is a little different in this one because of her value of 3, should perhaps be 1 or 2 like other square riggers)
Also, the mysterious function RS_GetRigTypeDivisor() from the POTC Build mods is _not_ modelled in this piece, since I don't know, how the engine is behaving. Needs testing, I think...
Please do write comments, or improve it yourselves.
And of course I don't claim credits for this one, since it was just copying and some minor fixing.
All thanks to NK, I think he wrote the original functions.
edit:
Hmm, can't seem to find the file. Maybe I post the code itself:
You have to change the AIShip.c between the lines:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
if (fWindDotShip >= 0.0)
<!--c2--></div><!--ec2-->
and
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
fMaxSpeedZ = fMaxSpeedZ * (0.75 - fWindDotShip/3 - pow(abs(fWindDotShip), fWindAgainstSpeed));
<!--c2--></div><!--ec2-->
or just comment them out.
Then insert:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
// Hawkeye -->
// okay, here is the REAL_SAILING stuff
// first get best point and closest point based on that fWindAgainstSpeed thingy
// doing that with a simple linear formula and the values of the Schooner and the big square riggers from POTC as fix points:
float fClosestPoint = (0.45 / 7) - 0.25 - (0.45 / 7) * fWindAgainstSpeed;
float fBestPoint = (0.5 / 7) + 0.75 - (0.5 / 7) * fWindAgainstSpeed;
// that way, the Schooner and the big ships will sail as in POTC and the others will differ a bit due to fWindAgainstSpeed in Ships_init.c
// beware: fWindDotShip != fOffWind from POTC!!
// (fWindDotShip is 0 when wind from abeam, 1 when running before wind
// while fOffWind was 0.5 when from abeam and 1 when before wind)
// calculate max speed scalar running before wind (linear function of fWindAgainstSpeed)
float fRBWMax = -0.01371 * fWindAgainstSpeed + 0.9187;
// calculate max speed scalar on a beam reach (lin fct(fWAS))
float fBeam = 0.09171 * fWindAgainstSpeed + 0.4263;
// calc min speed scalar on tack (again lin fct)
float fTackSpeed = 0.03386 * fWindAgainstSpeed + 0.3741;
// all prev speed scalars are calculated so that resulting scalars for Schooner and big ships will be the same as in POTC,
// others not necessarily equal, but in same order of magnitude, as the physicist says

// okay, that is the fore play, now I will just copy the code of the original REAL_SAILING mod
// with some changes to account for different fOffWind thingy
// (fOffWind_POTC = 0.5 * (fWindDotShip_AOP - 1)
// also had to replace the defines (RS_CP_OFFSET and RS_BACKWIND) with the actual values 0.04 (doubled because of different angles) resp. -0.25
// (otherwise the ENGINE.EXE would not run the code on my machine)
//begin speedscalar calcs
float fTempSpeedZ = 1.0; // PRS3 and below
//reorganized we only do one b2r calc.
if(fWindDotShip > fBestPoint) fTempSpeedZ = Bring2Range(1.0, fRBWMax, fBestPoint, 1.0, fWindDotShip); //scale speedscalar between best point of sail and running before the wind
else
{
if(fWindDotShip > 0) fTempSpeedZ = Bring2Range(fBeam, 1.0, 0, fBestPoint, fWindDotShip); //scale speedscalar between beam reach and best point of sail
else
{
if(fWindDotShip > fClosestPoint + 0.04) fTempSpeedZ = Bring2Range(fTackSpeed, fBeam, fClosestPoint + 0.04, 0, fWindDotShip); //fixed by Hook
//scale speedscalar between closest point of sail and beam reach.
else
{
if(fWindDotShip > fClosestPoint - 0.04) fTempSpeedZ = Bring2Range(0.0, fTackSpeed, fClosestPoint - 0.04, fClosestPoint + 0.04, fWindDotShip); //ramp quickly from 0 to min speed with wind
else //if(fOffWind <= fClosestPoint - RS_CP_OFFSET). Because that's the only thing it _can_ be.
{
if (fClosestPoint < -0.4) fTempSpeedZ = Bring2Range(-0.25, 0.0, 0.0, fClosestPoint - 0.04, fWindDotShip); //allow backwards travel
else fTempSpeedZ = 0.0; //if not square rigged, can't be pushed back
}
}
}
}
//end speedscalar calcs
// and finally adjust fMaxSpeedZ
fMaxSpeedZ = fMaxSpeedZ * fTempSpeedZ;
// JK <--
<!--c2--></div><!--ec2-->
That's it.