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

Need Help How to generate more vessel clutter in harbors

Status
Not open for further replies.

modernknight1

Field Marshall of Hot Tubs
Staff member
Storm Modder
Gents, I'm looking for ideas about what file(s) I would need to modify to get more random vessels to appear when entering and leaving harbors.

Sure there's the odd patrol ship or two and maybe a merchantman. Sometimes you will see a recruitable character's ship in the harbor. So the most ships you might see in harbor are four or five if you're lucky.

Most often your own squadron will have more ships than the harbor itself.

I would like to see - say seven to ten ships in the harbor when I show up. Many of our Caribbean harbors were bustling places and I would like to recreate that realism.

Any ideas???

MK
 
I suspect the relevant coding in CoAS might be quite different on this than PotC, because in PotC ships in ports and around islands was a mod-added feature in the first place.

In this case, are you referring to ships seen while ashore in port or when you're sailing around the island?
For ashore, PotC has the code in PROGRAM\Locations\locations_loader.c in the void LocLoadShips(ref Location) function.
That uses existing ships from around the island to show while in port.
 
I suspect the relevant coding in CoAS might be quite different on this than PotC, because in PotC ships in ports and around islands was a mod-added feature in the first place.

In this case, are you referring to ships seen while ashore in port or when you're sailing around the island?
For ashore, PotC has the code in PROGRAM\Locations\locations_loader.c in the void LocLoadShips(ref Location) function.
That uses existing ships from around the island to show while in port.


Both...

The patrol ships you see when approaching the port are at anchor when you land.

I will look to see if the code you provided is relevant. The ships are always anchored far off shore. I would love to see them close to the docks like in New Horizons. That would just be awesome!

MK
 
