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

Fixed Promotion ships

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
When you get promoted to a certain rank, you're supposed to get a promotion ship. If you already have a full set of four, you're supposed to get a message that your fleet is already impressive and you won't need it.

Having just been promoted to Post Captain, I got that message despite only having two ships in my fleet, both tier 5. One is admittedly quite impressive, being the super-xebec I got at the start of the "Assassin" storyline. The other is the pirate ship I'd just captured which earned me the promotion. The message even appears if I sell the pirate ship before reporting to the governor so that I only have my own ship.

Attached is a savegame on the pier of Port Royale just after capturing the pirate ship. This is from Beta 3.3 from 9th November.
 

Attachments

  • -=Player=- Jamaica.zip
    959.1 KB · Views: 82
Yeah, methinks the only way you can get the reward ship is to berth your ship and buy a tartane, then visit the Governor. I always have a 3 ship fleet by then so don't bother.
 
This will need checking. You're supposed to get the ship as long as you have one single slot available in your fleet.

Out of curiosity, @Grey Roger: Did you have 4 ships in the past but not anymore? Or did you never have 4 in that game?
 
Yes, I have had 4 ships in the past, the most recent being when I went to capture La Couronne and bagged both its escorts as well. But when I entered Port Royale this time, I only had my own ship. (I hadn't bothered looking for prey because I was in a bit of a hurry, having just put your fix for crew morale into place, and Port Royale was the nearest place where I know how to find the loanshark. :D)

But it occurs to me that this happened right after the Odd error while pirate-hunting bug. It's probably unrelated, but that's why I have put a copy of the report into Bug Tracker as requested.

Where is the code which checks how many ships you have and gives the message about an impressivc fleet if you have all four slots filled?
 
That is in PROGRAM\NK.c .

I'm wondering if somehow the game doesn't quite understand if you downsize your fleet again.
Anyway, we'll check. :doff
 
Don't know by the top of my head. It is a general game function. Maybe the Characters folder or utils file somewhere.
If you can't find it, let me know and I'll have a look when I get home again.
 
Fixed it

it had this check:
Code:
if (GetCompanionIndex(pchar,1) != -1 && GetCompanionIndex(pchar,2) != -1 && GetCompanionIndex(pchar,3) != -1)
which check if ALL ship slots are free, while it should check if only one is free so it had to be changed too:
Code:
if (GetCompanionIndex(pchar,1) != -1 || GetCompanionIndex(pchar,2) != -1 || GetCompanionIndex(pchar,3) != -1)

I believe I changed all instances in the file but might pop up somewhere else also, if you want to can check the files more secure to see.
But placing this file in your PROGRAM folder should solve it (mind this is NK.c from the newest version so it might conflict with your version, dunno if anything changed between the last update in NK.c)

Better version
 
Last edited:
I thought I copied that line from some stock game code in the standard storyline quests_reaction.c .

The old code looks good though? -1 is empty so if one is empty, that line should return true.
Does the new version not work out as checking if you have at least one companion ship?
Or am I misunderstanding it?
 
I thought I copied that line from some stock game code in the standard storyline quests_reaction.c .

The old code looks good though? -1 is empty so if one is empty, that line should return true.
Does the new version not work out as checking if you have at least one companion ship?
Or am I misunderstanding it?
it now checks if there is an empty ship slot. If you have anywhere between 1 and 3 ships you will get it. That's how its suppost to be right?
 
What exactly does "GetCompanionIndex" do? Judging by its appearance a couple of other times in "Nk.c" not related to promotion rewards, I'm guessing it returns a value pointing to an officer in command of a prize ship. Does it return -1 if there is no officer because you have no prize ship in that slot? (This is why I wanted to know where it is defined, so I can try to figure out when or if it returns -1.)

If it does return -1 for an empty slot then the original code is exactly wrong, it ought to try to give you a promotion ship if all slots do not return -1, i.e. they're all full. Levis' new one ought to give you a promotion ship if any slot does not return -1, i.e. if any is full. Should not the code be:
Code:
if (GetCompanionIndex(pchar,1) == -1 || GetCompanionIndex(pchar,2) == -1 || GetCompanionIndex(pchar,3) == -1)
That is, if any of them does return -1 then it will give you a promotion ship.

Or is my knowledge of programming even worse than I thought, which would be pretty difficult but perhaps not impossible? :D
 
Last edited:
I sugest looking at INTERFACE/ship.c

and look for the function to fill fourimages. that helped me to understand it.
 
The function is defined in PROGRAM\Characters\CharacterUtilite.c:
Code:
int GetCompanionIndex(ref _refCharacter,int _CompanionNum)
{
   if(_CompanionNum<0) return -1;
   if(_CompanionNum>3) return -1;
   if(_CompanionNum==0)
   {
     if(CheckAttribute(_refCharacter,"index")) return sti(_refCharacter.index);
   }

   string compName = "id"+_CompanionNum;
   if(!CheckAttribute(_refCharacter,"Fellows.Companions."+compName)) return -1;
   return sti(_refCharacter.Fellows.Companions.(compName));
}

And I think @Grey Roger has it right. Looking at it now, his suggestion does make sense.
We should try that and see if it makes more sense that way. :yes
 
Yes indeed thats better cause mine would fail if all slots are filled I think.
 
Alright, try this one... It should have my version of the condition line in the promotion sections for Britain, Holland, France, Spain, Portugal, America and Pirate.

If it's wrong, anyone who wants to edit it should take note: each nation has its own promotion section and they all need to be changed, otherwise your modification will only work for whichever nation(s) you found. The previous fix, for example, only works for Britain. ;)
 

Attachments

  • NK.zip
    17.7 KB · Views: 81
as far as I know I fixed it for most countries, I just searched for the specific piece of code and replaced it everywhere it was found. guess for 2 nations it was slightly different cause I got 5 results if I remember right.
In my defense it was late and I had to go :p.
 
I did a search-and-replace in my own game version already and caught 7 of them. Will check again next time I post a new update. :doff
 
This was marked "Fixed" and moved to the archive although nobody had reported testing the new code. While I appreciate the confidence in my programming, I do not share it. xD So I have now tested it myself.

The first time I tried to collect a promotion, I got the usual message about not needing a promotion ship.

This was expected. Starting from the savegame I posted, I put to sea and helped myself to two more ships, then I returned to Port Royale and saved game just outside the governor's residence. So when I went to collect the promotion, I had a full set of 4 ships. It's supposed to give the message!
Then I reloaded the savegame, sold one of the ships, went again to collect the promotion, and this time was rewarded for services to King and Build Mod with a shiny new Poseidon. :bounce

To make the test complete and conclusive, I repeated this twice more, reloading the savegame and selling a different ship each time, to make sure it detected each of the three companion slots. It did. Of course, this only tests promotions from England, but since I put the same code into the sections which handle each of the other nations' promotions, they ought to work too.

Which means as far as I'm concerned, this bug is well and truly squashed. :beer:
 
I knew it would work cause I tested it already with my code and I just overlooked something which you cuahgt. so I felt confident enough to call it would work :p.
 
Back
Top