• 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

Sorry, I think I’m getting confused with the currently-selected officer, which is -1 to begin with. Obviously we’re concerned about the companions.
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;
         trace("Main - i: "+i);
         break;
       }
     }
   }
The trace I have there returns 4, which clearly is the number of ships I have. So it’s being reset, right?
 
Well, if I have less than four ships and go to assign an officer, it still says -1.
That can't be right. That number must be the index of the empty companion slot that your new ship will go into.

Where do you have the Trace 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";

Trace("nMyCharacterCompanionPlace = " + nMyCharacterCompanionPlace); // PB: I think this value should NOT be "-1" for it to work properly

nCompanionIndex = GetCompanionIndex(refMyCharacter,nMyCharacterCompanionPlace);

The trace I have there returns 4, which clearly is the number of ships I have. So it’s being reset, right?
4 there is good. Because the player ship is 0, 4 must be the FIFTH ship in your fleet that you are trying to add.

Then when you check the resulting value in transfer_characters.c, it should of course still be 4 there as well.


This in PROGRAM\Characters\CharacterUtilite.c could very well be what is messing you up:
Code:
int GetCompanionIndex(ref _refCharacter,int _CompanionNum)
{
   if(_CompanionNum<0) return -1;
   //if(_CompanionNum>3) return -1; // <----------------- I think you will want to put your COMPANION_MAX setting here as well ------------------
   f(_CompanionNum>=COMPANION_MAX)   return -1; // <-------------------- So try this; ">=" because COMPANION_MAX = 4
   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));
}
 
Oooh... so it’s selecting the next slot. I think you read my mind again, I’ve just spent 10 minutes going through that file setting OFFICER_MAX all over it. What I’ve done is set that number in character.h to 5 so that it matches the companion limit for the time being, to save any problems. No idea what’ll happen if I try to recruit another one, but hey. I don’t think it matters anyway, the line you pointed out there is precisely what I just noticed and precisely the changed I just made, I think it might be the one. ;)
 
Either I read you or you read me, I swear down I’d already made that change before I saw you post it. :woot
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    93.5 KB · Views: 526
HOLY CRAP, eight ships in your player fleet? Congratulations! :woot

Either I read you or you read me, I swear down I’d already made that change before I saw you post it. :woot
I didn't see your post, that much I promise.

But since there was only one solution, it is quite possible that we just both found it independently at the same time.
Wouldn't be the first time that has happened! :rofl
 
Yeah, so technically there probably is no limit.

I need to reinstate the original files now and start over, I have no idea what changes I’ve made. I think I tend to revert stuff when it doesn’t work so there shouldn’t much. Maybe if I check them over, put OFFICER_MAX everywhere and then I can upload them so you can check them against your own files. I certainly think it’s worthwhile making these changes, that way you only need to worry about the settings in character.h.

The real issue here is about the interface, but like I said it is feasible to swap people and cargo at sea. My biggest concern, though, is narrow ports... I imagine there would be problems here and there with ships bouncing off each other and rocks, but I guess the ultimate choice is with the player as to how many ships they think they can safely command. In fact, the setting could be left at 4 ships and people can simply change it and do as they please. Fact of the matter is, it works.
 
Last edited:
I certainly think it’s worthwhile making these changes, that way you only need to worry about the settings in character.h.
Definitely agreed. It does no harm having it included and if people want it, at least the option is there. :woot

The real issue here is about the interface
That is what I expected.
I don't expect that part will be solved any time soon, but having it workable at all is already pretty awesome! :cheers

My biggest concern, though, is narrow ports... I imagine there would be problems here and there with ships bouncing off each off and rocks, but I guess the ultimate choice is with the player as to how many ships they think they can safely command. In fact, the setting could be left at 4 ships and people can simply change it and do as they please. Fact of the matter is, it works.
Agreed, agreed and agreed. :onya
 
The God Mode button cycles only the first four, where do I change this?

Anyway, here are the files. I’ve set OFFICER_MAX in them as well so don’t forget to define that in characters.h. There will be an abundance of other files which would require that setting if ever the officer limit is increased, but there are too many for me to be bothered with right now. It’s not tested but assuming the limit stays at 4 then I can’t imagine there being any problems, same with the companions.

