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

Medium Priority Strange Effects with Muskets using Quick-Equip

It's not the quick-equip so much as the looting situation.
Guards with the knife and a not yet fired musket on their hip give blademketK in the looting interface.
The visible corpse on the ground still has got knife + hip musket equipped.

So I tried to add another block before the old code in LAi_utils,c
if(CheckCharacterItem(chr, "blade_mKnife") && CheckCharacterItem(chr, "pistolmket"))
{
RemoveCharacterEquip(chr, GUN_ITEM_TYPE);
RemoveCharacterEquip(chr, BLADE_ITEM_TYPE);
TakeItemFromCharacter(chr, "pistolmket");
TakeItemFromCharacter(chr, "blade_mKnife");
GiveItem2Character(chr, "blademketK");
EquipCharacterByItem(chr, "blademketK");
}

if(CheckCharacterItem(chr, "blademketK"))
{
RemoveCharacterEquip(chr, GUN_ITEM_TYPE);
RemoveCharacterEquip(chr, BLADE_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, GUN_ITEM_TYPE);
RemoveCharacterEquip(chr, BLADE_ITEM_TYPE);
TakeItemFromCharacter(chr, "blademketB");
GiveItem2Character(chr, "pistolmketB");
if(!CheckCharacterItem(chr, "bladeX4")) GiveItem2Character(chr, "bladeX4");
EquipCharacterByItem(chr, "bladeX4");
EquipCharacterByItem(chr, "pistolmketB");
}
but I still get the wrong item sometimes.

I'll try something completely different now.
 
It's not the quick-equip so much as the looting situation.
I was specifically talking about the "looting situation" when I referred to LAi_Character_Dead_Event in LAi_events.c .

Guards with the knife and a not yet fired musket on their hip give blademketK in the looting interface.
The visible corpse on the ground still has got knife + hip musket equipped.
The visible corpse on the ground shouldn't matter one way or another; that isn't what you loot.
A "fake box locator" is created and the items from the corpse are moved there.

Equipping and unequipping the items shouldn't matter, because a dead character doesn't use the items anyway.
And a box isn't a character.

