• 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 3D Sailing Mode: Reduce Range for Ships Chasing Each Other

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
A while ago, I fixed the following bug: Fixed - Standard Storyline: Speightstown Blockading Squadron does not move | PiratesAhoy!
It seems we now have the very opposite effect on our hands now.

The Speightstown blockading squadron completely abandoned their posts when they went to pursue some passing Portuguese ships.
Those ships must have passed relatively closely, but I didn't see them even though I chased the squadron quite a way to see what was distracting them. o_O
 
Happened again. Seems that the character visibility range can be rather far, since they were pretty much halfway around the island.
But they saw them anyway and went in pursuit.

This isn't so very strange, because it is using this code:
Code:
int Find_nearest_inf_ship(ref chr)
{
   ref rGroup;
   ref PChar = GetMainCharacter();
   string groupname;

   int i;
   ref achr;
   int achridx;
   int place = -1;
   float enemydist;
   enemydist = 0.0;
   float memoire=0.0;

   if(CheckAttribute(chr,"runaway")){DeleteAttribute(chr,"runaway");}

   float visibility_range = GetCharVisibilityRange(chr, 4); // maximum visibility range
   float effective_range  = visibility_range;
As shown, it is using MAXIMUM visibility range to determine what ships can see each other.
However, in Realistic Game Mode, the spyglass doesn't show you 'nation' until you're closer than range "2".

If ships should not be able to see that another ship is hostile, why should they attack and pursue?
I'm considering reducing that number to "2" and see what happens. This means you should see a LOT less pursuing throughout the game.
Both enemies chasing the player, but also other ships chasing each other. Would that be a good change to make or am I missing something here?
 
That sounds normal as when I played the standard storyline I had to watch the wind carefully when trying to sneak into Bridgetown. If the wind kept them on their side of the island I was home free, but if the wind allowed them to come after me they would chase me until I sailed to another island. They always detected me instantly.

If this is a global change, then it would also mean that battles encountered on the world map would never happen as the ships spawn too far apart to tell who is what.
 
If ships should not be able to see that another ship is hostile, why should they attack and pursue?
I'm considering reducing that number to "2" and see what happens. This means you should see a LOT less pursuing throughout the game.
Both enemies chasing the player, but also other ships chasing each other. Would that be a good change to make or am I missing something here?


Would it not just be simpler to code something in the quests_reaction .c - specifically for those ships so they don't chase other ships - just the player.

Rather than changing the game's general mechanics - which will change everything - just to solve a specific problem.

Ships don't just go chasing each other because they "see" each other - the behaviour mimics ships that have been sent to investigate the reported siting of a hostile ship at a certain location around an island - so they sail to the location of the hostile to investigate - and engage it if they find it and catch up with it ( if it has not sailed away).

If the change you propose means ships stop chasing each other - it will change the nature of the sailing environment, ships will just sit at anchor more than they do already. And possibly introduce new bugs into the game.

:sail
 
"Chasing ships that are on the other side of the island" seems to me a more general game issue, which is why I am proposing a more general solution.
The Standard Storyline Blockading Squadron is just the most obvious example.

As far as I can tell from the code, this instance is the ONLY one of "range 4" being used anywhere.
A spyglass (in Realistic Game Mode) should not be able to tell you anything about a ship until you get within "range 3".
So we could set that value to 3 instead of 4 and see what it does.

This change would not STOP ships chasing each other; it would just make it less easy for them to notice each other and do so.
If enemy ships get closer, they'll still give chase.

If you do play Realistic Game Mode, have have a look through your spyglass to see at what range you can see "ship type" (within range 3) and "nation" (within range 2).
That would give you a better feeling for how those ranges are defined. My thinking is that if you can't see them with your spyglass, they shouldn't see you either.
And definitely not give chase. Again, this applies equally to player-to-NPC and NPC-to-NPC.

If (almost) every ship at sea is always chasing something, that does seem a bit excessive to me.
That also means that any "patrolling" navy ships will hardly ever be seen patrolling, because they'll start chasing real soon.
And while courageous merchants may go and attack ships on the other side of the island, regular merchants will try to make their escape.
Again, from those hostile ships on the other side of the island.

And I doubt you'll EVER get to see any ships peacefully proceeding to their anchorage and then staying there,
because unless there aren't ANY enemies around in the scenes at all, they'll probably be either chasing or running away before they ever get to the anchorage.

In other words: I fear that the whole clever "Improved Sea AI" functionality that @Screwface did
basically gets reduced to "chasing or running away" simply because of an excessive visibility range being used.

Note that the range at which ships see each other depends on the skill of their captain.
Navy ships would probably have better captains and therefore would spot potential targets sooner than merchants.
 
And I doubt you'll EVER get to see any ships peacefully proceeding to their anchorage and then staying there,
because unless there aren't ANY enemies around in the scenes at all, they'll probably be either chasing or running away before they ever get to the anchorage. ..........
If (almost) every ship at sea is always chasing something, that does seem a bit excessive to me.

They are not doing that now - I think you just had an exceptional example

I have seen at Bonaire - 2 pirates - 2 dutch & 2 French ships ( so all 3 sets of ships were hostile to each other) all at anchor - and Bonaire is probably a smaller island than Barbados.




In other words: I fear that the whole clever "Improved Sea AI" functionality that @Screwface did
basically gets reduced to "chasing or running away" simply because of an excessive visibility range being used.

Note that the range at which ships see each other depends on the skill of their captain.
Navy ships would probably have better captains and therefore would spot potential targets sooner than merchants.

If this is the case has it been affected by the new skills/Levelling system - were the Captains of the Blockading fleet that you saw more skilled than they used to be, in previous versions of the game. Because they never used to chase things ( sometimes not even the player xD ).

Are the specific values for these captains in the characters/init/story.c file being overwritten by the new skills/levelling system. :shrug

:drunk
 
Last edited:
They never used to chase anyone because they were (accidentally) excluded from the Improved Sea AI altogether.
That has been fixed by me a few months back. See opening post.

Maybe some debug logs should be added to see what is going on.
 
Thread now renamed to indicate my request is NOT limited to just three ships, but to ALL of them.

If this is the case has it been affected by the new skills/Levelling system - were the Captains of the Blockading fleet that you saw more skilled than they used to be, in previous versions of the game. Because they never used to chase things ( sometimes not even the player xD ).

Are the specific values for these captains in the characters/init/story.c file being overwritten by the new skills/levelling system. :shrug
I wouldn't rule it out. But even so.... I don't think skills make the range quite THAT much larger.
But if that range is already large to begin with, which it does seem to be, it might become a bit "much"....
 
Are the specific values for these captains in the characters/init/story.c file being overwritten by the new skills/levelling system. :shrug
They shouldn't be. Remy Gatien, Yves Giner and Begon Monchaty are the captains in question and they all have 'ch.questchar = true' set in "Story.c".
 
My suspicion is that this is a side-effect of me fixing that bug linked to in the opening post. The actual "bug" seems to be larger than just those ships.
It also technically isn't a bug; the code is doing exactly what it is written and meant to do.
But the big question is: Should we want it to do that? The AI seems a bit too aggressive in its chasing to me.
 
What about giving a ship 2 (for example) if they are at a island. and on open sea give them 4?
 
Who would be willing to help me with some tests on this one to see what does and doesn't seem right?
This will require enabling some extra log messages and probably getting a lot of on-screen "spam".
But it would also allow us to figure out if ships chasing or escaping other ships are indeed occurring too often, as I suspect.

What about giving a ship 2 (for example) if they are at a island. and on open sea give them 4?
That'll be difficult to figure out, I imagine. If you're using DirectSail, technically there is ALWAYS an island, for example.
For simplicity, I'd like a "one size fits all" solution if possible.
 
Who would be willing to help me with some tests on this one to see what does and doesn't seem right?
This will require enabling some extra log messages and probably getting a lot of on-screen "spam".
But it would also allow us to figure out if ships chasing or escaping other ships are indeed occurring too often, as I suspect.


That'll be difficult to figure out, I imagine. If you're using DirectSail, technically there is ALWAYS an island, for example.
For simplicity, I'd like a "one size fits all" solution if possible.
Theres a function to find the distance to the closest island I believe. Just use that and if it's below a certain threshold it gets 2 else it gets 4?
 
Theres a function to find the distance to the closest island I believe. Just use that and if it's below a certain threshold it gets 2 else it gets 4?
If we do that, we should probably use "range 3" inbetween too.

But even then, we still need to know what range values seem "right" for which behaviour and when.
And to get that, I need some people involved to actively test this in different conditions and give feedback.

Anyway, I suppose this is no high priority. This isn't technically broken functionality.
It does do what it is meant to; it just seems a bit too agressive to me. Which makes it more balancing than an actual problem.
 
Who would be willing to help me with some tests on this one to see what does and doesn't seem right?
This will require enabling some extra log messages and probably getting a lot of on-screen "spam".
But it would also allow us to figure out if ships chasing or escaping other ships are indeed occurring too often, as I suspect.
I'm repeating my request here: Anyone willing to help out here? I can't do this by myself!!!
 
I'll keep this in mind. But there are other things here in my mind already and it doesn't look like I'll be running out of things to test in the immediate future :)
 
I'm repeating my request here: Anyone willing to help out here? I can't do this by myself!!!

I can help, just give me instructions. I'm not playing PoTC with character leveling at the moment until the public release. Instead, I'm focusing on testing the game. I switched to COAS until we get a stable release.
 
I can help, just give me instructions.
Open PROGRAM\Screwface_functions.c and find:
Code:
int Find_nearest_inf_ship(ref chr)
{
   ref rGroup;
   ref PChar = GetMainCharacter();
   string groupname;

   int i;
   ref achr;
   int achridx;
   int place = -1;
   float enemydist;
   enemydist = 0.0;
   float memoire=0.0;

   if(CheckAttribute(chr,"runaway")){DeleteAttribute(chr,"runaway");}

   float visibility_range = GetCharVisibilityRange(chr, 4); // maximum visibility range
   float effective_range  = visibility_range;
Reduce that '4' on the visibility_range line to '3' and see what effect that has on ships chasing you and each other. Possibly even go down to '2' and see what happens.
This will make ships "go about their business" much more as they won't "see" each other until much later.
Good test case is the blockading squadron at the begin of the Standard storyline. They're meant to stay where they are unless enemies come close.
But with that number, "close" is already at the other side of the island, which seems a bit excessive to me.

Remove also the '\\' in front of the TraceAndLog lines in that same file.
That will give you all sorts of on-screen clutter to indicate what the AI is making the various ships in the scene do.
My suspicion is that "attacking" and "running away" behaviour is happening a LOT, unless there are really NO enemies around.
That would make for little variety in the ship behaviour, while there are also other tasks "proceeding en route"/"anchoring"/"patrolling".

So basically: Do a bit of experimenting, see what does and doesn't happen and think if maybe that requires some tweaking.
 
Back
Top