Fixed item enchanting.

This commit is contained in:
MobiusDevelopment 2023-03-25 14:24:17 +02:00
parent eb883e13bb
commit d769d4e79b
10 changed files with 67 additions and 267 deletions

View File

@ -29,7 +29,6 @@ import org.w3c.dom.Node;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
import org.l2jmobius.gameserver.model.item.enchant.EnchantSupportItem;
import org.l2jmobius.gameserver.model.item.instance.Item;
/**
@ -39,7 +38,6 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
public class EnchantItemData implements IXmlReader
{
private final Map<Integer, EnchantScroll> _scrolls = new HashMap<>();
private final Map<Integer, EnchantSupportItem> _supports = new HashMap<>();
/**
* Instantiates a new enchant item data.
@ -53,10 +51,8 @@ public class EnchantItemData implements IXmlReader
public synchronized void load()
{
_scrolls.clear();
_supports.clear();
parseDatapackFile("data/EnchantItemData.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _scrolls.size() + " enchant scrolls.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _supports.size() + " support items.");
}
@Override
@ -102,30 +98,6 @@ public class EnchantItemData implements IXmlReader
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Wrong enchant scroll item type: " + set.getString("id") + " defined in enchant data!");
}
}
else if ("support".equalsIgnoreCase(d.getNodeName()))
{
attrs = d.getAttributes();
set = new StatSet();
for (int i = 0; i < attrs.getLength(); i++)
{
att = attrs.item(i);
set.set(att.getNodeName(), att.getNodeValue());
}
try
{
final EnchantSupportItem item = new EnchantSupportItem(set);
_supports.put(item.getId(), item);
}
catch (NullPointerException e)
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Unexistent enchant support item: " + set.getString("id") + " defined in enchant data!");
}
catch (IllegalAccessError e)
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Wrong enchant support item type: " + set.getString("id") + " defined in enchant data!");
}
}
}
}
}
@ -150,20 +122,6 @@ public class EnchantItemData implements IXmlReader
return _scrolls.get(item.getId());
}
/**
* Gets the support item.
* @param item the support item
* @return enchant template for support item
*/
public EnchantSupportItem getSupportItem(Item item)
{
if (item == null)
{
return null;
}
return _supports.get(item.getId());
}
/**
* Gets the single instance of EnchantItemData.
* @return single instance of EnchantItemData

View File

@ -664,8 +664,6 @@ public class Player extends Playable
private boolean _isEnchanting = false;
private int _activeEnchantItemId = ID_NONE;
private int _activeEnchantSupportItemId = ID_NONE;
private int _activeEnchantAttrItemId = ID_NONE;
private long _activeEnchantTimestamp = 0;
protected boolean _inventoryDisable = false;
@ -2345,22 +2343,11 @@ public class Player extends Playable
return getStat().getExp();
}
public void setActiveEnchantAttrItemId(int objectId)
{
_activeEnchantAttrItemId = objectId;
}
public int getActiveEnchantAttrItemId()
{
return _activeEnchantAttrItemId;
}
public void setActiveEnchantItemId(int objectId)
{
// If we don't have a Enchant Item, we are not enchanting.
if (objectId == ID_NONE)
{
setActiveEnchantSupportItemId(ID_NONE);
setActiveEnchantTimestamp(0);
setEnchanting(false);
}
@ -2372,16 +2359,6 @@ public class Player extends Playable
return _activeEnchantItemId;
}
public void setActiveEnchantSupportItemId(int objectId)
{
_activeEnchantSupportItemId = objectId;
}
public int getActiveEnchantSupportItemId()
{
return _activeEnchantSupportItemId;
}
public long getActiveEnchantTimestamp()
{
return _activeEnchantTimestamp;
@ -7855,7 +7832,7 @@ public class Player extends Playable
return false;
}
if ((_activeEnchantItemId != ID_NONE) || (_activeEnchantAttrItemId != ID_NONE))
if (_activeEnchantItemId != ID_NONE)
{
return false;
}

View File

@ -115,10 +115,9 @@ public abstract class AbstractEnchantItem
/**
* @param itemToEnchant the item to be enchanted
* @param supportItem
* @return {@code true} if this support item can be used with the item to be enchanted, {@code false} otherwise
*/
public boolean isValid(Item itemToEnchant, EnchantSupportItem supportItem)
public boolean isValid(Item itemToEnchant)
{
if (itemToEnchant == null)
{

View File

@ -90,31 +90,16 @@ public class EnchantScroll extends AbstractEnchantItem
/**
* @param itemToEnchant the item to be enchanted
* @param supportItem the support item used when enchanting (can be null)
* @return {@code true} if this scroll can be used with the specified support item and the item to be enchanted, {@code false} otherwise
*/
@Override
public boolean isValid(Item itemToEnchant, EnchantSupportItem supportItem)
public boolean isValid(Item itemToEnchant)
{
if (!_items.isEmpty() && !_items.containsKey(itemToEnchant.getId()))
{
return false;
}
else if ((supportItem != null))
{
if (_isBlessed)
{
return false;
}
else if (!supportItem.isValid(itemToEnchant, supportItem))
{
return false;
}
else if (supportItem.isWeapon() != isWeapon())
{
return false;
}
}
if (_items.isEmpty())
{
for (EnchantScroll scroll : EnchantItemData.getInstance().getScrolls())
@ -130,7 +115,8 @@ public class EnchantScroll extends AbstractEnchantItem
}
}
}
return super.isValid(itemToEnchant, supportItem);
return super.isValid(itemToEnchant);
}
/**
@ -160,12 +146,11 @@ public class EnchantScroll extends AbstractEnchantItem
/**
* @param player
* @param enchantItem
* @param supportItem
* @return the total chance for success rate of this scroll
*/
public EnchantResultType calculateSuccess(Player player, Item enchantItem, EnchantSupportItem supportItem)
public EnchantResultType calculateSuccess(Player player, Item enchantItem)
{
if (!isValid(enchantItem, supportItem))
if (!isValid(enchantItem))
{
return EnchantResultType.ERROR;
}
@ -177,8 +162,7 @@ public class EnchantScroll extends AbstractEnchantItem
}
final double bonusRate = getBonusRate();
final double supportBonusRate = (supportItem != null) ? supportItem.getBonusRate() : 0;
final double finalChance = Math.min(chance + bonusRate + supportBonusRate, 100);
final double finalChance = Math.min(chance + bonusRate, 100);
final double random = 100 * Rnd.nextDouble();
final boolean success = (random < finalChance);
return success ? EnchantResultType.SUCCESS : EnchantResultType.FAILURE;

