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

Need Help wave and ship interaction

Hylie Pistof

Curmudgeon
QA Tester
Storm Modder
Pirate Legend
Been playing COAS for a bit now and one thing that bothers me is the way the ships jerk around in the waves instead of moving smoothly up and down and such.

This jerky ship motion came up in POTC and a file was found that has harmonics that can be adjusted.

What they do is make the waves more spikey or more rounder. Spikey waves look good but the ship jerks around and looks bad. The round roller type waves let the ship move smoothly and realistically. There was some debate when this file was discovered and it was decided to have mostly roundish waves and mostly smoothish ship action.

Well, COAS has the spikey waves and jerky ships. I looked in the folder where these files are kept and COAS does not have that particular file.

So, is the file for adjusting the wave/ship interaction somewhere else or has it been hard coded into the engine now?

In POTC the file is POTC--->program--->weather--->WhrGeneration.c. In COAS this file is missing, but the other files are there.
 
Have a look through the other files in the Weather folder. I suspect it should still be hiding in there somewhere....
 
Yep that file doesn't exist in COAS, it could have been merged into one of the weather files or maybe removed altogether.

Looking around here is what I have found, some of which might not be of any use, so bare with me I've only ever changed the weather in the weather files.

In globals.c
Code:
int MaxVertices = 32000;//32000;//16000;//8000;//4000
int MaxIndices = 33200;//33200;//17200;//9200;//5200
float GridStepX = 0.1;
float GridStepPC = 0.1;
float MaxWaveDistance = 4000.0;//4000.0;//3000.0;//2000.0;//1000.0
float LodScale = 0.7;//0.7;//1.2;//2.0;//4.0

WhrSea.c
Code:
void WhrDeleteSeaEnvironment()
{
	DeleteAttribute(&Sea,"");
}
	
