• 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 More direct-sail encounters

Don Lasagnetti

The Black Admiral
Storm Modder
Hello everyone,

I've been out of here for quite a while and recently had a look at the game again. It really looks great and is highly enjoyable. I've spent quite some time in direct-sail mode, but I'm honestly missing a few things that world-map travel simply does better.

Storms are the first thing. While I do get them occasionally when dropping in from map-mode, I never get them in direct sail mode.

Second thing is, how easily could I add battles to the random encounters? I've had a brief look at the file and was thinking, it might not be so hard to have the game randomly create 1, 2, 3 or 4 fleets (random nations) at the same time. Thought I'd ask if it's been tried or if someone can help me out here, before spending hours trying to figure this out for myself.

Thanks in advance for any help you can provide!
 
Storms are the first thing. While I do get them occasionally when dropping in from map-mode, I never get them in direct sail mode.
They do happen (sometimes more often than @Hylie Pistof would like), but they have to develop with the wind increasing until there is a storm and then decreasing again.
Storm occurrence depends on the month and is based on the actual Caribbean hurricane season.
So you could end up getting more storms than you would like a few game months from now.
See here for more details: Medium Priority - Reduce Monthly Storm Chance

Second thing is, how easily could I add battles to the random encounters? I've had a brief look at the file and was thinking, it might not be so hard to have the game randomly create 1, 2, 3 or 4 fleets (random nations) at the same time. Thought I'd ask if it's been tried or if someone can help me out here, before spending hours trying to figure this out for myself.
Sounds to me like it should be possible, but I don't think anyone ever tried it yet.
Would make sense to have them though, since the WorldMap has it and DirectSail is supposed to offer everything the WorldMap does (but, as you discovered, it doesn't).

I did once change the code to make DirectSail trigger the same encounter types used also on the WorldMap.
But the WorldMap has extra code to generate battles between two fleets.

Relevant files are:
PROGRAM\CCCdirectsail.c, especially the void DirectEncounter function.
PROGRAM\SEA_AI\sea.c, where this function is called to generate one separate fleet (I think directly ahead of the player)
PROGRAM\WorldMap\worldmap_encgen.c, especially the void wdmShipEncounter function
PROGRAM\WorldMap\worldmap_globals.c, especially the bool wdmCreateWarringShips function

Unfortunately the actual battle creation for the WorldMap is sent to the game engine, where we cannot control it.
However, it should be possible to do something similar in a different way during DirectSail.
You could try simply calling the DirectEncounter function twice with slightly different headings and see what happens.

I could also imagine you want to be able to control the nation of the fleets being generated to ensure they're hostile to each other,
in which case the 'Encnation' variable could be moved outside the function and into sea.c .

Hopefully that helps get you started. :doff
 
I don't like dropping out of the world map after checking everything straight into a storm when there should not be a storm there. This is especially bad when you drop into a battle as well. This is game breaking and I just reload from the last save and start over.

In direct sail storms are fun as you are moving one way and it is moving another way and you are guessing which way it is moving.
 
Alright,

thanks for pointing me the right direction! Another thing though, what would be the easiest way to trigger random encounters via console?

Also, I'm pretty sure that in 2 years IG time, not a single storm happened in direct-sail mode.

If I'm playing merchant, I never have to repair my ship, because pirates just ignore me and storms don't cross me.

But if no one else is experiencing that, could be just my game.


I could also imagine you want to be able to control the nation of the fleets being generated to ensure they're hostile to each other,
in which case the 'Encnation' variable could be moved outside the function and into sea.c .

Actually, I think I would prefer the possibility of fleets being the same nation. Since they're having a random location based around player ship, it could very well be a trap for a pirate or enemy corsair.
I'd rather have up to four or more different fleets trigger. Would make nation relations more interesting, I think.

But now to test if I can get anything to work in the first place
:ship
 
I think that ship encounters are pretty much realistic.when sailing between two near islands I encounter 1 fleet average.I have the game one year now and I think that storm chance is VERY realistic (it happens) and they are much better than the stock game because they're not always the same.would like to see battle encounters and to lower the chance of encountering loot,dismasted vessels...
 
I like ship Encounters too, would just love to see battles occasionally. :pirate41:
I've managed to activate them already, just gives me a lot of crashes. That could be lack of computing power though.
And I can't seem to get a console command to work to trigger events, makes testing take ages. :shrug
Also, unfortunately, since I'm not really good at coding, I haven't managed to random between single Encounters and battles yet.

I would like to see battle encounters and to lower the chance of encountering loot,dismasted vessels...
Haven't found where the encounter chances are defined yet either.

So, if anyone could help with a console command, that would be great and speed things up a lot :whipa
 
Another thing though, what would be the easiest way to trigger random encounters via console?
If I understand correctly, you could try this:
Code:
            // encounter markerattribute is attached to player
            pchar.directsail.encounter = 1;

            CreateEntity(&SeaFader, "fader");
            SendMessage(&SeaFader, "ls", FADER_PICTURE0, FindReloadPicture("SailHo.tga")); // KK
            SendMessage(&SeaFader, "lfl", FADER_IN, 0.5, true);
            PlaySound("#sail_ho");
            Sea_ReloadStartDirect();    // reloads Sea with new ships at horizon

Also, I'm pretty sure that in 2 years IG time, not a single storm happened in direct-sail mode.
That's a bit surprising. You could try playing with the numbers as suggested in that thread I linked to.

@Hylie Pistof, what are your experiences?
I do believe there's a LOT of random involved, which doesn't really help to distinguish any patterns...

If I'm playing merchant, I never have to repair my ship, because pirates just ignore me and storms don't cross me.
Pirates ignore you? What flag are you flying? And what are the nation relations? :shock

would like to see battle encounters and to lower the chance of encountering loot,dismasted vessels...
PROGRAM\CCCdirectsail.c in DirectsailRun() this triggers a random loot event:
Code:
        Randomshipevent();     // random shiplife events
        pchar.directsail.count = 0.0;        // LDH - 08Jan09
Looks like that code is messy as it's got one of those bizarre 'if-else-else' statements.
@LarryHookins apparently already picked up on that back in 2009, but it was never changed.
Probably a good idea to fix that up a bit now! If you have any suggestions, those will be most welcome. :doff

I'm not really good at coding
If you haven't seen it yet, some of this might help: Tutorial - Modding Tips & Tricks

I haven't managed to random between single Encounters and battles yet.
If you get them to work, switching between single and battles should be easy enough.
All you need is a chance check such as this one:
Code:
if (DIRECTENCOUNTERCHANCE > rand(100))

Haven't found where the encounter chances are defined yet either.
PROGRAM\NK.c (weird place needed because of the 'Open Sea Mod'):
Code:
// stljeffbb Jan 15 2012 -->
void InitOpenSeaMod()
{
    ref PChar = GetMainCharacter();
    if(iRealismMode>1 || OPEN_SEA_MOD)
    {
        DIRECTENCOUNTERCHANCE =                                25;        // chance in percent that an encounter fleet appears every hour
        [...]
    }
    else
    {
        DIRECTENCOUNTERCHANCE =                                50;        // chance in percent that an encounter fleet appears every hour
        [...]
    }
}
// stljeffbb Jan 15 2012 <--
 
My experience is that storms happen. In fact I always start out in a tier 8 Tartane or Hoy just so it won't capsize when I get caught in a storm when my skills are very low. One can go for months at a time with nothing but clear weather and then get hit with storm after storm in one voyage. A fast ship that sails into the wind well can sail around them or outrun them while a square sail ship needs to carry lots of repair parts.

I also see plenty of enemies. Not necessarily large fleets as those are rare, but they're out there.
 
If I understand correctly, you could try this:

Perfect, that worked like a charm, thank you :cheers

Pirates ignore you? What flag are you flying? And what are the nation relations? :shock

Yes, they do. Seems as if they were behaving according to AITask move instead of attack probably. I've been under either personal or french flag and all nations were wary or neutral, pirates hostile (around -100)

If you get them to work, switching between single and battles should be easy enough.
All you need is a chance check such as this one:
Code:
if (DIRECTENCOUNTERCHANCE > rand(100))
I've actually resorted to the rand-function in the end and it seems to work quite well in sea.c, after I've finally got the syntax right and (re)moved everything where it should belong, I think.
(At first it kept despawning island ships and toggled world-map availability, then it teleported me back to the island's main harbor all the time, both bugs had to walk the plank though)
:walkplank

Code:
    } else {


         if (bDirectSail && CheckAttribute(rPlayer, "directsail.encounter")) { // if set so in DirectsailCheck() random encounter ships are created

switch(rand( 3 ) ) //Don Lasagnetti - The Black Admiral: added random function for sea battles in direct sail mode. 1 - 3 fleets possible.
{

            case 1:
            rPlayer.ship.pos.x = stf(Login.PlayerGroup.x); // so that DirectEncounter doesn't use OLD coords
            rPlayer.ship.pos.z = stf(Login.PlayerGroup.z);
            DirectEncounter(stf(Login.PlayerGroup.ay));
            break;

            case 2:
            rPlayer.ship.pos.x = stf(Login.PlayerGroup.x); // so that DirectEncounter doesn't use OLD coords
            rPlayer.ship.pos.z = stf(Login.PlayerGroup.z);
            DirectEncounter(stf(Login.PlayerGroup.ay));
            DirectEncounter(stf(Login.PlayerGroup.ay));
            break;

            case 3:
            rPlayer.ship.pos.x = stf(Login.PlayerGroup.x); // so that DirectEncounter doesn't use OLD coords
            rPlayer.ship.pos.z = stf(Login.PlayerGroup.z);
            DirectEncounter(stf(Login.PlayerGroup.ay));
            DirectEncounter(stf(Login.PlayerGroup.ay));
            DirectEncounter(stf(Login.PlayerGroup.ay));
            break;

            }

            DeleteAttribute(rPlayer,"directsail");    // clears tags from player

        }

I've tested it for quite a while and it does what I was aiming for, create randomly either 1, 2 or 3 fleets at random locations, nations completely random too (so you could get 3 battle fleets of the same nation surrounding you).

There are two things that I've encountered though and where I'd be very grateful for others testing it too:
  • At times I got empty encounters. While the game was loading a sail-ho Encounter, there were no ships to be found anywhere (compile log had none spawned either, no error log created)
  • Occasionally I'm getting crashes during sail-ho loading screen, with standard Windows error. Compile log shows the ships loaded properly and I get no error log either. As my machine and I have a long and faithful history together, I assume it to be a matter of lacking computing power, so too many ships to load at once, which takes too long and makes Windows shut the game down. Could not find a way around this yet.
And this is where my request comes in: other players, please test the attached new file (copy the original first though!) and let me know, if this is working better for you or if anyone encounters trouble too. File has to be put into PROGRAM/SEA_AI.:whipa
 

Attachments

  • sea.c
    59.5 KB · Views: 475
Last edited:
Seems as if they were behaving according to AITask move instead of attack probably. I've been under either personal or french flag and all nations were wary or neutral, pirates hostile (around -100)
I suppose they should still attack then if you get too close, no?

I've actually resorted to the rand-function in the end and it seems to work quite well in sea.c, after I've finally got the syntax right and (re)moved everything where it should belong, I think.
(At first it kept despawning island ships and toggled world-map availability, then it teleported me back to the
Sounds like you've had some serious modding adventures! :shock

At times I got empty encounters. While the game was loading a sail-ho Encounter, there were no ships to be found anywhere (compile log had none spawned either, no error log created)
Probably because Rand(3) can return also 'case 0'.

Occasionally I'm getting crashes during sail-ho loading screen, with standard Windows error. Compile log shows the ships loaded properly and I get no error log either. As my machine and I have a long and faithful history together, I assume it to be a matter of lacking computing power, so too many ships to load at once, which takes too long and makes Windows shut the game down. Could not find a way around this yet.
If other people have the same problem, perhaps a delay could be introduced so they're not all generated at the same time.
That would take some more complicated programming though.

And this is where my request comes in: other players, please test the attached new file (copy the original first though!) and let me know, if this is working better for you or if anyone encounters trouble too. File has to be put into PROGRAM/SEA_AI.:whipa
@STARk7, @Grey Roger, @Hylie Pistof and @ANSEL?
 
What happens if you only switch between single and double encounters and ship the triple/quadruple?
Just to check if perhaps it is an overload of ships...
 
I know what happened.I spent very little time playing any game mode other than Iron Man Mode and I switched to Realistic game mode for testing because it have "sail to" option,and I forgot that ships are not just generated near me but near the island as well and when I open "sail to" there are a lot of ships/fleets...

My bad :wp
 
I think that it works great,only thing I don't like is the chance of encountering is the same for all tree cases so I changed it to be more realistic.

1 fleet=70%
2 fleets=20%
3 fleets=10%

Thanks for this :bow
 
20 encounters 1 crash,not bad

I encountered 5 fleets once and 4 fleets twice

What happens if you only switch between single and double encounters and ship the triple/quadruple?
Just to check if perhaps it is an overload of ships...

Thanks for testing so quickly and the feedback! I've tested it with a maximum of 2 fleets and max 3 too, for me it made no (noticeable) difference. As most people have way newer rigs than I do, I thought I'd test with 3 maximum right away.
Glad to hear it is indeed working and the crashes are caused by too many ships

I think that it works great,only thing I don't like is the chance of encountering is the same for all tree cases so I changed it to be more realistic.

1 fleet=70%
2 fleets=20%
3 fleets=10%

Thanks for this :bow

Hm, that was my next step too, for the upcoming weekend probably. How did you change it, code-wise?
 
Back
Top