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

Unique Ship Cannons not Firing AND Vanderdecken Buyable Steamships

I found the code that causes this problem. It's actually NOT what I posted above, though it does look very similar.
It's in PROGRAM\SEA_AI\AIShip.c:
Code:
void Ship_SetCannonQtyByCrew(ref rCharacter)
{
//bool ismch = sti(rCharacter.index) == GetMainCharacterIndex();
if(!GetCannonQuantity(&rCharacter)) return;
aref arship; makearef(arship, rCharacter.ship);
if (bRealBattleInterface == false && GetCharacterIndex(rCharacter.id) == GetMainCharacterIndex()) Event("evntUpdateCannonInfo"); // KK

// LDH set min crew ratio to number of crew actually required to load one broadside - 12May09 -->
ref	rCannon = GetCannonByType(sti(rCharacter.Ship.Cannons.Type));
float CrewPerGun = stf(rCannon.caliber);
if (rCannon.type == CANNON_NAME_LONG)
CrewPerGun /= 2.0;	// 12 pounder takes 6 crew, for example
else
CrewPerGun /= 6.0;	// carronades take fewer crew and are normally twice the caliber of the long guns they replace
// Note that if the player doesn't have USE_REAL_CANNONS set, the CrewPerGun is divided by 6 as well
CrewPerGun = fclamp(1.0, 10.0, CrewPerGun);		// gun crew no less than 1 and no more than 10

int iCanQty = GetCannonQuantity(&rCharacter);
float CrewRequired = CrewPerGun * iCanQty;
CrewRequired /= 2.0;		// We're only loading one broadside at a time.
if (CrewRequired < 1) CrewRequired = 1;

int CrewQuantity  = GetCrewQuantity(rCharacter);
if (USE_MINSAILCREW)
{
int MinSailCrew = GetCharacterShipHP(rCharacter)/100;	// crew needed for sailing, intentionally not using mininum crew here
if (MinSailCrew == 100000/100) MinSailCrew = 100;		// Black Pearl is a special case
CrewQuantity -= MinSailCrew;
}
if (CrewQuantity < CrewPerGun) CrewQuantity = CrewPerGun;		// detail one gun crew from the MinSailCrew
There's actually code in place there to PREVENT stuff like this happening for the Pearl and other ships that have 100000 HP points.
However, the randomization going on at Vanderdecken shipyard prevents this code from doing what it should, therefore introducing our problem.

There's two ways to fix this:

1. Change this code so that ANY ship with excessive HP values (even if it's not exactly 1000000) is "exempt" of the crew requirement.
This will be the easy way, since we can instantly do this.

2. Find the code that randomizes the Vanderdecken ship stats.
This'll be tricky, because I'm not sure where to search...
 
2. Find the code that randomizes the Vanderdecken ship stats.
This'll be tricky, because I'm not sure where to search...
Find it, I did! PROGRAM\Ships\ships.c in the FillShipsList() function.
Find:
Code:
arSetRandomStatsToShip(curship, i, shipnation);
Replace with:
Code:
		if (!CheckAttribute(rShip, "unique")) //if ship is not unique, do modify stats
arSetRandomStatsToShip(curship, i, shipnation);
else
curship.stats.nation = shipnation;
Result: NO more stats modification, therefore the cannon-fire code remains working as intended and all cannons will fire.
DO keep the cursed ships at 1000000 HP for this!

Recommendation: In PROGRAM\SEA_AI\AIShip.c and PROGRAM\SEA_AI\AICannon.c find:
Code:
if (MinSailCrew == 100000/100) MinSailCrew = 100;		// Black Pearl is a special case
Replace with:
Code:
if (MinSailCrew >= 100000/100) MinSailCrew = 100;		// Cursed ships are a special case
This ensures that ships with higher HP values are also safe from the only-one-cannon-fires bug.
Otherwise you could trigger this bug again when upgrading your super-ship at a shipyard. :facepalm
 
I vote option one- I like easy solutions, especially when they work! :onya
At least this way I assume that all the "cursed" ships' HP values can remain as the default, without issue.

EDIT:
Dammit, late again!
 
Sorry 'bout that. :razz


Find attached all files required for this fix.
KB_routines.c goes in PROGRAM
Ships.c goes in PROGRAM\Ships
AIShip.c and AICannon.c go in PROGRAM\SEA_AI

This fixes:
1. Errors related to upgrading "unique" ships at the shipyards (ship doesn't manoeuvre anymore / gets a black HP bar)
2. Randomization of "unique" ship stats at Vanderdecken (and theoretically all other) shipyards
3. Increasing the HP value of cursed ships above 1000000

Tests have confirmed that this results in:
1. All cannons firing on ships given to the player through console
2. All cannons firing on ships bought from Vanderdecken
3. All cannons firing on these ships even after applying upgrades
4. All cannons firing on cursed ships when encountered as enemy in storylines (checked with the Black Pearl at Martinique)
 
I'd love to take this opportunity to say "It works perfectly now..."

BUT I CAN'T!! :modding :modding

Erm, the Cursed Pearl and Cursed Caravel still don't fire correctly...
...BUT the Dutchman variants DO.

Randomization HAS stopped (except for the Cursed Corvette... which apparently isn't 'unique')
I've used all the new files and reverted all the HP values to the originals... so WHAT'S WRONG NOW?

I still haven't tested the storyline encounters, but for now I'll take your word for it...
Nor have I tried upgrading, nor have I used the console, so I'll check those next.

It's never SIMPLE is it?!
 
Make sure that all cursed ships have the following in their ships_init.c entries:
1. A line "refShip.unique = true;" - this prevents randomization of their stats that could mess up their HP value
2. A line "refShip.HP = 100000;" - higher is OK, somewhat lower isn't, because otherwise 1% of this is required in crew to fire all cannons

I noticed that some cursed ships didn't have the above properly set.
Doing so and performing a reinit (F11) should take care of the last issues.

For the Cursed Pearl, did you do this in a savegame where you decreased the HP originally?
Because that's one I tested and she definitly works good now.

Edit: Seems like you might even need to start a new game for the ships at Vanderdecken to be fully fixed.
Edit 2: Confirmed. The Cursed Corvette was refusing to work properly in my Vanderdecken savegame, but after starting a new game, she's all good.
 
Replaced all 6 files, and a newly purchased Dutchman ("Cursed Galleon" variant) works as advertised. However, trying to add the "Flush Decked" upgrade results in the game crashing. Intending to test other ships shortly.
 
Relating to the pearl attacking you in the storyline, I will take a look at this code to make the pearl friendly again ;)
 
Thanks Maggee; that's one less thing for me to worry about then. :cheeky

I'll check that "Flush Deck" upgrade; admittedly I didn't check that one just yet...
 
Replaced all 6 files, and a newly purchased Dutchman ("Cursed Galleon" variant) works as advertised. However, trying to add the "Flush Decked" upgrade results in the game crashing. Intending to test other ships shortly.
Confirmed and fixed. Put attached file in your PROGRAM folder and it should be all good. No new game required. :doff
 
I think all original issues are fixed now; all that's left is stuff related to the ships_init.c file.

Since I'm using Oberleutnant's file, some of the issues found are related to his modifications and no longer to the original issues reported.
Therefore, I split discussion on all ships_init.c related issues to it's own thread: http://forum.piratesahoy.net//topic/16145-additional-ship-balancing/
 
A lot of thanks to Experienced Captain and Derkylos, without whom these issues would've remained unfixed for a long time to come.
I would also like to offer my apologies for being quite wrong on quite a lot of things throughout the process of working on this.
I sure know better now than to not listen properly to your very accurate reports. :eek:ops2
 
Hello everybody,
I also had the problem with my game crashing after buying the Steamfrigate, but it is fixed with the ship_init.c from Pieter. Thanks!

I did not know the bugs with the unique ship because I have never bought them. (I didn't even know that one of them is the Flying Dutchman) I will buy some and check whether the problems with the cannons and the crew occur. And afterwards I will try the fixes.

None of the ships from Vanderdecken has 100k HP the highest is around 60000.
 
Back
Top