void WhrCreateSeaEnvironment()
{
	aref	aCurWeather = GetCurrentWeather();
	aref	aSea; makearef(aSea,aCurWeather.Sea);
	aref	aSea2; makearef(aSea2, aCurWeather.Sea2);
	aref	aCommon; makearef(aCommon, WhrCommonParams.Sea);
	int   i;
	float fMaxSeaHeight;

	if (CheckAttribute(&Sea,"MaxSeaHeight")) { fMaxSeaHeight = stf(Sea.MaxSeaHeight); }
	DeleteAttribute(&Sea,"");

	Sea.Clear = "";

	Sea.Transparency = Whr_GetFloat(aSea,"Transparency");
	Sea.FrenelCoefficient = Whr_GetFloat(aSea,"FrenelCoefficient");
	Sea.WaterReflection = Whr_GetFloat(aSea,"WaterReflection");
	Sea.WaterAttenuation = Whr_GetFloat(aSea,"WaterAttenuation");

	Sea.Sea2.BumpScale = Whr_GetFloat(aSea2, "BumpScale");

	ref mchr = GetMainCharacter();
	string sLocation = mchr.location;

	float FogDensity = 1.0;
	float FogSeaDensity = 1.0

	if (FindLocation(sLocation) != -1)
	{
		/*if(CheckAttribute(&locations[FindLocation(sLocation)], "fastreload"))
		{*/
			Sea.LodScale = 32.0;
			Sea.MaxVertices = 1000;
			Sea.MaxIndices = 1300;
			Sea.MaxWaveDistance = 10.0;
			Sea.MaxDim = 65536;
			Sea.MinDim = 64;
			Sea.GridStep = GridStepPC*5.0;
			if (CheckAttribute(aCurWeather, "Storm") && sti(aCurWeather.Storm) == true)
			{
				fMaxSeaHeight = 2.0;
			}
			else
            {
				fMaxSeaHeight = 0.5;
			}
			FogDensity = 20.0;
			FogSeaDensity = 20.0;

			Sea.Sea2.LodScale = 2.0;
			Sea.Sea2.GridStep = 0.15;
			Sea.Sea2.BumpScale = 0.3;
		/*}
		else
		{
			Sea.LodScale = 8.0;
			Sea.MaxVertices = 2000;
			Sea.MaxIndices = 2600;
			Sea.MaxWaveDistance = 1000.0;
			Sea.MaxDim = 65536;
			Sea.MinDim = 64;
			Sea.GridStep = GridStepPC;
			fMaxSeaHeight = 0.5;// boal áóõòû çàòàïëèâàåò 5.0;
			Sea.Sea2.LodScale = 2.0;
			Sea.Sea2.GridStep = 0.15;
			//SetSeaSettings();
		}*/
	}
	else
	{
        if (CheckAttribute(aCurWeather, "Storm") && sti(aCurWeather.Storm) == true)
		{
		    SetSeaSettings();
			fMaxSeaHeight = 200.0;
			Log_TestInfo("Øòîðì âêëþ÷åí, âîëíû ïî Ìàõ ðàçðåøåíû");
		}
		else
		{
			i = FindIsland(sLocation);
			if ( i != -1)
			{
				Sea.LodScale = 4.0;
				Sea.MaxVertices = 4000;
				Sea.MaxIndices = 5200;
				Sea.MaxWaveDistance = 1000.0;
				Sea.MaxDim = 65536;
				Sea.MinDim = 64;
				Sea.GridStep = GridStepPC;
				fMaxSeaHeight = SetMaxSeaHeight(i); //boal
				Sea.Sea2.LodScale = 1.0;
				Sea.Sea2.GridStep = 0.15;
			}
			else
			{
				SetSeaSettings();
				fMaxSeaHeight = 200.0;
			}
		}
	}
	Sea.Lights = aCurWeather.Lights;

	Sea.Water.Color = Whr_GetColor(aSea,"Water.Color");

	Sea.Sun.Color = Whr_GetColor(aCurWeather,"Sun.Color");
	Sea.Sun.HeightAngle = Whr_GetFloat(aCurWeather,"Sun.HeightAngle");
	Sea.Sun.AzimuthAngle = Whr_GetFloat(aCurWeather,"Sun.AzimuthAngle");

	string sCurFog = Whr_GetCurrentFog();
	Sea.Fog.Color = Whr_GetColor(aCurWeather, sCurFog + ".Color");
	Sea.Fog.Enable = Whr_GetLong(aCurWeather, sCurFog + ".Enable");
	Sea.Fog.Start = Whr_GetFloat(aCurWeather, sCurFog + ".Start");
	Sea.Fog.Density = Whr_GetFloat(aCurWeather, sCurFog + ".Density") * FogDensity;
	Sea.Fog.SeaDensity = Whr_GetFloat(aCurWeather, sCurFog + ".SeaDensity") * FogSeaDensity;
	
	Sea.Pena.Color = Whr_GetColor(aSea,"Pena.Color");
	Sea.Pena.DepthSmall = 20.0;
	Sea.Pena.DepthBig = 20.0;
	Sea.Pena.BigIslandMultiply = Whr_GetFloat(aCommon, "Pena.BigIslandMultiply");
	Sea.Pena.SmallIslandMultiply = Whr_GetFloat(aCommon, "Pena.SmallIslandMultiply");
	
	Sea.Bump.Dir = Whr_GetString(aSea, "Bump.Dir");
	Sea.Bump.Tile = Whr_GetFloat(aSea, "Bump.Tile");
	Sea.Bump.Ang = Whr_GetFloat(aSea, "Bump.Ang");
	Sea.Bump.Speed = Whr_GetFloat(aSea, "Bump.Speed");
	Sea.Bump.Scale = Whr_GetFloat(aSea, "Bump.Scale");
	Sea.Bump.AnimSpeed = Whr_GetFloat(aSea, "Bump.AnimSpeed");
	Sea.Bump.MipLevels = 4;
	Sea.Bump.Size = 128;

	Sea.GF2MX.BumpDir = Whr_GetString(aSea, "GF2MX.Bump.Dir");
	Sea.GF2MX.BumpTile = Whr_GetFloat(aSea, "GF2MX.Bump.Tile");
	Sea.GF2MX.BumpAnimSpeed = Whr_GetFloat(aSea, "GF2MX.Bump.AnimSpeed");
	Sea.GF2MX.WaterColor = Whr_GetColor(aSea, "GF2MX.Water.Color");
	Sea.GF2MX.SkyColor = Whr_GetColor(aSea, "GF2MX.Sky.Color");

	Sea.GF3.BumpDir = Whr_GetString(aSea, "Bump.Dir");
	Sea.GF3.BumpTile = Whr_GetFloat(aSea, "Bump.Tile");
	Sea.GF3.BumpAnimSpeed = Whr_GetFloat(aSea, "Bump.AnimSpeed");
	Sea.GF3.WaterColor = Whr_GetColor(aSea, "Water.Color");
	Sea.GF3.SkyColor = Whr_GetColor(aSea, "Sky.Color");

	// Sun road section
	Sea.Road.Start = Whr_GetFloat(aSea, "SunRoad.Start");
	Sea.Road.Color1 = Whr_GetColor(aSea, "SunRoad.Color1");
	Sea.Road.Color2 = Whr_GetColor(aSea, "SunRoad.Color2");
	Sea.Road.Power = Whr_GetFloat(aSea, "SunRoad.Power");

	if (CheckAttribute(aSea, "SunRoad.Special"))
	{
		Sea.Sun.HeightAngle = Whr_GetFloat(aSea, "SunRoad.Special.HeightAngle");
		Sea.Sun.AzimuthAngle = Whr_GetFloat(aSea, "SunRoad.Special.AzimuthAngle");
	}

	Sea.CubeMap.Size = 512;	
	Sea.CubeMap.VectorsSize = 256;
	
	Sea.CubeMap.Format = "r5g6b5";

	Sea.Sky.Color = Whr_GetColor(aSea, "Sky.Color");

	// harmonics
	aref aHarmonics; makearef(aHarmonics, aSea.Harmonics);
	int iNumHarmonics = GetAttributesNum(aHarmonics);
	for (i=0;i<iNumHarmonics;i++)
	{
		aref aHarmonic = GetAttributeN(aHarmonics,i);
		string sTemp = "h" + i;
		Sea.Harmonics.(sTemp) = GetAttributeValue(aHarmonic);
	}

	// Advanced Sea initialize
	Sea.Sea2.WaterColor = Whr_GetColor(aSea2, "WaterColor");
	Sea.Sea2.SkyColor = Whr_GetColor(aSea2, "SkyColor");

	Sea.Sea2.Amp1 = Whr_GetFloat(aSea2, "Amp1");
	Sea.Sea2.AnimSpeed1 = Whr_GetFloat(aSea2, "AnimSpeed1");
	Sea.Sea2.Scale1 = Whr_GetFloat(aSea2, "Scale1");
	Sea.Sea2.MoveSpeed1 = Whr_GetString(aSea2, "MoveSpeed1");

	Sea.Sea2.Amp2 = Whr_GetFloat(aSea2, "Amp2");
	Sea.Sea2.AnimSpeed2 = Whr_GetFloat(aSea2, "AnimSpeed2");
	Sea.Sea2.Scale2 = Whr_GetFloat(aSea2, "Scale2");
	Sea.Sea2.MoveSpeed2 = Whr_GetString(aSea2, "MoveSpeed2");

	Sea.Sea2.PosShift = Whr_GetFloat(aSea2, "PosShift");
	
	Sea.Sea2.Reflection = Whr_GetFloat(aSea2, "Reflection");
	Sea.Sea2.Transparency = Whr_GetFloat(aSea2, "Transparency");
	Sea.Sea2.Attenuation = Whr_GetFloat(aSea2, "Attenuation");
	Sea.Sea2.Frenel = Whr_GetFloat(aSea2, "Frenel");

	Sea.Sea2.SimpleSea = sti(InterfaceStates.SimpleSea);

	Sea.MaxSeaHeight = fMaxSeaHeight;
	Sea.isDone = "";
	//Log_TestInfo("Whether Sea.MaxSeaHeight " + Sea.MaxSeaHeight);
	
	// boal 14/09/06 çàïîìèíàåì ñòðåäíþþ âîëíó äëÿ ìîðÿ (íå ëîêàöèè)
	if (bSeaActive && !bAbordageStarted)
	{
		pchar.SystemInfo.ScaleSeaHeight = GetScaleSeaHeight();
	}
}

