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

Need Help add a new order for my companions

Myth

Freebooter
Good afternoon. Now I'm trying to add a new order for my companions. Between each other, two companions should work together. I can not understand:
1) How to create a list of ships with which interaction is possible?
2) How to get the one to whom I gave the order, and with whom does my companion interact?

Thank you in advance for your cooperation.
 
To give a command to ship, see BattleInterface.c:


ref BI_CommandEndChecking()
...
case "BI_NewCommand":
//What icons for ship selection will show? My Ship + Friend ship
BI_retComValue = BI_COMMODE_MY_SHIP_SELECT+BI_COMMODE_FRIEND_SHIP_SELECT+BI_COMMODE_ALLLOCATOR_SELECT;
BattleInterface.Commands.NewCommand.EffectRadius = 2000; //Only allow command for ships within this distance
break;
...

void BI_LaunchCommand()
...
case "BI_NewCommand":
//charIdx receiving command, targetNum is selected target to interact
ExecuteNewCommand(charIdx, targetNum );
break;
...

void BI_InitializeCommands()
...
BattleInterface.Commands.NewCommand.enable = true;
...
BattleInterface.Commands.NewCommand.event = "BI_NewCommand";
...

void ExecuteNewCommand(int charIdx, int targetNum )
{
Do stuff...
}
 
To give a command to ship, see BattleInterface.c:


ref BI_CommandEndChecking()
...
case "BI_NewCommand":
//What icons for ship selection will show? My Ship + Friend ship
BI_retComValue = BI_COMMODE_MY_SHIP_SELECT+BI_COMMODE_FRIEND_SHIP_SELECT+BI_COMMODE_ALLLOCATOR_SELECT;
BattleInterface.Commands.NewCommand.EffectRadius = 2000; //Only allow command for ships within this distance
break;
...

void BI_LaunchCommand()
...
case "BI_NewCommand":
//charIdx receiving command, targetNum is selected target to interact
ExecuteNewCommand(charIdx, targetNum );
break;
...

void BI_InitializeCommands()
...
BattleInterface.Commands.NewCommand.enable = true;
...
BattleInterface.Commands.NewCommand.event = "BI_NewCommand";
...

void ExecuteNewCommand(int charIdx, int targetNum )
{
Do stuff...
}

And what should I write after BI_retComValue, if I only need partners?
 
I think that gets a little trickier. The engine only understands enemy, friend, neutral, and has no way to figure only your companions, because that is a construct in the script.

But, I think we can do it with the .usericons, but that will require replacing them each time you select a command, because the sail state also uses them. I have not tested this, but it should give you the idea to follow:
Code:
ref BI_CommandEndChecking()
...
case "BI_Speed":
   SetUserIcons("BI_Speed"); //Add this
   BI_retComValue = BI_COMMODE_USER_ICONS;
   break;
...
case "BI_NewCommand":
   SetUserIcons("BI_NewCommand"); //Add this
   BI_retComValue = BI_COMMODE_USER_ICONS;
   break;
...

BI_LaunchCommand() doesn't change...the charIdx is the characters[] array index of the command issued to, and targetNum is the index of the character to target/interact with.
...
void BI_LaunchCommand()
...
case "BI_NewCommand":
//charIdx receiving command, targetNum is selected target to interact
ExecuteNewCommand(charIdx, targetNum );
break;
...

//New function
void SetUserIcons(string commState)
{
   if(BattleInterface.UserIconsState == commState) return;
   BattleInterface.UserIconsState = commState;
   //Try this, if it doesn't remove them all, try iterating
   DeleteAttribute(&BattleInterface, "UserIcons"); //Remove existing
   /* if above doesn't work, delete individually?
       aref userIcons, userIcn;
       makearef(userIcons, BattleInterface);
       int numUIcons = GetAttributesNum(userIcons);
       for(int i=0;i<numUIcons;i++) {
           userIcn = GetAttributeN(userIcons, i);
           DeleteAttribute(&BattleInterface, GetAttributeName(userIcn);
       }
   */
 
   switch(commState) {
       case "BI_NewCommand":
           int nNum = 1;
           //Loop companions and add icons
           for(int j = 0; j< COMPANION_MAX; j++) {
               int cn = GetCompanionIndex(pchar, i);
               if( cn>=0 ) {
                   string attName = "ui" + nNum;
                   Event(BI_EVENT_GET_DATA, "ll", BIDT_SHIPPICTURE, cn);
                   BattleInterface.UserIcons.(attName).enable = true;
                   BattleInterface.UserIcons.(attName).pic = BI_intNRetValue[0];
                   BattleInterface.UserIcons.(attName).selpic = BI_intNRetValue[1];
                   BattleInterface.UserIcons.(attName).tex = BI_intNRetValue[2];
                   BattleInterface.UserIcons.(attName).name = cn; //Not necessary...could probably be ""

                   nNum++;
               }
           }
       break;
       //Default to sails if not BI_NewCommand
           BattleInterface.UserIcons.ui1.enable = true;
           BattleInterface.UserIcons.ui1.pic = 25;
           BattleInterface.UserIcons.ui1.selpic = 9;
           BattleInterface.UserIcons.ui1.tex = 0;
           BattleInterface.UserIcons.ui1.name = "sail_none";

           BattleInterface.UserIcons.ui2.enable = true;
           BattleInterface.UserIcons.ui2.pic = 24;
           BattleInterface.UserIcons.ui2.selpic = 8;
           BattleInterface.UserIcons.ui2.tex = 0;
           BattleInterface.UserIcons.ui2.name = "sail_midi";

           BattleInterface.UserIcons.ui3.enable = true;
           BattleInterface.UserIcons.ui3.pic = 23;
           BattleInterface.UserIcons.ui3.selpic = 7;
           BattleInterface.UserIcons.ui3.tex = 0;
           BattleInterface.UserIcons.ui3.name = "sail_fast";
       break;
   }
}
...
//Change to add .UserIconsState to first command setup...find in battleinterface.c
SetParameterData()
...
BattleInterface.UserIconsState = "BI_Speed"; //Add this for checking for change
BattleInterface.UserIcons.ui1.enable = true;
   BattleInterface.UserIcons.ui1.pic = 25;
   BattleInterface.UserIcons.ui1.selpic = 9;
   BattleInterface.UserIcons.ui1.tex = 0;
   BattleInterface.UserIcons.ui1.name = "sail_none";

   BattleInterface.UserIcons.ui2.enable = true;
   BattleInterface.UserIcons.ui2.pic = 24;
   BattleInterface.UserIcons.ui2.selpic = 8;
   BattleInterface.UserIcons.ui2.tex = 0;
   BattleInterface.UserIcons.ui2.name = "sail_midi";

   BattleInterface.UserIcons.ui3.enable = true;
   BattleInterface.UserIcons.ui3.pic = 23;
   BattleInterface.UserIcons.ui3.selpic = 7;
   BattleInterface.UserIcons.ui3.tex = 0;
   BattleInterface.UserIcons.ui3.name = "sail_fast";
....
 
I think I found a better solution: I will not build a line from the ships. I decided to do this:
1) Have chosen a companion.
2) Specify that you want to run a new command.
3) Wrote it id as a variable.
4) Have chosen the second companion.
5) Specify that you need to execute a new command.
6) We have written the id of the second companion into another variable.
7) Run a new command.

If anyone is interested: I want to try to make a form of exchange of goods, etc. between companions.
 
Back
Top