CharInfo.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.data.xml.impl.NpcData;
  22. import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  23. import com.l2jserver.gameserver.model.PcCondOverride;
  24. import com.l2jserver.gameserver.model.actor.L2Decoy;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  27. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  28. import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
  29. import com.l2jserver.gameserver.model.zone.ZoneId;
  30. public class CharInfo extends L2GameServerPacket
  31. {
  32. private final L2PcInstance _activeChar;
  33. private int _objId;
  34. private int _x, _y, _z, _heading;
  35. private final int _mAtkSpd, _pAtkSpd;
  36. private final int _runSpd, _walkSpd;
  37. private final int _swimRunSpd;
  38. private final int _swimWalkSpd;
  39. private final int _flyRunSpd;
  40. private final int _flyWalkSpd;
  41. private final double _moveMultiplier;
  42. private final float _attackSpeedMultiplier;
  43. private int _vehicleId = 0;
  44. private static final int[] PAPERDOLL_ORDER = new int[]
  45. {
  46. Inventory.PAPERDOLL_UNDER,
  47. Inventory.PAPERDOLL_HEAD,
  48. Inventory.PAPERDOLL_RHAND,
  49. Inventory.PAPERDOLL_LHAND,
  50. Inventory.PAPERDOLL_GLOVES,
  51. Inventory.PAPERDOLL_CHEST,
  52. Inventory.PAPERDOLL_LEGS,
  53. Inventory.PAPERDOLL_FEET,
  54. Inventory.PAPERDOLL_CLOAK,
  55. Inventory.PAPERDOLL_RHAND,
  56. Inventory.PAPERDOLL_HAIR,
  57. Inventory.PAPERDOLL_HAIR2,
  58. Inventory.PAPERDOLL_RBRACELET,
  59. Inventory.PAPERDOLL_LBRACELET,
  60. Inventory.PAPERDOLL_DECO1,
  61. Inventory.PAPERDOLL_DECO2,
  62. Inventory.PAPERDOLL_DECO3,
  63. Inventory.PAPERDOLL_DECO4,
  64. Inventory.PAPERDOLL_DECO5,
  65. Inventory.PAPERDOLL_DECO6,
  66. Inventory.PAPERDOLL_BELT
  67. };
  68. public CharInfo(L2PcInstance cha)
  69. {
  70. _activeChar = cha;
  71. _objId = cha.getObjectId();
  72. if ((_activeChar.getVehicle() != null) && (_activeChar.getInVehiclePosition() != null))
  73. {
  74. _x = _activeChar.getInVehiclePosition().getX();
  75. _y = _activeChar.getInVehiclePosition().getY();
  76. _z = _activeChar.getInVehiclePosition().getZ();
  77. _vehicleId = _activeChar.getVehicle().getObjectId();
  78. }
  79. else
  80. {
  81. _x = _activeChar.getX();
  82. _y = _activeChar.getY();
  83. _z = _activeChar.getZ();
  84. }
  85. _heading = _activeChar.getHeading();
  86. _mAtkSpd = _activeChar.getMAtkSpd();
  87. _pAtkSpd = _activeChar.getPAtkSpd();
  88. _attackSpeedMultiplier = _activeChar.getAttackSpeedMultiplier();
  89. setInvisible(cha.isInvisible());
  90. _moveMultiplier = cha.getMovementSpeedMultiplier();
  91. _runSpd = (int) Math.round(cha.getRunSpeed() / _moveMultiplier);
  92. _walkSpd = (int) Math.round(cha.getWalkSpeed() / _moveMultiplier);
  93. _swimRunSpd = (int) Math.round(cha.getSwimRunSpeed() / _moveMultiplier);
  94. _swimWalkSpd = (int) Math.round(cha.getSwimWalkSpeed() / _moveMultiplier);
  95. _flyRunSpd = cha.isFlying() ? _runSpd : 0;
  96. _flyWalkSpd = cha.isFlying() ? _walkSpd : 0;
  97. }
  98. public CharInfo(L2Decoy decoy)
  99. {
  100. this(decoy.getActingPlayer()); // init
  101. _objId = decoy.getObjectId();
  102. _x = decoy.getX();
  103. _y = decoy.getY();
  104. _z = decoy.getZ();
  105. _heading = decoy.getHeading();
  106. }
  107. @Override
  108. protected final void writeImpl()
  109. {
  110. boolean gmSeeInvis = false;
  111. if (isInvisible())
  112. {
  113. final L2PcInstance activeChar = getClient().getActiveChar();
  114. if ((activeChar != null) && activeChar.canOverrideCond(PcCondOverride.SEE_ALL_PLAYERS))
  115. {
  116. gmSeeInvis = true;
  117. }
  118. }
  119. final L2NpcTemplate template = _activeChar.getPoly().isMorphed() ? NpcData.getInstance().getTemplate(_activeChar.getPoly().getPolyId()) : null;
  120. if (template != null)
  121. {
  122. writeC(0x0C);
  123. writeD(_objId);
  124. writeD(template.getId() + 1000000); // npctype id
  125. writeD(_activeChar.getKarma() > 0 ? 1 : 0);
  126. writeD(_x);
  127. writeD(_y);
  128. writeD(_z);
  129. writeD(_heading);
  130. writeD(0x00);
  131. writeD(_mAtkSpd);
  132. writeD(_pAtkSpd);
  133. writeD(_runSpd);
  134. writeD(_walkSpd);
  135. writeD(_swimRunSpd);
  136. writeD(_swimWalkSpd);
  137. writeD(_flyRunSpd);
  138. writeD(_flyWalkSpd);
  139. writeD(_flyRunSpd);
  140. writeD(_flyWalkSpd);
  141. writeF(_moveMultiplier);
  142. writeF(_attackSpeedMultiplier);
  143. writeF(template.getfCollisionRadius());
  144. writeF(template.getfCollisionHeight());
  145. writeD(template.getRHandId()); // right hand weapon
  146. writeD(template.getChestId()); // chest
  147. writeD(template.getLHandId()); // left hand weapon
  148. writeC(1); // name above char 1=true ... ??
  149. writeC(_activeChar.isRunning() ? 1 : 0);
  150. writeC(_activeChar.isInCombat() ? 1 : 0);
  151. writeC(_activeChar.isAlikeDead() ? 1 : 0);
  152. writeC(!gmSeeInvis && isInvisible() ? 1 : 0); // invisible ?? 0=false 1=true 2=summoned (only works if model has a summon animation)
  153. writeD(-1); // High Five NPCString ID
  154. writeS(_activeChar.getAppearance().getVisibleName());
  155. writeD(-1); // High Five NPCString ID
  156. writeS(gmSeeInvis ? "Invisible" : _activeChar.getAppearance().getVisibleTitle());
  157. writeD(_activeChar.getAppearance().getTitleColor()); // Title color 0=client default
  158. writeD(_activeChar.getPvpFlag()); // pvp flag
  159. writeD(_activeChar.getKarma()); // karma ??
  160. writeD(gmSeeInvis ? (_activeChar.getAbnormalVisualEffects() | AbnormalVisualEffect.STEALTH.getMask()) : _activeChar.getAbnormalVisualEffects()); // C2
  161. writeD(_activeChar.getClanId()); // clan id
  162. writeD(_activeChar.getClanCrestId()); // crest id
  163. writeD(_activeChar.getAllyId()); // ally id
  164. writeD(_activeChar.getAllyCrestId()); // all crest
  165. writeC(_activeChar.isFlying() ? 2 : 0); // is Flying
  166. writeC(_activeChar.getTeam().getId());
  167. writeF(template.getfCollisionRadius());
  168. writeF(template.getfCollisionHeight());
  169. writeD(0x00); // enchant effect
  170. writeD(_activeChar.isFlying() ? 2 : 0); // is Flying again?
  171. writeD(0x00);
  172. writeD(0x00); // CT1.5 Pet form and skills, Color effect
  173. writeC(template.isTargetable() ? 1 : 0); // targetable
  174. writeC(template.isShowName() ? 1 : 0); // show name
  175. writeC(_activeChar.getAbnormalVisualEffectSpecial());
  176. writeD(0x00);
  177. }
  178. else
  179. {
  180. writeC(0x31);
  181. writeD(_x);
  182. writeD(_y);
  183. writeD(_z);
  184. writeD(_vehicleId);
  185. writeD(_objId);
  186. writeS(_activeChar.getAppearance().getVisibleName());
  187. writeD(_activeChar.getRace().ordinal());
  188. writeD(_activeChar.getAppearance().getSex() ? 1 : 0);
  189. writeD(_activeChar.getBaseClass());
  190. for (int slot : getPaperdollOrder())
  191. {
  192. writeD(_activeChar.getInventory().getPaperdollItemDisplayId(slot));
  193. }
  194. for (int slot : getPaperdollOrder())
  195. {
  196. writeD(_activeChar.getInventory().getPaperdollAugmentationId(slot));
  197. }
  198. writeD(_activeChar.getInventory().getTalismanSlots());
  199. writeD(_activeChar.getInventory().canEquipCloak() ? 1 : 0);
  200. writeD(_activeChar.getPvpFlag());
  201. writeD(_activeChar.getKarma());
  202. writeD(_mAtkSpd);
  203. writeD(_pAtkSpd);
  204. writeD(0x00); // ?
  205. writeD(_runSpd);
  206. writeD(_walkSpd);
  207. writeD(_swimRunSpd);
  208. writeD(_swimWalkSpd);
  209. writeD(_flyRunSpd);
  210. writeD(_flyWalkSpd);
  211. writeD(_flyRunSpd);
  212. writeD(_flyWalkSpd);
  213. writeF(_moveMultiplier);
  214. writeF(_activeChar.getAttackSpeedMultiplier());
  215. writeF(_activeChar.getCollisionRadius());
  216. writeF(_activeChar.getCollisionHeight());
  217. writeD(_activeChar.getAppearance().getHairStyle());
  218. writeD(_activeChar.getAppearance().getHairColor());
  219. writeD(_activeChar.getAppearance().getFace());
  220. writeS(gmSeeInvis ? "Invisible" : _activeChar.getAppearance().getVisibleTitle());
  221. if (!_activeChar.isCursedWeaponEquipped())
  222. {
  223. writeD(_activeChar.getClanId());
  224. writeD(_activeChar.getClanCrestId());
  225. writeD(_activeChar.getAllyId());
  226. writeD(_activeChar.getAllyCrestId());
  227. }
  228. else
  229. {
  230. writeD(0x00);
  231. writeD(0x00);
  232. writeD(0x00);
  233. writeD(0x00);
  234. }
  235. writeC(_activeChar.isSitting() ? 0 : 1); // standing = 1 sitting = 0
  236. writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
  237. writeC(_activeChar.isInCombat() ? 1 : 0);
  238. writeC(!_activeChar.isInOlympiadMode() && _activeChar.isAlikeDead() ? 1 : 0);
  239. writeC(!gmSeeInvis && isInvisible() ? 1 : 0); // invisible = 1 visible =0
  240. writeC(_activeChar.getMountType().ordinal()); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
  241. writeC(_activeChar.getPrivateStoreType().getId());
  242. writeH(_activeChar.getCubics().size());
  243. for (int cubicId : _activeChar.getCubics().keySet())
  244. {
  245. writeH(cubicId);
  246. }
  247. writeC(_activeChar.isInPartyMatchRoom() ? 1 : 0);
  248. writeD(gmSeeInvis ? (_activeChar.getAbnormalVisualEffects() | AbnormalVisualEffect.STEALTH.getMask()) : _activeChar.getAbnormalVisualEffects());
  249. writeC(_activeChar.isInsideZone(ZoneId.WATER) ? 1 : _activeChar.isFlyingMounted() ? 2 : 0);
  250. writeH(_activeChar.getRecomHave()); // Blue value for name (0 = white, 255 = pure blue)
  251. writeD(_activeChar.getMountNpcId() + 1000000);
  252. writeD(_activeChar.getClassId().getId());
  253. writeD(0x00); // ?
  254. writeC(_activeChar.isMounted() ? 0 : _activeChar.getEnchantEffect());
  255. writeC(_activeChar.getTeam().getId());
  256. writeD(_activeChar.getClanCrestLargeId());
  257. writeC(_activeChar.isNoble() ? 1 : 0); // Symbol on char menu ctrl+I
  258. writeC(_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA) ? 1 : 0); // Hero Aura
  259. writeC(_activeChar.isFishing() ? 1 : 0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
  260. writeD(_activeChar.getFishx());
  261. writeD(_activeChar.getFishy());
  262. writeD(_activeChar.getFishz());
  263. writeD(_activeChar.getAppearance().getNameColor());
  264. writeD(_heading);
  265. writeD(_activeChar.getPledgeClass());
  266. writeD(_activeChar.getPledgeType());
  267. writeD(_activeChar.getAppearance().getTitleColor());
  268. writeD(_activeChar.isCursedWeaponEquipped() ? CursedWeaponsManager.getInstance().getLevel(_activeChar.getCursedWeaponEquippedId()) : 0);
  269. writeD(_activeChar.getClanId() > 0 ? _activeChar.getClan().getReputationScore() : 0);
  270. // T1
  271. writeD(_activeChar.getTransformationDisplayId());
  272. writeD(_activeChar.getAgathionId());
  273. // T2
  274. writeD(0x01);
  275. // T2.3
  276. writeD(_activeChar.getAbnormalVisualEffectSpecial());
  277. }
  278. }
  279. @Override
  280. protected int[] getPaperdollOrder()
  281. {
  282. return PAPERDOLL_ORDER;
  283. }
  284. }