View File

@ -892,8 +892,6 @@ public class Item extends WorldObject
&& ((_itemTemplate.getType2() != ItemTemplate.TYPE2_MONEY) || (_itemTemplate.getType1() != ItemTemplate.TYPE1_SHIELD_ARMOR)) // not money, not shield
&& (!player.hasSummon() || (getObjectId() != player.getSummon().getControlObjectId())) // Not Control item of currently summoned pet
&& (player.getActiveEnchantItemId() != getObjectId()) // Not momentarily used enchant scroll
&& (player.getActiveEnchantSupportItemId() != getObjectId()) // Not momentarily used enchant support item
&& (player.getActiveEnchantAttrItemId() != getObjectId()) // Not momentarily used enchant attribute item
&& (allowAdena || (_itemId != ADENA_ID)) // Not Adena
&& ((player.getCurrentSkill() == null) || (player.getCurrentSkill().getSkill().getItemConsumeId() != _itemId)) && (!player.isCastingSimultaneouslyNow() || (player.getLastSimultaneousSkillCast() == null) || (player.getLastSimultaneousSkillCast().getItemConsumeId() != _itemId)) && (allowNonTradeable || (isTradeable() && (!((_itemTemplate.getItemType() == EtcItemType.PET_COLLAR) && player.havePetInvItems())))));
}

View File

