Fixed item blessing.
This commit is contained in:
@@ -20,14 +20,6 @@
|
|||||||
<enchant id="956" targetGrade="D" maxEnchant="16" safeEnchant="4" scrollGroupId="0" /> <!-- Default scroll groups binding. -->
|
<enchant id="956" targetGrade="D" maxEnchant="16" safeEnchant="4" scrollGroupId="0" /> <!-- Default scroll groups binding. -->
|
||||||
<enchant id="93411" targetGrade="D" maxEnchant="16" safeEnchant="4" scrollGroupId="0" /> <!-- Default scroll groups binding. -->
|
<enchant id="93411" targetGrade="D" maxEnchant="16" safeEnchant="4" scrollGroupId="0" /> <!-- Default scroll groups binding. -->
|
||||||
|
|
||||||
<enchant id="94184" targetGrade="C" maxEnchant="1" isBlessed="true"/>
|
|
||||||
<enchant id="94184" targetGrade="A" maxEnchant="1" isBlessed="true"/>
|
|
||||||
|
|
||||||
<enchant id="94208" targetGrade="C" maxEnchant="1" isBlessed="true"/>
|
|
||||||
<enchant id="94208" targetGrade="A" maxEnchant="1" isBlessed="true"/>
|
|
||||||
<enchant id="94208" targetGrade="B" maxEnchant="1" isBlessed="true"/>
|
|
||||||
<enchant id="94208" targetGrade="S" maxEnchant="1" isBlessed="true"/>
|
|
||||||
|
|
||||||
<!-- Blessed Scrolls: Enchant Weapon -->
|
<!-- Blessed Scrolls: Enchant Weapon -->
|
||||||
<enchant id="6577" targetGrade="S" maxEnchant="16" />
|
<enchant id="6577" targetGrade="S" maxEnchant="16" />
|
||||||
<enchant id="6569" targetGrade="A" maxEnchant="16" />
|
<enchant id="6569" targetGrade="A" maxEnchant="16" />
|
||||||
|
@@ -20,6 +20,7 @@ import org.l2jmobius.gameserver.handler.IItemHandler;
|
|||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.blessing.ExOpenBlessOptionScroll;
|
import org.l2jmobius.gameserver.network.serverpackets.blessing.ExOpenBlessOptionScroll;
|
||||||
|
|
||||||
@@ -46,6 +47,8 @@ public class BlessingScrolls implements IItemHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.getVariables().set(PlayerVariables.USED_BLESS_SCROLL_ID, item.getId());
|
||||||
|
|
||||||
player.sendPacket(new ExOpenBlessOptionScroll(item.getId()));
|
player.sendPacket(new ExOpenBlessOptionScroll(item.getId()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -17,15 +17,10 @@
|
|||||||
package org.l2jmobius.gameserver.data.xml;
|
package org.l2jmobius.gameserver.data.xml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
@@ -47,7 +42,6 @@ public class EnchantItemData implements IXmlReader
|
|||||||
|
|
||||||
private final Map<Integer, EnchantScroll> _scrolls = new HashMap<>();
|
private final Map<Integer, EnchantScroll> _scrolls = new HashMap<>();
|
||||||
private final Map<Integer, EnchantSupportItem> _supports = new HashMap<>();
|
private final Map<Integer, EnchantSupportItem> _supports = new HashMap<>();
|
||||||
private final List<Entry<Integer, EnchantScroll>> _blessingScrolls = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new enchant item data.
|
* Instantiates a new enchant item data.
|
||||||
@@ -62,11 +56,9 @@ public class EnchantItemData implements IXmlReader
|
|||||||
{
|
{
|
||||||
_scrolls.clear();
|
_scrolls.clear();
|
||||||
_supports.clear();
|
_supports.clear();
|
||||||
_blessingScrolls.clear();
|
|
||||||
parseDatapackFile("data/EnchantItemData.xml");
|
parseDatapackFile("data/EnchantItemData.xml");
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _scrolls.size() + " enchant scrolls.");
|
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _scrolls.size() + " enchant scrolls.");
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _supports.size() + " support items.");
|
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _supports.size() + " support items.");
|
||||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _blessingScrolls.size() + " blessing scrolls.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,15 +93,8 @@ public class EnchantItemData implements IXmlReader
|
|||||||
item.addItem(parseInteger(cd.getAttributes(), "id"));
|
item.addItem(parseInteger(cd.getAttributes(), "id"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set.contains("isBlessed"))
|
|
||||||
{
|
|
||||||
_blessingScrolls.add(new AbstractMap.SimpleEntry<>(item.getId(), item));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_scrolls.put(item.getId(), item);
|
_scrolls.put(item.getId(), item);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (NullPointerException e)
|
catch (NullPointerException e)
|
||||||
{
|
{
|
||||||
LOGGER.warning(getClass().getSimpleName() + ": Unexistent enchant scroll: " + set.getString("id") + " defined in enchant data!");
|
LOGGER.warning(getClass().getSimpleName() + ": Unexistent enchant scroll: " + set.getString("id") + " defined in enchant data!");
|
||||||
@@ -173,11 +158,6 @@ public class EnchantItemData implements IXmlReader
|
|||||||
return _supports.get(item.getId());
|
return _supports.get(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Entry<Integer, EnchantScroll>> getBlessingScrolls(int itemId)
|
|
||||||
{
|
|
||||||
return _blessingScrolls.stream().filter(it -> it.getKey() == itemId).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the single instance of EnchantItemData.
|
* Gets the single instance of EnchantItemData.
|
||||||
* @return single instance of EnchantItemData
|
* @return single instance of EnchantItemData
|
||||||
|
@@ -77,6 +77,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String STAT_INT = "STAT_INT";
|
public static final String STAT_INT = "STAT_INT";
|
||||||
public static final String STAT_WIT = "STAT_WIT";
|
public static final String STAT_WIT = "STAT_WIT";
|
||||||
public static final String STAT_MEN = "STAT_MEN";
|
public static final String STAT_MEN = "STAT_MEN";
|
||||||
|
public static final String USED_BLESS_SCROLL_ID = "USED_BLESS_SCROLL_ID";
|
||||||
|
|
||||||
private final int _objectId;
|
private final int _objectId;
|
||||||
|
|
||||||
|
@@ -16,21 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets.blessing;
|
package org.l2jmobius.gameserver.network.clientpackets.blessing;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
import org.l2jmobius.gameserver.enums.ItemSkillType;
|
import org.l2jmobius.gameserver.enums.ItemSkillType;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.actor.request.BlessingItemRequest;
|
import org.l2jmobius.gameserver.model.actor.request.BlessingItemRequest;
|
||||||
import org.l2jmobius.gameserver.model.items.Item;
|
import org.l2jmobius.gameserver.model.items.Item;
|
||||||
import org.l2jmobius.gameserver.model.items.enchant.EnchantResultType;
|
|
||||||
import org.l2jmobius.gameserver.model.items.enchant.EnchantScroll;
|
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.CommonSkill;
|
import org.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
@@ -48,7 +44,6 @@ import org.l2jmobius.gameserver.util.Util;
|
|||||||
*/
|
*/
|
||||||
public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
private int _itemObjId;
|
private int _itemObjId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,8 +69,16 @@ public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Optional<Map.Entry<Integer, EnchantScroll>> targetScroll = EnchantItemData.getInstance().getBlessingScrolls(targetInstance.getId()).stream().filter(it -> it.getValue().getGrade() == targetInstance.getItem().getCrystalType()).findFirst();
|
ItemInstance targetScroll = player.getInventory().getItemByItemId(player.getVariables().getInt(PlayerVariables.USED_BLESS_SCROLL_ID, 0));
|
||||||
if (targetScroll.isEmpty())
|
if (targetScroll == null)
|
||||||
|
{
|
||||||
|
targetScroll = player.getInventory().getItemByItemId(94208); // Scroll of Blessing - Event
|
||||||
|
}
|
||||||
|
if (targetScroll == null)
|
||||||
|
{
|
||||||
|
targetScroll = player.getInventory().getItemByItemId(94184); // Scroll of Blessing
|
||||||
|
}
|
||||||
|
if (targetScroll == null)
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
||||||
return;
|
return;
|
||||||
@@ -108,8 +111,7 @@ public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
final ItemInstance item = request.getBlessingItem();
|
final ItemInstance item = request.getBlessingItem();
|
||||||
final ItemInstance scroll = request.getBlessScroll();
|
if (item == null)
|
||||||
if ((item == null) || (scroll == null))
|
|
||||||
{
|
{
|
||||||
player.removeRequest(request.getClass());
|
player.removeRequest(request.getClass());
|
||||||
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
||||||
@@ -126,7 +128,7 @@ public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// attempting to destroy scroll
|
// attempting to destroy scroll
|
||||||
if (player.getInventory().destroyItem("Blessing", scroll.getObjectId(), 1, player, item) == null)
|
if (player.getInventory().destroyItem("Blessing", targetScroll.getObjectId(), 1, player, item) == null)
|
||||||
{
|
{
|
||||||
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
client.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
|
||||||
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to bless with a scroll he doesn't have", Config.DEFAULT_PUNISH);
|
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " tried to bless with a scroll he doesn't have", Config.DEFAULT_PUNISH);
|
||||||
@@ -135,32 +137,14 @@ public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// last validation check
|
if (Rnd.get(100) < Config.BLESSING_CHANCE) // Success
|
||||||
if ((item.getOwnerId() != player.getObjectId()))
|
|
||||||
{
|
|
||||||
client.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
|
||||||
player.removeRequest(request.getClass());
|
|
||||||
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final EnchantResultType resultType = targetScroll.get().getValue().calculateSuccess(player, item);
|
|
||||||
switch (resultType)
|
|
||||||
{
|
|
||||||
case ERROR ->
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.AUGMENTATION_REQUIREMENTS_ARE_NOT_FULFILLED);
|
|
||||||
player.sendPacket(new ExBlessOptionEnchant(EnchantResult.ERROR));
|
|
||||||
}
|
|
||||||
case SUCCESS ->
|
|
||||||
{
|
{
|
||||||
final Item it = item.getItem();
|
final Item it = item.getItem();
|
||||||
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
|
// Increase enchant level only if scroll's base template has chance, some armors can success over +20 but they shouldn't have increased.
|
||||||
item.setBlessed(true);
|
item.setBlessed(true);
|
||||||
item.updateDatabase();
|
item.updateDatabase();
|
||||||
player.sendPacket(new ExBlessOptionEnchant(1));
|
player.sendPacket(new ExBlessOptionEnchant(1));
|
||||||
|
// Announce the success.
|
||||||
// announce the success
|
|
||||||
if ((item.getEnchantLevel() >= (item.isArmor() ? Config.MIN_ARMOR_ENCHANT_ANNOUNCE : Config.MIN_WEAPON_ENCHANT_ANNOUNCE)) //
|
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)))
|
&& (item.getEnchantLevel() <= (item.isArmor() ? Config.MAX_ARMOR_ENCHANT_ANNOUNCE : Config.MAX_WEAPON_ENCHANT_ANNOUNCE)))
|
||||||
{
|
{
|
||||||
@@ -187,14 +171,13 @@ public class RequestBlessOptionEnchant implements IClientIncomingPacket
|
|||||||
player.sendSkillList();
|
player.sendSkillList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
player.broadcastUserInfo(); // update user info
|
player.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case FAILURE ->
|
else // Failure.
|
||||||
{
|
{
|
||||||
player.sendPacket(new ExBlessOptionEnchant(0));
|
player.sendPacket(new ExBlessOptionEnchant(0));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendItemList();
|
player.sendItemList();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user