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

Medium Priority Worldmap Encounter Enhancement (V 1.32) Updated

Levis

Find(Rum) = false;
Staff member
Administrator
Creative Support
Programmer
Storm Modder
Okay let's see if I can describe the procedure see below for more details

1) the game looks which 3 towns are closes to you.
2) It gets the fleetsize (both merchant and militia ships) for these towns.
3) It uses a adapted form of the inverse square law to determine the shiprate at your distance
4) It determines if there are warring ships
5) Determine the percentage of trader vs militia ships
6) The ships which are used for warring are subtracted from the other ship rates conform the percentage
7) Everything is converted to a chance per X hours.
8) Check the time of the day and adjust the chance by it
9) Checks the state of the moon and adjusts chances by it
10) With these new chance the encounter are created by the old way but now multiple ships can be created at 1 time if the chance is larger then 100%.
11) Check the relations and set the nation of the ship.

Distance to town
It takes the player X and Z coords and the town X and Z coords and then determines the distance with SQRT((x1-x-2)^2+(z1-z2)^2)

Get fleet size
By now these are still fixed numbers, but this will change.

Inversed Square Law
The law works as follows, the shiprate is determined by:
fleetsize * 2 * constant * island_radius^0.3 * distance_to_town^0.55
distance_to_town^2
The constant is a value between 0 and 100 which can be set for each type of fleet. Most of the other values are found by trail and error to get a nice distribution of the shiprate. This way when you are still within the coastal waters of the harbor of the town the shipsrate is the fleetsize. The ship rate is how many ships you can encounter at 1 day which somewhere sounds logical cause these ships normally want to be in port as short as possible, especially when they are still carrying a cargo.

Warring Ships
For the warring ships it looks at how many ships there are in the vicinity (by checking the shiprate). There has to be at least 2 ships to get warring encounters. The amount of ships which are warring is determined by:
(totalships+2)^(1+(totalships+2)^0.1)*(1 - sqrt((d1-d2)^2) / 400)
100
The upper part generates a value by taking the total amount of ships in and exponential function. The totalships variable is shifted right 2 because the first part increases to quickly and this way the curve matches the expectance better. The part in bold is added to add a distance variable also. It checks the difference in distance between the two closest ports. And this value then is used to determine a percentage of warring ships which are "okay". This means that if you are right in the middel of two ports the full number is used while if you are in a port no warring ships will be created (almost ;) ). The whole thing is dived by 100 just because it had to or I had to use smaller numbers in the whole thing.

Chance per X hours
The game updates the world map every X hours. This depens on various factors. The functions check when the last update was and change the variables so it always is correct. so if you would add the chances for the last 24 hours (so say if you have blocks of 4 hours you take 6 blocks and add the chances together) you will get the normal shiprate / 100.

Time of the Day
A sinus function is used to check the rate on the time of the day.
The sinus goes between 0,25 and 1,25 with 8 o clock being the turning point. it has a period of 24 hours.
(sin((TIME_IN_HOURS-8)/12*PI)+1,5)/2
For the pirate chance this value is substracted from 2 to get the pirate chance.

Chance larger then 100%
There is a loop going which check how large the chance is. Say the chance is 150% then the loop will see it has to do 2 runs and uses a chance of 150/2 for each run to determine if a encounter has to be created.

Check the relations
It checks the relation of the nation of the closest island. For traders it takes all neutral and friendly nations and the ship can be any of these nations.
For war ships it takes only the friendly ones.
More explainations will come later but I would like some people to test it now and give feedback :).

For now it uses fixed values for each islands production rate. This will be made dependable on the islands gold and garrison. But I first need to check those numbers better and come up with good formula's.

This mod will already give you some sense of where it's going. For example you will notice most battles take place between islands and on the open sea you will encounter way less boats while close to the ports it can be quite busy.

I also want to add a day/night troggle later but this is a first version. please let me know what you think off it :).

To install extract the folder to your ROOT pirates folder.
Most recent version is included in the WIP version of the build mod
 
Last edited:
Uh yeah, this will take some talking about. :nerbz

If I understand you correctly this will be a major change as to where sea battles take place.
 
It changes the way encounters are determined on the worldmap. This used to be done by a random number generator and a spawn rate. This made the spawnrate the same over the whole worldmap. I changed this to be a bit more dynamic. I will explain it more soon.
Just test it and see what happens (and if you actually notice any difference).
It only changes the files in the worldmap and encounters folder (in program) so if you backup those folder you can always revert.
 
So this actually influences the worldmap encounters? Wow!
So if I understand correctly, you would be encountering a lot LESS ships far from the islands. Right?
That'd definitely be a sensible change! :onya
 
Yup, try it and you will see. And you will see ships batteling mostly between islands and not so much in the open sea.
Figured out how the world map thing worked. when I have it a bit more complete I will also add it to the direct sail.
 
Okay let's see if I can describe the procedure see below for more details

1) the game looks which 3 towns are closes to you.
2) It gets the fleetsize (both merchant and militia ships) for these towns.
3) It uses a adapted form of the inverse square law to determine the shiprate at your distance
4) It determines if there are warring ships
5) Determine the percentage of trader vs militia ships
6) The ships which are used for warring are subtracted from the other ship rates conform the percentage
7) Everything is converted to a chance per X hours.
8) With these new chance the encounter are created by the old way but now multiple ships can be created at 1 time if the chance is larger then 100%.

