Treasure chest

    
  1. Atsijungęs

    povis111

    Pranešimai: 0

    ups suklydau vienoj vietoj :D
    public void doExtract(final L2PlayableInstance playable, final L2ItemInstance item, int count)
    	{
    		if (!(playable instanceof L2PcInstance))
    			return;
    		final L2PcInstance activeChar = (L2PcInstance) playable;
    		final int itemID = item.getItemId(), raktoID = 1234;
    		
    		if (count > item.getCount())
    			return;
    		else if(itemID == 6518 && activeChar.getItemCount(raktoID, 0) < count)
    		{
    			activeChar.sendMessage("You do not have enough keys");
    			return;
    		}
    		while (count-- > 0)
    		{
    			L2ExtractableItem exitem = ExtractableItemsData.getInstance().getExtractableItem(itemID);
    			if (exitem == null)
    				return;
    			int createItemID = 0, createAmount = 0;
    			final int rndNum = Rnd.get(100);
    			int chanceFrom = 0;
    			for (final L2ExtractableProductItem expi : exitem.getProductItems())
    			{
    				final int chance = expi.getChance();
    				
    				if (rndNum >= chanceFrom && rndNum <= chance + chanceFrom)
    				{
    					createItemID = expi.getId();
    					createAmount = expi.getAmmount();
    					break;
    				}
    				
    				chanceFrom += chance;
    			}
    			
    			exitem = null;
    			
    			if (createItemID == 0)
    			{
    				activeChar.sendMessage("Nothing happened.");
    				return;
    			}
    			
    			if (createItemID > 0)
    			{
    				if (ItemTable.getInstance().createDummyItem(createItemID) == null)
    				{
    					LOGGER.warn("createItemID " + createItemID + " doesn't have template!");
    					activeChar.sendMessage("Nothing happened.");
    					return;
    				}
    				
    				if (ItemTable.getInstance().createDummyItem(createItemID).isStackable())
    				{
    					activeChar.addItem("Extract", createItemID, createAmount, item, false);
    				}
    				else
    				{
    					for (int i = 0; i < createAmount; i++)
    					{
    						activeChar.addItem("Extract", createItemID, 1, item, false);
    					}
    				}
    				SystemMessage sm;
    				
    				if (createAmount > 1)
    				{
    					sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
    					sm.addItemName(createItemID);
    					sm.addNumber(createAmount);
    				}
    				else
    				{
    					sm = new SystemMessage(SystemMessageId.EARNED_ITEM);
    					sm.addItemName(createItemID);
    				}
    				activeChar.sendPacket(sm);
    				sm = null;
    			}
    			else
    			{
    				activeChar.sendMessage("Item failed to open"); // TODO: Put a more proper message here.
    			}
    			if(itemID == 6518)
    			     activeChar.destroyItem("Raktas", raktoID, 1, activeChar.getTarget(), true);
    			activeChar.destroyItemByItemId("Extract", itemID, 1, activeChar.getTarget(), true);
    		}
    	}

    va, daba gerai :D
    19 Lapkričio 2016 - 12:01 / #11
  2. 
  3. Atsijungęs

    iitmtii

    Pranešimai: 0

    povis111,
    dekui, ryt butinai pameginsiu :)
    19 Lapkričio 2016 - 18:00 / #12