@ -26,7 +26,6 @@ import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.item.ItemTemplate;
import org.l2jmobius.gameserver.model.item.enchant.EnchantResultType;
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
import org.l2jmobius.gameserver.model.item.enchant.EnchantSupportItem;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.skill.CommonSkill;
import org.l2jmobius.gameserver.model.skill.Skill;
@ -44,18 +43,22 @@ public class RequestEnchantItem implements ClientPacket
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
private int _objectId;
private int _supportId;
@Override
public void read(ReadablePacket packet)
{
_objectId = packet.readInt();
_supportId = packet.readInt();
}
@Override
public void run(GameClient client)
{
// TODO: canEnchantItem
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final Player player = client.getPlayer();
if ((player == null) || (_objectId == 0))
{
@ -77,7 +80,6 @@ public class RequestEnchantItem implements ClientPacket
final Item item = player.getInventory().getItemByObjectId(_objectId);
Item scroll = player.getInventory().getItemByObjectId(player.getActiveEnchantItemId());
Item support = player.getInventory().getItemByObjectId(player.getActiveEnchantSupportItemId());
if ((item == null) || (scroll == null))
{
player.setActiveEnchantItemId(Player.ID_NONE);
@ -93,33 +95,11 @@ public class RequestEnchantItem implements ClientPacket
return;
}
// template for support item, if exist
EnchantSupportItem supportTemplate = null;
if (support != null)
{
if (support.getObjectId() != _supportId)
{
player.setActiveEnchantItemId(Player.ID_NONE);
return;
}
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
}
// first validation check - also over enchant check
if (!scrollTemplate.isValid(item, supportTemplate) || (Config.DISABLE_OVER_ENCHANTING && (item.getEnchantLevel() == scrollTemplate.getMaxEnchantLevel())))
if (!scrollTemplate.isValid(item) || (Config.DISABLE_OVER_ENCHANTING && (item.getEnchantLevel() == scrollTemplate.getMaxEnchantLevel())))
{
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
return;
}
// fast auto-enchant cheat check
if ((player.getActiveEnchantTimestamp() == 0) || ((System.currentTimeMillis() - player.getActiveEnchantTimestamp()) < 2000))
{
Util.handleIllegalPlayerAction(player, player + " use autoenchant program ", Config.DEFAULT_PUNISH);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
return;
}
@ -130,24 +110,9 @@ public class RequestEnchantItem implements ClientPacket
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
Util.handleIllegalPlayerAction(player, player + " tried to enchant with a scroll he doesn't have", Config.DEFAULT_PUNISH);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
return;
}
// attempting to destroy support if exist
if (support != null)
{
support = player.getInventory().destroyItem("Enchant", support.getObjectId(), 1, player, item);
if (support == null)
{
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
Util.handleIllegalPlayerAction(player, player + " tried to enchant with a support item he doesn't have", Config.DEFAULT_PUNISH);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
return;
}
}
final InventoryUpdate iu = new InventoryUpdate();
synchronized (item)
{
@ -156,22 +121,35 @@ public class RequestEnchantItem implements ClientPacket
{
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
return;
}
final EnchantResultType resultType = scrollTemplate.calculateSuccess(player, item, supportTemplate);
final EnchantResultType resultType = scrollTemplate.calculateSuccess(player, item);
switch (resultType)
{
case ERROR:
{
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
player.sendPacket(new EnchantResult(0));
break;
}
case SUCCESS:
{
if (item.getEnchantLevel() == 0)
{
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_S1_HAS_BEEN_SUCCESSFULLY_ENCHANTED);
sm.addItemName(item.getId());
player.sendPacket(sm);
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_S1_S2_HAS_BEEN_SUCCESSFULLY_ENCHANTED);
sm.addInt(item.getEnchantLevel());
sm.addItemName(item.getId());
player.sendPacket(sm);
}
Skill enchant4Skill = null;
final ItemTemplate it = item.getTemplate();
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
@ -180,28 +158,19 @@ public class RequestEnchantItem implements ClientPacket
item.setEnchantLevel(item.getEnchantLevel() + 1);
item.updateDatabase();
}
player.sendPacket(new EnchantResult(0, 0, 0));
player.sendPacket(new EnchantResult(item.getEnchantLevel()));
if (Config.LOG_ITEM_ENCHANTS)
{
final StringBuilder sb = new StringBuilder();
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
}
}
else if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Success, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
}
@ -237,32 +206,35 @@ public class RequestEnchantItem implements ClientPacket
}
case FAILURE:
{
if (item.getEnchantLevel() > 0)
{
final SystemMessage sm = new SystemMessage(SystemMessageId.THE_ENCHANTMENT_HAS_FAILED_YOUR_S1_S2_HAS_BEEN_CRYSTALLIZED);
sm.addInt(item.getEnchantLevel());
sm.addItemName(item.getId());
player.sendPacket(sm);
}
else
{
final SystemMessage sm = new SystemMessage(SystemMessageId.THE_ENCHANTMENT_HAS_FAILED_YOUR_S1_HAS_BEEN_CRYSTALLIZED);
sm.addItemName(item.getId());
player.sendPacket(sm);
}
if (scrollTemplate.isSafe())
{
// safe enchant - remain old value
player.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_LEVEL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
player.sendPacket(new EnchantResult(5, 0, 0));
player.sendPacket(new EnchantResult(0));
if (Config.LOG_ITEM_ENCHANTS)
{
final StringBuilder sb = new StringBuilder();
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
}
}
else if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Safe Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
}
}
@ -300,28 +272,17 @@ public class RequestEnchantItem implements ClientPacket
item.setEnchantLevel(0);
item.updateDatabase();
player.sendPacket(new EnchantResult(3, 0, 0));
player.sendPacket(new EnchantResult(0));
if (Config.LOG_ITEM_ENCHANTS)
{
final StringBuilder sb = new StringBuilder();
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
}
}
else if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Blessed Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
}
}
@ -333,28 +294,17 @@ public class RequestEnchantItem implements ClientPacket
// unable to destroy item, cheater ?
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from " + player + ", possible cheater !", Config.DEFAULT_PUNISH);
player.setActiveEnchantItemId(Player.ID_NONE);
player.sendPacket(new EnchantResult(2, 0, 0));
player.sendPacket(new EnchantResult(0));
if (Config.LOG_ITEM_ENCHANTS)
{
final StringBuilder sb = new StringBuilder();
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
}
}
else if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Unable to destroy, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
}
return;
@ -373,11 +323,11 @@ public class RequestEnchantItem implements ClientPacket
sm.addItemName(crystalId);
sm.addInt(count);
player.sendPacket(sm);
player.sendPacket(new EnchantResult(1, crystalId, count));
player.sendPacket(new EnchantResult(0));
}
else
{
player.sendPacket(new EnchantResult(4, 0, 0));
player.sendPacket(new EnchantResult(0));
}
if (Config.LOG_ITEM_ENCHANTS)
@ -385,22 +335,11 @@ public class RequestEnchantItem implements ClientPacket
final StringBuilder sb = new StringBuilder();
if (item.getEnchantLevel() > 0)
{
if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
}
}
else if (support == null)
{
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", +").append(item.getEnchantLevel()).append(" ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
else
{
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("], ").append(support.getName()).append("(").append(support.getCount()).append(") [").append(support.getObjectId()).append("]").toString());
LOGGER_ENCHANT.info(sb.append("Fail, Character:").append(player.getName()).append(" [").append(player.getObjectId()).append("] Account:").append(player.getAccountName()).append(" IP:").append(player.getIPAddress()).append(", ").append(item.getName()).append("(").append(item.getCount()).append(") [").append(item.getObjectId()).append("], ").append(scroll.getName()).append("(").append(scroll.getCount()).append(") [").append(scroll.getObjectId()).append("]").toString());
}
}
}
@ -430,18 +369,6 @@ public class RequestEnchantItem implements ClientPacket
iu.addModifiedItem(item);
}
if (support != null)
{
if (support.getCount() == 0)
{
iu.addRemovedItem(support);
}
else
{
iu.addModifiedItem(support);
}
}
player.sendPacket(iu);
player.broadcastUserInfo();
player.setActiveEnchantItemId(Player.ID_NONE);

