• 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

Yeah, but I’ll leave the berthing alone.

Now I’ve forgotten how to grab the current number of companions. :(
 
Code:
if (GetCompanionQuantity(GetMainCharacter()) > SlotNum2 )
Code:
RUNTIME ERROR - file: seadogs.c; line: 58
Incorrect instruction code
RUNTIME ERROR - file: seadogs.c; line: 58
function 'GetCompanionQuantity' stack error
What did I do or not do which I should’ve done or not done? :8q

Never mind, I think some changes stayed resident in the memory because it works now. :shrug
 
Last edited:
The God Mode button cycles only the first four, where do I change this?
Try this in seadogs.c:
Code:
      case "ScrollCharactersLeft":
         if(CheckAttribute(mc, "scrollchars"))
         {
           mc.scrollchars = sti(mc.scrollchars) - 1;
           if(sti(mc.scrollchars) < 0) mc.scrollchars = OFFICER_MAX + COMPANION_MAX - 2;
         }
         else
           mc.scrollchars = OFFICER_MAX + COMPANION_MAX - 2;

         while(Cheat_GetCharacterIndex(mc.scrollchars) == -1)
         {
           mc.scrollchars = sti(mc.scrollchars) - 1;
           if(sti(mc.scrollchars) < 0) mc.scrollchars = OFFICER_MAX + COMPANION_MAX - 2;
         }
         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) > OFFICER_MAX + COMPANION_MAX - 2;) mc.scrollchars = 0;
         }
         else
           mc.scrollchars = 1;

         while(Cheat_GetCharacterIndex(mc.scrollchars) == -1)
         {
           mc.scrollchars = sti(mc.scrollchars) + 1;
           if(sti(mc.scrollchars) > OFFICER_MAX + COMPANION_MAX - 2;) mc.scrollchars = 0;
         }
         LogIt("Selected character is " + Cheat_ScrollCharacterName(mc.scrollchars));
       break;
And this in NK.c:
Code:
string Cheat_ScrollCharacterName(int charnum)
{
   string logmessage;
   ref PChar = GetMainCharacter();
   if (charnum == 0)
   {
     logmessage = "player, " + GetMySimpleName(PChar);
   }
   else
   {
     if (charnum > 0 && charnum < OFFICER_MAX)
     {
       logmessage = "officer, " + GetMySimpleName( GetCharacter(GetOfficersIndex (PChar, charnum)) );
     }
     else
     {
       logmessage = "companion, " + GetMySimpleName( GetCharacter(GetCompanionIndex(PChar, charnum-OFFICER_MAX+1)) );
     }
   }
   return logmessage;
}

int Cheat_GetCharacterIndex(int charnum)
{
   int charIndex;
   ref PChar = GetMainCharacter();
   if (charnum == 0)
   {
     charIndex = GetMainCharacterIndex();
   }
   else
   {
     if (charnum > 0 && charnum < OFFICER_MAX)
     {
       charIndex = GetOfficersIndex (PChar, charnum);
     }
     else
     {
       charIndex = GetOfficersIndex (PChar, charnum-OFFICER_MAX+1);
     }
   }
   return charIndex;
}
I think in concept that should work, but you should double-check my use of +/-1 and such.
 
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;
   }
As I said earlier, in its current form that might as well say:
Code:
bBeParty = true;
And nothing else.

But:
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; // <------------------------ I suspect this was always meant to be 'false' -------------------------
   }

Based on that assumption, I think this is what you need to replace it with:
Code:
   bBeParty = false;
   for(i=1;i<OFFICER_MAX  ;i++)   {if( GetOfficersIndex (xi_refCharacter,i)>=0 ) bBeParty = true; break;}
   for(i=1;i<COMPANION_MAX;i++)   {if( GetCompanionIndex(xi_refCharacter,i)>=0 ) bBeParty = true; break;}
(If you want to be picky about performance, technically that second loop is superfluous if the first loop already set 'bBeParty = true')

Since apparently this never did serve any purpose, I have NO clue what will happen if it actually starts working as intended.
My suggestion: Give it a try and see what happens.
 
Attached also an archive containing my modified versions of your code files.
I strongly recommend you compare those with your own using WinMerge; I made some further changes that may be of help to you.

Anyway, that's enough from me for today. :cheeky
 

Attachments

  • Companion_Files.zip
    473.4 KB · Views: 155
WARNING: I already found one double mistake in those files I posted.
When you try them, you'll probably find it soon enough. Stops the game from running. :oops:
 
Code:
COMPILE ERROR - file: Screwface_functions.c; line: 402
Invalid Expression

if (GetNationRelation(iNation, nNation) == RELATION_ENEMY || !RELATION_IGNORE_FRIENDLY)
What, you mean this? :boom:
 
Last edited:
Code:
COMPILE ERROR - file: Screwface_functions.c; line: 402
Invalid Expression

if (GetNationRelation(iNation, nNation) == RELATION_ENEMY || !RELATION_IGNORE_FRIENDLY)
What, you mean this? :boom:
No, I meant something else. A ";" that I accidentally had inside an if statement.

Replace the line you found with this:
Code:
if (GetNationRelation(iNation, nNation) == RELATION_ENEMY)
The code files I posted are only those you posted first. But mine include a new toggle defined in InternalSettings.h .
But you didn't edit that file, so I didn't post my modified version of it either. Oops. :facepalm
 
Oh, I spotted the semi-colons in two seconds flat. I also removed that ‘or’ statement as well and it’s happy now. ;)

Why is the code so pedantic anyway? If this was PHP it would just ignore it and get on with its life. It’d be, like... “nope, that variable isn’t assigned so the clause fails”. It’s like when I put the same variable in a joint ‘if’ and ‘else’ statement - if neither statement can possibly match then neither can the variable possibly be duplicated! And even PHP would just use the second one and ignore the first. Eh.
 
Oh, and I might as well post this. I haven’t got it working yet but it’s all in good order for when I do figure something out.
 

Attachments

  • kam_shiptransfer.c
    15.5 KB · Views: 171
Why is the code so pedantic anyway? If this was PHP it would just ignore it and get on with its life. It’d be, like... “nope, that variable isn’t assigned so the clause fails”. It’s like when I put the same variable in a joint ‘if’ and ‘else’ statement - if neither statement can possibly match then neither can the variable possibly be duplicated! And even PHP would just use the second one and ignore the first. Eh.
I like the game telling me when code is wrong. Helps to fix it. :cheeky
 
Sometimes the game really doesn’t need to commit suicide, simply logging the error is good enough. Semi-colons in ‘if’ statements, yeah alright. xD

I tell you what’s annoying, though... spending two hours trawling through a few dozen files because a full- or semi- colon was used instead of the other.
 
passengers.c
Code:
     for(int i=1;i<OFFICER_MAX;i++)
     {
       if(idxNew==GetOfficersIndex(_refCh,i))
       {
         XI_ChangeOfficer(i,-1);
       }
     }
Should be +1 again, right? That’s in a few places in the file.
 
Are you sure?
I think it starts counting at 1 simply to exclude the player character.
 
Back
Top