Advertisement
Guest User

FakePc

a guest
Jul 28th, 2012
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.90 KB | None | 0 0
  1. Index: /trunk/Core/java/com/l2jserver/gameserver/network/serverpackets/AbstractNpcInfo.java
  2. ===================================================================
  3. --- /trunk/Core/java/com/l2jserver/gameserver/network/serverpackets/AbstractNpcInfo.java    (revision 443)
  4. +++ /trunk/Core/java/com/l2jserver/gameserver/network/serverpackets/AbstractNpcInfo.java    (revision 444)
  5. @@ -15,8 +15,12 @@
  6.  package com.l2jserver.gameserver.network.serverpackets;
  7.  
  8. +import java.text.DecimalFormat;
  9. +
  10.  import com.l2jserver.Config;
  11. +import com.l2jserver.gameserver.datatables.CharTemplateTable;
  12.  import com.l2jserver.gameserver.datatables.ClanTable;
  13.  import com.l2jserver.gameserver.instancemanager.TownManager;
  14.  import com.l2jserver.gameserver.model.L2Clan;
  15. +import com.l2jserver.gameserver.model.actor.FakePc;
  16.  import com.l2jserver.gameserver.model.actor.L2Character;
  17.  import com.l2jserver.gameserver.model.actor.L2Npc;
  18. @@ -26,4 +30,5 @@
  19.  import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
  20.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. +import com.l2jserver.gameserver.model.actor.templates.L2PcTemplate;
  22.  import com.l2jserver.gameserver.model.effects.AbnormalEffect;
  23.  
  24. @@ -126,4 +131,148 @@
  25.         protected void writeImpl()
  26.         {
  27. +           FakePc fpc = _npc.getFakePc();
  28. +           if (fpc != null)
  29. +           {
  30. +              writeC(0x31);
  31. +              writeD(_x);
  32. +              writeD(_y);
  33. +              writeD(_z);
  34. +              writeD(0x00); // vehicle id
  35. +              writeD(_npc.getObjectId());
  36. +              writeS(fpc.name); // visible name
  37. +              writeD(fpc.race);
  38. +              writeD(fpc.sex);
  39. +              writeD(fpc.clazz);
  40. +              
  41. +              writeD(fpc.pdUnder);
  42. +              writeD(fpc.pdHead);
  43. +              writeD(fpc.pdRHand);
  44. +              writeD(fpc.pdLHand);
  45. +              writeD(fpc.pdGloves);
  46. +              writeD(fpc.pdChest);
  47. +              writeD(fpc.pdLegs);
  48. +              writeD(fpc.pdFeet);
  49. +              writeD(fpc.pdBack);
  50. +              writeD(fpc.pdLRHand);
  51. +              writeD(fpc.pdHair);
  52. +              writeD(fpc.pdHair2);
  53. +              writeD(fpc.pdRBracelet);
  54. +              writeD(fpc.pdLBracelet);
  55. +              writeD(fpc.pdDeco1);
  56. +              writeD(fpc.pdDeco2);
  57. +              writeD(fpc.pdDeco3);
  58. +              writeD(fpc.pdDeco4);
  59. +              writeD(fpc.pdDeco5);
  60. +              writeD(fpc.pdDeco6);
  61. +              writeD(0x00); // belt
  62. +              
  63. +              writeD(fpc.pdUnderAug);
  64. +              writeD(fpc.pdHeadAug);
  65. +              writeD(fpc.pdRHandAug);
  66. +              writeD(fpc.pdLHandAug);
  67. +              writeD(fpc.pdGlovesAug);
  68. +              writeD(fpc.pdChestAug);
  69. +              writeD(fpc.pdLegsAug);
  70. +              writeD(fpc.pdFeetAug);
  71. +              writeD(fpc.pdBackAug);
  72. +              writeD(fpc.pdLRHandAug);
  73. +              writeD(fpc.pdHairAug);
  74. +              writeD(fpc.pdHair2Aug);
  75. +              writeD(fpc.pdRBraceletAug);
  76. +              writeD(fpc.pdLBraceletAug);
  77. +              writeD(fpc.pdDeco1Aug);
  78. +              writeD(fpc.pdDeco2Aug);
  79. +              writeD(fpc.pdDeco3Aug);
  80. +              writeD(fpc.pdDeco4Aug);
  81. +              writeD(fpc.pdDeco5Aug);
  82. +              writeD(fpc.pdDeco6Aug);
  83. +              writeD(0x00); // belt aug
  84. +              writeD(0x00);
  85. +              writeD(0x01);
  86. +              
  87. +              writeD(fpc.pvpFlag);
  88. +              writeD(fpc.karma);
  89. +              
  90. +              writeD(_mAtkSpd);
  91. +              writeD(_pAtkSpd);
  92. +              
  93. +              writeD(0x00);
  94. +              
  95. +              writeD(_runSpd);
  96. +              writeD(_walkSpd);
  97. +              writeD(_runSpd); // swim run speed
  98. +              writeD(_walkSpd); // swim walk speed
  99. +              writeD(_runSpd); // fly run speed
  100. +              writeD(_walkSpd); // fly walk speed
  101. +              writeD(_runSpd);
  102. +              writeD(_walkSpd);
  103. +              writeF(_npc.getMovementSpeedMultiplier()); // _activeChar.getProperMultiplier()
  104. +              writeF(_npc.getAttackSpeedMultiplier()); // _activeChar.getAttackSpeedMultiplier()
  105. +              
  106. +              // TODO: add handling of mount collision
  107. +              L2PcTemplate pctmpl = CharTemplateTable.getInstance().getTemplate(fpc.clazz);
  108. +              writeF(fpc.sex == 0 ? pctmpl.getCollisionRadius() : pctmpl.getCollisionRadius());
  109. +              writeF(fpc.sex == 0 ? pctmpl.getCollisionHeight() : pctmpl.getCollisionHeight());
  110. +              
  111. +              writeD(fpc.hairStyle);
  112. +              writeD(fpc.hairColor);
  113. +              writeD(fpc.face);
  114. +              if (_npc instanceof L2MonsterInstance)
  115. +                 writeS(fpc.title + " - HP " + new DecimalFormat("#.##").format(100.0 * _npc.getCurrentHp() / _npc.getMaxVisibleHp()) + "%"); // visible title
  116. +              else
  117. +                 writeS(fpc.title);
  118. +              
  119. +              writeD(0x00); // clan id
  120. +              writeD(0x00); // clan crest id
  121. +              writeD(0x00); // ally id
  122. +              writeD(0x00); // ally crest id
  123. +              
  124. +              writeC(0x01); // standing = 1  sitting = 0
  125. +              writeC(_npc.isRunning() ? 1 : 0); // running = 1  walking = 0
  126. +              writeC(_npc.isInCombat() ? 1 : 0);
  127. +              writeC(_npc.isAlikeDead() ? 1 : 0);
  128. +              
  129. +              writeC(fpc.invisible); // invisible = 1  visible =0
  130. +              
  131. +              writeC(fpc.mount); // 1 on strider  2 on wyvern  3 on Great Wolf  0 no mount
  132. +              writeC(0x00); //  1 - sellshop
  133. +              writeH(0x00); // cubic count
  134. +              //for (int id : allCubics)
  135. +              //    writeH(id);
  136. +              writeC(0x00); // find party members
  137. +              writeD(0x00); // abnormal effect
  138. +              writeC(0x00); // isFlying() ? 2 : 0
  139. +              writeH(0x00); //getRecomHave(): Blue value for name (0 = white, 255 = pure blue)
  140. +              writeD(1000000); // getMountNpcId() + 1000000
  141. +              writeD(fpc.clazz);
  142. +              writeD(0x00); // ?
  143. +              writeC(fpc.enchantEffect);
  144. +              writeC(fpc.team); //team circle around feet 1= Blue, 2 = red
  145. +              writeD(0x00); // getClanCrestLargeId()
  146. +              writeC(0x00); // isNoble(): Symbol on char menu ctrl+I
  147. +              writeC(fpc.hero); // Hero Aura
  148. +              writeC(fpc.fishing); //0x01: Fishing Mode (Cant be undone by setting back to 0)
  149. +              writeD(fpc.fishingX);
  150. +              writeD(fpc.fishingY);
  151. +              writeD(fpc.fishingZ);
  152. +              
  153. +              writeD(fpc.nameColor);
  154. +              writeD(_heading);
  155. +              writeD(0x00); // pledge class
  156. +              writeD(0x00); // pledge type
  157. +              writeD(fpc.titleColor);
  158. +              
  159. +              writeD(0x00); // cursed weapon level
  160. +              writeD(0x00); // reputation score
  161. +              writeD(0x00); // transformation id
  162. +              writeD(0x00); // agathion id
  163. +              writeD(0x01); // T2 ?
  164. +              writeD(0x00); // special effect
  165. +              /*writeD(0x00); // territory Id
  166. +              writeD(0x00); // is Disguised
  167. +              writeD(0x00); // territory Id*/
  168. +           }
  169. +           else
  170. +           {
  171.             writeC(0x0c);
  172.             writeD(_npc.getObjectId());
  173. @@ -183,4 +332,5 @@
  174.             writeD(_npc.getSpecialEffect());
  175.             writeD(_displayEffect);
  176. +           }
  177.         }
  178.     }
  179. Index: /trunk/Core/java/com/l2jserver/gameserver/model/actor/status/AttackableStatus.java
  180. ===================================================================
  181. --- /trunk/Core/java/com/l2jserver/gameserver/model/actor/status/AttackableStatus.java  (revision 443)
  182. +++ /trunk/Core/java/com/l2jserver/gameserver/model/actor/status/AttackableStatus.java  (revision 444)
  183. @@ -15,6 +15,10 @@
  184.  package com.l2jserver.gameserver.model.actor.status;
  185.  
  186. +import java.util.Collection;
  187. +
  188.  import com.l2jserver.gameserver.model.actor.L2Attackable;
  189.  import com.l2jserver.gameserver.model.actor.L2Character;
  190. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  191. +import com.l2jserver.gameserver.network.serverpackets.AbstractNpcInfo;
  192.  
  193.  public class AttackableStatus extends NpcStatus
  194. @@ -54,5 +58,21 @@
  195.     }
  196.    
  197. -   @Override
  198. +   @Override
  199. +   public void setCurrentHp(double newHp, boolean broadcastPacket)
  200. +   {
  201. +       super.setCurrentHp(newHp, broadcastPacket);
  202. +        
  203. +       if (getActiveChar().getFakePc() != null)
  204. +       {
  205. +          Collection<L2PcInstance> plrs = getActiveChar().getKnownList().getKnownPlayers().values();
  206. +          for (L2PcInstance player : plrs)
  207. +          {
  208. +              if (player != null)
  209. +                player.sendPacket(new AbstractNpcInfo.NpcInfo(getActiveChar(), player));
  210. +          }
  211. +       }
  212. +   }
  213. +  
  214. +   @Override
  215.     public L2Attackable getActiveChar()
  216.     {
  217. Index: /trunk/Core/java/com/l2jserver/gameserver/model/actor/L2Npc.java
  218. ===================================================================
  219. --- /trunk/Core/java/com/l2jserver/gameserver/model/actor/L2Npc.java    (revision 443)
  220. +++ /trunk/Core/java/com/l2jserver/gameserver/model/actor/L2Npc.java    (revision 444)
  221. @@ -27,4 +27,5 @@
  222.  import com.l2jserver.gameserver.ThreadPoolManager;
  223.  import com.l2jserver.gameserver.cache.HtmCache;
  224. +import com.l2jserver.gameserver.datatables.FakePcsTable;
  225.  import com.l2jserver.gameserver.datatables.ItemTable;
  226.  import com.l2jserver.gameserver.handler.BypassHandler;
  227. @@ -148,5 +149,5 @@
  228.      */
  229.     private L2Character _summoner = null;
  230. -  
  231. +   private FakePc _fakePc = null;
  232.     private final L2NpcAIData _staticAIData = getTemplate().getAIDataStatic();
  233.    
  234. @@ -542,5 +543,5 @@
  235.             return;
  236.         }
  237. -      
  238. +        _fakePc = FakePcsTable.getInstance().getFakePc(template.getNpcId());
  239.         // Set the name of the L2Character
  240.         setName(template.getName());
  241. @@ -1722,5 +1723,10 @@
  242.         return _displayEffect;
  243.     }
  244. -  
  245. +    
  246. +   public FakePc getFakePc()
  247. +   {
  248. +       return _fakePc;
  249. +   }
  250. +  
  251.     public int getColorEffect()
  252.     {
  253. Index: /trunk/Core/java/com/l2jserver/gameserver/model/actor/FakePc.java
  254. ===================================================================
  255. --- /trunk/Core/java/com/l2jserver/gameserver/model/actor/FakePc.java   (revision 444)
  256. +++ /trunk/Core/java/com/l2jserver/gameserver/model/actor/FakePc.java   (revision 444)
  257. @@ -0,0 +1,81 @@
  258. +/*
  259. + * This program is free software: you can redistribute it and/or modify it under
  260. + * the terms of the GNU General Public License as published by the Free Software
  261. + * Foundation, either version 3 of the License, or (at your option) any later
  262. + * version.
  263. + *
  264. + * This program is distributed in the hope that it will be useful, but WITHOUT
  265. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  266. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  267. + * details.
  268. + *
  269. + * You should have received a copy of the GNU General Public License along with
  270. + * this program. If not, see <http://www.gnu.org/licenses/>.
  271. + */
  272. +
  273. +package com.l2jserver.gameserver.model.actor;
  274. +
  275. +public class FakePc
  276. +{
  277. +   public int race;
  278. +   public int sex;
  279. +   public int clazz;
  280. +   public String title;
  281. +   public int titleColor;
  282. +   public String name;
  283. +   public int nameColor;
  284. +   public int hairStyle;
  285. +   public int hairColor;
  286. +   public int face;
  287. +   public byte mount;
  288. +   public byte team;
  289. +   public byte hero;
  290. +   public int pdUnder;
  291. +   public int pdUnderAug;
  292. +   public int pdHead;
  293. +   public int pdHeadAug;
  294. +   public int pdRHand;
  295. +   public int pdRHandAug;
  296. +   public int pdLHand;
  297. +   public int pdLHandAug;
  298. +   public int pdGloves;
  299. +   public int pdGlovesAug;
  300. +   public int pdChest;
  301. +   public int pdChestAug;
  302. +   public int pdLegs;
  303. +   public int pdLegsAug;
  304. +   public int pdFeet;
  305. +   public int pdFeetAug;
  306. +   public int pdBack;
  307. +   public int pdBackAug;
  308. +   public int pdLRHand;
  309. +   public int pdLRHandAug;
  310. +   public int pdHair;
  311. +   public int pdHairAug;
  312. +   public int pdHair2;
  313. +   public int pdHair2Aug;
  314. +   public int pdRBracelet;
  315. +   public int pdRBraceletAug;
  316. +   public int pdLBracelet;
  317. +   public int pdLBraceletAug;
  318. +   public int pdDeco1;
  319. +   public int pdDeco1Aug;
  320. +   public int pdDeco2;
  321. +   public int pdDeco2Aug;
  322. +   public int pdDeco3;
  323. +   public int pdDeco3Aug;
  324. +   public int pdDeco4;
  325. +   public int pdDeco4Aug;
  326. +   public int pdDeco5;
  327. +   public int pdDeco5Aug;
  328. +   public int pdDeco6;
  329. +   public int pdDeco6Aug;
  330. +   public int enchantEffect;
  331. +   public int pvpFlag;
  332. +   public int karma;
  333. +   public byte fishing;
  334. +   public int fishingX;
  335. +   public int fishingY;
  336. +   public int fishingZ;
  337. +   public byte invisible;
  338. +}
  339. Index: /trunk/Core/java/com/l2jserver/gameserver/datatables/FakePcsTable.java
  340. ===================================================================
  341. --- /trunk/Core/java/com/l2jserver/gameserver/datatables/FakePcsTable.java  (revision 444)
  342. +++ /trunk/Core/java/com/l2jserver/gameserver/datatables/FakePcsTable.java  (revision 444)
  343. @@ -0,0 +1,159 @@
  344. +/*
  345. + * This program is free software: you can redistribute it and/or modify it under
  346. + * the terms of the GNU General Public License as published by the Free Software
  347. + * Foundation, either version 3 of the License, or (at your option) any later
  348. + * version.
  349. + *
  350. + * This program is distributed in the hope that it will be useful, but WITHOUT
  351. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  352. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  353. + * details.
  354. + *
  355. + * You should have received a copy of the GNU General Public License along with
  356. + * this program. If not, see <http://www.gnu.org/licenses/>.
  357. + */
  358. +
  359. +package com.l2jserver.gameserver.datatables;
  360. +
  361. +import java.sql.Connection;
  362. +import java.sql.PreparedStatement;
  363. +import java.sql.ResultSet;
  364. +import java.sql.SQLException;
  365. +import java.util.logging.Level;
  366. +import java.util.logging.Logger;
  367. +
  368. +import javolution.util.FastMap;
  369. +
  370. +import com.l2jserver.L2DatabaseFactory;
  371. +import com.l2jserver.gameserver.model.actor.FakePc;
  372. +
  373. +public class FakePcsTable
  374. +{
  375. +   /** The logger<br> */
  376. +   private static Logger _log = Logger.getLogger(FakePcsTable.class.getName());
  377. +  
  378. +   private FastMap<Integer, FakePc> _fakePcs = new FastMap<Integer, FakePc>();
  379. +  
  380. +   private FakePcsTable()
  381. +   {
  382. +      loadData();
  383. +   }
  384. +  
  385. +   private void loadData()
  386. +   {
  387. +      _fakePcs.clear();
  388. +      
  389. +      Connection con = null;
  390. +      
  391. +      try
  392. +      {
  393. +         con = L2DatabaseFactory.getInstance().getConnection();
  394. +        
  395. +         PreparedStatement stmt = con.prepareStatement("SELECT * FROM `fake_pcs`");
  396. +         ResultSet rset = stmt.executeQuery();
  397. +        
  398. +         FakePc fpc = null;
  399. +        
  400. +         while (rset.next())
  401. +         {
  402. +            fpc = new FakePc();
  403. +            
  404. +            int npcId = rset.getInt("npc_id");
  405. +            fpc.race = rset.getInt("race");
  406. +            fpc.sex = rset.getInt("sex");
  407. +            fpc.clazz = rset.getInt("class");
  408. +            fpc.title = rset.getString("title");
  409. +            fpc.titleColor = Integer.decode("0x" + rset.getString("title_color"));
  410. +            fpc.name = rset.getString("name");
  411. +            fpc.nameColor = Integer.decode("0x" + rset.getString("name_color"));
  412. +            fpc.hairStyle = rset.getInt("hair_style");
  413. +            fpc.hairColor = rset.getInt("hair_color");
  414. +            fpc.face = rset.getInt("face");
  415. +            fpc.mount = rset.getByte("mount");
  416. +            fpc.team = rset.getByte("team");
  417. +            fpc.hero = rset.getByte("hero");
  418. +            fpc.pdUnder = rset.getInt("pd_under");
  419. +            fpc.pdUnderAug = rset.getInt("pd_under_aug");
  420. +            fpc.pdHead = rset.getInt("pd_head");
  421. +            fpc.pdHeadAug = rset.getInt("pd_head_aug");
  422. +            fpc.pdRHand = rset.getInt("pd_rhand");
  423. +            fpc.pdRHandAug = rset.getInt("pd_rhand_aug");
  424. +            fpc.pdLHand = rset.getInt("pd_lhand");
  425. +            fpc.pdLHandAug = rset.getInt("pd_lhand_aug");
  426. +            fpc.pdGloves = rset.getInt("pd_gloves");
  427. +            fpc.pdGlovesAug = rset.getInt("pd_gloves_aug");
  428. +            fpc.pdChest = rset.getInt("pd_chest");
  429. +            fpc.pdChestAug = rset.getInt("pd_chest_aug");
  430. +            fpc.pdLegs = rset.getInt("pd_legs");
  431. +            fpc.pdLegsAug = rset.getInt("pd_legs_aug");
  432. +            fpc.pdFeet = rset.getInt("pd_feet");
  433. +            fpc.pdFeetAug = rset.getInt("pd_feet_aug");
  434. +            fpc.pdBack = rset.getInt("pd_back");
  435. +            fpc.pdBackAug = rset.getInt("pd_back_aug");
  436. +            fpc.pdLRHand = rset.getInt("pd_lrhand");
  437. +            fpc.pdLRHandAug = rset.getInt("pd_lrhand_aug");
  438. +            fpc.pdHair = rset.getInt("pd_hair");
  439. +            fpc.pdHairAug = rset.getInt("pd_hair_aug");
  440. +            fpc.pdHair2 = rset.getInt("pd_hair2");
  441. +            fpc.pdHair2Aug = rset.getInt("pd_hair2_aug");
  442. +            fpc.pdRBracelet = rset.getInt("pd_rbracelet");
  443. +            fpc.pdRBraceletAug = rset.getInt("pd_rbracelet_aug");
  444. +            fpc.pdLBracelet = rset.getInt("pd_lbracelet");
  445. +            fpc.pdLBraceletAug = rset.getInt("pd_lbracelet_aug");
  446. +            fpc.pdDeco1 = rset.getInt("pd_deco1");
  447. +            fpc.pdDeco1Aug = rset.getInt("pd_deco1_aug");
  448. +            fpc.pdDeco2 = rset.getInt("pd_deco2");
  449. +            fpc.pdDeco2Aug = rset.getInt("pd_deco2_aug");
  450. +            fpc.pdDeco3 = rset.getInt("pd_deco3");
  451. +            fpc.pdDeco3Aug = rset.getInt("pd_deco3_aug");
  452. +            fpc.pdDeco4 = rset.getInt("pd_deco4");
  453. +            fpc.pdDeco4Aug = rset.getInt("pd_deco4_aug");
  454. +            fpc.pdDeco5 = rset.getInt("pd_deco5");
  455. +            fpc.pdDeco5Aug = rset.getInt("pd_deco5_aug");
  456. +            fpc.pdDeco6 = rset.getInt("pd_deco6");
  457. +            fpc.pdDeco6Aug = rset.getInt("pd_deco6_aug");
  458. +            fpc.enchantEffect = rset.getInt("enchant_effect");
  459. +            fpc.pvpFlag = rset.getInt("pvp_flag");
  460. +            fpc.karma = rset.getInt("karma");
  461. +            fpc.fishing = rset.getByte("fishing");
  462. +            fpc.fishingX = rset.getInt("fishing_x");
  463. +            fpc.fishingY = rset.getInt("fishing_y");
  464. +            fpc.fishingZ = rset.getInt("fishing_z");
  465. +            fpc.invisible = rset.getByte("invisible");
  466. +            _fakePcs.put(npcId, fpc);
  467. +         }
  468. +        
  469. +         rset.close();
  470. +         stmt.close();
  471. +      }
  472. +      catch (SQLException e)
  473. +      {
  474. +         _log.log(Level.SEVERE, "Error while creating fake pc table: " + e.getMessage(), e);
  475. +      }
  476. +      finally
  477. +      {
  478. +         L2DatabaseFactory.close(con);
  479. +      }
  480. +   }
  481. +  
  482. +   public void reloadData()
  483. +   {
  484. +      loadData();
  485. +   }
  486. +  
  487. +   public FakePc getFakePc(int npcId)
  488. +   {
  489. +      return _fakePcs.get(npcId);
  490. +   }
  491. +  
  492. +   public static FakePcsTable getInstance()
  493. +   {
  494. +      return SingletonHolder._instance;
  495. +   }
  496. +  
  497. +   @SuppressWarnings("synthetic-access")
  498. +   private static class SingletonHolder
  499. +   {
  500. +      protected static final FakePcsTable _instance = new FakePcsTable();
  501. +   }
  502. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement