Advertisement
Guest User

Polymorph

a guest
Apr 12th, 2010
1,932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 28.90 KB | None | 0 0
  1. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/L2MaxPolyModel.java
  2. ===================================================================
  3. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/L2MaxPolyModel.java  (revision 0)
  4. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/L2MaxPolyModel.java  (revision 0)
  5. @@ -0,0 +1,518 @@
  6. +/* This program 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 2, or (at your option)
  9. + * any later version.
  10. + *
  11. + * This program 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
  14. + * GNU 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, write to the Free Software
  18. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. + * 02111-1307, USA.
  20. + *
  21. + * http://www.gnu.org/copyleft/gpl.html
  22. + */
  23. +package net.sf.l2j.gameserver.model;
  24. +
  25. +import net.sf.l2j.gameserver.datatables.ArmorSetsTable;
  26. +import net.sf.l2j.gameserver.datatables.CharTemplateTable;
  27. +import net.sf.l2j.gameserver.datatables.ClanTable;
  28. +import net.sf.l2j.gameserver.datatables.ArmorSetsTable.ArmorDummy;
  29. +import net.sf.l2j.gameserver.model.base.Race;
  30. +import net.sf.l2j.gameserver.templates.StatsSet;
  31. +
  32. +/**
  33. + *
  34. + * @author Velvet
  35. + */
  36. +public class L2MaxPolyModel
  37. +{
  38. +   // Base
  39. +   private String _name;
  40. +   private String _title;
  41. +   private Race _race;
  42. +   private int _sex;
  43. +   private int _hair;
  44. +   private int _hairColor;
  45. +   private int _face;
  46. +   private int _classId;
  47. +   private int _npcId;
  48. +              
  49. +   // Item related
  50. +   private int _weaponIdRH;
  51. +   private int _weaponIdLH;
  52. +   private int _weaponIdEnc;
  53. +   private int _armorId; // all others p_dolls will be set auto if the value is a valid armor set id
  54. +   private int _head; // not seen
  55. +   private int _hats;
  56. +   private int _faces;
  57. +   private int _chest;
  58. +   private int _legs;
  59. +   private int _gloves;
  60. +   private int _feet;
  61. +  
  62. +   // Misc
  63. +   private int _abnormalEffect;
  64. +   private int _pvpFlag;
  65. +   private int _karma;
  66. +   private int _recom;
  67. +   private L2Clan _clan;
  68. +   private int _isHero;
  69. +   private int _pledge;
  70. +   private int _nameColor = 0xFFFFFF;
  71. +   private int _titleColor = 0xFFFF77;
  72. +
  73. +   public L2MaxPolyModel(StatsSet data)
  74. +   {
  75. +       _name = data.getString("name");
  76. +       _title = data.getString("title");
  77. +       _sex = data.getInteger("sex");
  78. +       _hair = data.getInteger("hair");
  79. +       _hairColor = data.getInteger("hairColor");
  80. +       _face = data.getInteger("face");
  81. +       _classId = data.getInteger("classId");
  82. +       _npcId = data.getInteger("npcId");
  83. +       _weaponIdRH = data.getInteger("weaponIdRH");
  84. +       _weaponIdLH = data.getInteger("weaponIdLH");
  85. +       _weaponIdEnc = data.getInteger("weaponIdEnc");
  86. +       _armorId = data.getInteger("armorId");
  87. +       _head = data.getInteger("head");
  88. +       _hats = data.getInteger("hats");
  89. +       _faces = data.getInteger("faces");
  90. +       _chest = data.getInteger("chest");
  91. +       _legs = data.getInteger("legs");
  92. +       _gloves = data.getInteger("gloves");
  93. +       _feet = data.getInteger("feet");
  94. +       _abnormalEffect = data.getInteger("abnormalEffect");
  95. +       _pvpFlag = data.getInteger("pvpFlag");
  96. +       _karma = data.getInteger("karma");
  97. +       _recom = data.getInteger("recom");
  98. +       _clan = ClanTable.getInstance().getClan(data.getInteger("clan"));
  99. +       _isHero = data.getInteger("isHero");
  100. +       _pledge = data.getInteger("pledge");
  101. +      
  102. +       if(data.getInteger("nameColor") > 0)
  103. +           _nameColor = data.getInteger("nameColor");
  104. +       if(data.getInteger("titleColor") > 0)
  105. +           _titleColor = data.getInteger("titleColor");
  106. +      
  107. +       _race = CharTemplateTable.getInstance().getTemplate(_classId).race;
  108. +      
  109. +       ArmorDummy armor = ArmorSetsTable.getInstance().getCusArmorSets(_armorId);
  110. +
  111. +       if(armor != null)
  112. +       {
  113. +           _head = armor.getHead();
  114. +           _chest = armor.getChest();
  115. +           _legs = armor.getLegs();
  116. +           _gloves = armor.getGloves();
  117. +           _feet = armor.getFeet();
  118. +       }
  119. +   }
  120. +  
  121. +   /**
  122. +    * @return Returns the name.
  123. +    */
  124. +   public String getName()
  125. +   {
  126. +       return _name;
  127. +   }
  128. +   /**
  129. +    * @param name The name to set.
  130. +    */
  131. +   public void setName(String name)
  132. +   {
  133. +       _name = name;
  134. +   }
  135. +   /**
  136. +    * @return Returns the title.
  137. +    */
  138. +   public String getTitle()
  139. +   {
  140. +       return _title;
  141. +   }
  142. +   /**
  143. +    * @param title The title to set.
  144. +    */
  145. +   public void setTitle(String title)
  146. +   {
  147. +       _title = title;
  148. +   }
  149. +   /**
  150. +    * @return Returns the sex.
  151. +    */
  152. +   public int getSex()
  153. +   {
  154. +       return _sex;
  155. +   }
  156. +   /**
  157. +    * @param sex The sex to set.
  158. +    */
  159. +   public void setSex(int sex)
  160. +   {
  161. +       _sex = sex;
  162. +   }
  163. +   /**
  164. +    * @return Returns the hair.
  165. +    */
  166. +   public int getHair()
  167. +   {
  168. +       return _hair;
  169. +   }
  170. +   /**
  171. +    * @param hair The hair to set.
  172. +    */
  173. +   public void setHair(int hair)
  174. +   {
  175. +       _hair = hair;
  176. +   }
  177. +   /**
  178. +    * @return Returns the hairColor.
  179. +    */
  180. +   public int getHairColor()
  181. +   {
  182. +       return _hairColor;
  183. +   }
  184. +   /**
  185. +    * @param hairColor The hairColor to set.
  186. +    */
  187. +   public void setHairColor(int hairColor)
  188. +   {
  189. +       _hairColor = hairColor;
  190. +   }
  191. +   /**
  192. +    * @return Returns the face.
  193. +    */
  194. +   public int getFace()
  195. +   {
  196. +       return _face;
  197. +   }
  198. +   /**
  199. +    * @param face The face to set.
  200. +    */
  201. +   public void setFace(int face)
  202. +   {
  203. +       _face = face;
  204. +   }
  205. +   /**
  206. +    * @return Returns the classId.
  207. +    */
  208. +   public int getClassId()
  209. +   {
  210. +       return _classId;
  211. +   }
  212. +   /**
  213. +    * @param classId The classId to set.
  214. +    */
  215. +   public void setClassId(int classId)
  216. +   {
  217. +       _classId = classId;
  218. +   }
  219. +
  220. +   /**
  221. +    * @return Returns the weaponIdRH.
  222. +    */
  223. +   public int getWeaponIdRH()
  224. +   {
  225. +       return _weaponIdRH;
  226. +   }
  227. +  
  228. +   /**
  229. +    * @return Returns the weaponIdRH.
  230. +    */
  231. +   public int getWeaponIdLH()
  232. +   {
  233. +       return _weaponIdLH;
  234. +   }
  235. +  
  236. +   /**
  237. +    * @param weaponIdRH The weaponIdRH to set.
  238. +    */
  239. +   public void setWeaponIdRH(int weaponIdRH)
  240. +   {
  241. +       _weaponIdRH = weaponIdRH;
  242. +   }
  243. +  
  244. +   public void setWeaponIdLH(int weaponIdLH)
  245. +   {
  246. +       _weaponIdLH = weaponIdLH;
  247. +   }
  248. +  
  249. +   /**
  250. +    * @return Returns the weaponIdEnc.
  251. +    */
  252. +   public int getWeaponIdEnc()
  253. +   {
  254. +       return _weaponIdEnc;
  255. +   }
  256. +   /**
  257. +    * @param weaponIdEnc The weaponIdEnc to set.
  258. +    */
  259. +   public void setWeaponIdEnc(int weaponIdEnc)
  260. +   {
  261. +       _weaponIdEnc = weaponIdEnc;
  262. +   }
  263. +   /**
  264. +    * @return Returns the armorId.
  265. +    */
  266. +   public int getArmorId()
  267. +   {
  268. +       return _armorId;
  269. +   }
  270. +   /**
  271. +    * @param armorId The armorId to set.
  272. +    */
  273. +   public void setArmorId(int armorId)
  274. +   {
  275. +       _armorId = armorId;
  276. +   }
  277. +   /**
  278. +    * @return Returns the head.
  279. +    */
  280. +   public int getHead()
  281. +   {
  282. +       return _head;
  283. +   }
  284. +   /**
  285. +    * @param head The head to set.
  286. +    */
  287. +   public void setHead(int head)
  288. +   {
  289. +       _head = head;
  290. +   }
  291. +   /**
  292. +    * @return Returns the hats.
  293. +    */
  294. +   public int getHats()
  295. +   {
  296. +       return _hats;
  297. +   }
  298. +   /**
  299. +    * @param hats The hats to set.
  300. +    */
  301. +   public void setHats(int hats)
  302. +   {
  303. +       _hats = hats;
  304. +   }
  305. +   /**
  306. +    * @return Returns the faces.
  307. +    */
  308. +   public int getFaces()
  309. +   {
  310. +       return _faces;
  311. +   }
  312. +   /**
  313. +    * @param faces The faces to set.
  314. +    */
  315. +   public void setFaces(int faces)
  316. +   {
  317. +       _faces = faces;
  318. +   }
  319. +   /**
  320. +    * @return Returns the chest.
  321. +    */
  322. +   public int getChest()
  323. +   {
  324. +       return _chest;
  325. +   }
  326. +   /**
  327. +    * @param chest The chest to set.
  328. +    */
  329. +   public void setChest(int chest)
  330. +   {
  331. +       _chest = chest;
  332. +   }
  333. +   /**
  334. +    * @return Returns the legs.
  335. +    */
  336. +   public int getLegs()
  337. +   {
  338. +       return _legs;
  339. +   }
  340. +   /**
  341. +    * @param legs The legs to set.
  342. +    */
  343. +   public void setLegs(int legs)
  344. +   {
  345. +       _legs = legs;
  346. +   }
  347. +   /**
  348. +    * @return Returns the gloves.
  349. +    */
  350. +   public int getGloves()
  351. +   {
  352. +       return _gloves;
  353. +   }
  354. +   /**
  355. +    * @param gloves The gloves to set.
  356. +    */
  357. +   public void setGloves(int gloves)
  358. +   {
  359. +       _gloves = gloves;
  360. +   }
  361. +   /**
  362. +    * @return Returns the feet.
  363. +    */
  364. +   public int getFeet()
  365. +   {
  366. +       return _feet;
  367. +   }
  368. +   /**
  369. +    * @param feet The feet to set.
  370. +    */
  371. +   public void setFeet(int feet)
  372. +   {
  373. +       _feet = feet;
  374. +   }
  375. +   /**
  376. +    * @return Returns the abnormalEffect.
  377. +    */
  378. +   public int getAbnormalEffect()
  379. +   {
  380. +       return _abnormalEffect;
  381. +   }
  382. +   /**
  383. +    * @param abnormalEffect The abnormalEffect to set.
  384. +    */
  385. +   public void setAbnormalEffect(int abnormalEffect)
  386. +   {
  387. +       _abnormalEffect = abnormalEffect;
  388. +   }
  389. +   /**
  390. +    * @return Returns the pvpFlag.
  391. +    */
  392. +   public int getPvpFlag()
  393. +   {
  394. +       return _pvpFlag;
  395. +   }
  396. +   /**
  397. +    * @param pvpFlag The pvpFlag to set.
  398. +    */
  399. +   public void setPvpFlag(int pvpFlag)
  400. +   {
  401. +       _pvpFlag = pvpFlag;
  402. +   }
  403. +   /**
  404. +    * @return Returns the karma.
  405. +    */
  406. +   public int getKarma()
  407. +   {
  408. +       return _karma;
  409. +   }
  410. +   /**
  411. +    * @param karma The karma to set.
  412. +    */
  413. +   public void setKarma(int karma)
  414. +   {
  415. +       _karma = karma;
  416. +   }
  417. +   /**
  418. +    * @return Returns the recom.
  419. +    */
  420. +   public int getRecom()
  421. +   {
  422. +       return _recom;
  423. +   }
  424. +   /**
  425. +    * @param recom The recom to set.
  426. +    */
  427. +   public void setRecom(int recom)
  428. +   {
  429. +       _recom = recom;
  430. +   }
  431. +   /**
  432. +    * @return Returns the clan.
  433. +    */
  434. +   public L2Clan getClan()
  435. +   {
  436. +       return _clan;
  437. +   }
  438. +   /**
  439. +    * @param clan The clan to set.
  440. +    */
  441. +   public void setClan(L2Clan clan)
  442. +   {
  443. +       _clan = clan;
  444. +   }
  445. +   /**
  446. +    * @return Returns the isHero.
  447. +    */
  448. +   public int getIsHero()
  449. +   {
  450. +       return _isHero;
  451. +   }
  452. +   /**
  453. +    * @param isHero The isHero to set.
  454. +    */
  455. +   public void setIsHero(int isHero)
  456. +   {
  457. +       _isHero = isHero;
  458. +   }
  459. +   /**
  460. +    * @return Returns the pledge.
  461. +    */
  462. +   public int getPledge()
  463. +   {
  464. +       return _pledge;
  465. +   }
  466. +   /**
  467. +    * @param pledge The pledge to set.
  468. +    */
  469. +   public void setPledge(int pledge)
  470. +   {
  471. +       _pledge = pledge;
  472. +   }
  473. +   /**
  474. +    * @return Returns the nameColor.
  475. +    */
  476. +   public int getNameColor()
  477. +   {
  478. +       return _nameColor;
  479. +   }
  480. +   /**
  481. +    * @param nameColor The nameColor to set.
  482. +    */
  483. +   public void setNameColor(int nameColor)
  484. +   {
  485. +       _nameColor = nameColor;
  486. +   }
  487. +   /**
  488. +    * @return Returns the titleColor.
  489. +    */
  490. +   public int getTitleColor()
  491. +   {
  492. +       return _titleColor;
  493. +   }
  494. +   /**
  495. +    * @param titleColor The titleColor to set.
  496. +    */
  497. +   public void setTitleColor(int titleColor)
  498. +   {
  499. +       _titleColor = titleColor;
  500. +   }
  501. +
  502. +   /**
  503. +    * @param npcId The npcId to set.
  504. +    */
  505. +   public void setNpcId(int npcId)
  506. +   {
  507. +       _npcId = npcId;
  508. +   }
  509. +
  510. +   /**
  511. +    * @return Returns the npcId.
  512. +    */
  513. +   public int getNpcId()
  514. +   {
  515. +       return _npcId;
  516. +   }
  517. +  
  518. +   public Race getRace()
  519. +   {
  520. +       return _race;
  521. +   }
  522. +  
  523. +}
  524. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
  525. ===================================================================
  526. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java    (revision 4034)
  527. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java    (working copy)
  528. @@ -32,9 +32,11 @@
  529.  import net.sf.l2j.gameserver.ThreadPoolManager;
  530.  import net.sf.l2j.gameserver.ai.CtrlIntention;
  531.  import net.sf.l2j.gameserver.cache.HtmCache;
  532. +import net.sf.l2j.gameserver.datatables.CharTemplateTable;
  533.  import net.sf.l2j.gameserver.datatables.ClanTable;
  534.  import net.sf.l2j.gameserver.datatables.HelperBuffTable;
  535.  import net.sf.l2j.gameserver.datatables.ItemTable;
  536. +import net.sf.l2j.gameserver.datatables.MaxCheatersTable;
  537.  import net.sf.l2j.gameserver.datatables.SkillTable;
  538.  import net.sf.l2j.gameserver.datatables.SpawnTable;
  539.  import net.sf.l2j.gameserver.idfactory.IdFactory;
  540. @@ -49,6 +51,7 @@
  541.  import net.sf.l2j.gameserver.model.L2DropCategory;
  542.  import net.sf.l2j.gameserver.model.L2DropData;
  543.  import net.sf.l2j.gameserver.model.L2ItemInstance;
  544. +import net.sf.l2j.gameserver.model.L2MaxPolyModel;
  545.  import net.sf.l2j.gameserver.model.L2Multisell;
  546.  import net.sf.l2j.gameserver.model.L2Object;
  547.  import net.sf.l2j.gameserver.model.L2Skill;
  548. @@ -127,6 +130,8 @@
  549.  
  550.      private int _isSpoiledBy = 0;
  551.  
  552. +    private final L2MaxPolyModel _mxcModel;
  553. +    
  554.      protected RandomAnimationTask _rAniTask = null;
  555.      private int _currentLHandId;  // normally this shouldn't change from the template, but there exist exceptions
  556.      private int _currentRHandId;  // normally this shouldn't change from the template, but there exist exceptions
  557. @@ -270,6 +275,21 @@
  558.          _currentCollisionHeight = getTemplate().collisionHeight;
  559.          _currentCollisionRadius = getTemplate().collisionRadius;
  560.          
  561. +        // Velvet - MxC
  562. +        _mxcModel = MaxCheatersTable.getInstance().getModelForID(template.npcId);
  563. +
  564. +        if(_mxcModel != null) // Lil Config xD
  565. +        {
  566. +           _currentCollisionHeight = CharTemplateTable.getInstance().getTemplate(_mxcModel.getClassId()).collisionHeight;
  567. +           _currentCollisionRadius = CharTemplateTable.getInstance().getTemplate(_mxcModel.getClassId()).collisionRadius;
  568. +
  569. +           if(_mxcModel.getWeaponIdRH() <= 0 && _mxcModel.getWeaponIdLH() <= 0)
  570. +           {
  571. +               _mxcModel.setWeaponIdRH(template.rhand);
  572. +               _mxcModel.setWeaponIdLH(template.lhand);
  573. +           }
  574. +        }
  575. +
  576.          if (template == null)
  577.          {
  578.              _log.severe("No template for Npc. Please check your datapack is setup correctly.");
  579. @@ -278,7 +298,6 @@
  580.  
  581.          // Set the name of the L2Character
  582.          setName(template.name);
  583. -
  584.      }
  585.  
  586.      @Override
  587. @@ -2283,4 +2302,9 @@
  588.      {
  589.         return _currentCollisionRadius;
  590.      }
  591. +
  592. +    public L2MaxPolyModel getMxcPoly()
  593. +    {
  594. +       return _mxcModel;
  595. +    }
  596.  }
  597. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/GameServer.java
  598. ===================================================================
  599. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/GameServer.java    (revision 4034)
  600. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/GameServer.java    (working copy)
  601. @@ -48,6 +48,7 @@
  602.  import net.sf.l2j.gameserver.datatables.ItemTable;
  603.  import net.sf.l2j.gameserver.datatables.LevelUpData;
  604.  import net.sf.l2j.gameserver.datatables.MapRegionTable;
  605. +import net.sf.l2j.gameserver.datatables.MaxCheatersTable;
  606.  import net.sf.l2j.gameserver.datatables.NobleSkillTable;
  607.  import net.sf.l2j.gameserver.datatables.NpcTable;
  608.  import net.sf.l2j.gameserver.datatables.NpcWalkerRoutesTable;
  609. @@ -393,6 +394,7 @@
  610.         TeleportLocationTable.getInstance();
  611.         LevelUpData.getInstance();
  612.         L2World.getInstance();
  613. +       MaxCheatersTable.getInstance();
  614.         ZoneData.getInstance();
  615.          SpawnTable.getInstance();
  616.          RaidBossSpawnManager.getInstance();
  617. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/MxCPolyInfo.java
  618. ===================================================================
  619. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/MxCPolyInfo.java (revision 0)
  620. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/MxCPolyInfo.java (revision 0)
  621. @@ -0,0 +1,158 @@
  622. +/*
  623. + * This program is free software; you can redistribute it and/or modify
  624. + * it under the terms of the GNU General Public License as published by
  625. + * the Free Software Foundation; either version 2, or (at your option)
  626. + * any later version.
  627. + *
  628. + * This program is distributed in the hope that it will be useful,
  629. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  630. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  631. + * GNU General Public License for more details.
  632. + *
  633. + * You should have received a copy of the GNU General Public License
  634. + * along with this program; if not, write to the Free Software
  635. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  636. + * 02111-1307, USA.
  637. + *
  638. + * http://www.gnu.org/copyleft/gpl.html
  639. + */
  640. +package net.sf.l2j.gameserver.serverpackets;
  641. +
  642. +import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  643. +
  644. +/**
  645. + *
  646. + * @author Velvet
  647. + */
  648. +public class MxCPolyInfo extends L2GameServerPacket
  649. +{
  650. +   private L2NpcInstance _activeChar;
  651. +   private int _x, _y, _z, _heading;
  652. +   private int _runSpd, _walkSpd, _swimRunSpd, _swimWalkSpd, _flRunSpd, _flWalkSpd, _flyRunSpd, _flyWalkSpd;
  653. +   private float _moveMultiplier;
  654. +   private int _maxCp;
  655. +
  656. +   public MxCPolyInfo(L2NpcInstance cha)
  657. +   {
  658. +       _activeChar = cha;
  659. +       _x = _activeChar.getX();
  660. +       _y = _activeChar.getY();
  661. +       _z = _activeChar.getZ();
  662. +       _heading = _activeChar.getHeading();
  663. +       _moveMultiplier = _activeChar.getMovementSpeedMultiplier();
  664. +       _runSpd = (int) (_activeChar.getRunSpeed() / _moveMultiplier);
  665. +       _walkSpd = (int) (_activeChar.getWalkSpeed() / _moveMultiplier);
  666. +       _swimRunSpd = _flRunSpd = _flyRunSpd = _runSpd;
  667. +       _swimWalkSpd = _flWalkSpd = _flyWalkSpd = _walkSpd;
  668. +       _maxCp = _activeChar.getMaxCp();
  669. +   }
  670. +
  671. +   @Override
  672. +   protected final void writeImpl()
  673. +   {
  674. +       writeC(0x03);
  675. +       writeD(_x);
  676. +       writeD(_y);
  677. +       writeD(_z);
  678. +       writeD(_heading);
  679. +       writeD(_activeChar.getObjectId());
  680. +       writeS(_activeChar.getMxcPoly().getName());
  681. +       writeD(_activeChar.getMxcPoly().getRace().ordinal());
  682. +       writeD(_activeChar.getMxcPoly().getSex());
  683. +       writeD(_activeChar.getMxcPoly().getClassId());
  684. +       writeD(_activeChar.getMxcPoly().getHats());
  685. +       writeD(_activeChar.getMxcPoly().getHead());
  686. +       writeD(_activeChar.getMxcPoly().getWeaponIdRH());
  687. +       writeD(_activeChar.getMxcPoly().getWeaponIdLH());
  688. +       writeD(_activeChar.getMxcPoly().getGloves());
  689. +       writeD(_activeChar.getMxcPoly().getChest());
  690. +       writeD(_activeChar.getMxcPoly().getLegs());
  691. +       writeD(_activeChar.getMxcPoly().getFeet());
  692. +       writeD(_activeChar.getMxcPoly().getHats());
  693. +       writeD(_activeChar.getMxcPoly().getWeaponIdRH());
  694. +       writeD(_activeChar.getMxcPoly().getHats());
  695. +       writeD(_activeChar.getMxcPoly().getFaces());
  696. +       write('H', 0, 24);
  697. +       writeD(_activeChar.getMxcPoly().getPvpFlag());
  698. +       writeD(_activeChar.getMxcPoly().getKarma());
  699. +       writeD(_activeChar.getMAtkSpd());
  700. +       writeD(_activeChar.getPAtkSpd());
  701. +       writeD(_activeChar.getMxcPoly().getPvpFlag());
  702. +       writeD(_activeChar.getMxcPoly().getKarma());
  703. +       writeD(_runSpd);
  704. +       writeD(_walkSpd);
  705. +       writeD(_swimRunSpd);
  706. +       writeD(_swimWalkSpd);
  707. +       writeD(_flRunSpd);
  708. +       writeD(_flWalkSpd);
  709. +       writeD(_flyRunSpd);
  710. +       writeD(_flyWalkSpd);
  711. +       writeF(_activeChar.getMovementSpeedMultiplier());
  712. +       writeF(_activeChar.getAttackSpeedMultiplier());
  713. +       writeF(_activeChar.getCollisionRadius());
  714. +       writeF(_activeChar.getCollisionHeight());
  715. +       writeD(_activeChar.getMxcPoly().getHair());
  716. +       writeD(_activeChar.getMxcPoly().getHairColor());
  717. +       writeD(_activeChar.getMxcPoly().getFace());
  718. +       writeS(_activeChar.getMxcPoly().getTitle());
  719. +       writeD(_activeChar.getMxcPoly().getClan() != null ? _activeChar.getMxcPoly().getClan().getClanId() : 0);
  720. +       writeD(_activeChar.getMxcPoly().getClan() != null ? _activeChar.getMxcPoly().getClan().getCrestId() : 0);
  721. +       writeD(_activeChar.getMxcPoly().getClan() != null ? _activeChar.getMxcPoly().getClan().getAllyId() : 0);
  722. +       writeD(_activeChar.getMxcPoly().getClan() != null ? _activeChar.getMxcPoly().getClan().getAllyCrestId() : 0);
  723. +       writeD(0);
  724. +       writeC(1);
  725. +       writeC(_activeChar.isRunning() ? 1 : 0);
  726. +       writeC(_activeChar.isInCombat() ? 1 : 0);
  727. +       writeC(_activeChar.isAlikeDead() ? 1 : 0);
  728. +       write('C',0,3);
  729. +       writeH(0);
  730. +       writeC(0x00);
  731. +       writeD(_activeChar.getAbnormalEffect());
  732. +       writeC(0);
  733. +       writeH(_activeChar.getMxcPoly().getRecom());
  734. +       writeD(_activeChar.getMxcPoly().getClassId());
  735. +       writeD(_maxCp);
  736. +       writeD((int) _activeChar.getCurrentCp());
  737. +       writeC(_activeChar.getMxcPoly().getWeaponIdEnc());
  738. +       writeC(0x00);
  739. +       writeD(_activeChar.getMxcPoly().getClan() != null ? _activeChar.getMxcPoly().getClan().getCrestLargeId() : 0);
  740. +       writeC(0);
  741. +       writeC(_activeChar.getMxcPoly().getIsHero());
  742. +       writeC(0);
  743. +       write('D',0,3);
  744. +       writeD(_activeChar.getMxcPoly().getNameColor());
  745. +       writeD(0x00);
  746. +       writeD(_activeChar.getMxcPoly().getPledge());
  747. +       writeD(0x00);
  748. +       writeD(_activeChar.getMxcPoly().getTitleColor());
  749. +       writeD(0x00);
  750. +   }
  751. +
  752. +   private final void write(char type, int value, int times)
  753. +   {
  754. +       for (int i = 0; i < times; i++)
  755. +       {
  756. +           switch (type)
  757. +           {
  758. +               case 'C':
  759. +                   writeC(value);
  760. +                   break;
  761. +               case 'D':
  762. +                   writeD(value);
  763. +                   break;
  764. +               case 'F':
  765. +                   writeF(value);
  766. +                   break;
  767. +               case 'H':
  768. +                   writeH(value);
  769. +                   break;
  770. +           }
  771. +       }
  772. +   }
  773. +
  774. +   @Override
  775. +   public String getType()
  776. +   {
  777. +       return "MxCOlyInfo: 0x03";
  778. +   }
  779. +}
  780. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/NpcInfo.java
  781. ===================================================================
  782. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/NpcInfo.java (revision 4034)
  783. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/NpcInfo.java (working copy)
  784. @@ -52,6 +52,12 @@
  785.      */
  786.     public NpcInfo(L2NpcInstance cha, L2Character attacker)
  787.     {
  788. +       if(cha.getMxcPoly() != null)
  789. +       {
  790. +           attacker.sendPacket(new MxCPolyInfo(cha));
  791. +           return;
  792. +       }
  793. +      
  794.         _activeChar = cha;
  795.         _idTemplate = cha.getTemplate().idTemplate;
  796.         _isAttackable = cha.isAutoAttackable(attacker);
  797. @@ -122,6 +128,9 @@
  798.     @Override
  799.     protected final void writeImpl()
  800.     {
  801. +       if(_activeChar == null)
  802. +           return;
  803. +      
  804.          if (_activeChar instanceof L2Summon)
  805.              if (((L2Summon)_activeChar).getOwner() != null
  806.                      && ((L2Summon)_activeChar).getOwner().getAppearance().getInvisible())
  807. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/MaxCheatersTable.java
  808. ===================================================================
  809. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/MaxCheatersTable.java   (revision 0)
  810. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/MaxCheatersTable.java   (revision 0)
  811. @@ -0,0 +1,137 @@
  812. +/* This program is free software; you can redistribute it and/or modify
  813. + * it under the terms of the GNU General Public License as published by
  814. + * the Free Software Foundation; either version 2, or (at your option)
  815. + * any later version.
  816. + *
  817. + * This program is distributed in the hope that it will be useful,
  818. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  819. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  820. + * GNU General Public License for more details.
  821. + *
  822. + * You should have received a copy of the GNU General Public License
  823. + * along with this program; if not, write to the Free Software
  824. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  825. + * 02111-1307, USA.
  826. + *
  827. + * http://www.gnu.org/copyleft/gpl.html
  828. + */
  829. +package net.sf.l2j.gameserver.datatables;
  830. +
  831. +import java.sql.Connection;
  832. +import java.sql.PreparedStatement;
  833. +import java.sql.ResultSet;
  834. +import java.sql.SQLException;
  835. +import java.util.logging.Logger;
  836. +
  837. +import javolution.util.FastMap;
  838. +import net.sf.l2j.L2DatabaseFactory;
  839. +import net.sf.l2j.gameserver.model.L2MaxPolyModel;
  840. +import net.sf.l2j.gameserver.templates.StatsSet;
  841. +
  842. +/**
  843. + *
  844. + * @author  Velvet
  845. + */
  846. +public class MaxCheatersTable
  847. +{
  848. +   private FastMap<Integer, L2MaxPolyModel> _map;
  849. +   private Logger _log = Logger.getLogger(MaxCheatersTable.class.getName());
  850. +   private static MaxCheatersTable _instance;
  851. +  
  852. +   private String SQL_SELECT = "SELECT * from max_poly";
  853. +  
  854. +   public MaxCheatersTable()
  855. +   {
  856. +       _map = new FastMap<Integer, L2MaxPolyModel>();
  857. +   }
  858. +  
  859. +   public static MaxCheatersTable getInstance()
  860. +   {
  861. +       if(_instance == null)
  862. +       {
  863. +           _instance = new MaxCheatersTable();
  864. +           _instance.load();
  865. +       }
  866. +       return _instance;
  867. +   }
  868. +  
  869. +   private void load()
  870. +   {
  871. +       Connection con = null;
  872. +       PreparedStatement st = null;
  873. +      
  874. +       try
  875. +       {
  876. +           con = L2DatabaseFactory.getInstance().getConnection();
  877. +           st = con.prepareStatement(SQL_SELECT);
  878. +           ResultSet rs = st.executeQuery();
  879. +           restore(rs);
  880. +       }
  881. +       catch(Exception e)
  882. +       {
  883. +           e.printStackTrace();
  884. +       }
  885. +       finally
  886. +       {
  887. +           if(con != null && st != null) // we don't like npes :P
  888. +           {
  889. +               try
  890. +               {
  891. +                   con.close();
  892. +                   st.close();
  893. +               }
  894. +               catch (Exception e)
  895. +               {
  896. +                   e.printStackTrace();
  897. +               }
  898. +           }
  899. +       }
  900. +   }
  901. +  
  902. +   private void restore(ResultSet data) throws SQLException
  903. +   {
  904. +       StatsSet set = new StatsSet();
  905. +      
  906. +       while (data.next())
  907. +       {
  908. +           set.set("name", data.getString("name"));
  909. +           set.set("title", data.getString("title"));
  910. +           set.set("sex", data.getInt("sex"));
  911. +           set.set("hair", data.getInt("hair"));
  912. +           set.set("hairColor", data.getInt("hairColor"));
  913. +           set.set("face", data.getInt("face"));
  914. +           set.set("classId", data.getInt("classId"));
  915. +           set.set("npcId", data.getInt("npcId"));
  916. +           set.set("weaponIdRH", data.getInt("weaponIdRH"));
  917. +           set.set("weaponIdLH", data.getInt("weaponIdLH"));
  918. +           set.set("weaponIdEnc", data.getInt("weaponIdEnc"));
  919. +           set.set("armorId", data.getInt("armorId"));
  920. +           set.set("head", data.getInt("head"));
  921. +           set.set("hats", data.getInt("hats"));
  922. +           set.set("faces", data.getInt("faces"));
  923. +           set.set("chest", data.getInt("chest"));
  924. +           set.set("legs", data.getInt("legs"));
  925. +           set.set("gloves", data.getInt("gloves"));
  926. +           set.set("feet", data.getInt("feet"));
  927. +           set.set("abnormalEffect", data.getInt("abnormalEffect"));
  928. +           set.set("pvpFlag", data.getInt("pvpFlag"));
  929. +           set.set("karma", data.getInt("karma"));
  930. +           set.set("recom", data.getInt("recom"));
  931. +           set.set("clan", data.getInt("clan"));
  932. +           set.set("isHero", data.getInt("isHero"));
  933. +           set.set("pledge", data.getInt("pledge"));
  934. +           set.set("nameColor", data.getInt("nameColor"));
  935. +           set.set("titleColor", data.getInt("titleColor"));
  936. +
  937. +           L2MaxPolyModel poly = new L2MaxPolyModel(set);
  938. +           _map.put(poly.getNpcId(), poly);// xD
  939. +       }
  940. +       _log.info("MaxCheatersTable Loaded: "+_map.size()+" npc to pc entry(s)");
  941. +   }
  942. +
  943. +   public L2MaxPolyModel getModelForID(int key)
  944. +   {
  945. +       return _map.get(key);
  946. +   }
  947. +  
  948. +}
  949. Index: D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/ArmorSetsTable.java
  950. ===================================================================
  951. --- D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/ArmorSetsTable.java (revision 4034)
  952. +++ D:/eclipse/workspace/L2_GameServer_It/java/net/sf/l2j/gameserver/datatables/ArmorSetsTable.java (working copy)
  953. @@ -43,7 +43,8 @@
  954.     private static Logger _log = Logger.getLogger(ArmorSetsTable.class.getName());
  955.     private static ArmorSetsTable _instance;
  956.  
  957. -   private FastMap<Integer,L2ArmorSet> _armorSets;
  958. +   private FastMap<Integer, L2ArmorSet> _armorSets;
  959. +   private final FastMap<Integer, ArmorDummy> _cusArmorSets;
  960.  
  961.     public static ArmorSetsTable getInstance()
  962.     {
  963. @@ -53,7 +54,8 @@
  964.     }
  965.     private ArmorSetsTable()
  966.     {
  967. -       _armorSets = new FastMap<Integer,L2ArmorSet>();
  968. +       _armorSets = new FastMap<Integer, L2ArmorSet>();
  969. +       _cusArmorSets = new FastMap<Integer, ArmorDummy>();
  970.         loadData();
  971.     }
  972.     private void loadData()
  973. @@ -62,11 +64,12 @@
  974.         try
  975.         {
  976.             con = L2DatabaseFactory.getInstance().getConnection();
  977. -           PreparedStatement statement = con.prepareStatement("SELECT chest, legs, head, gloves, feet, skill_id, shield, shield_skill_id, enchant6skill FROM armorsets");
  978. +           PreparedStatement statement = con.prepareStatement("SELECT id, chest, legs, head, gloves, feet, skill_id, shield, shield_skill_id, enchant6skill FROM armorsets");
  979.             ResultSet rset = statement.executeQuery();
  980.  
  981.             while(rset.next())
  982.             {
  983. +               int id = rset.getInt("id");
  984.                 int chest = rset.getInt("chest");
  985.                 int legs  = rset.getInt("legs");
  986.                 int head  = rset.getInt("head");
  987. @@ -77,6 +80,7 @@
  988.                 int shield_skill_id = rset.getInt("shield_skill_id");
  989.                 int enchant6skill = rset.getInt("enchant6skill");
  990.                 _armorSets.put(chest, new L2ArmorSet(chest, legs, head, gloves, feet,skill_id, shield, shield_skill_id, enchant6skill));
  991. +               _cusArmorSets.put(id, new ArmorDummy(chest, legs, head, gloves, feet, skill_id, shield));
  992.             }
  993.  
  994.             _log.config("ArmorSetsTable: Loaded "+_armorSets.size()+" armor sets.");
  995. @@ -98,4 +102,69 @@
  996.     {
  997.         return _armorSets.get(chestId);
  998.     }
  999. +  
  1000. +   /**
  1001. +    * @return Returns the cusArmorSets.
  1002. +    */
  1003. +   public ArmorDummy getCusArmorSets(int id)
  1004. +   {
  1005. +       return _cusArmorSets.get(id);
  1006. +   }
  1007. +
  1008. +   public class ArmorDummy
  1009. +   {
  1010. +       private final int _chest;
  1011. +       private final int _legs;
  1012. +       private final int _head;
  1013. +       private final int _gloves;
  1014. +       private final int _feet;
  1015. +       private final int _skill_id;
  1016. +       private final int _shield;
  1017. +      
  1018. +       public ArmorDummy(int chest, int legs, int head, int gloves, int feet, int skill_id, int shield)
  1019. +       {
  1020. +           _chest = chest;
  1021. +           _legs = legs;
  1022. +           _head = head;
  1023. +           _gloves = gloves;
  1024. +           _feet = feet;
  1025. +           _skill_id = skill_id;
  1026. +           _shield = shield;
  1027. +       }
  1028. +
  1029. +       public int getChest()
  1030. +       {
  1031. +           return _chest;
  1032. +       }
  1033. +
  1034. +       public int getLegs()
  1035. +       {
  1036. +           return _legs;
  1037. +       }
  1038. +
  1039. +       public int getHead()
  1040. +       {
  1041. +           return _head;
  1042. +       }
  1043. +
  1044. +       public int getGloves()
  1045. +       {
  1046. +           return _gloves;
  1047. +       }
  1048. +
  1049. +       public int getFeet()
  1050. +       {
  1051. +           return _feet;
  1052. +       }
  1053. +
  1054. +       public int getSkill_id()
  1055. +       {
  1056. +           return _skill_id;
  1057. +       }
  1058. +
  1059. +       public int getShield()
  1060. +       {
  1061. +           return _shield;
  1062. +       }
  1063. +   }
  1064.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement