CharInfo.java 16 KB

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