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

Fixed Sea Relations: Behaviour for Recognizing False Flags

How should enemy forts treat players sailing into port under a false flag?

  • Other, please specify below

    Votes: 0 0.0%

  • Total voters
    20
The memorizing is ship-dependent. A ship that was on the other side of the island when you went ashore would not remember you as being hostile and might believe your friendly flag when you go back to sea.
But a ship that you passed relatively closely would have seen you going in under a British flag.
Try renaming your ship and see if they start believing you again.
If there had been a French ship near me when the British flag was up, it would not have remembered me being hostile because by the time I was ashore, it would have been underwater. :rpirate

I think the false flag detection code was just dumped into a default function which is run very frequently.
That frequency isn't intentional, but simply a result of what was simple to code at the time.
@Levis was intending to have a look at such too-frequent checks and tone things down a bit. That'll help nicely with performance too.
In the meantime, the range of chance values should just be really, really small. So that while there IS a chance of being recognized any second, that chance is always low.
That's easily enough done. Just change the calculation line to:
Code:
float chance = rank/MAX_RANK * (11.0-sneak)/100.0;

In the line:
Code:
chance = fclamp(CHANCE_DETECT_FALSE_FLAG_BASE, CHANCE_DETECT_FALSE_FLAG_MAX, chance);
what are "CHANCE_DETECT_FALSE_FLAG_BASE" and "CHANCE_DETECT_FALSE_FLAG_MAX"? OK, they're the maximum and minimum chances, but what are their values? What I said earlier about the guy with no fame and Luck 10 might not be correct if "CHANCE_DETECT_FALSE_FLAG_BASE" is higher than 0.00417, not to mention it might mean that change of calculation code to divide by 100 rather than 10 might not do much good...
 
If there had been a French ship near me when the British flag was up, it would not have remembered me being hostile because by the time I was ashore, it would have been underwater. :rpirate
That depends on what you and the game consider to be "near". Anyway, if you don't get an on-screen message, then the reason for them being hostile should not be because you were caught as flying a false flag.
Did you try that "change ship name" thing? I seem to remember that should work, but I'm not entirely sure. Worth a shot anyway since it is easily done while ingame. :shrug

That's easily enough done. Just change the calculation line to:
Code:
float chance = rank/MAX_RANK * (11.0-sneak)/100.0;
In the line:
Code:
chance = fclamp(CHANCE_DETECT_FALSE_FLAG_BASE, CHANCE_DETECT_FALSE_FLAG_MAX, chance);
what are "CHANCE_DETECT_FALSE_FLAG_BASE" and "CHANCE_DETECT_FALSE_FLAG_MAX"? OK, they're the maximum and minimum chances, but what are their values? What I said earlier about the guy with no fame and Luck 10 might not be correct if "CHANCE_DETECT_FALSE_FLAG_BASE" is higher than 0.00417, not to mention it might mean that change of calculation code to divide by 100 rather than 10 might not do much good...
Those two are probably defined in PROGRAM\InternalSettings.h; have a look there.
You do make a valid point; the base value needs to allow properly low numbers. Actually, I think the base should be at 0 so that it just prevents any crazy negative values.
 
Renaming the ship had no effect. I loaded up the same savegame, renamed the ship, put to sea and "Sailed To" a ship which definitely hadn't seen me before I approached the island because it was Dutch and I've never seen a Dutch ship during any previous session from this savegame. It was immediately hostile, so the first thing I did was check the Relations screen to confirm that (a) I did have a French flag up and (b) Holland hadn't declared war on France. Then I sank it. Another couple of ships were also immediately hostile, correctly - they were pirates. The final pair of ships were French and the game seems to remember their existence, I've met the Enchantrice every time I've done this. They were friendly. I "Sailed To" the port, checked the tavern news to see if Holland had declared war on France recently and my relations screen had not been updated; no such news, Holland and France are still at peace. Then I put to sail again, "Sailed To" the French ships again, and they were hostile this time. I'd put that "chance = 0;" line back into "nations.c" so neither the Dutch or French ships should have recognised me.

Perhaps they're flying false flags. xD
 
There must be some other code in place that triggers hostile ships at sea in addition to the false flag detection chance.

I know the on-sea relations between ships is confusing at best and I couldn't really figure it out when I tried.
There was once a different approach to the coding for nation relations, but that messed things up even worse.
So I haven't dared touch that now. :facepalm
 
