• 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!

The Wind Guessing Game

Sharks Prize

Master Mariner
I hope this hasn't been talked about yet. if it has, I sure didn't see it.

It really annoys me how the wind direction in the map and sea modes are different. I can be running with the wind in the map mode, come across a ship I want to attack, and when I get into sea mode the wind is blowing right in my face.

It makes sense that the wind should be in the same direction in both modes, for realism. It was that way in Sid Meier's Pirates!, and it worked wonderfully. I could usually place my self in a strategic position in relation to the wind so as to give my ship a tactical advantage in battle.

Is it possible to make a mod that dictates the sea wind direction based on what the map wind direction was when you left map mode? Heck, if it's not too hard I might try it myself. But I could use some advice from some folks who know what they're talking about (i.e., not me) before I go nosing around in the code. I wouldn't even know what file to start on.
 
Not sure how you will get the wind to be generated to simulate the world map conditions but i would expect some things your looking for to be in worldmap_init located in Age of Pirates 2\Program\WorldMap and there are other files in that area that might have some other lines of codes that need ultering also some files should need altering in C:\Program Files\Age of Pirates 2\Program\Weather and Age of Pirates 2\Program\Weather\init.
 
Well, I'm seeing things like the following:

In program\weather\whrweather.c -

object Weathers[MAX_WEATHERS];

extern int InitWeather();

#event_handler("EWhr_GetWindAngle", "Whr_GetWindAngle");
#event_handler("EWhr_GetWindSpeed", "Whr_GetWindSpeed");
#event_handler("EWhr_GetShadowDensity", "Whr_GetShadowDensity");
#event_handler("EWhr_GetFogDensity", "Whr_GetFogDensity");
#event_handler("WeatherTimeUpdate", "Whr_TimeUpdate" );

Later in same file -

DelEventHandler("frame","Whr_OnWindChange");

Even later is same file. This one looks like maybe what I want -

if(CheckAttribute(pchar, "wind.angle"))
{
Weather.Wind.Angle = pchar.wind.angle;
//DeleteAttribute(pchar, "wind.angle");
}
else
{
Weather.Wind.Angle = frand(PIm2);// Áëèí!!! ýòî íå ãðàäóñû!!!!! frand(180.0);//Whr_GetFloat(aCurWeather,"Wind.Angle");
pchar.wind.angle = Weather.Wind.Angle;
}

if (CheckAttribute(pchar, "wind.speed"))
{
Weather.Wind.Speed = pchar.wind.speed;
//DeleteAttribute(pchar, "wind.speed");
}
else
{
Weather.Wind.Speed = Whr_GetFloat(aCurWeather,"Wind.Speed");
pchar.wind.speed = Weather.Wind.Speed;
}

pchar.quest.EraseWind.win_condition.l1 = "ExitFromSea";
pchar.quest.EraseWind.win_condition = "EraseWind";

Still same file -

Weather.isDone = "";

SetEventHandler(WEATHER_CALC_FOG_COLOR,"Whr_OnCalcFogColor",0);
SetEventHandler("frame","Whr_OnWindChange",0);

fFogDensity = stf(Weather.Fog.Density);

fWeatherDelta = 0.0;
fWeatherAngle = stf(Weather.Wind.Angle);
//fWeatherAngle = GetAngleY(stf(worldMap.WindX), stf(worldMap.WindZ));
fWeatherSpeed = stf(Weather.Wind.Speed);

I think this next part only applies to tornadoes -

if (bWhrTornado) { WhrCreateTornadoEnvironment(); }

Particles.windpower = 0.05 * Clampf(Whr_GetWindSpeed() / WIND_NORMAL_POWER);
Particles.winddirection.x = sin(Whr_GetWindAngle());
Particles.winddirection.z = cos(Whr_GetWindAngle());

Still whrweather.c -

void Whr_OnWindChange()
{
float fDeltaTime = MakeFloat(GetDeltaTime()) * 0.001;
fWeatherDelta = fWeatherDelta + fDeltaTime;

float fSpd = fWeatherSpeed + (fWeatherSpeed / 6.0) * 0.1 * (sin(fWeatherDelta) + sin(0.2 * fWeatherDelta) + sin(PI + 0.8 * fWeatherDelta) + cos(1.5 * fWeatherDelta));
float fAng = fWeatherAngle + 0.02 * (sin(fWeatherDelta) + sin(0.2 * fWeatherDelta) + sin(PI + 0.8 * fWeatherDelta) + cos(1.5 * fWeatherDelta));

Weather.Wind.Angle = fAng;
Weather.Wind.Speed = fSpd;

whrweather.c seems to have lots of wind stuff. Here's more -


float Whr_GetWindAngle()
{
if (!CheckAttribute(&Weather,"Wind.Angle")) { return 0.0; }
return stf(Weather.Wind.Angle);
}

float Whr_GetWindSpeed()
{
if (!CheckAttribute(&Weather,"Wind.Speed")) { return 3.0; }
return stf(Weather.Wind.Speed);

More -

void Whr_WindChange()
{
aref aCurWeather = GetCurrentWeather();

if(CheckAttribute(pchar, "wind.angle"))
{
Weather.Wind.Angle = stf(pchar.wind.angle) + frand((PI/4.0)) - (PI / 8.0);
if (stf(Weather.Wind.Angle) < 0) Weather.Wind.Angle = PIm2 + stf(Weather.Wind.Angle);
}
else
{
Weather.Wind.Angle = frand(PIm2);
}
pchar.wind.angle = Weather.Wind.Angle;

Weather.Wind.Speed = Whr_GetFloat(aCurWeather,"Wind.Speed");
pchar.wind.speed = Weather.Wind.Speed;

pchar.quest.EraseWind.win_condition.l1 = "ExitFromSea";
pchar.quest.EraseWind.win_condition = "EraseWind";

fWeatherAngle = stf(Weather.Wind.Angle);
fWeatherSpeed = stf(Weather.Wind.Speed);

That seems to be all for whrweather.c. Quite alot more than I expected. Sorry if I posted it in a confusing way.
 
Back
Top