Hello how would you put a scroll to all grids? I can not set the scroll grid for all.
### Eclipse Workspace Patch 1.0#P aCis_datapackIndex: data/xml/enchants.xml
===================================================================--- data/xml/enchants.xml (revision 0)+++ data/xml/enchants.xml (revision 0)@@-0,0+1,44@@+<?xml version='1.0' encoding='utf-8'?>+<list>+<!--Scrolls:EnchantWeapon-->+<enchant id="959" grade="5" weapon="True"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- S grade -Scrolls:EnchantWeapon-->+<enchant id="729" grade="4" weapon="True"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- A grade -Scrolls:EnchantWeapon-->+<enchant id="947" grade="3" weapon="True"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- B grade -Scrolls:EnchantWeapon-->+<enchant id="951" grade="2" weapon="True"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- C grade -Scrolls:EnchantWeapon-->+<enchant id="955" grade="1" weapon="True"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- D grade -Scrolls:EnchantWeapon-->++<!--Scrolls:EnchantArmor-->+<enchant id="960" grade="5" weapon="False"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- S grade -Scrolls:EnchantArmor-->+<enchant id="730" grade="4" weapon="False"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- A grade -Scrolls:EnchantArmor-->+<enchant id="948" grade="3" weapon="False"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- B grade -Scrolls:EnchantArmor-->+<enchant id="952" grade="2" weapon="False"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- C grade -Scrolls:EnchantArmor-->+<enchant id="956" grade="1" weapon="False"break="True" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- D grade -Scrolls:EnchantArmor-->++<!--BlessedScrolls:EnchantWeapon-->+<enchant id="6577" grade="5" weapon="True"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- S grade -BlessedScrolls:EnchantWeapon-->+<enchant id="6569" grade="4" weapon="True"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- A grade -BlessedScrolls:EnchantWeapon-->+<enchant id="6571" grade="3" weapon="True"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- B grade -BlessedScrolls:EnchantWeapon-->+<enchant id="6573" grade="2" weapon="True"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- C grade -BlessedScrolls:EnchantWeapon-->+<enchant id="6575" grade="1" weapon="True"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- D grade -BlessedScrolls:EnchantWeapon-->++<!--BlessedScrolls:ArmorWeapon-->+<enchant id="6578" grade="5" weapon="False"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- S grade -BlessedScrolls:EnchantArmor-->+<enchant id="6570" grade="4" weapon="False"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- A grade -BlessedScrolls:EnchantArmor-->+<enchant id="6572" grade="3" weapon="False"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- B grade -BlessedScrolls:EnchantArmor-->+<enchant id="6574" grade="2" weapon="False"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- C grade -BlessedScrolls:EnchantArmor-->+<enchant id="6576" grade="1" weapon="False"break="False" maintain="False" chance="100;100;100;95;90;85;80;75"/><!-- D grade -BlessedScrolls:EnchantArmor-->++<!--CrystalScrolls:EnchantWeapon-->+<enchant id="961" grade="5" weapon="True"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- S grade -CrystalScrolls:EnchantWeapon-->+<enchant id="731" grade="4" weapon="True"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- A grade -CrystalScrolls:EnchantWeapon-->+<enchant id="949" grade="3" weapon="True"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- B grade -CrystalScrolls:EnchantWeapon-->+<enchant id="953" grade="2" weapon="True"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- C grade -CrystalScrolls:EnchantWeapon-->+<enchant id="957" grade="1" weapon="True"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- D grade -CrystalScrolls:EnchantWeapon-->++<!--CrystalScrolls:EnchantArmor-->+<enchant id="962" grade="5" weapon="False"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- S grade -CrystalScrolls:EnchantWeapon-->+<enchant id="732" grade="4" weapon="False"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- A grade -CrystalScrolls:EnchantWeapon-->+<enchant id="950" grade="3" weapon="False"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- B grade -CrystalScrolls:EnchantWeapon-->+<enchant id="954" grade="2" weapon="False"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- C grade -CrystalScrolls:EnchantWeapon-->+<enchant id="958" grade="1" weapon="False"break="False" maintain="True" chance="100;100;100;95;90;85;80;75"/><!-- D grade -CrystalScrolls:EnchantWeapon-->+</list>
\ No newline at end of file
#P aCis_gameserverIndex: java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java
===================================================================--- java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (revision 5)+++ java/net/sf/l2j/gameserver/network/clientpackets/AbstractEnchantPacket.java (working copy)@@-1,212+0,0@@-/*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */-package net.sf.l2j.gameserver.network.clientpackets;--import java.util.HashMap;-import java.util.Map;--import net.sf.l2j.Config;-import net.sf.l2j.gameserver.model.item.instance.ItemInstance;-import net.sf.l2j.gameserver.model.item.kind.Item;-import net.sf.l2j.gameserver.model.item.kind.Weapon;-import net.sf.l2j.gameserver.model.item.type.CrystalType;-import net.sf.l2j.gameserver.model.item.type.WeaponType;--public abstract classAbstractEnchantPacket extends L2GameClientPacket
-{-publicstatic final Map<Integer,EnchantScroll> _scrolls =newHashMap<>();--publicstatic final classEnchantScroll-{-protected final boolean _isWeapon;-protected final CrystalType _grade;-private final boolean _isBlessed;-private final boolean _isCrystal;--publicEnchantScroll(boolean wep, boolean bless, boolean crystal,CrystalType type)-{- _isWeapon = wep;- _grade = type;- _isBlessed = bless;- _isCrystal = crystal;-}--/**
- * @param enchantItem : The item to enchant.
- * @return true if support item can be used for this item
- */-public final boolean isValid(ItemInstance enchantItem)-{-if(enchantItem == null)-returnfalse;--// checking scroll type and configured maximum enchant level-switch(enchantItem.getItem().getType2())-{-caseItem.TYPE2_WEAPON:-if(!_isWeapon ||(Config.ENCHANT_MAX_WEAPON >0&& enchantItem.getEnchantLevel()>=Config.ENCHANT_MAX_WEAPON))-returnfalse;-break;--caseItem.TYPE2_SHIELD_ARMOR:-caseItem.TYPE2_ACCESSORY:-if(_isWeapon ||(Config.ENCHANT_MAX_ARMOR >0&& enchantItem.getEnchantLevel()>=Config.ENCHANT_MAX_ARMOR))-returnfalse;-break;--default:-returnfalse;-}--// check for crystal type-if(_grade != enchantItem.getItem().getCrystalType())-returnfalse;--returntrue;-}--/**
- * @return true if item is a blessed scroll.
- */-public final boolean isBlessed()-{-return _isBlessed;-}--/**
- * @return true if item is a crystal scroll.
- */-public final boolean isCrystal()-{-return _isCrystal;-}--/**
- * Regarding enchant system :<br>
- * <br>
- * <u>Weapons</u>
- * <ul>
- * <li>magic weapons has chance of 40% until +15 and 20% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li>
- * <li>non magic weapons has chance of 70% until +15 and 35% from +15 and higher. There is no upper limit, there is no dependance on current enchant level.</li>
- * </ul>
- * <u>Armors</u>
- * <ul>
- * <li>non fullbody armors (jewelry, upper armor, lower armor, boots, gloves, helmets and shirts) has chance of 2/3 for +4, 1/3 for +5, 1/4 for +6, ...., 1/18 +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li>
- * <li>full body armors has a chance of 1/1 for +4, 2/3 for +5, 1/3 for +6, ..., 1/17 for +20. If you've made a +20 armor, chance to make it +21 will be equal to zero (0%).</li>
- * </ul>
- * @param enchantItem : The item to enchant.
- * @return the enchant chance under double format (0.7 / 0.35 / 0.44324...).
- */-public final double getChance(ItemInstance enchantItem)-{-if(!isValid(enchantItem))-return-1;-- boolean fullBody = enchantItem.getItem().getBodyPart()==Item.SLOT_FULL_ARMOR;-if(enchantItem.getEnchantLevel()<Config.ENCHANT_SAFE_MAX ||(fullBody && enchantItem.getEnchantLevel()<Config.ENCHANT_SAFE_MAX_FULL))-return1;--double chance =0;--// Armor formula : 0.66^(current-2), chance is lower and lower for each enchant.-if(enchantItem.isArmor())- chance =Math.pow(Config.ENCHANT_CHANCE_ARMOR,(enchantItem.getEnchantLevel()-2));-// Weapon formula is 70% for fighter weapon, 40% for mage weapon. Special rates after +14.-elseif(enchantItem.isWeapon())-{-if(((Weapon) enchantItem.getItem()).isMagical())- chance =(enchantItem.getEnchantLevel()>14)?Config.ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS :Config.ENCHANT_CHANCE_WEAPON_MAGIC;-else- chance =(enchantItem.getEnchantLevel()>14)?Config.ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS :Config.ENCHANT_CHANCE_WEAPON_NONMAGIC;-}--return chance;-}-}--/**
- * Format : itemId, (isWeapon, isBlessed, isCrystal, grade)<br>
- * Allowed items IDs must be sorted by ascending order.
- */-static-{-// Scrolls: Enchant Weapon- _scrolls.put(729,newEnchantScroll(true,false,false,CrystalType.A));- _scrolls.put(947,newEnchantScroll(true,false,false,CrystalType.B));- _scrolls.put(951,newEnchantScroll(true,false,false,CrystalType.C));- _scrolls.put(955,newEnchantScroll(true,false,false,CrystalType.D));- _scrolls.put(959,newEnchantScroll(true,false,false,CrystalType.S));--// Scrolls: Enchant Armor- _scrolls.put(730,newEnchantScroll(false,false,false,CrystalType.A));- _scrolls.put(948,newEnchantScroll(false,false,false,CrystalType.B));- _scrolls.put(952,newEnchantScroll(false,false,false,CrystalType.C));- _scrolls.put(956,newEnchantScroll(false,false,false,CrystalType.D));- _scrolls.put(960,newEnchantScroll(false,false,false,CrystalType.S));--// Blessed Scrolls: Enchant Weapon- _scrolls.put(6569,newEnchantScroll(true,true,false,CrystalType.A));- _scrolls.put(6571,newEnchantScroll(true,true,false,CrystalType.B));- _scrolls.put(6573,newEnchantScroll(true,true,false,CrystalType.C));- _scrolls.put(6575,newEnchantScroll(true,true,false,CrystalType.D));- _scrolls.put(6577,newEnchantScroll(true,true,false,CrystalType.S));--// Blessed Scrolls: Enchant Armor- _scrolls.put(6570,newEnchantScroll(false,true,false,CrystalType.A));- _scrolls.put(6572,newEnchantScroll(false,true,false,CrystalType.B));- _scrolls.put(6574,newEnchantScroll(false,true,false,CrystalType.C));- _scrolls.put(6576,newEnchantScroll(false,true,false,CrystalType.D));- _scrolls.put(6578,newEnchantScroll(false,true,false,CrystalType.S));--// Crystal Scrolls: Enchant Weapon- _scrolls.put(731,newEnchantScroll(true,false,true,CrystalType.A));- _scrolls.put(949,newEnchantScroll(true,false,true,CrystalType.B));- _scrolls.put(953,newEnchantScroll(true,false,true,CrystalType.C));- _scrolls.put(957,newEnchantScroll(true,false,true,CrystalType.D));- _scrolls.put(961,newEnchantScroll(true,false,true,CrystalType.S));--// Crystal Scrolls: Enchant Armor- _scrolls.put(732,newEnchantScroll(false,false,true,CrystalType.A));- _scrolls.put(950,newEnchantScroll(false,false,true,CrystalType.B));- _scrolls.put(954,newEnchantScroll(false,false,true,CrystalType.C));- _scrolls.put(958,newEnchantScroll(false,false,true,CrystalType.D));- _scrolls.put(962,newEnchantScroll(false,false,true,CrystalType.S));-}--/**
- * @param scroll The instance of item to make checks on.
- * @return enchant template for scroll.
- */-protectedstatic final EnchantScroll getEnchantScroll(ItemInstance scroll)-{-return _scrolls.get(scroll.getItemId());-}--/**
- * @param item The instance of item to make checks on.
- * @return true if item can be enchanted.
- */-protectedstatic final boolean isEnchantable(ItemInstance item)-{-if(item.isHeroItem()|| item.isShadowItem()|| item.isEtcItem()|| item.getItem().getItemType()==WeaponType.FISHINGROD)-returnfalse;--// only equipped items or in inventory can be enchanted-if(item.getLocation()!=ItemInstance.ItemLocation.INVENTORY && item.getLocation()!=ItemInstance.ItemLocation.PAPERDOLL)-returnfalse;--returntrue;-}-}
\ No newline at end of file
Index: config/players.properties
===================================================================--- config/players.properties (revision 5)+++ config/players.properties (working copy)@@-72,30+72,6@@AltGameFreightPrice=1000#=============================================================-#Enchant-#=============================================================-#% chance of success to enchant a magic weapon
-EnchantChanceMagicWeapon=0.4-EnchantChanceMagicWeapon15Plus=0.2--#% chance of success to enchant a non magic weapon
-EnchantChanceNonMagicWeapon=0.7-EnchantChanceNonMagicWeapon15Plus=0.35--#% chance of success to enchant an armor part (both jewelry or armor)-EnchantChanceArmor=0.66--#Enchant limit [default=0]-EnchantMaxWeapon=0-EnchantMaxArmor=0--#ifEnchantSafeMax is set to for ex '8' the item will be safly enchanted to '8' regardless of
-# enchant chance(default=3forEnchantSafeMax and default=4forEnchantSafeMaxFull)-#EnchantSafeMaxFull is for full body armor (upper and lower), value should be >0.-EnchantSafeMax=3-EnchantSafeMaxFull=4--#=============================================================# Augmentations#=============================================================# Control the chance to get a skill in the augmentation process.Index: java/net/sf/l2j/gameserver/datatables/EnchantTable.java
===================================================================--- java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0)+++ java/net/sf/l2j/gameserver/datatables/EnchantTable.java (revision 0)@@-0,0+1,117@@+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */+package net.sf.l2j.gameserver.datatables;++import java.io.File;+import java.util.HashMap;+import java.util.Map;+import java.util.logging.Logger;++import net.sf.l2j.gameserver.model.L2EnchantScroll;+import net.sf.l2j.gameserver.model.item.instance.ItemInstance;+import net.sf.l2j.gameserver.model.item.type.CrystalType;+import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;++import org.w3c.dom.Document;+import org.w3c.dom.NamedNodeMap;+import org.w3c.dom.Node;++publicclassEnchantTable+{+privatestaticLogger _log =Logger.getLogger(EnchantTable.class.getName());++privatestatic final Map<Integer, L2EnchantScroll> _map =newHashMap<>();++publicstaticEnchantTable getInstance()+{+returnSingletonHolder._instance;+}++protectedEnchantTable()+{+try+{+File f =newFile("./data/xml/enchants.xml");+Document doc =XMLDocumentFactory.getInstance().loadDocument(f);++for(Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())+{+if("list".equalsIgnoreCase(n.getNodeName()))+{+for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())+{+if("enchant".equalsIgnoreCase(d.getNodeName()))+{+NamedNodeMap attrs = d.getAttributes();++int id =Integer.valueOf(attrs.getNamedItem("id").getNodeValue());+ byte grade =Byte.valueOf(attrs.getNamedItem("grade").getNodeValue());+ boolean weapon =Boolean.valueOf(attrs.getNamedItem("weapon").getNodeValue());+ boolean breaks =Boolean.valueOf(attrs.getNamedItem("break").getNodeValue());+ boolean maintain =Boolean.valueOf(attrs.getNamedItem("maintain").getNodeValue());++String[]list= attrs.getNamedItem("chance").getNodeValue().split(";");+ byte[] chance =new byte[list.length];+for(int i =0; i <list.length; i++)+ chance[i]=Byte.valueOf(list[i]);++CrystalType grade_test =CrystalType.NONE;+switch(grade)+{+case1:+ grade_test =CrystalType.D;+break;+case2:+ grade_test =CrystalType.C;+break;+case3:+ grade_test =CrystalType.B;+break;+case4:+ grade_test =CrystalType.A;+break;+case5:+ grade_test =CrystalType.S;+break;+}++ _map.put(id,new L2EnchantScroll(grade_test, weapon, breaks, maintain, chance));+}+}+}+}++ _log.info("EnchantTable: Loaded "+ _map.size()+" enchants.");+}+catch(Exception e)+{+ _log.warning("EnchantTable: Error while loading enchant table: "+ e);+}+}++public L2EnchantScroll getEnchantScroll(ItemInstance item)+{+return _map.get(item.getItemId());+}++privatestaticclassSingletonHolder+{+protectedstatic final EnchantTable _instance =newEnchantTable();+}+}Index: java/net/sf/l2j/gameserver/GameServer.java
===================================================================--- java/net/sf/l2j/gameserver/GameServer.java (revision 5)+++ java/net/sf/l2j/gameserver/GameServer.java (working copy)@@-42,6+42,7@@import net.sf.l2j.gameserver.datatables.CharTemplateTable;import net.sf.l2j.gameserver.datatables.ClanTable;import net.sf.l2j.gameserver.datatables.DoorTable;+import net.sf.l2j.gameserver.datatables.EnchantTable;import net.sf.l2j.gameserver.datatables.FishTable;import net.sf.l2j.gameserver.datatables.GmListTable;import net.sf.l2j.gameserver.datatables.HelperBuffTable;@@-166,6+167,7@@FishTable.getInstance();SpellbookTable.getInstance();SoulCrystalsTable.load();+EnchantTable.getInstance();Util.printSection("Augments");AugmentationData.getInstance();Index: java/net/sf/l2j/gameserver/model/L2EnchantScroll.java
===================================================================--- java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0)+++ java/net/sf/l2j/gameserver/model/L2EnchantScroll.java (revision 0)@@-0,0+1,104@@+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */+package net.sf.l2j.gameserver.model;++import net.sf.l2j.gameserver.model.item.instance.ItemInstance;+import net.sf.l2j.gameserver.model.item.kind.Item;+import net.sf.l2j.gameserver.model.item.type.CrystalType;++publicclass L2EnchantScroll
+{+private final CrystalType _grade;+private final boolean _weapon;+private final boolean _breaks;+private final boolean _maintain;+private final byte[] _chance;++public L2EnchantScroll(CrystalType grade, boolean weapon, boolean breaks, boolean maintain, byte[] chance)+{+ _grade = grade;+ _weapon = weapon;+ _breaks = breaks;+ _maintain = maintain;+ _chance = chance;+}++/**
+ * @param enchantItem : The item to enchant.
+ * @return the enchant chance under double format.
+ */+public final byte getChance(ItemInstance enchantItem)+{+int level = enchantItem.getEnchantLevel();+if(enchantItem.getItem().getBodyPart()==Item.SLOT_FULL_ARMOR && level !=0)+ level--;++if(level >= _chance.length)+return0;++return _chance[level];+}++public final boolean canBreak()+{+return _breaks;+}++public final boolean canMaintain()+{+return _maintain;+}++// TODO: methods++/**
+ * @param enchantItem : The item to enchant.
+ * @return True if enchant can be used on selected item.
+ */+public final boolean isValid(ItemInstance enchantItem)+{+// check for crystal type+if(_grade != enchantItem.getItem().getCrystalType())+returnfalse;++// check enchant max level+if(enchantItem.getEnchantLevel()>= _chance.length)+returnfalse;++// checking scroll type+switch(enchantItem.getItem().getType2())+{+caseItem.TYPE2_WEAPON:+if(!_weapon)+returnfalse;+break;++caseItem.TYPE2_SHIELD_ARMOR:+caseItem.TYPE2_ACCESSORY:+if(_weapon)+returnfalse;+break;++default:+returnfalse;+}++returntrue;+}+}Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java
===================================================================--- java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (revision 5)+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestEnchantItem.java (working copy)@@-16,7+16,9@@import net.sf.l2j.Config;import net.sf.l2j.gameserver.datatables.ArmorSetsTable;+import net.sf.l2j.gameserver.datatables.EnchantTable;import net.sf.l2j.gameserver.datatables.SkillTable;+import net.sf.l2j.gameserver.model.L2EnchantScroll;import net.sf.l2j.gameserver.model.L2Skill;import net.sf.l2j.gameserver.model.L2World;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;@@-25,6+27,7@@import net.sf.l2j.gameserver.model.item.kind.Armor;import net.sf.l2j.gameserver.model.item.kind.Item;import net.sf.l2j.gameserver.model.item.kind.Weapon;+import net.sf.l2j.gameserver.model.item.type.WeaponType;import net.sf.l2j.gameserver.model.itemcontainer.Inventory;import net.sf.l2j.gameserver.network.SystemMessageId;import net.sf.l2j.gameserver.network.serverpackets.EnchantResult;@@-35,7+38,7@@import net.sf.l2j.gameserver.util.Util;import net.sf.l2j.util.Rnd;-public final classRequestEnchantItem extends AbstractEnchantPacket+public final classRequestEnchantItem extends L2GameClientPacket
{privateint _objectId =0;@@-48,16+51,19@@@Overrideprotectedvoid runImpl(){+// get player
final L2PcInstance activeChar = getClient().getActiveChar();if(activeChar == null || _objectId ==0)return;+// player online and activeif(!activeChar.isOnline()|| getClient().isDetached()){
activeChar.setActiveEnchantItem(null);return;}+// player on shop/craftif(activeChar.isProcessingTransaction()|| activeChar.isInStoreMode()){
activeChar.sendPacket(SystemMessageId.CANNOT_ENCHANT_WHILE_STORE);@@-65,7+71,18@@
activeChar.sendPacket(EnchantResult.CANCELLED);return;}++// player trading+if(activeChar.getActiveTradeList()!= null)+{+ activeChar.cancelActiveTrade();+ activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED);+ activeChar.setActiveEnchantItem(null);+ activeChar.sendPacket(EnchantResult.CANCELLED);+return;+}+// get item and enchant scrollItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);ItemInstance scroll = activeChar.getActiveEnchantItem();@@-77,13+94,13@@return;}-// template for scroll-EnchantScroll scrollTemplate = getEnchantScroll(scroll);-if(scrollTemplate == null)+// get scroll enchant data+ L2EnchantScroll enchant =EnchantTable.getInstance().getEnchantScroll(scroll);+if(enchant == null)return;-// first validation check-if(!scrollTemplate.isValid(item)||!isEnchantable(item))+// validation check+if(!isEnchantable(item)||!enchant.isValid(item)|| item.getOwnerId()!= activeChar.getObjectId()){
activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);
activeChar.setActiveEnchantItem(null);@@-91,7+108,7@@return;}-// attempting to destroy scroll+// destroy enchant scroll
scroll = activeChar.getInventory().destroyItem("Enchant", scroll.getObjectId(),1, activeChar, item);if(scroll == null){@@-102,46+119,27@@return;}-if(activeChar.getActiveTradeList()!= null)-{- activeChar.cancelActiveTrade();- activeChar.sendPacket(SystemMessageId.TRADE_ATTEMPT_FAILED);-return;-}-
synchronized (item){-double chance = scrollTemplate.getChance(item);--// last validation check-if(item.getOwnerId()!= activeChar.getObjectId()||!isEnchantable(item)|| chance <0)-{- activeChar.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITION);- activeChar.setActiveEnchantItem(null);- activeChar.sendPacket(EnchantResult.CANCELLED);-return;-}-// success-if(Rnd.get()< chance)+if(Rnd.get(100)< enchant.getChance(item)){-// announce the success+// send messageSystemMessage sm;if(item.getEnchantLevel()==0){
sm =SystemMessage.getSystemMessage(SystemMessageId.S1_SUCCESSFULLY_ENCHANTED);- sm.addItemName(item.getItemId());- activeChar.sendPacket(sm);}else{
sm =SystemMessage.getSystemMessage(SystemMessageId.S1_S2_SUCCESSFULLY_ENCHANTED);
sm.addNumber(item.getEnchantLevel());- sm.addItemName(item.getItemId());- activeChar.sendPacket(sm);}+ sm.addItemName(item.getItemId());+// update item
item.setEnchantLevel(item.getEnchantLevel()+1);
item.updateDatabase();@@-186,6+184,7@@}
activeChar.sendPacket(EnchantResult.SUCCESS);}+// failelse{// Drop passive skills from items.@@-228,39+227,46@@}}-if(scrollTemplate.isBlessed())+if(!enchant.canBreak()){-// blessed enchant - clear enchant value+// keep item
activeChar.sendPacket(SystemMessageId.BLESSED_ENCHANT_FAILED);- item.setEnchantLevel(0);- item.updateDatabase();+if(!enchant.canMaintain())+{+ item.setEnchantLevel(0);+ item.updateDatabase();+}
activeChar.sendPacket(EnchantResult.UNSUCCESS);}else{-// enchant failed, destroy item-int crystalId = item.getItem().getCrystalItemId();-int count = item.getCrystalCount()-(item.getItem().getCrystalCount()+1)/2;-if(count <1)- count =1;-+// destroy itemItemInstance destroyItem = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);if(destroyItem == null){-// unable to destroy item, cheater ?Util.handleIllegalPlayerAction(activeChar,"Unable to delete item on enchant failure from player "+ activeChar.getName()+", possible cheater !",Config.DEFAULT_PUNISH);
activeChar.setActiveEnchantItem(null);
activeChar.sendPacket(EnchantResult.CANCELLED);return;}-if(crystalId !=0)+// add crystals, if item crystalizable+int crystalType = item.getItem().getCrystalItemId();+ItemInstance crystals = null;+if(crystalType !=0){- activeChar.getInventory().addItem("Enchant", crystalId, count, activeChar, destroyItem);- activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystalId).addItemNumber(count));+// get crystals count+int crystalCount = item.getCrystalCount()-(item.getItem().getCrystalCount()+1)/2;+if(crystalCount <1)+ crystalCount =1;++// add crystals to inventory+ crystals = activeChar.getInventory().addItem("Enchant", crystalType, crystalCount, activeChar, destroyItem);+ activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S).addItemName(crystals.getItemId()).addItemNumber(crystalCount));}+// update inventoryInventoryUpdate iu =newInventoryUpdate();if(destroyItem.getCount()==0)
iu.addRemovedItem(destroyItem);@@-269,27+275,49@@
activeChar.sendPacket(iu);-// Messages.+// remove item+ L2World.getInstance().removeObject(destroyItem);++// send messageif(item.getEnchantLevel()>0)
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_S2_EVAPORATED).addNumber(item.getEnchantLevel()).addItemName(item.getItemId()));else
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENCHANTMENT_FAILED_S1_EVAPORATED).addItemName(item.getItemId()));- L2World.getInstance().removeObject(destroyItem);-if(crystalId ==0)+// send enchant result+if(crystalType ==0)
activeChar.sendPacket(EnchantResult.UNK_RESULT_4);else
activeChar.sendPacket(EnchantResult.UNK_RESULT_1);+// update weightStatusUpdate su =newStatusUpdate(activeChar);
su.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
activeChar.sendPacket(su);}}+// send item list
activeChar.sendPacket(newItemList(activeChar,false));++// update appearance
activeChar.broadcastUserInfo();
activeChar.setActiveEnchantItem(null);}}+/**
+ * @param item The instance of item to make checks on.
+ * @return true if item can be enchanted.
+ */+privatestatic final boolean isEnchantable(ItemInstance item)+{+if(item.isHeroItem()|| item.isShadowItem()|| item.isEtcItem()|| item.getItem().getItemType()==WeaponType.FISHINGROD)+returnfalse;++// only equipped items or in inventory can be enchanted+if(item.getLocation()!=ItemInstance.ItemLocation.INVENTORY && item.getLocation()!=ItemInstance.ItemLocation.PAPERDOLL)+returnfalse;++returntrue;+}}
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================--- java/net/sf/l2j/Config.java (revision 5)+++ java/net/sf/l2j/Config.java (working copy)@@-405,17+405,6@@publicstatic boolean ALT_GAME_FREIGHTS;publicstaticint ALT_GAME_FREIGHT_PRICE;-/** Enchant */-publicstaticdouble ENCHANT_CHANCE_WEAPON_MAGIC;-publicstaticdouble ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS;-publicstaticdouble ENCHANT_CHANCE_WEAPON_NONMAGIC;-publicstaticdouble ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS;-publicstaticdouble ENCHANT_CHANCE_ARMOR;-publicstaticint ENCHANT_MAX_WEAPON;-publicstaticint ENCHANT_MAX_ARMOR;-publicstaticint ENCHANT_SAFE_MAX;-publicstaticint ENCHANT_SAFE_MAX_FULL;-/** Augmentations */publicstaticint AUGMENTATION_NG_SKILL_CHANCE;publicstaticint AUGMENTATION_NG_GLOW_CHANCE;@@-1020,16+1009,6@@
ALT_GAME_FREIGHTS = players.getProperty("AltGameFreights",false);
ALT_GAME_FREIGHT_PRICE = players.getProperty("AltGameFreightPrice",1000);- ENCHANT_CHANCE_WEAPON_MAGIC = players.getProperty("EnchantChanceMagicWeapon",0.4);- ENCHANT_CHANCE_WEAPON_MAGIC_15PLUS = players.getProperty("EnchantChanceMagicWeapon15Plus",0.2);- ENCHANT_CHANCE_WEAPON_NONMAGIC = players.getProperty("EnchantChanceNonMagicWeapon",0.7);- ENCHANT_CHANCE_WEAPON_NONMAGIC_15PLUS = players.getProperty("EnchantChanceNonMagicWeapon15Plus",0.35);- ENCHANT_CHANCE_ARMOR = players.getProperty("EnchantChanceArmor",0.66);- ENCHANT_MAX_WEAPON = players.getProperty("EnchantMaxWeapon",0);- ENCHANT_MAX_ARMOR = players.getProperty("EnchantMaxArmor",0);- ENCHANT_SAFE_MAX = players.getProperty("EnchantSafeMax",3);- ENCHANT_SAFE_MAX_FULL = players.getProperty("EnchantSafeMaxFull",4);-
AUGMENTATION_NG_SKILL_CHANCE = players.getProperty("AugmentationNGSkillChance",15);
AUGMENTATION_NG_GLOW_CHANCE = players.getProperty("AugmentationNGGlowChance",0);
AUGMENTATION_MID_SKILL_CHANCE = players.getProperty("AugmentationMidSkillChance",30);
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I apologize for my incompetence. The ability to trade is limited only for builder 1. Ordinary characters can trade with each other, and this has nothing to do with auto loot.)
Question
l2jkain
Hello how would you put a scroll to all grids? I can not set the scroll grid for all.
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.