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

CMV3.1.5 ShipsUtilities.c

atpeace

Landlubber
Looking at code in CMV3.1.5 ShipsUtilities.c there seems to be some really odd code here.

Function SetShipyardStore

Code:
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");	
}

iTest_ship == 1 so SHIP_Gunboat and SHIP_BERMSLOOP will never be produced

same again for

Code:
if (iTest_ship == 2)
{
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");	
}

Only SHIP_Cutter will be produced

another
Code:
iTest_ship = rand(2);
if (iTest_ship == 1) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship3");
if (iTest_ship == 2) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship3");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LuggerVML), "ship3");
if (iTest_ship == 4)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_WAR_TARTANE), "ship3");
if (iTest_ship == 5)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Gunboat), "ship3");
if (iTest_ship == 6) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BERMSLOOP), "ship3");
if (iTest_ship == 7) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_EDINBURG), "ship3");
if (iTest_ship == 8) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Cutter), "ship3");
if (iTest_ship == 9) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER), "ship3");
if (iTest_ship == 10) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_PINK), "ship3");
if (iTest_ship == 11) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_LUGGER_h), "ship3");
if (iTest_ship == 12) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Galeoth_h), "ship3");
if (iTest_ship == 13) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Ketch), "ship3");
if (iTest_ship == 14) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_YACHT), "ship3");
if (iTest_ship == 15) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_BOUNTY), "ship3");
if (iTest_ship == 16) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_HMS_Bounty), "ship3");

Code:
iTest_ship = rand(2);
means iTest_ship will be either 0,1 or 2 meaning anything below

Code:
if (iTest_ship == 4)FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_WAR_TARTANE), "ship3");
is irrelevant and will never be generated.

and there are cases of iTest_ship = rand(70); but then maximum check is at (iTest_ship == 28).

am I missing something?

Attached is the function as I guess it was intended.
View attachment codesnip.txt
 
Have you tested the game with these changes?

Yes; here is a comparison for a lv 25 character. (19 and over gets all possible anyway)

code to output what ships are added for ShipsUtilites.c
Code:
int GenerateStoreShip(int iBaseType)
{
int iShip = GenerateShip(iBaseType, 0); // ÷åñòíûé 

if (iShip == -1)
{
return SHIP_NOTUSED;
}

ref rRealShip = GetRealShip(iShip);
rRealShip.StoreShip = true;  // êîðàëü íà âåðôè, òðåòñÿ îòäåëüíûì ìåòîäîì
//atpeace edit
ref refShip
makeref(refShip,ShipsTypes[iBaseType]);
trace("Adding ship to store: "+refShip.Name);
//end
return iShip;  
}

You need traces files on in engine.ini
tracefiles = 1
tracefilesoff = 0

output in compile.log after reinit and going to the shipyard to buy for CMV3.1.5 (5 tests)
Code:
test 1
------
Adding ship to store: Tartane
ship2
Adding ship to store: WarTartane
ship3
Adding ship to store: Bermsloop
ship4
Adding ship to store: Pink
ship5
Adding ship to store: Galeoth_h
ship6 (none)
ship8
Adding ship to store: Barque
ship9
Adding ship to store: Sloop
ship10
Adding ship to store: Brig
ship11
Adding ship to store: ColonialSchooner
ship12
Adding ship to store: Barkentine
ship13
Adding ship to store: Caravel
ship14 (none)
ship15
Adding ship to store: PO_Fleut50
ship141 (none)
ship151
Adding ship to store: Galeon_h
ship16 (none)
ship17 (none)

test 2
------

Adding ship to store: Tartane
ship2
Adding ship to store: Cutter
ship3
Adding ship to store: Cutter
ship4
Adding ship to store: Lugger
ship5
Adding ship to store: Lugger_h
ship6
Adding ship to store: Barque
ship8
Adding ship to store: Sloop_Cutter1_18
ship9
Adding ship to store: SchoonerXebec
ship10
Adding ship to store: Interceptor
ship11 (none)
ship12
Adding ship to store: Interceptor
ship13 (none)
ship14 (none)
ship15 (none)
ship141 (none)
ship151 (none)
ship16 (none)
ship17 (none)

test 3
------

