• 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

As of last night's play of a new "Ardent" game with the 6th February update:

I still leave the prison with 4 muskets, which is odd as there are only 3 guards equipped with muskets. Officers sometimes get stuck with blademusket, usually because they've run out of ammo but not always. I also occasionally still auto-loot a blademusket from a dead guard. Converting a blademusket to musket and bayonet requires me to equip a loaded musket (so need to have at least 2 gunpowder and 1 musket bullet), equip the blademusket, then sheath the weapons.

No officers spawned extra muskets this time. Either it's fixed or it happens sufficiently rarely that they didn't get lucky this time.
 
I have fixed it (again).
And Pieter it should be like I suggested earlier:
Code:
if(CheckCharacterItem(chr, "blademketK"))
        {
            RemoveCharacterEquip(chr, BLADE_ITEM_TYPE);
            RemoveCharacterEquip(chr, GUN_ITEM_TYPE);
            TakeItemFromCharacter(chr, "blademketK");
            GiveItem2Character(chr, "blade_mKnife");
            GiveItem2Character(chr, "pistolmket");
            EquipCharacterByItem(chr, "blade_mKnife");
            EquipCharacterByItem(chr, "pistolmket");
        }

        if(CheckCharacterItem(chr, "blademketB"))
        {
            RemoveCharacterEquip(chr, BLADE_ITEM_TYPE);
            TakeItemFromCharacter(chr, "blademketB");
            GiveItem2Character(chr, "pistolmketB");
            if(!CheckCharacterItem(chr,"bladeX4"))
            {
                GiveItem2Character(chr,"bladeX4");
            }
            EquipCharacterByItem(chr, "bladeX4");
            EquipCharacterByItem(chr, "pistolmketB");
        }

There is another issue though. Like @GreyRoger it happened one or two times I ended up
with 4 muskets even if there were only 3 guards. Something similar happened while I was looting
bows from indians. So I'm not sure this is only related to muskets.

Tested 20 times and that didn't happen any more.
 

Attachments

  • JRH looting muskets 16-02-10.7z
    6.4 KB · Views: 122
@Grey Roger and/or @Jack Rackham: What's the latest news on this?
Is it OK now? Or difficult to fix completely?
I could mark this as "Low Priority" to be fixed at some point in the future, but not now.
 
