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

[WIP] Limit special ship type to certain country

Try using MAX_NATIONS instead of NATIONS_QUANTITY; that might work better.
And believe it or not, that error message might actually mean progress! :cheeky

Heurka! It did not crash this time, that last hind must have been the point, for some wired reason. But I suggest to start a little debuging-session to get this damn thing running fine, once and for all...:whipa

It's still producing errors, here a short overview:

(Newest)
RUNTIME ERROR - file: interface\interface.c; line: 1525
process event stack error

RUNTIME ERROR - file: interface\utilite.c; line: 514
missed attribute: name
RUNTIME ERROR - file: interface\utilite.c; line: 514
no rAP data

the last one (rAP data) occured quite frequently within my poor coding-attempts, I'd badly like to know it's meaning...
 
I followed my instructions and made all necessary adjustments to the CoAS game code myself; see attached.
Note that this is for CM V3.2 and not one of the GoF version WIPs.
However, I don't get any weird error messages with these two files, so give it a try.
I haven't checked if it actually works either.
 
I added the code from PotC as I suggested and set all the ship chances to 0.0 in ships_init.c.
Result: Went into a worldmap encounter with the Spanish and not a single ship showed up.
This suggests some measure of success, since no ship SHOULD show up if the chances are 0.0 for every ship.
 
I reckon the nation dependency should work fine for worldmap ships now, provided that somebody sets the national chances sensibly in ships_init.c,
eg. set the Amsterdam to only be 1.0 for Holland and 0.0 for the others, etc.

Then I went searching for the code that chooses the ships encountered around the islands, which I found in PROGRAM\scripts\utils.c:
Code:
int SearchForMaxShip(aref chr, int isLock, int _tmp)
{
int iType;

if (sti(chr.nation) != PIRATE)
{
if (rand(100) > 70)
{
iType = rand(SHIP_FRIGATE);
}
else
{
iType = rand(SHIP_BRIG);
}
}
else
{
if (rand(100) > 70)
{
iType = rand(SHIP_BATTLESHIP);
}
else
{
iType = rand(SHIP_GALEON_L);
}
}
iType = GenerateShip(iType, isLock);
return iType;
}
This strikes me as being some VERY unfortunate coding.

For one thing, it seems to assume that the ship index numbers in PROGRAM\Ships\ships.h are ordered on size, which with the newly added ships, they are not.
Additionally, it uses rand(MAX_SHIP_INDEX) to select the index of the ship to use. This means that:
1. The highest index used here is SHIP_BATTLESHIP, so none of the ships with an index above 118 will ever be generated around islands.
2. This code doesn't care whatsoever about nationality or anything else.

Similar coding can be found in places where random quest characters (eg. "hunt the pirate") are assigned their ships.
Although it's quick to execute, it isn't sophisticated in the slightest and, in my mind, is really quite cheap.
I remember similar coding being used to define what items are being sold by the merchants. It's purely random and doesn't care about ANYTHING.

I think these issues will definitely need to be addressed if you want all ships to be used and want them to be used where appropriate.
For ships, we might be able to get most of these "randomize ship" functions to use the far more sophisticated Fantom_GetShipType function.
However, I am not sure about the items and I shudder to think what other similar cheap coding is lying behind the surface. :shock
 
For ships, we might be able to get most of these "randomize ship" functions to use the far more sophisticated Fantom_GetShipType function.
To do this, open PROGRAM\scripts\utils.c and find:
Code:
characters[iChar].ship.type = SearchForMaxShip(&characters[iChar], isLock, CharacterType);
Replace with:
Code:
			if(rand(1)==0)	characters[iChar].ship.type = Fantom_GetShipType(7, 1, "war", iNation);
else			characters[iChar].ship.type = Fantom_GetShipType(7, 1, "merchant", iNation);
This'll give a 50/50 chance of either a war or merchant ship being generated at the island.
 
See attached file for the files I changed to get the National Ships code to hopefully work correctly.
Somebody please adjust the chance values in ships_init.c accordingly so this can be tested for real.
Note that 0.0 means that the ship CANNOT be encountered for that nation, while 1.0 means it CAN.
Anything inbetween means that the ship CAN be encountered for that nation, but is rarer than she would otherwise be.

