PetStatusUpdate.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 net.sf.l2j.gameserver.serverpackets;
  16. import net.sf.l2j.gameserver.model.L2Summon;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  18. /**
  19. * This class ...
  20. *
  21. * @version $Revision: 1.5.2.3.2.5 $ $Date: 2005/03/29 23:15:10 $
  22. */
  23. public class PetStatusUpdate extends L2GameServerPacket
  24. {
  25. private static final String _S__CE_PETSTATUSSHOW = "[S] b6 PetStatusUpdate";
  26. private L2Summon _summon;
  27. private int _maxHp, _maxMp;
  28. private int _maxFed, _curFed;
  29. public PetStatusUpdate(L2Summon summon)
  30. {
  31. _summon = summon;
  32. _maxHp = _summon.getMaxHp();
  33. _maxMp = _summon.getMaxMp();
  34. if (_summon instanceof L2PetInstance)
  35. {
  36. L2PetInstance pet = (L2PetInstance)_summon;
  37. _curFed = pet.getCurrentFed(); // how fed it is
  38. _maxFed = pet.getMaxFed(); //max fed it can be
  39. }
  40. }
  41. @Override
  42. protected final void writeImpl()
  43. {
  44. writeC(0xb6);
  45. writeD(_summon.getSummonType());
  46. writeD(_summon.getObjectId());
  47. writeD(_summon.getX());
  48. writeD(_summon.getY());
  49. writeD(_summon.getZ());
  50. writeS(_summon.getTitle());
  51. writeD(_curFed);
  52. writeD(_maxFed);
  53. writeD((int)_summon.getCurrentHp());
  54. writeD(_maxHp);
  55. writeD((int)_summon.getCurrentMp());
  56. writeD(_maxMp);
  57. writeD(_summon.getLevel());
  58. writeQ(_summon.getStat().getExp());
  59. writeQ(_summon.getExpForThisLevel());// 0% absolute value
  60. writeQ(_summon.getExpForNextLevel());// 100% absolute value
  61. }
  62. @Override
  63. public String getType()
  64. {
  65. return _S__CE_PETSTATUSSHOW;
  66. }
  67. }