• 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 ship renaming is actually working, and not only that but my new ships are being spawned! :woot

Here’s one of the 32-gunners ready for a broadside...

Untitled.jpg

It might be Spanish there, but it’s just to get them spawned for testing. That ship is this one...

 
Last edited:
That's cool!

Bit how she's Spanish? There is plenty code in place to prevent ships from showing up for the wrong nations.
 
Okay, so how do these numbers work?
Code:
   refShip.period.0   = 0
   refShip.period.1   = 0
   refShip.period.2   = 0
   refShip.period.3   = 0
   refShip.period.4   = 0.6
   refShip.period.5   = 0.2

   refShip.england    = 0.5
   refShip.france     = 0
   refShip.holland    = 0
   refShip.portugal   = 0
   refShip.pirate     = 0
   refShip.spain      = 0
   refShip.america    = 0
I guess they’re essentially percent, but why twice? Does this mean the final value in period 4 is 30%?
 
The game randomly tries to find a ship within certain class limits.
As an extra random element, the period and nation encounter chances are checked against random number between 0 and 1.
So indeed that ship would have a 70% lower chance to appear in the game for England than she would if both values were 1.0.
See the Force Get Ship Type function in Ships.c for the actual function that handles it.
 
Ah, got it. I suppose the 5th and 6th frigates would be more common than that.

I’m looking at HMS Victory right now and that one would obviously need to be set quite low.

So basically, I could just set England to 100% but the period as 0.1 to give a 10% chance, right?

Also... the captain names are being changed as well using the same logic. :cheeky

There’s some dead guy on the floor in “my” cabin called “Sir Charles Thompson”. :rolleyes:
 
Last edited:
I think the chance values are a bit difficult to understand.
They're relative to their encounter chances if that extra period/nation limitation was not in there.
So they are not absolute chance values.
If there are a lot of ships fitting the same criteria, then each of those ships automatically gets a lower chance of showing up.
 
Okay, so I’m not getting a captain at all now. I get to the cabin on the Black Pearl on nobody is there. :unsure

