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

Solved False Flag Code Not Working (Need help to track this down!)

I've just been testing the same thing in WIP 12 and haven't seen it behave wrong yet.
Relations when I initially go to sea all match up with the flag I'm flying. There were a few exceptions, but I always saw the "We are recognized" log message when that happened.
So at least in WIP 12, if ships friendly to my flag ARE hostile to me, it IS because of the false flag recognizing code.
In WIP 15, they're hostile before that code ever gets round to being executed.

Then as I stay close to those ships, eventually they do recognize me and turn hostile.
But my tests being in the early game, this sometimes takes a while. Seems to work properly to me.
Now as for getting it working just as properly in WIP 15, eh....? :wp
 
Please let me know if this is NOT fixed in "Build 14 Beta 3 WIP 12/15 Hybrid Test Version 2".
 
On Hylie's observation elsewhere, as far as I can tell, false flag recognizing DOES work properly in this version.
I did include some code that if you START the game with a false flag, nobody will recognize you until you go to the worldmap.
This to prevent being blown out of the water by the fort at game start.
 
Since I removed the new nation relations behind-the-scenes code from the WIP 13-15 code base, this seems to be working again.

Note that if you START the game with a false flag, everybody WILL believe it until you go to the worldmap.
Of course using DirectSail eventually also qualifies as using the worldmap.
 
It does take quite a while at game start before they recognize me. I had to circle those Spanish over and over before they'd catch on.
But as the game progresses, that should be getting quicker. Anyway, it does what it is coded to do. If you feel it is unbalanced, we can always try adjusting it.
 
I started a new game this morning and went straight to San Juan and those hostile Spaniards. I made it mosrt of the way in without being recognized, but eventually was and was attacked by 2 ships. The wind was with me and I raced past them into the harbor, but still got shot up pretty good. I did not get the range at which the first recognized me.
Just now at level 5 as approaching Concepcion I was recognized at 5,000 and 6,000 yards. Luckily I had the good wind this time and got into port without being intercepted as those ships were on the other side of the island.
That distance seems too far and unless one has the good wind it is likely that you will be intercepted. 3,000-4,000 yards would be better as that is approx. the distance that forts begin shooting at you.
 
Right in the early game? When I tried that, I had to circle my enemies for several minutes before they caught on.
Apparently sometimes it is far, sometimes it is close. What difficulty are you playing at? When I tested, it was at Journeyman.

Relevant code is here in PROGRAM\NATIONS\nations.c:
Code:
float GetChanceDetectFalseFlag()
{
// original code -->
//    float rank = GetRankFromPoints(GetScore(GetMainCharacter()));
//    return CHANCE_DETECT_FALSE_FLAG_BASE+(CHANCE_DETECT_FALSE_FLAG_MAX-CHANCE_DETECT_FALSE_FLAG_BASE)*rank/MAX_RANK;
// original code <--

// LDH -->
    ref mchr = GetMainCharacter(); // KK
    float score  = GetScore(mchr); // KK
    float rank   = GetRankFromPoints(score);
    int   sneak  = GetSummonSkillFromName(mchr, SKILL_SNEAK);
    int difficulty = GetDifficulty();
    float chance = rank/MAX_RANK * (11.0-sneak)/10.0;
    chance = chance * difficulty/2.0;        // 0.5, 1.0, 1.5, 2.0
//    chance = chance * (difficulty+1)/3.0;        // alternate difficulty calculation 0.67, 1,0, 1.33, 1.67
    chance = retmin(chance,1.0);    // so chance doesn't go over 100%
//    LogIt("False Flag Detection - Score: " + score + ", rank: " + rank + ", Sneak: " + sneak + ", Chance: " + chance*100.0 + "%"); // for testing
//    LogIt("The chance of your false flag being detected is " + chance*100.0 + "%");    // Tell the player, it might get him used to looking for it.
    return chance;
// LDH <--
}
And here in PROGRAM\Screwface_functions.c:
Code:
void CheckForMainCharacterfalseflag(ref chr, float range)
{
    Ref Pchar = GetmainCharacter();
    ref rgroup = Group_GetGroupByID(GetGroupIDFromCharacter(chr));
    float distance;
    int i = 0;
    bool Recognized = false; // To avoid being recognized if we hoist our own nation flag

    if (ENABLE_FLAGS == 1)
    {
        distance = Ship_GetDistance2D(Pchar, chr);
        if(distance <= range)
        {
            int MyFlag = GetCurrentFlag();
            float chance = 1 - (distance / range);
            chance = 0.5 + chance; // 0.5 will be decreased if you are too easily recognized
            //logit(" "+chance+" ");

            if (iForceDetectionFalseFlag == 0) {
                if ((frnd() >= (GetChanceDetectFalseFlag() * chance)) || (MyFlag == PERSONAL_NATION)) {
                    MyFlag = GetCurrentFlag();
                } else {
                    MyFlag = PERSONAL_NATION;
                    Recognized = true;
                }
            }
            if (iForceDetectionFalseFlag == 1)
            {
                    MyFlag = PERSONAL_NATION;
                    Recognized = true;
            }
            if(Recognized==true && GetRMRelationType(GetActualRMRelation(sti(chr.nation))) == RELATION_ENEMY && !Checkattribute(chr,"recognized"))
            {
                chr.recognized = 1;
                chr.EnemyShipName = Pchar.Ship.Name;
                chr.EnemyShipType = Pchar.Ship.Type;
                if(iRealismMode<2) Log_SetStringToLog(TranslateString("", "We are recognized, captain!"));
                SetCharacterRelationBoth(sti(chr.index), sti(Pchar.index), RELATION_ENEMY);
                // Each ship of group must have recognized you just in case where leader would surrender or be destroyed
                bool fini = false;
                while (!fini)
                {
                    int iCharacterIndex = Group_GetCharacterIndexR(rGroup, i); i++;
                    if(iCharacterIndex >= 0)
                    {
                        Characters[iCharacterIndex].recognized = 1;
                        Characters[iCharacterIndex].EnemyShipName = Pchar.Ship.Name;
                        Characters[iCharacterIndex].EnemyShipType = Pchar.Ship.Type;
                    }
                    else
                    {
                        fini = true;
                    }
                }
                UpdateRelations();
            }
            if(distance < 1000){Pchar.obsenemy ="1";}
        }
    }
}
 
Swashbuckler level, eh? I just tried myself and indeed then they ARE pretty quick to recognize you. Exactly twice as likely, in fact.
You can try removing the // in front of that alternate calculation there and put it in front of the normal one.
That reduces the chance on Swashbuckler. Would that work better? Alternatively, should we remove the difficulty influence altogether?
 
Back
Top