• 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 mean they continue turning too long?
Try decreasing that 2* multiplier in the code.
But don't change it lower than 1, because that is the number where she is at risk of tacking right back to the other side.

Are you testing with a companion ship?
There are onscreen messages now that indicate when their tack starts and ends again.

When I tested myself, I had the system apply to the player ship too.
That way you can observe first hand what happens.
Do you think that might help you as well?
 
I set the 2* to 1* and then hit the jackpot! I bought two good Brigantines and could have bought a great Neptunus if I had the cash. So I'm now sailing a 3 ship fleet of 2 Brigantines and a Hoy.

I noticed the messages right away. So far I am sailing the slowest ship and while they seem to be possibly turning too much they seem to be keeping up ok. More testing needed.
 
I set the 2* to 1* and then hit the jackpot!
That might be a risky number! Having it at exactly 1 means that the tack ends right at the point where a tack in the other direction could start straight away.
That means that your ships may end up tacking back and forth like mad and never get anywhere anymore at all.
I'd recommend increasing the value at least a little bit. Maybe not as far as 1.5, but at least 1.1 or so?

Be sure to keep an eye on the behaviour of your ships! I'll be very curious to hear your findings. :)
 
@Hylie Pistof : If you can figure out some proper correct numbers for this feature, I'd much appreciate it!
We'll need to have the ships under control again before the Beta 4 release.
Otherwise Realistic Game Mode would probably be a bit unplayable and that is of course not an option. :wp
 
I will endeavor to play some POTC today. When it comes to play testing it takes some time to see if the changes work as intended and I have been out of the loop and not playing at all for some time.
 
So I direct sailed between Nevis and Marigot. Got good winds and bad. All ships are within one knot in speed but the Hoy can sail directly into the wind without tacking, with me sailing her.

What I saw was the NPCs tacking needlessly. A greater time spent sailing across the wind and less time spent tacking is desirable. They are spending all their time turning and very little time sailing forward. And they are doing all that while I am sailing forward just fine with no tacking at all, and I have the slowest ship of them all.
 
Thinking more on this it seems there is a disconnect between the luffing sound and the actual sailing abilities of the ships. They can sail far deeper into the wind than the luffing sound would indicate and that is why I can sail away from the NPCs. I am sailing along while they are turning this way and that going nowhere.

I see two solutions for this.

1) Adjust the ships sailing abilities so they stop moving forward when the luffing starts. This would require that all ships be worked on and I can see a concerted howl of protest coming from everyone when their ships suddenly don't sail any better than the current Carrack does. That is the worst ship in the game btw.

2) Allow the NPCs to continue sailing in spite of the luffing just like the players do. Only force them to tack when the luffing gets severe.
 
The luffing sound and tacking ARE linked because they use the same variables, so they really have to be.
At the moment the tacking is coded as soon as the ships START dropping speed. Which happens earlier than them losing all speed altogether.

Do you think the tack limit should be set to start only when they actually lose all speed?
That could be done. Should make for less tacking in general.
BUT it would also mean ships could keep sailing at angles where they do a lower speed than their maximum.

Still.... worth a try I suppose. I'll upload a changed file based on that soon; when I get back near my computer.
Do you have a good impulse value for me to include in there?
 
The way it works for me is: When the luffing starts there is no noticeable drop in speed, or it is just a tenth of a knot or so. As you go deeper into the wind the speed drops a little more but you are still making good headway. Then you hit a spot where the speed really drops off fast and I stay just above that spot and am making headway while the NPCs are turning this way and that and going nowhere at all.

Moving at a slower speed is preferable to moving sideways or backwards, as they seem to actually turn so far that they are sailing with the wind before starting their next tack.

Impulse value? I just changed it to 1.1* and 0.0018 +/-
 
Last edited:
This is hopeless. Just put it back the way it was before as then they can at least make headway against the wind, however slowly. Now they can't sail into the wind at all.

In this example we started at Sand Bluff, Cayman heading for the port. I sailed away into the wind without tacking at battle sails and after a while stopped so they could catch up as they had not moved at all. Then they took off and sailed down wind around the point and got stuck! They did eventually make it around that point and caught up with me well over a day later. Check out the time in the screenies. They were stuck so long that a couple of British ships came along and escorted them around that point.

POTC4_2016_02_21_09_20_48_026.jpg POTC4_2016_02_21_09_21_30_979.jpg POTC4_2016_02_21_09_26_07_572.jpg
 
