• 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

That was a bug, but wasn't the ships showing up in the wrong period fixed a little while ago?
 
I got them as Johan Elting 1666 in 2.3. I tried today a pure Beta 1 game. Perfect all kinds of encounters. Point is, above 2.3 all encounters are bugged.
You have to distinguish between something not working the way you'd like and something being a bug.
What you reported before IS the code doing exactly what it should. If you don't like it, that requires adjusting the code. But it is not a bug.
Those ships are deliberately coded to NOT show up in the Assassin storyline.

The encounter chance have been changed a lot since Beta 1, so it is very possible it used to be different. But that is on purpose.
If anything seems out-of-order to you, feel free to post the compile.log and we can check if it fits into the coded parameters or if it is really doing things it shouldn't.

That was a bug, but wasn't the ships showing up in the wrong period fixed a little while ago?
As far as I can tell, the period code is working pretty well. The game will rather NOT return a valid ship than to show a wrong-period one.
That is when you get a default ship though, which we want to avoid. So whenever it happens, we have to figure out WHY.
 
So.... what are we going to do with this for Beta 3, then? We still need comments! Lots of them too!
Are those "cannot find ship" errors still occurring? If so, how and when? Still any single-ship-type encounters?
Did setting the chance values to 1.0 or 0.0 help or not?

Armada? Hylie Pistof? Pillat? Anyone....? :rolleyes:
 
I didn't try the fix pack. But it would be usefull to tell me which are all files that deal with encounters. Is it all those folders &files in yours period_encounters_2. Btw I sent you a pm.
 
I was still getting the "can't find ship, reverting to default" kinda message on my last working install but it was rare and the chosen ship was ok for the battle.
 
I didn't try the fix pack. But it would be usefull to tell me which are all files that deal with encounters. Is it all those folders &files in yours period_encounters_2. Btw I sent you a pm.
Period and nation encounter chances are defines in PROGRAM\Ships\ships_init.c .
Force_GetShipType is in PROGRAM\Ships\ships.c .
Worldmap and DirectSail encounter types are in PROGRAM\Encounters\Encounters_init.c
Fantom_GenerateEncounter is in PROGRAM\SEA_AI\AIFantom.c
That should be pretty much all that is involved. See this previous post of mine on how the system works with those files:
Long story short:
1. Worldmap and DirectSail encounters have their minclass, maxclass, number of ships and trade/war based on PROGRAM\Encounters\Encounters_init.c
2. Other encounters, such as Coast Raiders around islands, have those values fixed
3. Whenever the game searches for a ship, it first establishes a list of all valid ships based on class, trade/war (NOT nation and period yet)
4. The game then randomly selects a ship from that list and checks that against the nation and period chance values
5. If this check FAILS, it'll try again. Up to a maximum of 100 tries per ship. If it does NOT fail, that ship is selected

How to read your compile.log file:
Code:
Fantom_GenerateEncounter: type = L - Fleet: Regional Patrol, a small fleet, # Mer = 0, Mer MAX = 0, Mer MIN = 0, # War = 7, War MAX = 1, War MIN = 3
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 15, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 4, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 13, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 2, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 19, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 11, Ship ID = NL_FWzP
Force_GetShipType: Maxclass = 1, Minclass = 3, Per = The Spanish Main, Nat = Holland, Type = War, Loop = 12, Ship ID = NL_FWzP
Fantom_GenerateEncounter refers to Encounters_init and tells you the type of encounter that is being requested.
The # values are the number of ships and the MAX/MIN values are the limits on the ship classes.

Force_GetShipType is the function that selects the actual ship, showing again the class limits, time period, nation and ship type (war/trade).
The "loop" values indicates the number of tries before the game found a ship. Ship ID is what the game eventually generates.

If "loop" reaches 100, the game writes an error message to compile.log and chooses between two period-appropriate generic ships.
Ideally, we do not want this to EVER happen, because it bypasses all other code that is there to make the encounters appropriate.
BTW: I haven't seen your PM. :no

I was still getting the "can't find ship, reverting to default" kinda message on my last working install but it was rare and the chosen ship was ok for the battle.
I want to see the compile.log for EVERY time that happens. Of course I removed the on-screen message in the latest update, but it is still being logged.
So after you close the game, please search compile.log for "error" just in case something wrong happened that was logged there.
 
