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); <------------THIS LINE SHOULD RETURN
if (CheckAttribute(ship, attrib)) return ship.(attrib); // KK
return ""; // KK
}