Advertisement
LIONN

ItemEnchanter NPC

Jul 1st, 2013
1,450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 23.62 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jFrozen_DataPack
  3. Index: data/html/itemEnchanter/empty_list.htm
  4. ===================================================================
  5. --- data/html/itemEnchanter/empty_list.htm  (revision 0)
  6. +++ data/html/itemEnchanter/empty_list.htm  (working copy)
  7. @@ -0,0 +1,5 @@
  8. +<html>
  9. +   <body>
  10. +       <font color="LEVEL">You don't have any item to enchant!</font><br><br>
  11. +   </body>
  12. +</html>
  13. Index: data/html/itemEnchanter/template.htm
  14. ===================================================================
  15. --- data/html/itemEnchanter/template.htm    (revision 0)
  16. +++ data/html/itemEnchanter/template.htm    (working copy)
  17. @@ -0,0 +1,12 @@
  18. +<html>
  19. +   <body>
  20. +       <center>
  21. +           <img src="Sek.cbui371" width=280 height=1>
  22. +           <table width=286 height=26 bgcolor=000000>
  23. +               <tr><td align="center"><font color="LEVEL">Item Enchanter</font></td></tr>
  24. +           </table>
  25. +           <img src="Sek.cbui371" width=280 height=1>
  26. +           %list%
  27. +       </center>
  28. +   </body>
  29. +</html>
  30. Index: sql/customs/added_custom_npc.sql
  31. ===================================================================
  32. --- sql/customs/added_custom_npc.sql    (revision 1004)
  33. +++ sql/customs/added_custom_npc.sql    (working copy)
  34. @@ -33,5 +33,8 @@
  35.  INSERT INTO `custom_npc` VALUES
  36.  (54, 21654, 'Necromancer of Destruction', 1, 'Equip Manager', 1, 'Monster.vale_master_20_bi', 14.50, 48.00, 80, 'male', 'L2Merchant', 40, 4608, 1896, 67.15, 3.09, 40, 43, 30, 21, 20, 10, 8042, 913, 1863, 587, 1182, 477, 278, 150, 333, 0, 0, 0, 77, 154, 'fire_clan', 300, 0, 0, 'LAST_HIT');
  37.  
  38. +INSERT INTO `custom_npc` VALUES
  39. +(56, 30026, 'Mario', 1, 'Item Enchanter', 1, 'NPC.a_fighterguild_master_Mhuman', 8.00, 23.50, 70, 'male', 'L2ItemEnchanter', 40, 3862, 1493, 11.85, 2.78, 40, 43, 30, 21, 20, 10, 0, 0, 1314, 470, 780, 382, 278, 0, 333, 0, 0, 0, 55, 132, null, 0, 1, 0, 'LAST_HIT');
  40. +
  41.  insert into custom_npc values
  42.  (50020, 30298, 'Augmenter', 1, 'L2Frozen', 1, 'NPC.a_smith_MDwarf', 7.00, 16.50, 70, 'male', 'L2Trainer', 40, 3862, 1493, 11.85, 2.78, 40, 43, 30, 21, 20, 10, 0, 0, 1314, 470, 780, 382, 278, 0, 333, 89, 0, 0, 55, 132, '', 0, 1, 0, 'LAST_HIT');
  43. \ No newline at end of file
  44. Index: data/html/itemEnchanter/long_list.htm
  45. ===================================================================
  46. --- data/html/itemEnchanter/long_list.htm   (revision 0)
  47. +++ data/html/itemEnchanter/long_list.htm   (working copy)
  48. @@ -0,0 +1,5 @@
  49. +<html>
  50. +   <body>
  51. +       <font color="LEVEL">Your item list is too long!</font><br><br>
  52. +   </body>
  53. +</html>
  54. Index: data/html/itemEnchanter/start.htm
  55. ===================================================================
  56. --- data/html/itemEnchanter/start.htm   (revision 0)
  57. +++ data/html/itemEnchanter/start.htm   (working copy)
  58. @@ -0,0 +1,15 @@
  59. +<html>
  60. +   <body>
  61. +       <center>
  62. +           <img src="Sek.cbui371" width=280 height=1>
  63. +           <table width=286 height=26 bgcolor=000000>
  64. +               <tr><td align="center"><font color="LEVEL">Item Enchanter</font></td></tr>
  65. +           </table>
  66. +           <img src="Sek.cbui371" width=280 height=1>
  67. +           <br><br>
  68. +           <button value="Weapon" action="bypass -h npc_%objectId%_enchant_weapon" width=100 height=15 back="sek.cbui94" fore="sek.cbui92">
  69. +           <br>
  70. +           <button value="Armor" action="bypass -h npc_%objectId%_enchant_armor" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  71. +       </center>
  72. +   </body>
  73. +</html>
  74. Index: data/html/itemEnchanter/disabled.htm
  75. ===================================================================
  76. --- data/html/itemEnchanter/disabled.htm    (revision 0)
  77. +++ data/html/itemEnchanter/disabled.htm    (working copy)
  78. @@ -0,0 +1,5 @@
  79. +<html>
  80. +   <body>
  81. +       <font color="LEVEL">This feature is currently disabled.</font><br><br>
  82. +   </body>
  83. +</html>
  84. #P L2jFrozen_GameServer
  85. Index: head-src/com/l2jfrozen/Config.java
  86. ===================================================================
  87. --- head-src/com/l2jfrozen/Config.java  (revision 1004)
  88. +++ head-src/com/l2jfrozen/Config.java  (working copy)
  89. @@ -2399,6 +2399,21 @@
  90.     public static String PVP1_CUSTOM_MESSAGE;
  91.     public static String PVP2_CUSTOM_MESSAGE;
  92.  
  93. +/*--------------------< Npc Enchant Items >------------------------*/
  94. +   public static boolean npcEnchantItemsEnabled;
  95. +   public static int weaponEnchantLevel;
  96. +   public static int armorEnchantLevel;
  97. +   public static int IngredientID;
  98. +   public static int InAmountWeapon;
  99. +   public static int InAmountArmor;
  100. +   public static int augmentItemChance;
  101. +   public static String nonEnchantableItems;
  102. +   public static List<Integer> nonEnchantableItemList;
  103. +
  104. +   public static boolean modifyItemEnchant;
  105. +   public static FastMap<Integer, Integer> modifyItemEnchantList;
  106. +/*--------------------< Npc Enchant Items >------------------------*/
  107. +
  108.     //============================================================
  109.     public static void loadL2JFrozenConfig()
  110.     {
  111. @@ -2517,6 +2532,47 @@
  112.             FARM2_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("Farm2CustomMeesage", "You have been teleported to Farm Zone 2!");
  113.             PVP1_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP1CustomMeesage", "You have been teleported to PvP Zone 1!");
  114.             PVP2_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP2CustomMeesage", "You have been teleported to PvP Zone 2!");
  115. +      
  116. +       /*---------------------------------------------< Npc Enchant Items >-------------------------------------------------*/
  117. +           npcEnchantItemsEnabled = Boolean.parseBoolean(L2JFrozenSettings.getProperty("EnableNpcEnchantItems", "False"));
  118. +           weaponEnchantLevel = Integer.parseInt(L2JFrozenSettings.getProperty("WeaponEnchantLevel", "20"));
  119. +           armorEnchantLevel = Integer.parseInt(L2JFrozenSettings.getProperty("ArmorEnchantLevel", "16"));
  120. +           IngredientID = Integer.parseInt(L2JFrozenSettings.getProperty("IngredientID", "57"));
  121. +           InAmountWeapon = Integer.parseInt(L2JFrozenSettings.getProperty("IngredientAmountWeapon", "15000"));
  122. +           InAmountArmor = Integer.parseInt(L2JFrozenSettings.getProperty("IngredientAmountArmor", "10000"));
  123. +           augmentItemChance = Integer.parseInt(L2JFrozenSettings.getProperty("AugmentItemChance", "30"));
  124. +           nonEnchantableItems = L2JFrozenSettings.getProperty("NonEnchantableItemList", "0");
  125. +           nonEnchantableItemList = new ArrayList<Integer>();
  126. +           for(String itemId : nonEnchantableItems.split(","))
  127. +               nonEnchantableItemList.add(Integer.parseInt(itemId));
  128. +
  129. +           modifyItemEnchant = Boolean.parseBoolean(L2JFrozenSettings.getProperty("ModifyItemEnchant", "false"));
  130. +           if(modifyItemEnchant)
  131. +           {
  132. +               modifyItemEnchantList = new FastMap<Integer, Integer>();
  133. +               String[] propertySplit = L2JFrozenSettings.getProperty("ModifyItemEnchantList", "").split(";");
  134. +               for(String item : propertySplit)
  135. +               {
  136. +                   String[] itemEnchantSplit = item.split(",");
  137. +                   if(itemEnchantSplit.length != 2)
  138. +                   {
  139. +                       System.out.println("invalid config property -> ModifyItemEnchantList \"" + item + "\"");
  140. +                   }
  141. +                   else
  142. +                   {
  143. +                       try
  144. +                       {
  145. +                           modifyItemEnchantList.put(Integer.parseInt(itemEnchantSplit[0]), Integer.parseInt(itemEnchantSplit[1]));
  146. +                       }
  147. +                       catch(NumberFormatException nfe)
  148. +                       {
  149. +                           if(Config.ENABLE_ALL_EXCEPTIONS)
  150. +                               nfe.printStackTrace();
  151. +                       }
  152. +                   }
  153. +               }
  154. +           }
  155. +       /*---------------------------------------------< Npc Enchant Items >-------------------------------------------------*/
  156.         }
  157.         catch(Exception e)
  158.         {
  159. Index: config/functions/l2jfrozen.properties
  160. ===================================================================
  161. --- config/functions/l2jfrozen.properties   (revision 1004)
  162. +++ config/functions/l2jfrozen.properties   (working copy)
  163. @@ -280,4 +280,33 @@
  164.  ProtectorSkillLevel = 13
  165.  ProtectorSkillTime = 600
  166.  # Npc Protector Message
  167. -ProtectorMessage = Hey You!, Never Kill On This Area, Go Read The Rules!
  168. \ No newline at end of file
  169. +ProtectorMessage = Hey You!, Never Kill On This Area, Go Read The Rules!
  170. +
  171. +# -------------------------------------------
  172. +#               Npc Enchant Items           -
  173. +# -------------------------------------------
  174. +# Npc Id = 56
  175. +# Enable Enchant Items NPC. Default: False
  176. +EnableNpcEnchantItems = False
  177. +
  178. +# Level of Weapon and Armor enchantment.
  179. +WeaponEnchantLevel = 20
  180. +ArmorEnchantLevel = 16
  181. +
  182. +# Price ID
  183. +IngredientID = 6393
  184. +
  185. +# Price Weapon Count
  186. +IngredientAmountWeapon = 50
  187. +
  188. +# Price Armor Count
  189. +IngredientAmountArmor = 10
  190. +
  191. +# Chance to augment item automatically on enchantment process.
  192. +AugmentItemChance = 30
  193. +
  194. +# List of Items that cannot be enchanted.
  195. +NonEnchantableItemList = 0
  196. +
  197. +ModifyItemEnchant = True
  198. +ModifyItemEnchantList = 0,0;
  199. Index: head-src/com/l2jfrozen/gameserver/model/PcInventory.java
  200. ===================================================================
  201. --- head-src/com/l2jfrozen/gameserver/model/PcInventory.java    (revision 1004)
  202. +++ head-src/com/l2jfrozen/gameserver/model/PcInventory.java    (working copy)
  203. @@ -25,6 +25,7 @@
  204.  
  205.  import javolution.util.FastList;
  206.  
  207. +import com.l2jfrozen.Config;
  208.  import com.l2jfrozen.gameserver.model.TradeList.TradeItem;
  209.  import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
  210.  import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance.ItemLocation;
  211. @@ -843,4 +844,57 @@
  212.        
  213.     }
  214.    
  215. +   public L2ItemInstance[] getWeaponsList()
  216. +   {
  217. +       FastList<L2ItemInstance> list = FastList.newInstance();
  218. +       for (L2ItemInstance item : _items)
  219. +       {
  220. +           if ((item != null) && (item.isEnchantable()) && item.isWeapon())
  221. +           {
  222. +               int enchantLevel = Config.weaponEnchantLevel;
  223. +               if (Config.modifyItemEnchant)
  224. +               {
  225. +                   if (Config.modifyItemEnchantList.containsKey(item.getItemId()))
  226. +                   {
  227. +                       enchantLevel = Config.modifyItemEnchantList.get(item.getItemId());
  228. +                   }
  229. +               }
  230. +
  231. +               if(item.getEnchantLevel() < enchantLevel)
  232. +                   list.add(item);
  233. +           }
  234. +       }
  235. +      
  236. +       L2ItemInstance[] result = list.toArray(new L2ItemInstance[list.size()]);
  237. +       FastList.recycle(list);
  238. +       return result;
  239. +   }
  240. +  
  241. +   public L2ItemInstance[] getArmorsList()
  242. +   {
  243. +       FastList<L2ItemInstance> list = FastList.newInstance();
  244. +       for (L2ItemInstance item : _items)
  245. +       {
  246. +           if ((item != null) && (item.isEnchantable()) && item.isArmor())
  247. +           {
  248. +               int enchantLevel = Config.armorEnchantLevel;
  249. +               if (Config.modifyItemEnchant)
  250. +               {
  251. +                   if (Config.modifyItemEnchantList.containsKey(item.getItemId()))
  252. +                   {
  253. +                       enchantLevel = Config.modifyItemEnchantList.get(item.getItemId());
  254. +                   }
  255. +               }
  256. +
  257. +               if(item.getEnchantLevel() < enchantLevel)
  258. +               {
  259. +                   list.add(item);
  260. +               }
  261. +           }
  262. +       }
  263. +      
  264. +       L2ItemInstance[] result = list.toArray(new L2ItemInstance[list.size()]);
  265. +       FastList.recycle(list);
  266. +       return result;
  267. +   }
  268.  }
  269. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemEnchanterInstance.java
  270. ===================================================================
  271. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemEnchanterInstance.java (revision 0)
  272. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemEnchanterInstance.java (working copy)
  273. @@ -0,0 +1,280 @@
  274. +/*
  275. + * This program is free software; you can redistribute it and/or modify
  276. + * it under the terms of the GNU General Public License as published by
  277. + * the Free Software Foundation; either version 2, or (at your option)
  278. + * any later version.
  279. + *
  280. + * This program is distributed in the hope that it will be useful,
  281. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  282. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  283. + * GNU General Public License for more details.
  284. + *
  285. + * You should have received a copy of the GNU General Public License
  286. + * along with this program; if not, write to the Free Software
  287. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  288. + * 02111-1307, USA.
  289. + *
  290. + * http://www.gnu.org/copyleft/gpl.html
  291. + */
  292. +package com.l2jfrozen.gameserver.model.actor.instance;
  293. +
  294. +import java.util.StringTokenizer;
  295. +
  296. +import com.l2jfrozen.Config;
  297. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  298. +import com.l2jfrozen.gameserver.datatables.sql.IconTable;
  299. +import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
  300. +import com.l2jfrozen.gameserver.datatables.xml.AugmentationData;
  301. +import com.l2jfrozen.gameserver.network.SystemMessageId;
  302. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  303. +import com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate;
  304. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  305. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  306. +import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  307. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  308. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  309. +import com.l2jfrozen.util.random.Rnd;
  310. +
  311. +public class L2ItemEnchanterInstance extends L2FolkInstance
  312. +{
  313. +   boolean flip = true;
  314. +   String IngredientName = ItemTable.getInstance().getTemplate(Config.IngredientID).getName();
  315. +  
  316. +   /**
  317. +    * @param objectId the object id
  318. +    * @param template the template
  319. +    */
  320. +   public L2ItemEnchanterInstance(int objectId, L2NpcTemplate template)
  321. +   {
  322. +       super(objectId, template);
  323. +   }
  324. +  
  325. +   /* (non-Javadoc)
  326. +    * @see com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance#onAction(com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance)
  327. +    */
  328. +   @Override
  329. +   public void onAction(L2PcInstance player)
  330. +   {
  331. +       if (!canTarget(player))
  332. +           return;
  333. +      
  334. +       // Check if the L2PcInstance already target the L2NpcInstance
  335. +       if (this != player.getTarget())
  336. +       {
  337. +           // Set the target of the L2PcInstance player
  338. +           player.setTarget(this);
  339. +          
  340. +           // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  341. +           MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  342. +           player.sendPacket(my);
  343. +           my = null;
  344. +          
  345. +           // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  346. +           player.sendPacket(new ValidateLocation(this));
  347. +       }
  348. +       else
  349. +       {
  350. +           // Calculate the distance between the L2PcInstance and the L2NpcInstance
  351. +           if (!canInteract(player))
  352. +           {
  353. +               // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  354. +               player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  355. +           }
  356. +           else
  357. +           {
  358. +               showChatWindow(player);
  359. +           }
  360. +       }
  361. +      
  362. +       // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  363. +       player.sendPacket(new ActionFailed());
  364. +   }
  365. +  
  366. +   @Override
  367. +   public void showChatWindow(L2PcInstance player)
  368. +   {
  369. +       String filename = "data/html/itemEnchanter/disabled.htm";
  370. +      
  371. +       if (Config.npcEnchantItemsEnabled)
  372. +       {
  373. +           filename = "data/html/itemEnchanter/start.htm";
  374. +       }
  375. +      
  376. +       NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  377. +       html.setFile(filename);
  378. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  379. +       player.sendPacket(html);
  380. +   }
  381. +  
  382. +   @Override
  383. +   public void onBypassFeedback(L2PcInstance player, String command)
  384. +   {
  385. +       String filename = "data/html/itemEnchanter/template.htm";
  386. +      
  387. +       StringTokenizer st = new StringTokenizer(command, " ");
  388. +       String actualCommand = st.nextToken();
  389. +      
  390. +       if (actualCommand.equalsIgnoreCase("enchant_weapon"))
  391. +       {
  392. +           L2ItemInstance[] weapon = player.getInventory().getWeaponsList();
  393. +           final int size = weapon.length;
  394. +           String text = "";
  395. +           String bgcolor = "";
  396. +          
  397. +           if (size == 0)
  398. +           {
  399. +               filename = "data/html/itemEnchanter/empty_list.htm";
  400. +           }
  401. +           else if (size > 15)
  402. +           {
  403. +               filename = "data/html/itemEnchanter/long_list.htm";
  404. +           }
  405. +          
  406. +           for (int i = 0; i != size; i++)
  407. +           {
  408. +               flip = !flip;
  409. +               final int itemId = weapon[i].getItem().getItemId();
  410. +               String name = weapon[i].getItemName();
  411. +               String Action = "Item " + String.valueOf(weapon[i].getObjectId());
  412. +               bgcolor = "";
  413. +              
  414. +               int enchantLevel = Config.weaponEnchantLevel;
  415. +               if (Config.modifyItemEnchant)
  416. +               {
  417. +                   if (Config.modifyItemEnchantList.containsKey(weapon[i].getItemId()))
  418. +                   {
  419. +                       enchantLevel = Config.modifyItemEnchantList.get(weapon[i].getItemId());
  420. +                   }
  421. +               }
  422. +
  423. +               if (flip == true)
  424. +               {
  425. +                   bgcolor = "bgcolor=000000";
  426. +               }
  427. +              
  428. +               text += "<table " + bgcolor + "><tr><td width=40><button action=\"bypass -h npc_" + getObjectId() + "_" + Action + "\" width=32 height=32 back=" + IconTable.getIcon(itemId) + " fore=" + IconTable.getIcon(itemId) + "></td><td width=220><table width=300><tr><td><font color=799BB0>+" + enchantLevel + " " + name + "</font></td><td></td></tr><tr><td><font color=B09B79> " + Config.InAmountWeapon + " " + IngredientName + "</font></td></tr></table></td></tr></table>";
  429. +           }
  430. +          
  431. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  432. +           html.setFile(filename);
  433. +          
  434. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  435. +           html.replace("%list%", String.valueOf(text));
  436. +           player.sendPacket(html);
  437. +       }
  438. +       if (actualCommand.equalsIgnoreCase("enchant_armor"))
  439. +       {
  440. +           L2ItemInstance[] armor = player.getInventory().getArmorsList();
  441. +           final int size = armor.length;
  442. +           String text = "";
  443. +           String bgcolor = "";
  444. +          
  445. +           if (size == 0)
  446. +           {
  447. +               filename = "data/html/itemEnchanter/empty_list.htm";
  448. +           }
  449. +           else if (size > 15)
  450. +           {
  451. +               filename = "data/html/itemEnchanter/long_list.htm";
  452. +           }
  453. +          
  454. +           for (int i = 0; i != size; i++)
  455. +           {
  456. +               flip = !flip;
  457. +               int itemId = armor[i].getItem().getItemId();
  458. +               String name = armor[i].getItemName();
  459. +               String Action = "Item " + String.valueOf(armor[i].getObjectId());
  460. +               bgcolor = "";
  461. +              
  462. +               int enchantLevel = Config.armorEnchantLevel;
  463. +               if (Config.modifyItemEnchant)
  464. +               {
  465. +                   if (Config.modifyItemEnchantList.containsKey(armor[i].getItemId()))
  466. +                   {
  467. +                       enchantLevel = Config.modifyItemEnchantList.get(armor[i].getItemId());
  468. +                   }
  469. +               }
  470. +
  471. +               if (flip == true)
  472. +               {
  473. +                   bgcolor = "bgcolor=000000";
  474. +               }
  475. +              
  476. +               text += "<table " + bgcolor + "><tr><td width=40><button action=\"bypass -h npc_" + getObjectId() + "_" + Action + "\" width=32 height=32 back=" + IconTable.getIcon(itemId) + " fore=" + IconTable.getIcon(itemId) + "></td><td width=220><table width=300><tr><td><font color=799BB0>+" + enchantLevel + " " + name + "</font></td><td></td></tr><tr><td><font color=B09B79> " + Config.InAmountArmor + " " + IngredientName + "</font></td></tr></table></td></tr></table>";
  477. +           }
  478. +          
  479. +           NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  480. +           html.setFile(filename);
  481. +          
  482. +           html.replace("%objectId%", String.valueOf(getObjectId()));
  483. +           html.replace("%list%", String.valueOf(text));
  484. +           player.sendPacket(html);
  485. +       }
  486. +      
  487. +       if (actualCommand.equalsIgnoreCase("Item"))
  488. +       {
  489. +           String bbx = st.nextToken();
  490. +           int itemId = Integer.valueOf(bbx);
  491. +           int itemCount = 0;
  492. +          
  493. +           int enchantLevel = Config.weaponEnchantLevel;
  494. +           int amount = Config.InAmountWeapon;
  495. +          
  496. +           L2ItemInstance item = player.getInventory().getItemByObjectId(itemId);
  497. +           if (item == null)
  498. +           {
  499. +               player.sendMessage("That item doesn't exist in your inventory.");
  500. +               return;
  501. +           }
  502. +          
  503. +           if (item.isArmor())
  504. +           {
  505. +               enchantLevel = Config.armorEnchantLevel;
  506. +               amount = Config.InAmountArmor;
  507. +           }
  508. +          
  509. +           if (Config.modifyItemEnchant)
  510. +           {
  511. +               if (Config.modifyItemEnchantList.containsKey(item.getItemId()))
  512. +               {
  513. +                   enchantLevel = Config.modifyItemEnchantList.get(item.getItemId());
  514. +               }
  515. +           }
  516. +
  517. +           if (player.getInventory().getItemByItemId(Config.IngredientID) != null)
  518. +           {
  519. +               itemCount = player.getInventory().getItemByItemId(Config.IngredientID).getCount();
  520. +               if (itemCount < amount)
  521. +               {
  522. +                   player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  523. +               }
  524. +               else
  525. +               {
  526. +                   player.destroyItemByItemId("enchantItem", Config.IngredientID, amount, player, true);
  527. +                   item.setEnchantLevel(enchantLevel);
  528. +                   player.sendPacket(new SystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED).addNumber(item.getEnchantLevel()).addItemName(item.getItemId()));
  529. +                  
  530. +                   if (item.isAugmentable())
  531. +                   {
  532. +                       if (Rnd.get(100) <= Config.augmentItemChance)
  533. +                       {
  534. +                           item.setAugmentation(AugmentationData.getInstance().generateRandomAugmentation(item, Rnd.get(7, 9), Rnd.get(2, 3)));
  535. +                           player.sendPacket(new SystemMessage(SystemMessageId.THE_ITEM_WAS_SUCCESSFULLY_AUGMENTED));
  536. +                       }
  537. +                   }
  538. +                  
  539. +                   InventoryUpdate iu = new InventoryUpdate();
  540. +                   iu.addModifiedItem(item);
  541. +                   player.sendPacket(iu);
  542. +                   player.broadcastUserInfo();
  543. +               }
  544. +           }
  545. +           else
  546. +           {
  547. +               player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  548. +           }
  549. +       }
  550. +      
  551. +       super.onBypassFeedback(player, command);
  552. +   }
  553. +}
  554. \ No newline at end of file
  555. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemInstance.java
  556. ===================================================================
  557. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemInstance.java  (revision 1004)
  558. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2ItemInstance.java  (working copy)
  559. @@ -49,6 +49,8 @@
  560.  import com.l2jfrozen.gameserver.templates.L2Armor;
  561.  import com.l2jfrozen.gameserver.templates.L2EtcItem;
  562.  import com.l2jfrozen.gameserver.templates.L2Item;
  563. +import com.l2jfrozen.gameserver.templates.L2Weapon;
  564. +import com.l2jfrozen.gameserver.templates.L2WeaponType;
  565.  import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  566.  import com.l2jfrozen.util.CloseUtil;
  567.  import com.l2jfrozen.util.database.L2DatabaseFactory;
  568. @@ -594,6 +596,75 @@
  569.     }
  570.  
  571.     /**
  572. +    * Returns true if item is an EtcItem
  573. +    * @return boolean
  574. +    */
  575. +   public boolean isEtcItem()
  576. +   {
  577. +       return (_item instanceof L2EtcItem);
  578. +   }
  579. +  
  580. +   /**
  581. +    * Returns true if item is a Weapon/Shield
  582. +    * @return boolean
  583. +    */
  584. +   public boolean isWeapon()
  585. +   {
  586. +       return (_item instanceof L2Weapon);
  587. +   }
  588. +  
  589. +   /**
  590. +    * Returns true if item is an Armor
  591. +    * @return boolean
  592. +    */
  593. +   public boolean isArmor()
  594. +   {
  595. +       return (_item instanceof L2Armor);
  596. +   }
  597. +  
  598. +   /**
  599. +    * Returns the characteristics of the L2EtcItem
  600. +    * @return L2EtcItem
  601. +    */
  602. +   public L2EtcItem getEtcItem()
  603. +   {
  604. +       if (_item instanceof L2EtcItem)
  605. +       {
  606. +           return (L2EtcItem) _item;
  607. +       }
  608. +      
  609. +       return null;
  610. +   }
  611. +  
  612. +   /**
  613. +    * Returns the characteristics of the L2Weapon
  614. +    * @return L2Weapon
  615. +    */
  616. +   public L2Weapon getWeaponItem()
  617. +   {
  618. +       if (_item instanceof L2Weapon)
  619. +       {
  620. +           return (L2Weapon) _item;
  621. +       }
  622. +      
  623. +       return null;
  624. +   }
  625. +  
  626. +   /**
  627. +    * Returns the characteristics of the L2Armor
  628. +    * @return L2Armor
  629. +    */
  630. +   public L2Armor getArmorItem()
  631. +   {
  632. +       if (_item instanceof L2Armor)
  633. +       {
  634. +           return (L2Armor) _item;
  635. +       }
  636. +      
  637. +       return null;
  638. +   }
  639. +  
  640. +   /**
  641.      * Returns the quantity of crystals for crystallization.
  642.      *
  643.      * @return int
  644. @@ -604,6 +675,16 @@
  645.     }
  646.  
  647.     /**
  648. +    * Returns the reference grade of the item.
  649. +    *
  650. +    * @return int
  651. +    */
  652. +   public final int getItemGrade()
  653. +   {
  654. +       return _item.getCrystalType();
  655. +   }
  656. +  
  657. +   /**
  658.      * Returns the reference price of the item.
  659.      *
  660.      * @return int
  661. @@ -1738,4 +1819,32 @@
  662.         return true;
  663.     }
  664.  
  665. +   /**
  666. +    * @return true if item can be enchanted.
  667. +    */
  668. +   public boolean isEnchantable()
  669. +   {
  670. +       if (isHeroItem() || isShadowItem() || isEtcItem() || (getItem().getItemType() == L2WeaponType.ROD))
  671. +           return false;
  672. +      
  673. +       if (getItemGrade() == L2Item.CRYSTAL_NONE)
  674. +           return false;
  675. +      
  676. +       if (Config.nonEnchantableItemList.contains(_itemId))
  677. +           return false;
  678. +      
  679. +       // only equipped items or in inventory can be enchanted
  680. +       if ((getLocation() != L2ItemInstance.ItemLocation.INVENTORY) && (getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL))
  681. +           return false;
  682. +      
  683. +       return true;
  684. +   }
  685. +  
  686. +   public boolean isAugmentable()
  687. +   {
  688. +       if(isAugmented() || isArmor() || getItem().getItemType() == L2WeaponType.NONE)
  689. +           return false;
  690. +      
  691. +       return true;
  692. +   }
  693.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement