Jump to content

alexvega021

Members
  • Posts

    4
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

About alexvega021

Profile Information

  • Gender
    Not Telling

alexvega021's Achievements

Newbie

Newbie (1/16)

0

Reputation

  1. I need to put 3 attributes, I configure and put all in one package custom.mondial.enchantmanager; import java.util.StringTokenizer; import java.util.logging.Logger; import com.l2jserver.gameserver.model.Elementals; import com.l2jserver.gameserver.model.actor.L2Npc; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.model.itemcontainer.Inventory; import com.l2jserver.gameserver.model.items.instance.L2ItemInstance; import com.l2jserver.gameserver.model.olympiad.OlympiadManager; import com.l2jserver.gameserver.model.quest.Quest; import com.l2jserver.gameserver.model.quest.QuestState; import com.l2jserver.gameserver.network.serverpackets.CharInfo; import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo; import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate; import com.l2jserver.gameserver.network.serverpackets.UserInfo; public class EnchantManager extends Quest { public static final Logger _log = Logger.getLogger(EnchantManager.class.getName()); private final static int npcId = 9994; // Item required to enchant armor +1 private final static int itemRequiredArmor = 9143; // Id for GA private final static int itemRequiredArmorCount = 50; // Item required to enchant jewels +1 private final static int itemRequiredJewels = 9143; private final static int itemRequiredJewelsCount = 50; // Item required to enchant weapon +1 private final static int itemRequiredWeapon = 9143; private final static int itemRequiredWeaponCount = 50; // Item required to enchant belt/shirt +1 private final static int itemRequiredBeltShirt = 9143; private final static int itemRequiredBeltShirtCount = 100; // Item required to add Lv 7 attribute to weapon private final static int itemRequiredAttr = 9143; private final static int itemRequiredAttrCount = 500; public EnchantManager(int questId, String name, String descr) { super(questId, name, descr); addStartNpc(npcId); addFirstTalkId(npcId); addTalkId(npcId); } public static void main(String[] args) { new EnchantManager(-1, "enchantmanager", "custom/mondial"); } @Override public String onFirstTalk(L2Npc npc, L2PcInstance player) { String enchantType = "html/Index.htm"; if (player.getQuestState(getName()) == null) { newQuestState(player); } else if (player.isInCombat()) { return drawHtml("You are in combat", "Don't fight if you want to talk with me!", enchantType); } else if (player.getPvpFlag() == 1) { return drawHtml("You are flagged", "Don't fight if you want to talk with me!", enchantType); } else if (player.getKarma() != 0) { return drawHtml("You are in chaotic state", "Don't fight if you want to talk with me!", enchantType); } else if (OlympiadManager.getInstance().isRegistered(player)) { return drawHtml("You are registered for Olympiad", "You can't use my services<br1>while playing the Olympiad.", enchantType); } else if (player.isInDuel()) { return drawHtml("Estas En duelo", "No puedes usar mis servicios.<br1>.", enchantType); } else if (player.isFestivalParticipant()) { return drawHtml("Estas Participando en Festival", "No puedes usar mis servicios.<br1>.", enchantType); } else if (player.isOnEvent()) { return drawHtml("Estas En Un Evento", "No puedes usar mis servicios.<br1>.", enchantType); } return enchantType; } @Override public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) { String htmlText = event; String enchantType = "Index.htm"; int armorType = -1; // If it contains space, then it's an attribute enchant. After space it's the element name. Eg: Fire if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributeWeapons")) { armorType = Inventory.PAPERDOLL_RHAND; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // Attribute Casco // if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributeCasco")) { armorType = Inventory.PAPERDOLL_HEAD; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // Termina aqui lo del casco// // Attribute Pechera // if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributePechera")) { armorType = Inventory.PAPERDOLL_CHEST; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // Termina aqui lo de la pechera// // Attribute Guantes// if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributeGuantes")) { armorType = Inventory.PAPERDOLL_GLOVES; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // Attribute Pantalones// if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributePantalones")) { armorType = Inventory.PAPERDOLL_LEGS; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // Termina Aqui lo de los pantalones// // Attribute Botas// if (event.contains(" ")) { final StringTokenizer st = new StringTokenizer(event); if (st.nextToken().equalsIgnoreCase("attributeBotas")) { armorType = Inventory.PAPERDOLL_FEET; enchantType = "Attributes.htm"; final String element = st.nextToken(); htmlText = enchant(element, enchantType, player, armorType, itemRequiredAttr, itemRequiredAttrCount); } } // termina las botas// // Armor parts else if (event.equals("enchantHelmet")) { armorType = Inventory.PAPERDOLL_HEAD; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } else if (event.equals("enchantChest")) { armorType = Inventory.PAPERDOLL_CHEST; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } else if (event.equals("enchantLeggings")) { armorType = Inventory.PAPERDOLL_LEGS; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } else if (event.equals("enchantGloves")) { armorType = Inventory.PAPERDOLL_GLOVES; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } else if (event.equals("enchantBoots")) { armorType = Inventory.PAPERDOLL_FEET; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } else if (event.equals("enchantShieldOrSigil")) { armorType = Inventory.PAPERDOLL_LHAND; enchantType = "EnchantArmor.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredArmor, itemRequiredArmorCount); } // Jewels else if (event.equals("enchantUpperEarring")) { armorType = Inventory.PAPERDOLL_LEAR; enchantType = "EnchantJewels.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredJewels, itemRequiredJewelsCount); } else if (event.equals("enchantLowerEarring")) { armorType = Inventory.PAPERDOLL_REAR; enchantType = "EnchantJewels.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredJewels, itemRequiredJewelsCount); } else if (event.equals("enchantNecklace")) { armorType = Inventory.PAPERDOLL_NECK; enchantType = "EnchantJewels.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredJewels, itemRequiredJewelsCount); } else if (event.equals("enchantUpperRing")) { armorType = Inventory.PAPERDOLL_LFINGER; enchantType = "EnchantJewels.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredJewels, itemRequiredJewelsCount); } else if (event.equals("enchantLowerRing")) { armorType = Inventory.PAPERDOLL_RFINGER; enchantType = "EnchantJewels.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredJewels, itemRequiredJewelsCount); } // Belt/Shirt else if (event.equals("enchantBelt")) { armorType = Inventory.PAPERDOLL_BELT; enchantType = "EnchantBeltShirt.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredBeltShirt, itemRequiredBeltShirtCount); } else if (event.equals("enchantShirt")) { armorType = Inventory.PAPERDOLL_UNDER; enchantType = "EnchantBeltShirt.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredBeltShirt, itemRequiredBeltShirtCount); } // Weapon else if (event.equals("enchantWeapon")) { armorType = Inventory.PAPERDOLL_RHAND; enchantType = "EnchantWeapon.htm"; htmlText = enchant("enchant", enchantType, player, armorType, itemRequiredWeapon, itemRequiredWeaponCount); } else { htmlText = "html/" + htmlText; } return htmlText; } private String enchant(String type, String enchantType, L2PcInstance player, int armorType, int itemRequired, int itemRequiredCount) { QuestState qs = player.getQuestState(getName()); // See if player has the required item and the correct amount of it if (qs.getQuestItemsCount(itemRequired) >= itemRequiredCount) { // Try to enchant try { // Get the item to enchant L2ItemInstance item = getItemToEnchant(player, armorType); // If valid item if (item != null) { // Check if item is valid if (item.isItem() && item.isEquipable() && !item.isConsumable() && !item.isCommonItem() && !item.isOlyRestrictedItem() && !item.isShadowItem() && !item.isQuestItem()) { // If we want to enchant if (type == "enchant") { final int currentEnchant = item.getEnchantLevel(); if (currentEnchant < 10) { int newEnchantLevel = setEnchant(player, item, currentEnchant + 1, armorType); if (newEnchantLevel > 0) { qs.takeItems(itemRequired, itemRequiredCount); player.sendMessage("You successfully enchanted your " + item.getItem().getName() + " from +" + currentEnchant + " to +" + newEnchantLevel + "!"); String htmlContent = "<center>You successfully enchanted your:<br>" + "<font color=\"FF7200\">" + item.getItem().getName() + "</font><br>" + "From: <font color=\"AEFF00\">+" + currentEnchant + "</font> to <font color=\"AEFF00\">+" + newEnchantLevel + "</font>" + "</center>"; return drawHtml("Congratulations!", htmlContent, enchantType); } } else { player.sendMessage("Your " + item.getItem().getName() + " is already +10!"); return drawHtml("It's already +10", "<center>Your <font color=\"FF7200\">" + item.getItem().getName() + "</font> is already +20!</center>", enchantType); } } // If we want to add attribute else { qs.takeItems(itemRequired, itemRequiredCount); setElement(player, item, type, armorType); player.sendMessage("You successfully added " + type + " element Lv 4 to your " + item.getItem().getName() + "!"); String htmlContent = "<center>You added <font color=\"AEFF00\">" + type + "</font> element Lv 4 to your:<br>" + "<font color=\"FF7200\">" + item.getItem().getName() + "</font>" + "</center>"; return drawHtml("Congratulations!", htmlContent, enchantType); } } // If item can not be enchanted else { player.sendMessage("Your " + item.getItem().getName() + " is not enchantable!"); return drawHtml("Not enchantable item!", "<center>Your <font color=\"FF7200\">" + item.getItem().getName() + "</font> is not enchantable!</center>", enchantType); } } } catch (StringIndexOutOfBoundsException e) { player.sendMessage("Something went wrong. Are equiped with the item?"); return drawHtml("Error Enchant", "<center>Something went wrong.<br>Are equiped with the item?</center>", enchantType); } catch (NumberFormatException e) { player.sendMessage("Something went wrong. Are equiped with the item?"); return drawHtml("Error Enchant", "<center>Something went wrong.<br>Are equiped with the item?</center>", enchantType); } player.sendMessage("Something went wrong. Are equiped with the item?"); return drawHtml("Error Enchant", "<center>Something went wrong.<br>Are equiped with the item?</center>", enchantType); } // If player doesn't have correct amount of required item, tell him what he needs String content = "<center>" + "Not enough <font color=\"FF7200\">Golden Apiga..</font>!<br>"; if (qs.getQuestItemsCount(itemRequired) > 0) { content += "You have " + qs.getQuestItemsCount(itemRequired) + " Golden Apiga,<br1>" + "Need " + (itemRequiredCount - qs.getQuestItemsCount(itemRequired)) + " more."; } else { content += "You need <font color=\"FF7200\">" + itemRequiredCount + " olden Apiga</font>!"; } content += "</center>"; return drawHtml("Not Enough Items", content, enchantType); } private L2ItemInstance getItemToEnchant(L2PcInstance player, int armorType) { L2ItemInstance itemInstance = null; L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType); if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType)) { itemInstance = parmorInstance; if (itemInstance != null) { return itemInstance; } } return null; } private int setEnchant(L2PcInstance player, L2ItemInstance item, int newEnchantLevel, int armorType) { if (item != null) { // set enchant value player.getInventory().unEquipItemInSlot(armorType); item.setEnchantLevel(newEnchantLevel); player.getInventory().equipItem(item); // send packets InventoryUpdate iu = new InventoryUpdate(); iu.addModifiedItem(item); player.sendPacket(iu); player.broadcastPacket(new CharInfo(player)); player.sendPacket(new UserInfo(player)); player.broadcastPacket(new ExBrExtraUserInfo(player)); return newEnchantLevel; } return -1; } private void setElement(L2PcInstance player, L2ItemInstance item, String type, int armorType) { if (item != null) { // set enchant value player.getInventory().unEquipItemInSlot(armorType); // New attr byte attr = Elementals.getElementId(type); byte attr1 = Elementals.getElementId(type); byte attr2 = Elementals.getElementId(type); byte clearAttr = -1; item.clearElementAttr(clearAttr); item.setElementAttr(attr, 60); item.setElementAttr(attr1, 60); item.setElementAttr(attr2, 60); player.getInventory().equipItem(item); // send packets InventoryUpdate iu = new InventoryUpdate(); iu.addModifiedItem(item); player.sendPacket(iu); } } public String drawHtml(String title, String content, String enchantType) { String html = "<html>" + "<title>L2Xos~Ros</title>" + "<body>" + "<center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>" + "<font color=\"FF9900\">" + title + "</font></center><br>" + content + "<br><br>" + "<center><a action=\"bypass -h Quest enchantmanager " + enchantType + "\">Go Back</a></center>" + "</body>" + "</html>"; return html; } }
  2. He spoke to who can help me!
  3. Well, I wanted to put it all in one but gives me 3 elements :/
  4. Warning in # if (itemInstance != null)
×
×
  • Create New...