At the moment, any ship can be used by any nation, regardless of the .nation attribute. This is becoming increasingly bothersome, especially if we are to implement Napoleonic navies with each country using different ships. Also Petros' Privateer was always intended to be a pirate only ship, but can still be seen being used by different nations. Therefore I propose to take the .nation attribute of ships into account when generating on-sea encounters and thus prevent ships with the .nation attribute set from being used by different nations. I have wanted to do this before, but I think I now found where to change this.
PROGRAM\SEA_AI\AIFantom.c:
I think this could be easily accomplished by adding a line
below
I don't have any time to test this right now, so could somebody please do this and check the effect on the game? Hopefully this will work and we will have no more ships under the wrong flags.
If we manage to make this work, we can set the .nation attribute for more ships. The end result could be that you can judge the nation of a ship by the ship type. For example: British ships have a black and yellow colour scheme, French ships a red and black colour scheme, the Spanish use galleons, the Portugues use Caravels, the Dutch use the Spiegelretourschip and Dutch Fluit, etc. I think this could add quite some value to the on-sea gameplay without actually requiring a very thorough modification.
=============================================================
I also see the following code in there:
Could it be that this code was meant for the exact same purpose I propose above? If so, we could use that instead. But how would it work? Add a refShip.skipnatENGLAND = true; to a ship's ships_init.c entry for example? That looks like an oddish line of code and I wonder if that would actually work. :wacko:
=============================================================
While we're at it, we could also add a new flag to ships: refShip.napoleonic = true;
Then also add a line
to the code posted above. Finally add a line
to BuildSettings.h. This could be a simple toggle on the Napoleonic ships for those players who don't want them in their game. The plus of doing it this way as opposed to adding an if() around the ships_init.c entries is that with this way, it is possible to turn the ships on and off in mid-game. Also it only pertains to the generation of random ships at sea. The ships can still be bought at shipyards if the player should choose so.
PROGRAM\SEA_AI\AIFantom.c:
Code:
int Fantom_GetShipType(int iClassMax, int iClassMin, string sShipType, int iNation) // NK
{
int iShips[2]; // was 512 - must be careful!!!!
SetArraySize(&iShips, SHIP_TYPES_QUANTITY*10); // new version of chance
int i, iShipsNum, iClass;
for(i = 0; i [ SHIP_TYPES_QUANTITY*10; i++) iShips[i] = INVALID_SHIP_TYPE;
// NK --]
int shipnation = -1;
float NatSkipChance;
ref rShip;
if(iNation == PIRATE) { NatSkipChance = NOSKIP_CHANCE_WRONGNATION_PIRATE; }
else { NatSkipChance = NOSKIP_CHANCE_WRONGNATION; }
if(sShipType == "pirate")
{
if(PIRATES_USE_BOTH_TYPES) { sShipType = ""; }
else { sShipType = "war"; }
}
int curyear = GetDataYear();
iShipsNum = 0;
// move class clamps things to Force_... 05-05-11
for (i=0; i[SHIP_TYPES_QUANTITY; i++)
{
rShip = GetShipByType(i); // why was this type object? 05-05-11
iClass = sti(rShip.Class);
if (iClass ] iClassMin) { continue; }
if (iClass [ iClassMax) { continue; }
if (sti(rShip.CanEncounter) != true) { continue; }
// new version of chance - old was if(CheckAttribute(rShip,"chance")) { if(frnd() ] stf(rShip.chance)) { continue; } } // 04-09-10 will skip if chance not met
// NK mod so we can disregard shiptype if we want to: 04-09-04
// LDH --] new fix for missing sShipType 03Sep06
// if(sShipType != "") { if (!sti(rShip.Type.(sShipType))) { continue; } } // Original NK code
if(sShipType != "")
{
if (CheckAttribute(rShip, "Type."+sShipType))
{
if (!sti(rShip.Type.(sShipType))) continue;
}
else
{
trace("Fantom_GetShipType(): Ship " + rShip.id + " has no shiptype");
continue;
}
}
// LDH [--
// NK --]
if(CheckAttribute(rShip,"skipnat"+iNation)) //so you can skip nations too
{
string tmp = "skipnat" + iNation;
if(sti(rShip.(tmp))) { continue; }
}
if(CheckAttribute(rShip,"Nation") && iNation != -1)
{
shipnation = sti(rShip.Nation);
if(shipnation != iNation && frnd() ] NatSkipChance) { continue; }
}
if(CheckAttribute(rShip, "startyear")) { if(sti(rShip.startyear ] curyear)) { continue; } }
if(CheckAttribute(rShip, "endyear")) { if(sti(rShip.endyear [ curyear)) { continue; } }
iClass = sti(rShip.chance); // New version of chance 05-05-11
iShips[iShipsNum] = i;
// iShipsNum += iClass;
iShipsNum++;
}
if (iShipsNum==0)
{
Trace("Can't find ship type '" + sShipType + "' with ClassMin = " + iClassMin + " and ClassMax = " + iClassMax);
return INVALID_SHIP_TYPE;
}
i = rand(iShipsNum-1);
while(i ] 0 && iShips[i] == INVALID_SHIP_TYPE) i--;
return iShips[i];
}
Code:
if (sti(rShip.nation) != iNation) { continue; }
Code:
if (iClass ] iClassMin) { continue; }
if (iClass [ iClassMax) { continue; }
if (sti(rShip.CanEncounter) != true) { continue; }
If we manage to make this work, we can set the .nation attribute for more ships. The end result could be that you can judge the nation of a ship by the ship type. For example: British ships have a black and yellow colour scheme, French ships a red and black colour scheme, the Spanish use galleons, the Portugues use Caravels, the Dutch use the Spiegelretourschip and Dutch Fluit, etc. I think this could add quite some value to the on-sea gameplay without actually requiring a very thorough modification.
=============================================================
I also see the following code in there:
Code:
if(CheckAttribute(rShip,"skipnat"+iNation)) //so you can skip nations too
{
string tmp = "skipnat" + iNation;
if(sti(rShip.(tmp))) { continue; }
}
=============================================================
While we're at it, we could also add a new flag to ships: refShip.napoleonic = true;
Then also add a line
Code:
if (!NAPOLEONIC_SHIPS && sti(rShip.napoleonic) == true) { continue; }
Code:
#define NAPOLEONIC_SHIPS = true;
// 1: Napoleonic ships are enabled in the game
// 0: No Napoleonic era ships will appear at sea