CharInfo.java 14 KB

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