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

Where's the info on extra ships stored?

iamthejarha

Landlubber
By "extra ships," of course, I mean any ships beyond your first ship. In Characters_init.c, there are entries for "ShipSlot1" through "ShipSlot3," but these are for `new-game` initialization, and always remain empty. Furthermore, any changes passed to them don't seem to have any effect whatsoever on ships that already occupy those slots.

I just finished a mod that allows you to change the name of your main ship through BuildSettings.h and a hotkey, and I'd like to extend that functionality to your other three ships, but I can't find <i>anything</i> that stores said information, nor can I figure out where it's generated. Is it all handled by engine code and stored in the save files? Is that why I can't find any references or ways to change them anywhere? If so, that's cool, but I'd really like to be able to modify this stuff. If any of you code gurus can point me in the right direction, it'd be awesome. In the meantime, I'll just keep poking around all these files in hopes that I'll actually come across something useful to my cause. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
I believe that this is stored in the saved game but there might be a way to change the ships name by using a command like
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->Characters1.ship.name = "Marie Celeste";<!--QuoteEnd--></div><!--QuoteEEnd-->
With the number incrementing up to 3 to cover all three companion ships.
 
<!--QuoteBegin-Sirus_Darke+--><div class='quotetop'>QUOTE(Sirus_Darke)</div><div class='quotemain'><!--QuoteEBegin-->I believe that this is stored in the saved game but there might be a way to change the ships name by using a command like
<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->
Characters1.ship.name = "Marie Celeste";<!--QuoteEnd--></div><!--QuoteEEnd-->
With the number incrementing up to 3 to cover all three companion ships.<!--QuoteEnd--></div><!--QuoteEEnd-->

Hmm. I'm not sure where "Characters1(2 or 3)" would lead me, since I haven't seen that anywhere else in the code. I've tried ShipSlot1.Name, which is the reference in Characters_init.c, and even managed to get the log to output the changed name, but it didn't affect the actual ship in that slot--or at least, what <i>should</i> be that slot.

I wonder if the ships are assigned instead to the officers you place as captain, rather than being assigned to your character? It might make sense, since your character can only be aboard one ship at a time. If that's the case though, I don't know where to start checking for something like that.

EDIT: I just used a hex editor and found references to all four of my ships in it, so it's obviously stored there. The question now is whether or not that information is stored--or can be accessed from--anywhere else. That's the part I haven't quite figured out yet.
 
look at character_init.c I believe they commented out where you can set it in there. "Character1" would be a referance and would have nothing to do wih your ships, it would refer to a differant NPC unless you se it to your character in which case you would do something like character1,ship1.name = "Marie Celeste" .... alas what I said is incorrect most likely because i am currently at work and have no access to the code.

EDIT:
Aww snap, I forgot I made a tutorial out of copying the code form that file...here's how it looks in there:
ch.ShipSlot1.Type=SHIP_NOTUSED;
ch.ShipSlot1.Name="No Name?";
ch.ShipSlot2.Type=SHIP_NOTUSED;
ch.ShipSlot2.Name="No Name?";
ch.ShipSlot3.Type=SHIP_NOTUSED;
ch.ShipSlot3.Name="No Name?";

so you would set ch to the player and then change the ship names
 
<!--QuoteBegin-Verruckt+--><div class='quotetop'>QUOTE(Verruckt)</div><div class='quotemain'><!--QuoteEBegin-->look at character_init.c I believe they commented out where you can set it in there. "Character1" would be a referance and would have nothing to do wih your ships, it would refer to a differant NPC unless you se it to your character in which case you would do something like character1,ship1.name = "Marie Celeste" .... alas what I said is incorrect most likely because i am currently at work and have no access to the code.

EDIT:
Aww snap, I forgot I made a tutorial out of copying the code form that file...here's how it looks in there:
ch.ShipSlot1.Type=SHIP_NOTUSED;
ch.ShipSlot1.Name="No Name?";
ch.ShipSlot2.Type=SHIP_NOTUSED;
ch.ShipSlot2.Name="No Name?";
ch.ShipSlot3.Type=SHIP_NOTUSED;
ch.ShipSlot3.Name="No Name?";

so you would set ch to the player and then change the ship names<!--QuoteEnd--></div><!--QuoteEEnd-->

