• 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

That’s one problem I have is that I don’t know where GetCompanionIndex is initially defined. I’ve ran a search for the variable, I have a lovely list now of something like 50 files.
Searching for "GetCompanionIndex" will turn up every place where it's called. But if it's returning an index then it's probably an integer function, so search for "int GetCompanionIndex" (include the quote marks so it searches for that exact phrase). For me, that turns up "PROGRAM\Characters\CharacterUtilite.c". A quick check shows that the definition is indeed in there.
 
That’s definitely the file I need to be looking at, I’ve just changed a lot of stuff in it. It’s messy, though... some of these functions, as I said, have nothing to do with the number of ships and more to do with officers, which technically can probably also exceed 3 but there is no way I’m even thinking about that because I’m having a hard enough time with their oversized hit-boxes as it is.
 
That’s one problem I have is that I don’t know where GetCompanionIndex is initially defined.
I think it is PROGRAM\Characters\CharacterUtilite.c .

The Windows Search Index + Notepad++ method from here should allow you to find it as well:
Tutorial - Modding Tips & Tricks | PiratesAhoy!

Interestingly enough, LogInterface.c is already using “COMPANION_MAX” in one place, but then proceeds to use “4” afterwards.
I think somebody once started doing what you do now, but never finished.
So it's a bit "half done". :facepalm

Another thing I need to think about is that some of these functions could be referring to the amount of officer slots, not companions.
Indeed some of the "loops through 4" can relate to officers, while others are for companions.
So a simple search-and-replace wouldn't work, I'm afraid....

some of these functions, as I said, have nothing to do with the number of ships and more to do with officers, which technically can probably also exceed 3 but there is no way I’m even thinking about that because I’m having a hard enough time with their oversized hit-boxes as it is.
"Shore Party" officers can never exceed 4 for the same reason as ships: The interface was made for only 4.
However, you can have far more actual officers as "Passengers". They still do their jobs that way, but don't follow you around.
 
The Windows Search Index + Notepad++ method from here should allow you to find it as well:
Tutorial - Modding Tips & Tricks | PiratesAhoy!
Yep, I’ve only just started using Notepad++ and I really like it. I used to use HTML Kit for programming but this is much better.
I think somebody once started doing what you do now, but never finished.
That explains why I keep seeing it now that I’m looking through the files.
Indeed some of the "loops through 4" can relate to officers, while others are for companions.
So a simple search-and-replace wouldn't work, I'm afraid....
I’ve probably got it wrong in a few places, but I’ve been keeping a careful eye on this.
"Shore Party" officers can never exceed 4 for the same reason as ships: The interface was made for only 4.
Well, I’m thinking that additional officers could easily be assigned to follow me around, just like having more ships... I just wouldn’t be able to manage them properly with the existing interface. Besides, I’m beginning to get really annoyed with the hit-boxes, they need scaling down because they often get stuck trying to get past me, other crew members or even the enemy, particularly when using ramps while boarding. Increasing the number of officers would only make this much worse.

Anyway, I’ve now changed 12 files to reference COMPANION_MAX. I didn’t think about it at first, but now I realise that this is relevant to all sorts of stuff, like for example if I hoist my flag then each companion must do the same. In any case, I still cannot move them into the slots on a captured ship.
 
Well, I’m thinking that additional officers could easily be assigned to follow me around, just like having more ships... I just wouldn’t be able to manage them properly with the existing interface.
I think four officers on shore is quite enough. If you want more, just tell some crewmembers to follow you as well.
That feature already exists. :cheeky

Besides, I’m beginning to get really annoyed with the hit-boxes, they need scaling down because they often get stuck trying to get past me, other crew members or even the enemy, particularly when using ramps while boarding. Increasing the number of officers would only make this much worse.
Eventually I would want to see the player and enemy crews to start each on their own side, with the player IN FRONT.
I don't imagine the character hitboxes can be changed, but at least when you are in front, then at least you don't accidentally get stuck.

Sidestep can help to get through "character blockades" though.
 
Honestly, if it wasn’t for the side-step then I probably wouldn’t even bother playing.

Oh, and seemingly the cabin trick is working. Well, except that they keep on boarding me so I still have to fight.

By the way, why has Nathaniel become a skeleton? Is it that weird Aztec coin? :8q
 
Honestly, if it wasn’t for the side-step then I probably wouldn’t even bother playing.
I like that feature quite a bit.
Though because people complained too much about the imperfections (Yes, we KNOW you can go through the walls!), we decided to disable it by default. :wp

By the way, why has Nathaniel become a skeleton? Is it that weird Aztec coin? :8q
At nighttime? Yep, that can happen. That is a PotC film feature we added.
 
I like walking through walls, especially if I’m a skeleton. ;) So does he actually do anything different or is it just aesthetic? Does he scare people and make them surrender quicker? Does he smell bad, worse than Davy Jones?