PROGRAM\InternalSettings.h:
Code:
#define CHANCE_DETECT_FALSE_FLAG_BASE       0.1     // FLOAT - minimal probability of detecting false flag.
#define CHANCE_DETECT_FALSE_FLAG_MAX       0.99   // FLOAT - probability of detecting false flag when Nathaniel rank=MAX_RANK.

The actual recognizing is done in PROGRAM\Screwface_functions.c in the CheckForMainCharacterfalseflag function.
This is called through Find_nearest_inf_ship in the same file, which again is called through Improve_SeaAi also in there.
That is executed through procUpdateTime in PROGRAM\BATTLE_INTERFACE\LogInterface.c .
I think that is called basically continuously, but there is a check in place for:
Code:
#define UPDATE_AI_FREQUENCY       1       // INT - Time frequency in minutes for AI update at sea

So based on that, the false flag detection check is done every minute. The lowest possible value is 0.1 which is actually 10%.
That means that there is a just about 100% chance of being detected by any ship within 10 minutes.
Nope, that don't sound so good.

My first suggestion is to set CHANCE_DETECT_FALSE_FLAG_BASE to 0.01 or perhaps even just to 0.
That'll at least allow the low chances to become proper low instead of being fixed at a too-high minimum value.

Then the question is if the maximum chance should actually be able to go up to 99% at all.
A 99% chance every minute sounds potentially VERY excessive.
 
So far I've been unable to make much sense of this.
Did get recognized, but by a bunch of ships that were quite far away from my own location.
The one I was right next to seemed to be perfectly OK with my presence there.
 
More data:
I'd just raided Kralendijk, then hoisted a Spanish flag so I wouldn't have to fight the fort again, and again, and again... There are a couple of "logit" lines at the bottom of "GetChanceDetectFlag", commented out, so I've uncommented them. This is the result:
rank.jpg
Look closely and you'll see a pair of lines which have almost faded out of existence. What's "rank"? I thought it was your fame, which for me is "Scourge of the Caribbean", which is one below the ultimate "Scourge of the Seven Seas". This would be consistent with my "rank" being 11. But that faded line shows rank 12, yet when it first appeared and I checked "Relations", I was still "Scourge of the Caribbean". Also, what's "score"?

Is "GetChanceDetectFlag" called every time a recognition check is made? If so, it's certainly not every second - those messages were appearing about once or twice a minute.

Merchants should perhaps have a lower chance than warships of recognising your false flag. For one thing, it's not their job, that's why there's a navy. For another, it's very unwise to challenge an Endymion when you're a tier 7 tiddler. One such ship got lucky, I was close enough to board it, and was planning to board and sink it to save ammo. But the captain was also sensible and surrendered right away, so being a nice guy, I went back to the port I'd just left, then sold the cargo, the ship and the captain. And then I tried going to sea again. This time there were two tier 7 tiddlers who seemed to be sensible, they stayed friendly for a while. I decided to see if I could sail the whole way out of port, which anyone playing Iron Man mode or choosing to Direct Sail everywhere would have to do anyway. Sure enough, the inevitable happened and they turned hostile, and this time I wasn't close enough to board and couldn't be bothered closing.
Did I mention that it's a really bad idea for a tier 7 tiddler to challenge an Endymion? :pirate41:
 
GetScore returns a value indicating how well you've done for yourself. This determines your "Known as" on the relations screen, for example "Famous Pirate".
It depends on whether you're married, have a mistress, the difficulty level and your average "crew share ratio".

GetRankFromPoints returns rank, based on points from your score value.

I am wondering if it might not be the best idea to throw just about everything out of the window where this code is concerned and then re-implement is from scratch as we want it.
Looking through it two days ago, it all looks very fancy and amazing. But in testing, it doesn't seem to be doing what I think it should.
Not sure if a simple fix is possible. And it seems there are a LOT of variables being used here. Perhaps a bit too many. :facepalm

Indeed you're right on the check frequency: While the function that calls it IS checked more often, there is a check in place to limit the false flag checks to once per minute.
 
1. I wanted to sail into Kralendijk to beg for forgiveness so raised the white flag of truce. It didn't work as two warships sailed out and started shooting holes in my ship.
When I did some testing a while back, it did seem that the false flag is doing different things than what I think it should.
But I still have to look into that.

Also, the white flag function is unfinished and I would definitely NOT recommend using that for anything ever.
 
Others have reported using it successfully so I thought I would give it a try. :shrug I ended up sneaking in using my regular flag that they were hostile to.
 
In the latest patch false flags seem to be really random at first. One time I was recognized by a ship I never did see from a great distance, and the next time I sailed very close to a 6th rate without being recognized.

