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

Included in Build Ship Encounter Chances Correction

^ If you've got any suggestions for better generic ships being used, feel free to post them. :cheeky
 
By that time, the code doesn't care about nationality anymore. It needs to return something.
Which ships exactly do you not want to be seen in use by pirates? Perhaps we can limit them a little bit further...

What I also remember seeing is fleets of the exact same type of ship. Definitely ran into two NL_SevenProvincien at once.
Unless it was four. I definitely saw a fleet of four the same type ships once.
 
We weren't even thinking about pirates using those ships back then. How about replacing the pinnace1 with the Neptunus, Postillionen, or Revenge?
 
You tell me which ships to use and I'll set up the code.
I could even put something in place to prevent pirates using certain ones. As long as there'll be something left for the pirates.
 
I am personally happy with the ships in use as they are a mix of merchant and war ships. The problem is pirates using merchant ships.
 
So.... how would this be?
Code:
        // PB: If all fails, return a random period-specific ship type instead of the player ship -->
        switch((GetCurrentPeriod()))
        {
            case PERIOD_EARLY_EXPLORERS:
                switch(rand(1))
                {
                    case 0: return GetShipIndex("Carrack"); break;
                    case 1: return GetShipIndex("caravel1"); break;
                }
            break;
 
            case PERIOD_THE_SPANISH_MAIN:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("SP_Derfflinger"); break;
                    case 1: return GetShipIndex("RN_RevengeM"); break;
                    case 2: return GetShipIndex("FastGalleon1"); break;
                }
            break;
 
            case PERIOD_GOLDEN_AGE_OF_PIRACY:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("Barque4_47"); break;
                    case 1: return GetShipIndex("PiratPostillionen"); break;
                    case 2: return GetShipIndex("frigate1"); break;
                }
            break;
 
            case PERIOD_COLONIAL_POWERS:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("PiratHannah"); break;
                    case 1: return GetShipIndex("PO_Neptunus"); break;
                    case 2: return GetShipIndex("frigate2"); break;
                }
            break;
 
            case PERIOD_REVOLUTIONS:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("ketch"); break;
                    case 1: return GetShipIndex("Hooker"); break;
                    case 2: return GetShipIndex("Corvette47"); break;
                }
            break;
 
            case PERIOD_NAPOLEONIC:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("Schooner50"); break;
                    case 1: return GetShipIndex("FastMerchantman1"); break;
                    case 2: return GetShipIndex("lineship47"); break;
                }
            break;
        }
        // PB: If all fails, return a random period-specific ship type instead of the player ship <--
 
I'm trying to think of a smallish dual use ship to replace the Derfflinger and all I can come up with is the Caravel.
 
I guess, it is faster and all those quick loading guns make it a decent close in fighter.
 
Alrightee; that makes it this:
Code:
        //    return GetCharacterShipType(GetMainCharacter());
        // PB: If all fails, return a random period-specific ship type instead of the player ship -->
        trace("Force_GetShipType: unable to find ship, returning default ship instead");
        switch((GetCurrentPeriod()))
        {
            case PERIOD_EARLY_EXPLORERS:
                switch(rand(1))
                {
                    case 0: return GetShipIndex("Carrack"); break;
                    case 1: return GetShipIndex("caravel1"); break;
                }
            break;

            case PERIOD_THE_SPANISH_MAIN:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("Caravel2"); break;
                    case 1: return GetShipIndex("RN_RevengeM"); break;
                    case 2: return GetShipIndex("FastGalleon1"); break;
                }
            break;

            case PERIOD_GOLDEN_AGE_OF_PIRACY:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("Barque4_47"); break;
                    case 1: return GetShipIndex("PiratPostillionen"); break;
                    case 2: return GetShipIndex("frigate1"); break;
                }
            break;

            case PERIOD_COLONIAL_POWERS:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("PiratHannah"); break;
                    case 1: return GetShipIndex("PO_Neptunus"); break;
                    case 2: return GetShipIndex("frigate2"); break;
                }
            break;

            case PERIOD_REVOLUTIONS:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("ketch"); break;
                    case 1: return GetShipIndex("Hooker"); break;
                    case 2: return GetShipIndex("Corvette47"); break;
                }
            break;

            case PERIOD_NAPOLEONIC:
                switch(rand(2))
                {
                    case 0: return GetShipIndex("Schooner50"); break;
                    case 1: return GetShipIndex("FastMerchantman1"); break;
                    case 2: return GetShipIndex("lineship47"); break;
                }
            break;
        }
        // PB: If all fails, return a random period-specific ship type instead of the player ship <--
I'm adding in a trace, so that we will be able to analyse how frequently this occurs if necessary.
 
I have changed the compile.log entry whenever the game cannot find a ship to be an on-screen message as well in here:
http://www.piratesahoy.net/threads/quests-not-executing.20670/#post-452947
Hopefully that will make it more apparent how frequently this happens.

We should monitor our compile.log files after each time we played so we can see how frequently it occurs.
After all, technically it is an error, even though we managed to make the results be "not too bad". :shrug
 
I'll keep this in mind when playing; the on-screen message will be very helpful.

One thing that bothers me is that, despite making PiratCorvette and CrimsonBlood considerably rare, the first pirate fleet I encountered in my Beta 2.5 game consisted of JUST those two ships. :facepalm
I checked the code and the changes I made are present, so clearly I still haven't done enough to discourage those two from showing up too frequently.
 
