enchant weapon formulas

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
streamsss
Posts: 186
Joined: Wed Jun 24, 2009 10:01 am

enchant weapon formulas

Post by streamsss »

Code: Select all

# Более гибкая формула для тех кто держит PvP или просто нехочет чтобы у него люди бегали переточёные# Представляет из себя прогрессию где шанс на каждой +1 уменьшаеться# поумолчанию с +3  до +4 65%...50% 40% 30 20 10 5 1 1 1;для тех кто непонял: 80-15=65;# шансы могут принимать значения от 16(1%) и до 160(100% на +10)# уровень safeEnchant также влияет на форумулу с него начинаеться отсчёт % на уменьшение# для тех кто непонял  при safeenchant = 5 - +5 - +6 65%AltEnchantFormulaForPvPServers = FalseEChanceWeapon = 80EChanceMageWeapon = 80EChanceArmor = 80PenaltyforEChanceToHandBlunt = 18 
можно-ли реализовать у нас такую же систему?
User avatar
momo61
Posts: 1648
Joined: Fri Jun 06, 2008 2:05 pm
Location: Europe

Re: enchant weapon formulas

Post by momo61 »

I dont know what this is, but if its something about more weapon/armor enchant options, then I would agree that L2J needs that.
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: enchant weapon formulas

Post by _DS_ »

Custom, will not be done :)
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
nBd
L2j Inner Circle
L2j Inner Circle
Posts: 350
Joined: Wed Jun 07, 2006 2:26 pm

Re: enchant weapon formulas

Post by nBd »

Translation?
<ZaKaX> Ohh nBd, you're so professianal with your analconda.
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: enchant weapon formulas

Post by _DS_ »

Ariphmetic progression of the enchant chance. For me table of the fixed level/chance is better, but anyway custom :)
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
streamsss
Posts: 186
Joined: Wed Jun 24, 2009 10:01 am

Re: enchant weapon formulas

Post by streamsss »

requestenchantitem.java

Code: Select all

