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

Improve the Sea AI

<!--quoteo(post=328150:date=Jun 12 2009, 09:10 PM:name=PeterWillemoes)--><div class='quotetop'>QUOTE (PeterWillemoes @ Jun 12 2009, 09:10 PM) <a href="index.php?act=findpost&pid=328150"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->If you can increase visibility range in clear weather too, that would be nice. I can often see the other ship's flags with my bare eyes from my ship, but they dont reckognize me.<!--QuoteEnd--></div><!--QuoteEEnd-->
In fact, visibilty range of other ships increase according to their leadership and sailing skills. The difference with the default v-range is insignificant for the low level captains but a captain with 10 of leadership and 10 of sailing can see about 500 yards more far than the default v-range so a good captain could see you before a low level one.
Plus, the chance for your false flag to be recognized increase if you approach ships but is low if you keep your distances <img src="style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />
 
Sounds advanced to me. Alright then! <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
<!--quoteo(post=328144:date=Jun 12 2009, 08:39 PM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jun 12 2009, 08:39 PM) <a href="index.php?act=findpost&pid=328144"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I have something in my mind which i would like to have your opinion !
If you hoist an enemy flag close to ships, they will become enemies and if you or they run away out of visibility range and if you hoist a neutral flag, they will become neutral.
I just thought that if you hoist an enemy flag of some ships who are in your V-range, perhaps the recognized attribute should be set to true for those ships and they will remain enemy even if you change again your flag. In fact, they will remenber you as the ships who have detected your false flag. What do you think about that ?<!--QuoteEnd--></div><!--QuoteEEnd-->That does make sense to me. If you don't want ships to be hostile to you, don't fly a hostile flag near them. <img src="style_emoticons/<#EMO_DIR#>/no.gif" style="vertical-align:middle" emoid=":no" border="0" alt="no.gif" />
 
I made some change in the Sea Ai update :

Now, relations are updating when you hoist another flag at sea but with some limitations so you should be careful before hoist another flag

- Enemy ships who have you in their visisibility range will remain enemies even if you hoist a neutral flag.

- If you hoist an enemy flag of ships who have you in their v-range, they will remember your deceit and will stay enemies as ships who have recognized your false flag (except if you change your ship)
- If you open fire on a ship, he will also remember you

- Relations with forts are also updating when you change your flag. This works even if you are relatively close to a fort because as i said, the distance calculation is erroneous with forts. It seems always bigger than for a ship. To confirm that, try with your spyglass. Watch a ship who are close to a fort and watch the fort, the distances will be radically differents.

Update is for build 14 alpha 9.5 Patch 1 <img src="style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />
 

Attachments

  • Sea_Ai_update_for_build_14_9.5_Patch_1.rar
    67.6 KB · Views: 53
That sounds absolutely great! Thanks very much! <img src="style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />
 
That does indeed sound awesome as!
Thanks for the whole Sea AI improvement it has made the game so much better in itself
 
<img src="style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />

@ Pieter,

Be careful, i just saw that in the Battleinterface.c version i used in my update, there is a "relic" of ASVS new officer system code which i was experimented when i made this update <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />

So normaly, this section of code :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    /*bool    retRepair = GetCharacterPerkUsing(chref,"InstantRepair");
    if(!retRepair)
    {
        int cn;
        for(int i=1; i<4; i++)
        {
            cn = GetOfficersIndex(chref,i);
            if(cn!=-1)
            {
                if(GetCharacterPerkUsing(GetCharacter(cn),"InstantRepair"))
                {
                    retRepair = true;
                    break;
                }    
            }
        }
    }*/ // ASVS commented that out, see below.
    bool retRepair = GetOfficersPerkUsing(chref,"InstantRepair"); //ASVS - come on, we have a function for that, why not using it?<!--c2--></div><!--ec2-->

must be :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    bool    retRepair = GetCharacterPerkUsing(chref,"InstantRepair");
    if(!retRepair)
    {
        int cn;
        for(int i=1; i<4; i++)
        {
            cn = GetOfficersIndex(chref,i);
            if(cn!=-1)
            {
                if(GetCharacterPerkUsing(GetCharacter(cn),"InstantRepair"))
                {
                    retRepair = true;
                    break;
                }    
            }
        }
    }<!--c2--></div><!--ec2-->