This is the code I’m currently using...
Code:
void SetRandomNameToShip(ref rCharacter)
{
   ...
   if (rShiptype == "BlackPearl") {
     rCharacter.Name      = "Hector Barbossa"
     rCharacter.id        = "Barbossa"
     rCharacter.model     = "Barbossa"
     rCharacter.nation    = PIRATE
     rCharacter.FaceId    = 78
     rCharacter.Flags.Personal   = 2
     rCharacter.Flags.Pirate     = 0
   }
   ...
This does affect his name (like with Nelson in his cabin, but with a different model) and sails, but seemingly the model is done wrong.
 
Right then, I have managed to get Barbossa in his cabin. :napoleon

seadogs2_0000.tga.jpg

I assume this will work fine with one Lord Nelson as well.

I’ve moved the code out of ships.c to the very bottom of AIFantom.c and this is what I have so far...
Code:
void Fantom_SetRandomModel(ref rFantom, string sFantomType)
{
   ...

   bool override = false

   //int iShip = GetCharacterShipType(rFantom)
   //ref rShip = GetShipByType(iShip)

   if (rFantom.Ship.Type == "BlackPearl") {
     override = true
     rFantom.Ship.Name  = "Black Pearl"
     rFantom.Name       = "Hector"
     rFantom.LastName   = "Barbossa"
     rFantom.ID         = "Barbossa"
     rFantom.Model      = "Barbossa"
     rFantom.Nation     = PIRATE
     rFantom.FaceId     = 78
     rFantom.Flags.Personal = 2
     rFantom.Flags.Pirate   = 0
     SetModelfromArray(rFantom,GetModelIndex("Barbossa"))
   }
   if (rFantom.Ship.Type == "HMS_Victory") {
     override = true
     rFantom.Ship.Name  = "Victory"
     rFantom.Name       = "Horatio"
     rFantom.LastName   = "Nelson"
     rFantom.ID         = "Cpnnelson"
     rFantom.Model      = "Cpnnelson"
     rFantom.Nation     = ENGLAND
     rFantom.FaceId     = 103
     rFantom.Flags.Personal  = 20

     SetModelfromArray(rFantom,GetModelIndex("Cpnnelson"))
   }

   // Original function...
   if (override == false) {
     string mAni = Models[GetModelIndex(sModel)].ani;
     string mSex = Models[GetModelIndex(sModel)].sex;
     float mHeight = stf(Models[GetModelIndex(sModel)].height);
     SetModel(&rFantom, sModel, mAni, mSex, mHeight, false);
   }
}
What I’d ideally like to achieve is to create a new file altogether which has a comprehensive list of unique characters. That way I could possibly go so far as to applying individual skills to them as well. Then it’s just a simple case of getting the above function to check the file first to see if the ship has a unique captain assigned to it.

Doing it this way might also mean I don’t have to worry about applying any attributes in ship init.
 
Last edited:
You're going to get awfully close to just defining those ships with their captains in the regular character init files.
Then you'll have full control and by definition there will be only one of them.
Only question you need to figure out then is where to make them appear?

Actually, this might work together with an idea @Bartolomeu o Portugues once had: to make a "fake multiplayer" with famous characters active in the Caribbean who you can encounter.
They might be rival Pirates, such as in Sid Meier's Pirates!, but why not also respectable navy officers?

Might be fun if they actually go about their own business and you can team up or get into a "nemesis" situation or just compare scores as you progress.
 
Sid Meier’s is actually something which came to mind while I was doing this. I don’t really want to think too much about the possibilities this could open up, I’m way too liable to losing attention to one thing and switching to another - as you’ve probably noticed. xD

Do characters like Barbossa already have a character set-up? I mean, there’s the default model which I have already applied, there is the storyline option and there may be some dialogue floating around... but is there actually such a character coded anywhere?
 
Barbossa exists in the character init files for the Standard and Jack Sparrow storylines.
 
Ah, well I guess they work somewhat differently to creating an NPC.

Anyway, I think I’ve triggered some kind of “problem”. By changing an existing NPC’s ID, the game now cannot seem to find somebody and is regularly crashing when I go to sea or dock at port. I’ve narrowed down the problem to a particular function...
Code:
void SetCoastTraffic(string islandstr)
{
   ...
      ref cr = CharacterFromID(chrstr + (i+j));
      ...
      bool bDead = CharacterIsDead(cr);
This guy just don’t exist. :boom:Well if he does then he’s probably in Victory’s cabin. :wp

So yeah, I couldn’t launch my boats without it crashing. Then I did this...
Code:
bool bDead;
if (CheckAttribute(cr, "index")) {
  bDead = CharacterIsDead(cr);
}
else {
  bDead = true;
}
It shouldn’t be necessary, but I’m actually going to leave that as it is because it stops a crash.

My error log is completely littered, I have to create the characters anew and boot the original captain out.
 
That’s what I was doing to get these guys spawned in their ships. Maybe I don’t need to do that, I dunno.

I think I need to make new characters and forcibly replace the captain.
 
That’s what I was doing to get these guys spawned in their ships. Maybe I don’t need to do that, I dunno.
I can't really think of any situations where you need to change the ID.

I think I need to make new characters and forcibly replace the captain.
Simplest would be to just define your entire characters with their ships and character stats and maybe even ship stats in the character init files.

Main question is: How and when would you then encounter them?
Maybe for starters a random chance that such a "famous character" gets appended to a randomly encountered WorldMap fleet?
Note my suggestion of appending rather than replacing. I suspect appending might be simpler.
 
To clarify, the way I’m doing it at the moment is like this...

For HMS Victory, Black Pearl, Flying Dutchman, Queen Anne’s Revenge and a few others, I have changed CanEncounter to true. At the moment they all have a temporary 10% chance of being spawned if the ship class requirement is fulfilled.

When one of them is spawned, the captain’s attributes are forcibly changed to match with the proper character. That’s all fine and dandy of course, until the game starts looking for the guy who used to be there... and can’t find him.

So far as the encounters go, I’m happy enough with how that is at the moment. I could look at how they are generated, like adding them to an existing encounter or just using them as a default part of one, but right now I’m concerned with sorting the captains out. I don’t see why I would need to do anything about the attributes outside of ships_init since the above ships are already defined and there would be nothing to change.
 
I don’t see why I would need to do anything about the attributes outside of ships_init since the above ships are already defined and there would be nothing to change.
I was thinking more along the lines that if you define the character with ship stats in the character init files, you may not need to define a whole new ship.
 
Back
Top