}
// Check if the autoLoot mode is active
if(Config.AUTO_LOOT)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(item_templ == null){
_log.info("ERROR: Item id to autoloot " + item.getItemId() + " has not template into items/armor/weapon tables.. It cannot be dropped..");
//DropItem(player, item);
}else{
if(!player.getInventory().validateCapacity(item_templ) || (!Config.AUTO_LOOT_BOSS && this instanceof L2RaidBossInstance) || (!Config.AUTO_LOOT_BOSS && this instanceof L2GrandBossInstance))
DropItem(player, item);
else
player.doAutoLoot(this, item); // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
}
}
else
{
DropItem(player, item); // drop the item on the ground
}
// Broadcast message if RaidBoss was defeated
if(this instanceof L2RaidBossInstance || this instanceof L2GrandBossInstance )
{
SystemMessage sm;
sm = new SystemMessage(SystemMessageId.S1_DIED_DROPPED_S3_S2);
sm.addString(getName());
sm.addItemName(item.getItemId());
sm.addNumber(item.getCount());
broadcastPacket(sm);
sm = null;
}
}
}
item = null;
}
// Apply Special Item drop with rnd qty for champions
if(Config.L2JMOD_CHAMPION_ENABLE && isChampion() && player.getLevel() <= getLevel()+3 && Config.L2JMOD_CHAMPION_REWARD > 0 && Rnd.get(100) < Config.L2JMOD_CHAMPION_REWARD)
{
int champqty = Rnd.get(Config.L2JMOD_CHAMPION_REWARD_QTY);
champqty++; //quantity should actually vary between 1 and whatever admin specified as max, inclusive.
RewardItem item = new RewardItem(Config.L2JMOD_CHAMPION_REWARD_ID, champqty);
// Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
if(Config.AUTO_LOOT)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("ChampionLoot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
}
//Instant Item Drop :>
double rateHp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
if(rateHp < 2 && String.valueOf(npcTemplate.type).contentEquals("L2Monster")) //only L2Monster with <= 1x HP can drop herbs
{
boolean _hp = false;
boolean _mp = false;
boolean _spec = false;
//ptk - patk type enhance
int random = Rnd.get(1000); // note *10
if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec) // && !_spec useless yet
{
RewardItem item = new RewardItem(8612, 1); // Herb of Warrior
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_spec = true;
}
else
{
for(int i = 0; i < 3; i++)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_COMMON_HERBS)
{
RewardItem item = null;
if(i == 0)
{
item = new RewardItem(8606, 1); // Herb of Power
}
if(i == 1)
{
item = new RewardItem(8608, 1); // Herb of Atk. Spd.
}
if(i == 2)
{
item = new RewardItem(8610, 1); // Herb of Critical Attack
}
if (item == null)
{
break;
}
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
break;
}
}
}
//mtk - matk type enhance
random = Rnd.get(1000); // note *10
if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec)
{
RewardItem item = new RewardItem(8613, 1); // Herb of Mystic
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_spec = true;
}
else
{
for(int i = 0; i < 2; i++)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_COMMON_HERBS)
{
RewardItem item = null;
if(i == 0)
{
item = new RewardItem(8607, 1); // Herb of Magic
}
if(i == 1)
{
item = new RewardItem(8609, 1); // Herb of Casting Speed
}
if (item == null)
{
break;
}
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
break;
}
}
}
//hp+mp type
random = Rnd.get(1000); // note *10
if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec)
{
RewardItem item = new RewardItem(8614, 1); // Herb of Recovery
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_mp = true;
_hp = true;
_spec = true;
}
//hp - restore hp type
if(!_hp)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_MP_HP_HERBS)
{
RewardItem item = new RewardItem(8600, 1); // Herb of Life
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_hp = true;
}
}
if(!_hp)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_GREATER_HERBS)
{
RewardItem item = new RewardItem(8601, 1); // Greater Herb of Life
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_hp = true;
}
}
if(!_hp)
{
random = Rnd.get(1000); // note *10
if(random < Config.RATE_DROP_SUPERIOR_HERBS)
{
RewardItem item = new RewardItem(8602, 1); // Superior Herb of Life
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
}
}
//mp - restore mp type
if(!_mp)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_MP_HP_HERBS)
{
RewardItem item = new RewardItem(8603, 1); // Herb of Mana
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_mp = true;
}
}
if(!_mp)
{
random = Rnd.get(100);
if(random < Config.RATE_DROP_GREATER_HERBS)
{
RewardItem item = new RewardItem(8604, 1); // Greater Herb of Mana
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
_mp = true;
}
}
if(!_mp)
{
random = Rnd.get(1000); // note *10
if(random < Config.RATE_DROP_SUPERIOR_HERBS)
{
RewardItem item = new RewardItem(8605, 1); // Superior Herb of Mana
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
}
else
{
DropItem(player, item);
}
item = null;
}
}
// speed enhance type
random = Rnd.get(100);
if(random < Config.RATE_DROP_COMMON_HERBS)
{
RewardItem item = new RewardItem(8611, 1); // Herb of Speed
if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
{
L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
if(!player.getInventory().validateCapacity(item_templ))
DropItem(player, item);
else
player.addItem("Loot", item.getItemId(), item.getCount(), this, true);