package l2p.gameserver.clientpackets; import java.io.PrintStream;import java.util.logging.Logger;import l2p.Config;import l2p.extensions.multilang.CustomMessage;import l2p.gameserver.cache.Msg;import l2p.gameserver.model.L2Player;import l2p.gameserver.model.PcInventory;import l2p.gameserver.model.instances.L2ItemInstance;import l2p.gameserver.model.instances.L2ItemInstance.ItemLocation;import l2p.gameserver.network.L2GameClient;import l2p.gameserver.serverpackets.EnchantResult;import l2p.gameserver.serverpackets.InventoryUpdate;import l2p.gameserver.tables.ItemTable;import l2p.gameserver.templates.L2Item;import l2p.gameserver.templates.L2Item.Grade;import l2p.gameserver.templates.L2Weapon;import l2p.gameserver.templates.L2Weapon.WeaponType;import l2p.util.Log;import l2p.util.Rnd; public class RequestEnchantItem extends L2GameClientPacket{  protected static Logger _log = Logger.getLogger(RequestEnchantItem.class.getName());  private int _objectId;  private int _unk;   public void readImpl()  {    this._objectId = readD();    if (((L2GameClient)getClient()).isGraciaFinal())    {      this._unk = readD();      System.out.println(getType() + " :: _unk = " + this._unk);    }  }   public void runImpl()  {    label256: L2ItemInstance removedScroll;    double chance;    L2Player activeChar = ((L2GameClient)getClient()).getActiveChar();    if (activeChar == null)      return;     if ((activeChar.isOutOfControl()) || (activeChar.isActionsDisabled()))    {      activeChar.sendActionFailed();      return;    }     PcInventory inventory = activeChar.getInventory();    L2ItemInstance itemToEnchant = inventory.getItemByObjectId(Integer.valueOf(this._objectId));    L2ItemInstance scroll = activeChar.getEnchantScroll();    activeChar.setEnchantScroll(null);     if ((itemToEnchant == null) || (scroll == null))    {      activeChar.sendActionFailed();      return;    }     Log.add(activeChar.getName() + "|Trying to enchant|" + itemToEnchant.getItemId() + "|+" + itemToEnchant.getEnchantLevel() + "|" + itemToEnchant.getObjectId(), "enchants");     if (!(itemToEnchant.canBeEnchanted()))    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS);      activeChar.sendActionFailed();      return;    }     if ((itemToEnchant.getLocation() != L2ItemInstance.ItemLocation.INVENTORY) && (itemToEnchant.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL))    {      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS);      activeChar.sendActionFailed();      return;    }     if (activeChar.getPrivateStoreType() != 0)    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendPacket(Msg.YOU_CANNOT_PRACTICE_ENCHANTING_WHILE_OPERATING_A_PRIVATE_STORE_OR_PRIVATE_MANUFACTURING_WORKSHOP);      activeChar.sendActionFailed();      return;    }     if (!(itemToEnchant.isStackable())) if ((scroll = inventory.getItemByObjectId(Integer.valueOf(scroll.getObjectId()))) != null)        break label256;    activeChar.sendPacket(EnchantResult.CANCEL);    activeChar.sendActionFailed();    return;     int crystalId = itemToEnchant.getEnchantCrystalId(scroll);     if (crystalId == 0)    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS);      activeChar.sendActionFailed();      return;    }     if (itemToEnchant.getEnchantLevel() >= Config.ENCHANT_MAX)    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendMessage(new CustomMessage("l2p.gameserver.clientpackets.RequestEnchantItem.MaxLevel", activeChar));      activeChar.sendActionFailed();      return;    }     if (itemToEnchant.getOwnerId() != activeChar.getObjectId())    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS);      activeChar.sendActionFailed();      return;    }     synchronized (inventory)    {      removedScroll = inventory.destroyItem(scroll.getObjectId(), 1L, true);    }     if (removedScroll == null)    {      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendActionFailed();      return;    }     int itemType = itemToEnchant.getItem().getType2();    int safeEnchantLevel = (itemToEnchant.getItem().getBodyPart() == 32768) ? Config.SAFE_ENCHANT_FULL_BODY : Config.SAFE_ENCHANT_COMMON;     if (itemToEnchant.getEnchantLevel() < safeEnchantLevel) {      chance = 100.0D;    } else if (itemType == 0) {      chance = Config.ENCHANT_CHANCE_WEAPON;    } else if (itemType == 1) {      chance = Config.ENCHANT_CHANCE_ARMOR;    } else if (itemType == 2) {      chance = Config.ENCHANT_CHANCE_ACCESSORY;    }    else {      System.out.println("WTF? Request to enchant " + itemToEnchant.getItemId());      activeChar.sendPacket(EnchantResult.CANCEL);      activeChar.sendActionFailed();      activeChar.sendPacket(Msg.SYSTEM_ERROR);      activeChar.getInventory().addItem(removedScroll);      return;    }     if ((scroll.getItemId() >= 22006) && (scroll.getItemId() <= 22017))      chance += 10.0D;    else if ((scroll.getItemId() >= 22018) && (scroll.getItemId() <= 22021))      chance = 100.0D;     if (Config.ALT_ENCHANT_FORMULA)    {      int enchlvl = itemToEnchant.getEnchantLevel();      L2Item.Grade crystaltype = itemToEnchant.getItem().getCrystalType();       if ((itemType == 0) && (itemToEnchant.getItemType() == L2Weapon.WeaponType.DUAL))        ++safeEnchantLevel;       if (enchlvl < safeEnchantLevel) {        chance = 100.0D;      } else if (enchlvl > 11) {        chance = 1.0D;      }      else      {        if (itemType == 0)        {          L2Weapon wepToEnchant = (L2Weapon)itemToEnchant.getItem();          boolean magewep = (itemType == 0) && (crystaltype.cry >= 1459) && (wepToEnchant.getPDamage() - wepToEnchant.getMDamage() <= wepToEnchant.getPDamage() * 0.4D);          chance = Config.ALT_ENCHANT_CHANCE_MAGE_W;           if ((itemToEnchant.getItem().getBodyPart() == 16384) && (itemToEnchant.getItem().getItemType() == L2Weapon.WeaponType.BLUNT) && (!(magewep)))            chance -= Config.PENALTY_TO_TWOHANDED_BLUNTS;        }        else {          chance = Config.ALT_ENCHANT_CHANCE_ARMOR;        }        int DeltaChance = 15;         for (int i = safeEnchantLevel; i < enchlvl; ++i)        {          if (i == safeEnchantLevel + 2)            DeltaChance -= 5;          if (i == safeEnchantLevel + 6)            DeltaChance -= 5;          chance -= DeltaChance;        }         int Delta2 = 5;        for (int in = 0; in < crystaltype.ordinal(); ++in)        {          if (in == 1459)            Delta2 -= 5;          if (in == 1460)            Delta2 -= 5;          if (in == 1461)            Delta2 -= 2;          if (in == 1462)            --Delta2;        }        chance += Delta2;         if (scroll.isBlessedEnchantScroll())          chance += 2.0D;        if (chance < 1.0D)          chance = 1.0D;      }     }     if (Rnd.chance(chance))    {      itemToEnchant.setEnchantLevel(itemToEnchant.getEnchantLevel() + 1);      itemToEnchant.updateDatabase();       activeChar.sendPacket(new InventoryUpdate().addModifiedItem(itemToEnchant));       Log.add(activeChar.getName() + "|Successfully enchanted|" + itemToEnchant.getItemId() + "|to+" + itemToEnchant.getEnchantLevel() + "|" + chance, "enchants");      Log.LogItem(activeChar, Integer.valueOf(925), itemToEnchant);      activeChar.sendPacket(EnchantResult.SUCESS);    }    else    {      Log.add(activeChar.getName() + "|Failed to enchant|" + itemToEnchant.getItemId() + "|+" + itemToEnchant.getEnchantLevel() + "|" + chance, "enchants");       if (scroll.isBlessedEnchantScroll())      {        itemToEnchant.setEnchantLevel(0);        activeChar.sendPacket(new InventoryUpdate().addModifiedItem(itemToEnchant));        activeChar.sendPacket(Msg.FAILED_IN_BLESSED_ENCHANT_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);        activeChar.sendPacket(EnchantResult.CANCEL);      }      else      {        if (itemToEnchant.isEquipped()) {          activeChar.getInventory().unEquipItemInSlot(itemToEnchant.getEquipSlot());        }         L2ItemInstance destroyedItem = inventory.destroyItem(itemToEnchant.getObjectId(), 1L, true);        if (destroyedItem == null)        {          _log.warning("failed to destroy " + itemToEnchant.getObjectId() + " after unsuccessful enchant attempt by char " + activeChar.getName());          activeChar.sendActionFailed();          return;        }         L2ItemInstance crystalsToAdd = ItemTable.getInstance().createItem(crystalId);         int count = (int)(itemToEnchant.getItem().getCrystalCount() * 0.87D);        if (destroyedItem.getEnchantLevel() > 3)          count = (int)(count + itemToEnchant.getItem().getCrystalCount() * 0.25D * (destroyedItem.getEnchantLevel() - 3));        if (count < 1)          count = 1;        crystalsToAdd.setCount(count);         activeChar.getInventory().addItem(crystalsToAdd);         Log.LogItem(activeChar, Integer.valueOf(926), itemToEnchant);        Log.LogItem(activeChar, Integer.valueOf(959), crystalsToAdd);         activeChar.sendPacket(new EnchantResult(1, crystalsToAdd.getItemId(), count));         activeChar.refreshExpertisePenalty();        activeChar.refreshOverloaded();      }    }     activeChar.setEnchantScroll(null);    activeChar.sendChanges();  }} 

