PetInfo.java 6.3 KB

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