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

[REQ] Decreasing turning speed mod?

[...] I don't know how to do that.

Me neither... yet.

If there is a way to do it I'll find it, sooner or later. But may be it is not, I fear those things are coded in the DLLs, not in the open sources.

Just now, apparently, I can't affect the turning speed without affecting the lineal speed as a secondary result, which is the opposite relation and very wrong.

Cheers.
buho (A).
 
On second thought I guess without dramatic changes in AI behaviour we can't introduce these ideas. Because we would a lot AI ships stalled.
For now I'm really happy with my little changes in ships characteristic.
 
Hi. Thanks for the great mod GOF :onya .
I've just found this topic. I think it's possible to stop turning completly.

IN AIShip.c, void Ship_UpdateParameters(), before the line fTRResult = Bring2Range(0.07, 0.95, 0.00001, 1.0, fTRResult); we have:
float fTRResult = fMaxSpeedY * fShipTurnRate * fTRFromSailState * fTRFromSpeed;
Result is a factor of:
- fMaxSpeedY which depends on the Sea_TurnRateMagicNumber
- fShipTurnRate which is the current turn rate with skills and perks
- fTRFromSailState which depends on the sails damage
- fTRFromSpeed which is the current ship speed with current wind speed
The lower these values the lower the result. If you change fTRFromSpeed to a 0 (zero) and comment out the line Bring2Range ... turning is disabled at all. So if you allow fTRFromSpeed to take values of 0 or close to 0, then result (turning speed) is close to 0.

I have tested it. Thanks to Jonathan Aldridge explanation about the Bring2Range function i understand that is the problem. That line is correcting result to a minimum value which makes turning always possible. Commenting it out and studying fTRFromSpeed values it's possible to prevent a stopped ship from turning, although i think a minimum value is always necessary to avoid ships completly halted.

NOTE: Where could i find a reference for the functions of this programming language?

EDIT: Ok, i have tested this change fTRResult = Bring2Range(0.00001, 0.95, 0.00001, 1.0, fTRResult); and results are quite acceptable. With lowered sails and speed 0, the turning rate is very very low. When sailing at a good speed and turning into the wind it's noticeable how the turning rate lowers when speed decreases. Still, i think i'm going to study the sea speed functions because something is wrong. When wind speed is high some ships can sail faster than wind, and some can sail directly into the wind with some speed.

About the sail hit points either the code is changed either we change all ships back to 100 Sp, because some values are 200, 250, 300 ,400 ...
 
Code:
// From AIShip.c, Ship_UpdateParameters()

fTRResult = Bring2Range(0.07, 0.95, 0.00001, 1.0, fTRResult);         // <---- ??
arCharShip.MaxSpeedY =	fTRResult;

Is this the line you changed?

- o -

You have some documentation in the Program\_doc_scripts folder. Mostly or all in russian. I translated the files using Google translator, they are not a big help but are better than nothing. If you have problems translating them I can upload the translations to my uploading service.

Cheers.
buho (A).
 
Code:
// From AIShip.c, Ship_UpdateParameters()

fTRResult = Bring2Range(0.07, 0.95, 0.00001, 1.0, fTRResult);         // <---- ??
arCharShip.MaxSpeedY =	fTRResult;

Is this the line you changed?

- o -

You have some documentation in the Program\_doc_scripts folder. Mostly or all in russian. I translated the files using Google translator, they are not a big help but are better than nothing. If you have problems translating them I can upload the translations to my uploading service.

Cheers.
buho (A).
Yes that's it.
Thanks, may be the translation could be uploaded to the forum and pinned for reference. I can understand most functions but some are unknown to me. I was googleing when i found this topic :)
 
Before going to ship speed i'm trying to understand the logic of these operations. Perhaps someone good in maths can help. My goal is to make turn rate depending on speed on a logaritmic increased function not a linear one. speed 0 = turn rate close to 0; low speed = very low turn rate; high speed = very high turn rate (up to a maximum).
From this line variables: float fTRResult = fMaxSpeedY * fShipTurnRate * fTRFromSailState * fTRFromSpeed;

