• 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

the original engine is flawed and for the most part, you will be unable to circumvent that. Some of you have enough experience modding/playing this game that you know this to be true and these "workarounds" like drive cleaning and such, are just wishful thinking, typically based on anecdotal coincidence, because they do not really solve the various, underlying, root problems and your drive fragmentation (or whatever) was never really the cause and had no bearing on the true issue.
You speak the truth for sure there. I know you do. :onya
 
Alright, I didn't understand the better part of the recent posts, but it's unfortunate that the crashes were not due to my old hardware. Sounds like they can hardly be avoided either :(
The DS_Multifleet-function is exactly what I was trying in the first place, but I did not get anything to work at all, this project was my first real attempt to implement something by myself.
So thank you Grey Roger, a toggle would be great, I for one would rather have occasional crashes and the chance to see multiple fleets than only single encounters. :cheers
My logic behind this was that it might be nations teaming up against another, or one nation setting an ambush with multiple fleets. Question to counter: Why would clever tacticians place all their ships in one line and not split them into 2-3 convoys to cut off escape routes/let fire rain on the enemy from two sides/chase the enemy with wind advantage into a waiting wall of cannons etc., I believe you get my drift… :bonaparte

Alright, another thanks to ChezJfrey for the explanations on randomization in the game, sounds like it was quite an easy fix. Looking forward to that one too.

On another note, I have more changes I made to my game and was wondering if you believe they could be of interest to others too, mainy concerning period availability.
I don't have enough free time to play in several timelines, so it usually was revolutions for me (to have the U.S. added). That way, I did not get to enjoy the whole diversity of ships (and weapons) the game has to offer.
So I made all ships available in all periods, albeit with a rather small chance outside of the periods deemed historically correct by whoever set the chances originally. Furthermore, I've made some questships able to be encountered with very small chance.

I do believe, please correct me if I'm wrong, that it should be rather easy to add a toggle for this, simply by making two copies of the file, one with the settings as they are and one with adepted encounter chances and calling the one required. I fail to find out how I would accomplish that though, so if someone would nudge me the right direction, I would gladly take the workload of adjusting chances for all ships.

My other approach was to add very rare special encounters for direct sailing, for example pirates with ships larger than tier 3, a fleet led by the pearl in one of it's variants, EITC convoys, a pair of chinese junks, one of the cursed ships, ships of nations not currently represented (no need to worry about nation relations...) and so on. Again, ideally with one or more toggles (standard/only realistic enouncters/fictional and fantasy encounters).

So my questions are, would this be of interest with the current direction the mod is heading or is the realism approach prevailing?
And secondly, would someone with good coding experience be willing to help me (greatly)? As you can see, I am really inexperienced still but would be more than willing to fill the framework, if someone helps me with that in the first place. I really want to emphasize again though, that it won't be an occasional question to answer here and there but actually explaining, adjusting or outright writing required functions mostly for the time being.
 
So I made all ships available in all periods, albeit with a rather small chance outside of the periods deemed historically correct by whoever set the chances originally. Furthermore, I've made some questships able to be encountered with very small chance.

I do believe, please correct me if I'm wrong, that it should be rather easy to add a toggle for this, simply by making two copies of the file, one with the settings as they are and one with adepted encounter chances and calling the one required. I fail to find out how I would accomplish that though, so if someone would nudge me the right direction, I would gladly take the workload of adjusting chances for all ships.
Perhaps you could work that into the PERIOD_ACCURACY_LEVEL toggle that I hid at the top of ships_init.c?
That would make sense to me. :yes

My other approach was to add very rare special encounters for direct sailing, for example pirates with ships larger than tier 3, a fleet led by the pearl in one of it's variants, EITC convoys, a pair of chinese junks, one of the cursed ships, ships of nations not currently represented (no need to worry about nation relations...) and so on. Again, ideally with one or more toggles (standard/only realistic enouncters/fictional and fantasy encounters).
That definitely sounds like something some people would enjoy! :onya

So my questions are, would this be of interest with the current direction the mod is heading or is the realism approach prevailing?
From my side, we've always tried to tailor to BOTH sides in a way that everybody can be happy and nobody needs to feel left out.
The mod defaults tend towards realistic these days, but that doesn't mean that everything else is unwelcome. Not at all!
(And I myself really like fantasy stuff too. ;) )

And secondly, would someone with good coding experience be willing to help me (greatly)? As you can see, I am really inexperienced still but would be more than willing to fill the framework, if someone helps me with that in the first place. I really want to emphasize again though, that it won't be an occasional question to answer here and there but actually explaining, adjusting or outright writing required functions mostly for the time being.
Willing? Absolutely.
How much I'll be able to afford to do though? That I cannot make any guarantees on.
But we can try! :cheers

Perhaps instead of a 'switch(rand( 2 ) )', this:
Code:
if (bDirectSail && CheckAttribute(rPlayer, "directsail.encounter"))
{ // if set so in DirectsailCheck() random encounter ships are created
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));
if (DS_MULTIFLEET > 0.0)
{
if (frand(100) <= DS_MULTIFLEET)
{
DirectEncounter(stf(Login.PlayerGroup.ay)); // Second group in encounter, chance of a third
if (frand(100) <= DS_MULTIFLEET) DirectEncounter(stf(Login.PlayerGroup.ay));
}
}
DeleteAttribute(rPlayer,"directsail"); // clears tags from player
}
'DS_MULTIFLEET' is set in "InternalSettings.h", default 0.0. It should be a percentage chance of a second encounter. Repeating the line in the above code means there's a percentage^2 chance of getting two additional encounters, i.e. a triple encounter. For example, if you set 'DS_MULTIFLEET' to 50.0 then there should be a 0.5 chance of an extra group and a 0.25 chance of two extra groups.
Perhaps something to try in PROGRAM\CCCdirectsail.c find:
Code:
//-------------------------------- Encounters and events -----------------------------------

void DirectEncounter(float encay)  // called by SeaLoginDirect
Replace with:
Code:
//-------------------------------- Encounters and events -----------------------------------

#event_handler("CallDirectEncounter", "DirectEncounter");
void DirectEncounter(float encay)  // called by SeaLoginDirect
Then replace that section by @Grey Roger with:
Code:
if (bDirectSail && CheckAttribute(rPlayer, "directsail.encounter"))
{ // if set so in DirectsailCheck() random encounter ships are created
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));
if (DS_MULTIFLEET > 0.0)
{
if (frand(100) <= DS_MULTIFLEET)
{
PostEvent("CallDirectEncounter", 1000, "f", stf(Login.PlayerGroup.ay)); // Second group in encounter, chance of a third
if (frand(100) <= DS_MULTIFLEET) PostEvent("CallDirectEncounter", 2000, "f", stf(Login.PlayerGroup.ay));
}
}
DeleteAttribute(rPlayer,"directsail"); // clears tags from player
}
I haven't tested it, but (something like) that should add the second and third groups after a 1000 and 2000 millisecond delay.
If the crashes are indeed caused by an instantaneous game engine overload with too many engine errors triggering at the same time,
such delays might help as a workaround to relieve the stress.
 
What would happen if the '#define PERIOD_ACCURACY_LEVEL' line were moved out of "Ships_init.c" and into "InternalSettings.h" along with all the other customisable variables? Would that work, or is "InternalSettings.h" read too late for "Ships_init.c" to use it?

For larger pirate ships, just change the setting "MAXPIRATECLASS" in "InternalSettings.h".
 
Alright, I've played around and implemented as suggested above and Grey Roger's variant is working out already. I seem unable to get the delay to work properly though, it always spawns just one fleet. Tried variants too, replacing CallDirectEncounter with DirectEncounter only, toning down delays to 100 / 200 respectively but to no avail...
Code:
PostEvent("CallDirectEncounter", 1000, "f", stf(Login.PlayerGroup.ay)); // Second group in encounter, chance of a third
if (frand(100) <= DS_MULTIFLEET) PostEvent("CallDirectEncounter", 2000, "f", stf(Login.PlayerGroup.ay));
Could someone break down this function for me, step by step, please?
 
What would happen if the '#define PERIOD_ACCURACY_LEVEL' line were moved out of "Ships_init.c" and into "InternalSettings.h" along with all the other customisable variables? Would that work, or is "InternalSettings.h" read too late for "Ships_init.c" to use it?

For larger pirate ships, just change the setting "MAXPIRATECLASS" in "InternalSettings.h".
I think that's a great Suggestion actually, if that would work and is not too late. On that note, it's not explained what 2 does:
Code:
#define PERIOD_ACCURACY_LEVEL        2    // PB: 1 = Simplified 0% or 100% Period+Nation chance, 0 = Period chance ignored

And indeed, for myself I've allowed pirates up to tier 1 already. ;)
 
Option 2 for 'PERIOD_ACCURACY_LEVEL' changes the period and nation settings from fractional probabilities into simple toggles - either the ship can appear in that period or under that nation's flag, or it can't. A tier 1 ship which is allowed to appear as French in "Revolutions" period is as likely to appear as a 6th rate frigate which is also allowed.
 
What would happen if the '#define PERIOD_ACCURACY_LEVEL' line were moved out of "Ships_init.c" and into "InternalSettings.h" along with all the other customisable variables? Would that work, or is "InternalSettings.h" read too late for "Ships_init.c" to use it?
That would work perfectly fine.
InternalSettings.h is read first.

For larger pirate ships, just change the setting "MAXPIRATECLASS" in "InternalSettings.h".
Actually, I don't think that is enough because the nation encounter chances don't allow for bigger pirate ships either.