Maybe the "AUTOLOOT" functionality is confusing things though.
That one gets called through LAi_CalcDeadExp like this BEFORE any "corpse" code is executed:
Code:
void LAi_ApplyCharacterBladeDamage(aref attack, aref enemy, float attackDmg, float hitDmg, bool isBlocked)
{
   [...]
   // Baste <--
   if(LAi_IsDead(enemy))
   {
     //Начислим за убийство
     exp = exp + LAi_CalcDeadExp(attack, enemy);

Maybe putting your "item swapping" into LAi_IsDead would be the most fail-safe solution?
 
Now I have tried your suggestion Pieter but sorry not better.

I have managed though to make a workaround if nothing better works.

In itemsbox
void IDoExit(int exitCode)
{
int s; // NK for below for() statements

ref pchar = GetMainCharacter();

//JRH -->
if(sti(GetAttribute(pchar, "items.blademketK")) >0)
{
RemoveCharacterEquip(Pchar, GUN_ITEM_TYPE);
RemoveCharacterEquip(Pchar, BLADE_ITEM_TYPE);
TakeItemFromCharacter(Pchar, "blademketK");
GiveItem2Character(Pchar, "blade_mKnife");
GiveItem2Character(Pchar, "pistolmket");
EquipCharacterByItem(Pchar, "blade_mKnife");
EquipCharacterByItem(Pchar, "pistolmket");
}
//<--JRH
you can (at least you think so) pick up blademketK but when leaving this interface and
checking in your inventory that terrible item is switched to what we want.

This should make the 2 equipchecks I made yesterday. quick_equip button + equip via inventory
unnecessary.
 
Now I have tried your suggestion Pieter but sorry not better.
Have you already tried my LAi_IsDead suggestion? I think that one might just work.
In PROGRAM\Loc_ai\LAi_character.c find:
Code:
bool LAi_IsDead(aref chr)
{
   if(CheckAttribute(chr, "chr_ai.hp") == false) return true;
   if(stf(chr.chr_ai.hp) < 1.0) return true;
   return false;
}
Replace with:
Code:
bool LAi_IsDead(aref chr)
{
   bool bDead = false;
   if (CheckAttribute(chr, "chr_ai.hp") == false) bDead = true;
   if (stf(chr.chr_ai.hp) < 1.0) bDead = true;
   //JRH -->
   if (bDead && !IsMainCharacter(chr))
   {
     if(CheckCharacterItem(chr, "blademketK"))
     {
       TakeItemFromCharacter(chr, "blademketK");
       GiveItem2Character(chr, "blade_mKnife");
       GiveItem2Character(chr, "pistolmket");
     }

     if(CheckCharacterItem(chr, "blademketB"))
     {
       TakeItemFromCharacter(chr, "blademketB");
       GiveItem2Character(chr, "pistolmketB");
     }
   }
   //<-- JRH
   return bDead;
}

Probably doesn't work if you loot a character that isn't dead though through stunning/Thief's Knife/Etc.
But that is probably a separate issue that cannot be fixed in the same way as the "looting dead characters" problem.

you can (at least you think so) pick up blademketK but when leaving this interface and
checking in your inventory that terrible item is switched to what we want.
If you are going to do that, you probably need to count the number of items and swap multiple if there are multiple ones.
Why does everything always get so complicated so quickly? :facepalm
 
I think that one might just work.
Hmm I was in the wrong file but tested with LAi_character now......

and........... IT WORKS. :dance:dance:dance
Set that one up on you Pieter. :cheers

I'll upload tomorrow morning before going out on a long cold car tour.
 
@Jack Rackham: I think the looting should be fixed now.
Should that also take care of the weirdness I have with equipping or does that still need a separate fix?
 
No I think the problem was getting those blademuskets at all.
If you can't get them you can't wrongly equip them so I have skipped the equip check.
One thing I missed though is cleaning up LAi_utils.c where my first anti-looting code still is.

Here's a clean one.
 

Attachments

  • LAi_utils.c
    24.1 KB · Views: 195
No I think the problem was getting those blademuskets at all.
If you can't get them you can't wrongly equip them so I have skipped the equip check.
Thanks. Then I know we can mark this one for testing and no more work needs to be done unless we find mor ecrazy stuff. :onya

One thing I missed though is cleaning up LAi_utils.c where my first anti-looting code still is.

Here's a clean one.
Thanks! :cheers
 
Looting seems to be fine, but there still seems to be a problem with officers using muskets. Occasionally they keep their blademuskets. This is fair enough if they've run out of ammo, but I've seen a few occasions when they kept the blademusket yet still had at least 2 gunpowder and 1 musket bullet. Also, even rarer, they sometimes spawn new muskets and bayonets. Playing my "Ardent" proto-storyline, I'd managed to defeat the ambush party which jumps you soon after you escape prison - I may make them tougher, they're supposed to encourage you to leave town, not provide a source of free muskets and ammo! For now, defeating them provides a wonderful opportunity to test the use of muskets and bayonets, so I'd handed each of my officers one musket, one bayonet and a full load of ammo. Out in the jungle there are often plenty of thugs or highwaymen to provide targets for these weapons, and after a battle I found that one of my officers had two muskets and two bayonets, and I didn't give them to him.

This is with the 18th January installer.
 
but I've seen a few occasions when they kept the blademusket yet still had at least 2 gunpowder and 1 musket bullet.
In a fight they should switch to blademuskets after a shot. During that fight they shouldn't equip the musket again as they can't reload during the figtht.

After the fight is another thing, here a switch to muskets should happen.
My last checkpoint for this is when pchar sheathes his blade everyone else should reset (to muskets on back). Doesn't this work?
 
Not always. The fight is over, usually everyone switches back to separate musket and bayonet (unless they're out of ammo), but occasionally they keep the blademusket even though they have ammo.
 
I can convert a blademusket to a musket plus bayonet by doing that, provided I have a firearm (either a pistol or an already existing musket) equipped. So if one of my officers has failed to remove his bayonet, I can take the blademusket off him, separate the bayonet myself, then give him the musket and bayonet back.

But I don't know how to order the officer to draw and sheathe his own blademusket in an attempt to convert it back. ;)
 
But I don't know how to order the officer to draw and sheathe his own blademusket in an attempt to convert it back.
But that was my idea: by sheathing your blade all NPC:s should reset too. Maybe I have missed something with the officers.
I'll take a look.
 
But that was my idea: by sheathing your blade all NPC:s should reset too. Maybe I have missed something with the officers.
I'll take a look.
What happens if the NPC hasn't sheathed his weapon at the time that you sheathe yours? I've occasionally seen them keep their weapons drawn long after the battle has finished. So you put your weapon away, everyone else's blademuskets are converted to musket and bayonet, but this guy is still waving his blademusket around. (Perhaps that's what caused the other weirdness, which is that someone started a battle with one musket and bayonet, and ended it with two - I'll have to watch for that next time...)
 
Yeah, could be. I couldn't force them to sheathe their blade as that would put an end to every fight...

I'll have to watch for that next time...
And please watch for those that have sheathed their blades: if they are reset ok so we know that at least that
case is ok.
 
I have checked the code and found nothing strange.

The only thing I can say is:
wait until all NPC:s have sheathed their blades. If someone still has got a blademusket equipped try draw your blade and sheathe it again. Even if they're out of ammo they're supposed to go back to knife + musket on the back.
(As a reset mode)
 
Back
Top