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

Replacing Cannons on bugged ships

atpeace

Landlubber
Hey all,

First of all great work on the mod all you modders! truly excellent work.

I have a problem I have found and read that it a known bug on some non stock ships that cannons can't be removed and they duplicate, they also can't be fixed. Now I have just swapped out of ships with this problem until I was happy with a ship that didn't suffer from the bug.

But now I am a bit stuck, after a good many hours of play I finally capped the Flying Dutchman and am more than happy with the ship except that it too suffers from the cannon bug.

Is there a way I can fix this for my installation. I appreciate that a patch is forthcoming that will fix this but would like to do it now :)

As I understand I will have to edit some text file, ships_init.c? then re init, (blank button on options screen (I do definitely have 3.1.5)) then use the debug to grant myself an unbugged Flying Dutchman, swap into it, sink the old and sail away. Is it possible someone can give me the details of this pretty pretty please?
 
Hey bud, not sure if this will fix the problem but these are the files that had problems. These files are only compatable with CMV3.1.5.

Use the reinit button and get yourself a new Flying Dutchman. I guess the ship is the none quest version?
 
Hey bud, not sure if this will fix the problem but these are the files that had problems. These files are only compatable with CMV3.1.5.

Use the reinit button and get yourself a new Flying Dutchman. I guess the ship is the none quest version?

The ship was the quest version, as in I capped it after completing the Ghost Ship Quest. Took some hours getting myself a big enough ship with big enough crew to actually do that.

So I tried the files. Partial success.

I copied the files to the correct locations, changed the names of the old files as to not overwrite.
I edited

ShipUtilities.c ->
SetShipyardStore ->

added the line:
FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_Flyingdutchman), "ship99");

and

Ships_init.c ->
makeref(refShip,ShipsTypes[SHIP_FLYINGDUTCHMAN]); ->

edited the cost price to 1
refShip.Price = 1;

Then I "reinit"

Then went to the shipyard, bought a flying dutchman

found I could change the cannons; yay!

got in the ship, sailed around a bit, then found I could no longer change the cannons. It was just as before. Seems that just entering the ship caused the bug to reappear. Any ideas? I am investigating further.
 
Research completed and fix found.

I removed the files that you posted, cannons.h, cannons.c, cannons_init.c, shipsutilities.c and reverted back to the original 3.1.5 copies.
I retuned the cannon layout for FLYINGDUTCHMAN in ships_init.c back to the original stock cannon layout :
Code:
refShip.CannonsQuantity        = 60;
refShip.rcannon                 = 24;
refShip.lcannon                 = 24;
refShip.fcannon                 = 4;
refShip.bcannon                 = 8;
I modded the price too and ShipUtilites.c so that it could be bought in the shipyard
reinit
bought the flying dutchman got in it and fired shots and found I could change the cannons, fix broken and do as you would expect.

With the files you provided ontop of stock + mod 3.1.5 I found that with a new flying dutchman I could only change the cannons BEFORE I actually entered the ship, upon entering and thereafter you could no longer change the left and right cannons, you could change the front no problem and there are no rear.

Conclusion

the change of layout of the cannons causes this bug, there must be somewhere else other than "ships_init.c" the cannon layout must be updated if a modded layout is wanted.
 
Good find bud. :onya

So changing the ships cannon quantity courses the bug, so that will explain the other ships having this bug too since many had there cannon quantity reduced due to them not actually having the amount of gun ports as the model was said to have when been ported over from POTC. I believe the Fleut and Pinnace's was the biggest net looses because of that due to them having porthold painted on as they would have done to make them look from a distance as if they was well armed.

Looks like the ships will have to be looked at again and fix those that have been changed as for files that effect ships cannon quanitity changes, i have a funny feeling that is because of the ship models locators and not a file which would mean redoing many of the ships locators to only point to those guns that are actually there rather than the amount it say's are there.

If that is the case then all ships that have been edited will have to be reset to there original settings and tested. :modding
 
Hi. I read your fix atpeace but I can't follow the instructions, I'm not good at this. The same problem happens with my ship, the Surprise. Can you help me with editing the files for the surprise? Where is the ships_init.c file? I can't find it in INI.... ;__;