What irR4tiOn4L suggests might be possible. But somebody would need to code it in. And I don't know who would want to.
:treasure:
 

Attachments

  • Files.zip
    247.1 KB · Views: 106
Last edited:
The God Mode button cycles only the first four, where do I change this?
The relevant code for that is in PROGRAM\seadogs.c:
Code:
      case "ScrollCharactersLeft":
         if(CheckAttribute(mc, "scrollchars"))
         {
           mc.scrollchars = sti(mc.scrollchars) - 1;
           if(sti(mc.scrollchars) < 0) mc.scrollchars = 6;
         }
         else
           mc.scrollchars = 6;

         while(Cheat_GetCharacterIndex(mc.scrollchars) == -1)
         {
           mc.scrollchars = sti(mc.scrollchars) - 1;
           if(sti(mc.scrollchars) < 0) mc.scrollchars = 6;
         }
         LogIt("Selected character is " + Cheat_ScrollCharacterName(mc.scrollchars));
       break;

       case "ScrollCharactersMain":
         mc.scrollchars = 0
         LogIt("Selected character is " + Cheat_ScrollCharacterName(mc.scrollchars));
       break;

       case "ScrollCharactersRight":
         if(CheckAttribute(mc, "scrollchars"))
         {
           mc.scrollchars = sti(mc.scrollchars) + 1;
           if(sti(mc.scrollchars) > 6) mc.scrollchars = 0;
         }
         else
           mc.scrollchars = 1;

         while(Cheat_GetCharacterIndex(mc.scrollchars) == -1)
         {
           mc.scrollchars = sti(mc.scrollchars) + 1;
           if(sti(mc.scrollchars) > 6) mc.scrollchars = 0;
         }
         LogIt("Selected character is " + Cheat_ScrollCharacterName(mc.scrollchars));
       break;
And also PROGRAM\NK.c:
Code:
string Cheat_ScrollCharacterName(int charnum)
{
   string logmessage;
   ref PChar = GetMainCharacter();
   switch(sti(charnum))
   {
     case 0:
       logmessage = "player, " + GetMySimpleName(PChar);
     break;
     case 1:
       logmessage = "officer, " + GetMySimpleName( GetCharacter(GetOfficersIndex (PChar, sti(1))) );
     break;
     case 2:
       logmessage = "officer, " + GetMySimpleName( GetCharacter(GetOfficersIndex (PChar, sti(2))) );
     break;
     case 3:
       logmessage = "officer, " + GetMySimpleName( GetCharacter(GetOfficersIndex (PChar, sti(3))) );
     break;
     case 4:
       logmessage = "companion, " + GetMySimpleName( GetCharacter(GetCompanionIndex(PChar, sti(1))) );
     break;
     case 5:
       logmessage = "companion, " + GetMySimpleName( GetCharacter(GetCompanionIndex(PChar, sti(2))) );
     break;
     case 6:
       logmessage = "companion, " + GetMySimpleName( GetCharacter(GetCompanionIndex(PChar, sti(3))) );
     break;
   }
   return logmessage;
}

int Cheat_GetCharacterIndex(int charnum)
{
   int charIndex;
   ref PChar = GetMainCharacter();
   switch(sti(charnum))
   {
     case 0:
       charIndex = GetMainCharacterIndex();
     break;
     case 1:
       charIndex = GetOfficersIndex (PChar, sti(1));
     break;
     case 2:
       charIndex = GetOfficersIndex (PChar, sti(2));
     break;
     case 3:
       charIndex = GetOfficersIndex (PChar, sti(3));
     break;
     case 4:
       charIndex = GetCompanionIndex(PChar, sti(1));
     break;
     case 5:
       charIndex = GetCompanionIndex(PChar, sti(2));
     break;
     case 6:
       charIndex = GetCompanionIndex(PChar, sti(3));
     break;
   }
   return charIndex;
}

Admittedly not particularly "simply increase the numbers"-friendly.
I won't tell you who you can blame for that one! :whipa

Yes, that was me being lazy.... :oops:


Ha, good find! Merged. :cheeky
 
I think I’ll leave that one in your hands. o_O