View File

@ -1,38 +0,0 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
/**
* @author KenM
*/
public class RequestExCancelEnchantItem implements ClientPacket
{
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player != null)
{
player.sendPacket(new EnchantResult(2, 0, 0));
player.setActiveEnchantItemId(Player.ID_NONE);
}
}
}

View File

@ -55,7 +55,7 @@ public class RequestRestart implements ClientPacket
return;
}
if ((player.getActiveEnchantItemId() != Player.ID_NONE) || (player.getActiveEnchantAttrItemId() != Player.ID_NONE))
if (player.getActiveEnchantItemId() != Player.ID_NONE)
{
player.sendPacket(RestartResponse.valueOf(false));
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -21,14 +21,10 @@ import org.l2jmobius.gameserver.network.ServerPackets;
public class EnchantResult extends ServerPacket
{
private final int _result;
private final int _crystal;
private final int _count;
public EnchantResult(int result, int crystal, int count)
public EnchantResult(int result)
{
_result = result;
_crystal = crystal;
_count = count;
}
@Override
@ -36,7 +32,5 @@ public class EnchantResult extends ServerPacket
{
ServerPackets.ENCHANT_RESULT.writeId(this);
writeInt(_result);
writeInt(_crystal);
writeInt(_count);
}
}

View File

@ -104,6 +104,7 @@ What is done
-Removed all non existing skill enchants.
-Fixed skill enchanting.
-Adjusted MagicSkillUse packet.
-Fixed item enchanting.
TODO: Important (project unusable due to the following)
-Adjust all skills according to Interlude description.