CharInfo.java 16 KB

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