Additionally, I added various log lines that will appear on the screen when a character has a ship randomly assigned.
This might be helpful if we decide to randomize other code properly as well.
For example, the SetShipToFantom function in PROGRAM\SEA_AI\AIFantom.c uses similar coding as well:
Code:
void SetShipToFantom(ref _chr, string _type, bool _setgoods)
{
Log_SetStringToLog("Function SetShipToFantom executed for character" + _chr.id);
int ShipType;
int Nation = sti(_chr.nation)
int Rank = sti(pchar.rank);
switch (_type)
{
case "trade":
if (Rank < 11)
{
ShipType = RandFromThreeDight(SHIP_SLOOP, SHIP_SCHOONER, SHIP_LUGGER);
}
if (Rank >= 11 && Rank <= 20)
{
if (Nation == SPAIN) ShipType = RandFromThreeDight(SHIP_CARAVEL, SHIP_BARKENTINE, SHIP_BARQUE);
else ShipType = RandFromThreeDight(SHIP_FLEUT, SHIP_BARQUE, SHIP_GALEON_L);
}
if (Rank > 20)
{
if (Nation == SPAIN) ShipType = SHIP_GALEON_H;
else ShipType = SHIP_PINNACE;
}
break;
case "pirate":
if (Rank < 4)
{
ShipType = SHIP_LUGGER;
}			
if (Rank >= 4 && Rank < 11)
{
ShipType = RandFromThreeDight(SHIP_SLOOP, SHIP_SCHOONER, SHIP_BRIG);
}
if (Rank >= 11 && Rank <= 20)
{
ShipType = RandFromThreeDight(SHIP_GALEON_L, SHIP_GALEON_H, SHIP_CORVETTE);
}
if (Rank > 20)
{
ShipType = SHIP_FRIGATE;
}
break;

/*case "war":
if (Rank < 11)
{
ShipType = RandFromThreeDight(SHIP_SLOOP, SHIP_SCHOONER, SHIP_LUGGER);
}
if (Rank >= 11 && Rank <= 20)
{
if (Nation == SPAIN) ShipType = RandFromThreeDight(SHIP_CARAVEL, SHIP_BRIG, SHIP_PINNACE);
else ShipType = RandFromThreeDight(SHIP_BRIG, SHIP_GALEON_L, SHIP_PINNACE);
}
if (Rank > 20)
{
if (Nation == SPAIN) RandFromFiveDight(SHIP_GALEON_H, SHIP_LINESHIP, SHIP_WARSHIP, SHIP_BATTLESHIP, SHIP_MANOWAR);
if (Nation == HOLLAND) ShipType = SHIP_GALEON_H;
if (Nation == ENGLAND || Nation == FRANCE) ShipType = SHIP_PINNACE;
}
break;*/
}
_chr.Ship.Type = GenerateShip(ShipType, true);
SetRandomNameToShip(_chr);
SetBaseShipData(_chr);
SetCrewQuantityFull(_chr);
Fantom_SetCannons(_chr, _type);
Fantom_SetBalls(_chr, _type);
if (_setgoods)
{
Fantom_SetGoods(_chr, _type);
}
}
This means that ANY pirate ship encountered by this function above rank 20 will ALWAYS be the same frigate model.

Another problem that struck me with this coding is that the rand(SHIP_INDEX) code could potentially generate ships with an index lower than the one in the function that are set to CanEncounter = false!

Note that I didn't yet adapt the nation ship code for shipyards, though if it is found to work correctly in encounters, I should be able to prevent shipyards from selling other nations' ships.
 
Are those files in your attachements updated to include the new changes because if they are then when compared to GOF their is no changes at all apart from in the nation_init file which is the line about ships which fixes (we think) the ship error problems and also the problem where going to sea mode would sometimes leave you with no error messages or ships to fight The game just wouldn't even try to generate any ships. Now all seems well in both of these area's although i am spending more time checking for this because it has annoyed us for the better part of the combined mods up to now.
 
Oops; uploaded the wrong files. Try attached instead. These files are based on GoF 1.0 without any additional modifications.
Nations_init.c is not modified. Of course you should use WinMerge to install code adjustments to ensure that you know what changes I made and to ensure you don't lose any changes that you made after uploading GoF 1.0.
 
Thanks Pieter, i alway's use winmerge to see the changes made even if its to files we haven't edited or updated for a while. I like to know what was done and how, as you said it gives us chance to see how it was done. :yes
 
Exactly; it's always a good idea. :onya

In any case, I hope you and/or some other people can run with my files so that you can include it in the final GoF release;
I really hate seeing Dutch ships under French colours and British ships under Spanish colours. :whipa
 
I will start testing it, i have put it to one side ready to be included into the patch should it work. I just need to make some ship changes so that ships are set to only be generated by specific nations, then i am ready to start testing. :dance
 
If you're interested, I've got a copy of ships_init.c with ALL chances set to 0.0. If the code works correctly, no ships will be generated anymore at all.
That's the way I tested, figuring it'd be the quickest and most obvious.

On that subject, we may need to include some code so that if no ship can be chosen to appear, a default ship should be used instead.
Or maybe a random choice out of several default ships.
 
In CoAS, there is three textures available for each hull. That might complicate this mod a bit, since quite possibly different textures are for different nations, even on the same ship model.
That doesn't help. :facepalm
 
In CoAS, there is three textures available for each hull. That might complicate this mod a bit, since quite possibly different textures are for different nations, even on the same ship model.
That doesn't help. :facepalm

Yes please Pieter the ship_init file would be a big help. :onya

