PetInfo.java 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.6.2.5.2.12 $ $Date: 2005/03/31 09:19:16 $
  23. */
  24. public class PetInfo extends L2GameServerPacket
  25. {
  26. //private static Logger _log = Logger.getLogger(PetInfo.class.getName());
  27. private static final String _S__B2_PETINFO = "[S] b2 PetInfo";
  28. private L2Summon _summon;
  29. private int _x, _y, _z, _heading;
  30. private boolean _isSummoned;
  31. private int _val;
  32. private int _mAtkSpd, _pAtkSpd;
  33. private int _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd;
  34. private int _maxHp, _maxMp;
  35. private int _maxFed, _curFed;
  36. private float _multiplier;
  37. /**
  38. * rev 478 dddddddddddddddddddffffdddcccccSSdddddddddddddddddddddddddddhc
  39. * @param _characters
  40. */
  41. public PetInfo(L2Summon summon, int val)
  42. {
  43. _summon = summon;
  44. _isSummoned = _summon.isShowSummonAnimation();
  45. _x = _summon.getX();
  46. _y = _summon.getY();
  47. _z = _summon.getZ();
  48. _heading = _summon.getHeading();
  49. _mAtkSpd = _summon.getMAtkSpd();
  50. _pAtkSpd = _summon.getPAtkSpd();
  51. _multiplier = _summon.getMovementSpeedMultiplier();
  52. _runSpd = _summon.getPetSpeed();
  53. _walkSpd = _summon.isMountable() ? 45 : 30;
  54. _swimRunSpd = _flRunSpd = _flyRunSpd = _runSpd;
  55. _swimWalkSpd = _flWalkSpd = _flyWalkSpd = _walkSpd;
  56. _maxHp = _summon.getMaxVisibleHp();
  57. _maxMp = _summon.getMaxMp();
  58. _val = val;
  59. if (_summon instanceof L2PetInstance)
  60. {
  61. L2PetInstance pet = (L2PetInstance)_summon;
  62. _curFed = pet.getCurrentFed(); // how fed it is
  63. _maxFed = pet.getMaxFed(); //max fed it can be
  64. }
  65. else if (_summon instanceof L2SummonInstance)
  66. {
  67. L2SummonInstance sum = (L2SummonInstance)_summon;
  68. _curFed = sum.getTimeRemaining();
  69. _maxFed = sum.getTotalLifeTime();
  70. }
  71. }
  72. @Override
  73. protected final void writeImpl()
  74. {
  75. writeC(0xb2);
  76. writeD(_summon.getSummonType());
  77. writeD(_summon.getObjectId());
  78. writeD(_summon.getTemplate().idTemplate+1000000);
  79. writeD(0); // 1=attackable
  80. writeD(_x);
  81. writeD(_y);
  82. writeD(_z);
  83. writeD(_heading);
  84. writeD(0);
  85. writeD(_mAtkSpd);
  86. writeD(_pAtkSpd);
  87. writeD(_runSpd);
  88. writeD(_walkSpd);
  89. writeD(_swimRunSpd);
  90. writeD(_swimWalkSpd);
  91. writeD(_flRunSpd);
  92. writeD(_flWalkSpd);
  93. writeD(_flyRunSpd);
  94. writeD(_flyWalkSpd);
  95. writeF(_multiplier); // movement multiplier
  96. writeF(1); // attack speed multiplier
  97. writeF(_summon.getTemplate().fCollisionRadius);
  98. writeF(_summon.getTemplate().fCollisionHeight);
  99. writeD(_summon.getWeapon()); // right hand weapon
  100. writeD(_summon.getArmor()); // body armor
  101. writeD(0); // left hand weapon
  102. writeC(_summon.getOwner() != null ? 1 : 0); // when pet is dead and player exit game, pet doesn't show master name
  103. writeC(1); // running=1 (it is always 1, walking mode is calculated from multiplier)
  104. writeC(_summon.isInCombat() ? 1 : 0); // attacking 1=true
  105. writeC(_summon.isAlikeDead() ? 1 : 0); // dead 1=true
  106. writeC(_isSummoned ? 2 : _val); // 0=teleported 1=default 2=summoned
  107. writeS(_summon.getName()); // summon name
  108. writeS(_summon.getTitle()); // owner name
  109. writeD(1);
  110. writeD(_summon.getOwner() != null ? _summon.getOwner().getPvpFlag() : 0); //0 = white,2= purpleblink, if its greater then karma = purple
  111. writeD(_summon.getOwner() != null ? _summon.getOwner().getKarma() : 0); // karma
  112. writeD(_curFed); // how fed it is
  113. writeD(_maxFed); //max fed it can be
  114. writeD((int)_summon.getCurrentHp());//current hp
  115. writeD(_maxHp);// max hp
  116. writeD((int)_summon.getCurrentMp());//current mp
  117. writeD(_maxMp);//max mp
  118. writeD(_summon.getStat().getSp()); //sp
  119. writeD(_summon.getLevel());// lvl
  120. writeQ(_summon.getStat().getExp());
  121. if (_summon.getExpForThisLevel()>_summon.getStat().getExp())
  122. writeQ(_summon.getStat().getExp());// 0% absolute value
  123. else
  124. writeQ(_summon.getExpForThisLevel());// 0% absolute value
  125. writeQ(_summon.getExpForNextLevel());// 100% absoulte value
  126. writeD(_summon instanceof L2PetInstance ? _summon.getInventory().getTotalWeight() : 0);//weight
  127. writeD(_summon.getMaxLoad());//max weight it can carry
  128. writeD(_summon.getPAtk(null));//patk
  129. writeD(_summon.getPDef(null));//pdef
  130. writeD(_summon.getMAtk(null,null));//matk
  131. writeD(_summon.getMDef(null,null));//mdef
  132. writeD(_summon.getAccuracy());//accuracy
  133. writeD(_summon.getEvasionRate(null));//evasion
  134. writeD(_summon.getCriticalHit(null,null));//critical
  135. writeD((int) _summon.getStat().getMoveSpeed());//speed
  136. writeD(_summon.getPAtkSpd());//atkspeed
  137. writeD(_summon.getMAtkSpd());//casting speed
  138. writeD(_summon.getAbnormalEffect());//c2 abnormal visual effect... bleed=1; poison=2; poison & bleed=3; flame=4;
  139. int npcId = _summon.getTemplate().npcId;
  140. writeH(_summon.isMountable() ? 1 : 0);//c2 ride button
  141. writeC(0); // c2
  142. // Following all added in C4.
  143. writeH(0); // ??
  144. writeC(_summon.getOwner() != null ? _summon.getOwner().getTeam() : 0); // team aura (1 = blue, 2 = red)
  145. writeD(_summon.getSoulShotsPerHit()); // How many soulshots this servitor uses per hit
  146. writeD(_summon.getSpiritShotsPerHit()); // How many spiritshots this servitor uses per hit
  147. int form = 0;
  148. if (npcId == 16041 || npcId == 16042)
  149. {
  150. if(_summon.getLevel() > 84)
  151. form = 3;
  152. else if(_summon.getLevel() > 79)
  153. form = 2;
  154. else if(_summon.getLevel() > 74)
  155. form = 1;
  156. }
  157. else if (npcId == 16025 ||npcId == 16037)
  158. {
  159. if(_summon.getLevel() > 69)
  160. form = 3;
  161. else if(_summon.getLevel() > 64)
  162. form = 2;
  163. else if(_summon.getLevel() > 59)
  164. form = 1;
  165. }
  166. writeD(form);//CT1.5 Pet form and skills
  167. writeD(_summon.getSpecialEffect());
  168. }
  169. /* (non-Javadoc)
  170. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  171. */
  172. @Override
  173. public String getType()
  174. {
  175. return _S__B2_PETINFO;
  176. }
  177. }