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

WIP Unique Ship/Captain Encounters

The only case where I’ve done that is the Flying Dutchman because it has 100k hull, but I suppose your idea would work there.

The others haven’t been altered at all except for the chance of encounter.
 
The others haven’t been altered at all except for the chance of encounter.
So you have identical copies of ships_init.c entries where only the encounter chance is different?
Since you probably only want a single one of them to appear anyway, I think the character init option might serve quite well.
Then by definition there is only one. :cheeky
 
No, no... only the Flying Dutchman has been duplicated. For the others, I just flipped the encounter bool and added the nations and periods - other than that they are completely unchanged. So then it’s just a matter of preventing multiple instances of them.
 
Is it possible to spawn a ship next to me? I’m doing this at the console...

Force_GetShipType(1,1,"war",ENGLAND)

All I see is a compile.log entry telling me about HMS Victory, but no ship. :unsure
 
That function just finds a ship ID, but doesn't do anything with it.
Try the function at the top of quests_common.c .
 
I have a somewhat primitive but effective method in place. It’s still modifying the random captains but I hope to find a more permanent solution in due course. For what it’s worth though, this actually works remarkably well. The only real test at the moment is how likely they are to be generated as per their class, since pirates don’t tend to show up in big ships.

Code:
[SEA_AI\AIFantom.c]

int Fantom_GetShipType(...)
{
   ...
   for (i=0; i<SHIP_TYPES_QUANTITY; i++)
   {
     ...
     /* Unique Ship and Character Encounters - by Mere Mortal */
     // <!-- START
     if (CheckAttribute(rShip,"unique")) {
       // Check if the ship has already been generated...
       if (CheckAttribute(rShip,"exists")) {
         if (rShip.exists == true) {
           // If so, then check the character...
           if (CheckAttribute(rShip,"curChar")) {
             ref rChar = CharacterFromID(rShip.curChar)
             // If he's dead, well then he stays dead...
             if (CheckAttribute(rChar,"killer")) {
               continue
             }
             else { // Otherwise respawn the ship...
               DeleteAttribute(rShip,"curChar")
               rShip.exists = false
             }
           }
         }
       }
       else {
         rShip.exists = false
       }
       // Catch multiple attempts to spawn the same ship...
       if (rShip.exists == true) {
         continue
       }
       // Since this was called and it hasn't bailed yet...
       rShip.exists = true
     }
     // END -->
     ...
}

void Fantom_SetRandomModel(...)
{
   ...
   /* Unique Ships and Captains - by Mere Mortal */
   #include "_Unique.c"
   GenerateUniqueCharacter(rFantom)
}
Also this console function to check up on it...
Code:
   string ShipName = "Black Pearl"
   ref rShip = GetShipByID("BlackPearl")
   if (CheckAttribute(rShip,"oldChar")) {
     if (CheckAttribute(rShip,"exists")) {
       if (rShip.exists == true) {
         if (CheckAttribute(rShip,"curChar")) {
           char = CharacterFromID(rShip.curChar)
           if (CheckAttribute(char,"killer")) {
             LogIt(ShipName+" is with Davy Jones now!")
           }
           else {
             LogIt(ShipName+" is lurking!")
           }
         }
         else {
           LogIt("ERROR: No character set, this shouldn't happen!")
         }
       }
     }
     else {
       LogIt("ERROR: Flag not set, this shouldn't happen!")
     }
   }
   else {
     LogIt(ShipName+" has not yet been encountered!")
   }

seadogs2_0000.tga.jpg seadogs2_0002.tga.jpg
 
Last edited:
The only real test at the moment is how likely the ships are to be generated as per their class, since pirates don’t tend to show up in big ships.
There is indeed code in place to prevent random pirates ever using ships of Tier 3 and higher.
Only specific quest character pirates should be able to have larger ships.
 
Going by the class of the unique ships in the init file, they go up as far as tier 4... but I guess that doesn’t really mean anything since it changes in-game. I’ve had to wrangle a few attributes to allow them to be encountered on a regular basis, and it will be pretty tough testing this properly to see how reliably they do appear. What I’d like to see is a reasonable chance for all of them to be encountered over a 10-year period - maybe the likelihood can be increased as time goes by (hey, maybe as the player’s fame increases it can be as if these famous captains are looking for them, and maybe fame can eventually be tied into this). I really believe that something like this can add a decent amount of re-playability to the game, it would give players something else to do and achieve.
 
Which ships are intended to now appear as random encounters? Hopefully not fantasy ships like Black Pearl or Flying Dutchman - Hornblower shouldn't see those, and for preference neither should free-play characters based on people from real history such as Francis Drake. I'd also like the "Ardent" storyline to remain free of supernatural encounters. Also, some ships are unique because they're supposed to be specific to their own storylines or side quests - the Satanist frigate and Satanist fluyt of war are supposed to be specific to the "Strange Things Going On" side quest, and "PiratBattleGalleon" is supposed to be specific to the "Bartolomeu" storyline (Bartolomeu captures a regular "SP_BattleGalleon" and then repaints and customises it).

What might make sense is to ignore the unique ships but randomly generate a high level enemy captain assigned to a more powerful regular ship than normal, then have him encounter you. Sid Meier's "Pirates" did something along these lines - you could run into a war galleon commanded by a pirate hunter.
 
Whether or not changes like these will be put into the mod is one thing of course, and nobody has suggested it, but even then it won’t stop me from revitalising the entire encounter logic if only for my own amusement. Besides, this is the sort of thing which could, if I put enough work into it and have a stable end-product, go onto ModDB as an add-on. I personally feel that the lack of open-play encounters with famous names, be they historical or fictional, is something which lets this game down.
 
Last edited:
Which ships are intended to now appear as random encounters? Hopefully not fantasy ships like Black Pearl or Flying Dutchman - Hornblower shouldn't see those, and for preference neither should free-play characters based on people from real history such as Francis Drake. I'd also like the "Ardent" storyline to remain free of supernatural encounters. Also, some ships are unique because they're supposed to be specific to their own storylines or side quests - the Satanist frigate and Satanist fluyt of war are supposed to be specific to the "Strange Things Going On" side quest, and "PiratBattleGalleon" is supposed to be specific to the "Bartolomeu" storyline (Bartolomeu captures a regular "SP_BattleGalleon" and then repaints and customises it).
I think the characters are pretty much supposed to be pre-defined.

Probably some period limitations need to be in place, as well as an option within certain storylines to disable them altogether.
This would probably only really belong in the Free Play storyline and not really any of the others.

Also a check if the "famous character" has the same name as the player character.
Would be weird encountering "yourself".

Whether or not changes like these will be put into the mod is one thing of course, and nobody has suggested it
@Bartolomu o Portugues suggested it here: Planned Feature - Large Ships for Rival Pirates | PiratesAhoy!
Also potentially related: Feature Request - Treasure Fleet Sidequest | PiratesAhoy!

If this is just purely graphical, then for me it doesn't hold so much interest.
But I definitely think there is potential to this, especially if it becomes closer to the "rival pirates" from Sid Meier's Pirates!
When it actually becomes an integrated gameplay element, possible with "rumours" about where to find these famous characters, it could be very cool.

Besides, this is the sort of thing which could, if I put enough work into it and have a stable end-product, go onto ModDB as an add-on.
We've had "code and model addons" in the past, but not anymore.
I hate those, because it is a royal pain to keep anything not in the main mod compatible with subsequent updates.
I much prefer including everything, optionally with toggles if desired.
 
with "rumours" about where to find these famous characters, it could be very cool
This is something I’ve thought about. How could this be applied? Suppose the rumour speaks of Jamaica, then can the chance of encounter be increased while within a certain range of the island and a specific time limit?
I much prefer including everything, optionally with toggles if desired.
I would prefer that to be honest. Actually, what I’m going to do for now is replace some of the unique encounter flags with a define which can be flipped in the settings file, then I’ll look to see if this can be overridden outside of free-play (so if a story mode is active, the setting is always false). I reckon there’d be too much room for conflict if these unique ships could spawn where they are relevant to a quest, so it’s a wise idea.

Bear in mind I’m already using the unique attribute as a flag to prevent more than more occurrence so it’s kind of integrating well all by itself. I’ll also duplicate characters who are already defined so that they are not the same as the quest ones, and Blackbeard is an example so far.
 
Last edited:
This is something I’ve thought about. How could this be applied? Suppose the rumour speaks of Jamaica, then can the chance of encounter be increased while within a certain range of the island and a specific time limit?
I'm sure it's possible somehow. Not sure it would be easy though.
There are two methods you could use: The citizen rumours (shown in dialog) and the Tavern News.
Citizen rumours do have a "chance" value and can be limited to specific islands, but they are defined at the start of the game and not dynamic.
The Tavern News on the other hand IS dynamic, so that might be easier to work with.
At the moment that news isn't location-specific though.

Actually, what I’m going to do for now is replace some of the unique encounter flags with a define which can flipped in the settings file, then I’ll look to see if this can be overridden outside of free-play (so if a story mode is active, the setting is always false).
There if you look in PROGRAM\Storyline at the bottom of the .c files there, you can see there are variables that can be enabled/disabled per storyline.
You could use that instead of a #define.

Only issue you might run into is that ships_init.c may be initialized PRIOR to the storyline being started.
I think this may not actually be a problem for you, because it should be RE-initialized when the storyline is started.
But it'd be worth checking on.

I’ll also duplicate characters who are already defined so that they are not the same as the quest ones, and Blackbeard is an example so far.
Blackbeard does indeed always exist, but that is more of an Easter Egg than anything else (simply to put him to use SOMEWHERE).
I think if you can get Blackbeard to randomly sail around in the Queen Anne's Revenge, probably that Easter Egg can be moved to actually ON the ship.
Then he'd only need to be on his beach if your mod is disabled. Either way, there would only be one of them. :cheeky
 
The main purpose of the define is to allow the unique ships to be toggled at a whim. Really, any ship which has unique defined should be easily checked by the story handlers and prevented from being spawned at all, regardless of that setting.

One thing I do have in mind about existing characters is dialogue... naturally we wouldn’t want a quest being activated and maybe the player teleporting some place just by meeting them after boarding their ship. That reminds me, another thing I thought about is to force these characters to never surrender, so the player must fight them to take their ship and cannot possibly use them as an officer (maybe with exceptions, I do kind of like the idea of Jack Sparrow being recruitable).
 
This is beginning to sound more and more like the characters themselves should be defined in the character init files.
Then depending on the storyline, some could be disabled.

Plus if the IDs are identical, the storyline one always overrides the generic one. So that would be automatically covered as well.

You can then also defined per character if he/she can surrender or not.
And custom dialog files would be possible as well.

Seems potentially like a much simpler solution to me.

The only thing that needs to be controlled is what is done with those pre-defined characters. Specifically how and when they can be encountered.
But definitely having them as regular characters does give maximum control.
 
I’ve actually already done them to a basic extent, I assume CommonQuest.c is the correct place anyhow.

Is Fantom_AddFantomCharacter() where I need to be looking to get them into their ships?
 
You can use CommonQuest.c or even make a brand new file of your own.

I think you have two options: Append them to the worldmap encounters or handle them completely independently.
The second option might be more flexible. You could then control their appearance through quest coding.
Or.... have it linked to the random events that go in the Tavern News. ;)
 
For dialogue-generated encounter I think I’ll leave that for now, best to get something worthwhile in place as a foundation for the time being. Since I have a stable method in place which simply modifies the existing random captain, I guess I’m good to move to the next step and I think that is to actually get the new characters to be used at the world map.

So far as the rumours go, would the only option there to be creating them as coastal traffic?
 
What I would imagine:
- Rumour is triggered that a certain famous character is at a certain Island.
- This rumour is valid for 7 days.
- The ship is moved to that Island, so if you visit, you'll get the encounter.
- You see this rumour in the Tavern News.
- After 7 days, the ship is moved to nowhere again

There is a random chance each day for one of these events to be triggered.
Which ship is triggered would also be random.
If you use sequential numbered character IDs, finding a random one should be quite easy.

Does that sound like something that could serve as a start?
 
Well first of all I’d need to look at existing code and get my head around it. I’m thinking about how governors can give orders to attack an enemy which is lurking about the coast, this could probably work as a base for now.
 
Back
Top