• 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 Increasing Companion Limit

I don’t think this can be done. Using Cheat Engine, I managed to track the memory address holding the value for the number of companions. It’s quite simple actually - take the current number of player ships at sea, search that number and then capture another. Search for the new number, sink the ship and search again. If there isn’t already only one address remaining, try again.

So I changed it to 5 and at the moment I got to the plunder screen next time around, the game crashed. This could be because I obviously didn’t have 5 ships, maybe there was a mismatch somewhere... but I’m more inclined to think that the hard code just does not support having more than 4.

I mean, it looks as though the problem with the boarding logic, so far as the scripts are concerned, is that transferCaptain causes all sorts of problems, specifically the game crashing to desktop upon saving and without any kind of error message (be it an operating system alert or log entries). This variable doesn’t even need boarding to be active to cause it, the game just won’t save, regardless.

I’ll try again tomorrow, like changing the value to something less than 5 but more than the companions I have - if that crashes it as well then it’s a mismatch with the real number of companions. Maybe I’ll see it to zero as well just to see if a kraken appears.
Now I can see why people gave up half way through. No grog, that’s why. :rumgone
 
Last edited:
Cheat Engine? Never heard of that.
Doesn't sound very safe.

Did you try already my suggestion to check the variables in that Assign Officers interface?
That is the only method that I know that would give you any answers.
 
Cheat Engine? Never heard of that. Doesn't sound very safe.
I wouldn’t call it safe either, it can quite possibly be rather dangerous. Generally speaking though, the worst that can happen is the game crashing, as it did in this case. It’s a great tool, though... I could do all sorts with it like freezing my money, number of sail cloths, etc. But it’s also great for debugging things like this.
Did you try already my suggestion to check the variables in that Assign Officers interface?
Nope, I’ll do that in a moment. :onya
 
Okay, so...

nMyCharacterCompanionPlace = -1
nCompanionIndex = 4

My ship stats don’t tell me anything useful, except that I killed Clint Eastwood.

The enemy I assume is “chr_ai”, and again I don’t see anything interesting.
 
nMyCharacterCompanionPlace = -1
Yep, that's what I suspected.
That means that the "InterfaceParam.i1" attribute doesn't get set correctly.
I'm not sure where that comes from, but I'd expect it to be set in "transfer_main.c" and then later used in "transfer_characters.c".

My ship stats don’t tell me anything useful, except that I killed Clint Eastwood.
Ship stats? What do you mean? :confused:
 
You can also call DumpAttributes on myCh and enemyCh to see what characters they are.
This gives me a bunch of info on my ship, but nothing for the enemy. I just went to the shipyard berthing and the “chr_ai” parameters still show, as does something about abordage, so I assume it has nothing at all to do with boarding a ship since I’m in the shipyard.

Okay, so in the berthing screen I now see a value of 1 for nMyCharacterCompanionPlace, but 141 (!) for nCompanionIndex. What’s that all about?

So it looks like the character’s unique ID or such.
 
Last edited:
his gives me a bunch of info on my ship
It should give ALL info for your CHARACTER. That does include your ship, but much, much more.

but nothing for the enemy
Are you using two DumpAttributes lines in sequence? If so, it can be quite hard to tell where your character ends and the next one begins.
Normally I use a Trace("====================="); line inbetween so I can see the difference.

Do you use Windowed game mode with Alt+Tab? Interface files are loaded when you open them, so you can make a change in the code,
execute it in the game, check compile.log, delete compile.log, edit the code again, execute it, etc. without closing and starting the game every time.

Okay, so in the berthing screen I now see a value of 1 for nMyCharacterCompanionPlace, but 141 (!) for nCompanionIndex. What’s that all about?
nCompanionIndex is then apparently the "index in the character array" that corresponds to that character.
While mostly you refer to characters by reference or ID, they actually all have a unique index value.
 
Yeah, I’m windowed and keeping the game running.

I’ve moved the trace to SelectPassenger() and looked at the “i” parameter, it still gives me the character ID. Also, after sinking a ship I now see a value of 3 for nMyCharacterCompanionPlace in that function, which clearly corresponds to the number of ships I have. I’m assuming that a value of -1 for the character means that the ship has no captain, so if I can’t physically move an officer over, which I can at the moment because I have a spare companion slot, then of course it will always read as -1. Right?

By the way, I’m not sure at the moment as to why, but I can tell you that I haven’t had a crash for quite some time when looting. I’ll have to check this out again later.

Well that’s interesting... I’ve just got to the cabin while having 4 ships and after claiming the captain as an officer, all I can see now is the sea - no ship, no ransack menu... just the sea. I can access the inventory and stuff, so the game hasn’t bailed.
 
I’ve moved the trace to SelectPassenger() and looked at the “i” parameter, it still gives me the character ID. Also, after sinking a ship I now see a value of 3 for nMyCharacterCompanionPlace in that function, which clearly corresponds to the number of ships I have. I’m assuming that a value of -1 for the character means that the ship has no captain, so if I can’t physically move an officer over, which I can at the moment because I have a spare companion slot, then of course it will always read as -1. Right?
I don't know what "nMyCharacterCompanionPlace == -1" actually means. I figure that is something to check if it is a companion of yours or not.

By the way, I’m not sure at the moment as to why, but I can tell you that I haven’t had a crash for quite some time when looting. I’ll have to check this out again later.
Did you make any changes related to your sail repairs suggestion? Or is it not crashing with the original Beta 4.0 code?
 
