In PROGRAM\SEA_AI\sea.c find this code:
Code:
int iNumFantomShips = Fantom_GenerateEncounter(sGName, &oResult, iEncounterType, iNumWarShips, iNumMerchantShips);
Replace it with:
Code:
int iNation = sti(rEncounter.Nation);
int iNumFantomShips = Fantom_GenerateEncounter(sGName, &oResult, iEncounterType, iNumWarShips, iNumMerchantShips, iNation); // NK
Now open PROGRAM\SEA_AI\AIFantom.c and find this code:
Code:
int Fantom_GenerateEncounter(string sGroupName, object oResult, int iEType, int iNumWarShips, int iNumMerchantShips)
Replace it with:
Code:
int Fantom_GenerateEncounter(string sGroupName, object oResult, int iEType, int iNumWarShips, int iNumMerchantShips, int iNation) // NK
Then find this code in the same file:
Code:
iShipType = Fantom_GetShipType(iMerchantClassMin, iMerchantClassMax, "Merchant");
Replace with:
Code:
iShipType = Fantom_GetShipType(iMerchantClassMin, iMerchantClassMax, "Merchant", iNation); // NK
Then find this code in the same file:
Code:
iShipType = Fantom_GetShipType(iWarClassMin, iWarClassMax, "War");
Replace with:
Code:
iShipType = Fantom_GetShipType(iWarClassMin, iWarClassMax, "War", iNation); // NK
And at last find:
Code:
int Fantom_GetShipType(int iClassMin, int iClassMax, string sShipType)
And replace it with:
Code:
int Fantom_GetShipType(int iClassMin, int iClassMax, string sShipType, int iNation) // NK
We have now enabled ourselves to code in nation-specific ship type encounters!
Now it's time to add in the nation-specific code to the
Fantom_GetShipType function:
Code:
int Fantom_GetShipType(int iClassMin, int iClassMax, string sShipType)
{
int iShips[50];
int i, iShipsNum;
iShipsNum = 0;
for (i=SHIP_TARTANE; i<=SHIP_MANOWAR; i++) //ýÃÂêàóÃÂòåðû òîëüêî äî ìàÃÂîâàðà, êâåñòîâûå êîðàáëè îòäåëüÃÂî
{
object rShip = GetShipByType(i);
if (!checkAttribute(rship, "class"))
{
trace ("bad ship is: " + rship.name);
}
int iClass = MakeInt(rShip.Class);
if (iClass > iClassMin) { continue; }
if (iClass < iClassMax) { continue; }
if (sti(rShip.CanEncounter) != true) { continue; }
if (sti(rShip.Type.(sShipType)) != true) { continue; }
if (CheckAttribute(rShip, "nation") && sti(rShip.nation) != iNation) { continue; } // PB: Limiting Ships to Certain Nations
iShips[iShipsNum] = i;
iShipsNum++;
}
if (iShipsNum==0)
{
Trace("Can't find ship type '" + sShipType + "' with ClassMin = " + iClassMin + " and ClassMax = " + iClassMax);
return INVALID_SHIP_TYPE;
}
int iBaseShipType = iShips[rand(iShipsNum - 1)];
//trace(ShipsTypes[iBaseShipType].name);
int iRealShipType = GenerateShip(iBaseShipType, 0);
return iRealShipType;
}
Now you can add code lines in PROGRAM\SHIPS\ships_init.c for nation-specific ships, for example
refShip.nation = ENGLAND; will make the ship appear only in English squadrons.
The above code is adjusted for CoAS, but is not tested. It is adapted from the PotC Build Mod simple version (we've got more advanced code in place for this now), where it works perfectly fine.