As of 18th February zip update, officers with muskets and bayonets still occasionally spawn new ones. I've still no idea what triggers it, it doesn't seem consistent. One of my officers now has 10 of the things and I only ever gave him one! They also sometimes still get stuck with blademusket and the only way to convert it back to musket and bayonet is to take it from the officer, equip it along with a loaded firearm (doesn't need to be a musket but does need to be loaded), then draw and sheath it.
 
As of 18th February zip update, officers with muskets and bayonets still occasionally spawn new ones. I've still no idea what triggers it, it doesn't seem consistent. One of my officers now has 10 of the things and I only ever gave him one! They also sometimes still get stuck with blademusket and the only way to convert it back to musket and bayonet is to take it from the officer, equip it along with a loaded firearm (doesn't need to be a musket but does need to be loaded), then draw and sheath it.
Thanks for the update. :doff
 
I have started to check what's wrong with the muskets with absolutely no success so far.
Just to be sure: should it be only pchar who can autoloot weapons (and not officers for ex)?
 
Just to be sure: should it be only pchar who can autoloot weapons (and not officers for ex)?
I am not 100% sure, but I thought the way it was supposed to work is:
- Player kills a character, that character's gold, sword and gun is added to the player inventory
- Other character kills another character, no auto-looting so that the player can manually loot what they had
 
That is indeed my experience. Non-player characters (officers, enemies, anyone who got caught in the cross-fire and joined in) do not loot anything, so if they kill someone, I can loot the corpse for weapons and gold. Besides, the officers spawn their extra muskets while in combat where nobody else has muskets, e.g. random thugs in the jungle. And no weapons other than muskets and bayonets ever multiply like this.

They also still occasionally get stuck with a blademusket and I have to take it from the officer, equip it, separate it, then hand back a musket and bayonet.
 
Besides, the officers spawn their extra muskets while in combat where nobody else has muskets, e.g. random thugs in the jungle.
Hmm, so then it's maybe not autolootng that gone wrong but in some of the other places where muskets for officers are mentioned.
I have only noticed so far that officers get extra muskets when they kill enemies with muskets. And the muskets remains
on the corps as well.

They also still occasionally get stuck with a blademusket and I have to take it from the officer, equip it, separate it, then hand back a musket and bayonet.
Yes I know,that's the second problem. The part "mguns_reset_check" in quests_common doesn't work at all for officers.
 
:onya Multiple muskets (and knifes) on offiers fixed.
:onya Draw and sheathe your blade now again resets blademket to musket (back) + knife.
 

Attachments

  • JRH muskets bugfixes 16-04-10.7z
    33.3 KB · Views: 91
:onya Multiple muskets (and knifes) on offiers fixed.
:onya Draw and sheathe your blade now again resets blademket to musket (back) + knife.
Wow, you found a fix? That is AWESOME! :dance

Just to double-check on this though:
Code:
    //   if (weaponID == "") continue; // PB: Prevent potential error messages JRH: stopped blademket case
       aref weapon;
       Items_FindItem(weaponID, &weapon);
If I recall, Items_FindItem causes an error.log entry if it gets called with an invalid item ID.
"" is definitely an invalid ID, which is why I added that line to prevent that.
Are you absolutely certain that line of mine should be removed? :unsure
 
I'm certain about that line was making one of the bugs. It didn't read the "blademketK" case after that line.
All the other equip cases are guns and were executed ok.

Tested again and got nothing in the error log with that line gone.
 
I'm certain about that line was making one of the bugs. It didn't read the "blademketK" case after that line.
That's quite weird. The section of code is this:
Code:
   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);
     //   if (weaponID == "") continue; // PB: Prevent potential error messages JRH: stopped blademketK case
       aref weapon;
       Items_FindItem(weaponID, &weapon);
GetCharacterEquipByGroup returns "" only if a character does not have a gun equipped at all.
If that is the case, everything that follows is superfluous for that character, isn't it?

My fix line is there to skip all of it and continue with the next character.

I assume this is the "blademketK" section you say is not being executed?
Code:
         if(IsEquipCharacterByItem(tmpChr, "pistolmket"))
         {
           if(CheckCharacterItem(tmpChr, "blade_mKnife"))
           {
             if(!IsEquipCharacterByItem(tmpChr, "blade_mKnife")) EquipCharacterByItem(tmpChr, "blade_mKnife");
           }

           weapon.model = "musket_back";
           EquipCharacterByItem(tmpChr, "pistolmket");
           tmpChr.chr_ai.charge = GunCurCharge; // Levis
         }
That whole section doesn't apply if there is no gun equipped, right?
In fact, if weaponID is "", then IsEquipCharacterByItem(tmpChr, "pistolmket") should by definition return false too.

I'd suggest adding some debug lines in there to check what does and doesn't happen.
Maybe something like:
Code:
       makeref(tmpChr, Characters[index]);

       string weaponID = GetCharacterEquipByGroup(tmpChr,GUN_ITEM_TYPE);
       TraceAndLog("reset_check_mguns: " + GetMySimpleName(tmpChr) + " (" + tmpChr.id + ") has " + weaponID  + " equipped");
       if (weaponID == "") continue; // PB: Prevent potential error messages JRH: stopped blademketK case
       aref weapon;
       Items_FindItem(weaponID, &weapon);

What is the best way of testing this? Do you perhaps have a savegame?
I'd like to know what happens here, because as far as I read the code, what you describe shouldn't happen.
So that makes this rather mysterious. o_O
 
My fix line is there to skip all of it and continue with the next character.
I didn't know continue meant that. It took me hours to track down and test this bug. :ko
I assume this is the "blademketK" section you say is not being executed?
Yes.
GetCharacterEquipByGroup returns "" only if a character does not have a gun equipped at all.
If that is the case, everything that follows is superfluous for that character, isn't it?
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?

What is the best way of testing this?
Start Ardent and get out of the cell. When the first officer Louwman shows up use this console, F12, to give
and equip him with "blademketK".
Then draw your blade and sheathe it again. He should reset to musket on back + knife at the hip. :guns:
 

Attachments

  • console.c
    37.3 KB · Views: 129
Back
Top