-Added all existing enchantment scrolls & lucky stones.
-Full done all scrolls and stones (standard,bless,giant's,safe, -1, etc..) -Added parameters minEnchant, maxEnchantFighter, maxEnchantMagic (minEnchant for Improved stones (+10..+15 only), others for Heavenly Scrolls -Implemented Hair accessory enchant (ONLY IN CORE - ITEMS FOR ENCHANTING NOT DONE, EXCEPT 34717. Also, visual bug when enchanting - "+pdef", but really not gained (same as official servers.) -Added enchant options for hair accessories (increase M. Def. ) -Increased P.Def/M.Def gain when enchanting R grade armor from +1/+3 to +2/+4 (as official). Contributed by NviX.
This commit is contained in:
@@ -46,11 +46,29 @@ public abstract class AbstractEnchantItem
|
||||
EtcItemType.SCRL_ENCHANT_WP,
|
||||
EtcItemType.SCRL_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.SCRL_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.BLESS_SCRL_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.BLESS_SCRL_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.GIANT_SCRL_ENCHANT_AM,
|
||||
EtcItemType.GIANT_SCRL_ENCHANT_WP,
|
||||
EtcItemType.GIANT_SCRL_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.GIANT_SCRL_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
EtcItemType.SCRL_ENCHANT_HR
|
||||
};
|
||||
|
||||
private final int _id;
|
||||
private final CrystalType _grade;
|
||||
private final int _minEnchantLevel;
|
||||
private final int _maxEnchantLevel;
|
||||
private final int _maxEnchantLevelFighter;
|
||||
private final int _maxEnchantLevelMagic;
|
||||
private final double _bonusRate;
|
||||
|
||||
public AbstractEnchantItem(StatsSet set)
|
||||
@@ -65,7 +83,10 @@ public abstract class AbstractEnchantItem
|
||||
throw new IllegalAccessError();
|
||||
}
|
||||
_grade = set.getEnum("targetGrade", CrystalType.class, CrystalType.NONE);
|
||||
_minEnchantLevel = set.getInt("minEnchant", 0);
|
||||
_maxEnchantLevel = set.getInt("maxEnchant", 65535);
|
||||
_maxEnchantLevelFighter = set.getInt("maxEnchantFighter", 65535);
|
||||
_maxEnchantLevelMagic = set.getInt("maxEnchantMagic", 65535);
|
||||
_bonusRate = set.getDouble("bonusRate", 0);
|
||||
}
|
||||
|
||||
@@ -106,6 +127,14 @@ public abstract class AbstractEnchantItem
|
||||
*/
|
||||
public abstract boolean isWeapon();
|
||||
|
||||
/**
|
||||
* @return the minimum enchant level that this scroll/item can be used with
|
||||
*/
|
||||
public int getMinEnchantLevel()
|
||||
{
|
||||
return _minEnchantLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum enchant level that this scroll/item can be used with
|
||||
*/
|
||||
@@ -114,6 +143,22 @@ public abstract class AbstractEnchantItem
|
||||
return _maxEnchantLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum enchant level that fighter weapon can be enchanted with this scroll
|
||||
*/
|
||||
public int getMaxEnchantLevelFighter()
|
||||
{
|
||||
return _maxEnchantLevelFighter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum enchant level that magic weapon can be enchanted with this scroll
|
||||
*/
|
||||
public int getMaxEnchantLevelMagic()
|
||||
{
|
||||
return _maxEnchantLevelMagic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemToEnchant the item to be enchanted
|
||||
* @param supportItem
|
||||
@@ -133,10 +178,22 @@ public abstract class AbstractEnchantItem
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_minEnchantLevel != 0) && (itemToEnchant.getEnchantLevel() < _minEnchantLevel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_maxEnchantLevel != 0) && (itemToEnchant.getEnchantLevel() >= _maxEnchantLevel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_maxEnchantLevelFighter != 0) && !itemToEnchant.getItem().isMagicWeapon() && (itemToEnchant.getEnchantLevel() >= _maxEnchantLevelFighter))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ((_maxEnchantLevelMagic != 0) && itemToEnchant.getItem().isMagicWeapon() && (itemToEnchant.getEnchantLevel() >= _maxEnchantLevelMagic))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (_grade != itemToEnchant.getItem().getCrystalTypePlus())
|
||||
{
|
||||
return false;
|
||||
|
@@ -25,6 +25,7 @@ import java.util.logging.Level;
|
||||
import com.l2jserver.gameserver.data.xml.impl.EnchantItemGroupsData;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.items.type.ItemType;
|
||||
@@ -40,6 +41,8 @@ public final class EnchantScroll extends AbstractEnchantItem
|
||||
private final boolean _isWeapon;
|
||||
private final boolean _isBlessed;
|
||||
private final boolean _isSafe;
|
||||
private final boolean _isGiant;
|
||||
private final boolean _isHair;
|
||||
private final int _scrollGroupId;
|
||||
private Set<Integer> _items;
|
||||
|
||||
@@ -49,9 +52,11 @@ public final class EnchantScroll extends AbstractEnchantItem
|
||||
_scrollGroupId = set.getInt("scrollGroupId", 0);
|
||||
|
||||
final ItemType type = getItem().getItemType();
|
||||
_isWeapon = (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP) || (type == EtcItemType.BLESS_SCRL_ENCHANT_WP) || (type == EtcItemType.SCRL_ENCHANT_WP);
|
||||
_isWeapon = (type == EtcItemType.GIANT_SCRL_ENCHANT_WP) || (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP) || (type == EtcItemType.BLESS_SCRL_ENCHANT_WP) || (type == EtcItemType.SCRL_ENCHANT_WP);
|
||||
_isBlessed = (type == EtcItemType.BLESS_SCRL_ENCHANT_AM) || (type == EtcItemType.BLESS_SCRL_ENCHANT_WP);
|
||||
_isSafe = (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_AM) || (type == EtcItemType.ANCIENT_CRYSTAL_ENCHANT_WP);
|
||||
_isGiant = (type == EtcItemType.GIANT_SCRL_ENCHANT_AM) || (type == EtcItemType.GIANT_SCRL_ENCHANT_WP);
|
||||
_isHair = (type == EtcItemType.SCRL_ENCHANT_HR);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +81,22 @@ public final class EnchantScroll extends AbstractEnchantItem
|
||||
return _isSafe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} for giant scrolls (enchant attempts has a chance of increasing the enchant value between +1 and +3 randomly), {@code false} otherwise
|
||||
*/
|
||||
public boolean isGiant()
|
||||
{
|
||||
return _isGiant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} for hair enchant scrolls, {@code false} otherwise
|
||||
*/
|
||||
public boolean isHair()
|
||||
{
|
||||
return _isHair;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return id of scroll group that should be used
|
||||
*/
|
||||
@@ -109,9 +130,22 @@ public final class EnchantScroll extends AbstractEnchantItem
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (isHair() && (itemToEnchant.getItem().getBodyPart() != L2Item.SLOT_HAIR) && (itemToEnchant.getItem().getBodyPart() != L2Item.SLOT_HAIR2) && (itemToEnchant.getItem().getBodyPart() != L2Item.SLOT_HAIRALL))
|
||||
{
|
||||
_log.info("bodypart: " + itemToEnchant.getItem().getBodyPart());
|
||||
return false;
|
||||
}
|
||||
else if ((supportItem != null))
|
||||
{
|
||||
if (isBlessed())
|
||||
if (isBlessed() && (supportItem.getItem().getItemType() != EtcItemType.BLESS_SCRL_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.BLESS_SCRL_INC_ENCHANT_PROP_AM) && (supportItem.getItem().getItemType() != EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_AM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (isGiant() && (supportItem.getItem().getItemType() != EtcItemType.GIANT_SCRL_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.GIANT_SCRL_INC_ENCHANT_PROP_AM) && (supportItem.getItem().getItemType() != EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_AM) && (supportItem.getItem().getItemType() != EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_AM) && (supportItem.getItem().getItemType() != EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!isBlessed() && !isGiant() && (supportItem.getItem().getItemType() != EtcItemType.SCRL_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.SCRL_INC_ENCHANT_PROP_AM) && (supportItem.getItem().getItemType() != EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_WP) && (supportItem.getItem().getItemType() != EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_AM))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -187,6 +221,14 @@ public final class EnchantScroll extends AbstractEnchantItem
|
||||
{
|
||||
set.set("isSafe", isSafe());
|
||||
}
|
||||
if (isGiant())
|
||||
{
|
||||
set.set("isGiant", isGiant());
|
||||
}
|
||||
if (isHair())
|
||||
{
|
||||
set.set("isHair", isHair());
|
||||
}
|
||||
set.set("chance", Util.formatDouble(chance, "#.##"));
|
||||
if (bonusRate > 0)
|
||||
{
|
||||
|
@@ -31,7 +31,14 @@ public final class EnchantSupportItem extends AbstractEnchantItem
|
||||
public EnchantSupportItem(StatsSet set)
|
||||
{
|
||||
super(set);
|
||||
_isWeapon = getItem().getItemType() == EtcItemType.SCRL_INC_ENCHANT_PROP_WP;
|
||||
if ((getItem().getItemType() == EtcItemType.SCRL_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.BLESS_SCRL_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.GIANT_SCRL_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_WP) || (getItem().getItemType() == EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP))
|
||||
{
|
||||
_isWeapon = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isWeapon = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -55,6 +55,21 @@ public enum EtcItemType implements ItemType
|
||||
ANCIENT_CRYSTAL_ENCHANT_AM,
|
||||
RUNE_SELECT,
|
||||
RUNE,
|
||||
GIANT_SCRL_ENCHANT_WP,
|
||||
GIANT_SCRL_ENCHANT_AM,
|
||||
BLESS_SCRL_INC_ENCHANT_PROP_WP,
|
||||
BLESS_SCRL_INC_ENCHANT_PROP_AM,
|
||||
GIANT_SCRL_INC_ENCHANT_PROP_WP,
|
||||
GIANT_SCRL_INC_ENCHANT_PROP_AM,
|
||||
GIANT_SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
GIANT_SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
BLESS_DROP_SCRL_INC_ENCHANT_PROP_WP,
|
||||
BLESS_DROP_SCRL_INC_ENCHANT_PROP_AM,
|
||||
GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP,
|
||||
GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_AM,
|
||||
SCRL_ENCHANT_HR,
|
||||
|
||||
// L2J CUSTOM, BACKWARD COMPATIBILITY
|
||||
SHOT;
|
||||
|
@@ -75,7 +75,21 @@ public class FuncEnchant extends AbstractFunction
|
||||
|
||||
if ((getStat() == Stats.MAGIC_DEFENCE) || (getStat() == Stats.POWER_DEFENCE))
|
||||
{
|
||||
return value + enchant + (3 * overenchant);
|
||||
switch (item.getItem().getCrystalTypePlus())
|
||||
{
|
||||
case R:
|
||||
value += (2 * enchant) + (4 * overenchant);
|
||||
break;
|
||||
case S:
|
||||
case A:
|
||||
case B:
|
||||
case C:
|
||||
case D:
|
||||
case NONE:
|
||||
value += enchant + (3 * overenchant);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
if (getStat() == Stats.MAGIC_ATTACK)
|
||||
|
@@ -33,6 +33,7 @@ import com.l2jserver.gameserver.model.items.enchant.EnchantResultType;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantScroll;
|
||||
import com.l2jserver.gameserver.model.items.enchant.EnchantSupportItem;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jserver.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
@@ -44,6 +45,7 @@ import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
public final class RequestEnchantItem extends L2GameClientPacket
|
||||
{
|
||||
@@ -190,7 +192,18 @@ public final class RequestEnchantItem extends L2GameClientPacket
|
||||
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
|
||||
if (scrollTemplate.getChance(activeChar, item) > 0)
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() + 1);
|
||||
if (scrollTemplate.isGiant() && ((supportTemplate == null) || (supportTemplate.getItem().getItemType() != EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_AM) || (supportTemplate.getItem().getItemType() != EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP)))
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() + Rnd.get(1, 3));
|
||||
}
|
||||
else if (scrollTemplate.isGiant() && (supportTemplate != null) && ((supportTemplate.getItem().getItemType() == EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_AM) || (supportTemplate.getItem().getItemType() == EtcItemType.GIANT2_SCRL_BLESS_INC_ENCHANT_PROP_WP)))
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() + Rnd.get(2, 4));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() + 1);
|
||||
}
|
||||
item.updateDatabase();
|
||||
}
|
||||
activeChar.sendPacket(new EnchantResult(EnchantResult.SUCCESS, item));
|
||||
@@ -227,7 +240,7 @@ public final class RequestEnchantItem extends L2GameClientPacket
|
||||
}
|
||||
}
|
||||
|
||||
if ((item.isArmor()) && (item.getEnchantLevel() == 4) && item.isEquipped())
|
||||
if ((item.isArmor()) && (item.getEnchantLevel() >= 4) && item.isEquipped())
|
||||
{
|
||||
enchant4Skill = it.getEnchant4Skill();
|
||||
if (enchant4Skill != null)
|
||||
@@ -290,7 +303,30 @@ public final class RequestEnchantItem extends L2GameClientPacket
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
|
||||
if (scrollTemplate.isBlessed())
|
||||
if (scrollTemplate.isBlessed() && (supportTemplate != null) && ((supportTemplate.getItem().getItemType() == EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_AM) || (supportTemplate.getItem().getItemType() == EtcItemType.BLESS_DROP_SCRL_INC_ENCHANT_PROP_WP)))
|
||||
{
|
||||
// blessed enchant + using special stone - drop enchant value by 1
|
||||
activeChar.sendPacket(SystemMessageId.FAILURE_WILL_DEDUCT_YOUR_ENCHANT_VALUE_BY_1);
|
||||
|
||||
item.setEnchantLevel(item.getEnchantLevel() - 1);
|
||||
item.updateDatabase();
|
||||
activeChar.sendPacket(new EnchantResult(EnchantResult.BLESSED_FAIL, 0, 0));
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
LogRecord record = new LogRecord(Level.INFO, "Blessed Fail");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
activeChar,
|
||||
item,
|
||||
scroll,
|
||||
support,
|
||||
});
|
||||
record.setLoggerName("item");
|
||||
_logEnchant.log(record);
|
||||
}
|
||||
}
|
||||
else if (scrollTemplate.isBlessed() || ((supportTemplate != null) && ((supportTemplate.getItem().getItemType() == EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_AM) || (supportTemplate.getItem().getItemType() == EtcItemType.GIANT_SCRL_BLESS_INC_ENCHANT_PROP_WP) || (supportTemplate.getItem().getItemType() == EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_AM) || (supportTemplate.getItem().getItemType() == EtcItemType.SCRL_BLESS_INC_ENCHANT_PROP_WP))))
|
||||
{
|
||||
// blessed enchant - clear enchant value
|
||||
activeChar.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
|
Reference in New Issue
Block a user