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

AI ships use False Flags ?

Talisman

Smuggler
Storm Modder
Has anyone else noticed the following:-

On several occasions when sailing to an island the AI ships generated arround the islands have fought each other, while all carrying the same flag, both in the graphics and on the Sail To menu.

The most recent instance for me was on appraoching Bonaire, 4 Dutch ships were close to the harbour, and they were firing at each other, they ignored me completely. On other occasions at martinique 6 French ships were firing at each other, and the Fort joined in, this also happened at Port Royale, Jamaica, with British ships.

Attached are the log files for the Bonaire incident.

I am playing Build 14 Aplha 9.5 patch 1

I have not noticed this in any of the previous versions. - Has the AI been given ( or evolved on its own <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /> ) the abliity to create false flags for itself.
 
There has been a modification with the sea AI code, but I don't think there's any intentional AI false flag addition.
Let's see what Screwface says of this. <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
Here are a couple more instances, one at Nevis, the other at Port Royale Jamaica.

At Nevis I am just about to set sail from the pirate settlement, under Portuguese flag, there are 6 British Ships in a line across my bow, I just sit there sails furled as they just attack each other and I watch. <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> ( all the triangles in the radar are green all the time)

At Port Royale, I am just sailing towards the Fort, there are 4 British ships close by the Fort, they start firing at each other, the 2 smaller British ships surrender, the 2 larger british ships then turn towards me (their triangles in the radar/compass go to red from green) and they start firing at me. I don't fire back since the Fort doesn't fire during any of this and I don't want it to start shooting at me. The 2 larger british ships also continue to fire at the 2 surrendered ships.

I am flying a Portuguese flag on both occasions and my relations with Britain are Hostile (-61).
 
Thanks again. I notified Screwface who made the new sea AI code, so let's see what he makes of this. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
 
<!--quoteo(post=324821:date=Jun 3 2009, 05:42 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jun 3 2009, 05:42 PM) <a href="index.php?act=findpost&pid=324821"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Thanks again. I notified Screwface who made the new sea AI code, so let's see what he makes of this. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

I have just played the Nevis bit again and noticed that on the Sail To menu the 6 ships have British flags but 2 have a Red border and 4 have a green border.

These apprear to be the 2 groups that attack each other.
 
There one good thing about this I would love to just sit back and watch <img src="style_emoticons/<#EMO_DIR#>/duel_pa.gif" style="vertical-align:middle" emoid=":ixi" border="0" alt="duel_pa.gif" /> then take who lift <img src="style_emoticons/<#EMO_DIR#>/thpirateshipff.gif" style="vertical-align:middle" emoid=":piratesahoy!" border="0" alt="thpirateshipff.gif" />
 
Pirate! <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" />
 
Could you tell me if it happened from the beginning of the game and specially from the first time you sailed around those islands ?
I have started a new game and for the moment i haven't seen it yet. I'm wondering if this bug happens after some regenerations of the coastraiders or after ships have surrended on time and have been regenerated <img src="style_emoticons/<#EMO_DIR#>/dunno.gif" style="vertical-align:middle" emoid=":shrug" border="0" alt="dunno.gif" />
 
I stayed a while around jamaica and i have finished to encounter the problem <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> But i did some observations which confirm what i said above.

First time i was around island there were :

- A dutch merchant group
- 2 pirate groups

Everything was allright between the 2 pirate groups. Pirates attack dutch and one of them surrendered. After that i destructed one of the pirate groups and decided to wait after the next regeneration.

After regeneration there were :

- An english trade group (previously dutch one)
- An english war group (previously pirate)
- A pirate group

And then the 2 english group fire each others when they are close but do not set their task to attack the other group. The war group run after the pirate group when he is in his range. It seems to me that ships keep "memory" of their previous nation and the bug continue even if the sea Ai update mod is set off <img src="style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" />
 
A second problem with coastal raiders nationality is that sometimes you see Dutch ships under English flag, while this should not happen anymore.
This is REALLY annoying and I wished something could be done about it.
In ships_init.c, those ships do have all national chance values set to 0, apart from the Dutch one.
So WHY are the still appearing??? Maybe something related? Though I have seen this straight upon starting a new game as well. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
<!--quoteo(post=325080:date=Jun 4 2009, 01:03 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jun 4 2009, 01:03 PM) <a href="index.php?act=findpost&pid=325080"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->A second problem with coastal raiders nationality is that sometimes you see Dutch ships under English flag, while this should not happen anymore.
This is REALLY annoying and I wished something could be done about it.
In ships_init.c, those ships do have all national chance values set to 0, apart from the Dutch one.
So WHY are the still appearing??? Maybe something related? Though I have seen this straight upon starting a new game as well. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