config.java

Code: Select all

      ALT_ENCHANT_FORMULA = getBooleanProperty(otherSettings, "AltEnchantFormulaForPvPServers", false);        ALT_ENCHANT_CHANCE_W = getIntProperty(otherSettings, "EChanceWeapon", 80);        ALT_ENCHANT_CHANCE_MAGE_W = getIntProperty(otherSettings, "EChanceMageWeapon", 80);        ALT_ENCHANT_CHANCE_ARMOR = getIntProperty(otherSettings, "EChanceArmor", 80);        PENALTY_TO_TWOHANDED_BLUNTS = getIntProperty(otherSettings, "PenaltyforEChanceToHandBlunt", 18);         ENCHANT_CHANCE_WEAPON = getIntProperty(otherSettings, "EnchantChance", 66);        ENCHANT_CHANCE_ARMOR = getIntProperty(otherSettings, "EnchantChanceArmor", ENCHANT_CHANCE_WEAPON);        ENCHANT_CHANCE_ACCESSORY = getIntProperty(otherSettings, "EnchantChanceAccessory", ENCHANT_CHANCE_ARMOR);        ENCHANT_CHANCE_CRYSTAL_WEAPON = getIntProperty(otherSettings, "EnchantChanceCrystal", 66);        ENCHANT_CHANCE_CRYSTAL_ARMOR = getIntProperty(otherSettings, "EnchantChanceCrystalArmor", ENCHANT_CHANCE_CRYSTAL_WEAPON);        ENCHANT_CHANCE_CRYSTAL_ACCESSORY = getIntProperty(otherSettings, "EnchantChanceCrystalAccessory", ENCHANT_CHANCE_CRYSTAL_ARMOR);        SAFE_ENCHANT_COMMON = getIntProperty(otherSettings, "SafeEnchantCommon", 3);        SAFE_ENCHANT_FULL_BODY = getIntProperty(otherSettings, "SafeEnchantFullBody", 4);        ENCHANT_MAX = getByteProperty(otherSettings, "EnchantMax", 20);  
can you help me do this for l2jserver?)
streamsss
Posts: 186
Joined: Wed Jun 24, 2009 10:01 am

Re: enchant weapon formulas

Post by streamsss »

mm..who make
# Default: 33,33,33
EnchantChanceWeapon = 33
EnchantChanceArmor = 33
EnchantChanceJewelry = 33

who can make other value..
EnchantChanceMageWeapon ?
because users can enchant Arcana mace +10..+11
but chance mageweapon< chance warrior weapon
streamsss
Posts: 186
Joined: Wed Jun 24, 2009 10:01 am

Re: enchant weapon formulas

Post by streamsss »

DS what you say about this?)
_DS_
L2j Veteran
L2j Veteran
Posts: 3437
Joined: Wed Apr 30, 2008 8:53 am
Location: Russia

Re: enchant weapon formulas

Post by _DS_ »

3 message from the start of the topic. Maybe later.
Commiter of the shit
public static final int PI = 3.1415926535897932384626433832795;
Post Reply