Addition of new enchant system.
Contributed by Index.
This commit is contained in:
parent
37bf68d766
commit
196e4a6af8
@ -16,7 +16,11 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.request;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -27,6 +31,11 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
private volatile int _enchantingItemObjectId;
|
||||
private volatile int _enchantingScrollObjectId;
|
||||
private volatile int _supportItemObjectId;
|
||||
private volatile int _enchantingItemCurrentEnchantLevel;
|
||||
private final Map<Integer, Integer> _multiEnchantingItems = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, ItemHolder> _multiFailRewardItems = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, int[]> _successEnchant = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Integer> _failureEnchant = new ConcurrentHashMap<>();
|
||||
|
||||
public EnchantItemRequest(Player player, int enchantingScrollObjectId)
|
||||
{
|
||||
@ -34,6 +43,36 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
_enchantingScrollObjectId = enchantingScrollObjectId;
|
||||
}
|
||||
|
||||
public void setMultiSuccessEnchantList(Map<Integer, int[]> list)
|
||||
{
|
||||
_successEnchant.putAll(list);
|
||||
}
|
||||
|
||||
public void setMultiFailureEnchantList(Map<Integer, Integer> list)
|
||||
{
|
||||
_failureEnchant.putAll(list);
|
||||
}
|
||||
|
||||
public void clearMultiSuccessEnchantList()
|
||||
{
|
||||
_successEnchant.clear();
|
||||
}
|
||||
|
||||
public void clearMultiFailureEnchantList()
|
||||
{
|
||||
_failureEnchant.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, int[]> getMultiSuccessEnchantList()
|
||||
{
|
||||
return _successEnchant;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getMultiFailureEnchantList()
|
||||
{
|
||||
return _failureEnchant;
|
||||
}
|
||||
|
||||
public Item getEnchantingItem()
|
||||
{
|
||||
return getActiveChar().getInventory().getItemByObjectId(_enchantingItemObjectId);
|
||||
@ -64,6 +103,71 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
_supportItemObjectId = objectId;
|
||||
}
|
||||
|
||||
public void setEnchantLevel(int enchantLevel)
|
||||
{
|
||||
_enchantingItemCurrentEnchantLevel = enchantLevel;
|
||||
}
|
||||
|
||||
public int getEnchantLevel()
|
||||
{
|
||||
return _enchantingItemCurrentEnchantLevel;
|
||||
}
|
||||
|
||||
public void addMultiEnchantingItems(int slot, int objectId)
|
||||
{
|
||||
_multiEnchantingItems.put(slot, objectId);
|
||||
}
|
||||
|
||||
public int getMultiEnchantingItemsBySlot(int slot)
|
||||
{
|
||||
return _multiEnchantingItems.getOrDefault(slot, -1);
|
||||
}
|
||||
|
||||
public void changeMultiEnchantingItemsBySlot(int slot, int objectId)
|
||||
{
|
||||
_multiEnchantingItems.replace(slot, objectId);
|
||||
}
|
||||
|
||||
public boolean checkMultiEnchantingItemsByObjectId(int objectId)
|
||||
{
|
||||
return _multiEnchantingItems.containsValue(objectId);
|
||||
}
|
||||
|
||||
public int getMultiEnchantingItemsCount()
|
||||
{
|
||||
return _multiEnchantingItems.size();
|
||||
}
|
||||
|
||||
public void clearMultiEnchantingItemsBySlot()
|
||||
{
|
||||
_multiEnchantingItems.clear();
|
||||
}
|
||||
|
||||
public String getMultiEnchantingItemsLits()
|
||||
{
|
||||
return _multiEnchantingItems.toString();
|
||||
}
|
||||
|
||||
public void addMultiEnchantFailItems(ItemHolder itemHolder)
|
||||
{
|
||||
_multiFailRewardItems.put(getMultiFailItemsCount() + 1, itemHolder);
|
||||
}
|
||||
|
||||
public int getMultiFailItemsCount()
|
||||
{
|
||||
return _multiFailRewardItems.size();
|
||||
}
|
||||
|
||||
public void clearMultiFailReward()
|
||||
{
|
||||
_multiFailRewardItems.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, ItemHolder> getMultiEnchantFailItems()
|
||||
{
|
||||
return _multiFailRewardItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemRequest()
|
||||
{
|
||||
|
@ -79,6 +79,17 @@ import org.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchant
|
||||
import org.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchantTry;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeEstimate;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeItemCancel;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExAddEnchantScrollItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExCancelEnchantItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExTryToPutEnchantSupportItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExTryToPutEnchantTargetItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestFinishMultiEnchantScroll;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestStartMultiEnchantScroll;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestViewMultiEnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.single.ExRequestEnchantFailRewardInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.single.ExRequestViewEnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
|
||||
@ -150,6 +161,7 @@ import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTelepor
|
||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleportFavoritesAddDel;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleportFavoritesUIToggle;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.RequestExRemoveEnchantSupportItem;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -712,16 +724,16 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_L2PASS_BUY_PREMIUM(0x225, null, ConnectionState.IN_GAME),
|
||||
EX_SAYHAS_SUPPORT_TOGGLE(0x226, null, ConnectionState.IN_GAME),
|
||||
// 362
|
||||
EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x227, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x227, ExRequestEnchantFailRewardInfo::new, ConnectionState.IN_GAME),
|
||||
EX_SET_ENCHANT_CHALLENGE_POINT(0x228, null, ConnectionState.IN_GAME),
|
||||
EX_RESET_ENCHANT_CHALLENGE_POINT(0x229, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_ENCHANT_RESULT(0x22A, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_START_MULTI_ENCHANT_SCROLL(0x22B, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_MULTI_ENCHANT_RESULT(0x22C, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_FINISH_MULTI_ENCHANT_SCROLL(0x22D, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_ENCHANT_RESULT(0x22A, ExRequestViewEnchantResult::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_START_MULTI_ENCHANT_SCROLL(0x22B, ExRequestStartMultiEnchantScroll::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_MULTI_ENCHANT_RESULT(0x22C, ExRequestViewMultiEnchantResult::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_FINISH_MULTI_ENCHANT_SCROLL(0x22D, ExRequestFinishMultiEnchantScroll::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_CHANGE_MULTI_ENCHANT_SCROLL(0x22E, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_SET_MULTI_ENCHANT_ITEM_LIST(0x22F, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_MULTI_ENCHANT_ITEM_LIST(0x230, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_SET_MULTI_ENCHANT_ITEM_LIST(0x22F, ExRequestSetMultiEnchantItemList::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_MULTI_ENCHANT_ITEM_LIST(0x230, ExRequestMultiEnchantItemList::new, ConnectionState.IN_GAME),
|
||||
EX_WORLDCASTLEWAR_SUPPORT_PLEDGE_FLAG_SET(0x231, null, ConnectionState.IN_GAME),
|
||||
EX_WORLDCASTLEWAR_SUPPORT_PLEDGE_INFO_SET(0x232, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_HOMUNCULUS_PROB_LIST(0x233, null, ConnectionState.IN_GAME),
|
||||
|
@ -25,6 +25,7 @@ import org.l2jmobius.commons.network.IConnectionState;
|
||||
import org.l2jmobius.commons.network.IIncomingPacket;
|
||||
import org.l2jmobius.commons.network.IIncomingPackets;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.*;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestEnchantItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestAnswerFriendInvite;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDel;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendInvite;
|
||||
|
@ -27,8 +27,8 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemOk;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantRetryToPutItemFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantRetryToPutItemOk;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -54,13 +54,15 @@ public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (player.isInStoreMode())
|
||||
|
||||
if (player.isInStoreMode())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_IN_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
else if (player.isProcessingTransaction() || player.isProcessingRequest())
|
||||
|
||||
if (player.isProcessingTransaction() || player.isProcessingRequest())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
@ -94,15 +96,15 @@ public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final CombinationItem combinationItem = CombinationItemsData.getInstance().getItemsBySlots(itemOne.getId(), itemOne.getEnchantLevel(), itemTwo.getId());
|
||||
|
||||
// Not implemented or not able to merge!
|
||||
final CombinationItem combinationItem = CombinationItemsData.getInstance().getItemsBySlots(itemOne.getId(), itemOne.getEnchantLevel(), itemTwo.getId());
|
||||
if (combinationItem == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(ExEnchantRetryToPutItemOk.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -24,7 +24,6 @@ import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import org.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
@ -37,11 +36,12 @@ import org.l2jmobius.gameserver.model.skill.CommonSkill;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExItemAnnounce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@ -50,13 +50,12 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
|
||||
|
||||
private int _objectId;
|
||||
private int _supportId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_objectId = packet.readD();
|
||||
_supportId = packet.readD();
|
||||
packet.readC(); // Unknown.
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -99,27 +98,31 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
if (item.getEnchantLevel() != request.getEnchantLevel())
|
||||
{
|
||||
item.setEnchantLevel(request.getEnchantLevel());
|
||||
}
|
||||
|
||||
// template for scroll
|
||||
// Template for scroll.
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// template for support item, if exist
|
||||
// Template for support item, if exist.
|
||||
EnchantSupportItem supportTemplate = null;
|
||||
if (support != null)
|
||||
{
|
||||
if (support.getObjectId() != _supportId)
|
||||
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
if (supportTemplate == null)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
}
|
||||
|
||||
// first validation check - also over enchant check
|
||||
// First validation check, also over enchant check.
|
||||
if (!scrollTemplate.isValid(item, supportTemplate) || (Config.DISABLE_OVER_ENCHANTING && ((item.getEnchantLevel() == scrollTemplate.getMaxEnchantLevel()) || (!(item.getTemplate().getEnchantLimit() == 0) && (item.getEnchantLevel() == item.getTemplate().getEnchantLimit())))))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
@ -128,8 +131,8 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// fast auto-enchant cheat check
|
||||
if ((request.getTimestamp() == 0) || ((Chronos.currentTimeMillis() - request.getTimestamp()) < 2000))
|
||||
// Fast auto-enchant cheat check.
|
||||
if ((request.getTimestamp() == 0) || ((Chronos.currentTimeMillis() - request.getTimestamp()) < 1000))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, player + " use autoenchant program ", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
@ -137,7 +140,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy scroll
|
||||
// Attempting to destroy scroll.
|
||||
if (player.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, player, item) == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
||||
@ -147,7 +150,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy support if exist
|
||||
// Attempting to destroy support if exists.
|
||||
if ((support != null) && (player.getInventory().destroyItem("Enchant", support.getObjectId(), 1, player, item) == null))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
||||
@ -160,7 +163,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
synchronized (item)
|
||||
{
|
||||
// last validation check
|
||||
// Last validation check.
|
||||
if ((item.getOwnerId() != player.getObjectId()) || !item.isEnchantable())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
@ -191,7 +194,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setEnchantLevel(Math.min(item.getEnchantLevel() + Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
item.setEnchantLevel(item.getEnchantLevel() + Math.min(Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
}
|
||||
item.updateDatabase();
|
||||
}
|
||||
@ -219,7 +222,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
}
|
||||
|
||||
// announce the success
|
||||
// Announce the success.
|
||||
if ((item.getEnchantLevel() >= (item.isArmor() ? Config.MIN_ARMOR_ENCHANT_ANNOUNCE : Config.MIN_WEAPON_ENCHANT_ANNOUNCE)) //
|
||||
&& (item.getEnchantLevel() <= (item.isArmor() ? Config.MAX_ARMOR_ENCHANT_ANNOUNCE : Config.MAX_WEAPON_ENCHANT_ANNOUNCE)))
|
||||
{
|
||||
@ -243,7 +246,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_ENCHANT, holder ->
|
||||
{
|
||||
// add skills bestowed from +4 armor
|
||||
// Add skills bestowed from +4 armor.
|
||||
if (item.getEnchantLevel() >= holder.getValue())
|
||||
{
|
||||
player.addSkill(holder.getSkill(), false);
|
||||
@ -251,7 +254,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
});
|
||||
}
|
||||
player.broadcastUserInfo(); // update user info
|
||||
player.broadcastUserInfo(); // Update user info.
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -259,7 +262,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
{
|
||||
if (scrollTemplate.isSafe())
|
||||
{
|
||||
// safe enchant - remain old value
|
||||
// Safe enchant: Remain old value.
|
||||
player.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SAFE_FAIL, item));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
@ -287,7 +290,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
// unequip item on enchant failure to avoid item skills stack
|
||||
// Unequip item on enchant failure to avoid item skills stack.
|
||||
if (item.isEquipped())
|
||||
{
|
||||
if (item.getEnchantLevel() > 0)
|
||||
@ -314,19 +317,19 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
|
||||
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown() || ((supportTemplate != null) && supportTemplate.isDown()) || ((supportTemplate != null) && supportTemplate.isBlessed()))
|
||||
{
|
||||
// blessed enchant - enchant value down by 1
|
||||
// Blessed enchant: Enchant value down by 1.
|
||||
if (scrollTemplate.isBlessedDown() || ((supportTemplate != null) && supportTemplate.isDown()))
|
||||
{
|
||||
client.sendPacket(SystemMessageId.THE_ENCHANT_VALUE_IS_DECREASED_BY_1);
|
||||
item.setEnchantLevel(item.getEnchantLevel() - 1);
|
||||
}
|
||||
else // blessed enchant - clear enchant value
|
||||
else // Blessed enchant: Clear enchant value.
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
item.setEnchantLevel(0);
|
||||
}
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SUCCESS, item));
|
||||
item.updateDatabase();
|
||||
player.sendPacket(new EnchantResult(EnchantResult.BLESSED_FAIL, 0, 0));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (item.getEnchantLevel() > 0)
|
||||
@ -352,10 +355,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
// enchant failed, destroy item
|
||||
// Enchant failed, destroy item.
|
||||
if (player.getInventory().destroyItem("Enchant", item, player, null) == null)
|
||||
{
|
||||
// unable to destroy item, cheater ?
|
||||
// Unable to destroy item, cheater?
|
||||
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from " + player + ", possible cheater !", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
|
||||
@ -397,7 +400,6 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
if (count > 0)
|
||||
{
|
||||
crystals = player.getInventory().addItem("Enchant", crystalId, count, player, item);
|
||||
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S1_X_S2);
|
||||
sm.addItemName(crystals);
|
||||
sm.addLong(count);
|
||||
@ -445,11 +447,9 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendItemList();
|
||||
|
||||
player.broadcastUserInfo();
|
||||
request.setProcessing(false);
|
||||
player.broadcastUserInfo(UserInfoType.ENCHANTLEVEL);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -25,7 +25,8 @@ import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantScrollItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantScrollItemResult;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -33,13 +34,12 @@ import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantScrollItemResu
|
||||
public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
{
|
||||
private int _scrollObjectId;
|
||||
private int _enchantObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_scrollObjectId = packet.readD();
|
||||
_enchantObjectId = packet.readD();
|
||||
packet.readD(); // enchantObjectId?
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,20 +52,17 @@ public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if ((request == null) || request.isProcessing())
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return;
|
||||
player.addRequest(new EnchantItemRequest(player, _scrollObjectId));
|
||||
}
|
||||
|
||||
request.setEnchantingItem(_enchantObjectId);
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
|
||||
final Item item = request.getEnchantingItem();
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
if ((item == null) || (scroll == null))
|
||||
if ((scroll == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
player.sendPacket(new ExPutEnchantScrollItemResult(0));
|
||||
request.setEnchantingItem(Player.ID_NONE);
|
||||
@ -76,7 +73,7 @@ public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if ((scrollTemplate == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
player.sendPacket(new ExPutEnchantScrollItemResult(0));
|
||||
request.setEnchantingScroll(Player.ID_NONE);
|
@ -14,13 +14,14 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
|
||||
/**
|
||||
* @author KenM
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -26,7 +26,9 @@ import org.l2jmobius.gameserver.model.item.enchant.EnchantSupportItem;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
@ -67,7 +69,7 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
final Item support = request.getSupportItem();
|
||||
if ((item == null) || (scroll == null) || (support == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
request.setEnchantingItem(Player.ID_NONE);
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
@ -78,7 +80,7 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
final EnchantSupportItem supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
if ((scrollTemplate == null) || (supportTemplate == null) || !scrollTemplate.isValid(item, supportTemplate))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
player.sendPacket(new ExPutEnchantSupportItemResult(0));
|
||||
@ -88,5 +90,6 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
request.setSupportItem(support.getObjectId());
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
player.sendPacket(new ExPutEnchantSupportItemResult(_supportObjectId));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -26,7 +26,9 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantTargetItemResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
@ -58,6 +60,7 @@ public class RequestExTryToPutEnchantTargetItem implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
request.setEnchantingItem(_objectId);
|
||||
request.setEnchantLevel(player.getInventory().getItemByObjectId(_objectId).getEnchantLevel());
|
||||
|
||||
final Item item = request.getEnchantingItem();
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
@ -78,7 +81,9 @@ public class RequestExTryToPutEnchantTargetItem implements IClientIncomingPacket
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
player.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestFinishMultiEnchantScroll implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) != null)
|
||||
{
|
||||
player.removeRequest(EnchantItemRequest.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,374 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantResultType;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestMultiEnchantItemList implements IClientIncomingPacket
|
||||
{
|
||||
private int _useLateAnnounce;
|
||||
private int _slotId;
|
||||
private final Map<Integer, Integer> _itemObjectId = new HashMap<>();
|
||||
private final Map<Integer, String> _result = new HashMap<>();
|
||||
private final Map<Integer, int[]> _successEnchant = new HashMap<>();
|
||||
private final Map<Integer, Integer> _failureEnchant = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @code slot_id @code item_holder
|
||||
*/
|
||||
private final Map<Integer, ItemHolder> _failureReward = new HashMap<>();
|
||||
|
||||
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_useLateAnnounce = packet.readC();
|
||||
_slotId = packet.readD();
|
||||
for (int i = 1; packet.getReadableBytes() != 0; i++)
|
||||
{
|
||||
_itemObjectId.put(i, packet.readD());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if (request == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((request.getEnchantingScroll() == null) || request.isProcessing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
if (scroll.getCount() < _slotId)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 1));
|
||||
Logger.getLogger("MultiEnchant - player " + player.getObjectId() + " " + player.getName() + " trying enchant items, when scrolls count less than items;");
|
||||
}
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int[] slots = new int[_slotId];
|
||||
for (int i = 1; i <= _slotId; i++)
|
||||
{
|
||||
if (!request.checkMultiEnchantingItemsByObjectId(_itemObjectId.get(i)))
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
slots[i - 1] = getMultiEnchantingSlotByObjectId(request, _itemObjectId.get(i));
|
||||
}
|
||||
|
||||
_itemObjectId.clear();
|
||||
request.setProcessing(true);
|
||||
|
||||
for (int slotCounter = 0; slotCounter < slots.length; slotCounter++)
|
||||
{
|
||||
final int i = slots[slotCounter];
|
||||
if ((i == -1) || (request.getMultiEnchantingItemsBySlot(i) == -1))
|
||||
{
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
final Item enchantItem = player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i));
|
||||
if (scrollTemplate.getMaxEnchantLevel() < enchantItem.getEnchantLevel())
|
||||
{
|
||||
Logger.getLogger("MultiEnchant - player " + player.getObjectId() + " " + player.getName() + " trying over-enchant item " + enchantItem.getItemName() + " " + enchantItem.getObjectId());
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getInventory().destroyItemByItemId("Enchant", scroll.getId(), 1, player, enchantItem) == null)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
synchronized (enchantItem)
|
||||
{
|
||||
if ((enchantItem.getOwnerId() != player.getObjectId()) || !enchantItem.isEnchantable())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantResultType resultType = scrollTemplate.calculateSuccess(player, enchantItem, null);
|
||||
switch (resultType)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INAPPROPRIATE_ENCHANT_CONDITIONS);
|
||||
player.removeRequest(request.getClass());
|
||||
_result.put(slots[i - 1], "ERROR");
|
||||
break;
|
||||
}
|
||||
case SUCCESS:
|
||||
{
|
||||
// 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(player, enchantItem) > 0)
|
||||
{
|
||||
enchantItem.setEnchantLevel(enchantItem.getEnchantLevel() + Math.min(Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
enchantItem.updateDatabase();
|
||||
}
|
||||
_result.put(i, "SUCCESS");
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FAILURE:
|
||||
{
|
||||
if (scrollTemplate.isSafe())
|
||||
{
|
||||
// Safe enchant: Remain old value.
|
||||
player.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SAFE_FAIL, enchantItem));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown())
|
||||
{
|
||||
// Blessed enchant: Enchant value down by 1.
|
||||
if (scrollTemplate.isBlessedDown())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.THE_ENCHANT_VALUE_IS_DECREASED_BY_1);
|
||||
enchantItem.setEnchantLevel(enchantItem.getEnchantLevel() - 1);
|
||||
}
|
||||
else // Blessed enchant: Clear enchant value.
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
enchantItem.setEnchantLevel(0);
|
||||
}
|
||||
_result.put(i, "BLESSED_FAIL");
|
||||
enchantItem.updateDatabase();
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enchant failed, destroy item.
|
||||
if (player.getInventory().destroyItem("Enchant", enchantItem, player, null) == null)
|
||||
{
|
||||
// Unable to destroy item, cheater?
|
||||
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from " + player + ", possible cheater !", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
_result.put(i, "ERROR");
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
World.getInstance().removeObject(enchantItem);
|
||||
|
||||
int count = 0;
|
||||
if (enchantItem.getTemplate().isCrystallizable())
|
||||
{
|
||||
count = Math.max(0, enchantItem.getCrystalCount() - ((enchantItem.getTemplate().getCrystalCount() + 1) / 2));
|
||||
}
|
||||
|
||||
Item crystals = null;
|
||||
final int crystalId = enchantItem.getTemplate().getCrystalItemId();
|
||||
if (count > 0)
|
||||
{
|
||||
crystals = player.getInventory().addItem("Enchant", crystalId, count, player, enchantItem);
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S1_X_S2);
|
||||
sm.addItemName(crystals);
|
||||
sm.addLong(count);
|
||||
player.sendPacket(sm);
|
||||
ItemHolder itemHolder = new ItemHolder(crystalId, count);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE && (crystals != null))
|
||||
{
|
||||
iu.addItem(crystals);
|
||||
}
|
||||
|
||||
if ((crystalId == 0) || (count == 0))
|
||||
{
|
||||
ItemHolder itemHolder = new ItemHolder(0, 0);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
_result.put(i, "NO_CRYSTAL");
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHolder itemHolder = new ItemHolder(0, 0);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
_result.put(i, "FAIL");
|
||||
}
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int slotCounter = 0; slotCounter < slots.length; slotCounter++)
|
||||
{
|
||||
final int i = slots[slotCounter];
|
||||
if (_result.get(i).equals("SUCCESS"))
|
||||
{
|
||||
int[] intArray = new int[2];
|
||||
intArray[0] = request.getMultiEnchantingItemsBySlot(i);
|
||||
intArray[1] = player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i)).getEnchantLevel();
|
||||
_successEnchant.put(i, intArray);
|
||||
}
|
||||
else if (_result.get(i).equals("NO_CRYSTAL") || _result.get(i).equals("FAIL"))
|
||||
{
|
||||
_failureEnchant.put(i, request.getMultiEnchantingItemsBySlot(i));
|
||||
request.changeMultiEnchantingItemsBySlot(i, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : _failureReward.keySet())
|
||||
{
|
||||
request.addMultiEnchantFailItems(_failureReward.get(i));
|
||||
}
|
||||
request.setProcessing(false);
|
||||
|
||||
player.sendItemList();
|
||||
player.broadcastUserInfo();
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, true));
|
||||
|
||||
if (_useLateAnnounce == 1)
|
||||
{
|
||||
request.setMultiSuccessEnchantList(_successEnchant);
|
||||
request.setMultiFailureEnchantList(_failureEnchant);
|
||||
}
|
||||
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, _successEnchant, _failureEnchant));
|
||||
}
|
||||
|
||||
public int getMultiEnchantingSlotByObjectId(EnchantItemRequest request, int objectId)
|
||||
{
|
||||
int slotId = -1;
|
||||
for (int i = 1; i <= request.getMultiEnchantingItemsCount(); i++)
|
||||
{
|
||||
if ((request.getMultiEnchantingItemsCount() == 0) || (objectId == 0))
|
||||
{
|
||||
return slotId;
|
||||
}
|
||||
else if (request.getMultiEnchantingItemsBySlot(i) == objectId)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return slotId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestSetMultiEnchantItemList implements IClientIncomingPacket
|
||||
{
|
||||
private int _slotId;
|
||||
private final Map<Integer, Integer> _itemObjectId = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_slotId = packet.readD();
|
||||
for (int i = 1; packet.getReadableBytes() != 0; i++)
|
||||
{
|
||||
_itemObjectId.put(i, packet.readD());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if (request.getMultiEnchantingItemsBySlot(_slotId) != -1)
|
||||
{
|
||||
request.clearMultiEnchantingItemsBySlot();
|
||||
for (int i = 1; i <= _slotId; i++)
|
||||
{
|
||||
request.addMultiEnchantingItems(i, _itemObjectId.get(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
request.addMultiEnchantingItems(_slotId, _itemObjectId.get(_slotId));
|
||||
}
|
||||
|
||||
_itemObjectId.clear();
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 0));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, true));
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResetSelectMultiEnchantScroll;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestStartMultiEnchantScroll implements IClientIncomingPacket
|
||||
{
|
||||
private int _scrollObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_scrollObjectId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
player.addRequest(new EnchantItemRequest(player, _scrollObjectId));
|
||||
}
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
final Item scroll = player.getInventory().getItemByObjectId(_scrollObjectId);
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
player.sendPacket(new ExResetSelectMultiEnchantScroll(player, _scrollObjectId, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
|
||||
player.sendPacket(new ExResetSelectMultiEnchantScroll(player, _scrollObjectId, 0));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultMultiEnchantItemList;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestViewMultiEnchantResult implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
packet.readC();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, request.getMultiSuccessEnchantList(), request.getMultiFailureEnchantList(), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.enchant.single;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ResetEnchantItemFailRewardInfo;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestEnchantFailRewardInfo implements IClientIncomingPacket
|
||||
{
|
||||
private int _itemobjectid;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_itemobjectid = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item addedItem = player.getInventory().getItemByObjectId(_itemobjectid);
|
||||
if (addedItem != null)
|
||||
{
|
||||
player.sendPacket(new ResetEnchantItemFailRewardInfo(player));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.enchant.single;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestViewEnchantResult implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,39 +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.serverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemFail implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemFail STATIC_PACKET = new ExEnchantRetryToPutItemFail();
|
||||
|
||||
private ExEnchantRetryToPutItemFail()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,39 +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.serverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemOk implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemOk STATIC_PACKET = new ExEnchantRetryToPutItemOk();
|
||||
|
||||
private ExEnchantRetryToPutItemOk()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_OK.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -14,20 +14,21 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public class EnchantResult implements IClientOutgoingPacket
|
||||
{
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int FAIL = 1;
|
||||
public static final int ERROR = 2;
|
||||
public static final int BLESSED_FAIL = 3;
|
||||
public static final int SUCCESS = 0; /* 11, 12 */
|
||||
public static final int FAIL = 1; /* 6, 9 */
|
||||
public static final int ERROR = 2; /* 10 */
|
||||
public static final int BLESSED_FAIL = 3; /* 7 */
|
||||
public static final int NO_CRYSTAL = 4;
|
||||
public static final int SAFE_FAIL = 5;
|
||||
public static final int SAFE_FAIL = 5; /* 8 */
|
||||
|
||||
private final int _result;
|
||||
private final int _crystal;
|
||||
@ -62,16 +63,9 @@ public class EnchantResult implements IClientOutgoingPacket
|
||||
packet.writeD(_result);
|
||||
packet.writeD(_crystal);
|
||||
packet.writeQ(_count);
|
||||
// Guessing.
|
||||
// With 166 options became 3x write integers instead of shorts and enchant level moved bellow.
|
||||
// Commenting until actually knowing.
|
||||
// for (int option : _enchantOptions)
|
||||
// {
|
||||
// packet.writeD(option);
|
||||
// }
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(_enchantLevel); // Confirmed.
|
||||
return true;
|
||||
}
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author nBd
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author nBd
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -22,7 +22,8 @@ import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExRemoveEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -51,12 +52,13 @@ public class RequestExRemoveEnchantSupportItem implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
final Item supportItem = request.getSupportItem();
|
||||
if ((supportItem == null) || (supportItem.getCount() < 1))
|
||||
if ((supportItem == null) || (supportItem.getCount() >= 0))
|
||||
{
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
}
|
||||
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
|
||||
player.sendPacket(ExRemoveEnchantSupportItemResult.STATIC_PACKET);
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
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.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ResetEnchantItemFailRewardInfo implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
|
||||
public ResetEnchantItemFailRewardInfo(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
if ((request.getEnchantingItem() == null) || request.isProcessing() || (request.getEnchantingScroll() == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantScroll enchantScroll = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll());
|
||||
final Item enchantItem = request.getEnchantingItem();
|
||||
Item addedItem = enchantItem;
|
||||
EnchantSupportItem enchantSupportItem = null;
|
||||
ItemHolder result = null;
|
||||
if (request.getSupportItem() != null)
|
||||
{
|
||||
enchantSupportItem = EnchantItemData.getInstance().getSupportItem(request.getSupportItem());
|
||||
}
|
||||
if (enchantScroll.isBlessed() || ((request.getSupportItem() != null) && (enchantSupportItem != null) && enchantSupportItem.isBlessed()))
|
||||
{
|
||||
addedItem.setEnchantLevel(0);
|
||||
}
|
||||
else if (enchantScroll.isBlessedDown() || ((request.getSupportItem() != null) && (enchantSupportItem != null) && enchantSupportItem.isDown()))
|
||||
{
|
||||
addedItem.setEnchantLevel(enchantItem.getEnchantLevel() - 1);
|
||||
}
|
||||
else if (enchantScroll.isSafe())
|
||||
{
|
||||
addedItem.setEnchantLevel(enchantItem.getEnchantLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
addedItem = null;
|
||||
if (enchantItem.getTemplate().isCrystallizable())
|
||||
{
|
||||
result = new ItemHolder(enchantItem.getTemplate().getCrystalItemId(), Math.max(0, enchantItem.getCrystalCount() - ((enchantItem.getTemplate().getCrystalCount() + 1) / 2)));
|
||||
}
|
||||
}
|
||||
|
||||
OutgoingPackets.EX_RES_ENCHANT_ITEM_FAIL_REWARD_INFO.writeId(packet);
|
||||
packet.writeD(enchantItem.getObjectId());
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
packet.writeD(1); // Loop count.
|
||||
packet.writeD(result.getId());
|
||||
packet.writeD((int) result.getCount());
|
||||
}
|
||||
else if (addedItem != null)
|
||||
{
|
||||
packet.writeD(1); // Loop count.
|
||||
packet.writeD(enchantItem.getId());
|
||||
packet.writeD(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0); // Loop count.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResetSelectMultiEnchantScroll implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final int _scrollObjectId;
|
||||
private final int _resultType;
|
||||
|
||||
public ExResetSelectMultiEnchantScroll(Player player, int scrollObjectId, int resultType)
|
||||
{
|
||||
_player = player;
|
||||
_scrollObjectId = scrollObjectId;
|
||||
_resultType = resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
if (request.getEnchantingScroll() == null)
|
||||
{
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
}
|
||||
|
||||
OutgoingPackets.EX_RES_SELECT_MULTI_ENCHANT_SCROLL.writeId(packet);
|
||||
|
||||
packet.writeD(_scrollObjectId);
|
||||
packet.writeD(_resultType);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResultMultiEnchantItemList implements IClientOutgoingPacket
|
||||
{
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int FAIL = 1;
|
||||
public static final int ERROR = 2;
|
||||
private final Player _player;
|
||||
private boolean _error;
|
||||
private boolean _isResult;
|
||||
private Map<Integer, int[]> _successEnchant = new HashMap<>();
|
||||
private Map<Integer, Integer> _failureEnchant = new HashMap<>();
|
||||
private Map<Integer, ItemHolder> _failureReward = new HashMap<>();
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, boolean error)
|
||||
{
|
||||
_player = player;
|
||||
_error = error;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, ItemHolder> failureReward)
|
||||
{
|
||||
_player = player;
|
||||
_failureReward = failureReward;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, int[]> successEnchant, Map<Integer, Integer> failureEnchant)
|
||||
{
|
||||
_player = player;
|
||||
_successEnchant = successEnchant;
|
||||
_failureEnchant = failureEnchant;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, int[]> successEnchant, Map<Integer, Integer> failureEnchant, boolean isResult)
|
||||
{
|
||||
_player = player;
|
||||
_successEnchant = successEnchant;
|
||||
_failureEnchant = failureEnchant;
|
||||
_isResult = isResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
OutgoingPackets.EX_RES_MULTI_ENCHANT_ITEM_LIST.writeId(packet);
|
||||
|
||||
if (_error)
|
||||
{
|
||||
packet.writeC(0);
|
||||
return true;
|
||||
}
|
||||
packet.writeC(1);
|
||||
|
||||
/* EnchantSuccessItem */
|
||||
if (_failureReward.size() == 0)
|
||||
{
|
||||
packet.writeD(_successEnchant.size());
|
||||
if (_successEnchant.size() != 0)
|
||||
{
|
||||
for (int i : _successEnchant.keySet())
|
||||
{
|
||||
int[] intArray = _successEnchant.get(i);
|
||||
packet.writeD(intArray[0]);
|
||||
packet.writeD(intArray[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailItem */
|
||||
packet.writeD(_failureEnchant.size());
|
||||
if (_failureEnchant.size() != 0)
|
||||
{
|
||||
for (int i : _failureEnchant.keySet())
|
||||
{
|
||||
packet.writeD(_failureEnchant.get(i));
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailRewardItem */
|
||||
if (((_successEnchant.size() == 0) && (request.getMultiFailItemsCount() != 0)) || (_isResult && (request.getMultiFailItemsCount() != 0)))
|
||||
{
|
||||
packet.writeD(request.getMultiFailItemsCount());
|
||||
_failureReward = request.getMultiEnchantFailItems();
|
||||
for (int i : _failureReward.keySet())
|
||||
{
|
||||
ItemHolder itemHolder = _failureReward.get(i);
|
||||
packet.writeD(itemHolder.getId());
|
||||
packet.writeD((int) itemHolder.getCount());
|
||||
}
|
||||
if (_isResult)
|
||||
{
|
||||
request.clearMultiSuccessEnchantList();
|
||||
request.clearMultiFailureEnchantList();
|
||||
}
|
||||
request.clearMultiFailReward();
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailChallengePointInfo */
|
||||
packet.writeD(1);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResultSetMultiEnchantItemList implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final int _resultType;
|
||||
|
||||
public ExResultSetMultiEnchantItemList(Player player, int resultType)
|
||||
{
|
||||
_player = player;
|
||||
_resultType = resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
OutgoingPackets.EX_RES_SET_MULTI_ENCHANT_ITEM_LIST.writeId(packet);
|
||||
packet.writeD(_resultType);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.single;
|
||||
|
||||
import static org.l2jmobius.gameserver.model.stats.Stat.ENCHANT_RATE;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ChangedEnchantTargetItemProbabilityList implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final boolean _isMulti;
|
||||
|
||||
public ChangedEnchantTargetItemProbabilityList(Player player, Boolean isMulti)
|
||||
{
|
||||
_player = player;
|
||||
_isMulti = isMulti;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
if ((!_isMulti && (request.getEnchantingItem() == null)) || request.isProcessing() || (request.getEnchantingScroll() == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = 1;
|
||||
if (_isMulti)
|
||||
{
|
||||
count = request.getMultiEnchantingItemsCount();
|
||||
}
|
||||
|
||||
final double supportRate = getSupportRate(request);
|
||||
final double passiveRate = getPassiveRate();
|
||||
|
||||
OutgoingPackets.EX_CHANGED_ENCHANT_TARGET_ITEM_PROB_LIST.writeId(packet);
|
||||
packet.writeD(count);
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
// 100,00 % = 10000, because last 2 numbers going after float comma.
|
||||
double baseRate;
|
||||
if (!_isMulti || (request.getMultiEnchantingItemsBySlot(i) != 0))
|
||||
{
|
||||
baseRate = getBaseRate(request, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseRate = 0;
|
||||
}
|
||||
double totalRate = baseRate + supportRate + passiveRate;
|
||||
if (totalRate >= 10000)
|
||||
{
|
||||
totalRate = 10000;
|
||||
}
|
||||
if (!_isMulti)
|
||||
{
|
||||
packet.writeD(request.getEnchantingItem().getObjectId());
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(request.getMultiEnchantingItemsBySlot(i));
|
||||
}
|
||||
packet.writeD((int) totalRate); // Total success.
|
||||
packet.writeD((int) baseRate); // Base success.
|
||||
packet.writeD((int) supportRate); // Support success.
|
||||
packet.writeD((int) passiveRate); // Passive success (items, skills).
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getBaseRate(EnchantItemRequest request, int i)
|
||||
{
|
||||
double baseRate;
|
||||
if (!_isMulti)
|
||||
{
|
||||
baseRate = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll()).getChance(_player, request.getEnchantingItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Item item = _player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i));
|
||||
baseRate = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll()).getChance(_player, item);
|
||||
}
|
||||
baseRate = baseRate * 100;
|
||||
return (int) baseRate;
|
||||
}
|
||||
|
||||
private int getSupportRate(EnchantItemRequest request)
|
||||
{
|
||||
double supportRate = 0;
|
||||
if (!_isMulti && (request.getSupportItem() != null))
|
||||
{
|
||||
supportRate = EnchantItemData.getInstance().getSupportItem(request.getSupportItem()).getBonusRate();
|
||||
supportRate = supportRate * 100;
|
||||
}
|
||||
return (int) supportRate;
|
||||
}
|
||||
|
||||
private int getPassiveRate()
|
||||
{
|
||||
double passiveRate = 0;
|
||||
if (_player.getStat().getValue(ENCHANT_RATE) != 0)
|
||||
{
|
||||
passiveRate = _player.getStat().getValue(ENCHANT_RATE);
|
||||
passiveRate = passiveRate * 100;
|
||||
}
|
||||
return (int) passiveRate;
|
||||
}
|
||||
}
|
@ -16,7 +16,11 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.request;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@ -27,6 +31,11 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
private volatile int _enchantingItemObjectId;
|
||||
private volatile int _enchantingScrollObjectId;
|
||||
private volatile int _supportItemObjectId;
|
||||
private volatile int _enchantingItemCurrentEnchantLevel;
|
||||
private final Map<Integer, Integer> _multiEnchantingItems = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, ItemHolder> _multiFailRewardItems = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, int[]> _successEnchant = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Integer> _failureEnchant = new ConcurrentHashMap<>();
|
||||
|
||||
public EnchantItemRequest(Player player, int enchantingScrollObjectId)
|
||||
{
|
||||
@ -34,6 +43,36 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
_enchantingScrollObjectId = enchantingScrollObjectId;
|
||||
}
|
||||
|
||||
public void setMultiSuccessEnchantList(Map<Integer, int[]> list)
|
||||
{
|
||||
_successEnchant.putAll(list);
|
||||
}
|
||||
|
||||
public void setMultiFailureEnchantList(Map<Integer, Integer> list)
|
||||
{
|
||||
_failureEnchant.putAll(list);
|
||||
}
|
||||
|
||||
public void clearMultiSuccessEnchantList()
|
||||
{
|
||||
_successEnchant.clear();
|
||||
}
|
||||
|
||||
public void clearMultiFailureEnchantList()
|
||||
{
|
||||
_failureEnchant.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, int[]> getMultiSuccessEnchantList()
|
||||
{
|
||||
return _successEnchant;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getMultiFailureEnchantList()
|
||||
{
|
||||
return _failureEnchant;
|
||||
}
|
||||
|
||||
public Item getEnchantingItem()
|
||||
{
|
||||
return getActiveChar().getInventory().getItemByObjectId(_enchantingItemObjectId);
|
||||
@ -64,6 +103,71 @@ public class EnchantItemRequest extends AbstractRequest
|
||||
_supportItemObjectId = objectId;
|
||||
}
|
||||
|
||||
public void setEnchantLevel(int enchantLevel)
|
||||
{
|
||||
_enchantingItemCurrentEnchantLevel = enchantLevel;
|
||||
}
|
||||
|
||||
public int getEnchantLevel()
|
||||
{
|
||||
return _enchantingItemCurrentEnchantLevel;
|
||||
}
|
||||
|
||||
public void addMultiEnchantingItems(int slot, int objectId)
|
||||
{
|
||||
_multiEnchantingItems.put(slot, objectId);
|
||||
}
|
||||
|
||||
public int getMultiEnchantingItemsBySlot(int slot)
|
||||
{
|
||||
return _multiEnchantingItems.getOrDefault(slot, -1);
|
||||
}
|
||||
|
||||
public void changeMultiEnchantingItemsBySlot(int slot, int objectId)
|
||||
{
|
||||
_multiEnchantingItems.replace(slot, objectId);
|
||||
}
|
||||
|
||||
public boolean checkMultiEnchantingItemsByObjectId(int objectId)
|
||||
{
|
||||
return _multiEnchantingItems.containsValue(objectId);
|
||||
}
|
||||
|
||||
public int getMultiEnchantingItemsCount()
|
||||
{
|
||||
return _multiEnchantingItems.size();
|
||||
}
|
||||
|
||||
public void clearMultiEnchantingItemsBySlot()
|
||||
{
|
||||
_multiEnchantingItems.clear();
|
||||
}
|
||||
|
||||
public String getMultiEnchantingItemsLits()
|
||||
{
|
||||
return _multiEnchantingItems.toString();
|
||||
}
|
||||
|
||||
public void addMultiEnchantFailItems(ItemHolder itemHolder)
|
||||
{
|
||||
_multiFailRewardItems.put(getMultiFailItemsCount() + 1, itemHolder);
|
||||
}
|
||||
|
||||
public int getMultiFailItemsCount()
|
||||
{
|
||||
return _multiFailRewardItems.size();
|
||||
}
|
||||
|
||||
public void clearMultiFailReward()
|
||||
{
|
||||
_multiFailRewardItems.clear();
|
||||
}
|
||||
|
||||
public Map<Integer, ItemHolder> getMultiEnchantFailItems()
|
||||
{
|
||||
return _multiFailRewardItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemRequest()
|
||||
{
|
||||
|
@ -82,6 +82,17 @@ import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElement
|
||||
import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElementalSpiritExtractInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElementalSpiritInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElementalSpiritSetTalent;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExAddEnchantScrollItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExCancelEnchantItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExTryToPutEnchantSupportItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestExTryToPutEnchantTargetItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestFinishMultiEnchantScroll;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestStartMultiEnchantScroll;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.multi.ExRequestViewMultiEnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.single.ExRequestEnchantFailRewardInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.single.ExRequestViewEnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
|
||||
@ -167,6 +178,7 @@ import org.l2jmobius.gameserver.network.clientpackets.teleports.RequestRaidTelep
|
||||
import org.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.vip.ExRequestVipInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.vip.RequestVipLuckGameInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.RequestExRemoveEnchantSupportItem;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -729,16 +741,16 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_L2PASS_BUY_PREMIUM(0x225, null, ConnectionState.IN_GAME),
|
||||
EX_SAYHAS_SUPPORT_TOGGLE(0x226, null, ConnectionState.IN_GAME),
|
||||
// 362
|
||||
EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x227, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_ENCHANT_FAIL_REWARD_INFO(0x227, ExRequestEnchantFailRewardInfo::new, ConnectionState.IN_GAME),
|
||||
EX_SET_ENCHANT_CHALLENGE_POINT(0x228, null, ConnectionState.IN_GAME),
|
||||
EX_RESET_ENCHANT_CHALLENGE_POINT(0x229, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_ENCHANT_RESULT(0x22A, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_START_MULTI_ENCHANT_SCROLL(0x22B, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_MULTI_ENCHANT_RESULT(0x22C, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_FINISH_MULTI_ENCHANT_SCROLL(0x22D, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_ENCHANT_RESULT(0x22A, ExRequestViewEnchantResult::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_START_MULTI_ENCHANT_SCROLL(0x22B, ExRequestStartMultiEnchantScroll::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_VIEW_MULTI_ENCHANT_RESULT(0x22C, ExRequestViewMultiEnchantResult::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_FINISH_MULTI_ENCHANT_SCROLL(0x22D, ExRequestFinishMultiEnchantScroll::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_CHANGE_MULTI_ENCHANT_SCROLL(0x22E, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_SET_MULTI_ENCHANT_ITEM_LIST(0x22F, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_MULTI_ENCHANT_ITEM_LIST(0x230, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_SET_MULTI_ENCHANT_ITEM_LIST(0x22F, ExRequestSetMultiEnchantItemList::new, ConnectionState.IN_GAME),
|
||||
EX_REQ_MULTI_ENCHANT_ITEM_LIST(0x230, ExRequestMultiEnchantItemList::new, ConnectionState.IN_GAME),
|
||||
EX_WORLDCASTLEWAR_SUPPORT_PLEDGE_FLAG_SET(0x231, null, ConnectionState.IN_GAME),
|
||||
EX_WORLDCASTLEWAR_SUPPORT_PLEDGE_INFO_SET(0x232, null, ConnectionState.IN_GAME),
|
||||
EX_REQ_HOMUNCULUS_PROB_LIST(0x233, null, ConnectionState.IN_GAME),
|
||||
|
@ -25,6 +25,7 @@ import org.l2jmobius.commons.network.IConnectionState;
|
||||
import org.l2jmobius.commons.network.IIncomingPacket;
|
||||
import org.l2jmobius.commons.network.IIncomingPackets;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.*;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.enchant.RequestEnchantItem;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestAnswerFriendInvite;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDel;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendInvite;
|
||||
|
@ -29,12 +29,12 @@ import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExItemAnnounce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.blessing.ExBlessOptionEnchant;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.blessing.ExBlessOptionPutItem;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
|
@ -27,8 +27,8 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExEnchantRetryToPutItemOk;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantRetryToPutItemFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantRetryToPutItemOk;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -54,13 +54,15 @@ public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (player.isInStoreMode())
|
||||
|
||||
if (player.isInStoreMode())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_DO_THAT_WHILE_IN_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
return;
|
||||
}
|
||||
else if (player.isProcessingTransaction() || player.isProcessingRequest())
|
||||
|
||||
if (player.isProcessingTransaction() || player.isProcessingRequest())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_SYSTEM_DURING_TRADING_PRIVATE_STORE_AND_WORKSHOP_SETUP);
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
@ -94,15 +96,15 @@ public class RequestNewEnchantRetryToPutItems implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final CombinationItem combinationItem = CombinationItemsData.getInstance().getItemsBySlots(itemOne.getId(), itemOne.getEnchantLevel(), itemTwo.getId());
|
||||
|
||||
// Not implemented or not able to merge!
|
||||
final CombinationItem combinationItem = CombinationItemsData.getInstance().getItemsBySlots(itemOne.getId(), itemOne.getEnchantLevel(), itemTwo.getId());
|
||||
if (combinationItem == null)
|
||||
{
|
||||
client.sendPacket(ExEnchantRetryToPutItemFail.STATIC_PACKET);
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(ExEnchantRetryToPutItemOk.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -24,7 +24,6 @@ import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import org.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
@ -37,11 +36,12 @@ import org.l2jmobius.gameserver.model.skill.CommonSkill;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExItemAnnounce;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@ -50,13 +50,12 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
|
||||
|
||||
private int _objectId;
|
||||
private int _supportId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_objectId = packet.readD();
|
||||
_supportId = packet.readD();
|
||||
packet.readC(); // Unknown.
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -99,27 +98,31 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
if (item.getEnchantLevel() != request.getEnchantLevel())
|
||||
{
|
||||
item.setEnchantLevel(request.getEnchantLevel());
|
||||
}
|
||||
|
||||
// template for scroll
|
||||
// Template for scroll.
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// template for support item, if exist
|
||||
// Template for support item, if exist.
|
||||
EnchantSupportItem supportTemplate = null;
|
||||
if (support != null)
|
||||
{
|
||||
if (support.getObjectId() != _supportId)
|
||||
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
if (supportTemplate == null)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
}
|
||||
|
||||
// first validation check - also over enchant check
|
||||
// First validation check, also over enchant check.
|
||||
if (!scrollTemplate.isValid(item, supportTemplate) || (Config.DISABLE_OVER_ENCHANTING && ((item.getEnchantLevel() == scrollTemplate.getMaxEnchantLevel()) || (!(item.getTemplate().getEnchantLimit() == 0) && (item.getEnchantLevel() == item.getTemplate().getEnchantLimit())))))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
@ -128,9 +131,8 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// fast auto-enchant cheat check
|
||||
// Lowered value to 500 (from 2000) On Essence, some enchantments are much faster than normal ones.
|
||||
if ((request.getTimestamp() == 0) || ((Chronos.currentTimeMillis() - request.getTimestamp()) < 500))
|
||||
// Fast auto-enchant cheat check.
|
||||
if ((request.getTimestamp() == 0) || ((Chronos.currentTimeMillis() - request.getTimestamp()) < 1000))
|
||||
{
|
||||
Util.handleIllegalPlayerAction(player, player + " use autoenchant program ", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
@ -138,7 +140,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy scroll
|
||||
// Attempting to destroy scroll.
|
||||
if (player.getInventory().destroyItem("Enchant", scroll.getObjectId(), 1, player, item) == null)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
||||
@ -148,7 +150,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// attempting to destroy support if exist
|
||||
// Attempting to destroy support if exists.
|
||||
if ((support != null) && (player.getInventory().destroyItem("Enchant", support.getObjectId(), 1, player, item) == null))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
||||
@ -161,7 +163,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
synchronized (item)
|
||||
{
|
||||
// last validation check
|
||||
// Last validation check.
|
||||
if ((item.getOwnerId() != player.getObjectId()) || !item.isEnchantable())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
@ -190,15 +192,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
{
|
||||
item.setEnchantLevel(Math.min(item.getEnchantLevel() + Rnd.get(supportTemplate.getRandomEnchantMin(), supportTemplate.getRandomEnchantMax()), supportTemplate.getMaxEnchantLevel()));
|
||||
}
|
||||
else if (scrollTemplate.isCursed())
|
||||
{
|
||||
item.setEnchantLevel(item.getEnchantLevel() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.setEnchantLevel(Math.min(item.getEnchantLevel() + Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
item.setEnchantLevel(item.getEnchantLevel() + Math.min(Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
}
|
||||
|
||||
item.updateDatabase();
|
||||
}
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SUCCESS, item));
|
||||
@ -225,7 +222,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
}
|
||||
|
||||
// announce the success
|
||||
// Announce the success.
|
||||
if ((item.getEnchantLevel() >= (item.isArmor() ? Config.MIN_ARMOR_ENCHANT_ANNOUNCE : Config.MIN_WEAPON_ENCHANT_ANNOUNCE)) //
|
||||
&& (item.getEnchantLevel() <= (item.isArmor() ? Config.MAX_ARMOR_ENCHANT_ANNOUNCE : Config.MAX_WEAPON_ENCHANT_ANNOUNCE)))
|
||||
{
|
||||
@ -249,7 +246,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
{
|
||||
it.forEachSkill(ItemSkillType.ON_ENCHANT, holder ->
|
||||
{
|
||||
// add skills bestowed from +4 armor
|
||||
// Add skills bestowed from +4 armor.
|
||||
if (item.getEnchantLevel() >= holder.getValue())
|
||||
{
|
||||
player.addSkill(holder.getSkill(), false);
|
||||
@ -257,7 +254,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
});
|
||||
}
|
||||
player.broadcastUserInfo(); // update user info
|
||||
player.broadcastUserInfo(); // Update user info.
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -265,7 +262,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
{
|
||||
if (scrollTemplate.isSafe())
|
||||
{
|
||||
// safe enchant - remain old value
|
||||
// Safe enchant: Remain old value.
|
||||
player.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SAFE_FAIL, item));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
@ -293,7 +290,7 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
// unequip item on enchant failure to avoid item skills stack
|
||||
// Unequip item on enchant failure to avoid item skills stack.
|
||||
if (item.isEquipped())
|
||||
{
|
||||
if (item.getEnchantLevel() > 0)
|
||||
@ -318,20 +315,21 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown() || ((supportTemplate != null) && supportTemplate.isBlessed()))
|
||||
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown() /* || ((supportTemplate != null) && supportTemplate.isDown()) */ || ((supportTemplate != null) && supportTemplate.isBlessed()))
|
||||
{
|
||||
// blessed enchant - enchant value down by 1
|
||||
if (scrollTemplate.isBlessedDown())
|
||||
// Blessed enchant: Enchant value down by 1.
|
||||
if (scrollTemplate.isBlessedDown() /* || ((supportTemplate != null) && supportTemplate.isDown()) */)
|
||||
{
|
||||
client.sendPacket(SystemMessageId.THE_ENCHANT_VALUE_IS_DECREASED_BY_1);
|
||||
item.setEnchantLevel(item.getEnchantLevel() - 1);
|
||||
}
|
||||
else // blessed enchant - clear enchant value
|
||||
else // Blessed enchant: Clear enchant value.
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
item.setEnchantLevel(0);
|
||||
}
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SUCCESS, item));
|
||||
item.updateDatabase();
|
||||
player.sendPacket(new EnchantResult(EnchantResult.BLESSED_FAIL, 0, 0));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (item.getEnchantLevel() > 0)
|
||||
@ -357,10 +355,10 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
// enchant failed, destroy item
|
||||
// Enchant failed, destroy item.
|
||||
if (player.getInventory().destroyItem("Enchant", item, player, null) == null)
|
||||
{
|
||||
// unable to destroy item, cheater ?
|
||||
// Unable to destroy item, cheater?
|
||||
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from " + player + ", possible cheater !", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new EnchantResult(EnchantResult.ERROR, 0, 0));
|
||||
@ -402,7 +400,6 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
if (count > 0)
|
||||
{
|
||||
crystals = player.getInventory().addItem("Enchant", crystalId, count, player, item);
|
||||
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S1_X_S2);
|
||||
sm.addItemName(crystals);
|
||||
sm.addLong(count);
|
||||
@ -450,11 +447,9 @@ public class RequestEnchantItem implements IClientIncomingPacket
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendItemList();
|
||||
|
||||
player.broadcastUserInfo();
|
||||
request.setProcessing(false);
|
||||
player.broadcastUserInfo(UserInfoType.ENCHANTLEVEL);
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -25,7 +25,8 @@ import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantScrollItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantScrollItemResult;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -33,13 +34,12 @@ import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantScrollItemResu
|
||||
public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
{
|
||||
private int _scrollObjectId;
|
||||
private int _enchantObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_scrollObjectId = packet.readD();
|
||||
_enchantObjectId = packet.readD();
|
||||
packet.readD(); // enchantObjectId?
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -52,20 +52,17 @@ public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if ((request == null) || request.isProcessing())
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return;
|
||||
player.addRequest(new EnchantItemRequest(player, _scrollObjectId));
|
||||
}
|
||||
|
||||
request.setEnchantingItem(_enchantObjectId);
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
|
||||
final Item item = request.getEnchantingItem();
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
if ((item == null) || (scroll == null))
|
||||
if ((scroll == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
player.sendPacket(new ExPutEnchantScrollItemResult(0));
|
||||
request.setEnchantingItem(Player.ID_NONE);
|
||||
@ -76,7 +73,7 @@ public class RequestExAddEnchantScrollItem implements IClientIncomingPacket
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if ((scrollTemplate == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
player.sendPacket(new ExPutEnchantScrollItemResult(0));
|
||||
request.setEnchantingScroll(Player.ID_NONE);
|
@ -14,13 +14,14 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
|
||||
/**
|
||||
* @author KenM
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -26,7 +26,9 @@ import org.l2jmobius.gameserver.model.item.enchant.EnchantSupportItem;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
@ -67,7 +69,7 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
final Item support = request.getSupportItem();
|
||||
if ((item == null) || (scroll == null) || (support == null))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
request.setEnchantingItem(Player.ID_NONE);
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
@ -78,7 +80,7 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
final EnchantSupportItem supportTemplate = EnchantItemData.getInstance().getSupportItem(support);
|
||||
if ((scrollTemplate == null) || (supportTemplate == null) || !scrollTemplate.isValid(item, supportTemplate))
|
||||
{
|
||||
// message may be custom
|
||||
// Message may be custom.
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
player.sendPacket(new ExPutEnchantSupportItemResult(0));
|
||||
@ -88,5 +90,6 @@ public class RequestExTryToPutEnchantSupportItem implements IClientIncomingPacke
|
||||
request.setSupportItem(support.getObjectId());
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
player.sendPacket(new ExPutEnchantSupportItemResult(_supportObjectId));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.clientpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -26,7 +26,9 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.PacketLogger;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ExPutEnchantTargetItemResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
@ -58,6 +60,7 @@ public class RequestExTryToPutEnchantTargetItem implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
request.setEnchantingItem(_objectId);
|
||||
request.setEnchantLevel(player.getInventory().getItemByObjectId(_objectId).getEnchantLevel());
|
||||
|
||||
final Item item = request.getEnchantingItem();
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
@ -78,7 +81,9 @@ public class RequestExTryToPutEnchantTargetItem implements IClientIncomingPacket
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
player.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestFinishMultiEnchantScroll implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) != null)
|
||||
{
|
||||
player.removeRequest(EnchantItemRequest.class);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,374 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantResultType;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.EnchantResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestMultiEnchantItemList implements IClientIncomingPacket
|
||||
{
|
||||
private int _useLateAnnounce;
|
||||
private int _slotId;
|
||||
private final Map<Integer, Integer> _itemObjectId = new HashMap<>();
|
||||
private final Map<Integer, String> _result = new HashMap<>();
|
||||
private final Map<Integer, int[]> _successEnchant = new HashMap<>();
|
||||
private final Map<Integer, Integer> _failureEnchant = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @code slot_id @code item_holder
|
||||
*/
|
||||
private final Map<Integer, ItemHolder> _failureReward = new HashMap<>();
|
||||
|
||||
protected static final Logger LOGGER_ENCHANT = Logger.getLogger("enchant.items");
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_useLateAnnounce = packet.readC();
|
||||
_slotId = packet.readD();
|
||||
for (int i = 1; packet.getReadableBytes() != 0; i++)
|
||||
{
|
||||
_itemObjectId.put(i, packet.readD());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if (request == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((request.getEnchantingScroll() == null) || request.isProcessing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item scroll = request.getEnchantingScroll();
|
||||
if (scroll.getCount() < _slotId)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 1));
|
||||
Logger.getLogger("MultiEnchant - player " + player.getObjectId() + " " + player.getName() + " trying enchant items, when scrolls count less than items;");
|
||||
}
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int[] slots = new int[_slotId];
|
||||
for (int i = 1; i <= _slotId; i++)
|
||||
{
|
||||
if (!request.checkMultiEnchantingItemsByObjectId(_itemObjectId.get(i)))
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
slots[i - 1] = getMultiEnchantingSlotByObjectId(request, _itemObjectId.get(i));
|
||||
}
|
||||
|
||||
_itemObjectId.clear();
|
||||
request.setProcessing(true);
|
||||
|
||||
for (int slotCounter = 0; slotCounter < slots.length; slotCounter++)
|
||||
{
|
||||
final int i = slots[slotCounter];
|
||||
if ((i == -1) || (request.getMultiEnchantingItemsBySlot(i) == -1))
|
||||
{
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
final Item enchantItem = player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i));
|
||||
if (scrollTemplate.getMaxEnchantLevel() < enchantItem.getEnchantLevel())
|
||||
{
|
||||
Logger.getLogger("MultiEnchant - player " + player.getObjectId() + " " + player.getName() + " trying over-enchant item " + enchantItem.getItemName() + " " + enchantItem.getObjectId());
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getInventory().destroyItemByItemId("Enchant", scroll.getId(), 1, player, enchantItem) == null)
|
||||
{
|
||||
player.removeRequest(request.getClass());
|
||||
return;
|
||||
}
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
synchronized (enchantItem)
|
||||
{
|
||||
if ((enchantItem.getOwnerId() != player.getObjectId()) || !enchantItem.isEnchantable())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
player.removeRequest(request.getClass());
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantResultType resultType = scrollTemplate.calculateSuccess(player, enchantItem, null);
|
||||
switch (resultType)
|
||||
{
|
||||
case ERROR:
|
||||
{
|
||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
||||
player.removeRequest(request.getClass());
|
||||
_result.put(slots[i - 1], "ERROR");
|
||||
break;
|
||||
}
|
||||
case SUCCESS:
|
||||
{
|
||||
// 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(player, enchantItem) > 0)
|
||||
{
|
||||
enchantItem.setEnchantLevel(enchantItem.getEnchantLevel() + Math.min(Rnd.get(scrollTemplate.getRandomEnchantMin(), scrollTemplate.getRandomEnchantMax()), scrollTemplate.getMaxEnchantLevel()));
|
||||
enchantItem.updateDatabase();
|
||||
}
|
||||
_result.put(i, "SUCCESS");
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FAILURE:
|
||||
{
|
||||
if (scrollTemplate.isSafe())
|
||||
{
|
||||
// Safe enchant: Remain old value.
|
||||
player.sendPacket(SystemMessageId.ENCHANT_FAILED_THE_ENCHANT_SKILL_FOR_THE_CORRESPONDING_ITEM_WILL_BE_EXACTLY_RETAINED);
|
||||
player.sendPacket(new EnchantResult(EnchantResult.SAFE_FAIL, enchantItem));
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Safe Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scrollTemplate.isBlessed() || scrollTemplate.isBlessedDown())
|
||||
{
|
||||
// Blessed enchant: Enchant value down by 1.
|
||||
if (scrollTemplate.isBlessedDown())
|
||||
{
|
||||
client.sendPacket(SystemMessageId.THE_ENCHANT_VALUE_IS_DECREASED_BY_1);
|
||||
enchantItem.setEnchantLevel(enchantItem.getEnchantLevel() - 1);
|
||||
}
|
||||
else // Blessed enchant: Clear enchant value.
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THE_BLESSED_ENCHANT_FAILED_THE_ENCHANT_VALUE_OF_THE_ITEM_BECAME_0);
|
||||
enchantItem.setEnchantLevel(0);
|
||||
}
|
||||
_result.put(i, "BLESSED_FAIL");
|
||||
enchantItem.updateDatabase();
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Blessed Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enchant failed, destroy item.
|
||||
if (player.getInventory().destroyItem("Enchant", enchantItem, player, null) == null)
|
||||
{
|
||||
// Unable to destroy item, cheater?
|
||||
Util.handleIllegalPlayerAction(player, "Unable to delete item on enchant failure from " + player + ", possible cheater !", Config.DEFAULT_PUNISH);
|
||||
player.removeRequest(request.getClass());
|
||||
_result.put(i, "ERROR");
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Unable to destroy, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
World.getInstance().removeObject(enchantItem);
|
||||
|
||||
int count = 0;
|
||||
if (enchantItem.getTemplate().isCrystallizable())
|
||||
{
|
||||
count = Math.max(0, enchantItem.getCrystalCount() - ((enchantItem.getTemplate().getCrystalCount() + 1) / 2));
|
||||
}
|
||||
|
||||
Item crystals = null;
|
||||
final int crystalId = enchantItem.getTemplate().getCrystalItemId();
|
||||
if (count > 0)
|
||||
{
|
||||
crystals = player.getInventory().addItem("Enchant", crystalId, count, player, enchantItem);
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S1_X_S2);
|
||||
sm.addItemName(crystals);
|
||||
sm.addLong(count);
|
||||
player.sendPacket(sm);
|
||||
ItemHolder itemHolder = new ItemHolder(crystalId, count);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
}
|
||||
|
||||
if (!Config.FORCE_INVENTORY_UPDATE && (crystals != null))
|
||||
{
|
||||
iu.addItem(crystals);
|
||||
}
|
||||
|
||||
if ((crystalId == 0) || (count == 0))
|
||||
{
|
||||
ItemHolder itemHolder = new ItemHolder(0, 0);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
_result.put(i, "NO_CRYSTAL");
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHolder itemHolder = new ItemHolder(0, 0);
|
||||
_failureReward.put(_failureReward.size() + 1, itemHolder);
|
||||
_result.put(i, "FAIL");
|
||||
}
|
||||
|
||||
if (Config.LOG_ITEM_ENCHANTS)
|
||||
{
|
||||
if (enchantItem.getEnchantLevel() > 0)
|
||||
{
|
||||
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", +" + enchantItem.getEnchantLevel() + " " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER_ENCHANT.info("Fail, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", " + enchantItem.getName() + "(" + enchantItem.getCount() + ") [" + enchantItem.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int slotCounter = 0; slotCounter < slots.length; slotCounter++)
|
||||
{
|
||||
final int i = slots[slotCounter];
|
||||
if (_result.get(i).equals("SUCCESS"))
|
||||
{
|
||||
int[] intArray = new int[2];
|
||||
intArray[0] = request.getMultiEnchantingItemsBySlot(i);
|
||||
intArray[1] = player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i)).getEnchantLevel();
|
||||
_successEnchant.put(i, intArray);
|
||||
}
|
||||
else if (_result.get(i).equals("NO_CRYSTAL") || _result.get(i).equals("FAIL"))
|
||||
{
|
||||
_failureEnchant.put(i, request.getMultiEnchantingItemsBySlot(i));
|
||||
request.changeMultiEnchantingItemsBySlot(i, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, true));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : _failureReward.keySet())
|
||||
{
|
||||
request.addMultiEnchantFailItems(_failureReward.get(i));
|
||||
}
|
||||
request.setProcessing(false);
|
||||
|
||||
player.sendItemList();
|
||||
player.broadcastUserInfo();
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, true));
|
||||
|
||||
if (_useLateAnnounce == 1)
|
||||
{
|
||||
request.setMultiSuccessEnchantList(_successEnchant);
|
||||
request.setMultiFailureEnchantList(_failureEnchant);
|
||||
}
|
||||
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, _successEnchant, _failureEnchant));
|
||||
}
|
||||
|
||||
public int getMultiEnchantingSlotByObjectId(EnchantItemRequest request, int objectId)
|
||||
{
|
||||
int slotId = -1;
|
||||
for (int i = 1; i <= request.getMultiEnchantingItemsCount(); i++)
|
||||
{
|
||||
if ((request.getMultiEnchantingItemsCount() == 0) || (objectId == 0))
|
||||
{
|
||||
return slotId;
|
||||
}
|
||||
else if (request.getMultiEnchantingItemsBySlot(i) == objectId)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return slotId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultSetMultiEnchantItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestSetMultiEnchantItemList implements IClientIncomingPacket
|
||||
{
|
||||
private int _slotId;
|
||||
private final Map<Integer, Integer> _itemObjectId = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_slotId = packet.readD();
|
||||
for (int i = 1; packet.getReadableBytes() != 0; i++)
|
||||
{
|
||||
_itemObjectId.put(i, packet.readD());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
if (request.getMultiEnchantingItemsBySlot(_slotId) != -1)
|
||||
{
|
||||
request.clearMultiEnchantingItemsBySlot();
|
||||
for (int i = 1; i <= _slotId; i++)
|
||||
{
|
||||
request.addMultiEnchantingItems(i, _itemObjectId.get(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
request.addMultiEnchantingItems(_slotId, _itemObjectId.get(_slotId));
|
||||
}
|
||||
|
||||
_itemObjectId.clear();
|
||||
player.sendPacket(new ExResultSetMultiEnchantItemList(player, 0));
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, true));
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.enchant.EnchantScroll;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResetSelectMultiEnchantScroll;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestStartMultiEnchantScroll implements IClientIncomingPacket
|
||||
{
|
||||
private int _scrollObjectId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_scrollObjectId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
player.addRequest(new EnchantItemRequest(player, _scrollObjectId));
|
||||
}
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
final Item scroll = player.getInventory().getItemByObjectId(_scrollObjectId);
|
||||
final EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
|
||||
if (scrollTemplate == null)
|
||||
{
|
||||
player.sendPacket(new ExResetSelectMultiEnchantScroll(player, _scrollObjectId, 1));
|
||||
return;
|
||||
}
|
||||
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
|
||||
player.sendPacket(new ExResetSelectMultiEnchantScroll(player, _scrollObjectId, 0));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.multi.ExResultMultiEnchantItemList;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestViewMultiEnchantResult implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
packet.readC();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = player.getRequest(EnchantItemRequest.class);
|
||||
player.sendPacket(new ExResultMultiEnchantItemList(player, request.getMultiSuccessEnchantList(), request.getMultiFailureEnchantList(), true));
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.enchant.single;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.ResetEnchantItemFailRewardInfo;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestEnchantFailRewardInfo implements IClientIncomingPacket
|
||||
{
|
||||
private int _itemobjectid;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_itemobjectid = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final Player player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item addedItem = player.getInventory().getItemByObjectId(_itemobjectid);
|
||||
if (addedItem != null)
|
||||
{
|
||||
player.sendPacket(new ResetEnchantItemFailRewardInfo(player));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.enchant.single;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExRequestViewEnchantResult implements IClientIncomingPacket
|
||||
{
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,39 +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.serverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemFail implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemFail STATIC_PACKET = new ExEnchantRetryToPutItemFail();
|
||||
|
||||
private ExEnchantRetryToPutItemFail()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_FAIL.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,39 +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.serverpackets;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExEnchantRetryToPutItemOk implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExEnchantRetryToPutItemOk STATIC_PACKET = new ExEnchantRetryToPutItemOk();
|
||||
|
||||
private ExEnchantRetryToPutItemOk()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENCHANT_RETRY_TO_PUT_ITEM_OK.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -14,20 +14,21 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public class EnchantResult implements IClientOutgoingPacket
|
||||
{
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int FAIL = 1;
|
||||
public static final int ERROR = 2;
|
||||
public static final int BLESSED_FAIL = 3;
|
||||
public static final int SUCCESS = 0; /* 11, 12 */
|
||||
public static final int FAIL = 1; /* 6, 9 */
|
||||
public static final int ERROR = 2; /* 10 */
|
||||
public static final int BLESSED_FAIL = 3; /* 7 */
|
||||
public static final int NO_CRYSTAL = 4;
|
||||
public static final int SAFE_FAIL = 5;
|
||||
public static final int SAFE_FAIL = 5; /* 8 */
|
||||
|
||||
private final int _result;
|
||||
private final int _crystal;
|
||||
@ -62,16 +63,9 @@ public class EnchantResult implements IClientOutgoingPacket
|
||||
packet.writeD(_result);
|
||||
packet.writeD(_crystal);
|
||||
packet.writeQ(_count);
|
||||
// Guessing.
|
||||
// With 166 options became 3x write integers instead of shorts and enchant level moved bellow.
|
||||
// Commenting until actually knowing.
|
||||
// for (int option : _enchantOptions)
|
||||
// {
|
||||
// packet.writeD(option);
|
||||
// }
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(0); // option
|
||||
packet.writeD(_enchantLevel); // Confirmed.
|
||||
return true;
|
||||
}
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author nBd
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author nBd
|
@ -14,10 +14,11 @@
|
||||
* 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.serverpackets;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
@ -14,7 +14,7 @@
|
||||
* 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;
|
||||
package org.l2jmobius.gameserver.network.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
@ -22,7 +22,8 @@ import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExRemoveEnchantSupportItemResult;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.single.ChangedEnchantTargetItemProbabilityList;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
@ -51,12 +52,13 @@ public class RequestExRemoveEnchantSupportItem implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
final Item supportItem = request.getSupportItem();
|
||||
if ((supportItem == null) || (supportItem.getCount() < 1))
|
||||
if ((supportItem == null) || (supportItem.getCount() >= 0))
|
||||
{
|
||||
request.setSupportItem(Player.ID_NONE);
|
||||
}
|
||||
|
||||
request.setTimestamp(Chronos.currentTimeMillis());
|
||||
|
||||
player.sendPacket(ExRemoveEnchantSupportItemResult.STATIC_PACKET);
|
||||
player.sendPacket(new ChangedEnchantTargetItemProbabilityList(player, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
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.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ResetEnchantItemFailRewardInfo implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
|
||||
public ResetEnchantItemFailRewardInfo(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
if ((request.getEnchantingItem() == null) || request.isProcessing() || (request.getEnchantingScroll() == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantScroll enchantScroll = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll());
|
||||
final Item enchantItem = request.getEnchantingItem();
|
||||
Item addedItem = enchantItem;
|
||||
EnchantSupportItem enchantSupportItem = null;
|
||||
ItemHolder result = null;
|
||||
if (request.getSupportItem() != null)
|
||||
{
|
||||
enchantSupportItem = EnchantItemData.getInstance().getSupportItem(request.getSupportItem());
|
||||
}
|
||||
if (enchantScroll.isBlessed() || ((request.getSupportItem() != null) && (enchantSupportItem != null) && enchantSupportItem.isBlessed()))
|
||||
{
|
||||
addedItem.setEnchantLevel(0);
|
||||
}
|
||||
else if (enchantScroll.isBlessedDown() /* || ((request.getSupportItem() != null) && (enchantSupportItem != null) && enchantSupportItem.isDown()) */)
|
||||
{
|
||||
addedItem.setEnchantLevel(enchantItem.getEnchantLevel() - 1);
|
||||
}
|
||||
else if (enchantScroll.isSafe())
|
||||
{
|
||||
addedItem.setEnchantLevel(enchantItem.getEnchantLevel());
|
||||
}
|
||||
else
|
||||
{
|
||||
addedItem = null;
|
||||
if (enchantItem.getTemplate().isCrystallizable())
|
||||
{
|
||||
result = new ItemHolder(enchantItem.getTemplate().getCrystalItemId(), Math.max(0, enchantItem.getCrystalCount() - ((enchantItem.getTemplate().getCrystalCount() + 1) / 2)));
|
||||
}
|
||||
}
|
||||
|
||||
OutgoingPackets.EX_RES_ENCHANT_ITEM_FAIL_REWARD_INFO.writeId(packet);
|
||||
packet.writeD(enchantItem.getObjectId());
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
packet.writeD(1); // Loop count.
|
||||
packet.writeD(result.getId());
|
||||
packet.writeD((int) result.getCount());
|
||||
}
|
||||
else if (addedItem != null)
|
||||
{
|
||||
packet.writeD(1); // Loop count.
|
||||
packet.writeD(enchantItem.getId());
|
||||
packet.writeD(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0); // Loop count.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResetSelectMultiEnchantScroll implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final int _scrollObjectId;
|
||||
private final int _resultType;
|
||||
|
||||
public ExResetSelectMultiEnchantScroll(Player player, int scrollObjectId, int resultType)
|
||||
{
|
||||
_player = player;
|
||||
_scrollObjectId = scrollObjectId;
|
||||
_resultType = resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
if (request.getEnchantingScroll() == null)
|
||||
{
|
||||
request.setEnchantingScroll(_scrollObjectId);
|
||||
}
|
||||
|
||||
OutgoingPackets.EX_RES_SELECT_MULTI_ENCHANT_SCROLL.writeId(packet);
|
||||
|
||||
packet.writeD(_scrollObjectId);
|
||||
packet.writeD(_resultType);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResultMultiEnchantItemList implements IClientOutgoingPacket
|
||||
{
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int FAIL = 1;
|
||||
public static final int ERROR = 2;
|
||||
private final Player _player;
|
||||
private boolean _error;
|
||||
private boolean _isResult;
|
||||
private Map<Integer, int[]> _successEnchant = new HashMap<>();
|
||||
private Map<Integer, Integer> _failureEnchant = new HashMap<>();
|
||||
private Map<Integer, ItemHolder> _failureReward = new HashMap<>();
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, boolean error)
|
||||
{
|
||||
_player = player;
|
||||
_error = error;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, ItemHolder> failureReward)
|
||||
{
|
||||
_player = player;
|
||||
_failureReward = failureReward;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, int[]> successEnchant, Map<Integer, Integer> failureEnchant)
|
||||
{
|
||||
_player = player;
|
||||
_successEnchant = successEnchant;
|
||||
_failureEnchant = failureEnchant;
|
||||
}
|
||||
|
||||
public ExResultMultiEnchantItemList(Player player, Map<Integer, int[]> successEnchant, Map<Integer, Integer> failureEnchant, boolean isResult)
|
||||
{
|
||||
_player = player;
|
||||
_successEnchant = successEnchant;
|
||||
_failureEnchant = failureEnchant;
|
||||
_isResult = isResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
OutgoingPackets.EX_RES_MULTI_ENCHANT_ITEM_LIST.writeId(packet);
|
||||
|
||||
if (_error)
|
||||
{
|
||||
packet.writeC(0);
|
||||
return true;
|
||||
}
|
||||
packet.writeC(1);
|
||||
|
||||
/* EnchantSuccessItem */
|
||||
if (_failureReward.size() == 0)
|
||||
{
|
||||
packet.writeD(_successEnchant.size());
|
||||
if (_successEnchant.size() != 0)
|
||||
{
|
||||
for (int i : _successEnchant.keySet())
|
||||
{
|
||||
int[] intArray = _successEnchant.get(i);
|
||||
packet.writeD(intArray[0]);
|
||||
packet.writeD(intArray[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailItem */
|
||||
packet.writeD(_failureEnchant.size());
|
||||
if (_failureEnchant.size() != 0)
|
||||
{
|
||||
for (int i : _failureEnchant.keySet())
|
||||
{
|
||||
packet.writeD(_failureEnchant.get(i));
|
||||
packet.writeD(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailRewardItem */
|
||||
if (((_successEnchant.size() == 0) && (request.getMultiFailItemsCount() != 0)) || (_isResult && (request.getMultiFailItemsCount() != 0)))
|
||||
{
|
||||
packet.writeD(request.getMultiFailItemsCount());
|
||||
_failureReward = request.getMultiEnchantFailItems();
|
||||
for (int i : _failureReward.keySet())
|
||||
{
|
||||
ItemHolder itemHolder = _failureReward.get(i);
|
||||
packet.writeD(itemHolder.getId());
|
||||
packet.writeD((int) itemHolder.getCount());
|
||||
}
|
||||
if (_isResult)
|
||||
{
|
||||
request.clearMultiSuccessEnchantList();
|
||||
request.clearMultiFailureEnchantList();
|
||||
}
|
||||
request.clearMultiFailReward();
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
/* EnchantFailChallengePointInfo */
|
||||
packet.writeD(1);
|
||||
packet.writeD(0);
|
||||
packet.writeD(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.multi;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ExResultSetMultiEnchantItemList implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final int _resultType;
|
||||
|
||||
public ExResultSetMultiEnchantItemList(Player player, int resultType)
|
||||
{
|
||||
_player = player;
|
||||
_resultType = resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
OutgoingPackets.EX_RES_SET_MULTI_ENCHANT_ITEM_LIST.writeId(packet);
|
||||
packet.writeD(_resultType);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* 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.serverpackets.enchant.single;
|
||||
|
||||
import static org.l2jmobius.gameserver.model.stats.Stat.ENCHANT_RATE;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Index
|
||||
*/
|
||||
public class ChangedEnchantTargetItemProbabilityList implements IClientOutgoingPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final boolean _isMulti;
|
||||
|
||||
public ChangedEnchantTargetItemProbabilityList(Player player, Boolean isMulti)
|
||||
{
|
||||
_player = player;
|
||||
_isMulti = isMulti;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
if (_player.getRequest(EnchantItemRequest.class) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final EnchantItemRequest request = _player.getRequest(EnchantItemRequest.class);
|
||||
|
||||
if ((!_isMulti && (request.getEnchantingItem() == null)) || request.isProcessing() || (request.getEnchantingScroll() == null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int count = 1;
|
||||
if (_isMulti)
|
||||
{
|
||||
count = request.getMultiEnchantingItemsCount();
|
||||
}
|
||||
|
||||
final double supportRate = getSupportRate(request);
|
||||
final double passiveRate = getPassiveRate();
|
||||
|
||||
OutgoingPackets.EX_CHANGED_ENCHANT_TARGET_ITEM_PROB_LIST.writeId(packet);
|
||||
packet.writeD(count);
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
// 100,00 % = 10000, because last 2 numbers going after float comma.
|
||||
double baseRate;
|
||||
if (!_isMulti || (request.getMultiEnchantingItemsBySlot(i) != 0))
|
||||
{
|
||||
baseRate = getBaseRate(request, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
baseRate = 0;
|
||||
}
|
||||
double totalRate = baseRate + supportRate + passiveRate;
|
||||
if (totalRate >= 10000)
|
||||
{
|
||||
totalRate = 10000;
|
||||
}
|
||||
if (!_isMulti)
|
||||
{
|
||||
packet.writeD(request.getEnchantingItem().getObjectId());
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(request.getMultiEnchantingItemsBySlot(i));
|
||||
}
|
||||
packet.writeD((int) totalRate); // Total success.
|
||||
packet.writeD((int) baseRate); // Base success.
|
||||
packet.writeD((int) supportRate); // Support success.
|
||||
packet.writeD((int) passiveRate); // Passive success (items, skills).
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getBaseRate(EnchantItemRequest request, int i)
|
||||
{
|
||||
double baseRate;
|
||||
if (!_isMulti)
|
||||
{
|
||||
baseRate = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll()).getChance(_player, request.getEnchantingItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Item item = _player.getInventory().getItemByObjectId(request.getMultiEnchantingItemsBySlot(i));
|
||||
baseRate = EnchantItemData.getInstance().getEnchantScroll(request.getEnchantingScroll()).getChance(_player, item);
|
||||
}
|
||||
baseRate = baseRate * 100;
|
||||
return (int) baseRate;
|
||||
}
|
||||
|
||||
private int getSupportRate(EnchantItemRequest request)
|
||||
{
|
||||
double supportRate = 0;
|
||||
if (!_isMulti && (request.getSupportItem() != null))
|
||||
{
|
||||
supportRate = EnchantItemData.getInstance().getSupportItem(request.getSupportItem()).getBonusRate();
|
||||
supportRate = supportRate * 100;
|
||||
}
|
||||
return (int) supportRate;
|
||||
}
|
||||
|
||||
private int getPassiveRate()
|
||||
{
|
||||
double passiveRate = 0;
|
||||
if (_player.getStat().getValue(ENCHANT_RATE) != 0)
|
||||
{
|
||||
passiveRate = _player.getStat().getValue(ENCHANT_RATE);
|
||||
passiveRate = passiveRate * 100;
|
||||
}
|
||||
return (int) passiveRate;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user