1.-
float fMaxSpeedY = stf(rShip.TurnRate) / Sea_TurnRateMagicNumber();
In GeneratorUtilite.c Sea_TurnRateMagicNumber returns an arbitrary constant 244.444. Question one is why is there a semicolon after the function declaration. Question 2 is why this exact number

2.-
fShipTurnRate = stf(rCharacter.Tmp.fShipTurnRate);
This assigns the turn rate, i think it is the unmodified possible turn rate of the ship

3.-
float fTRFromSailState = 1.0;
switch (MakeInt(fSailState * 2.0))
{
case 0: fTRFromSailState = 0.08; break;
case 1: fTRFromSailState = 1.0; break;
case 2: fTRFromSailState = 0.68; break;
}

These are the states of sails: first no sails, second midi, third full sails. So half sails has optimal turn rate, second is full sails, and third no sails. I have to check if a fully dismastled ship is counted as having no sails.

4.-
float fCurrentSpeedZ = stf(rCharacter.Ship.Speed.z);
if (iCharacterIndex == GetMainCharacterIndex())
{fTRFromSpeed = 1.0 - 0.86 * (1.0 - Clampf(fCurrentSpeedZ / fShipSpeed));}

[To simplify I have taken (MOD_SKILL_ENEMY_RATE > 2) and NOT (iArcadeSails == 1)]
Why asks if Character is Main Character? If it's not then how it is calculated for NPCs?
This formula is the important one. I'd like to boost turn rate with high speed and steeply lower it as speed decreases.
 
1)

The semicolon is irrelevant and the magic number is just that: a magic number obtained empirically, only the original programmers can explain it (if they actually can).

3)

I believe a dismasted ship is not counted as having no sails. But I can't be sure only analyzing the code because fSailState is taken from the event data stack and I have no idea what value is the engine pushing there. Moreover, the Ship_GetSailState function itself (in Program\SEA_AI\AIShip.c) is a call to the engine.

In the C-scripts sources is some code cleanly defining the sail states as 0.0 (heaving to), 0.5 (battle sails) and 1.0 (full sails) and that is why the

Code:
Switch(Makeint(fSailState * 2)) 
{
0:...; 
1:...; 
2:...;
}
construction is used along the code. On the other hand there is too some code like this:

Code:
float fSailSt = Ship_GetSailState(chref);
if( fSailSt<0.3 ) {nSailState = 0;}
else {
if( fSailSt<0.6 ) {nSailState = 1;}
else {nSailState = 2;}
}
and
Code:
float fState = Ship_GetSailState(pchar);
if( fState < 0.33 ) {
BI_intNRetValue[1] = 20;
} else {
if( fState < 0.66 ) {
BI_intNRetValue[1] = 19;
} else {
BI_intNRetValue[1] = 18;
}
}

so I'm not really sure what the hell is the sail state.

4)

The NPC ships are calculated in the "else". Why it is different I can't say.

Cheers.
buho (A).
 
I believe a dismasted ship is not counted as having no sails. But I can't be sure only analyzing the code because fSailState is taken from the event data stack and I have no idea what value is the engine pushing there. Moreover, the Ship_GetSailState function itself (in Program\SEA_AI\AIShip.c) is a call to the engine.

construction is used along the code. On the other hand there is too some code like this:

Code:
float fSailSt = Ship_GetSailState(chref);
if( fSailSt<0.3 ) {nSailState = 0;}
else {
if( fSailSt<0.6 ) {nSailState = 1;}
else {nSailState = 2;}
}
and
Code:
float fState = Ship_GetSailState(pchar);
if( fState < 0.33 ) {
BI_intNRetValue[1] = 20;
} else {
if( fState < 0.66 ) {
BI_intNRetValue[1] = 19;
} else {
BI_intNRetValue[1] = 18;
}
}

Cheers.
buho (A).

I suppose this magic number is a way to control the final value. Bigger number lower result.
yes i found the get event data. Perhaps sail damage is substracted from sail state in a temp variable, so 0.5 battle sails can become 0.33 after some damage, or 1.0 full sails can become 0.66. Then a dismastled ship is counted as 0.0 sails because i've noticed that dismastled ships have 0 speed, the same as no sails.

With new values I've found tat some ships turn rates result (derived from the line 3187 fShipTurnRate = FindShipTurnRate(rCharacter)) are too low when crew experience or crew numbers are low. It does make sense although, if a ship can't maneuver due to lack of crew.
The same happens when cargo load is more than half capacity, but this happens because many ships have TurnDependWeight value very high. In vanilla game the highest value was 0.4 or 0.4.5 while now many ships have 0.8
With the minimum TurnRate value granted before, that wasn't a problem, but now it matters a lot, so i'm going to change my Ships_init values to old numbers: cargo ships 0.2 light warships 0.3 heavy warships 0.4

Also i'm going to change sail hitpoints back to 100
 
yes i found the get event data. Perhaps sail damage is substracted from sail state in a temp variable, so 0.5 battle sails can become 0.33 after some damage, or 1.0 full sails can become 0.66. Then a dismastled ship is counted as 0.0 sails because i've noticed that dismastled ships have 0 speed, the same as no sails.

I'll not bet on it.

Having sail states different of 0.0, 0.5, 1.0 will defeat the "Switch(MakeInt(...))" construction the original programmers used alot. I think they are illegal and the "if" are corrections for older code reused in COAS. Of course I'm guessing, I can be totally wrong.

For checking the sails damage try with the GetSailPercent function (Program\characters\CharacterUtilite.c).

Also i'm going to change sail hitpoints back to 100

Why, if I can ask?

Be careful Ed: sail points are a hellishly thing, they are related to masts and yards states in a way I never managed to understand. I have no idea what changes where done to make them different based on ship rate, reverting them back to 100 may open a can of worms.

Cheers... and good luck ;).
buho (A).
 
Having sail states different of 0.0, 0.5, 1.0 will defeat the "Switch(MakeInt(...))" construction the original programmers used alot. I think they are illegal and the "if" are corrections for older code reused in COAS. Of course I'm guessing, I can be totally wrong.

For checking the sails damage try with the GetSailPercent function (Program\characters\CharacterUtilite.c).

Also i'm going to change sail hitpoints back to 100

Why, if I can ask?

Be careful Ed: sail points are a hellishly thing, they are related to masts and yards states in a way I never managed to understand. I have no idea what changes where done to make them different based on ship rate, reverting them back to 100 may open a can of worms.

Cheers... and good luck ;).
buho (A).
Sail states are 3: none-half-full. That doesn't change ever. But there are a couple of situations where there is a percentage of sails. One being raising or lowering sails and the other damaged sails. Speed calculations need to translate this percentage of sails to a sail state in order to apply the factors. Your Ex:
Code:
        float fSailSt = Ship_GetSailState(chref);
if( fSailSt<0.3 ) {nSailState = 0;}
else {
if( fSailSt<0.6 ) {nSailState = 1;}
else {nSailState = 2;
If percent vaue is under 0.3 then sail state is 0 (no sails)
If it's betwen 0.3 and 0.6 then it's 1 (half sails)
If more than 0.6 then it's 2 (full sails)

In the first page of this topic you said that game code is written for a value of 100 Sp (sail points). May be the modders who changed Sp values thought it would be better to have more Sp in stronger ships but did they check it if it was doing anything? Anyway i've already done it and in a few days i will see if there is a difference.
 
Sail states are 3: none-half-full. That doesn't change ever. But there are a couple of situations where there is a percentage of sails. One being raising or lowering sails and the other damaged sails. Speed calculations need to translate this percentage of sails to a sail state in order to apply the factors. Your Ex:
Code:
        float fSailSt = Ship_GetSailState(chref);
if( fSailSt<0.3 ) {nSailState = 0;}
else {
if( fSailSt<0.6 ) {nSailState = 1;}
else {nSailState = 2;
If percent vaue is under 0.3 then sail state is 0 (no sails)
If it's betwen 0.3 and 0.6 then it's 1 (half sails)
If more than 0.6 then it's 2 (full sails)
I think the "ifs" are there to correct some situation produced by the use of old code, working in a different way that COAS works. My theory is that for COAS the only "legal" values for sail states are 0.0, 0.5 and 1.0. Pure guess, of course.


In the first page of this topic you said that game code is written for a value of 100 Sp (sail points). May be the modders who changed Sp values thought it would be better to have more Sp in stronger ships but did they check it if it was doing anything? Anyway i've already done it and in a few days i will see if there is a difference.

Jonathan said that ;). I was not here when the changes where made. I have no idea about why or how they changed the sail points. And Jonathan is not here now, so we have no one to ask.

Well... "why" I can guess: more sail points calls for longer fights when working down the sails of the bigger ships.

Cheers.
buho (A).
 
Sorry that I write off-topic, please help to understand, I want to redo the quest flying golandets, in which topic to me what subject I go apologize for the bad english, I'm from Russia.
 
Sorry that I write off-topic, please help to understand, I want to redo the quest flying golandets, in which topic to me what subject I go apologize for the bad english, I'm from Russia.

Open a new topic in this same forum. Elaborate as much as possible on what you want to change, may be somebody can help you.

Cheers.
buho (A).
 
Having sail states different of 0.0, 0.5, 1.0 will defeat the "Switch(MakeInt(...))" construction the original programmers used alot. I think they are illegal and the "if" are corrections for older code reused in COAS. Of course I'm guessing, I can be totally wrong.

For checking the sails damage try with the GetSailPercent function (Program\characters\CharacterUtilite.c).

Also i'm going to change sail hitpoints back to 100

Why, if I can ask?

Be careful Ed: sail points are a hellishly thing, they are related to masts and yards states in a way I never managed to understand. I have no idea what changes where done to make them different based on ship rate, reverting them back to 100 may open a can of worms.

Cheers... and good luck ;).
buho (A).
Sail states are 3: none-half-full. That doesn't change ever. But there are a couple of situations where there is a percentage of sails. One being raising or lowering sails and the other damaged sails. Speed calculations need to translate this percentage of sails to a sail state in order to apply the factors. Your Ex:
Code:
        float fSailSt = Ship_GetSailState(chref);
if( fSailSt<0.3 ) {nSailState = 0;}
else {
if( fSailSt<0.6 ) {nSailState = 1;}
else {nSailState = 2;
If percent vaue is under 0.3 then sail state is 0 (no sails)
If it's betwen 0.3 and 0.6 then it's 1 (half sails)
If more than 0.6 then it's 2 (full sails)

In the first page of this topic you said that game code is written for a value of 100 Sp (sail points). May be the modders who changed Sp values thought it would be better to have more Sp in stronger ships but did they check it if it was doing anything? Anyway i've already done it and in a few days i will see if there is a difference.

Luke and I played with boosting those numbers back when we were first playing with RTBL mod. If they are part of the problem with causing ships to spin then lets lower them. I will do a little testing on this as well. I just started a new game.

Welcome aboard Edmaroon.

MK
 
Luke and I played with boosting those numbers back when we were first playing with RTBL mod. If they are part of the problem with causing ships to spin then lets lower them. I will do a little testing on this as well. I just started a new game.

Welcome aboard Edmaroon.

MK

Thanks MK. No, it was my fault. I installed GOF and patch to 1.1 and missed the 1.1.1 and 1.1.2 links because they are not in the same post. Then looking at the code and reading what Buho and J. Aldridge said i thought those values weren't doing anything. But now i have installed 1.1.2 and i think buho fixed it to take into account new Sp values.

Code:
	//// {*} BUHO-FIX - Original - Deprecated - Wrong use of Bring2Range.
/*
float fTRFromSailDamage = Bring2Range(0.1, 1.0, 0.1, 100.0, fSailsDamage); //0.3
*/
//// {*} BUHO END REMOVE

//// {*} BUHO-FIX - REPLACEMENT - Use of Bring2Range
float fTRFromSailDamage = Bring2Range(0.1, 1.0, 0.1, 100.0, GetSailPercent(refCharacter));
//// {*} BUHO END REPLACEMENT

Anyway that wasn't a problem. I was just trying to understand the meaning of all these calculations. To find TurnRate result there are a number of variables influencing it. Cargo weight, number of crew, quality of crew, sails state, captain skills, maximum turn rate and current speed.
 
Back
Top