• 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 "LAi_CreateFantomGroup" does not assign correct ammo

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
The new function to generate random attackers, "LAi_CreateFantomGroup", does not assign correct ammo if you specify the gun. This is because it calls a chain of functions starting with "LAi_CreateFantomCharacterRk", which assigns the character a random gun and the ammo to go with it; then if a gun was specified for "LAi_CreateFantomGroup", it removes the random gun and assigns the specified gun without replacing the ammo. So if you use "LAi_CreateFantomGroup" to summon a squad of soldiers armed specifically with muskets, they'll have muskets and random pistol or grapeshot ammo.
 
Thanks for catching that! I had completely forgotten to take care of that too.
Should be relatively easy to sort out. I'll do it once I have access to my computer again. :doff
 
@Jack Rackham: I created a new function from your code to assign ammunition:
Code:
void LAi_NPC_Ammo(ref chr)
{
 // PB: Clear Existing Ammo -->
 DeleteAttribute(chr, "items.pistolbullets");
 DeleteAttribute(chr, "items.pistolgrapes");
 DeleteAttribute(chr, "items.musketbullets");
 DeleteAttribute(chr, "items.bladearrows");
 DeleteAttribute(chr, "items.gunpowder");
 // PB: Clear Existing Ammo <--

 // JRH fix oct 06: rewritten old did not give any ammo to NPCs, amount reduced -->
 //Levis made sure you always have at least 1 bullet
 if (ENABLE_AMMOMOD) { // LDH change

 string weaponID = GetCharacterEquipByGroup(chr,GUN_ITEM_TYPE);
 aref weapon;
 Items_FindItem(weaponID, &weapon);
 bool givepowder = false;

 if(CheckAttribute(weapon, "shottype") && weapon.shottype != "")
 {
 if(weapon.shottype == "pb" || weapon.shottype == "pb2") { TakenItems(chr, "pistolbullets", 1+rand(2)); givepowder = true; }

 if(weapon.shottype == "pg" || weapon.shottype == "pg2") { TakenItems(chr, "pistolgrapes", 1+rand(2)); givepowder = true; }

 if(weapon.shottype == "mb") { TakenItems(chr, "musketbullets", 1); givepowder = true; } //Always 1 bullet

 if(weapon.shottype == "ar") { TakenItems(chr, "bladearrows", rand(2)); givepowder = false; } //Levis for indians (you will always have at least some arrows) JRH: rand(2) only as 1 arrow always got as a blade
 }
 if(givepowder)
 {
 TakenItems(chr, "gunpowder", rand(3));
 }
 }
 //<-- JRH gives this to officers & enemies, officers are also equipped by Enc_Officers_dialog
}
Does that seem about right to you?
And do you have similar sections of code in use elsewhere? Maybe those can be replaced with a call to the same function too.

For now, I have it in use in only its original spot. See attached. Extract to PROGRAM\Loc_ai .
 

Attachments

  • LAi_equip.zip
    3.8 KB · Views: 124
@Grey Roger: In addition to the file from the previous post, extract also the attached one to PROGRAM\LandEncounters .
That contains a call to that new function to resupply the correct ammunition for those character groups:
Code:
// PB: Custom Gun
if (gunID != "")
{
TakeItemFromCharacter(chr, GetCharacterEquipByGroup(chr, GUN_ITEM_TYPE));
RemoveCharacterEquip(chr, GUN_ITEM_TYPE);
if(!CheckCharacterItem(chr, gunID)) GiveItem2Character(chr, gunID);
EquipCharacterByItem(chr, gunID);
LAi_NPC_Ammo(chr); // JRH
}

I think that should be enough to solve this problem. :woot
 

Attachments

  • LEnc_monsters.zip
    14 KB · Views: 117
Back
Top