After a while they would either turn towards me and attack from a long distance or turn away and leave depending on what type of ships they were. At that point I just kept my personal flag and would just jump back and forth between the world map and direct sail until the coast was clear, then sail in.
 
False flags are unreliable as far as other ships are concerned. I've seen them turn hostile without even getting a message that I've been recognised. They do sometimes work on ships, and they always work on forts so they're still a useful way of getting into a hostile port, which can be crucial to some story quests. ("Bartolomeu" starts you off hostile to France but your first delivery for Eugene Martin is to St. Pierre and your third is to Marigot.)
 
Yep, this still needs to be looked at. I fear it'll be another time-consuming and annoying piece of reverse-engineering code that should have already been working properly in the first place. :modding
Still without a normally installed computer though, so more patience required....
 
There is no rush. A poorly running computer can cause errors that ruins hours of work. :modding
 
In the near future, I will be looking into this functionality and will rewrite it so that it hopefully works better and makes more sense.

Here's what I've got in mind:
- False flag detection works only for ships within the appropriate visibility range (see below)
- False flag detection works only for ships that are hostile to you personally
- Detection chance increases the closer you get to the ship, so passing them at a distance should be OK
- If recognized, you will automatically hoist the flag of your Served Nation

Situation where you are hostile to a ship you are close to, but are friendly based on your current false flag:

CURRENT SITUATION:
When you hoist a flag hostile to them within visibility range of them, they will (of course) turn hostile AND you will be marked as "traitor" by their nation.
If that has happened, you can be recognized ashore for your actions in towns of that nation. You can only be "traitor" to one nation at a time.

Alternate idea: Do away with this feature altogether and instead have the "traitor" functionality linked to your ServedNation.
If this is PIRATE for whatever reason, you can be recognized as a traitor in ALL non-pirate towns.


-----------------------------------------------

There are four visibility ranges defined which affect what you can see through the Spyglass/Sail-To Interfaces:
default = 3000.0: You cannot see any details for ships exceeding this range
1 = 1000.0: You can recognize ship type for ships exceeding this range
2 = 500.0: You can see nation for ships exceeding this range
3 = 300.0: You can see name for ships exceeding this range

These values are halved at night and further reduced by any fog density.

At the moment in some cases the other ships' captains' leadership and sailing skill are added as per this formula:
Code:
SKILL_LEADERSHIP + SKILL_SAILING * 5
This number can vary between 6 and 60 which seem like relatively low values compared to the value of the ranges.
So I'm not sure if this serves any purpose and if this is something we should maintain.

One extra idea is to have an on-screen message indicating the value of the visibility in words (e.g. "Good"/"Moderate"/"Poor").
We could then also change the values used here to match with specific of these ranges,
so that it would be clearer to the player what they and other ships can and cannot see of each other.
 
@Grey Roger: Could you have a look at the above post? Based on your posts on the Brainstorming forum, I am thinking you might have missed it.... :oops:
 
Recognition would have to be within visibility range 3 (can see ship's name). The other ship might be able to see your flag (range 2) but without any other details it has no reason to disbelieve the flag. The on-screen message indicating visibility might be good, but another clue is that if you can see the other ship's name, it can probably see yours. ;)

