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

Realistic Shipis Purchase

Luke159

Buccaneer
Storm Modder
What am i doing wrong here?

I have tried managed to get the game to load and with realistic ship purchase off all ships are generated as normal depending on your rank. When i turn realistic ship purchase on the game still loads but only the ships from rand 2 are generated or more spacifically those marked in shipsuntilities as.
Code:
 "ship2");

And not all ships from that group are generated, only Lugger, Bermuda Sloop, Tartan and War Tartan are generated. I figured because in the original code i had done it like this for every rand.

Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{
}
if (iTest_ship == 2)
{
if (iTest_ship == 1) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER), "ship2");
if (iTest_ship == 2) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_PINK), "ship2");
if (iTest_ship == 4) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER_h), "ship2");
if (iTest_ship == 5) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Galeoth_h), "ship2");
if (iTest_ship == 6) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship2");
if (iTest_ship == 7) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Sloop_Cutter1_18), "ship2");
if (iTest_ship == 8) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LuggerVML), "ship2");
if (iTest_ship == 9) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_HMS_Bounty), "ship2");
if (iTest_ship == 10) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Hooker1), "ship2");
if (iTest_ship == 11) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_brig_n1), "ship2");

}
else // = If Realistic SHIP_PURCHASE IS enabled
{

if (iTest_ship == 1) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");
if (iTest_ship == 2) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LuggerVML), "ship2");
if (iTest_ship == 4)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_WAR_TARTANE), "ship2");
if (iTest_ship == 5)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Gunboat), "ship2");
if (iTest_ship == 6) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");
if (iTest_ship == 7) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_EDINBURG), "ship2");
if (iTest_ship == 8) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship2");
}

I figured maybe its because of this missing for the above the above rand.

Code:
}
if (iTest_ship == 2)
{

So i added each rand into the realistic ship purchase enteries and the game wouldn't load. I then thourght maybe its because there are already open and closed brackets which are effecting code, but if i remove them from all rands the game doesn't load any ships.

I then made it so the ships for none realistic mod would be all enetered together and the ones for the realistic mod would have there enteries but that didn't work instead no ships was generated because it doesn't know which ships to generate for which rand due to the rands not been part of the realistic ships purchase enteries.

How do i work my way around this. Bellow is the shipsutilities file which i have got working. Also included is the _mod_on_off file which is used to turn the mod on or off obviously. Any help on this would be very helpfull and much appritiated.

Thanks in advance
Luke.
 
Realistic Ship Purchase? What exactly is that supposed to do and how is it supposed to work?
I coded a mod with that name in PotC, but it looks nothing like the one you show above...

I do see this at the top of your above code, which can't be the intention:
Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{
}
The closing bracket is already there at the top and nothing is inside the if-statement.
Therefore the rest of the code will be executed whether the mod is on or not.
 
Realistic Ship Purchase? What exactly is that supposed to do and how is it supposed to work?
I coded a mod with that name in PotC, but it looks nothing like the one you show above...

I do see this at the top of your above code, which can't be the intention:
Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{
}
The closing bracket is already there at the top and nothing is inside the if-statement.
Therefore the rest of the code will be executed whether the mod is on or not.

I had noticed the same thing, and it is repeated a number of times throughout the code.

What do you use as an editor, Luke? The editor I use, Code::Blocks, points out where each bracket's 'other half' is, which can be a big help.

Edit: If I'm reading this correctly (which I may or may not be) there are brackets either misplaced or missing all over the file you've uploaded. To clarify, which parts do you have working, and which are your problem areas? Because the way I'm looking at it, I'm not sure it should be working at all... I could definitely be wrong here, my C is not excellent.

Edit 2{/b]: So, am I to understand that you're trying to get the contents of shipyards to reflect the character's... what? Current ship and rank with the government of that colony? I unfortunately don't have any experience with a lot of the objects these are pointing to...
 
My recommendation for an editor is at least Notepad++.
That's what I use. It also shows which brackets go together.
It's, as the name suggests, basically Windows Notepad, only better.

I tried Code::Blocks once and it does offer very nice options,
but as soon as I'd add/remove a file from the game structure,
it'd go nuts on me. :(
 
Realistic Ship Purchase? What exactly is that supposed to do and how is it supposed to work?
I coded a mod with that name in PotC, but it looks nothing like the one you show above...

I do see this at the top of your above code, which can't be the intention:
Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{
}
The closing bracket is already there at the top and nothing is inside the if-statement.
Therefore the rest of the code will be executed whether the mod is on or not.

I haven't removed any brackets at all, i have added the lines of code around the current brackets because if you remove them the game doesn't load. The above code you refer to Pieter is part of this. And its the same throughout the file. :shrug

Code:
}        if (iTest_ship == 2)        {

I tried to add code in ships_init to see if i could have the option to turn them off in _mod_on_off but it didn't work out.


@ Darkhymn

I use note pad, i did have note pad ++ till i reformatted my computer and i haven't got around to installing it yet.
 
After popping open the original ShipsUtilies.c, the error Pieter pointed out, is in the code you've added, as is the second one I've (possibly) corrected, here.

In my understanding, this:
Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{

iTest_ship = rand(2);
if (iTest_ship == 1)
{
if (iTest_ship == 1)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_WAR_TARTANE), "ship2");
if (iTest_ship == 2)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Gunboat), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");

}
Is missing a bracket and should look like this:

Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{

iTest_ship = rand(2);
if (iTest_ship == 1)
{
if (iTest_ship == 1)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_WAR_TARTANE), "ship2");
if (iTest_ship == 2)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Gunboat), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");

}
}
And this:

Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{
}
if (iTest_ship == 2)
{
if (iTest_ship == 1) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER), "ship2");
if (iTest_ship == 2) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_PINK), "ship2");
if (iTest_ship == 4) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER_h), "ship2");
if (iTest_ship == 5) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Galeoth_h), "ship2");
if (iTest_ship == 6) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship2");
if (iTest_ship == 7) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Sloop_Cutter1_18), "ship2");
if (iTest_ship == 8) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LuggerVML), "ship2");
if (iTest_ship == 9) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_HMS_Bounty), "ship2");
if (iTest_ship == 10) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Hooker1), "ship2");
if (iTest_ship == 11) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_brig_n1), "ship2");

}
Has the initial if statement's closing bracket in the wrong place and should look like this:

Code:
if(!REALISTIC_SHIP_PURCHASE) // = If Realistic Ship Purchase is NOT enabled
{

if (iTest_ship == 2)
{
if (iTest_ship == 1) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER), "ship2");
if (iTest_ship == 2) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship2");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_PINK), "ship2");
if (iTest_ship == 4) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER_h), "ship2");
if (iTest_ship == 5) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Galeoth_h), "ship2");
if (iTest_ship == 6) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship2");
if (iTest_ship == 7) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Sloop_Cutter1_18), "ship2");
if (iTest_ship == 8) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LuggerVML), "ship2");
if (iTest_ship == 9) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_HMS_Bounty), "ship2");
if (iTest_ship == 10) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Hooker1), "ship2");
if (iTest_ship == 11) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_brig_n1), "ship2");

}
}

I cannot stress enough that this is the way I understand it, and that if what I'm saying seems wrong, it's because it probably is. My understanding of C is spotty at best, and so far as I am aware, this is not quite the same language, so feel free to correct me if I'm way off.
 
I've fixed it, i also loaded the vanilla shiputilities file and checked to see which brackets was for which codes and after fixing them the game loads fine and the ships are been generated with both realistic ships purchase on or off. :will

Thanks guy's for your help. :onya

How it works is as follows.

This is where i was going wrong.

Code:
}
if (sti(PChar.rank) > 3)
{

The top bracket is used to close the above ships and the lower bracket goes down to.

Code:
}
if (sti(PChar.rank) > 5)
{
Which closed all the ships above it off. In my original code i had added.

Code:
		if(!REALISTIC_SHIP_PURCHASE) // = If Realistic SHIPpurchase is NOT enabled
{

Above them which ment the bracket for that line of code was been used and not the bracket that it should have been using. After moving that line of code around the mod works fine. :dance
 
I've fixed it, i also loaded the vanilla shiputilities file and checked to see which brackets was for which codes and after fixing them the game loads fine and the ships are been generated with both realistic ships purchase on or off. :will

Thanks guy's for your help. :onya

Awesome! Glad to see that we were able to help you work it out relatively quickly. Was I in the ballpark with my guess at the function of the mod?
 
I have edited the above here post to better explain what was wrong, you was right about the brackets. :onya

Yes i couldn't have done it without your help and the use of nore pad ++. thanks bud.;)
 
Basically if you turn realistic ship purchase on you can't buy Frigate's, MOW's and other war type ships. You can only buy small class 5 and 6 ships and trade ships like Fleut's, Galleons etc.

Leaving the stock settings you can buy all ships that are in COAS apart from quest ships of course.

The mod will be amde available in CMV3 patch 2. :onya
 
Basically if you turn realistic ship purchase on you can't buy Frigate's, MOW's and other war type ships. You can only buy small class 5 and 6 ships and trade ships like Fleut's, Galleons etc.

Leaving the stock settings you can buy all ships that are in COAS apart from quest ships of course.

The mod will be amde available in CMV3 patch 2. :onya
Oh. Sweet. Glad I could help with that one, because it's definitely something that needs doing. Best of luck :)
 
Doing this to both the spy glass and ships available to purchase means that people who want a more realistic experience can without having to ask or wait a for a mod to be released.
 
Congratulations, Luke! Glad to hear you got it sorted.
Notepad++ is pretty good, isn't it? :wp

I cannot stress enough that this is the way I understand it, and that if what I'm saying seems wrong, it's because it probably is. My understanding of C is spotty at best, and so far as I am aware, this is not quite the same language, so feel free to correct me if I'm way off.
It appears to me like your "spotty" understanding of C code is serving you quite well. :cheeky
 
Thanks Pieter. :onya

Yes Note pad++ is a very important tool and i will be using it from now on. :dance

Update:
So far in testing ships with the realistic ship purchase tunred on is working fine, i'm seeing ships be generated as they should. and i have encountered no problems with ships been generated at sea either. :will
 
Back
Top