I think I found where CoAS generated its "Coast Raiders". Here in Program\scripts\islandships.c .
The way it decides the number seems a bit weird to me, but I think this is the relevant code:
Code:
          float fChecker = frand(1.0);
           if (fChecker < 0.8)
           {
             iShipsQuantity = makeint(fChecker * 4.0);
             while (iShipsQuantity > 0)
fChecker generates a random value between 0.0 and 1.0 .
In 20% of the cases, this value will be less than 0.8 and no ships will be generated at the island at all.
So the max value for fChecker will be 0.8 and the number of ships generated then is 0.8*4.0 = 3.2, which is cut off to be 3 ships in total.
Does that match with what you see in the game? Never more than 3 ships coastal traffic? PotC usually has 6 of them around each island.

In any case, if you agree with that "20% of the time no ships" thing, then I think just increasing that 4.0 to, say, 8.0 should have the effect of doubling the number of ships.

The ships are always anchored far off shore. I would love to see them close to the docks like in New Horizons. That would just be awesome!
Does CoAS have any locations with long enough piers for the ships to be generated alongside those? Or would it suffice to just have them anchored a bit closer?

Captain Maggee and me added that feature to PotC, but that does require quite some work:
- The port locator files have to be edited with Inez Dias' TOOL to add a new "jetty ship" locator
- Search for "jettyships" in locations_loader.c to see the code we added
- There needs to be a check on ship size, because large ships alongside the jetty don't look particularly good as seen on this screenshot taken while we were working on this:
Huge_Manowar.jpg

Another thing I really like for port ships is the "sailaway" code we added to that same file.
This makes some of the ships in port be sailing along instead of floating at anchor. Gives the feel of some actual traffic on the sea.
It's not perfect and sometimes they'll happily sail through the port, but I do reckon it adds some life.

I hope the above helps point you in the right direction. :doff
 
YOU SIR ARE THE MAN!!!! :onya:thumbs1:thumbs1:thumbs1 By Jove Pieter, you've done it again.

That worked unbelievably well! Thank you for the tips!


There are a couple small ports on Antigua and Tortuga that would cause problems. However I love the extended jetty idea. Maybe you guys can help me once we have our mods out.

MK
 
YOU SIR ARE THE MAN!!!! :onya:thumbs1:thumbs1:thumbs1 By Jove Pieter, you've done it again.

That worked unbelievably well! Thank you for the tips!
It actually worked? Niiice! As always, glad to be of service. :doff

There are a couple small ports on Antigua and Tortuga that would cause problems. However I love the extended jetty idea. Maybe you guys can help me once we have our mods out.
Small ports aren't a problem. The way the jetty ships system works is that if there are no jetty ship locators, they're not being used.
A bigger problem is preventing big ships from being generated there. We always keep running into even more ships we didn't know didn't fit.
 
Just made similar mod a few days ago, but decided to generate mostly class 7 (not all of them) ships with small chance of spawning usual random ships.

Instead of using fchecker, made my own number randomizer for ships.

islandships.c
Code:
iShipsQuantity = rand(6);
                        if(iShipsQuantity>4)
                        {
                        iShipsQuantity=iShipsQuantity+rand(8);
                        }                      
                        if(iShipsQuantity>8 && rand(4)>0)
                        {
                        iShipsQuantity=iShipsQuantity-rand(6);
                        }
                      
                        while (iShipsQuantity > 0)
                        {
                            if(rand(6)==1) //Generate random ship (from all of them)
                            {
                            iChar = GenerateCharacter(iNation, WITH_SHIP, "soldier", MAN, -1, WARRIOR);
                            } //-1 - ýňî 1 äĺíü
                            else // only class7 etc
                            {
                            iChar = GeneratePortShip(iNation, WITH_SHIP, "soldier", MAN, -1, WARRIOR);
                            }
[...]

In same file you can also change how many ships supose to sailaway

Code:
int iTask = rand(3); // chance for sailaway 25%
  
    float x, z;
    if (iTask == 0)
    {
        x = rand(1000000);
        z = rand(1000000);
        Group_SetTaskMove(sGroup, x, z);
    }
    else
    {
        Ship_SetTaskDrift(SECONDARY_TASK, iChar);
        //Group_SetTaskNone(sGroup);
    }

GeneratePortShip is a copy of GenChar function but made only for class 7 ships.
utils.c
Code:
int GeneratePortShip(int iNation, int isShip, string sModel, int iSex, int isLock, int CharacterType)
{
//    Log_SetStringToLog("Function GenerateCharacter executed");
    int iChar = NPC_GeneratePhantomCharacter(sModel, iNation, iSex, -isLock); // -isLock) == -1 || 0

    if (IsShip == WITH_SHIP)
    {
        // to_do del
        if(CharacterType == FORT_COMMANDER)
        {
            characters[iChar].ship.type = GenerateShip(SHIP_FORT, isLock);
            Fantom_SetRandomCrewExp(&characters[iChar], "war");
        }
        else
        {
        //    characters[iChar].ship.type = SearchForMaxShip(&characters[iChar], isLock, CharacterType);
            characters[iChar].ship.type = Fantom_GetPortShipType(8, 6, "merchant", iNation);
                        // PB: 50% chance for merchant, 50% chance for navy
            Fantom_SetRandomCrewExp(&characters[iChar], "war");

            }

        SetBaseShipData(&characters[iChar]);

        SetRandomNameToShip(&characters[iChar]);
    }
    else
    {
        characters[iChar].ship.type = SHIP_NOTUSED;
        DeleteAttribute(&characters[iChar], "ship.upgrades");
    }
    return iChar;
}

In the end i decided to use only some of ships, and give them exact chance of appearance, so made a new function (Fantom_GetPortShipType) to generate shiptypes.

AIFantom.c

Code:
int Fantom_GetPortShipType(int iClassMin, int iClassMax, string sShipType, int iNation) // NK
{
    int PSchance;
    int iRealShipType;
  
    PSchance = rand(100);
  
    if(PSchance <= 100) iRealShipType = GenerateShip(SHIP_TARTANE, 0);
    if(PSchance <= 70) iRealShipType = GenerateShip(SHIP_WAR_TARTANE, 0);
    if(PSchance <= 29) iRealShipType = GenerateShip(SHIP_LUGGER, 0);
    if(PSchance == 24) iRealShipType = GenerateShip(SHIP_BOUNTY, 0);
    if(PSchance < 24) iRealShipType = GenerateShip(SHIP_HANNAH, 0);
    if(PSchance <= 19) iRealShipType = GenerateShip(SHIP_KETCH, 0);
    if(PSchance <= 15) iRealShipType = GenerateShip(SHIP_LYON, 0);
    if(PSchance <= 8) iRealShipType = GenerateShip(SHIP_SLOOP, 0);
    if(PSchance <= 7) iRealShipType = GenerateShip(SHIP_GALEOTH_H, 0);
    if(PSchance <= 5) iRealShipType = GenerateShip(SHIP_YACHT, 0);
    if(PSchance == 3) iRealShipType = GenerateShip(SHIP_SPEEDY, 0);
    if(PSchance == 2) iRealShipType = GenerateShip(SHIP_LUGGER_H, 0);
    if(PSchance <= 1) iRealShipType = GenerateShip(SHIP_BARQUE, 0);
  
    return iRealShipType;
}

Ofc code isn't efficient i made it just to see if it will work, and if they will spawn properly in large numbers, so far after a few hours of testing everything seems to work fine in game.
 
Last edited:
In same file you can also change how many ships supose to sailaway
Out of curiosity, is that sailing away AT SEA or while you're walking around IN PORT?
Just wondering if they got that mod of mine working a bit more sensibly in CoAS. :wp

Code:
int Fantom_GetPortShipType(int iClassMin, int iClassMax, string sShipType, int iNation) // NK
"NK" notes in the CoAS code? Well, now I KNOW they've been looking at the PotC Build Mod!
Pretty sure Nathan Kell never did any work on AoP or AoP 2.
Have you run into any "PB" ones yet? :rofl

Ofc code isn't efficient i made it just to see if it will work, and if they will spawn properly in larger numbers, so far after a few hours of testing everything seems to work fine in game.
As far as I can tell of the CoAS code, quite a bit of it is written in simple ways just so it would work.
As long as it does that, it fits right in! :cheeky
 
Out of curiosity, is that sailing away AT SEA or while you're walking around IN PORT?
Just wondering if they got that mod of mine working a bit more sensibly in CoAS. :wp

Just at sea ;)

Code:
int Fantom_GetPortShipType(int iClassMin, int iClassMax, string sShipType, int iNation) // NK
"NK" notes in the CoAS code? Well, now I KNOW they've been looking at the PotC Build Mod!
Pretty sure Nathan Kell never did any work on AoP or AoP 2.
Have you run into any "PB" ones yet? :rofl

Just fiddling around with gof 2.09, so dunno all this came from :shrug
 
:cheersWelcome ihuedge! You should join the few of us that are left. Maybe I can enlist your help in Eras Module 3 which is set in the 1785-1815 period.

I really would LOVE to be able to see ships under sail while walking around port. That is a worthy project and I would love some hints and some help. I am already happy with the clutter I am getting now while at sea, so my initial goals have been met.

MK
 
Ships under sail was surprisingly simple to accomplish in PotC. Just search for "sailaway" in attached file.
Basically, the game was already written to allow it; all that is needed is to add some attributes that would otherwise cause error messages if missing.
 

Attachments

  • locations_loader.zip
    10.3 KB · Views: 270
Ok i found out how to make them sailaway while in port, now i just need to figure out how to give them proper angles, so they wont sail towards port/island.

Edit: oh and there also will be another problem, most prolly when they sail away in port, they will still spawn somewhere close to port when you enter the sea mode, kinda immersion breaking :(
 
Assuming all ports are build on same model regarding axes i can force same angle for all of them (with random small deviation). Now i need to separate player/companions ships from rest so they wont sail away without captain... :aar
 
If you're looking at my PotC example, the player ships never sail away in there either. :no

I think you can be pretty sure that all ports are NOT built on the same angles.
There's an incredible LACK of consistency in the location models. In PotC at least. And I doubt CoAS will be much better.
 
I managed to filter out player/companion ships, but you were right about angles :(

Edit: As far as i can tell for most cases standard angles are working well enough, unfortunately entering any shops/houses resets positions of all ships in port, and there is nothing i can do about it without putting a lot of effort in this stuff. I plan to keep those changes for my nearest gameplay, will see how it gonna work out.
 
Last edited:
I am actually happy with the clutter I am getting because the game is selecting ships that I already designated for specific nationalities in a different part of my mod. So everything looks great. The only problem I have is with the quick sail feature. If you manually sail into harbors with your fleet following you then you're fine. But if you use the tab to transport your fleet into the harbor with all the new clutter, ......they "May come out of Hyperspace too close to" another ship and that ends your trip real quick! :rolleyes:

Remembering that I have St Ashley's 8 ship max mod as part of the mod, 8 ships suddenly appearing on top of 12 others sitting there can be interesting...xD

The best thing to do is simply give orders to all your ships to furl sails. Then they don't "go into hyperspace" when you auto transport into the harbor, only your ship does. I will have to add this as special instructions in the read-me file.

It's well worth the trouble.
MK
 
Status
Not open for further replies.
Back
Top