Right then, these are the files I’ve changed. Some of them might have other random edits going on, but all that’s relevant is where I’ve inserted “COMPANION_MAX”. What am I missing here? None of this has let me transfer an officer over, I’m starting to think it’s hard-coded.
 

Attachments

  • Files.zip
    204.9 KB · Views: 128
I like walking through walls, especially if I’m a skeleton. ;) So does he actually do anything different or is it just aesthetic? Does he scare people and make them surrender quicker? Does he smell bad, worse than Davy Jones?
I'm feeling lazy, so I just quote Build Info.txt: :cheeky
Code:
  . Elaborate Curse of Cortez functionality added for Aztec Coins by Pieter Boelen
  > The chest in the cave on Isla de Muerta is filled with Aztec Coins
  > Aztec Coins turn you into a skeleton when outside at night, that is hated by all
  You get additional HP for this, but only WHILE you are a skeleton
  > Aztec Coins can be given to officers/crew or placed in all your ships' weaponslockers
  If placed in the Weaponslocker, they are used by boarders and decrease crew damage during sea battles
  > Food and Rum consumption decreases for each crewmember cursed, but morale decreases too
  > Aztec Coins can be sold; however, they WILL keep counting for the extent of the curse
  > After a while of being cursed, your ship will get torn sails and start trailing fog
  > The curse can only be lifted by placing 882 coins back in the chest on Isla de Muerta
  Careful with losing those coins! If you can't collect 882 again, you're stuck with the curse!
  There is ONE place other than the chest on Isla de Muerta where ONE additional coin can be acquired if you are in dire need of it. Guess where!

What am I missing here? None of this has let me transfer an officer over, I’m starting to think it’s hard-coded.
I'm afraid I don't know. My recommendation when in doubt: Add Trace lines to see what is going on and how far it does get.
 
@Mere_Mortal: I merged your changes with my own game version, resulting in the attached files.
There are some of your lines that I didn't include, because I think those relate to officers and not companions.
This applies especially to the entirety of transfer_characters.c, because the "four images" there should relate to your officer slots.

Not sure if this solves your problem, but hopefully it helps at least a little bit. :doff

I assume you have something like WinMerge to see what changes I made?
 

Attachments

  • Files_PB.zip
    205.1 KB · Views: 137
Me either, I think maybe it’s that Aztec coin. :cool

I guess the main file to be concerned with is transfer_characters.c, I really can’t see why else anything would affect this while capturing. I mean, realistically it’s the only way to have more than four ships because the current interface does not support buying or relaunching a fifth one, but the capture procedure in no way involves the four ship slots so far as I can tell (and by this I mean the slots on the interface, not the actual companions).

Here’s another thing to think about - we can gain information from the enemy captain which can unlock skills, and when that happens the ship is sunk by the “Hand of God” - in which case, the captain actually stays with his ship after the boarding ends, but is deliberately sunk for balance reasons. Since this can happen, I suppose we could technically force the captain to become an officer while staying with his ship, this way it would not be sunk. This might actually be a better idea, instead of just being able to have more than 4 ships, the player would have to bargain with the captain in a particular way so that he keeps his ship, but becomes a companion as well. If the character transfer screen is indeed hard-coded to not do anything if there are already 4 ships then this might be a good workaround.
I assume you have something like WinMerge to see what changes I made?
Nope, never heard of it... so I’d better get my Googlers on!
This applies especially to the entirety of transfer_characters.c, because the "four images" there should relate to your officer slots.
Wait, what? This is the key file I think. I don’t know why, but for some of the officer functions it checks how many companions there are, probably because it has to cycle through the ships as well as their officers - it might not apply in this file, but it does elsewhere (salary and hoisting in particular are relevant).
 
Hey, for simplicity it might also be an idea to define “OFFICERS_MAX”, at least then it would be obvious as to which is which. It’s probably unlikely to ever change from 3, but it might save a lot of bother if it did change or if people make their own personal modifications.

So now I’m seriously thinking about making the captain stay with his ship if he agrees to become an officer, which would therefore be the only way to have more than 4 ships. I’m guessing there is some code somewhere which removes him as captain, leaving the ship with nobody at the helm. So if he does stay on as captain then the ship will not sink.
 
I guess the main file to be concerned with is transfer_characters.c, I really can’t see why else anything would affect this while capturing. I mean, realistically it’s the only way to have more than four ships because the current interface does not support buying or relaunching a fifth one, but the capture procedure in no way involves the four ship slots so far as I can tell (and by this I mean the slots on the interface, not the actual companions).
Enabling/disabling the "Assign Captain" button should be either in transfer_main.c or ransack_main.c

we can gain information from the enemy captain which can unlock skills, and when that happens the ship is sunk by the “Hand of God” - in which case, the captain actually stays with his ship after the boarding ends, but is deliberately sunk for balance reasons.
Does it happen like that? That sounds more like a bug than anything else. Should still say "sunk by you" then, no?

