PetStatusUpdate.java 2.4 KB

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