I don't know what "nMyCharacterCompanionPlace == -1" actually means. I figure that is something to check if it is a companion of yours or not.
That’s not the parameter which is -1, while boarding it tells me how many ships I have (so it can’t be less than 1). The character ID shows as -1, which is understandable if I don’t have a character in the officer slots, which is seemingly impossible if I already have four ships .
Did you make any changes related to your sail repairs suggestion? Or is it not crashing with the original Beta 4.0 code?
I need to take a look at it again, but I think I reverted most of the changes I made. I’m pretty sure the only two things I have in place at the moment are sail cloths prevented from being spawned in ship inventories and that line which I thought might be missing.
 
I’m tracing newCompanion in SelectPassenger() and whenever I click on an officer it logs the character ID. So it’s finding their IDs without a problem, it just bluntly refuses to move them across.
 
I’m tracing newCompanion in SelectPassenger() and whenever I click on an officer it logs the character ID. So it’s finding their IDs without a problem, it just bluntly refuses to move them across.
I don't think the problem is with the Passengers; the problem is with the "companion number".
It needs to somehow know if the new ship in your fleet is going to be the 2nd, 3rd or 4th.
That probably gets "fed" from somewhere else using the "InterfaceParam.i1" attribute.
 
Well since the number of companions ought be incremented whenever a ship is bought or captured, shouldn’t the code just see that the number is 4 and automatically decide that the next one is 5?
 
Well since the number of companions ought be incremented whenever a ship is bought or captured, shouldn’t the code just see that the number is 4 and automatically decide that the next one is 5?
Maybe; maybe not. I haven't a clue.
See if you can find that "InterfaceParam.i1" attribute (probably in "ransack_main.c" or "transfer_main.c") and see what it actually does and/or how it works.
Maybe there is a "cap" of 4 on it that you also have to change?
 
That’s just it, I can’t find anything which might relate to the companion limit. I’ve been tracking the companion number in Cheat Engine, I’ve been altering the memory values and it doesn’t make the slightest difference, even the log doesn’t change from stating that I have four ships after I force the memory to less than 4 (and remember it crashed yesterday when I changed it to 5, but not if I change it to less). It has to be hard-coded, unless and only unless it is something to do with the interface - it could be that even though the relevant ship interfaces are not up, such as the shipyard or berthing screens, it might still look at the interface code and see that there is no fifth slot... so it either prevents a fifth ship or otherwise it might crash. Even if we were to add more slots on the actual interface that doesn’t mean to say it will allow a fifth ship. I think I’ve tried everything, I’ll have another look at it later but since I’ve got a good save game running for boarding ships then I might as well look at the loot bug for the time being.
 
In transfer_characters.c, it only seems to reference it rather than set anything.

In ransack_main.c we have this, which is what enables the assign officers button...
Code:
   if(newCurNod!="")
   {
     SetCurrentNode(newCurNod);
   }
   else
   {
     RecalculateCargoLoad( xi_refCharacter );
     RecalculateCargoLoad( refEnemyCharacter );
     DeleteAttribute(xi_refCharacter,"InterfaceParam");
     for(i=1;i<COMPANION_MAX;i++)
     {
       if(GetCompanionIndex(xi_refCharacter,i)==-1)
       {
         pCharacter.InterfaceParam.i1 = i;
         break;
       }
     }
   }
Since I’ve already defined the maximum companions and it allows me to get to the next screen, I can’t see where the problem is.
 
Indeed that code does what I was imagining: It cycles through all your companions until it finds an empty slot.
Then it stores the number of that "empty slot" on "InterfaceParam.i1" so it can be used later in the "Assign officers" interface.

Refer again to this section of code:
Code:
void InitInterface_RR(string iniName,ref myCh,ref enemyCh)
{
  MainChar = GetMainCharacter();  // added after build 11 by KAM

  int i;

  refMyCharacter = myCh;
  refEnemyCharacter = enemyCh;
  nMyCharacterCompanionPlace = -1;
  if(CheckAttribute(myCh,"InterfaceParam.i1")) {
  nMyCharacterCompanionPlace = sti(myCh.InterfaceParam.i1);
  } else {
  interfaceResultCommand = RC_INTERFACE_TRANSFER_MAIN_RETURN;
  EndCancelInterface(true);
  return;
  }
//  GameInterface.title = "titleTransferCharacters";
  GameInterface.title = "titleAssignOfficers";

  nCompanionIndex = GetCompanionIndex(refMyCharacter,nMyCharacterCompanionPlace);
If you don't have the "InterfaceParam.i1" attribute at all, then loading the interface is cancelled.
The fact that the interface opens means that you do have that attribute.

However, that attribute is used to set nMyCharacterCompanionPlace which you have seen is actually -1, which should not happen.

You should add plenty Trace lines to that section in ransack_main.c to double-check exactly what it does and what the values of the variables are.
 
Well, if I have less than four ships and go to assign an officer, it still says -1. I assume this is because there is no officer in the first slot. Nobody has been selected, so I expect it is supposed to say -1 until the player actually moves an officer over. Failing that, why does the ship sink if nobody is assigned by the player? I guess ships are sunk when that value is -1, right? But since I’ve set the maximum companions to 5, then I expect it to cycle through 4 of them and then assign that value as 5.

Is it possible to reinitialise the scripts whilst at the ransack screen? Seemingly I can’t enforce the changes without reloading.
 
Back
Top