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

Fixed Hull Upgrade Does Not Increment Cannon Calibre

Mere_Mortal

Free Like a Radical
Storm Modder
The code for the reinforced hull upgrade is supposed to boost the ship’s cannon calibre by one, but this does not happen.

After checking my character’s stats I can see that the maximum calibre under MainChar.Ship.MaxCaliber is set to 32-pounders, even though the ship is a Heavy Pinnace with a maximum of 24lb. What I think is happening here is that the upgrade is boosting that attribute every time it is purchased, but it is never reset whenever a new ship is bought or swapped to. In fact, it might be that this attribute is only ever used by that upgrade; I believe that GetMaximumCaliber() looks at the base ship and returns the default calibre. This attribute should be set properly whenever a character changes ship so that it can be referenced in a correct manner. Whether or not it is appropriate for the hull upgrade to boost the calibre in the first place is for another topic; what matters here is that the attribute is essentially broken.
 
Last edited:
Code:
int GetMaximumCaliber(ref refCharacter)
{
   int nShipType = GetCharacterShipType(refCharacter);
   if (nShipType <0 || nShipType >= SHIP_TYPES_QUANTITY) { return 0; } // PB: Prevent CTDs
   ref rShip = GetShipByType(nShipType);
   aref arship; makearef(arship, refCharacter.ship); // PRS3
   return sti(GetLocalShipAttrib(arship, rShip,"MaxCaliber")); // PRS3
}
And:
Code:
string GetLocalShipAttrib(aref chrship, ref ship, string attrib) //pass this the chr and the shipstypes[] entry and the attribute name. Will return local version if there.
{
   //originally written to use a string; should work ok without it.
   //string tmpstr;
   //tmpstr = ship.(attrib);
   // NK special handling for cannon qty 05-04-18 -->
   if(attrib == "CurCanQty")
   {
// KK -->
     if (CheckAttribute(chrship, "Cannons.Type") == true && sti(chrship.Cannons.Type) == CANNON_TYPE_NONECANNON) return "0";
     if (CheckAttribute(chrship,"Cannons.Borts.cannonf.qty") && CheckAttribute(chrship,"Cannons.Borts.cannonb.qty") && CheckAttribute(chrship,"Cannons.Borts.cannonl.qty") && CheckAttribute(chrship,"Cannons.Borts.cannonr.qty"))
       return "" + (sti(chrship.Cannons.Borts.cannonf.qty) + sti(chrship.Cannons.Borts.cannonb.qty) + sti(chrship.Cannons.Borts.cannonl.qty) + sti(chrship.Cannons.Borts.cannonr.qty));
     else
       return GetLocalShipAttrib(&chrship, &ship, "CannonsQuantity");
     // TIH <-- empty cannons bug fix
// <-- KK
   }
   if(attrib == "MaxCanQty")
   {
     int fullqty = sti(GetLocalShipAttrib(&chrship, &ship, "Cannons.Borts.cannonf.qty"));
     fullqty += sti(GetLocalShipAttrib(&chrship, &ship, "Cannons.Borts.cannonb.qty"));
     fullqty += sti(GetLocalShipAttrib(&chrship, &ship, "Cannons.Borts.cannonl.qty"));
     fullqty += sti(GetLocalShipAttrib(&chrship, &ship, "Cannons.Borts.cannonr.qty"));
     return ""+fullqty;
   }
   // NK <--
   if(CheckAttribute(chrship,"stats."+attrib)) return chrship.stats.(attrib);
   if (CheckAttribute(ship, attrib)) return ship.(attrib); // KK
   return ""; // KK
}

Looks like the player ship itself is not being checked for "MaxCaliber".
 
Looks like the player ship itself is not being checked for "MaxCaliber".
That’s probably just as well since the attribute is never reset after changing ship.

If it were to be checked then no doubt they’d all eventually have 32-pounders. :shock

So yeah, I think the code which sets the ship attributes needs to be looked at as well?
 
Actually, it might just be stored in the wrong spot.
Apparently it should look at ch.ship.STATS.MaxCaliber .

Maybe replace this:
Code:
if(cal != -1) { cal=cal + inc; _char.ship.maxcaliber= Cannon_Calibers[cal]; }
With this:
Code:
if(cal != -1) { cal=cal + inc; _char.ship.stats.maxcaliber= Cannon_Calibers[cal]; }

Not sure what that will do, but it might work.
I assume that those "stats" are reset when you change ships.
 
That actually worked. :woot Thing is, if the upgrade has already been purchased then it’s too late. :(
 
Does it get reset when you get another ship again?
The attribute holds for the individual ship. I just bought a Sloop for a companion with 6lb cannons, upgraded to 9lb and then swapped to it. After swapping back to my Heavy Pinnace, that itself did not change its 24lb calibre and the Sloop kept the 9lb maximum.
Can you sell it and then buy it again?
No, it’s an irreversible upgrade.
 
Back
Top