void CheckInitialFlagRelations(ref chr, float visibility_range, float ship_range)
{
// Initialize nations
int iNation = GetCurrentFlag();
int nNation = sti(chr.nation);
float rel = GetRMRelation(GetMainCharacter(), nNation);
bool IsFort = GetAttribute(chr, "ship.type") == SHIP_FORT_NAME;
// Initialize relations between NPC ships
UpdateAllShipsAtSea(chr, IsFort);
if (IsCompanion (chr)) return; // Companions don't care
if (CharacterIsDead(chr)) return; // Already dead, don't change relation again
if (rel <= REL_WAR && iForceDetectionFalseFlag == 1 && ship_range < visibility_range) chr.recognized = 1; // GR: obey forced recognition of false flag
// Ships that recognized you are ALWAYS hostile
if (CheckAttribute(chr, "recognized") && !CheckAttribute(chr, "surrendered"))
{
Trace("FLAGS: The " + GetMyShipNameShow(chr) + " turned hostile as they have recognized us");
SetCharRelationToFleet(chr, RELATION_ENEMY);
}
else
{
// Remember player's previous flag
if (!CheckAttribute(chr, "PlayerNation") || !CheckAttribute(chr, "PlayerShip") || GetNationRelation(iNation, nNation) == RELATION_ENEMY)
{
if (ship_range < visibility_range)
{
if (GetNationRelation(iNation, nNation) == RELATION_ENEMY || !RELATION_IGNORE_FRIENDLY)
{
chr.PlayerNation = iNation;
// chr.PlayerShip = GetCharacterShipID(GetMainCharacter());
chr.PlayerShip = GetCharacterShipModel(GetMainCharacter());
Trace("FLAGS: The " + GetMyShipNameShow(chr) + " has spotted us at " + ship_range + " and will remember us as " + GetNationDescByType(iNation) + " in " + chr.PlayerShip + " with visibility=" + visibility_range);
}
else Trace("FLAGS: The " + GetMyShipNameShow(chr) + " has spotted us at " + ship_range + ", but is not interested as we are not hostile");
}
else
{
// Trace("FLAGS: The " + GetMyShipNameShow(chr) + " is out of range and is not checking our flag");
}
}
else
{
if (ship_range < visibility_range)
{
if (!HasThisShip(chr.PlayerShip))
{
Trace("FLAGS: The " + GetMyShipNameShow(chr) + " remembered us as having " + chr.PlayerShip + ", which we no longer have");
ResetCharacterMemory(chr);
}
else
{
iNation = sti(chr.PlayerNation);
Trace("FLAGS: The " + GetMyShipNameShow(chr) + " remembers us as " + GetNationDescByType(iNation) );
}
}
else
{
Trace("FLAGS: The " + GetMyShipNameShow(chr) + " is out of range so can neither remember nor forget us");
}
}
// Turn hostile depending on player's previous flag
if (IsFort && iNation == PIRATE)
{
// Trace("FLAGS: The " + GetMyShipNameShow(chr) + " turned " + GetFortRelationToPirates(chr) + " based on their relation to pirates");
SetCharRelationToFleet(chr, GetFortRelationToPirates(chr));
}
else
{
if(GetNationRelation(iNation, sti(chr.nation)) == RELATION_ENEMY)
{
// Trace("FLAGS: The " + GetMyShipNameShow(chr) + " turned hostile as they believe us to be " + GetNationDescByType(iNation));
if (SeaAI_GetRelation(GetMainCharacterIndex(), sti(chr.index)) != RELATION_ENEMY)
{
SetCharRelationToFleet(chr, RELATION_ENEMY);
}
}
else
{
// Trace("FLAGS: The " + GetMyShipNameShow(chr) + " believes our current flag");
SetCharRelationToFleet(chr, GetNationRelation(GetCurrentFlag(), nNation));
}
}
}
}