З.Ы, Обрати внимание на цикл - я в нем не уверен...
Получиться должно нечто вроде компресед соулшотс, только для стрел (думаю ты это и сам понял).
Заранее благодарен за неоценимую помощь.
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package net.sf.l2j.gameserver.handler.itemhandlers;
import net.sf.l2j.gameserver.ItemTable;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
import net.sf.l2j.gameserver.serverpackets.ItemList;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
/**
* This class ...
*
* @version $Revision: 1.1.2.1.2.3 $ $Date: 2005/03/27 15:30:07 $
*/
public class ArrowsPacks implements IItemHandler
{
private static int[] _itemIds ={
10000, 10001, 10002, 10003, 10004, 10005 // Arrows
};
public void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
if (!(playable instanceof L2PcInstance))
return;
L2PcInstance activeChar = (L2PcInstance)playable;
int itemId = item.getItemId();
int itemToCreateId = 0;
int amount = 0; // default regular pack
if (itemId >= 10000 && itemId <= 10005) // Arrows
{
if (itemId == 10005) // S Grade
itemToCreateId = 1345;
else
if (itemId == 10004) // A Grade
itemToCreateId = 1344;
else
if (itemId == 10003) // B Grade
itemToCreateId = 1343;
else
if (itemId == 10002) // C Grade
itemToCreateId = 1342;
else
if (itemId == 10001) //D Grade
itemToCreateId = 1341;
else
if (itemId == 10000) // Non Grade
itemToCreateId = 17;
amount = 1000;
}
unpackPackage(activeChar,itemToCreateId,amount);
activeChar.removeItemFromInventory(item, 1);
}
private void unpackPackage(L2PcInstance actor, int itemId, int amount)
{
L2ItemInstance pack = ItemTable.getInstance().createItem(itemId);
pack.setCount(amount);
actor.getInventory().addItem(pack);
SystemMessage sm = new SystemMessage(SystemMessage.EARNED_S2_S1_s);
sm.addItemName(itemId);
sm.addNumber(amount);
actor.sendPacket(sm);
actor.sendPacket(new ItemList(actor, false));
}
public int[] getItemIds()
{
return _itemIds;
}
}