Sorry for this inattention error <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
Thanks for testing out my mod, Screwface!

This part should work even with my officer mod off, it just remove some duplicate code. If I remember well, the part I commented out is the exact replica of the original GetOfficersPerkUsing() function.
 
<!--quoteo(post=329746:date=Jun 16 2009, 11:14 PM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jun 16 2009, 11:14 PM) <a href="index.php?act=findpost&pid=329746"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->@ Pieter,
Be careful, i just saw that in the Battleinterface.c version i used in my update, there is a "relic" of ASVS new officer system code which i was experimented when i made this update <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
Sorry for this inattention error <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->I used WinMerge to install your latest update and already caught that. But thanks for letting me know. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
 
Mr. Lenin had some weird fort-related issues in <a href="http://forum.piratesahoy.net//index.php?s=&showtopic=13756&view=findpost&p=329961" target="_blank">this thread</a> and your recent Sea AI update has fixed that for him. So good job, Screwface! <img src="style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />
 
I've been having some weird issues with flags. It all started with me testing the Jack Sparrow Grand Entrance scene and
noticing that despite the <i>HoistFlag(ENGLAND);</i> line in quests_reaction.c, the Dauntless was still flying my own colours.
So then I tried executing the HoistFlag line at sea and absolutely nothing happened. Relations weren't updated, nor did the flag on my masts change.
Not even after a RefreshFlags.

So then I noticed that apparently the flags shown on your ship are ALWAYS the pchar.nation flags. The following did update my flags properly:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    pchar.nation = PIRATE;
    RefreshFlags();<!--c2--></div><!--ec2-->
But still no other ships turned hostile. The following did make the ships go hostile:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    pchar.nation = PIRATE;
    HoistFlag(PIRATE);
    SetRelationsForFlag(PIRATE);
    RefreshFlags();<!--c2--></div><!--ec2-->
But then I got away from the hostile ships, raised a British flag and some ships were friendly again, but not the ones that had seen me with my pirate flag.
So that is good. But then I went to the friendly ships, who happened to be in a battle with the pirates, then I executed that code again.
My ship did end up showing pirate flags again, but the British ships didn't go hostile and the pirate ships didn't go friendly.
The second I can understand, but the first seemed rather weird to me.

So a couple of questions:
1. What DOES the HoistFlag function do? It doesn't update the flag I'm flying, nor the relations.
2. Do I REALLY need to change pchar.nation if I want to show different nation flags on the player ship?
3. Why didn't those British ships turn hostile when I executed my pirate flag code, while it DID work before?

In short... the whole flags thing has me rather confused. <img src="style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" />
 
Just for clarity's sake, this is what I WOULD like to happen upon a HoistFlag execution:
1. Nation relations are updated for the hoisted flag
2. Hoisted flag shows up on player ships
3. Hoisted flag shows up in interface screens
4. Pchar.nation is NOT changed

So I'd rather have just one line of code for raising a new flag, being HoistFlag and not have to do a whole bunch of things for it to work.
HoistFlag is used for that purpose in various parts of various quests, but now I find that it doesn't do what we thought it did.
And could we then put the RefreshFlags() call IN the HoistFlag function and only actually refresh flags if you hoisted another flag?
 
This is also what I would really like to happen, it saves us lines of code and allows us to keep pchar.nation the same as it was originally (unless something drastic happens and you have to turn pirate/your own nation) <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
Isn't pchar.nation used to check if you're flying a false flag? You select your nation in the Select Storyline screen, right?
And I imagine that if you're flying a flag of that nation OR your own nation, you will not be recognized as flying a fake flag, because it ISN'T a fake flag.
But if you fly any other flag, then there would be a chance of being recognized. Right?
But that gets severely messed up if pchar.nation has to change all the time for a flag change. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
I think it always has been like that, if you look in the battleinterface.c, the code section to hoist the pirate flag by the fast command is based on the same way :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    case "BI_HoistFlag":
.........
        // become an evil pirate
        mainChr.nation = PIRATE; ---------Indicate the Nation------------
        SetShipFlag(GetMainCharacterIndex());
        for(cc = 1; cc < 4; cc++)
        {
            int compIdx = GetCompanionIndex(mainChr, cc); // added by MAXIMUS [checking, if you have companions]
            if(compIdx<0) continue; // added by MAXIMUS [checking, if you have companions]
            if (GetRemovable(GetCharacter(compIdx)))
            {
                Characters[compIdx].nation = mainChr.nation;
            }
        } // NK so comps' nations update
