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