void SetSeaSettings()
{
	Sea.LodScale = LodScale;
	Sea.MaxVertices = MaxVertices;
	Sea.MaxIndices = MaxIndices;
	Sea.MaxWaveDistance = MaxWaveDistance;
	Sea.MaxDim = 65536;
	Sea.MinDim = 128;
	//Sea.GridStep = GridStepPC;
	Sea.GridStep = 0.1 + 0.1 * (1.0 - stf(InterfaceStates.SeaDetails));

	Sea.Sea2.LodScale = 0.5;
	Sea.Sea2.GridStep = 0.07 + 0.1 * (1.0 - stf(InterfaceStates.SeaDetails));
}

void SetSeaGridStep(float SeaDetails)
{
	if (!IsEntity(&Sea)) { return; }

	ref mchr = GetMainCharacter();
	string sLocation = mchr.location;

	// if current location is land - return
	if(FindLocation(sLocation) != -1)
	{
		if(CheckAttribute(&locations[FindLocation(sLocation)], "fastreload"))
		{
			return;
		}
	}

	Sea.Sea2.GridStep = 0.07 + 0.1 * (1.0 - SeaDetails);

	Sea.Sea2.SimpleSea = sti(InterfaceStates.SimpleSea);
}

// boal 14.09.06 îòíîñèòåëüíàÿ âûñîòà âîëíû
float GetScaleSeaHeight()
{
	/*
	èç ÿäðà
	float fScale = (fMaxSeaHeight >= _fAmp1 + _fAmp2) ? 1.0f : fMaxSeaHeight / (_fAmp1 + _fAmp2);

		fAmp1 = _fAmp1 * fScale;
		fAmp2 = _fAmp2 * fScale;
		
    áóäåè ñ÷èòàòü ñðåäíþþ âîëíó êàê (à1 + à2)/2
	*/
	float fMaxSeaHeight = 0.0;

	if (CheckAttribute(&Sea, "MaxSeaHeight")) { fMaxSeaHeight = stf(Sea.MaxSeaHeight); }
	
	aref arWeath = GetCurrentWeather();
	float fAmp1, fAmp2;
	
	fAmp1 = stf(arWeath.Sea2.Amp1);
	fAmp2 = stf(arWeath.Sea2.Amp2);
	
	float fScale;
	if (fMaxSeaHeight >= (fAmp1 + fAmp2))
	{
		fScale = 1.0; 
	}
	else
	{
		fScale = fMaxSeaHeight / (fAmp1 + fAmp2);
	}

	fAmp1 = fAmp1 * fScale;
	fAmp2 = fAmp2 * fScale;
		
	return (fAmp1 + fAmp2) / 2.0;
}

Or maybe because ever game hours now has a set coding for the weather the coding is actually in the files for each game period morning, day, evening and night.
Code:
	Weathers[n].Sea.GF2MX.Sky.Color = argb(0,160,210,255);
	Weathers[n].Sea.GF2MX.Water.Color = argb(0,0,5,10);
	Weathers[n].Sea.GF2MX.Bump.Tile = 0.05;
	Weathers[n].Sea.GF2MX.Bump.AnimSpeed = 7.0;
	Weathers[n].Sea.GF2MX.Bump.Dir = "weather\sea\bump_g2mx\";

	Weathers[n].Sea.Transparency = 0.9;
	Weathers[n].Sea.FrenelCoefficient = 0.4;
	Weathers[n].Sea.WaterReflection = 0.8;
	Weathers[n].Sea.WaterAttenuation = 0.2;
	Weathers[n].Sea.Sky.Color = argb(0,200,180,180);
	Weathers[n].Sea.Water.Color = argb(0,70,95,95);
	Weathers[n].Sea.Pena.Color = argb(0,175,175,155);
	Weathers[n].Sea.Bump.Dir = "resource\textures\weather\sea\bump_g3\";
	Weathers[n].Sea.Bump.Tile = 0.04;
	Weathers[n].Sea.Bump.Ang = 0.0;
	Weathers[n].Sea.Bump.Speed = 0.01;
	Weathers[n].Sea.Bump.AnimSpeed = 15.0;
	Weathers[n].Sea.Bump.Scale = 2.0;
	Weathers[n].Sea.SunRoad.Start = 0.99;
	Weathers[n].Sea.SunRoad.Color1 = argb(0,128,55,0);
	Weathers[n].Sea.SunRoad.Color2 = argb(0,255,200,150);
	Weathers[n].Sea.SunRoad.Power = 0.2;
	//óãîë, ÷àñòîòà, âûñîòà âîëíû â ìåòðàõ, íà÷àëüíàÿ ïîçèöèÿ âîëíû, ñêîðîñòü âîëíû
	Weathers[n].Sea.Harmonics.h1 = "0.0, 1.5, 3.0, 0.0, 10.0";
	Weathers[n].Sea.Harmonics.h2 = "0.0, 3.5, 2.0, 0.0, 20.0";
	Weathers[n].Sea.Harmonics.h3 = "90.0, 2.5, 4.0, 0.0, 15.0";
	Weathers[n].Sea.Harmonics.h4 = "90.0, 1.5, 1.5, 0.0, 15.0";
	Weathers[n].Sea.Harmonics.h5 = "240.0, 15.0, 1.0, 10.0, 85.0";
	Weathers[n].Sea.Harmonics.h6 = "120.0, 18.0, 0.8, 30.0, 125.0";
 
