RequestPetGetItem.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.clientpackets;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
  18. import com.l2jserver.gameserver.instancemanager.MercTicketManager;
  19. import com.l2jserver.gameserver.model.L2ItemInstance;
  20. import com.l2jserver.gameserver.model.L2World;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  22. import com.l2jserver.gameserver.model.actor.instance.L2SummonInstance;
  23. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  24. /**
  25. * This class ...
  26. *
  27. * @version $Revision: 1.2.4.4 $ $Date: 2005/03/29 23:15:33 $
  28. */
  29. public final class RequestPetGetItem extends L2GameClientPacket
  30. {
  31. //private static Logger _log = Logger.getLogger(RequestPetGetItem.class.getName());
  32. private static final String _C__8f_REQUESTPETGETITEM= "[C] 8F RequestPetGetItem";
  33. private int _objectId;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _objectId = readD();
  38. }
  39. @Override
  40. protected void runImpl()
  41. {
  42. L2World world = L2World.getInstance();
  43. L2ItemInstance item = (L2ItemInstance)world.findObject(_objectId);
  44. if (item == null || getClient().getActiveChar() == null)
  45. return;
  46. int castleId = MercTicketManager.getInstance().getTicketCastleId(item.getItemId());
  47. if (castleId > 0) {
  48. sendPacket(ActionFailed.STATIC_PACKET);
  49. return;
  50. }
  51. if(getClient().getActiveChar().getPet() instanceof L2SummonInstance)
  52. {
  53. sendPacket(ActionFailed.STATIC_PACKET);
  54. return;
  55. }
  56. L2PetInstance pet = (L2PetInstance)getClient().getActiveChar().getPet();
  57. if (pet == null || pet.isDead() || pet.isOutOfControl())
  58. {
  59. sendPacket(ActionFailed.STATIC_PACKET);
  60. return;
  61. }
  62. if(FortSiegeManager.getInstance().isCombat(item.getItemId()) )
  63. {
  64. sendPacket(ActionFailed.STATIC_PACKET);
  65. return;
  66. }
  67. pet.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, item);
  68. }
  69. @Override
  70. public String getType()
  71. {
  72. return _C__8f_REQUESTPETGETITEM;
  73. }
  74. }