package custom;
import ru.catssoftware.gameserver.handler.IItemHandler;
import ru.catssoftware.gameserver.handler.ItemHandler;
import ru.catssoftware.gameserver.model.L2ItemInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance;
import ru.catssoftware.gameserver.model.actor.instance.L2PlayableInstance;
import ru.catssoftware.gameserver.util.PcAction;
import ru.catssoftware.tools.random.Rnd;
/**
* Created with IntelliJ IDEA.
* User: Masone
* Date: 15.09.16
* Time: 13:30
* To change this template use File | Settings | File Templates.
*/
public class Chest implements IItemHandler
{
private static final int[] ITEM_IDS = { 9901 };
private static int[] COIN_IDS = { 4037,6673,9900,9901 };
public void useItem(L2PlayableInstance playable, L2ItemInstance item, boolean par){}
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!playable.isPlayer())
return;
L2PcInstance player = (L2PcInstance) playable;
int _Rnd = Rnd.get(100);
if(_Rnd < 90)
{
player.sendMessage("Мне жаль,но ничего не выпало..");
}
else
{
int reward_id = 0;
int count = 1;
switch (Rnd.get(1))
{
case 1:
{
reward_id = COIN_IDS[Rnd.get(COIN_IDS.length)];
count = (reward_id == 4037 ? Rnd.get(1,200) : 1);
break;
}
//case...
}
// activeChar или не знаю кто у тебя он там в коде -- кому выдавать
PcAction.giveItems(player, reward_id, count);
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
}
}
public static void main (String... arguments )
{
new Chest();
}
public int[] getItemIds()
{
return ITEM_IDS;
}
}