Aha! That last one has the harmonics but there are only 6 of them while POTC has 10. But 5 of those are commented out so POTC only uses 5.

if(REALISTIC_WAVES == 1)
{
// Note on the piece of code below: each line, numbered 1, 2 and 3, are each separate "generators" of waves,
// each controlling the different aspects of the harmonics model.
// The first line controls the height, direction and speed of the wave.
// The second line controls the direction, speed and height of the entire surface.
// The third line controls the direction, height and speed of each wave.
// The value changed is "waveLength#"
// (waveLength1 is equal to 20 right now, wavelength2 is equal to 0.01, and wavelength3 is equal to 10).
// For example, setting the second and third line to 0.01 (minimum value) while keeping the first line as the
// same number would make the waves go in a single direction, without changing shape or breaking.
// Setting all numbers for "generators" to an equal value would create perfect harmonic waves.
// If you are not satisfied with the waves in this mod, please modify the the values that right now say "20", "0.01" and "10"

Weathers.Sea.Harmonics.h1 = direction1 + ",20.0," + seaStrength1 + ",80.87," + waveSpeed;
Weathers.Sea.Harmonics.h2 = direction2 + ",0.01," + seaStrength2 + ",82.28," + waveSpeed;
Weathers.Sea.Harmonics.h3 = direction3 + ",10.0," + seaStrength3 + ",82.28," + waveSpeed;
if(bWhrStorm) //screwface
{
// screwface
if(bSeaActive && !ownDeckStarted())
{
iStormLockSeconds = 60;
Seafoam.storm = "true";
//bstorm = true;
// Build 13 fog - Armada -> (fog effects changed and moved to lines 85 and 94)
/*Weathers.Fog.Enable = true;
Weathers.Fog.Height = 500.0;
Weathers.Fog.Start = 0.0;
Weathers.Fog.Density = 10.0;
Weathers.Fog.SeaDensity = 0.019;
Weathers.Fog.Color = argb(0,33,40,50);*/
// Build 13 fog - Armada <-
Weathers.Sea.Sky.Color = argb(0,255,255,255);
//Weathers.Sea.Water.Color = argb(0,0,0,10);
//Weathers.Sea.Pena.Color = argb(0,100,100,100);
//Weathers.Sea.Bump.Tile = 0.07;
Weathers.Sea.Bump.Ang = 2.0;
Weathers.Sea.Bump.Speed = 0.01;
Weathers.Sea.Bump.AnimSpeed = 23.0;
Weathers.Sea.Bump.Scale = 2.0;
Weathers.Sea.Harmonics.h1 = "0.0,10.0,0.1202,80.87,-68.00";
Weathers.Sea.Harmonics.h2 = "1.57,10.0,2.1002,82.28,88.00";
Weathers.Sea.Harmonics.h3 = "0.47,7.0,2.2002,82.28,68.00";
//Weathers.Sea.Harmonics.h4 = "0.27,47.0,0.0502,82.28,288.00"; //
//Weathers.Sea.Harmonics.h5 = "1.27,57.0,0.0702,82.28,188.00";
Weathers.Sea.Harmonics.h6 = "2.27,57.0,0.0302,82.28,88.00";
//Weathers.Sea.Harmonics.h7 = "2.27,37.0,0.1402,82.28,188.00";
//Weathers.Sea.Harmonics.h8 = "2.77,17.0,0.0502,82.28,288.00";
//Weathers.Sea.Harmonics.h9 = "1.77,17.0,0.1002,82.28,188.00";
Weathers.Sea.Harmonics.h10 = "1.0,14.0,0.5002,82.28,28.00"; //
if(Characters[GetMainCharacterIndex()].location !="")
{
Sea.MaxSeaHeight = 50.0;


I have no idea what those harmonics numbers mean.
 
Try throwing the PotC numbers at CoAS and see what happens. :shrug
 
I found the files and did just that to the init - day.c file. So far there is almost no difference at all, but there are lots of things to tinker with.
 
How's this going bud, found anything else that improves the waves?

There is so much to tinker with its not so easy to get the perfect wave and some of the Sea.Harmonics go down to 6 like in morning.c.
 
The changes I have made so far don't seem to make any difference at all, or they are so small that I can barely tell any difference. All I have done so far is copy and paste POTC stuff into the COAS stuff.
 
Yes. I replaced the COAS values with POTC values as I do not know what that stuff does, except that it does change things in POTC.
 
I'm guessing you've tried starting a new game for the changes to take effect?
 
I'm guessing you've tried starting a new game for the changes to take effect?

You should be able to add globals.c into an edited reinit function not break the current game, as the basic weather file is already included.
Or did Hylie even try a reinit already?

Weather code variables are not fixed values.
 
I have not tried a new game but did try a reinit. Still pretty green with COAS.

EDIT: Started a new game and there is no difference in the waves that I can see.
 
Last edited:
You should have to start a fresh game or use the reinit for weather modifications. Use the bracket keys "[ to go back 1 hour or ] to go forward 1 hour" .
 
Lol, my bad I was half a sleep when I wrote that. You don't need to start a new game after editing any weather value's normally its files like ".init and .ini and .h" which require new games in less they are linked up with the reinit function which ships_init is, but ships.h is not neither is common.ini which is why patch 1.2 for GOF 2 isn't save game compatible, due to me moving ships around so they all line up in the same order as ships.h.
 
Back
Top