• 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 Custom Personal Flags for Companions not working

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
@Bartolomeu o Portugues asked before about having a different personal flag for Roxanne Lalliere.
Today I happened to be looking through the relevant section of code and found this:
Code:
int GetPersonalFlag(ref chr, int ntex)
{
  // PB: Always use the player's own flag -->
   ref PChar = GetMainCharacter();
   if(!IsCompanion(chr))
   {
     if (CheckAttribute(chr, "Flags.Personal.texture")) ntex = sti(chr.Flags.Personal.texture);
     if (CheckAttribute(chr, "Flags.Personal")) return sti(chr.Flags.Personal);
   }
   ntex = sti(PChar.Flags.Personal.texture);
   return sti(PChar.Flags.Personal);
   // PB: Always use the player's own flag <--
/*   ntex = 0;
   if(IsCompanion(chr))
   {
     ref PChar = GetMainCharacter();
     ntex = sti(PChar.Flags.Personal.texture);
     return sti(PChar.Flags.Personal);
   }
   else
   {
     if (CheckAttribute(chr, "Flags.Personal.texture")) ntex = sti(chr.Flags.Personal.texture);
     if (CheckAttribute(chr, "Flags.Personal")) return sti(chr.Flags.Personal);
     ref cmdr = Group_GetGroupCommander(GetGroupIDFromCharacter(chr));
     if (!CheckAttribute(cmdr, "Flags.Personal"))
     {
       ntex = rand(PERSONALFLAGS_TEXTURES_QUANTITY - 1);
       cmdr.Flags.Personal.texture = ntex;
       cmdr.Flags.Personal = rand(FLAGS_PICTURES_QUANTITY_PER_TEXTURE - 1);
       chr.Flags.Personal.texture = ntex;
       chr.Flags.Personal = sti(cmdr.Flags.Personal);
       return sti(chr.Flags.Personal);
     }
     ntex = sti(cmdr.Flags.Personal.texture);
     return sti(cmdr.Flags.Personal);
   }*/
}
Looks like a person with initials "PB" decided it was a good idea to force ALL personal flags to always be the player one rather than a custom one for different characters as required.
But I'm pretty sure that was once set up so that DID work as proven by the screenshot of Jack Sparrow escorting Cutler Beckett!

So I tried to restore that functionality, which led me to find out why I apparently so harshly simplified the related code.
It turns out that ONLY the texture file needed for the player is actually loaded, so anything on another texture file is not shown at all. :facepalm

This is obviously not very nice at all, so we should definitely aim to get that fixed some time. :modding
 
We might be in luck.... I think I figure it out already.

From PROGRAM\SEA_AI\AIShip.c:
Code:
  for (i = 0; i < shipsqty; i++)
   {
     if (locidx < 0) {
       if (Ships[i] < 0) continue;
       chr = GetCharacter(Ships[i]);
     } else {
       if (iShips[i] < 0) continue;
       chr = GetCharacter(iShips[i]);
     }
     if (sti(chr.nation) != PRIVATEER_NATION) continue;
     GetPersonalFlag(chr, &ntexture);
But that "PRIVATEER_NATION" is an unfinished feature that isn't actually used anywhere.
The REAL player flag is loaded elsewhere, but this does mean custom personal flags for other characters aren't loaded.
That seems to be fixed with the following change to that last line:
Code:
if (sti(chr.nation) != PRIVATEER_NATION && sti(chr.nation) != PERSONAL_NATION) continue; // PB: Other characters might have personal nation too!
And replace the section of code from the opening post in PROGRAM\BATTLE_INTERFACE\Flags.c with:
Code:
int GetPersonalFlag(ref chr, int ntex)
{
   // PB -->
   // Use character-specific flag if available
   if (CheckAttribute(chr, "Flags.Personal.texture")) ntex = sti(chr.Flags.Personal.texture);
   if (CheckAttribute(chr, "Flags.Personal")) return sti(chr.Flags.Personal);

   // Otherwise use the player's own flag
   ref PChar = GetMainCharacter();
   ntex = sti(PChar.Flags.Personal.texture);
   return sti(PChar.Flags.Personal);
   // PB <--
/*   ntex = 0;
   if(IsCompanion(chr))
   {
     ref PChar = GetMainCharacter();
     ntex = sti(PChar.Flags.Personal.texture);
     return sti(PChar.Flags.Personal);
   }
   else
   {
     if (CheckAttribute(chr, "Flags.Personal.texture")) ntex = sti(chr.Flags.Personal.texture);
     if (CheckAttribute(chr, "Flags.Personal")) return sti(chr.Flags.Personal);
     ref cmdr = Group_GetGroupCommander(GetGroupIDFromCharacter(chr));
     if (!CheckAttribute(cmdr, "Flags.Personal"))
     {
       ntex = rand(PERSONALFLAGS_TEXTURES_QUANTITY - 1);
       cmdr.Flags.Personal.texture = ntex;
       cmdr.Flags.Personal = rand(FLAGS_PICTURES_QUANTITY_PER_TEXTURE - 1);
       chr.Flags.Personal.texture = ntex;
       chr.Flags.Personal = sti(cmdr.Flags.Personal);
       return sti(chr.Flags.Personal);
     }
     ntex = sti(cmdr.Flags.Personal.texture);
     return sti(cmdr.Flags.Personal);
   }*/
}
I just tested that and it appears to work.

We might even now be able to restore that original section of code that apparently checks the commander and can assign random personal flags as if they were pirate flags.
Not sure why we would want that though, but it is apparently possible.

And on a related note.... This "PRIVATEER_NATION" does sound interesting.
Might be useful for the non-player ship with flag of Malta that you sink in the Assassin storyline.
Or possible to make some towns on Hispaniola independent in the Napoleonic time period.

Rambling on even further: There is also support in the code for two "guest nations" in each time period.
At the moment we only have America in the last two periods, but it should therefore be possible to add more than we currently have. :rolleyes:

But I suppose that might be better left until Build 15....
Still.... the possibility IS there, even if it might take a bit more doing.
 
I posted the pirate one in .jpg format way back here. ;) Here it is again:

roxanne-jpg.22134


Beyond that, and a one-off file for a pirate crest, I haven't been doing anything with pirate flags. Mainly I've been concentrating on "Hornblower".
 
Last edited:
Yes. I did finish the job on personal flags, incorporating the textured flags for Roxanne Lalliere, Milady de Winter, Jean Lafitte and John Paul Jones into "perflg6.tga.tx" and "perpnt6.tga.tx". Those ought to be included in the update; they may even have been in the previous one.
 
The personal flag has also this old texture effect, @Grey Roger ?
The personal flags are already OK. The pirate ones.... no further progress so far.
I'm hoping somebody will pitch in to take care of some of that, but we need the flags and crests for that for the whole line of flags.
Otherwise it wouldn't look professional for a public release.
 
Back
Top