That's the code I've been trying to reference, actually, but I'm not sure why it exists, because it has <i>no</i> effect on other ships that you pick along beyond your first. It <i>seems</i> like it would, but it doesn't. I think each extra ship might be stored as the 'flagship' of the officer you've placed as captain, but since that information is apparently stored solely in the save file, too, I don't think there's a way to edit it. As it stands, I've only found one workaround, and it's a pain in the neck: transfer to each ship in your fleet one at a time, `alt-tab` (if you can) or save and exit the game, change the ship name in BuildSettings.h, then go back to the game and hit the V key to load in the new name. That'll allow you to change the names of all four ships, but it's really only useful if you want to use characters like apostrophes, exclamation points, or others that can't be made through the `in-game` keyboard.
 
To update, I've figured out why the 'ch.ShipSlot1.Name' attribute doesn't work--the other ships in your fleet aren't assigned to your character, they're assigned to the officers who captain them for you. In fact, I've figured out a way to set the ship name of another ship in your fleet--the bad news is that I can only seem to change it if it's captained by a quest officer (in my case, Artois Voysey).

I can use "GetCharacterIndex("Artois Voysey")" to access Voysey, and thus his (my) ship, but the same doesn't work for hired officers. I assume that's because they're randomly generated, so they don't have concrete entries like Voysey, Danielle, and the other quest officers listed in Officers.c. I'll keep digging, but does anyone know how to access the information stored in your hired officers?

