NpcInventory.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* This program is free software; you can redistribute it and/or modify
  2. * it under the terms of the GNU General Public License as published by
  3. * the Free Software Foundation; either version 2, or (at your option)
  4. * any later version.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License
  12. * along with this program; if not, write to the Free Software
  13. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  14. * 02111-1307, USA.
  15. *
  16. * http://www.gnu.org/copyleft/gpl.html
  17. */
  18. package net.sf.l2j.gameserver.model;
  19. import java.util.List;
  20. import javolution.util.FastList;
  21. import net.sf.l2j.gameserver.model.L2ItemInstance.ItemLocation;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  23. public class NpcInventory extends Inventory
  24. {
  25. public static final int ADENA_ID = 57;
  26. public static final int ANCIENT_ADENA_ID = 5575;
  27. private final L2NpcInstance _owner;
  28. public boolean sshotInUse = false;
  29. public boolean bshotInUse = false;
  30. public NpcInventory(L2NpcInstance owner)
  31. {
  32. _owner = owner;
  33. }
  34. public void reset()
  35. {
  36. this.destroyAllItems("Reset", null, null);
  37. if (_owner.getTemplate().ss > 0)
  38. this.addItem("Reset", 1835, _owner.getTemplate().ss, null, null);
  39. if (_owner.getTemplate().bss > 0)
  40. this.addItem("Reset", 3947, _owner.getTemplate().bss, null, null);
  41. }
  42. @Override
  43. public L2NpcInstance getOwner() { return _owner; }
  44. @Override
  45. protected ItemLocation getBaseLocation() { return ItemLocation.NPC; }
  46. @Override
  47. protected ItemLocation getEquipLocation() { return ItemLocation.NPC; }
  48. /**
  49. * Returns the list of all items in inventory that have a given item id.
  50. * @return L2ItemInstance[] : matching items from inventory
  51. */
  52. public L2ItemInstance[] getAllItemsByItemId(int itemId)
  53. {
  54. List<L2ItemInstance> list = new FastList<L2ItemInstance>();
  55. for (L2ItemInstance item : _items)
  56. {
  57. if (item.getItemId() == itemId)
  58. list.add(item);
  59. }
  60. return list.toArray(new L2ItemInstance[list.size()]);
  61. }
  62. /**
  63. * Refresh the weight of equipment loaded
  64. */
  65. @Override
  66. public void refreshWeight()
  67. {
  68. // not needed
  69. }
  70. /**
  71. * Get back items in inventory from database
  72. */
  73. @Override
  74. public void restore()
  75. {
  76. // not needed
  77. }
  78. }