Perhaps the range should also be affected by spyglass type? (Can the dirt cheap spyglass even get the ship's name?) If so, you'd need to work out what sort of spyglass the other ship has. And, for preference, put it in the ship's chest. If the enemy captain has such a good spyglass that he can make out my details when I can barely see his flag, and then raises the alarm, I want to board the ship and steal his spyglass. :rpirate

Merchants should have a lower chance of detecting you than naval ships. As I mentioned somewhat earlier in this thread, it's not a merchant's job to look for trouble, especially if you're in a bigger ship. Little coastal freighters like luggers and sloops really don't want to upset any big scary pirate that might be flying a false flag! Naval ships are paid to look for trouble.
 
Recognition would have to be within visibility range 3 (can see ship's name). The other ship might be able to see your flag (range 2) but without any other details it has no reason to disbelieve the flag. The on-screen message indicating visibility might be good, but another clue is that if you can see the other ship's name, it can probably see yours. ;)
There is some sense in that, of course. We'll have to see how it works out in testing.
Changing one range in another is done by simply changing one number, so that is easily changed.
But if false flags are only detected when you're right alongside the other ship, then the whole feature pretty much has no purpose as that does not happen all that often.
Having a false flag feature is only interesting if there is a risk involved, after all.

I could imagine that a ship may get suspicious if you manoeuvre strangely when approaching them, even before being able to read the ship name.
Which would suggest that perhaps there can be a slight chance of being recognized within flag range, with that chance once you get into name range.

Perhaps the range should also be affected by spyglass type? (Can the dirt cheap spyglass even get the ship's name?) If so, you'd need to work out what sort of spyglass the other ship has. And, for preference, put it in the ship's chest. If the enemy captain has such a good spyglass that he can make out my details when I can barely see his flag, and then raises the alarm, I want to board the ship and steal his spyglass. :rpirate
Non-player ships don't use a spyglass at all. I suppose that is the reason for the skill-related addition for NPC ships so that higher level captains can see further:
Code:
SKILL_LEADERSHIP + SKILL_SAILING * 5
The spyglasses also don't govern the RANGE at which certain information becomes available; a crappy spyglass simply won't show nation at all, while the best shows nation starting at the default range.
So we might be able to skip on that for the foreseeable future.

Merchants should have a lower chance of detecting you than naval ships. As I mentioned somewhat earlier in this thread, it's not a merchant's job to look for trouble, especially if you're in a bigger ship. Little coastal freighters like luggers and sloops really don't want to upset any big scary pirate that might be flying a false flag! Naval ships are paid to look for trouble.
Recognizing a false flag doesn't necessarily need to mean that the ships go and attack you. It could also trigger a flee response, which would be much more sensible for a merchant ship.
I can certainly imagine that some merchants may not be very trusting of other ships and would rather recognize you and flee than to let you come close and allow you to attack them without them having the chance to defend themselves.

For the time being, I first want to get a system that technically works and isn't bugged like it is now.
Once that is done, we can start making it more fancy by distinguishing between captain types, linking it with AI behaviour and having different spyglasses give different visibility ranges for NPC ships.
 
Maybe use ship size instead of spyglass, if you can't generate a spyglass for a NPC ship? A large ship is more likely to be rich and able to afford a good spyglass. (Or, in game terms, the captain is more likely to be high enough level to be allowed a good spyglass.) A little lugger is not so rich (that's the sort of ship with which you start the game, so the captain is low level) and doesn't have a good spyglass. That's another reason for small ships to be less likely to recognise you.

The flee response might make sense on the open sea where there's plenty of room to get out each other's way, and if you don't want to get out of his way then he gets out of yours. It's less sensible near a port where you're bound to get close to another ship that happens to be approaching, leaving or parked near the same port.

Another problem is that if I'm in a genuine naval ship and a small merchant vessel runs away from me, that makes me suspicious. I'm Dutch, his flag says he's Dutch too, so he should have nothing to fear, yet he's running away, which means he may be a smuggler, a spy, or up to some other mischief. Which means I'm going to chase him. Turn that around; I'm in a small merchant ship, a warship carrying the same flag is approaching me which means he may already suspect I'm up to no good, and if I try to run away then that's as good as admitting it.
 
Maybe use ship size instead of spyglass, if you can't generate a spyglass for a NPC ship? A large ship is more likely to be rich and able to afford a good spyglass. (Or, in game terms, the captain is more likely to be high enough level to be allowed a good spyglass.) A little lugger is not so rich (that's the sort of ship with which you start the game, so the captain is low level) and doesn't have a good spyglass. That's another reason for small ships to be less likely to recognise you.
If anything, I'll link it to captain skills for the time being. Once the system actually works, we can do further finetuning.

The flee response might make sense on the open sea where there's plenty of room to get out each other's way, and if you don't want to get out of his way then he gets out of yours. It's less sensible near a port where you're bound to get close to another ship that happens to be approaching, leaving or parked near the same port.
So the AI has to check the location of the ports relative to its own position now too?
This is getting more complicated by the minute. I don't intend to touch the AI behaviour while we're still working on Build 14. :no

Another problem is that if I'm in a genuine naval ship and a small merchant vessel runs away from me, that makes me suspicious. I'm Dutch, his flag says he's Dutch too, so he should have nothing to fear, yet he's running away, which means he may be a smuggler, a spy, or up to some other mischief. Which means I'm going to chase him. Turn that around; I'm in a small merchant ship, a warship carrying the same flag is approaching me which means he may already suspect I'm up to no good, and if I try to run away then that's as good as admitting it.
NPC ships don't use false flags (yet? Build 15 idea!) so if you are Dutch, flying a Dutch flag and encountering a Dutch merchant, there is no false flag checking to be done.
On the other hand, the logic does stand from the side of the NPC merchant ship, but again, that is adding more complexity to something doesn't even work right now in a simplified form.
 
Back
Top