// KK -->
        if (ENABLE_FLAGS == 0) {
            // hostile all nations, ally pirates
            if(GetRMRelation(mainChr, PIRATE) < REL_AMNESTY) SetRMRelation(mainChr, PIRATE, REL_AMNESTY);
            SetRMRelation(mainChr, ENGLAND, REL_WAR);    // ccc dec 05
            SetRMRelation(mainChr, FRANCE, REL_WAR);    // ccc dec 05
            SetRMRelation(mainChr, SPAIN, REL_WAR);    // ccc dec 05
            SetRMRelation(mainChr, PORTUGAL, REL_WAR);    // ccc dec 05
            SetRMRelation(mainChr, HOLLAND, REL_WAR);        // ccc dec 05
            if(bUSAExists) SetRMRelation(mainChr, AMERICA, REL_WAR);        // ccc dec 05

            UpdateRelations();
            RefreshBattleInterface();
        } else {
            HoistFlag(PIRATE); -----------HoistFlag function----------
            SetRelationsForFlag(PIRATE); -----------Update relations----------
        }
        RefreshFlags();---------and refresh flags------------<!--c2--></div><!--ec2-->

I think that your real relations with nations is stocked in an array (ActualRMRelations[iNation]) and that's not the same functions which are used to check your flag relations and your real relations so it doesn't matters that your Pchar.nation change all the time ! This attribute is only used for flag relations and when your nation is your personnal nation, in this case that's the ActualRMRelations array which are used to update your relations with nations...
 
So setting your nation in the Select Storyline interface really DOESN'T do anything?
And so we really SHOULD be setting pchar.nation INSTEAD of using HoistFlag?
But what DOES HoistFlag do? Becuase I haven't observed it doing ANYTHING. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
If you are at land, that's not necessary and neither in select storyline interface because a hoistflag and SetRelationsForFlag are done when you log to sea in the sea.c so you only have to set the pchar.nation as you said !
If i have understood all, it seems hoistflag function set all your relations with all nations according to the relations they have with the nation you have hoisted. the function update the array of your flag relations (FlagRMRelations[iNation] not the same as you real relations). This array is used by other functions (as getflagrelation)
And the SetRelationsForFlag is used to update your relations really according to this array !
 
So HoistFlag prepares the array of relations and SetRelationsForFlag actually does it? So you do need those two consecutive lines?
Why not include those two functionalities in the same function? <img src="style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" />
Anyway, so setting pchar.nation <i>is</i> the right way to go about things? Right... <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
<!--quoteo(post=334195:date=Jun 30 2009, 03:51 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jun 30 2009, 03:51 PM) <a href="index.php?act=findpost&pid=334195"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->So HoistFlag prepares the array of relations and SetRelationsForFlag actually does it? So you do need those two consecutive lines?
Why not include those two functionalities in the same function? <img src="style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" />
Anyway, so setting pchar.nation <i>is</i> the right way to go about things? Right... <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->
The best example is in the nationrelation.c when you change your flag by interface and can explain why the 2 fonctionnalities is not in the same function.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->void KAM_SetColours(int ReqdNation)
{
    int i;

// KK -->
    PChar.nation = ReqdNation;
    if (ENABLE_FLAGS == 1) {
        HoistFlag(ReqdNation);
        if (IsEntity(&BattleInterface)) SetRelationsForFlag(ReqdNation);
    }<!--c2--></div><!--ec2-->
In fact, the SetRelationsForFlag only need to be recall if you are at sea ! It seems that the hoistflag is necessary even if you are at land but i think that the Pchar.nation change is the most important to do before !

<!--quoteo(post=334195:date=Jun 30 2009, 03:51 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jun 30 2009, 03:51 PM) <a href="index.php?act=findpost&pid=334195"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->2. Do I REALLY need to change pchar.nation if I want to show different nation flags on the player ship?
3. Why didn't those British ships turn hostile when I executed my pirate flag code, while it DID work before?<!--QuoteEnd--></div><!--QuoteEEnd-->
2 - yes <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
3 - Never saw that <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
Ok; thanks a lot for clarifying it then, Screwface. At least I know then how to do things PROPERLY. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />
 
Back
Top