//JRH -->
string bladeID = GetCharacterEquipByGroup(crew, BLADE_ITEM_TYPE);
aref blade;
Items_FindItem(bladeID, &blade);
string bladeID2 = GetCharacterEquipByGroup(mainChr, BLADE_ITEM_TYPE);
aref blade2;
Items_FindItem(bladeID2, &blade2);
string gunID = GetCharacterEquipByGroup(crew, GUN_ITEM_TYPE);
aref gun;
Items_FindItem(gunID, &gun);
string gunID2 = GetCharacterEquipByGroup(mainChr, GUN_ITEM_TYPE);
aref gun2;
Items_FindItem(gunID2, &gun2);
string old_gun;
string right_gun;
string old_blade;
string right_blade;
//---------------------------------------------------------------------------------------------------
if(CheckAttribute(blade2, "price"))
{
if(blade2.price >= 8000)
{
right_blade = "blade34";
}
else
{
if(blade2.price >= 4000)
{
right_blade = "blade24";
}
}
else
{
if(blade2.price >= 1000)
{
right_blade = "blade31";
}
}
else
{
if(blade2.price >= 500)
{
right_blade = "blade12";
}
}
else
{
if(blade2.price >= 250)
{
right_blade = "blade10";
}
}
else
{
if(blade2.price >= 50)
{
right_blade = "blade4";
}
}
else
{
if(blade2.price >= 2)
{
//anything better than fists
right_blade = "barmansknife";
}
}
else
{
//player has fists only
right_blade = "bladeX4";
}
}
if(bladeID2 == "")
{
right_blade = "";
}
//LogIt("right_blade = " + right_blade);
if(!IsEquipCharacterByItem(crew, right_blade))
{
if(bladeID != "")
{
old_blade = GetCharacterEquipByGroup(crew, BLADE_ITEM_TYPE);
//LogIt("old_blade = " + old_blade);
TakeItemFromCharacter(crew, old_blade);
}
//else LogIt("old_blade = " + "no blade");
GiveItem2Character(crew, right_blade);
EquipCharacterbyItem(crew, right_blade);
}
//---------------------------------------------------------------------------------------------------
if(GetCurrentPeriod() >= PERIOD_GOLDEN_AGE_OF_PIRACY)
{
if(gunID2 == "pistolmket" || gunID2 == "pistolmtoon" || gunID2 == "pistol10" || gunID2 == "LongRifle_C" || gunID2 == "LongRifle_CT")
{
right_gun = "pistolbbuss";
}
if(gunID2 == "pistolbbuss")
{
right_gun = "pistol3";
}
if(gunID2 == "pistol3_14" || HasSubStr(gunID2, "pistol9"))
{
right_gun = "pistol5";
}
if(HasSubStr(gunID2, "pistol8"))
{
right_gun = "pistol6";
}
if( HasSubStr(gunID2, "pistol7") || HasSubStr(gunID2, "pistol6") || HasSubStr(gunID2, "PiratesPistol") )
{
right_gun = "pistol2";
}
if(HasSubStr(gunID2, "pistol4") || gunID2 == "pistol4_1")
{
right_gun = "pistol7";
}
if(HasSubStr(gunID2, "pistol5") || HasSubStr(gunID2, "pistol3") )
{
right_gun = "PiratesPistol";
}
if( HasSubStr(gunID2, "pistol25") || HasSubStr(gunID2, "pistol26") )
{
right_gun = "pistol5";
}
else
{
if(HasSubStr(gunID2, "pistol2") )
{
right_gun = "pistol1";
}
}
if(HasSubStr(gunID2, "pistol1") )
{
right_gun = "pistol1";
}
if(gunID2 == "")
{
right_gun = "";
}
}
else
{
if(gunID2 == "Arguebuse" || gunID2 == "pistol13")
{
right_gun = "pistol13";
}
if( HasSubStr(gunID2, "pistol11") || HasSubStr(gunID2, "pistol12") )
{
right_gun = "pistol11";
}
}
//LogIt("right_gun = " + right_gun);
if(!IsEquipCharacterByItem(crew, right_gun))
{
if(gunID != "")
{
old_gun = GetCharacterEquipByGroup(crew, GUN_ITEM_TYPE);
//LogIt("old_gun = " + old_gun);
TakeItemFromCharacter(crew, old_gun);
}
//else LogIt("old_gun = " + "no gun");
GiveItem2Character(crew, right_gun);
EquipCharacterbyItem(crew, right_gun);
//AMMO only if crew got a gun
gunID = GetCharacterEquipByGroup(crew, GUN_ITEM_TYPE);
Items_FindItem(gunID, &gun);
if(gunID != "")
{
TakeNItems(crew,"gunpowder", -100);
TakeNItems(crew,"pistolbullets", -100);
TakeNItems(crew,"pistolgrapes", -100);
TakeNItems(crew,"musketbullets", -100);
if(CheckAttribute(gun, "shottype"))
{
if(gun.shottype == "pb" || gun.shottype == "pb2") TakeNItems(crew,"pistolbullets", 6);
if(gun.shottype == "pg" || gun.shottype == "pg2") TakeNItems(crew,"pistolgrapes", 6);
if(gun.shottype == "mb") TakeNItems(crew,"musketbullets", 3);
if(gun.shottype == "pg" || gun.shottype == "pg2" || gun.shottype == "pb" || gun.shottype == "pb2" || gun.shottype == "mb")
TakeNItems(crew,"gunpowder", 6);
if(gun.shottype == "ca") TakeNItems(crew,"cartridges", 6);
}
//here for "new" gun, both first gun or changed gun
if(CheckAttribute(gun, "chargeQ"))
{
crew.chr_ai.charge = makeint(gun.chargeQ);
}
}
}
if(right_gun == "")
{
TakeNItems(crew,"gunpowder", -100);
TakeNItems(crew,"pistolbullets", -100);
TakeNItems(crew,"pistolgrapes", -100);
TakeNItems(crew,"musketbullets", -100);
}
//LogIt("gun.shottype = " + gun.shottype);
//LogIt("charges = " + crew.chr_ai.charge);
//LAi_SetImmortal(crew, true); //while testing
//<-- JRH