The way it works for me is: When the luffing starts there is no noticeable drop in speed, or it is just a tenth of a knot or so. As you go deeper into the wind the speed drops a little more but you are still making good headway. Then you hit a spot where the speed really drops off fast and I stay just above that spot and am making headway while the NPCs are turning this way and that and going nowhere at all.
Good point; I forgot that the "luffing sound" starts BEFORE the speed drop does, so I wrote the code to be a bit "too trigger-happy" with tacking.

Here's an alternate suggestion:
Code:
        // PB: Rewritten Tacking -->
         if(!CheckAttribute(rCharacter, "tackShip"))                               // Ship is not tacking
         {
           if (fOffWind <= fClosestPoint - RS_CP_OFFSET)                           // Ship loses ALL speed 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.0018;                 // Make the ship rotate to port
             else           arCharShip.Impulse.Rotate.y =  0.0018;                 // Make the ship rotate to starboard
             if (IsCompanion(rCharacter)) LogIt("The " + GetMyShipNameShow(rCharacter) + " is tacking");
           }
         }
         else                                                 // Tack in progress
         {
           if (fOffWind > fClosestPoint)                                   // 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
           }
         }
         // PB: Rewritten Tacking <--
By using minus RS_CP_OFFSET instead of plus, the tack shouldn't start until the point where a ship would lose ALL speed.
Also, the tack continues until the point where the speed is restored, but not further.
This should make tacking occur only when REALLY needed.

Extract attached to PROGRAM\SEA_AI to try. Now that I think about it, I think this probably makes more sense than my first attempt.
So it should be better. :doff

Depending on your feedback on this, I do have some other alternatives in mind that we could try.
Let's not give up just yet.... :cheeky
 

Attachments

  • AIShip.zip
    55.2 KB · Views: 199
Just remembered: I have to remember to REMOVE the "tacking" attribute from ships when the scene is reloaded!!!
 
I have a new fleet of 3 Postillionens with pretty similar statistics now and the fleet is staying pretty well grouped now. If I'm not careful I can screw up the NPC ships when rounding a point, so I have to sail well past it so they can go around it smoothly, but in the open sea they stick pretty close unless the wind change catches them just wrong.

This seems to be very good and much better than before.:cheers
 
This seems to be very good and much better than before.:cheers
Progress at last!!! :dance

Thanks for doing the testing on this one. If at some point you have an idea on how to further improve it, feel free to let me know.

As far as I can tell, the original code didn't quite do what it was supposed to.
I think this version does.
 
All I could hope for is that the NPCs stay on their course longer between tacks so they can make better progress forward. I can still put a little distance between us over time by staying on my course while they are tacking.
 
All I could hope for is that the NPCs stay on their course longer between tacks so they can make better progress forward. I can still put a little distance between us over time by staying on my course while they are tacking.
I can think of a couple of ways to handle that, though not all are equally good/realistic:
1. Make the AI actually UNDERSTAND wind direction (not going to happen.... :( )
2. Add a "counter" so that a tack isn't started within, say, 10(?) seconds of the previous one being completed
3. "Force" the ships away from the wind in the OTHER direction (but that might prevent tacking altogether)
4. Make the ships turn further upon completing their tack; that would make it less likely for them to turn right back.
But if they WANT to turn right back, they will anyway. :facepalm

Does any of that sound in any way promising to you?
My first impression would be to combine #2 and #3 so that after a tack, the ship is FORCED to stay on the next tack for a period.
But that is overruling the AI itself and may have all sorts of strange effects as well.... :oops:
 
1) Not going to happen.

2) Sounds promising as now they spend all their time turning.

3) Forcing them away from the wind sounds like making them sail with the wind, which they were doing before.

4) That again makes them sail with the wind, going in the opposite direction from what they want to go in. They were doing that before.
 
So.... timer then?
Of course while the timer is going, the AI could still decide to turn back into the wind and lose all speed.

My idea of forcing them away from the wind would purely be to get them outside the speed drop range.
 
That is how I sail into the wind. I set my course to be as close as possible while still making some headway and hold it until the wind changes on the hour. I do less turning and more sailing than the NPCs and get a little bit ahead of them.

As an example I recently took on the pirate ship off Martinique. After we cleared the island I ordered them to attack it and as it was far far away it took a long time to even get in sight of it. Since I was sailing the slowest one the other two passed me. That looked pretty cool too. Then the wind shifted and while one NPC and myself were able to maintain our course the third one started tacking and fell behind. It is that close now. :onya

BTW, that one pirate frigate is a tough one. I got $30,000 reward but it cost over $120,000 to repair my ships. :pirateraft
 
Back
Top