EDIT: ok I got it, I found it in the program file, and edit the cannons, btw the waterline for the surprise may need fixing, (set it =o,o; perhaps?
So now I need a bit of help editing it to the shipyard...

EDIT2:eek:k.......found the other file, added the line for the surprise in SetShipyardStore (quite randomly though).
Went into the game nothing happens..... ;__; What is this "reinit"?
 
The waterline isn't that hard to fix and this is where the reinit button comes in. It will be a good idea to save your game (in less your already using cheats) if you are not then save your game because you'll need to use the cheats in less you have a lot of money already.

1. To fix the waterline go into Program\Ships == Ships_init.C now press F3 to open a search box, enter into the search box Surprise and hit ok. Scroll down in the section for the Surprise till you see this line of code.
Code:
refship.WaterLine			= 0.2;

(This value maybe different than your, thats because many ships waterlines have already been fixed) Increasing the value ie from 0.2 to 1.0 will make the ship sit higher in the water, if the value is 0.0 and the ship is sitting higher then you can add - before the value so you could put -0.2. When you have made a change to the value save the file or exit and save then load your game (you can make changes without closing the game but need to play in windowed mode). Now load your game and hit the reinit button in options, this will update the game to the new changes in ships_init. These changes do not effect your ship so you will need to aquire a new Surprise by either using the cheats or buying one or capturing one. Using the cheats will be best keep making the changes to the waterline till your happy each change to the waterline requires the reinit button to be pushed and a new updated Surprise to be bourght. When you have her fixed load your game again and get a new Surprise.

2. shipsutilities.c i think you mean, the ships listed in each rand is so the game knows at what rank you need to be at before the game will generate the ship at the shipyard. Any ships that are not listed there will never be randomly generated at shipyards but will be generated at sea apart from the quest ships of course which are excluded from that. The more rands a ship is listed in (on once per rand) the more often that ship will be likely generated at sea and at shipyards.

Hope this helps. :onya
 
EDIT2:eek:k.......found the other file, added the line for the surprise in SetShipyardStore (quite randomly though).
Went into the game nothing happens..... ;__; What is this "reinit"?

reinit is short for reinitialise and it is the blank right hand button in the options menu on CM3.1.5, It causes the whatever_init.c files to be read again and applied to the game your playing. Please note that items in ship chests are removed when you do this though I have found no other negative effects when pressing this button.

Seeing as the SURPRISE was not in stock COAS I would not know what the correct cannon layout for that model would be and therefore unable to suggest what values you should use for CannonsQuantity and the amounts for every side. I can only suggest a laborious trial and error approach. One thing is clear if you can remove cannons without them duplicating at sea then the cannon number for that particular side is correct.

Using cheats would be quicker than buying from the shipyard but I don't know how this is done. Indeed there would be many ways to test mods for a ship I just didn't know them and saw a possibility in the shipyard to get a new reinited ship. I only started looking at this stuff yesterday. If you want to do the shipyard way then change the cost of the surprise to 1 in ships_init .c and add this line to SetShipyardStore

Code:
FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_SURPRISE), "ship99");

below

Code:
FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_TARTANE), "ship1");

remember to backup any file you edit so you can go back if you break something. Once you are happy with your mods change the price back and remove the line from SetShipyardStore
 
I don't use cheats. I did what you said, pressed reinit after loading the game like 150-200 times, refreshing the ships in the shipyard. It never appeared.....
 
Carefull how you put the ships in the rands because they should all have the same final value as the ships in that rand. Example.

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

Now if i was to add the Surprise to this and not change anything the code would look at follows.

Code:
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");
if (iTest_ship == 3) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_SURPRISE), "ship141");

The code should look like this.

Code:
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");
if (iTest_ship == 4) FillShipParamShipyard(NPChar, GenerateStoreShip(SHIP_SURPRISE), "ship2");

The first value is what ever comes next ie, 1, 2, 3 etc and the final value in this case 2 is the ships group number for that rand. If these do not mactch up right then the ship will not be generated either at shipyards or at sea. At sea you would get a message like ship XXX could not be generated message or the game would crash depending on how many ships of that type was been generated at the time.

Yep the reinit button is the far right with no text in, don't know why it has no text though because that was fixed for CMV3.1.5. :shrug
 
I don't use cheats. I did what you said, pressed reinit after loading the game like 150-200 times, refreshing the ships in the shipyard. It never appeared.....

I don't know what you've done wrong, but I tested this and works fine with me. This modded ShipsUtilites.c will enable you to buy every ship in the game from the shipyard. Just copy ShipsUtilites.c into "Age of Pirates 2\Program\scripts" load the game, load your save and push the re-init button then check the shipyard and you should see them all there. Included is the original from CMV3.1.5 to revert to when done.

View attachment ShipsUtilites.zip
 
