@Override public void act(final Player player, final Item parentItem, Item targetItem) { PacketSendUtility.sendPacket( player, new SM_ITEM_USAGE_ANIMATION( player.getObjectId(), parentItem.getObjectId(), parentItem.getItemTemplate().getTemplateId(), 5000, 0, 0)); player.getController().cancelTask(TaskId.ITEM_USE); player .getController() .addNewTask( TaskId.ITEM_USE, ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { PacketSendUtility.sendPacket( player, new SM_ITEM_USAGE_ANIMATION( player.getObjectId(), parentItem.getObjectId(), parentItem.getItemTemplate().getTemplateId(), 0, 1, 0)); Storage inventory = player.getInventory(); inventory.removeFromBagByObjectId(parentItem.getObjectId(), 1); int decomposedId = parentItem.getItemId() - 1; switch (parentItem.getItemId()) { case 152000112: case 152000328: decomposedId -= 2; break; case 152000213: case 152000327: decomposedId -= 3; break; case 152000326: decomposedId -= 4; } ItemService.addItem(player, decomposedId, 3); } }, 5000)); }
@Override public HandlerResult onItemUseEvent(final QuestCookie env, Item item) { final Player player = env.getPlayer(); final QuestState qs = player.getQuestStateList().getQuestState(questId); final int id = item.getItemTemplate().getTemplateId(); final int itemObjId = item.getObjectId(); if (id == 186000107) { if (!ZoneService.getInstance().isInsideZone(player, ZoneName.DEBILKARIM_FORGE_300160000)) return HandlerResult.FAILED; if (qs == null) return HandlerResult.UNKNOWN; if (qs.getQuestVarById(0) != 0) return HandlerResult.FAILED; if (player.getInventory().getItemCountByItemId(100900716) == 0 || player.getInventory().getItemCountByItemId(186000099) == 0 || player.getInventory().getItemCountByItemId(186000106) < 20 || player.getInventory().getItemCountByItemId(186000107) == 0) return HandlerResult.FAILED; PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 3000, 0, 0), true); ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { ItemService.addItems( player, Collections.singletonList(new QuestItems(182209634, 1))); PacketSendUtility.broadcastPacket( player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), itemObjId, id, 0, 1, 0), true); player.getInventory().removeFromBagByItemId(186000099, 1); player.getInventory().removeFromBagByItemId(186000106, 20); player.getInventory().removeFromBagByItemId(186000107, 1); qs.setStatus(QuestStatus.REWARD); updateQuestStatus(env); } }, 3000); return HandlerResult.SUCCESS; } return HandlerResult.UNKNOWN; }
@Override public boolean canAct(Player player, Item parentItem, Item targetItem) { int itemId = parentItem.getItemTemplate().getTemplateId(); if (itemId >= 152000329 && itemId <= 152000331) { // There are Unique items with the same name and these Epic // items don't split although specified as splittable in the client return false; } return true; }