One thing that bothers me is that, despite making PiratCorvette and CrimsonBlood considerably rare, the first pirate fleet I encountered in my Beta 2.5 game consisted of JUST those two ships. :facepalm
I checked the code and the changes I made are present, so clearly I still haven't done enough to discourage those two from showing up too frequently.
Those are NOT the default ships, so that is not the problem. Perhaps the minclass/maxclass/type is what is messing things up?
If the pirates just don't have enough ships available within those parameters, the same ones will keep cropping up.

Extract attached to PROGRAM\Ships . This will add lines like these into compile.log for EVERY single randomly encountered ship:
Code:
Force_GetShipType: Maxclass = 3, Minclass = 8, Nat = Spain, Type = trade, Loop = 0, Ship ID = BarqueHeavy
Force_GetShipType: Maxclass = 3, Minclass = 8, Nat = Spain, Type = trade, Loop = 0, Ship ID = Yacht2
Force_GetShipType: Maxclass = 3, Minclass = 8, Nat = Spain, Type = trade, Loop = 0, Ship ID = US_Hannah
Force_GetShipType: Maxclass = 3, Minclass = 8, Nat = Spain, Type = trade, Loop = 0, Ship ID = Lugger1
Force_GetShipType: Maxclass = 1, Minclass = 8, Nat = Holland, Type = war, Loop = 0, Ship ID = Cutter1
Force_GetShipType: Maxclass = 1, Minclass = 8, Nat = Holland, Type = war, Loop = 0, Ship ID = Sloop2
So that allows us to do the following:
- If we encounter a ship too frequently, we can check this data to find out with what parameters it was generated and hopefully find out why no other ship was selected
- We should keep an eye on that "loop" value. This time it is "0" which means the game managed to find a ship each time on first try. So that is good.
But if we start running into higher values, that means the game is having trouble finding an appropriate ship even if it DOES end up finding one.
If the number goes to 200, a visible error log message is generated on the screen with the details, along with the accompanying compile.log data.

Edit: Also open PROGRAM\SEA_AI\AIFantom.c and find:
Code:
Trace("Can't find ship type '" + sShipType + "' with ClassMin = " + iClassMin + " and ClassMax = " + iClassMax);
Add // in front of this to comment it out. This will prevent the compile.log from needlessly looking like this:
Code:
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
[... continued 200 times ...]
Edit 2: See the attachment of this post instead: http://www.piratesahoy.net/threads/ship-encounter-chances-correction.17815/page-11#post-453022
 
Here are some findings already:
Code:
Force_GetShipType: Maxclass = 4, Minclass = 6, Nat = Holland, Type = Trade, Loop = 2, Ship ID = Schooner2
Force_GetShipType: Maxclass = 4, Minclass = 6, Nat = Britain, Type = Trade, Loop = 1, Ship ID = FastMerchantman2
Force_GetShipType: Maxclass = 4, Minclass = 6, Nat = America, Type = Trade, Loop = 2, Ship ID = Shnyava1
Can't find ship type 'Trade' with ClassMin = 3 and ClassMax = 3
ERROR - Force_GetShipType: unable to find ship, returning a default ship instead
 
Those are NOT the default ships, so that is not the problem. Perhaps the minclass/maxclass/type is what is messing things up?
If the pirates just don't have enough ships available within those parameters, the same ones will keep cropping up.
Yeah, I meant to say that was unrelated to the default ships problem.
Now that you mention it, the max/min class may well be a problem, since PiratCorvette and CrimsonBlood are among the only Tier 4 pirate ships

Extract attached to PROGRAM\Ships . This will add lines like these into compile.log for EVERY single randomly encountered ship

Extract... what? :wp
 
Extract... what? :wp
Sorry; I was in the middle of editing my post due to excessive amounts of compile.log entries that I had not anticipated.
It's back to normal with a new and improved file. :razz
 
I figured I might explain how the selection code actually works. Basically it goes through every ship in the game and any ship that falls within its parameters (see above) is added into a list.
Once this list of potential ships is compiled, the game will randomly select one of them.
This is a pretty damn good system and certainly beats selecting a random ship out of all available and then checking if falls within the parameters.

However, our Period and Nation chances code is "shoe-horned" into this system before that "list of potential ships" is compiled.
So the resulting list will differ each time it is compiled because the chance values make ships sometimes fall into it and sometimes not.
But basically this means that for EACH ship that is generated, the game might compile that same list up to 200(!) times.
And EACH time the list is generated, it looks at those chance values.

So if a default ship is selected, that means that EVERY ship that falls within the requested parameters has failed on the chance check 200 times.
The odds of that seem pretty astronomical to me. So that means that when a default ship IS generated, the game probably has literally nothing to choose from.

This is also indicated by the fact that in the short tests that I did, most of the time the game managed to generate a ship on first try.
A few times the game had to loop once or twice. Except that one Dutch encounter where the game looped 200 times and still didn't find anything.

Does that make any sense?
 
So if a default ship is selected, that means that EVERY ship that falls within the requested parameters has failed on the chance check 200 times.
The odds of that seem pretty astronomical to me. So that means that when a default ship IS generated, the game probably has literally nothing to choose from.

This is also indicated by the fact that in the short tests that I did, most of the time the game managed to generate a ship on first try.
A few times the game had to loop once or twice. Except that one Dutch encounter where the game looped 200 times and still didn't find anything.

With that example of a 'Trade' ship with max/min class 3... does the game define 'Trade' as being refShip.Type.Trade = true AND refShip.Type.War = false?
If that's the case... there are NO Tier 3 trade vessels in the game. There are some 'balanced' vessels like the Amsterdam in that Tier, though.
 
Back
Top