(This idea is turning out to be probably more difficult than it's worth, and I might just drop it and be happy to change my flagship name, but I'm pushing on for sheer knowledge's sake. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/pirate2.gif" style="vertical-align:middle" emoid=":p:" border="0" alt="pirate2.gif" /> )
 
i spent ages and ages in this bit of the code when doing the ship berthing mod (which <i>still</i> needs tweaking...), so i know it very well <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

to get your officers' indexes, use <b>GetCompanionIndex(<<<character>>>,<<<integer from 0 to 3>>>)</b>

for example:
<b>ref MainChar = GetMainCharacter();
GetCompanionIndex(MainChar,0)</b> returns the main character's index
<b>GetCompanionIndex(MainChar,1)</b> returns the index of officer in slot 1 (or -1 if there isn't one there)
<b>GetCompanionIndex(MainChar,2)</b> returns the index of officer in slot 2 (or -1 if there isn't one there)
<b>GetCompanionIndex(MainChar,3)</b> returns the index of officer in slot 3 (or -1 if there isn't one there)

remember the slots don't have to be used in order (so you could have an officer in slot 3 and none in slots 1 and 2).


then you can use:
<b>Characters[<<<index>>>].ship.name = ...</b>

or:
<b>ref ch = GetCharacter(<<<index>>>);
ch.ship.name = ...</b>


hope that helped <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" />
 
<!--QuoteBegin-Kieron+--><div class='quotetop'>QUOTE(Kieron)</div><div class='quotemain'><!--QuoteEBegin-->i spent ages and ages in this bit of the code when doing the ship berthing mod (which <i>still</i> needs tweaking...), so i know it very well <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

to get your officers' indexes, use <b>GetCompanionIndex(<<<character>>>,<<<integer from 0 to 3>>>)</b>

for example:
<b>ref MainChar = GetMainCharacter();
GetCompanionIndex(MainChar,0)</b> returns the main character's index
<b>GetCompanionIndex(MainChar,1)</b> returns the index of officer in slot 1 (or -1 if there isn't one there)
<b>GetCompanionIndex(MainChar,2)</b> returns the index of officer in slot 2 (or -1 if there isn't one there)
<b>GetCompanionIndex(MainChar,3)</b> returns the index of officer in slot 3 (or -1 if there isn't one there)

remember the slots don't have to be used in order (so you could have an officer in slot 3 and none in slots 1 and 2).


then you can use:
<b>Characters[<<<index>>>].ship.name = ...</b>

or:
<b>ref ch = GetCharacter(<<<index>>>);
ch.ship.name = ...</b>


hope that helped <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

That sounds very similar to what I was trying to do last night, but wouldn't "GetCompanionsIndex()" return the officers in my <i>party</i>, as opposed to the officers who are captaining my ships? Or do I have it backwards, and "GetOfficersIndex()" does that? I'll give this a shot, definitely.
 
Okay, I scrapped the post written here before entirely, because I got it to work. Here's the code:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// iamthejarha -->



void ChangeShipName(ref char)

{

    int pship1 = GetCompanionIndex(char,1);

    int pship2 = GetCompanionIndex(char,2);

    int pship3 = GetCompanionIndex(char,3);

    

    if(FLAGSHIP=="" || FLAGSHIP==char.ship.name) Log_SetStringToLog("No change to flagship...");

    else

    {

 DeleteAttribute(char,"ship.name");

 char.ship.name = FLAGSHIP;

 if(LogsToggle) Log_SetStringToLog("Changing flagship name to " + FLAGSHIP + "...");

    }

    

    if(pship1 == -1)

    {

 if(LogsToggle) Log_SetStringToLog("You don't have a second ship!");

    }

    else

    {

 if(SHIP1=="" || SHIP1==Characters[pship1].ship.name) Log_SetStringToLog("No change to second ship...");

 else

 {

     DeleteAttribute(Characters[pship1],"ship.name");

     Characters[pship1].ship.name = SHIP1;

     if(LogsToggle) Log_SetStringToLog("Changing second ship name to " + SHIP1 + "...");

 }

    }

    

    if(pship2 == -1)

    {

 if(LogsToggle) Log_SetStringToLog("You don't have a third ship!");

    }

    else

    {

 if(SHIP2=="" || SHIP2==Characters[pship2].ship.name) Log_SetStringToLog("No change to third ship...");

 else

 {

     DeleteAttribute(Characters[pship2],"ship.name");

     Characters[pship2].ship.name = SHIP2;

     if(LogsToggle) Log_SetStringToLog("Changing third ship name to " + SHIP2 + "...");

 }

    }

    

    if(pship3 == -1)

    {

 if(LogsToggle) Log_SetStringToLog("You don't have a fourth ship!");

    }

    else

    {

 if(SHIP3=="" || SHIP3==Characters[pship3].ship.name) Log_SetStringToLog("No change to fourth ship...");

 else

 {

     DeleteAttribute(Characters[pship3],"ship.name");

     Characters[pship3].ship.name = SHIP3;

     if(LogsToggle) Log_SetStringToLog("Changing fourth ship name to " + SHIP3 + "...");

 }

    }

}

// iamthejarha <--<!--c2--></div><!--ec2-->

SHIP1, SHIP2, and SHIP3 are defined in BuildSettings.h, and I set two checks to make sure that a) there <i>is</i> a ship in that slot (no check on the main character's ship), and B) there's a <i>new</i> name listed in each definition. I've tested it, and it works like a charm, but that's a lot of code. I was trying to work with a 'for' loop to trim down the code, but I can't figure out how to turn each global into something that can be placed and updated in a loop. For example:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->"SHIP1" can't be used as "SHIP" in a 'for' loop. (I put this in code to prevent the from italicizing everything.)<!--c2--></div><!--ec2-->

Any ideas on that? If not, I'll just work with what I've got. It's more code, but it's <i>working</i> code, which makes all the difference in the world to me. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
<!--QuoteBegin-iamthejarha+--><div class='quotetop'>QUOTE(iamthejarha)</div><div class='quotemain'><!--QuoteEBegin-->That sounds very similar to what I was trying to do last night, but wouldn't "GetCompanionsIndex()" return the officers in my <i>party</i>, as opposed to the officers who are captaining my ships? Or do I have it backwards, and "GetOfficersIndex()" does that? I'll give this a shot, definitely.<!--QuoteEnd--></div><!--QuoteEEnd-->

no, your companions are the three guys captaining the other ships in your fleet, and your officers are the three guys who trail around with you `on-shore` and get themselves killed incessantly <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
<!--QuoteBegin-iamthejarha+--><div class='quotetop'>QUOTE(iamthejarha)</div><div class='quotemain'><!--QuoteEBegin-->SHIP1, SHIP2, and SHIP3 are defined in BuildSettings.h, and I set two checks to make sure that a) there <i>is</i> a ship in that slot (no check on the main character's ship), and B) there's a <i>new</i> name listed in each definition. I've tested it, and it works like a charm, but that's a lot of code. I was trying to work with a 'for' loop to trim down the code, but I can't figure out how to turn each global into something that can be placed and updated in a loop. For example:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->"SHIP1" can't be used as "SHIP" in a 'for' loop. (I put this in code to prevent the from italicizing everything.)<!--c2--></div><!--ec2-->

Any ideas on that? If not, I'll just work with what I've got. It's more code, but it's <i>working</i> code, which makes all the difference in the world to me. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

could you define it as <b>int ship[3];</b> rather than <b>#define SHIP1</b> etc etc.? since buildsettings.h is #included in seadogs.c that array should be accessible everywhere in the code. then you could use ship[0] as the flagship and `1-3` as the companions...? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" />
 
<!--QuoteBegin-Kieron+--><div class='quotetop'>QUOTE(Kieron)</div><div class='quotemain'><!--QuoteEBegin-->could you define it as <b>int ship[3];</b> rather than <b>#define SHIP1</b> etc etc.? since buildsettings.h is #included in seadogs.c that array should be accessible everywhere in the code. then you could use ship[0] as the flagship and `1-3` as the companions...? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

Now <i>that's</i> something I hadn't considered. Because all the definitions in BuildSettings.h are global, I assumed that was the way to do it. I'll give that a try and see if it works. Thanks, Kieron!
 
oh hang on, i mean <b>string ship[3];</b>, not int. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/blush.gif" style="vertical-align:middle" emoid=":eek:ops" border="0" alt="blush.gif" />:
 
<!--QuoteBegin-Kieron+--><div class='quotetop'>QUOTE(Kieron)</div><div class='quotemain'><!--QuoteEBegin-->oh hang on, i mean <b>string ship[3];</b>, not int. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/blush.gif" style="vertical-align:middle" emoid=":eek:ops" border="0" alt="blush.gif" />:<!--QuoteEnd--></div><!--QuoteEEnd-->

I tried using brackets when I declared the variables, but the game crashed on startup, and the error log said I was declaring the same variable twice, as if it didn't read the brackets at all. I've been trying to work it out, but it just hasn't happened yet.
 
oh, that's odd. as far as i can see there's nothing wrong with <b>string ship[3];</b>... modding! why can it never just do what you want it to? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_twisted.gif" style="vertical-align:middle" emoid=":twisted:" border="0" alt="icon_twisted.gif" />
 
<!--QuoteBegin-Kieron+--><div class='quotetop'>QUOTE(Kieron)</div><div class='quotemain'><!--QuoteEBegin-->oh, that's odd. as far as i can see there's nothing wrong with <b>string ship[3];</b>... why can't it just do what you want? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_twisted.gif" style="vertical-align:middle" emoid=":twisted:" border="0" alt="icon_twisted.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

Because it <i>HATES</i> me. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> I'll make a backup of BuildSettings.h and Reinit.c, then see if I can get a loop to work. I've already trimmed down the code enough that I'm pretty happy with it, but I'd still like to see if I can get a loop working. I'm obsessive like that. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" />
 
well really you have to be if you want to mod. ask cat, she'll agree <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" />
 
AbsoLUTELY!!! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> This little guy <img src="http://www.ganotherapyusa.com/extras/modding.gif" border="0" class="linked-image" /> is called "Modding" for a REASON! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" />

I mod, therefore I am <i>peculiar...</i> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />
 
<!--QuoteBegin-iamthejarha+--><div class='quotetop'>QUOTE(iamthejarha)</div><div class='quotemain'><!--QuoteEBegin--><!--QuoteBegin-Kieron+--><div class='quotetop'>QUOTE(Kieron)</div><div class='quotemain'><!--QuoteEBegin-->oh, that's odd. as far as i can see there's nothing wrong with <b>string ship[3];</b>... why can't it just do what you want? <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/icon_twisted.gif" style="vertical-align:middle" emoid=":twisted:" border="0" alt="icon_twisted.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

Because it <i>HATES</i> me. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" /> I'll make a backup of BuildSettings.h and Reinit.c, then see if I can get a loop to work. I've already trimmed down the code enough that I'm pretty happy with it, but I'd still like to see if I can get a loop working. I'm obsessive like that. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->

Huzzah! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/william.gif" style="vertical-align:middle" emoid=":will" border="0" alt="william.gif" /> I got a loop to work! I'm not at my computer right now, but I'll post the function code ASAP to make sure it's 'proper.' It works, but I've never worked with arrays before, so I'm not positive I did everything <i>exactly</i> right.
 
Here's the code I was talking about. I've gotten the For loop to work properly (finally!), and it didn't require changing the definitions in BuildSettings.h.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// iamthejarha -->

void ChangeShipName(ref char)

{

    string sh[4];

    AddStr2Array(&sh, 0, FLAGSHIP);

    AddStr2Array(&sh, 1, SHIP1);

    AddStr2Array(&sh, 2, SHIP2);

    AddStr2Array(&sh, 3, SHIP3);



    int i, p;

    for(i = 0; i < 4; i++)

    {

 p = GetCompanionIndex(char,i);

 ref ch = GetCharacter(p);

 if(p != -1 && sh != "" && sh != ch.ship.name)

 {

     DeleteAttribute(ch,"ship.name");

     ch.ship.name = sh;

     if(LogsToggle) Log_SetStringToLog("Changing ship name to " + sh + "...");

 }

 else { if(LogsToggle) Log_SetStringToLog("No ship changes made..."); }

    }

}

// iamthejarha <--<!--c2--></div><!--ec2-->
 
Back
Top