Since this can happen, I suppose we could technically force the captain to become an officer while staying with his ship, this way it would not be sunk. This might actually be a better idea, instead of just being able to have more than 4 ships, the player would have to bargain with the captain in a particular way so that he keeps his ship, but becomes a companion as well.
The Cabinfight_dialog.c file has some code to do that, but it was disabled because apparently it caused CTDs.
It's still in there though.

Nope, never heard of it... so I’d better get my Googlers on!
I mentioned it in the -http://www.piratesahoy.net/threads/modding-tips-tricks.24942/ article and it is basically the most awesome program ever; complete life-saver.
There are other programs that do the same though, such as Beyond Compare that we use at work.
 
Hey, for simplicity it might also be an idea to define “OFFICERS_MAX”, at least then it would be obvious as to which is which. It’s probably unlikely to ever change from 3, but it might save a lot of bother if it did change or if people make their own personal modifications.
I was thinking the same thing! By all means, please go for it. :woot

So now I’m seriously thinking about making the captain stay with his ship if he agrees to become an officer, which would therefore be the only way to have more than 4 ships. I’m guessing there is some code somewhere which removes him as captain, leaving the ship with nobody at the helm. So if he does stay on as captain then the ship will not sink.
See my above post. :doff
 
Enabling/disabling the "Assign Captain" button should be either in transfer_main.c or ransack_main.c
This isn’t the problem, I can bring up the transfer screen... it just won’t actually move an officer into the empty slots.
Does it happen like that? That sounds more like a bug than anything else. Should still say "sunk by you" then, no?
It did that at least one time, I think I’ve got all the locked skills now so I can’t really test it at the moment.
I was thinking the same thing! By all means, please go for it. :woot
Okay, well I’ll get around to that later. :treasure:
 
This isn’t the problem, I can bring up the transfer screen... it just won’t actually move an officer into the empty slots.
I'd start looking here in transfer_characters.c:
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);
Use Trace to find out what nMyCharacterCompanionPlace and nCompanionIndex normally are when it does work.
You can also call DumpAttributes on myCh and enemyCh to see what characters they are.

Most likely you will find that nMyCharacterCompanionPlace is -1.
 
I thought this has already been done, by the fact that you can ask a crewmember for up to 9 extra men to follow you ashore, and if I am correct, promote them to officers?
 
Cabinfight_dialog.c said:
// TIH --> adjusted method Jul19'06
// instad of trying to autoassign the captain as companion, we simply leave that decision up to the player
// so instead we move the captian to an officer passenger of the player, and they can elect to assign the
// new captain to the ship to salvage the ship (or assign some OTHER officer to the ship, its their choice)
//=========================================================================================================//
// MAXIMUS: hmm... My idea was - to leave the captain with his own ship and his own crew - this is right, if we'll think logically, and all dialog says about it
// Also - this gives to us possibility for some small quests: such as escape of new companion, or his assault, when player will be not prepared, or his assault
// during sea battle with the ships of his compatriots. IT was my idea... I'll revive it, in course of time.
So how exactly can I change this? If it crashes then so be it, at least it might get me somewhere.
 
So how exactly can I change this? If it crashes then so be it, at least it might get me somewhere.
See here:
Code:
    case "be_companion":
       int myPower = sti(CalcCharacterSkill(PChar,SKILL_LEADERSHIP) + CalcCharacterSkill(PChar,SKILL_SNEAK) + CalcCharacterSkill(PChar,SKILL_FENCING) + CalcCharacterSkill(PChar,SKILL_CANNONS));
       int enPower = sti(CalcCharacterSkill(NPChar,SKILL_LEADERSHIP) + CalcCharacterSkill(NPChar,SKILL_SNEAK) + CalcCharacterSkill(NPChar,SKILL_FENCING) + CalcCharacterSkill(NPChar,SKILL_CANNONS));
       if(myPower<enPower)
       {
         dialog.text = DLG_TEXT[80];
         link.l1 = DLG_TEXT[81];
         link.l1.go = "officer";
         link.l2 = DLG_TEXT[21] + GetCharacterAddressForm(NPChar, ADDR_CIVIL, false, false) + ".";
         link.l2.go = "talk";
       }
       else
       {
         dialog.text = DLG_TEXT[78];
         link.l1 = DLG_TEXT[79];
         // link.l1.go = "Exit_companion";
         link.l1.go = "exit_joined"; // Sulan 2010-06-12: Exit_companion causes CTD - reason so far unknown.
         // Unless that is fixed and properly tested, please use this workaround
         link.l2 = DLG_TEXT[31];
         link.l2.go = "talk";
       }
     break;
Specifically that part marked by Sulan. Just swap those lines and see what happens.
 
Back
Top