public void setItem(L1Item item) { _item = item; _itemId = item.getItemId(); }
private boolean makeItems(L1PcInstance pc, String npcName, int amount) { if (amount <= 0) { return false; } boolean isEnoughMaterials = true; for (L1ObjectAmount<Integer> material : _materials) { if (!pc.getInventory() .checkItemNotEquipped(material.getObject(), material.getAmount() * amount)) { L1Item temp = ItemTable.getInstance().getTemplate(material.getObject()); pc.sendPackets( new S_ServerMessage( 337, temp.getName() + "(" + ((material.getAmount() * amount) - pc.getInventory().countItems(temp.getItemId())) + ")")); // \f1%0が不足しています。 isEnoughMaterials = false; } } if (!isEnoughMaterials) { return false; } // 容量と重量の計算 int countToCreate = 0; // アイテムの個数(纏まる物は1個) int weight = 0; for (L1ObjectAmount<Integer> makingItem : _items) { L1Item temp = ItemTable.getInstance().getTemplate(makingItem.getObject()); if (temp.isStackable()) { if (!pc.getInventory().checkItem(makingItem.getObject())) { countToCreate += 1; } } else { countToCreate += makingItem.getAmount() * amount; } weight += temp.getWeight() * (makingItem.getAmount() * amount) / 1000; } // 容量確認 if (pc.getInventory().getSize() + countToCreate > 180) { pc.sendPackets(new S_ServerMessage(263)); // \f1一人のキャラクターが持って歩けるアイテムは最大180個までです。 return false; } // 重量確認 if (pc.getMaxWeight() < pc.getInventory().getWeight() + weight) { pc.sendPackets(new S_ServerMessage(82)); // アイテムが重すぎて、これ以上持てません。 return false; } for (L1ObjectAmount<Integer> material : _materials) { // 材料消費 pc.getInventory().consumeItem(material.getObject(), material.getAmount() * amount); } for (L1ObjectAmount<Integer> makingItem : _items) { L1ItemInstance item = pc.getInventory().storeItem(makingItem.getObject(), makingItem.getAmount() * amount); if (item != null) { String itemName = ItemTable.getInstance().getTemplate(makingItem.getObject()).getName(); if (makingItem.getAmount() * amount > 1) { itemName = itemName + " (" + makingItem.getAmount() * amount + ")"; } pc.sendPackets(new S_ServerMessage(143, npcName, itemName)); // \f1%0が%1をくれました。 } } return true; }