The main issue here is when captured captains are put in charge of their own ship. Mind you, he can be selected whilst in the cabin before leaving the ransack screen because at that point he’s a regular passenger/officer, so it’s not a huge deal I guess. Or the player can just not cheat.
 
I think I’ll leave that one in your hands. o_O
Except I don't quite intend to change it....
I wrote it that way because I didn't expect it would ever need to take into account more characters. :facepalm

It isn't technically all that complicated: The code in seadogs.c sets the "scrollchars" attribute to a number between 0 and 6.
The code in NK.c then relates that number to the player, your three shore officers and your three companions.

I suppose that "6" should become 1+OFFICERS_MAX+COMPANIONS_MAX .
Then the stuff in NK.c would need some extra cleverness to be added to determine from a single number if it relates to the player, an officer or a companion.
At the moment that is hardcoded, so it would need to be made dynamic. Should be quite possible actually.

Or the player can just not cheat.
Always an option! :rofl
 
Well I suppose it’s something to think about another time. Quite frankly, if I lose one of my twenty ships because I couldn’t set it to invincible then so be it!

What does this do? I don’t know which to set those numbers to...
Code:
   for(i=1;i<4;i++)   {if( GetOfficersIndex(pCharacter,i)>=0 || GetCompanionIndex(pCharacter,i)>=0 ) break;}
   if(i==4)
   {
     bBeParty = true;
   }
   else
   {
     bBeParty = true;
   }
 
Last edited:
Right then... I didn’t change kam_shiptransfer.c because I wasn’t sure what it would do. I’ve set the variable and the ship transfer screen is now displaying my fifth ship, so it would appear that this interface will quite happily allow transfers with the additional ships... which therefore means swapping ships at sea is not necessary, it can be done here. That is to say, if a player wants to sell, berth or do anything else with their ship where the interface normally shows four pictures for them rather than a scroll-bar, then they can use this interface to swap between them, or indeed they can just do it at sea if they so please.

:ship
 
Last edited:
I was totally going to update my game files based on yours, but got carried away by other things and forgot.
Please remind me tomorrow.... :eek:
 
Okay, well as good as it has gone so far I have found a bit of a problem... berthing. It’s buggy enough anyway so far as I’ve noticed, and this doesn’t help.

Berthing a ship which is in slot 5 or higher will be problematic with the existing interface, simple as that. I’ve removed the variable from the berthing files, it should prevent them from being berthed at all. In order to do so, they’ll have to be swapped into one of the first four slots beforehand. To be fair, I think the entire berthing interface could do with a rewrite as it is, so maybe this would present a good opportunity (for somebody who isn’t me). Nothing else really needs to be changed so far as I can tell at this point, the ship transfer screen pretty much covers the basics.
 
Last edited:
As far as I know, berthing does generally work OK for four ships.
But it is admittedly quite an ancient interface so having it improved would still be good.

That being said, I personally would not consider it a high priority.
I can think of a lot of other things I'd much rather see done. (See all the many, many features losted on this forum! :shock )
But of course the choice of what you want to do is yours.
 
Basically, it’s okay to berth a fifth ship but relaunching it is another matter entirely. :confused:

My issue with the interface is that I haven’t a clue how to edit it, but maybe I’ll pick up on it.

I say berthing is buggy anyway but it might be because I’ve been editing the files, probably.
 
I’ve hit another snag. It has occurred to me that once a fifth ship has been acquired, its slot cannot be removed unless the ship which is using it is sunk. Okay, so I have a working model to get around this. Yep, the main ship transfer screen of course!

I have opened up the closed slots, as in those which don’t normally show if they are empty. This means that they could be interacted with on the transfer screen but I have stopped this from happening, we probably don’t want that to be possible. It’s almost ready to go, all I need to know is how to tell the interface to actually swap the ships over. Simply clicking the button which normally goes to the transfer screen should be able to do the trick on its own.

For now though, it doesn’t really do anything other than display as many ships as the companion limit has defined, which by all means is handy.
 

Attachments

  • 1.jpg
    1.jpg
    181.1 KB · Views: 107
  • kam_shiptransfer.c
    14.8 KB · Views: 113
  • 2.jpg
    2.jpg
    175.4 KB · Views: 110
Last edited:
Back
Top