if(playable == null || !playable.isPlayer())
{
return;
}
L2Player player = (L2Player) playable;
L2Weapon weaponItem = player.getActiveWeaponItem();
L2ItemInstance weaponInst = player.getActiveWeaponInstance();
int SoulshotId = item.getItemId();
boolean isAutoSoulShot = false;
L2Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if(player.getAutoSoulShot().contains(SoulshotId))
{
isAutoSoulShot = true;
}
if(weaponInst == null)
{
if(!isAutoSoulShot)
{
player.sendPacket(Msg.CANNOT_USE_SOULSHOTS);
}
return;
}
// soulshot is already active
if(weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
{
return;
}
int grade = weaponItem.getCrystalType().externalOrdinal;
int soulShotConsumption = weaponItem.getSoulShotCount();
long count = item.getCount();
if(soulShotConsumption == 0)
{
// Can't use soulshots
if(isAutoSoulShot)
{
player.removeAutoSoulShot(SoulshotId);
player.sendPacket(new ExAutoSoulShot(SoulshotId, false), new SystemMessage(SystemMessage.THE_AUTOMATIC_USE_OF_S1_WILL_NOW_BE_CANCELLED).addString(itemTemplate.getName()));
return;
}
player.sendPacket(Msg.CANNOT_USE_SOULSHOTS);
return;
}
if(grade == 0 && SoulshotId != 5789 && SoulshotId != 1835 // NG
|| grade == 1 && SoulshotId != 1463 && SoulshotId != 22082 && SoulshotId != 13037 // D
|| grade == 2 && SoulshotId != 1464 && SoulshotId != 22083 && SoulshotId != 13045 // C
|| grade == 3 && SoulshotId != 1465 && SoulshotId != 22084 // B
|| grade == 4 && SoulshotId != 1466 && SoulshotId != 22085 && SoulshotId != 13055 // A
|| grade == 5 && SoulshotId != 1467 && SoulshotId != 22086 // S
)
{
// wrong grade for weapon
if(isAutoSoulShot)
{
return;
}
player.sendPacket(Msg.SOULSHOT_DOES_NOT_MATCH_WEAPON_GRADE);
return;
}
if(weaponItem.getItemType() == WeaponType.BOW || weaponItem.getItemType() == WeaponType.CROSSBOW)
{
int newSS = (int) player.calcStat(Stats.SS_USE_BOW, soulShotConsumption, null, null);
if(newSS < soulShotConsumption && Rnd.chance(player.calcStat(Stats.SS_USE_BOW_CHANCE, soulShotConsumption, null, null)))
{
soulShotConsumption = newSS;