• 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 Problem with gunner on deck

Just curious. When is someone an able captain?
 
It's just a toggle in internalsettings. It gives you the advantage of a gunner without having one.
Concerning the supply etc.
 
Can we call this fixed?
 
Thanks @Jack Rackham for further improving on this one! :woot

Some notes:

- In PROGRAM\reload.c you should be able to replace this:
Code:
// --> JRH
   if (CharacterHasOfficerType(rPlayer, OFFIC_TYPE_CANNONEER) || AMMOMOD_ABLECAPTAIN)
   {
     SupplyAmmo(true);
   }
// <-- JRH
With this:
Code:
  SupplyAmmo(false); // JRH
Those checks are already included in the function.

- In SupplyAmmo, I think the "pchar.got_ammo" change will return true ONLY if the 4th character in a shore party got supplied, because it is reset on each loop.
So I'd propose moving the "no" statement outside the for-loop like this:
Code:
void SupplyAmmo(bool bOverride)
{
   if(ENABLE_AMMOMOD)
   {
     ref PChar = GetMainCharacter();
     ref NPChar;
     int i, iOfficer, cc;

     string weaponID;
     aref weapon;

     bool tmpAbleRefill = false;
     bool bGotAmmo  = false;
     if (bOverride)                         { tmpAbleRefill = true; }
     if (CharacterHasOfficerType(pchar, OFFIC_TYPE_CANNONEER))   { tmpAbleRefill = true; }
     if (AMMOMOD_ABLECAPTAIN)                   { tmpAbleRefill = true; }

     if (tmpAbleRefill)
     {
       //PLAYER AND OFFICERS
       for(i = 0; i < 4; i++)
       {
         iOfficer = GetOfficersIndex(PChar, i);
         if(iOfficer < 0) continue;
         NPChar = GetCharacter(iOfficer);

         weaponID = GetCharacterEquipByGroup(NPChar,GUN_ITEM_TYPE);
         if(weaponID != "")
         {
           Items_FindItem(weaponID, &weapon);
           if(CheckAttribute(weapon, "shottype"))
           {
             if(weapon.shottype == "pg2" || weapon.shottype == "pg" || weapon.shottype == "mb" || weapon.shottype == "pb" || weapon.shottype == "pb2")
             {
               int OpriorGP = GetCharacterItem(NPChar,"gunpowder");
               int OpriorPB = GetCharacterItem(NPChar,"pistolbullets");
               int OpriorPG = GetCharacterItem(NPChar,"pistolgrapes");
               int OpriorMB = GetCharacterItem(NPChar,"musketbullets");

               DeleteAttribute(NPChar,"Items.gunpowder");
               DeleteAttribute(NPChar,"Items.pistolbullets");
               DeleteAttribute(NPChar,"Items.pistolgrapes");
               DeleteAttribute(NPChar,"Items.musketbullets");

               if(CheckCharacterItem(NPChar,"powderbarrel")) { TakeNItems(NPChar,"gunpowder", (4 * MAX_GUNPOWDER)); }
               else
               {
                 if(CheckCharacterItem(NPChar,"powderflask")) { TakeNItems(NPChar,"gunpowder", (2 * MAX_GUNPOWDER)); }
                 else { TakeNItems(NPChar,"gunpowder", MAX_GUNPOWDER); }
               }
               if(CheckCharacterItem(NPChar,"ammobag")) { cc = (4 * MAX_SHOTS); }
               else
               {
                 if(CheckCharacterItem(NPChar,"ammopouch")) { cc = (2 * MAX_SHOTS); }
                 else { cc = MAX_SHOTS; }
               }
               //LogIt("cc = " + cc);
               if(cc > OpriorGP)                                                     { bGotAmmo = true; }

               if(weapon.shottype == "pg2" || weapon.shottype == "pg")   { TakeNItems(NPChar,"pistolgrapes" , cc);  if (cc > OpriorPG)   { bGotAmmo = true; } }   
               if(weapon.shottype == "mb")                { TakeNItems(NPChar,"musketbullets", cc/2);  if (cc > OpriorMB)   { bGotAmmo = true; } }
               if(weapon.shottype == "pb2" || weapon.shottype == "pb")   { TakeNItems(NPChar,"pistolbullets", cc);  if (cc > OpriorPB)   { bGotAmmo = true; } }
             }
           }
         }
       }
       if(bGotAmmo)
       {
         LogIt(TranslateString("","Your shore party has been resupplied with Ammunition!"));
         PlaySound("INTERFACE\important_item.wav");
       }
     }
   }
}
Additional change in the above code is to replace the player attribute with an internal boolean (true/false) which doesn't get stored outside the function.

I hope that I correctly understood the way your code is meant to work and didn't accidentally mess anything up by making the above changes.... :oops:
 
As I remember it I couldn't get everything to work and think this extra check was needed.
(In the way I did it). Anyway thank you for simplifying it. :doff
 
Back
Top