Adding ship to store: Tartane
ship2
Adding ship to store: WarTartane
ship3
Adding ship to store: Bermsloop
ship4
Adding ship to store: Lugger_h
ship5
Adding ship to store: Pink
ship6
Adding ship to store: Sloop_Cutter1_18
ship8
Adding ship to store: Sloop_Cutter1_18
ship9
Adding ship to store: Sloop_Cutter1_18
ship10
Adding ship to store: Barkentine
ship11 (none)
ship12 (none)
ship13
Adding ship to store: XebecAS
ship14
Adding ship to store: FleutOfWar34G
ship15 (none)
ship141 (none)
ship151
Adding ship to store: Greyhound
ship16
Adding ship to store: Galeon_h
ship17 (none)

test 4
------

Adding ship to store: Tartane
ship2
Adding ship to store: WarTartane
ship3
Adding ship to store: Cutter
ship4
Adding ship to store: Pink
ship5
Adding ship to store: Galeoth_h
ship6
Adding ship to store: Sloop
ship8
Adding ship to store: Sloop
ship9
Adding ship to store: SchoonerXebec
ship10
Adding ship to store: Brigantine
ship11
Adding ship to store: Pinnace
ship12
Adding ship to store: BattleXebec
ship13
Adding ship to store: FleutOfWar
ship14 (none)
ship15
Adding ship to store: Pinnace3_50
ship141
Adding ship to store: XebecAS
ship151 (none)
ship16 (none)
ship17 (none)

test 5
------

Adding ship to store: Tartane
ship2 (none)
ship3 (none)
ship4
Adding ship to store: Pink
ship5 (none)
ship6
Adding ship to store: Sloop
ship8
Adding ship to store: Shnyava
ship9
Adding ship to store: Sloop
ship10 (none)
ship11
Adding ship to store: Barkentine
ship12
Adding ship to store: BattleXebec
ship13
Adding ship to store: Pinnace3_50
ship14 (none)
ship15 (none)
ship141 (none)
ship151 (none)
ship16
Adding ship to store: Pinnace3_50
ship17 (none)

Many ship numbers not generated for at all
only a couple of choice for a few ship numbers

With my edit in OP you get (5 tests)
Code:
Adding ship to store: Tartane
Adding ship to store: Edinburg
Adding ship to store: Bounty
Adding ship to store: Yacht
Adding ship to store: Pink
Adding ship to store: Sloop_Cutter1_18
Adding ship to store: Sloop
Adding ship to store: Packet_Brig
Adding ship to store: Interceptor
Adding ship to store: Caravel2
Adding ship to store: Galeon_l
Adding ship to store: FleutOfWar
Adding ship to store: Greyhound
Adding ship to store: Greyhound
Adding ship to store: FleutOfWar
Adding ship to store: Galeonw
Adding ship to store: FleutOfWar
Adding ship to store: FleutOfWar
---
Adding ship to store: Tartane
Adding ship to store: Bermsloop
Adding ship to store: WarTartane
Adding ship to store: Pink
Adding ship to store: Barque
Adding ship to store: Shnyava
Adding ship to store: Hooker1
Adding ship to store: Fleut
Adding ship to store: Caravel
Adding ship to store: Pinnace11
Adding ship to store: Fleut
Adding ship to store: PO_Fleut50
Adding ship to store: FleutOfWar34G
Adding ship to store: Fleut4_50
Adding ship to store: Galeonw
Adding ship to store: Greyhound
Adding ship to store: Greyhound
Adding ship to store: Pinnace3_50
---
Adding ship to store: Tartane
Adding ship to store: WarTartane
Adding ship to store: HMS_Bounty
Adding ship to store: Lugger
Adding ship to store: Hooker1
Adding ship to store: Sloop_Cutter1_18
Adding ship to store: Sloop_Cutter1_18
Adding ship to store: BattleXebec
Adding ship to store: brig_n1
Adding ship to store: Brig3
Adding ship to store: Caravel
Adding ship to store: Fleut
Adding ship to store: Galeonw
Adding ship to store: Pinnaceofwar
Adding ship to store: TwoDecker1_47
Adding ship to store: Galeon1
Adding ship to store: Fleut
Adding ship to store: Pinnace11
---
Adding ship to store: Tartane
Adding ship to store: WarTartane
Adding ship to store: LuggerVML
Adding ship to store: Bounty
Adding ship to store: Yacht
Adding ship to store: SchoonerXebec
Adding ship to store: Brig_20_Gun1_18
Adding ship to store: Shnyava
Adding ship to store: ColonialSchooner
Adding ship to store: Pinnaceofwar
Adding ship to store: USS_Enterprise
Adding ship to store: Pinnace11
Adding ship to store: XebecAS
Adding ship to store: FleutOfWar
Adding ship to store: Fleut4_50
Adding ship to store: Pinnace3_50
Adding ship to store: Greyhound
Adding ship to store: Caravel2
---
Adding ship to store: Tartane
Adding ship to store: Edinburg
Adding ship to store: Galeoth_h
Adding ship to store: Galeoth_h
Adding ship to store: Sloop_Cutter1_18
Adding ship to store: Hooker1
Adding ship to store: Sloop
Adding ship to store: Caravel
Adding ship to store: BattleXebec
Adding ship to store: Pinnace
Adding ship to store: Caravel2
Adding ship to store: TwoDecker1_47
Adding ship to store: War_Pinnace
Adding ship to store: FleutOfWar34G
Adding ship to store: Caravel
Adding ship to store: TwoDecker1_47
Adding ship to store: Batavia2
Adding ship to store: Pinnace11
---