it's not explained what 2 does:
Code:
#define PERIOD_ACCURACY_LEVEL
2 is just the default behaviour, isn't it?

I seem unable to get the delay to work properly though, it always spawns just one fleet. Tried variants too, replacing CallDirectEncounter with DirectEncounter only, toning down delays to 100 / 200 respectively but to no avail...
Code:
PostEvent("CallDirectEncounter", 1000, "f", stf(Login.PlayerGroup.ay)); // Second group in encounter, chance of a third
if (frand(100) <= DS_MULTIFLEET) PostEvent("CallDirectEncounter", 2000, "f", stf(Login.PlayerGroup.ay));
Could someone break down this function for me, step by step, please?
Can you add a Trace and/or LogIt into DirectEncouncter to see if it gets triggered at all?
Those PostEvents are a bit fuzzy.

Also, did you add that extra line in CCCdirectsail.c as well?
It will definitely not work without it.
 
Morning,

I've been playtesting this for a bit yesterday and not a single crash in more than 30 encounters…

I have another problem now though, the walk folder in Sea.Ai seems broken, I can't even open it anymore. Extracting only that folder from the b14_beta4_final is not working either, it keeps telling me a lot of files are missing (I suspect some are unpacked several times with different names?).

In any case, could anyone upload that folder by any chance so I don't have to reinstall from the start?

Thanks in advance!
 
I've been playtesting this for a bit yesterday and not a single crash in more than 30 encounters…
That much less than before, isn't it?
What did you change? Did you get that PostEvent working or is it something else?
 
I've implemented Grey Roger's solution and so far no crash in 40+ encounters.
If I had to guess, it's because I duplicated the coordinate checks too for multiple encounters.
That much less than before, isn't it?
What did you change? Did you get that PostEvent working or is it something else?
Unfortunately not, CCCdirectsail.c would be modified as you said.
I wouldn't know how to add LogIt correctly. I've gone through everything though, and could my console command be the culprit for it not working?
Code:
            pchar.directsail.encounter = 1;
To be honest, as it seems to work much better now, I did not invest that much time into the PostEvent anymore.

Looking at boarding outcomes next, I think. I would love if you could continue the game after falling during Boarding, but in a dinghy as if your ship was sunk.
It was captured by the enemy after all, but perhaps the captain showed mercy...
 
I've implemented Grey Roger's solution and so far no crash in 40+ encounters.
If I had to guess, it's because I duplicated the coordinate checks too for multiple encounters.
Ooh, nice!
I don't really care how it works anyway; as long as it works. :woot

I wouldn't know how to add LogIt correctly.
Does trick #6 here help?
Tutorial - Modding Tips & Tricks
It's basically a simple matter of putting a string between quotation marks as single function argument.
LogIt, Trace and TraceAndLog all work the same.
A Log goes to the screen while a Trace goes to the compile.log file.
That way you can figure out what gets executed.

Looking at boarding outcomes next, I think. I would love if you could continue the game after falling during Boarding, but in a dinghy as if your ship was sunk.
It was captured by the enemy after all, but perhaps the captain showed mercy...
Wow, that would be cool!
 
Looking at boarding outcomes next, I think. I would love if you could continue the game after falling during Boarding, but in a dinghy as if your ship was sunk.
It was captured by the enemy after all, but perhaps the captain showed mercy...
That would be really interesting, since you can show mercy, why can't others show mercy to you? :onya
 
If you have changed "sea.c", could you upload it, please? After I implemented my own "solution", the game crashed on the third encounter, as previously reported, so your version is evidently more reliable than mine. If you've changed any other files to make multiple encounters work, please upload those as well.

"LogIt" is simple:
Code:
Logit("Here's a logit message");
That puts the message on screen.

Personally I prefer 'traceandlog', which displays the message on screen and writes it to "compile.log" at the same time. It works the same way:
Code:
traceandlog("Here's a logged message going into the log file");

Either way, if you want to know if a piece of code is being run, put one of these somewhere in that code. If the code immediately above the 'Logit' or 'traceandlog' line has been run then this line will be run as well. So if you see the message on screen (or in "compile.log" if you used 'traceandlog' then you know that code was run. If you don't see the message, this line wasn't run and neither was the code above it.
 
Looking at boarding outcomes next, I think. I would love if you could continue the game after falling during Boarding, but in a dinghy as if your ship was sunk.
It was captured by the enemy after all, but perhaps the captain showed mercy...
Look through "seadogs.c" for the function 'GameOver(string sName)'.

If I remember correctly, the old Sid Meier "Pirates!" had something like this. If you lost a fight, you could be ransomed by your crew, you'd continue the game, but it would drop the difficulty level by 1, which would probably affect your end score. That won't do much in PoTC, where difficulty level can be changed any time during the game. So perhaps remove some of your money, dump you in a friendly port, give you a dinghy, and maybe remove some XP.

(Personally I never used that feature of "Pirates!". If I lost a fight, I reloaded a savegame. Likewise, in PoTC, I never use land resurrection either, not least because it's liable to foul up whichever story I'm playing, so I'd need to reload a savegame anyway.)
 
(Personally I never used that feature of "Pirates!". If I lost a fight, I reloaded a savegame. Likewise, in PoTC, I never use land resurrection either, not least because it's liable to foul up whichever story I'm playing, so I'd need to reload a savegame anyway.)
Me too i have set the game settings so as to always die, but still it's an interesting idea that could be used by someone. ;)
 
Good evening,

I've spent some time the past two weeks trying to achieve continued playing after a failed boarding attempt, I think this should allow the option for playing without ever needing to reload due to game restrictions.
Started out with a toggle, but I think basing it on the survival chance should be enough, refraining from adding more toggles to internal settings.

After I identified to relevant pieces of code (I believe), I've got several options doing parts of what I was trying to achieve, but not one without issues.
So here I am again, frustrated as I seem unable to find out why exactly it behaves strangely.

The most workable solution so far was to use GameOverE, which has me ending up in a dinghy, but it behaves strangely.
I'm getting the lock to F1 as if I had died on land (telling me to wait for the tavern medics to leave) and at the same time I fail to clear the boarding scene.
I found the culprit not allowing me to go to the main menu, but I'm totally unable to tell where it is disabled again, NoSave.Resurrection == false and similiar attempts did not work for me either.
Code:
    if(CheckAttribute(GetMainCharacter(), "NoSave.Resurrection"):
    {
        LogIt(TranslateString("", "You can't save or load until") + " " + GetMyFullName(ResurrectingOfficiant) + " " + TranslateString("", "leaves."));
        return;
    }
But as far as I could tell, the boarding code is all over the place in several files and folders, same with land fights, it seems. I have gone through 30+ ´files and tried to find out how to clear the whole boarding scene properly, to no avail. Nothing I've tried seems to be the function which is responsible. Is anyone familiar with that system by any chance? I'm out of ideas where else to look/what else to try.
Or perhaps there is a chart displaying the logic behind the many files, where often several seem to address some aspect of the same functionality?

As it stands now, my change, while technically working, is totally not playable and without help I won't be able to get it working properly, but I suspect it's just a minor step to finalize.
I'm already able to direct sail, sail-to and use the worldmap, but once I enter land-mode, the previous boarding scene is placed over the actual environment, which blocks me from doing anything but fast-travel.
Here is GameOverE for your reference:
Code:
void GameOverE()
{
    ref mc = GetMainCharacter();
    if(rand(100) + (sti(mc.skill.Sneak)*3) > DEATHRATE)    // BF mar05
    {    //ccc new survival section
// KK
        if (HasSubStr(mc.ship.type, "Tartane") == true || mc.ship.type == "Gunboat") {
            GameOverOrg("sea");
            DeleteSeaEnvironment();
            return;
        }
// <-- KK
        Event("DoInfoShower","sl","MainMenuLaunch",true);    //TIH - black out the screen to hide uglyjunk
        LAi_SetCurHPMax(mc);
        mc.lost.ship.type = GetCharacterShipID(mc); // PB: So you can get her back if necessary
        GiveShip2Character(mc,SHIP_LIFEBOAT,"Lifeboat",-1,GetServedNation(),false,false);
// KK -->
        SetCharacterGoods(mc, GOOD_BALLS   , 0);
        SetCharacterGoods(mc, GOOD_GRAPES  , 0);
        SetCharacterGoods(mc, GOOD_KNIPPELS, 0);
        SetCharacterGoods(mc, GOOD_BOMBS   , 0);
        AddCharacterGoods(mc, GOOD_WHEAT   , 2);
        AddCharacterGoods(mc, GOOD_RUM     , 2);
// <-- KK
        mc.lifeboatlaunch = true;    //TIH - better check for when they sank
        Sea_ReloadStart();
        PostEvent("DoInfoShower",100,"s","");    //TIH - clears black screen
        PlaySound("#ship_sinking");        //ccc mar20 // KK
        Log_SetStringToLog(TranslateString("","You manage to launch a boat in the last moment."));    //ccc mar20
        Log_SetStringToLog(TranslateString("","With a few mates you escape from disaster."));    //ccc mar20
    } else {    //ccc call original GameOver function
        GameOverOrg("sea");
        DeleteSeaEnvironment();
        return;
    }
}

Also, attached the sea.c file and internal settings, I believe I didn't change anything else for more direct encounters to work.
 

Attachments

  • sea.c
    59.2 KB · Views: 218
  • InternalSettings.h
    70 KB · Views: 185
Back
Top