I think that's a problem of the SetCoastTraffic function. This function seems to re-use the previous type of ships to regenerate the next coastraiders. In the same style as your example above , i have also seen an english trade ship with a HMS before her name <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
TRADE ship with HMS? Grr! <img src="style_emoticons/<#EMO_DIR#>/boom.gif" style="vertical-align:middle" emoid=":boom" border="0" alt="boom.gif" />
The strange thing with the Dutch ships under English flag, though, is that I saw them even right after starting a new game.
There shouldn't have been any regeneration before I ever even went to sea, should there? <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
<!--quoteo(post=325063:date=Jun 4 2009, 09:56 AM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jun 4 2009, 09:56 AM) <a href="index.php?act=findpost&pid=325063"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Could you tell me if it happened from the beginning of the game and specially from the first time you sailed around those islands ?
I have started a new game and for the moment i haven't seen it yet. I'm wondering if this bug happens after some regenerations of the coastraiders or after ships have surrended on time and have been regenerated <img src="style_emoticons/<#EMO_DIR#>/dunno.gif" style="vertical-align:middle" emoid=":shrug" border="0" alt="dunno.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

I started playing the standard storyline with Alpha 9.5 patch 1 ( only story I have played so far on this version). As far as I can remember the 1st time I encountered this was when escaping to Jamaica after French invasion of barbados. 6 British Ships were arround Port Royale fighting and the Fort was firing as well. I think it happens every time I visit an island if 4 or more ships are grouped together. The big ships always seem to pick on the small ones. <img src="style_emoticons/<#EMO_DIR#>/slap.gif" style="vertical-align:middle" emoid=":slap" border="0" alt="slap.gif" />

I have figured out what the green and red borders arround the flags in the Sail to menu mean. Green borders = have not recognised my false colours. Red borders = have. found that out the hard way <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
To pieter : in fact, i was mistaken, it seems when a ship in a trade group disappear, the next regeneration can be a war ship and you can have a trade group with a trade ship and a war ship in. That's the reason of the HMS <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />

For the group of same nation who are firing each others, i think i have found the fix !

In the SEA_AI\sea.c file, at the beginning of the SetCoastTraffic function you can find this section of code :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->for( j = 1; j <7; j++)    //Loop to reset relation BEFORE groupcreation
{
    if(GetCharacterIndex(chrstr + j)==-1) continue;//MAXIMUS
    cr = CharacterFromID(chrstr + j);
    SetCharacterRelationBoth(sti(cr.index), GetMainCharacterIndex(), RELATION_NEUTRAL);
}<!--c2--></div><!--ec2-->
I Wondered why this function need to reset the relation between coastraiders and player and why it do not reset the relation between each coastraider. it seems that a coastraider who was previously pirate and was regenerated in an english group could keep his old relationship with the other ships. When he fired on an english ship of another group, the entire 2 groups becomed enemies and fired.

So i added some code at the end of the function to also reset the relation between each coastraider. Just find the following section in the function :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// KK -->
                if (CheckAttribute(cr, "after_1st_sailto")) DeleteAttribute(cr, "after_1st_sailto");
                RestoreCharacter(cr);    // LDH this may not be needed here, called when character is regen'd 15Feb09
// <-- KK
            }
            // NK <--<!--c2--></div><!--ec2-->
and put this code just after :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->            // Screwface : Fix for groups of same nation firing each others. We need to reset relation between each coastraider
            for(int k = 1; k <7; k++)
            {
                if(GetCharacterIndex(chrstr + k)==-1) continue;
                ref cr2 = CharacterFromID(chrstr + k);
                SetCharacterRelationBoth(sti(cr.index), sti(cr2.index), GetNationRelation(sti(cr.nation), sti(cr2.nation)));
            }<!--c2--></div><!--ec2-->
This fix seems to work fine so you can try it and confirm it or not <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />

For the dutch ships under english flag bug, i will try to have a look on it too <img src="style_emoticons/<#EMO_DIR#>/readon.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="readon.gif" />
 
Thansk Screwface! For the fix and also for looking into the Dutch ships issue. I'd love for that one to finally be sorted. <img src="style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />
In PROGRAM\SEA_AI\AIFantom.c, there is the following code that is intended to make sure this does NOT happen:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->        // PB: Periods -->
// KK -->
        if (iNation >= 0 && iNation < NATIONS_QUANTITY) {
            string sNation = GetNationNameByType(iNation);
            if (CheckAttribute(rShip, sNation) == true && stf(rShip.(sNation)) < FRAND(1.0)) continue;
        }
        string sPeriod = GetCurrentPeriod();
        if (CheckAttribute(rShip, "period."+sPeriod) && stf(rShip.period.(sPeriod)) < FRAND(1.0)) continue;
