• 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 Looting Muskets with Bayonets

No! :shock
If a character got "blademketK" equipped he probably hasn't got any gun equipped too.
So that explains why the "blademketK" section wasn't read.
Makes sense?
Beginning to make sense, yes.

What about this section then?
Code:
        if(IsEquipCharacterByItem(tmpChr, "blademketK"))
         {
           RemoveCharacterEquip(tmpChr, BLADE_ITEM_TYPE );
           TakeItemFromCharacter(tmpChr, "blademketK");
           GiveItem2Character(tmpChr, "blade_mKnife");
           EquipCharacterByItem(tmpChr, "blade_mKnife");

           GiveItem2Character(tmpChr, "pistolmket");
           EquipCharacterByItem(tmpChr, "pistolmket");

           if(weapon.model == "musket")
           {
             weapon.model = "musket_back";
             EquipCharacterByItem(tmpChr, "pistolmket");
           }
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }
You say if you have "blademketK" equipped, then probably you don't have a gun equipped.
That means that weaponID == "" and aref weapon will end up being some sort of "nothing".

Then in this section, you check if(weapon.model == "musket") which would not be the case because 'weapon' was set as nothing before.
Do I understand correctly that in the part, 'weapon' should actually be the newly equipped "pistolmket" rather than the "" you had equipped as a gun before?

In that case, I might suggest something like this instead:
Code:
        if(IsEquipCharacterByItem(tmpChr, "blademketK"))
         {
           RemoveCharacterEquip(tmpChr, BLADE_ITEM_TYPE );
           TakeItemFromCharacter(tmpChr, "blademketK");
           GiveItem2Character(tmpChr, "blade_mKnife");
           EquipCharacterByItem(tmpChr, "blade_mKnife");

           GiveItem2Character(tmpChr, "pistolmket");
           EquipCharacterByItem(tmpChr, "pistolmket");

           Items_FindItem("pistolmket", &weapon); // PB: Add this line here instead <----------------------------------
           if(weapon.model == "musket")
           {
             weapon.model = "musket_back";
             EquipCharacterByItem(tmpChr, "pistolmket");
           }
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }
If so, then something like this may be a safer solution:
Code:
#event_handler("mguns_reset_check", "reset_check_mguns");
void reset_check_mguns()
{
   ref PChar = GetMainCharacter();
   aref attack = GetEventData();
   ref tmpChr;
   float GunCurCharge;
   
   for (int i = 0; i < LAi_numloginedcharacters; i++)
   {
     int index = LAi_loginedcharacters[i];
     if (index >= 0)
     {
       makeref(tmpChr, Characters[index]);

       string weaponID = GetCharacterEquipByGroup(tmpChr,GUN_ITEM_TYPE);
       aref weapon;

       if (!LAi_IsDead(tmpChr) && !LAi_IsFightMode(tmpChr))
       {
         GunCurCharge = LAi_GetCharacterRelCharge(tmpChr); // Levis
         if(IsEquipCharacterByItem(tmpChr, "pistolmket"))
         {
           if(CheckCharacterItem(tmpChr, "blade_mKnife"))
           {
             if(!IsEquipCharacterByItem(tmpChr, "blade_mKnife")) EquipCharacterByItem(tmpChr, "blade_mKnife");
           }

           Items_FindItem("pistolmket", &weapon);
           weapon.model = "musket_back";
           EquipCharacterByItem(tmpChr, "pistolmket");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "blademketK"))
         {
           RemoveCharacterEquip(tmpChr, BLADE_ITEM_TYPE );
           TakeItemFromCharacter(tmpChr, "blademketK");
           GiveItem2Character(tmpChr, "blade_mKnife");
           EquipCharacterByItem(tmpChr, "blade_mKnife");

           GiveItem2Character(tmpChr, "pistolmket");
           EquipCharacterByItem(tmpChr, "pistolmket");

           Items_FindItem("pistolmket", &weapon);
           if(weapon.model == "musket")
           {
             weapon.model = "musket_back";
             EquipCharacterByItem(tmpChr, "pistolmket");
           }
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "pistolmtoon"))
         {
           Items_FindItem("pistolmtoon", &weapon);
           weapon.model = "musketoon_back";
           EquipCharacterByItem(tmpChr, "pistolmtoon");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "pistolmketB"))
         {
           Items_FindItem("pistolmketB", &weapon);
           weapon.model = "musketB_back";
           EquipCharacterByItem(tmpChr, "pistolmketB");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "blademketB"))
         {
           TakeItemFromCharacter(tmpChr, "blademketB");
           if(!CheckCharacterItem(tmpChr, "bladeX4")) GiveItem2Character(tmpChr, "bladeX4");
           EquipCharacterByItem(tmpChr, "bladeX4");

           GiveItem2Character(tmpChr, "pistolmketB");
           EquipCharacterByItem(tmpChr, "pistolmketB");

           Items_FindItem("pistolmketB", &weapon);
           if(weapon.model == "musketB")
           {
             weapon.model = "musketB_back";
             EquipCharacterByItem(tmpChr, "pistolmketB");
           }
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "Arguebuse"))
         {
           Items_FindItem("Arguebuse", &weapon);
           weapon.model = "Arguebuse_back";
           EquipCharacterByItem(tmpChr, "Arguebuse");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "pistolbbuss"))
         {
           Items_FindItem("pistolbbuss", &weapon);
           weapon.model = "blunder1_10_back";
           EquipCharacterByItem(tmpChr, "pistolbbuss");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "pistol13"))
         {
           Items_FindItem("pistol13", &weapon);
           weapon.model = "pistol13_back";
           EquipCharacterByItem(tmpChr, "pistol13");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }

         if(IsEquipCharacterByItem(tmpChr, "LongRifle_C"))
         {
           Items_FindItem("LongRifle_C", &weapon);
           weapon.model = "LongRifle_C_back";
           EquipCharacterByItem(tmpChr, "LongRifle_C");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }
       }
     }
   }
}
Is that something that makes sense to you?
 
Is that something that makes sense to you?
Indeed you are right Pieter. Now it worked but only because
a new fresh "pistolmket" taken direct from initItems.c has the model
"musket_back" and nothing else.

I have right now tested to skip those extra checks and all is ok so I suggest
deleting them instead.
 

Attachments

  • JRH muskets bugfixes 2 16-04-10.7z
    33.3 KB · Views: 79
I have right now tested to skip those extra checks and all is ok so I suggest
deleting them instead.
Still looks like you're missing some of my suggestions. Please WinMerge attached file with your own version.
I think what I did there is the safest solution that does do what you have in mind.
 

Attachments

  • quests_common.zip
    38.7 KB · Views: 90
Ok I see.
I made a quick test with your version and everything seems to be fine. No errorlog either.
Still those 2 extra checks could be removed. (but does no harm)
 
Yes, and I made another quick test of that part. I think it's alright now.
Thanks for trying to make it safer. :onya
 
Back
Top