Yep we would have to some how to the game which texture is for which nation, not a easy thing at all and not even sure if its possible without changing things in the source code. :shrug

As for ships for all nations, Sloop's, Lugger's and other ships like that was more popular so in the caribbean so they should be for all nations.
 
See attached for my zero-chance ships_init.c file; with all my code files in place, no more ships should show up randomly around islands or on the worldmap.

The colour schemes will be tricky, but at least you'll be able to prevent certain ship MODELS from showing up for certain nations.
Limiting the textures also will be more complex, because I don't know how that works, being only familiar with PotC.
 
Thanks Pieter, we can if needs be make a duplicate copy of the ship and give the other ship the textures for the other nation, so if one ship has 3 textures one for Spain, Dutch and England then we could make 2 copies of that ship model and give each model 1 texture for a nation but in each of the 3 hull folders so that only that texture is used for that given nation, however this will require a lot of work to do and a lot more work to undo if another way is found.
 
Thanks Pieter, we can if needs be make a duplicate copy of the ship and give the other ship the textures for the other nation, so if one ship has 3 textures one for Spain, Dutch and England then we could make 2 copies of that ship model and give each model 1 texture for a nation but in each of the 3 hull folders so that only that texture is used for that given nation, however this will require a lot of work to do and a lot more work to undo if another way is found.

But if we copy the entire ships...
1 set for the brits, 1 set for the Hollanders, 1 set for the Frenchies , 1 set for the Spaniards...
and one (reduced?) set for the pirates.

and each ship type, for each nation has 3 different color shemes.
british typical colors,
NL typical colore
Typical french colors
Spanish colors
Pirate colors.

we could then go and personalize the ships for every nation!
The french get the french Ships (soleil royal, la couronne) and the generics (remove fluyt, HMS victory... etc etc)
The NL get the Fluyt, thhe NL escort warship, no first rates and the generics (remove la couronne, ...)
The Brits get a bunch of second rates and the generics (but no couronne, no soleil royal, no USS constitution...)
The spaniards get all the spanisg-inspired ships and the generics
The pirates get the Xebecs, the small Pirate attack type ships, the flying dutchman and none of the cargo haulers.


In that context, one needs to ask a few questions:

Do we have enough ships to fully represent the different Nations Fleets from... 1650 onwards?
How do we represent ships that were captured from Nation A and then served in Nation B? Is that an issue?
Can a French "Light Pinnace" be different from a Spanish "Light Pinnace" by Varying the Crew, armor, Hull strength, sailing properties?
I think so. (Historians will teach us the differences)

flash:
WTF is Uss constitution doing in the game? IIRC the Yanks built that Beast... yet we have no American Navy in there... confused... need to find a fix...
 
Yes we can customise the ships, we can have the Spanish Galleon's have more hit points, high crew size, more cargo space. The only thing we can't do is change the amount of guns the ship has mounted without editing the GM files. But that is possible as well, as for the Constitution that would have to be a pirate ship, perhaps made into a unique ship at some later point. I am not sure if the ship was made due to the movie masters and commanders or if it was made before then, but i like the ship and do not wish to see it removed. Which is why it would be good to make her a unique ship for the pirates where you can only capture her in a quest similar to the Blue Bird quest. This would require some people who know how to put such things into context and get them working. The Black Pearl, Flying Dutchmen obviously need to be pirate ships. But most pirate ships need to be small agile ships because no pirates ever had MOW's, very few ever used Galleon's like the Black Pearl. The other way for this would be to add switches to allow people to pick historical or fantasy gameplay where as in historical the fantasy ships like the Black Pearl are not in the game but are in fantasy mode. This shouldn't be to hard to do and could very easily be done for a future feature in GOF.

Right now though new features have been put on hold while we test things out, so for now at least we can only imagine what we can do to further increase GOF as a more enjoyable mod or game addon as some might see it.
 
I would recommend not allowing the Black Pearl and Flying Dutchman to show up at random; that's just weird.

As for ships of nation A captured by nation B, even though I agree that could happen in real life, I would recommend ignoring that for the modpack because it defeats the purpose of distinguishing between national ship types.

In the PotC Build Mod, in Realistic Game Mode, the spyglass no longer tells you the nationality of ships (because a real spyglass doesn't), so then you're going to have to base your guess on the nationality on the ships' colour schemes, type and flags.
If that works properly, it does encourage players to apply the same thinking that captains back in the days would have to do. Is she friendly or not? Engage or not?

USS Constitution was modeled after the release of M&C but I don't think that had anything to do with it; ZarethPL just wanted to model that ship.
We had been planning to put the USA as a nation in the PotC Build Mod anyway and eventually we did manage that, so in our case at least we can put her to use.
You might be able to put the USA in the game at some point as well, but I suppose after the release of GoF 1.0.
In the meantime, you could have the USS Constitution available only as a starting ship or so.
 
Back
Top