CharInfo.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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 java.util.logging.Logger;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.datatables.NpcTable;
  19. import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  22. import com.l2jserver.gameserver.skills.AbnormalEffect;
  23. import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
  24. /**
  25. * 0000: 03 32 15 00 00 44 fe 00 00 80 f1 ff ff 00 00 00 .2...D..........<p>
  26. * 0010: 00 6b b4 c0 4a 45 00 6c 00 6c 00 61 00 6d 00 69 .k..JE.l.l.a.m.i<p>
  27. * 0020: 00 00 00 01 00 00 00 01 00 00 00 12 00 00 00 00 ................<p>
  28. * 0030: 00 00 00 2a 00 00 00 42 00 00 00 71 02 00 00 31 ...*...B...q...1<p>
  29. * 0040: 00 00 00 18 00 00 00 1f 00 00 00 25 00 00 00 00 ...........%....<p>
  30. * 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f9 ................<p>
  31. * 0060: 00 00 00 b3 01 00 00 00 00 00 00 00 00 00 00 7d ...............}<p>
  32. * 0070: 00 00 00 5a 00 00 00 32 00 00 00 32 00 00 00 00 ...Z...2...2....<p>
  33. * 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 67 ...............g<p>
  34. * 0090: 66 66 66 66 66 f2 3f 5f 63 97 a8 de 1a f9 3f 00 fffff.?_c.....?.<p>
  35. * 00a0: 00 00 00 00 00 1e 40 00 00 00 00 00 00 37 40 01 .............7..<p>
  36. * 00b0: 00 00 00 01 00 00 00 01 00 00 00 00 00 c1 0c 00 ................<p>
  37. * 00c0: 00 00 00 00 00 00 00 00 00 01 01 00 00 00 00 00 ................<p>
  38. * 00d0: 00 00<p>
  39. * <p>
  40. * dddddSdddddddddddddddddddddddddddffffdddSdddccccccc (h)<p>
  41. * dddddSdddddddddddddddddddddddddddffffdddSdddddccccccch
  42. * dddddSddddddddddddddddddddddddddddffffdddSdddddccccccch (h) c (dchd) ddc dcc c cddd d
  43. * dddddSdddddddddddddddhhhhhhhhhhhhhhhhhhhhhhhhddddddddddddddffffdddSdddddccccccch [h] c (ddhd) ddc c ddc cddd d d dd d d d
  44. * @version $Revision: 1.7.2.6.2.11 $ $Date: 2005/04/11 10:05:54 $
  45. */
  46. public class CharInfo extends L2GameServerPacket
  47. {
  48. private static final Logger _log = Logger.getLogger(CharInfo.class.getName());
  49. private static final String _S__03_CHARINFO = "[S] 31 CharInfo";
  50. private L2PcInstance _activeChar;
  51. private Inventory _inv;
  52. private int _x, _y, _z, _heading;
  53. private int _mAtkSpd, _pAtkSpd;
  54. /**
  55. * Run speed, swimming run speed and flying run speed
  56. */
  57. private int _runSpd;
  58. /**
  59. * Walking speed, swimming walking speed and flying walking speed
  60. */
  61. private int _walkSpd;
  62. private float _moveMultiplier, _attackSpeedMultiplier;
  63. /**
  64. * @param _characters
  65. */
  66. public CharInfo(L2PcInstance cha)
  67. {
  68. _activeChar = cha;
  69. _inv = cha.getInventory();
  70. _x = _activeChar.getX();
  71. _y = _activeChar.getY();
  72. _z = _activeChar.getZ();
  73. _heading = _activeChar.getHeading();
  74. _mAtkSpd = _activeChar.getMAtkSpd();
  75. _pAtkSpd = _activeChar.getPAtkSpd();
  76. _moveMultiplier = _activeChar.getMovementSpeedMultiplier();
  77. _attackSpeedMultiplier = _activeChar.getAttackSpeedMultiplier();
  78. _runSpd = (int)(_activeChar.getRunSpeed()/_moveMultiplier);
  79. _walkSpd = (int)(_activeChar.getWalkSpeed()/_moveMultiplier);
  80. _invisible = cha.getAppearance().getInvisible();
  81. }
  82. @Override
  83. protected final void writeImpl()
  84. {
  85. boolean gmSeeInvis = false;
  86. if (_invisible)
  87. {
  88. L2PcInstance tmp = getClient().getActiveChar();
  89. if (tmp != null && tmp.isGM())
  90. gmSeeInvis = true;
  91. }
  92. if (_activeChar.getPoly().isMorphed())
  93. {
  94. L2NpcTemplate template = NpcTable.getInstance().getTemplate(_activeChar.getPoly().getPolyId());
  95. if (template != null)
  96. {
  97. writeC(0x0c);
  98. writeD(_activeChar.getObjectId());
  99. writeD(_activeChar.getPoly().getPolyId()+1000000); // npctype id
  100. writeD(_activeChar.getKarma() > 0 ? 1 : 0);
  101. writeD(_x);
  102. writeD(_y);
  103. writeD(_z);
  104. writeD(_heading);
  105. writeD(0x00);
  106. writeD(_mAtkSpd);
  107. writeD(_pAtkSpd);
  108. writeD(_runSpd); // TODO: the order of the speeds should be confirmed
  109. writeD(_walkSpd);
  110. writeD(_runSpd); // swim run speed
  111. writeD(_walkSpd); // swim walk speed
  112. writeD(_runSpd); // fly run speed
  113. writeD(_walkSpd); // fly walk speed
  114. writeD(_runSpd); // fly run speed ?
  115. writeD(_walkSpd); // fly walk speed ?
  116. writeF(_moveMultiplier);
  117. writeF(_attackSpeedMultiplier);
  118. writeF(template.fCollisionRadius);
  119. writeF(template.fCollisionHeight);
  120. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND)); // right hand weapon
  121. writeD(0);
  122. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND)); // left hand weapon
  123. writeC(1); // name above char 1=true ... ??
  124. writeC(_activeChar.isRunning() ? 1 : 0);
  125. writeC(_activeChar.isInCombat() ? 1 : 0);
  126. writeC(_activeChar.isAlikeDead() ? 1 : 0);
  127. if (gmSeeInvis)
  128. {
  129. writeC(0);
  130. }
  131. else
  132. {
  133. writeC(_invisible? 1 : 0); // invisible ?? 0=false 1=true 2=summoned (only works if model has a summon animation)
  134. }
  135. writeS(_activeChar.getAppearance().getVisibleName());
  136. if (gmSeeInvis)
  137. {
  138. writeS("Invisible");
  139. }
  140. else
  141. {
  142. writeS(_activeChar.getAppearance().getVisibleTitle());
  143. }
  144. writeD(0);
  145. writeD(0);
  146. writeD(0000); // hmm karma ??
  147. if (gmSeeInvis)
  148. {
  149. writeD( (_activeChar.getAbnormalEffect() | AbnormalEffect.STEALTH.getMask()) );
  150. }
  151. else
  152. {
  153. writeD(_activeChar.getAbnormalEffect()); // C2
  154. }
  155. writeD(_activeChar.getClanId()); //clan id
  156. writeD(_activeChar.getClanCrestId()); //crest id
  157. writeD(0); // C2
  158. writeD(0); // C2
  159. writeC(0); // C2
  160. writeC(0x00); // C3 team circle 1-blue, 2-red
  161. writeF(template.fCollisionRadius);
  162. writeF(template.fCollisionHeight);
  163. writeD(0x00); // C4
  164. writeD(0x00); // C6
  165. writeD(0x00);
  166. writeD(0x00);
  167. writeC(0x01);
  168. writeC(0x01);
  169. writeD(0x00);
  170. }
  171. else
  172. {
  173. _log.warning("Character "+_activeChar.getName()+" ("+_activeChar.getObjectId()+") morphed in a Npc ("+_activeChar.getPoly().getPolyId()+") w/o template.");
  174. }
  175. }
  176. else
  177. {
  178. writeC(0x31);
  179. writeD(_x);
  180. writeD(_y);
  181. writeD(_z);
  182. writeD(0x00);
  183. writeD(_activeChar.getObjectId());
  184. writeS(_activeChar.getAppearance().getVisibleName());
  185. writeD(_activeChar.getRace().ordinal());
  186. writeD(_activeChar.getAppearance().getSex()? 1 : 0);
  187. if (_activeChar.getClassIndex() == 0)
  188. writeD(_activeChar.getClassId().getId());
  189. else
  190. writeD(_activeChar.getBaseClass());
  191. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_UNDER));
  192. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
  193. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
  194. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
  195. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
  196. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
  197. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
  198. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
  199. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
  200. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LRHAND));
  201. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
  202. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
  203. // T1 new d's
  204. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
  205. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LBRACELET));
  206. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO1));
  207. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO2));
  208. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO3));
  209. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO4));
  210. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO5));
  211. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_DECO6));
  212. writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BELT));
  213. // end of t1 new d's
  214. // c6 new h's
  215. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_UNDER));
  216. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_HEAD));
  217. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_RHAND));
  218. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_LHAND));
  219. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_GLOVES));
  220. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_CHEST));
  221. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_LEGS));
  222. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_FEET));
  223. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_BACK));
  224. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_LRHAND));
  225. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_HAIR));
  226. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_HAIR2));
  227. // T1 new h's
  228. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_RBRACELET));
  229. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_LBRACELET));
  230. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO1));
  231. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO2));
  232. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO3));
  233. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO4));
  234. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO5));
  235. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_DECO6));
  236. writeD(_inv.getPaperdollAugmentationId(Inventory.PAPERDOLL_BELT));
  237. writeD(0x00);
  238. writeD(0x00);
  239. // end of t1 new h's
  240. writeD(_activeChar.getPvpFlag());
  241. writeD(_activeChar.getKarma());
  242. writeD(_mAtkSpd);
  243. writeD(_pAtkSpd);
  244. writeD(_activeChar.getPvpFlag());
  245. writeD(_activeChar.getKarma());
  246. writeD(_runSpd); // TODO: the order of the speeds should be confirmed
  247. writeD(_walkSpd);
  248. writeD(_runSpd); // swim run speed
  249. writeD(_walkSpd); // swim walk speed
  250. writeD(_runSpd); // fly run speed
  251. writeD(_walkSpd); // fly walk speed
  252. writeD(_runSpd); // fly run speed ?
  253. writeD(_walkSpd); // fly walk speed ?
  254. writeF(_activeChar.getMovementSpeedMultiplier()); // _activeChar.getProperMultiplier()
  255. writeF(_activeChar.getAttackSpeedMultiplier()); // _activeChar.getAttackSpeedMultiplier()
  256. if (_activeChar.getMountType() != 0)
  257. {
  258. writeF(NpcTable.getInstance().getTemplate(_activeChar.getMountNpcId()).fCollisionRadius);
  259. writeF(NpcTable.getInstance().getTemplate(_activeChar.getMountNpcId()).fCollisionHeight);
  260. }
  261. else if (_activeChar.getTransformation() != null)
  262. {
  263. writeF(_activeChar.getTransformation().getCollisionRadius());
  264. writeF(_activeChar.getTransformation().getCollisionHeight());
  265. }
  266. else
  267. {
  268. writeF(_activeChar.getCollisionRadius());
  269. writeF(_activeChar.getCollisionHeight());
  270. }
  271. writeD(_activeChar.getAppearance().getHairStyle());
  272. writeD(_activeChar.getAppearance().getHairColor());
  273. writeD(_activeChar.getAppearance().getFace());
  274. if (gmSeeInvis)
  275. {
  276. writeS("Invisible");
  277. }
  278. else
  279. {
  280. writeS(_activeChar.getAppearance().getVisibleTitle());
  281. }
  282. if (!_activeChar.isCursedWeaponEquipped())
  283. {
  284. writeD(_activeChar.getClanId());
  285. writeD(_activeChar.getClanCrestId());
  286. writeD(_activeChar.getAllyId());
  287. writeD(_activeChar.getAllyCrestId());
  288. }
  289. else
  290. {
  291. writeD(0);
  292. writeD(0);
  293. writeD(0);
  294. writeD(0);
  295. }
  296. // In UserInfo leader rights and siege flags, but here found nothing??
  297. // Therefore RelationChanged packet with that info is required
  298. writeD(0);
  299. writeC(_activeChar.isSitting() ? 0 : 1); // standing = 1 sitting = 0
  300. writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
  301. writeC(_activeChar.isInCombat() ? 1 : 0);
  302. writeC(_activeChar.isAlikeDead() ? 1 : 0);
  303. if (gmSeeInvis)
  304. {
  305. writeC(0);
  306. }
  307. else
  308. {
  309. writeC(_invisible ? 1 : 0); // invisible = 1 visible =0
  310. }
  311. writeC(_activeChar.getMountType()); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
  312. writeC(_activeChar.getPrivateStoreType()); // 1 - sellshop
  313. writeH(_activeChar.getCubics().size());
  314. for (int id : _activeChar.getCubics().keySet())
  315. writeH(id);
  316. writeC(0x00); // find party members
  317. if (gmSeeInvis)
  318. {
  319. writeD( (_activeChar.getAbnormalEffect() | AbnormalEffect.STEALTH.getMask()) );
  320. }
  321. else
  322. {
  323. writeD(_activeChar.getAbnormalEffect());
  324. }
  325. writeC(_activeChar.isFlying() ? 2 : 0);
  326. writeH(_activeChar.getRecomHave()); //Blue value for name (0 = white, 255 = pure blue)
  327. writeD(_activeChar.getMountNpcId() + 1000000);
  328. writeD(_activeChar.getClassId().getId());
  329. writeD(0x00); //?
  330. writeC(_activeChar.isMounted() ? 0 : _activeChar.getEnchantEffect());
  331. if(_activeChar.getTeam()==1)
  332. writeC(0x01); //team circle around feet 1= Blue, 2 = red
  333. else if(_activeChar.getTeam()==2)
  334. writeC(0x02); //team circle around feet 1= Blue, 2 = red
  335. else
  336. writeC(0x00); //team circle around feet 1= Blue, 2 = red
  337. writeD(_activeChar.getClanCrestLargeId());
  338. writeC(_activeChar.isNoble() ? 1 : 0); // Symbol on char menu ctrl+I
  339. writeC(_activeChar.isHero() || (_activeChar.isGM() && Config.GM_HERO_AURA) ? 1 : 0); // Hero Aura
  340. writeC(_activeChar.isFishing() ? 1 : 0); //0x01: Fishing Mode (Cant be undone by setting back to 0)
  341. writeD(_activeChar.getFishx());
  342. writeD(_activeChar.getFishy());
  343. writeD(_activeChar.getFishz());
  344. writeD(_activeChar.getAppearance().getNameColor());
  345. writeD(_heading);
  346. writeD(_activeChar.getPledgeClass());
  347. writeD(_activeChar.getPledgeType());
  348. writeD(_activeChar.getAppearance().getTitleColor());
  349. if (_activeChar.isCursedWeaponEquipped())
  350. writeD(CursedWeaponsManager.getInstance().getLevel(_activeChar.getCursedWeaponEquippedId()));
  351. else
  352. writeD(0x00);
  353. if (_activeChar.getClanId() > 0)
  354. writeD(_activeChar.getClan().getReputationScore());
  355. else
  356. writeD(0x00);
  357. // T1
  358. writeD(_activeChar.getTransformationId());
  359. writeD(_activeChar.getAgathionId());
  360. // T2
  361. writeD(0x01);
  362. // T2.3
  363. writeD(_activeChar.getSpecialEffect());
  364. writeD(0x00);
  365. writeD(0x00);
  366. writeD(0x00);
  367. }
  368. }
  369. /* (non-Javadoc)
  370. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  371. */
  372. @Override
  373. public String getType()
  374. {
  375. return _S__03_CHARINFO;
  376. }
  377. }