// <-- KK
        // PB: Periods <--<!--c2--></div><!--ec2-->
Is that function even used for coastal raiders?
 
Of course, that function (Fantom_GetShipType) is used by the Force_GetShipType function and this last one is called by setcoasttraffic to generate coastal raiders.

I found this section of code at the end of the Force_GetShipType function :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    int iShipType = Fantom_GetShipType(maxclass, minclass, type, nat);
    if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
    trace("oh no, we didn't find a ship the first go!");
    iShipType = Fantom_GetShipType(maxclass, minclass, type, nat); // try again, for randomness
    if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
    iShipType = Fantom_GetShipType(maxclass, minclass, type, -1); // clear nation
    if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
    iShipType = Fantom_GetShipType(maxclass, minclass, "none", -1); // clear type too
    if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
    iShipType = GetCharacterShipType(GetMainCharacter());
    return iShipType;<!--c2--></div><!--ec2-->
And i wonder what the function could return if the 2 first call of Fantom_GetshipType were not succesfull and if there was the 3rd call with -1 as nation value ? In this case, the checking of the periods and nation type wouldn't be done <img src="style_emoticons/<#EMO_DIR#>/dunno.gif" style="vertical-align:middle" emoid=":shrug" border="0" alt="dunno.gif" /> Perhaps the problem could come from this section of code <img src="style_emoticons/<#EMO_DIR#>/readon.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="readon.gif" />
 
That would very well be possible! Have you got any idea what could be done about that?
Of course I understand the need to prevent infinite (or long) loops, but I just hate it when I see ships under flags I never want to see them under. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
Would it be possible to change the code so a ship can either belong to a nation or not (boolean) instead of a chance value?
And then set up a seperate array of possible ship types for each nation.
Then when the game could search in that array for the ship type and thus never return a ship from a wrong nation.
 
Lets have a try by replacing the above section of Force_GetshipType by this one :

Code:
	// Screwface
bool finish = false;
int end = 0; // Security to avoid infinite loop
while(!finish && end < 100) // maximum of 100 loop should be enough
{
int iShipType = Fantom_GetShipType(maxclass, minclass, type, nat);
if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0)
{
finish = true;
}
else
{
end++;
}
}
if(finish){return iShipType;}
else{return GetCharacterShipType(GetMainCharacter());}

// old section outcommented
/*int iShipType = Fantom_GetShipType(maxclass, minclass, type, nat);
if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
trace("oh no, we didn't find a ship the first go!");
iShipType = Fantom_GetShipType(maxclass, minclass, type, nat); // try again, for randomness
if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
iShipType = Fantom_GetShipType(maxclass, minclass, type, -1); // clear nation
if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
iShipType = Fantom_GetShipType(maxclass, minclass, "none", -1); // clear type too
if(iShipType < SHIP_TYPES_QUANTITY && iShipType >= 0) { return iShipType; }
iShipType = GetCharacterShipType(GetMainCharacter());
return iShipType;*/

I tried it a little and it seems to me that ships of differnet nation are really differents (specially the big ones). Could you try it and tell me if you still encounter the same bad flag ships as before. I don't know very well all the different type of ships of the game and their native nations <img src="http://forum.piratesahoy.net//public/style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
I've encountered a Dutch lineship under english flag so the problem don't come from this section of code <img src="style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" /> Forget my modification of the Force_GetshipType function. As we said it was too beautiful to be true <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />

Plus, you were right when you said that's not a question of regeneration because it happens around an island where i was sailing for the first time <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" />
 
I finally found an error in Fantom_GetShipType function which could explain the bug :

In this section of code :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// KK -->
        if (iNation >= 0 && iNation < NATIONS_QUANTITY) {
            string sNation = GetNationNameByType(iNation);
            if (CheckAttribute(rShip, sNation) == true && stf(rShip.(sNation)) < FRAND(1.0)) continue;
        }<!--c2--></div><!--ec2-->

For the english ships, the GetNationNameByType(iNation) return "britain", not "england" or if you look in ships_init.c, the attribute of rShip (stf(rShip.(sNation)) should be rShip.england so in the code above, that's rShip.britain attribute which is checked and as this attribute do not exist, british ships can have types of all nations ! To fix that, just add a line of code :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// KK -->
        if (iNation >= 0 && iNation < NATIONS_QUANTITY) {
            string sNation = GetNationNameByType(iNation);
            if(sNation == "britain"){sNation = "england";} // Screwface : Fix for other nations type under english flag
            if (CheckAttribute(rShip, sNation) == true && stf(rShip.(sNation)) < FRAND(1.0)) continue;
        }<!--c2--></div><!--ec2-->

It confirms that the bug is only for the english ships, isn't it ?
 
Back
Top