I guess this is what is expected. for a 19+ level char 18 ships every time from all listed; though there are duplicates which may or may not be a problem

here is a test output from the rand() function
Code:
test output for rand(10): 4
test output for rand(10): 1
test output for rand(10): 9
test output for rand(10): 6
test output for rand(10): 0
test output for rand(10): 4
test output for rand(10): 9
test output for rand(10): 4
test output for rand(10): 10
test output for rand(10): 7
test output for rand(10): 1
test output for rand(10): 0
test output for rand(10): 2
test output for rand(10): 4
test output for rand(10): 2
test output for rand(10): 0
test output for rand(10): 7
test output for rand(10): 5
test output for rand(10): 4
test output for rand(10): 0
test output for rand(10): 7
test output for rand(10): 7
test output for rand(10): 1
test output for rand(10): 8
test output for rand(10): 1
test output for rand(10): 10
test output for rand(10): 2
test output for rand(10): 4
test output for rand(10): 1
test output for rand(10): 6
test output for rand(10): 0
test output for rand(10): 5
test output for rand(10): 1
test output for rand(10): 5
test output for rand(10): 10
test output for rand(10): 6
test output for rand(10): 1
test output for rand(10): 10
test output for rand(10): 5
test output for rand(10): 3
test output for rand(10): 0
test output for rand(10): 1
test output for rand(10): 3
test output for rand(10): 9
test output for rand(10): 9
test output for rand(10): 5
test output for rand(10): 0
test output for rand(10): 0
test output for rand(10): 7
test output for rand(10): 5
test output for rand(10): 9
test output for rand(10): 7
test output for rand(10): 7
test output for rand(10): 9
test output for rand(10): 5
test output for rand(10): 6
test output for rand(10): 6
test output for rand(10): 0
test output for rand(10): 7
test output for rand(10): 5
test output for rand(10): 4
test output for rand(10): 9
test output for rand(10): 9
test output for rand(10): 4
test output for rand(10): 7
test output for rand(10): 10
test output for rand(10): 0
test output for rand(10): 9
test output for rand(10): 3
test output for rand(10): 2
test output for rand(10): 1
test output for rand(10): 5
test output for rand(10): 1
test output for rand(10): 4
test output for rand(10): 3
test output for rand(10): 4
test output for rand(10): 1
test output for rand(10): 0
test output for rand(10): 9
test output for rand(10): 1
test output for rand(10): 8
test output for rand(10): 4
test output for rand(10): 1
test output for rand(10): 8
test output for rand(10): 5
test output for rand(10): 4
test output for rand(10): 0
test output for rand(10): 0
test output for rand(10): 0
test output for rand(10): 8
test output for rand(10): 4
test output for rand(10): 5
test output for rand(10): 10
test output for rand(10): 4
test output for rand(10): 4
test output for rand(10): 4
test output for rand(10): 4
test output for rand(10): 1
test output for rand(10): 7
as you can see rand(10) generates numbers between 0 and 10

I tested buying and sailing ships.
 
So, changing the numbering fixes the generating problem? Can you post the updated ShipUtilities.c file?
 
Back
Top