L2JMobius

C6 how to drop an item on all mobs

thezzari · 9 · 3138

Offline thezzari

  • Heir
  • **
    • Posts: 12
    • L2 Crusader BR
Hello guys, how do I add an item to drop from all the game's mobs? it's possible ? first of all i want to thank all the game developers, it is the most complete rev i have ever used and as soon as possible i will make a donation.


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 327
Hello,

You must edit your java source. Open gameserver/model/actor/Attackable.java and find the Champion drops.

Code: [Select]
// Apply Special Item drop with rnd qty for champions
if (Config.CHAMPION_ENABLE && isChampion() && (player.getLevel() <= (getLevel() + 3)) && (Config.CHAMPION_REWARD > 0) && (Rnd.get(100) < Config.CHAMPION_REWARD))
{
int champqty = Rnd.get(Config.CHAMPION_REWARD_QTY);
champqty++; // quantity should actually vary between 1 and whatever admin specified as max, inclusive.

// Give this or these Item(s) to the PlayerInstance that has killed the Attackable
final RewardItem item = new RewardItem(Config.CHAMPION_REWARD_ID, champqty);
if (Config.AUTO_LOOT)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
DropItem(player, item);
}
else
{
player.addItem("ChampionLoot", item.getItemId(), item.getCount(), this, true);
}
}
else
{
DropItem(player, item);
}
}

After this add your drop. Let's say we want to add 10 adenas with 5% chance.

Code: [Select]
if (Rnd.get(100) < 5)
{

final RewardItem item = new RewardItem(57, 10);
if (Config.AUTO_LOOT)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
DropItem(player, item);
}
else
{
player.addItem("GlobalDrop", item.getItemId(), item.getCount(), this, true);
}
}
else
{
DropItem(player, item);
}
}

Of course this is just an example. You can edit it your way and have variables, make quantity dynamic or random, add drops on monsters over a specific level etc.


Offline thezzari

  • Heir
  • **
    • Posts: 12
    • L2 Crusader BR
Thank you very much, I managed to solve it with your help.



Offline thezzari

  • Heir
  • **
    • Posts: 12
    • L2 Crusader BR

just one more question, how do i make the item drop at maximum 6 level difference?


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 327
if(player.getLevel() <= (getLevel() + 6)){
     //code here
}


Offline thezzari

  • Heir
  • **
    • Posts: 12
    • L2 Crusader BR
thanks again, everything worked out.

Code: [Select]
if ((player.getLevel() <= (getLevel() + 6)) && (Rnd.get(100) < 40))
{

final RewardItem item = new RewardItem(9655, 1);
if (Config.AUTO_LOOT)
{
final Item itemTemplate = ItemTable.getInstance().getTemplate(item.getItemId());
if (!player.getInventory().validateCapacity(itemTemplate))
{
DropItem(player, item);
}
else
{
player.addItem("GlobalDrop", item.getItemId(), item.getCount(), this, true);
}
}
else
{


Online anarki

  • Knight
  • ***
    • Posts: 58
And is there another option to add more items to drop  ???


Online G-hamsteR

  • Viscount
  • *****
    • Posts: 327