First of all I want to thank you both for your great help. I just realized just now that I was messing in a folder called "script" and not "scripts" (did it even existed before there? I guess I'm losing it after so many hours)......And I was beginning to doubt my mental state....... Anyway, your fix works perfect, I fixed the guns (42 instead of 32) and the waterline. It is beyond perfect.
Yet, I have a feeling though, that we will meet again in the future.....lol
 
Looks like the ships will have to be looked at again and fix those that have been changed as for files that effect ships cannon quanitity changes, i have a funny feeling that is because of the ship models locators and not a file which would mean redoing many of the ships locators to only point to those guns that are actually there rather than the amount it say's are there.

Paged through the remove code

starting in interface\ships.c
CanonsRemoveAll()
-SetCannonsToBort()
--GetBortCannonsQty()
---GetBortIntactCannonsNum()
---logs to trace "ship XX, have invalid cannons on bort. cannonX XX, but need: XX"
goes on to add stock to inventory on remove or replace.

It would appear that the actual cannons from the model are listed for individual damage the same as a fort. These cannons have to match the ships_init.c else GetBortIntactCannonsNum() returns how many should be there according to the damage stats. setcannonstobort then messes things up in the if's comparison afterwards.

Sadly the readout of the cannon numbers is taken from the ships_init.c subtracting dead cannons (0 on bugged ships due to the fault in GetBortIntactCannonsNum)
The ODS of cannons when in a ship reads out direct from the cannon damage stats ignoring the ships_init.c value completely.
 
First of all I want to thank you both for your great help. I just realized just now that I was messing in a folder called "script" and not "scripts" (did it even existed before there? I guess I'm losing it after so many hours)......And I was beginning to doubt my mental state....... Anyway, your fix works perfect, I fixed the guns (42 instead of 32) and the waterline. It is beyond perfect.
Yet, I have a feeling though, that we will meet again in the future.....lol

Good to hear bud, you should have 2 copies of the scripts folder. That was a error in CMV3.1.5 and one i didn'r know about till some ships wasn't been generated. The folder marked Script which should only have the file shiputilities/C in needs that file moving to the folder called Scripts and then the folder Script deleting because the game uses Scripts folder to run those files from.

If you are planning on keeping the file atpeace has uploaded for you and not revert back to the CMV3.1.5 copy then you may aswell delete the folder Script and not bother copying the shipsutilities file over.

Looks like the ships will have to be looked at again and fix those that have been changed as for files that effect ships cannon quanitity changes, i have a funny feeling that is because of the ship models locators and not a file which would mean redoing many of the ships locators to only point to those guns that are actually there rather than the amount it say's are there.

Paged through the remove code

starting in interface\ships.c
CanonsRemoveAll()
-SetCannonsToBort()
--GetBortCannonsQty()
---GetBortIntactCannonsNum()
---logs to trace "ship XX, have invalid cannons on bort. cannonX XX, but need: XX"
goes on to add stock to inventory on remove or replace.

It would appear that the actual cannons from the model are listed for individual damage the same as a fort. These cannons have to match the ships_init.c else GetBortIntactCannonsNum() returns how many should be there according to the damage stats. setcannonstobort then messes things up in the if's comparison afterwards.

Sadly the readout of the cannon numbers is taken from the ships_init.c subtracting dead cannons (0 on bugged ships due to the fault in GetBortIntactCannonsNum)
The ODS of cannons when in a ship reads out direct from the cannon damage stats ignoring the ships_init.c value completely.

Thats the problem, there is no file (as of yet found) that actually tells you how many cannons the ship should have other than the Ships_init and since i ported many ships over there was only the ships_init file that had any references to amount of cannons mounted on ships. Which is why i said i have this bad feeling its the locators for ship models that the game is using. I don't know why (if this is whats happoening) why the game would be setup to read the ships in that kind of way because it limits what you can do without editing the ships.
 
Thats the problem, there is no file (as of yet found) that actually tells you how many cannons the ship should have other than the Ships_init and since i ported many ships over there was only the ships_init file that had any references to amount of cannons mounted on ships. Which is why i said i have this bad feeling its the locators for ship models that the game is using. I don't know why (if this is whats happoening) why the game would be setup to read the ships in that kind of way because it limits what you can do without editing the ships.

Ok I understand what you mean by locators now. When I get access to the modelling tools I'll investigate further. I would understand the reading of the locators to determine cannon numbers because if they were ignored there is no other information on the location of that cannon when fired/dead/removed and these factors need to be simulated to the player. The ships_init.c would be a quick way to display the cannon numbers without loading the model for use in shipyards.

What viewer/tool would I need to see the model / cannon info for this? I guess Akella's Mod Tools and I hope I do not need Maya also...?
 
I don't know about the tools because i haven't looked into modelling, but hopefully when you do get those tools you can fix some of these ships. The best place to ask about the tools would be here. :onya
 
I don't know about the tools because i haven't looked into modelling, but hopefully when you do get those tools you can fix some of these ships. The best place to ask about the tools would be here. :onya

Ok, you can view the model using gm_viewer point the texture texture directory and turn on locator labels.
Make a note of the label names for cannons that are not wanted.
In the flying dutchman they are (to match ships_init.c in CM3.15)
Rear:_27,_28,_29,_30,_57,_58,_59,_60
Left:_14
Right:_44

using Inez Dias' Tool
Load the model
View the locators
Remove the listed locators,apply
save the model (model saved with "NAME_x.gm ",backup the original and rename the new one)

Then get the ship and test.
Tests found with the removal of these locators the remove cannon function no longer bugs out.

flying dutchman that will work with cm3.1.5

yay!
 
Back
Top