Armada, what do you think of the ship encounters code now? Should we keep the old chance values you did or try to make new ones from scratch?
What we could do is to add a toggle to the file that sets any chance value larger than 0.0 to 100% for testing purposes.
Then at least we could switch that testing toggle OFF again if it proves to not be necessary.
Anyway, I think this was always your project, so just let me know what you want done before we can consider it release-ready. :doff
 
Sorry, I was at an air show earlier today. Haven't managed to test these changes yet. :read
Earliest I can look into it is probably tomorrow. I certainly have no plans to modify anything too much, though.
 
I'll probably wait at least until next weekend for the Beta 3 public release, so we've still got time to play around with this a bit.
Basically, we have two options: keep the values at 0.0/1.0 or stick to the earlier values we had. I have zero clue on what difference it makes though.
 
I'm adding this toggle to the top of ships_init.c:
Code:
#define PERIOD_ACCURACY_LEVEL     2   // PB: 1 = Simplified 0% or 100% Period+Nation chance, 0 = Period chance ignored
2 = Original values by Armada
1 = Simplified 1.0 or 0.0 chance for testing purposes
0 = All period chance values set to 1.0 if you care more about variety than historical accuracy

Defaults to setting 2.
 
I'm afraid I couldn't test it yet (And to be honest, I didn't watched out for this ever before:p ) But I hope my new laptop gets ready this week and then I hope I can finally play PotC Beta 3 in peace and can test all those wonderful things :)
 
Last edited:
Code:
CARGO: Fantom_SetGoods rare chance silver shipment!
Hey, I didn't know the game did such a thing! Apparently it DOES. Niiice! :woot
Well, I took the liberty of giving the Spanish Treasure Fleet encounter a 75% chance at having its trade ships loaded with gold and silver.
25% chance that they might be on the return journey or have already been pirated or something though. Can't go full 100, now, can we? :wp

Anyway, this goes for ALL the ships in that fleet. So if one of those merchants has treasure, the other ones do too!
This opposed to the 5% per random ship chance in general gameplay.

Seems to be working too:
Code:
Treasure Fleet!
Fantom_GenerateEncounter: type = L - Merchant 2: -->SPAIN ONLY<--, Trans-Atlantic Treasure Fleet, a convoy, # Mer = 3, Mer MAX = 3, Mer MIN = 3, # War = 5, War MAX = 1, War MIN = 4
Force_GetShipType: Maxclass = 3, Minclass = 3, Per = Early Explorers, Nat = Spain, Type = Trade, Loop = 1, Ship ID = Galeon50
Force_GetShipType: Maxclass = 3, Minclass = 3, Per = Early Explorers, Nat = Spain, Type = Trade, Loop = 0, Ship ID = GaleonWar
Force_GetShipType: Maxclass = 3, Minclass = 3, Per = Early Explorers, Nat = Spain, Type = Trade, Loop = 2, Ship ID = Galeon50
Force_GetShipType: Maxclass = 1, Minclass = 4, Per = Early Explorers, Nat = Spain, Type = War, Loop = 0, Ship ID = FastGalleon2
Force_GetShipType: Maxclass = 1, Minclass = 4, Per = Early Explorers, Nat = Spain, Type = War, Loop = 0, Ship ID = SP_ApostolFelipe
Force_GetShipType: Maxclass = 1, Minclass = 4, Per = Early Explorers, Nat = Spain, Type = War, Loop = 0, Ship ID = GaleonWar
Force_GetShipType: Maxclass = 1, Minclass = 4, Per = Early Explorers, Nat = Spain, Type = War, Loop = 0, Ship ID = SP_ApostolFelipe
Force_GetShipType: Maxclass = 1, Minclass = 4, Per = Early Explorers, Nat = Spain, Type = War, Loop = 0, Ship ID = FastGalleon2
CARGO: Fantom_SetGoods rare chance gold shipment!
CARGO: Fantom_SetGoods rare chance silver shipment!
CARGO: Fantom_SetGoods rare chance silver shipment!
Funnily enough though, the two Treasure Galleons (SP_ApostolFelipe) were escorts and therefore wouldn't be carrying any cargo.
Should we change that ship to trade only to ensure that she DOES get the cargo?
Seems weird to have a Treasure Galleon that doesn't have treasure in a fully-loaded treasure fleet. Let alone two of them. o_O
 
The error problem remains on the "Merchant 2" encounter:
Code:
Fantom_GenerateEncounter: type = Merchant 2: a single merchant with heavy escort, # Mer = 1, Mer MAX = 0, Mer MIN = 0, # War = 3, War MAX = 3, War MIN = 5
ERROR - Force_GetShipType: unable to find ship, returning a default ship instead
ERROR - Force_GetShipType: Maxclass = 3, Minclass = 3, Per = Early Explorers, Nat = Holland, Type = Trade
ERROR - Force_GetShipType: unable to find ship, returning a default ship instead
ERROR - Force_GetShipType: Maxclass = 3, Minclass = 5, Per = Early Explorers, Nat = Holland, Type = War
ERROR - Force_GetShipType: unable to find ship, returning a default ship instead
ERROR - Force_GetShipType: Maxclass = 3, Minclass = 5, Per = Early Explorers, Nat = Holland, Type = War
Force_GetShipType: Maxclass = 3, Minclass = 5, Per = Early Explorers, Nat = Holland, Type = War, Loop = 11, Ship ID = NL_FleutWar
Especially the trade part is apparently bugged, because it asks for minclass and maxclass of 0, which somehow translates as 3.
Also strange is that for the first two warships, the game failed to find an appropriate ship.
But with the same criteria, the third ship DID return NL_FleurWar on the 11th try. UH?

And as far as I can tell, there is nothing wrong with the encounter code; looks very similar to ENCOUNTER_TYPE_MERCHANT1 as confirmed by WinMerge. :modding

Has anyone seen this on non-Dutch Merchant 2 encounters yet? Every time I see this error on Merchant 2, it is a Dutch group of ships. :shock
 
The error problem remains on the "Merchant 2" encounter:
I do believe I've got it! For some reason, the code was including the ENCOUNTER_TYPE_PATROL code in the ENCOUNTER_TYPE_MERCHANT2 version.
This happens to be exactly where the maxpirate class code is sandwiched between, so I moved that to BEFORE the encounter initialization code.
As far as I can tell, the encounters now ARE being initialized the way they should be. So hopefully that will FINALLY kill the bugged Merchant 2 encounter! :aar

Edit: YUCK, that maxpirate class code was really messed up. Turns out it didn't have brackets in the right spots either, which caused all sorts of weirdness.
One of those being that when being reinitialized, the old settings were NOT being deleted.
So that means that thing got messed up if you start a New Game without first closing the game.
Fixed now too, so I think the encounters code might actually start behaving itself properly now. :whipa
 
Last edited:
Next up: DirectSail encounters
Turns out that these ignored any additional nations, so you'd never encounter Americans in DirectSail, for example.
Also it completely bypassed the encounter type for nation check, so you could get ANY encounter from ANY nation.
So you'd potentially get much larger pirate encounters in DirectSail that are supposed to be happening.
I have now rewritten both to use the correct values and functions, so it should work now much closer to the Worldmap encounters.

I'd much appreciate feedback once this is released though!
 
So I think I got all encounter-code to behave itself the way it is supposed to in the latest update: http://www.piratesahoy.net/threads/build-14-beta-3-progress.20686/
http://www.piratesahoy.net/threads/build-14-beta-3-progress.20686/
Now all we need is testing! Lots of it too! Stuff I especially would like to know:

1. During DirectSail in Revolutions and Napoleonic, do you encounter American ships too?

2. During DirectSail, do you encounter the larger fleets now too? Battle of Trafalgar style and Spanish Treasure Fleets, for example.

3. Do you ever see pirates with big ships or do they stick to the smaller ones properly?

4. Are the Spanish Treasure Fleets properly limited to Spain? Do they use the correct ship types?
And do the merchants have gold and silver on board like they should? (NOTE: 75 chance on this)

5. Check your compile.log for the "ship not found" errors. Especially on the "Merchant 2" encounter.

As far as I can tell from the code and my quick tests, this should all work now. But you never do know. :shrug
 
Are there any people at the moment looking into this or willing to look into this?
It is pretty much the only project we've still got on the To-Do list for Beta 3.

Though I suppose with all the recent fixes done to this, it should for sure be better than Beta 2.5 .
It'd be good though to have some confirmation that the changes made indeed DO have the intended effect.
 
I just upgraded to the latest version and haven't played it much.

I really can not answer any of those questions as I have not seen anything different from a month ago. How would one know when they encounter a treasure fleet?
 
Back
Top