One fun aspect of Sid Meier's Pirates is that the wind mostly blew to the west, leading to interesting strategic choices for the player in deciding their trade routes. Also, for privateer hunting, it would factor into their ship sail type and the direction of possible escapes/targets/friendly ports.
From some research, it does seem in the real world winds in the Caribbean tend to blow towards the west: Caribbean Weather
WITH A TOGGLE I think having a tendency for winds to usually blow to the west could be interesting for the mod as well.
One interesting fact--Sid Meier's Pirates, on the lowest difficulty level, winds always blew exactly west, and they became more variable as difficulty level increased. In other words, for those who choose to play with them on, predictability of winds actually might reduce difficulty in ways, but really only insofar as they lead the player to be able to take advantage of intelligent strategic choices--which seems a really good thing!
At any rate, I think it is worth trying--shouldn't be any harm with a toggle. Of course, if needed I can try it first as part of the experimental version I maintaining if needed.
I spent a couple of hours trying to figure this out tonight, but didn't have much luck on my own. I am hoping I can request some advice and assistance?
I went over all the weather files, and here are the parts I thought looked relevant (also, the two files attached):
In WhrGeneration we have
But why is it called "old"? Because it is initial value, or because it will be changed later?
And
rWindA = frand(MAX_ANGLECHANGE)
and
fWeatherAngleOld = fWindA;
and
Globals defines some of these values:
#define PIm2 6.283185307179586476925286766559 // 6.28318530
#define PId2 1.5707963267948966192313216916398 // 1.57079632
in WhrWeather.c we have
Weather.Wind.Angle = Whr_GetFloat(aCurWeather,"Wind.Angle");
and later
fWeatherDelta = 0.0;
fWeatherAngle = stf(Weather.Wind.Angle);
And then for changes we have
Could anyone help me understand this code better? I think I have the general idea--an initial wind direction is generated, and then over time changed according to the last bit of code I quoted. But I'm having troulble grasping the specific, as well as how to weight it towards a particular direction.
I guess it would have to be weighted more likely to the west in two places, first in the initial wind generation, and then in the onwindchange part when it slowly changes direction, so it both is more likely to start west and also drift towards west over time? Or if I could find where the final wind is used in game, I guess I could just scale that number to a new wind range that is mostly to the west? I'm just trying to figure out how to get started, so I can then finetune the values through extensive playtesting, but I'm not sure how to begin.
Thanks so much for any help or advice.
From some research, it does seem in the real world winds in the Caribbean tend to blow towards the west: Caribbean Weather
WITH A TOGGLE I think having a tendency for winds to usually blow to the west could be interesting for the mod as well.
One interesting fact--Sid Meier's Pirates, on the lowest difficulty level, winds always blew exactly west, and they became more variable as difficulty level increased. In other words, for those who choose to play with them on, predictability of winds actually might reduce difficulty in ways, but really only insofar as they lead the player to be able to take advantage of intelligent strategic choices--which seems a really good thing!
At any rate, I think it is worth trying--shouldn't be any harm with a toggle. Of course, if needed I can try it first as part of the experimental version I maintaining if needed.
I spent a couple of hours trying to figure this out tonight, but didn't have much luck on my own. I am hoping I can request some advice and assistance?
I went over all the weather files, and here are the parts I thought looked relevant (also, the two files attached):
In WhrGeneration we have
Code:
//Traceandlog("WhrInit.c : Whr_Generator() called -- gWeatherInit: " +gWeatherInit); //JL - Figuring out this weather system
bool bWhrTornado = false;
bool bWhrStorm = false;
if(gWeatherInit == 1){
goldRain = rand(100);
goldFog = rand(20);
// oldWind = rand(30);
oldWind = rand(25) + 5; // LDH 09Feb09
fWeatherAngleOld = frand(PIm2);
But why is it called "old"? Because it is initial value, or because it will be changed later?
And
rWindA = frand(MAX_ANGLECHANGE)
and
fWeatherAngleOld = fWindA;
and
Code:
string direction1, direction2, direction3;
fSeaA = PIm2 - fWindA;
if (fSeaA >= (3.0 * PId2))
{
fSeaB = (fSeaA + PId2 - PIm2);
}
else
{
fSeaB = fSeaA + PId2;
}
Weathers.Wind.Angle = fWindA;
Weathers.Wind.Speed.Min = minwind;
Weathers.Wind.Speed.Max = maxwind;
direction1 = fts(fSeaB, 4);
direction2 = fts((fSeaB + (PId2 / 2.0)), 4);
direction3 = fts((fSeaB - (PId2 / 2.0)), 4);
Globals defines some of these values:
#define PIm2 6.283185307179586476925286766559 // 6.28318530
#define PId2 1.5707963267948966192313216916398 // 1.57079632
in WhrWeather.c we have
Weather.Wind.Angle = Whr_GetFloat(aCurWeather,"Wind.Angle");
and later
fWeatherDelta = 0.0;
fWeatherAngle = stf(Weather.Wind.Angle);
And then for changes we have
Code:
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;
}
Could anyone help me understand this code better? I think I have the general idea--an initial wind direction is generated, and then over time changed according to the last bit of code I quoted. But I'm having troulble grasping the specific, as well as how to weight it towards a particular direction.
I guess it would have to be weighted more likely to the west in two places, first in the initial wind generation, and then in the onwindchange part when it slowly changes direction, so it both is more likely to start west and also drift towards west over time? Or if I could find where the final wind is used in game, I guess I could just scale that number to a new wind range that is mostly to the west? I'm just trying to figure out how to get started, so I can then finetune the values through extensive playtesting, but I'm not sure how to begin.
Thanks so much for any help or advice.
Attachments
Last edited: