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

Included in Build Realistic Game Mode: Modify NPC Tacking Behaviour at Sea

You are now officially three steps ahead of me.

I just discovered something that has been skewing my results. I have two CastelFs. The one I started the game with and another I recently bought. The original is French and is a smaller faster version. The other is Spanish and is a larger slower version.

Well I noticed that when heading into the wind at an angle where my ship was not luffing I was doing 3.3 knots but the other ship running at the same heading with full sails was only doing 1.1 knots. So I swapped ships and sure enough there is a big difference in the way they sail. The original one will not sail nearly as deep into the wind without luffing as the new one will. I have searched the stats and looked in shipsinit.c and can not explain this. I intend to buy another CastelF ASAP and see how it works.

Oh, deleting that whole section by TM causes the NPC ship to not furl its sails and it tries to sail into the wind at full sails, so I will be putting it back in and trying other things. I'm not sure if it even wants to tack.
 
Could the national modifiers be confusing things?
Or ship upgrades?

If you want to test with multiple identical ships, we may need a console command for that.
Then at least we know for sure they have the same national design and no upgrades.

You can also set refShip.unique = true; and then reinitialize and then use console to update your fleet.
That should definitely make all their stats identical.
 
I was finally able to test your latest settings and with both ships close to but not luffing that NPC ship had already raised sails and was slowing down while I was continuing on just fine. I swapped ships and the same thing happened again. The NPC slows down before sail luffing begins.
 
My "new settings" are the old settings. I just reset everything back to how it was before we started playing around with it.
You seemed to be unsure if this was related to the tacking mod or to the ship stats, so that seemed to be the best thing to do.

I don't know what else to be done now.
Feel free to play around with it though.
 
It seems that when I changed the rigging from lugger to brigantine I already had the first ship and it kept the old performance, but the next ship got the new performance, so that was messing things up. In this new game they both go into the wind the same although their speed and turn rates are slightly different. So this time I will be comparing apples to apples instead of apples to oranges.

EDIT: I see that the *8 is now *4 and that did not seem to help, so I changed the 0.02 to 0.0. Now to see if that helps.
 
Last edited:
Dunno. I'm working with what I have got. The NPC ship seems to be sticking with me pretty well so far with these settings. More testing needed to see how other ships do, like when we get into a tacking duel during a battle.
 
I am pretty happy with the *4 and 0.0 settings. My NPC ships keep up with me pretty well and in battles methinks I still have a slight edge in tacking. Maybe. My opponents so far seem to be turning and firing better so I am taking more damage than I am used to. But that is ok. Small ships like English Barques can be a real problem and large 60 gun ships can wipe out smaller ships in not time. The NPCs are no longer pushovers.
 
I am pretty happy with the *4 and 0.0 settings.
I'm a bit concerned with the 0.0 setting. For one thing, the "ramp" between "full speed" and "zero speed" becomes non-existent that way.
And also this line:
Code:
if(fOffWind < fClosestPoint + (RS_CP_OFFSET * 8) && fOffWind > fClosestPoint && fSailState > 0.0) {Ship_SetSailState(iCharacterIndex, 1.00);};
Ends up meaning this:
Code:
if(fOffWind < fClosestPoint && fOffWind > fClosestPoint && fSailState > 0.0) {Ship_SetSailState(iCharacterIndex, 1.00);};
Of course 'fOffWind' cannot be both smaller than AND greater than 'fClosestPoint' at the same time.
So that means that line can never be triggered, rendering it pointless.

This doesn't quite sound like a real fix to me.... :confused:
 
With 0.0 you kill part of the functionality because it cannot work then.
Plus there is no gradual speed loss when approaching your Closest Point.
So doesn't seem like a good solution to me.
You could try 0.1?
 
Could it be that they stay in the area where the speed begins to drop but isn't zero yet?
If so, I may have thought of how to tweak the tacking code.
Could you keep an eye this weekend and see if that might be the case?
 
@Hylie Pistof: Since you weren't happy with how the tacking currently works in the game, I spent some time investigating and rewriting the behaviour.
I'm not entirely sure if it ever quite worked, but it certainly almost did.

Please extract attached file to your PROGRAM\SEA_AI folder to try my new version:
Code:
        if(!CheckAttribute(rCharacter, "tackShip"))                               // Ship is not tacking
         {
           if (fOffWind <= fClosestPoint + RS_CP_OFFSET)                           // Ship is in the "luffing" area and needs to tack
           {
             rCharacter.tackShip = true;                                   // Indicate that the ship is tacking
             Ship_SetSailState(iCharacterIndex, 0.001);                           // Lower all sails
             float fTacking = stf(arCharShip.Speed.y);                           // Check which way the ship is going
             if(fTacking <= 0.0)     arCharShip.Impulse.Rotate.y = -0.01;                 // Make the ship rotate to port
             else           arCharShip.Impulse.Rotate.y =  0.01;                 // Make the ship rotate to starboard
             if (IsCompanion(rCharacter)) LogIt("The " + GetMyShipNameShow(rCharacter) + " is tacking");
           }
         }
         else                                                 // Tack in progress
         {
           if (fOffWind > fClosestPoint + 2*RS_CP_OFFSET)                           // Ship is outside the "luffing area" again
           {
             DeleteAttribute(rCharacter, "tackShip");                           // Mark the tack as completed
             Ship_SetSailState(iCharacterIndex, 1.00);                           // Make sail
             arCharShip.Impulse.Rotate.y = 0.0;                               // Stop rotating
             if (IsCompanion(rCharacter)) LogIt("The " + GetMyShipNameShow(rCharacter) + " has completed her tack");
           }
           else
           {
             Ship_SetSailState(iCharacterIndex, 0.001);                           // Keep sails lowered
           }
         }
I added a whole bunch of comments to hopefully indicate how it works now.
Basically:
- The ship ends up in the "luffing" area and so apparently needs to tack
- When that happens, she'll lower all sails (and keep them lowered) to avoid making sternway
- The "rotate impulse" will make her turn to the other direction (I increased this value A LOT because it used to be "0.0015" and now it is "0.01")
- When the ship is double outside the "luffing area", the tack is marked as completed and business resumes as normal

This may not quite be perfect yet, but hopefully it is at least a start.
One of the main issues that you'll probably observe is that NPC ships could end up tacking repeatedly back and forth far too often.
The "continue turning until she's double outside the "luffing area" is to counter that.
The idea is that if she turned that far, she probably won't immediately turn back.

So some numbers to play with:
- The 2* can be decreased to make the tack faster (because it would go less far than needed), at the risk of her immediately getting into a tack in the other direction again. :facepalm
- The "0.01" can be increased/decreased if you find that ships turn too slow/fast while tacking.

Possibly that number should be dynamically determined based on ship turnrate and/or speed.
But I'm not sure how that would work, so for now it is just a single number.

Having tested this, I can guarantee you that it DOES actually function as intended now.
What I cannot guarantee is if this situation is actually better or not.
It could be that the AI is too stupid to understand the whole "tacking business".

Anyway, hopefully will lead towards this feature actually serving its purpose in the game! :cheers
 

Attachments

  • AIShip.zip
    55.3 KB · Views: 180
I finally got the chance to play for a few hours today. I'm sailing a single hoy so can not comment, but I have been seeing many ships spinning in circles. That is kinda new.

So I am going to change that "rotate impulse" to 0.002.
 
Please let me know if you find a good value.

I'm afraid different types of ships might require different numbers.
But hopefully you'll be able to figure out if that's the case.

At least it is a start that you notice something has changed now! :rofl
 
With the rotate impulse set to 0.002 the ships are turning well but are going too far so that they are sailing sideways to the wind and are not moving into the wind. Gotta fix that.
 
Back
Top