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

Limiting ships to certain nations

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
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:
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];
}
I think this could be easily accomplished by adding a line
Code:
		if (sti(rShip.nation) != iNation) { continue; }
below
Code:
		if (iClass ] iClassMin) { continue; }
if (iClass [ iClassMax) { continue; }
if (sti(rShip.CanEncounter) != true) { continue; }
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:
Code:
		if(CheckAttribute(rShip,"skipnat"+iNation)) //so you can skip nations too
{
string tmp = "skipnat" + iNation;
if(sti(rShip.(tmp))) { continue; }
}
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
Code:
if (!NAPOLEONIC_SHIPS && sti(rShip.napoleonic) == true) { continue; }
to the code posted above. Finally add a line
Code:
#define NAPOLEONIC_SHIPS = true;
// 1: Napoleonic ships are enabled in the game
// 0: No Napoleonic era ships will appear at sea
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.
 
Hello Pieter,

I tried the code if (sti(rShip.nation) != iNation) { continue; } and tested it in game, I then engaged Dutch merchants, which was comprised of about eight Fluits (I assumed it has its nation set in ships init). Then I encountered a battle between Spanish ships and English ships, The English ship was a Yacht (has no nation set) and the Spanish ships were a mix of Galeons and War Galeons, so I think it actually works.

Hope that helps.
 
EIGHT Fluits? Wow. Did you set any .nation attributes in ships_init yourself? By default only a very select few ships have these attributes set. For example: The Privateer should be pirate-only and the Spiegelretourschip en Dutch Fluit should be Dutch-only. I don't recall Galleons and War Galleons having the attribute set yet. <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
some ships shouldn't get the nation attribute in my opinion, like the cutter, sloop, yacht, barque, and maybe other small ships. frigates and corvettes shouldn't be used by spain in my opinion, but i'm not sure wether or not that would be historically correct.
 
Of course. Some ships should be used randomly, but some should be limited. Especially the ones with a nation-specific colour scheme or ones obviously intended to be of a certain nation. Personally I can't see Spain or Portugal using any frigates and corvettes. I always associate Spain with galleons and Portugal with Caravels.
 
portugal would be sitting ducks. <img src="style_emoticons/<#EMO_DIR#>/smile2.gif" style="vertical-align:middle" emoid=":))" border="0" alt="smile2.gif" />
 
That's why we should add a somewhat more even distribution of the ships.
 
maybe something like those big galleons from AOP for the spanish and portugese?
 
I have a nice new skin for a AOP galleon, made it some while ago for alpha 8 but KK never released it, so I think I am going to do THAT myself.
 
What did you say about the portuguese ships. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" />
 
Limiting ships to certain nation is not only thing what should be changed. <img src="style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" />

I think that English, Dutch, French, etc shipyards should be selling their nation's ships.
And for Pirates there should be a ability at pirate shipyard to make your captured English, Dutch, French, etc ship(s) to pirate class. YARRR!!! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />
 
<!--quoteo(post=219796:date=Nov 1 2007, 08:27 PM:name=bartolomeu o portugues)--><div class='quotetop'>QUOTE(bartolomeu o portugues @ Nov 1 2007, 08:27 PM) [snapback]219796[/snapback]</div><div class='quotemain'><!--quotec-->What did you say about the portuguese ships. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

He said that portugal would be sitting ducks. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />

Anyways it seems like some of us have to walk the plank. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
I think we will need to also decide on which nations will use which ships. Any thoughts?

<!--quoteo(post=219776:date=Nov 1 2007, 05:21 PM:name=Thomas the Terror)--><div class='quotetop'>QUOTE(Thomas the Terror @ Nov 1 2007, 05:21 PM) [snapback]219776[/snapback]</div><div class='quotemain'><!--quotec-->I have a nice new skin for a AOP galleon, made it some while ago for alpha 8 but KK never released it, so I think I am going to do THAT myself.<!--QuoteEnd--></div><!--QuoteEEnd-->I have all Pirate_KK's files now, including your AoP reskins (fixed) AND Captain Dan's SloopBrig (meant to be HMS Sophie from the first Master and Commander novel). Tomorrow I am going to release a Build 14 Alpha 8 WIP version for all the modders and your ship will be included. <img src="style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />

<!--quoteo(post=219796:date=Nov 1 2007, 07:27 PM:name=bartolomeu o portugues)--><div class='quotetop'>QUOTE(bartolomeu o portugues @ Nov 1 2007, 07:27 PM) [snapback]219796[/snapback]</div><div class='quotemain'><!--quotec-->What did you say about the portuguese ships. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->LOL. Personally when I think of Portuguese ships, I think of Caravels. Perhaps you could tell me which ships would be more realistic for the Portuguese to use?

<!--quoteo(post=219797:date=Nov 1 2007, 07:35 PM:name=Cylon13)--><div class='quotetop'>QUOTE(Cylon13 @ Nov 1 2007, 07:35 PM) [snapback]219797[/snapback]</div><div class='quotemain'><!--quotec-->I think that English, Dutch, French, etc shipyards should be selling their nation's ships.
And for Pirates there should be a ability at pirate shipyard to make your captured English, Dutch, French, etc ship(s) to pirate class. YARRR!!! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->At the moment all the shipyards sell mostly ships from their own nation and only very occasionally other ships.
 
<!--quoteo(post=219798:date=Nov 1 2007, 06:44 PM:name=Cylon13)--><div class='quotetop'>QUOTE(Cylon13 @ Nov 1 2007, 06:44 PM) [snapback]219798[/snapback]</div><div class='quotemain'><!--quotec--><!--quoteo(post=219796:date=Nov 1 2007, 08:27 PM:name=bartolomeu o portugues)--><div class='quotetop'>QUOTE(bartolomeu o portugues @ Nov 1 2007, 08:27 PM) [snapback]219796[/snapback]</div><div class='quotemain'><!--quotec-->What did you say about the portuguese ships. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

He said that portugal would be sitting ducks. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />

Anyways it seems like some of us have to walk the plank. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
<!--QuoteEnd--></div><!--QuoteEEnd-->
Thank God, for now, I'm not Barbossa <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />

<!--quoteo(post=219796:date=Nov 1 2007, 07:27 PM:name=bartolomeu o portugues)--><div class='quotetop'>QUOTE(bartolomeu o portugues @ Nov 1 2007, 07:27 PM) [snapback]219796[/snapback]</div><div class='quotemain'><!--quotec-->What did you say about the portuguese ships. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->LOL. Personally when I think of Portuguese ships, I think of Caravels. Perhaps you could tell me which ships would be more realistic for the Portuguese to use?

Of course for the Caravels <img src="style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" /> . But not only this ship for the portuguese nation. <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" /> For instance, Portugal would be the only nation to have caravels but it could also have lugger, barque, sloop, battleship.....like the other nations.
 
<!--quoteo(post=219875:date=Nov 2 2007, 04:49 PM:name=bartolomeu o portugues)--><div class='quotetop'>QUOTE(bartolomeu o portugues @ Nov 2 2007, 04:49 PM) [snapback]219875[/snapback]</div><div class='quotemain'><!--quotec-->but it could also have lugger...<!--QuoteEnd--></div><!--QuoteEEnd-->

LUGGER!?! <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />

BEST invention EVER made to board a warship. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />
 
<!--quoteo(post=219897:date=Nov 2 2007, 06:01 PM:name=morgan terror)--><div class='quotetop'>QUOTE(morgan terror @ Nov 2 2007, 06:01 PM) [snapback]219897[/snapback]</div><div class='quotemain'><!--quotec-->one tap and it sinks.<!--QuoteEnd--></div><!--QuoteEEnd-->

Not in my command. <img src="style_emoticons/<#EMO_DIR#>/smile2.gif" style="vertical-align:middle" emoid=":))" border="0" alt="smile2.gif" />
 
Well if you only let to. <img src="style_emoticons/<#EMO_DIR#>/nerbz.gif" style="vertical-align:middle" emoid=":nerbz" border="0" alt="nerbz.gif" />
 
Back
Top