Distance to town
It takes the player X and Z coords and the town X and Z coords and then determines the distance with SQRT((x1-x-2)^2+(z1-z2)^2)

Get fleet size
By now these are still fixed numbers, but this will change.

Inversed Square Law
The law works as follows, the shiprate is determined by:
fleetsize * 2 * constant * island_radius^0.3 * distance_to_town^0.55
distance_to_town^2
The constant is a value between 0 and 100 which can be set for each type of fleet. Most of the other values are found by trail and error to get a nice distribution of the shiprate. This way when you are still within the coastal waters of the harbor of the town the shipsrate is the fleetsize. The ship rate is how many ships you can encounter at 1 day which somewhere sounds logical cause these ships normally want to be in port as short as possible, especially when they are still carrying a cargo.

Warring Ships
For the warring ships it looks at how many ships there are in the vicinity (by checking the shiprate). There has to be at least 2 ships to get warring encounters. The amount of ships which are warring is determined by:
(totalships+2)^(1+(totalships+2)^0.1)*(1 - sqrt((d1-d2)^2) / 400)
100
The upper part generates a value by taking the total amount of ships in and exponential function. The totalships variable is shifted right 2 because the first part increases to quickly and this way the curve matches the expectance better. The part in bold is added to add a distance variable also. It checks the difference in distance between the two closest ports. And this value then is used to determine a percentage of warring ships which are "okay". This means that if you are right in the middel of two ports the full number is used while if you are in a port no warring ships will be created (almost ;) ). The whole thing is dived by 100 just because it had to or I had to use smaller numbers in the whole thing.

Chance per X hours
The game updates the world map every X hours. This depens on various factors. The functions check when the last update was and change the variables so it always is correct. so if you would add the chances for the last 24 hours (so say if you have blocks of 4 hours you take 6 blocks and add the chances together) you will get the normal shiprate / 100.

Chance larger then 100%
There is a loop going which check how large the chance is. Say the chance is 150% then the loop will see it has to do 2 runs and uses a chance of 150/2 for each run to determine if a encounter has to be created.
 
Very interesting indeed! :onya

Do you know if there is also an influence of the nations of the nearest towns?
As in: If you are close to the Dutch islands, you will see more Dutch ships and less enemy ones?
 
There are option in the game for it. I haven't used it yet but I intend to use it.
 
New version again.
What is new:

It now checks relations for the encounters. So say you are next to a dutch island then only traders which are friendly and neutral with the dutch will be created and warships will only be created which are friendly. The battles between two ships are between an enemy of the nation. It could be that the french are allies with the dutch so a french ship is batteling close to a dutch island with a nation which is neutral to the dutch but because its an enemy to the french they are still batteling.

Pirates are created by checking the ratio between traders and militia. The more militia there is the less pirates you will see. But if there are a lot of traders and not much milita expect a lot of pirates then.

During the night less normal encounters are created. Then pirates are more created.

I think that's it.
Next step will be to make the encounter rate for militia and traders variable for each island.
Btw can people check if this creates errors and if so please upload the error.log. I'm getting really weird errors and I don't think thats because of the code cause it says something goes wrong on a line where there is nothing :p.
 
Last edited:
I've been seeing weird worldmap errors for a while now. If the ones you get are the same ones, then they aren't related to your work.

Taking the time of day into account sounds interesting. But ships persist on the worldmap more than 24 hours.
So I'm afraid that might not make much of a difference. :facepalm
 
I've been seeing weird worldmap errors for a while now. If the ones you get are the same ones, then they aren't related to your work.

Taking the time of day into account sounds interesting. But ships persist on the worldmap more than 24 hours.
So I'm afraid that might not make much of a difference. :facepalm

I does help. I tested it with and without and this does help. Not that much but I do notice a improvement in how the encounters are generated
 
Found out what was causing the errors in the error.log so here is a version which doesn't generate a lot of errors.
 
So any Feedback on it already? Anyone noticing strange things?

btw I just tought up that calculating if there is a fullmoon is very easy. This function could also be usefull with cursed coins etc (for example only immortal during full moon and else just more hitpoints).
I could use that function also to have more pirates spawn during fullmoon (and things very Close to it). Would that be nice? I mean its Logical. They would hunt most during nights with full moon cause you can see best then (depending on the weather ofc).
 
Last edited:
Full moon? Interesting. Indeed for the cursed coins, that does make sense.
Technically, it should also take into account the cloud coverage for changing to skeleton form.

EDIT: If we are going for complete accuracy to the movies here, any moonlight changes the characters into a skeleton.
Full Moon not required, though New Moon should prevent it.

Not sure about pirates coming out more at full moon though.
If they can see their targets, their targets can see them too.
On that account, it might again be more trouble than it's worth....
 
Last edited:
I can't test this as I am involved with COAS stuff now, but others seem to be stepping up.
 
Hey, Levis! ;)

Great job, mate! Cheeeeers!

When we are at World Map Encounters anyways... one thing that always bothered me, was, that if the encounter dialog shows up and you can decide "Engage" or "Leave", the time on the sea map KEEPS RUNNING, while it should - of course - stop, so that you can read the encounter dialog without being in the hell of a hurry (especially with time speed increased).

Any chance of getting that issue fixed up as well? That would be sooooo great!

Have fun, happy modding and jolly plunderin, y'all! :D
 
Back
Top