Item transformation implementation.

Contributed by Index.
This commit is contained in:
MobiusDevelopment 2022-05-16 10:30:34 +00:00
parent fedd97659d
commit 78bd8eabd2
107 changed files with 8408 additions and 38 deletions

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
</list>

View File

@ -204,6 +204,13 @@ public class GameAssistant extends AbstractNpcAI
}
break;
}
case "items_conversion":
{
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
}
return htmltext;
}

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -69,6 +69,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -278,6 +279,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RecipeData.getInstance();
ArmorSetData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -75,6 +75,7 @@ import org.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrys
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
@ -498,7 +499,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, null, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
</list>

View File

@ -204,6 +204,13 @@ public class GameAssistant extends AbstractNpcAI
}
break;
}
case "items_conversion":
{
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
}
return htmltext;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
<spawn name="red_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_right_from_etinas" spawnByDefault="true">
<group name="red_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -98,7 +98,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="red_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_left_from_etinas" spawnByDefault="true">
<group name="red_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -197,7 +197,7 @@
</group>
</spawn>
<spawn name="green_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_right_from_etinas" spawnByDefault="true">
<group name="green_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -281,7 +281,7 @@
<npc id="24856" count="7" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Raven -->
</group>
</spawn>
<spawn name="green_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_left_from_etinas" spawnByDefault="true">
<group name="green_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -366,7 +366,7 @@
</group>
</spawn>
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true">
<group name="blue_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">
@ -467,7 +467,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true">
<group name="blue_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -70,6 +70,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -280,6 +281,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RecipeData.getInstance();
ArmorSetData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -83,6 +83,7 @@ import org.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrys
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
@ -508,7 +509,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, null, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, null, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
</list>

View File

@ -200,6 +200,13 @@ public class GameAssistant extends AbstractNpcAI
}
break;
}
case "items_conversion":
{
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
}
return htmltext;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
<spawn name="red_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_right_from_etinas" spawnByDefault="true">
<group name="red_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -98,7 +98,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="red_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_left_from_etinas" spawnByDefault="true">
<group name="red_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -197,7 +197,7 @@
</group>
</spawn>
<spawn name="green_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_right_from_etinas" spawnByDefault="true">
<group name="green_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -281,7 +281,7 @@
<npc id="24856" count="7" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Raven -->
</group>
</spawn>
<spawn name="green_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_left_from_etinas" spawnByDefault="true">
<group name="green_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -366,7 +366,7 @@
</group>
</spawn>
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true">
<group name="blue_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">
@ -467,7 +467,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true">
<group name="blue_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -70,6 +70,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -282,6 +283,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RecipeData.getInstance();
ArmorSetData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -83,6 +83,7 @@ import org.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrys
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
@ -510,7 +511,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, RequestPurchaseLimitShopItemBuy::new, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
</list>

View File

@ -200,6 +200,13 @@ public class GameAssistant extends AbstractNpcAI
}
break;
}
case "items_conversion":
{
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
}
return htmltext;
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../xsd/spawns.xsd">
<spawn name="red_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_right_from_etinas" spawnByDefault="true">
<group name="red_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -98,7 +98,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="red_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="red_zone_left_from_etinas" spawnByDefault="true">
<group name="red_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8900" maxZ="-8960">
@ -197,7 +197,7 @@
</group>
</spawn>
<spawn name="green_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_right_from_etinas" spawnByDefault="true">
<group name="green_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -281,7 +281,7 @@
<npc id="24856" count="7" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Raven -->
</group>
</spawn>
<spawn name="green_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="green_zone_left_from_etinas" spawnByDefault="true">
<group name="green_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8740" maxZ="-8880">
@ -366,7 +366,7 @@
</group>
</spawn>
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_right_from_etinas" spawnByDefault="true">
<group name="blue_right_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">
@ -467,7 +467,7 @@
<npc id="24857" count="3" respawnTime="30sec" respawnRandom="0sec" /> <!-- Atelia Wizard -->
</group>
</spawn>
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true" >
<spawn name="blue_zone_left_from_etinas" spawnByDefault="true">
<group name="blue_left_first_left" spawnByDefault="true">
<territories>
<territory shape="Cuboid" rad="1" minZ="-8600" maxZ="-8740">

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -70,6 +70,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -282,6 +283,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RecipeData.getInstance();
ArmorSetData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -94,6 +94,7 @@ import org.l2jmobius.gameserver.network.clientpackets.enchant.single.ExRequestVi
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.homunculus.ExHomunculusEvolve;
@ -528,7 +529,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, RequestExTryEnchantArtifact::new, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, RequestPurchaseLimitShopItemBuy::new, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
<upgrade id="1" type="1" chance="50" commission="5000000">
<upgradeItem id="6660" count="1" enchantLevel="0" /> <!-- Queen Ant's Ring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="2" type="1" chance="50" commission="5000000">
<upgradeItem id="6661" count="1" enchantLevel="0" /> <!--Orfen's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="3" type="1" chance="20" commission="2000000">
<upgradeItem id="6662" count="1" enchantLevel="0" /> <!-- Ring of Core -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="4" type="1" chance="23" commission="7500000">
<upgradeItem id="49580" count="1" enchantLevel="0" /> <!-- Baium's Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="5" type="1" chance="80" commission="7500000">
<upgradeItem id="90763" count="1" enchantLevel="0" /> <!-- Zaken's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="6" type="1" chance="40" commission="10000000">
<upgradeItem id="90992" count="1" enchantLevel="0" /> <!-- Antharas' Earring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="2" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="7" type="1" chance="40" commission="10000000">
<upgradeItem id="91550" count="1" enchantLevel="0" /> <!-- Frintezza's Necklace -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
</list>

View File

@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.network.serverpackets.PackageToList;
import org.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgrade.ExShowUpgradeSystem;
import ai.AbstractNpcAI;
@ -277,8 +276,9 @@ public class GameAssistant extends AbstractNpcAI
}
case "items_conversion":
{
player.setTarget(player);
player.sendPacket(new ExShowUpgradeSystem());
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
// Multisell

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -69,6 +69,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -286,6 +287,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RaidTeleportListData.getInstance();
RecipeData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -77,6 +77,7 @@ import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElement
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
@ -496,7 +497,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, RequestPurchaseLimitShopItemBuy::new, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,444 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
<upgrade id="1" type="1" chance="50" commission="5000000">
<upgradeItem id="6660" count="1" enchantLevel="0" /> <!-- Queen Ant's Ring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="2" type="1" chance="50" commission="5000000">
<upgradeItem id="6661" count="1" enchantLevel="0" /> <!-- Orfen's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="3" type="1" chance="20" commission="2000000">
<upgradeItem id="6662" count="1" enchantLevel="0" /> <!-- Ring of Core -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="4" type="1" chance="23" commission="7500000">
<upgradeItem id="49580" count="1" enchantLevel="0" /> <!-- Baium's Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="5" type="1" chance="80" commission="7500000">
<upgradeItem id="90763" count="1" enchantLevel="0" /> <!-- Zaken's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="6" type="1" chance="40" commission="10000000">
<upgradeItem id="90992" count="1" enchantLevel="0" /> <!-- Antharas' Earring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="2" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="7" type="1" chance="40" commission="10000000">
<upgradeItem id="91550" count="1" enchantLevel="0" /> <!-- Frintezza's Necklace -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="8" type="1" chance="100" commission="50000">
<upgradeItem id="91046" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="9" type="1" chance="100" commission="50000">
<upgradeItem id="91047" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="10" type="1" chance="100" commission="50000">
<upgradeItem id="91048" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="11" type="1" chance="100" commission="100000">
<upgradeItem id="91118" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="12" type="1" chance="100" commission="200000">
<upgradeItem id="91119" count="1" enchantLevel="0" /> <!-- Ignis' Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="13" type="1" chance="100" commission="300000">
<upgradeItem id="91119" count="1" enchantLevel="1" /> <!-- Ignis' Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="14" type="1" chance="100" commission="500000">
<upgradeItem id="91119" count="1" enchantLevel="2" /> <!-- Ignis' Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="15" type="1" chance="100" commission="700000">
<upgradeItem id="91119" count="1" enchantLevel="3" /> <!-- Ignis' Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="16" type="1" chance="100" commission="1000000">
<upgradeItem id="91119" count="1" enchantLevel="4" /> <!-- Ignis' Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="17" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="5" /> <!-- Ignis' Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="18" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="6" /> <!-- Ignis' Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="19" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="7" /> <!-- Ignis' Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="20" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="8" /> <!-- Ignis' Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="21" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="9" /> <!-- Ignis' Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="22" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="10" /> <!-- Ignis' Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="23" type="1" chance="100" commission="50000">
<upgradeItem id="91043" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="24" type="1" chance="100" commission="50000">
<upgradeItem id="91044" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="25" type="1" chance="100" commission="50000">
<upgradeItem id="91045" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="26" type="1" chance="100" commission="100000">
<upgradeItem id="91116" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="27" type="1" chance="100" commission="200000">
<upgradeItem id="91117" count="1" enchantLevel="0" /> <!-- Nebula's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="28" type="1" chance="100" commission="300000">
<upgradeItem id="91117" count="1" enchantLevel="1" /> <!-- Nebula's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="29" type="1" chance="100" commission="500000">
<upgradeItem id="91117" count="1" enchantLevel="2" /> <!-- Nebula's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="30" type="1" chance="100" commission="700000">
<upgradeItem id="91117" count="1" enchantLevel="3" /> <!-- Nebula's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="31" type="1" chance="100" commission="1000000">
<upgradeItem id="91117" count="1" enchantLevel="4" /> <!-- Nebula's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="32" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="5" /> <!-- Nebula's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="33" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="6" /> <!-- Nebula's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="34" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="7" /> <!-- Nebula's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="35" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="8" /> <!-- Nebula's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="36" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="9" /> <!-- Nebula's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="37" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="10" /> <!-- Nebula's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="38" type="1" chance="100" commission="50000">
<upgradeItem id="91049" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="39" type="1" chance="100" commission="50000">
<upgradeItem id="91050" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="40" type="1" chance="100" commission="50000">
<upgradeItem id="91051" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="41" type="1" chance="100" commission="100000">
<upgradeItem id="91120" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="42" type="1" chance="100" commission="200000">
<upgradeItem id="91121" count="1" enchantLevel="0" /> <!-- Procella's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="43" type="1" chance="100" commission="300000">
<upgradeItem id="91121" count="1" enchantLevel="1" /> <!-- Procella's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="44" type="1" chance="100" commission="500000">
<upgradeItem id="91121" count="1" enchantLevel="2" /> <!-- Procella's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="45" type="1" chance="100" commission="700000">
<upgradeItem id="91121" count="1" enchantLevel="3" /> <!-- Procella's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="46" type="1" chance="100" commission="1000000">
<upgradeItem id="91121" count="1" enchantLevel="4" /> <!-- Procella's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="47" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="5" /> <!-- Procella's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="48" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="6" /> <!-- Procella's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="49" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="7" /> <!-- Procella's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="50" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="8" /> <!-- Procella's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="51" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="9" /> <!-- Procella's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="52" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="10" /> <!-- Procella's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="53" type="1" chance="100" commission="50000">
<upgradeItem id="91052" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="54" type="1" chance="100" commission="50000">
<upgradeItem id="91053" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="55" type="1" chance="100" commission="50000">
<upgradeItem id="91054" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="56" type="1" chance="100" commission="100000">
<upgradeItem id="91122" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="57" type="1" chance="100" commission="200000">
<upgradeItem id="91123" count="1" enchantLevel="0" /> <!-- Petram's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="58" type="1" chance="100" commission="300000">
<upgradeItem id="91123" count="1" enchantLevel="1" /> <!-- Petram's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="59" type="1" chance="100" commission="500000">
<upgradeItem id="91123" count="1" enchantLevel="2" /> <!-- Petram's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="60" type="1" chance="100" commission="700000">
<upgradeItem id="91123" count="1" enchantLevel="3" /> <!-- Petram's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="61" type="1" chance="100" commission="1000000">
<upgradeItem id="91123" count="1" enchantLevel="4" /> <!-- Petram's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="62" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="5" /> <!-- Petram's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="63" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="6" /> <!-- Petram's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="64" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="7" /> <!-- Petram's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="65" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="8" /> <!-- Petram's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="66" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="9" /> <!-- Petram's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="67" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="10" /> <!-- Petram's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
</list>

View File

@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.network.serverpackets.PackageToList;
import org.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgrade.ExShowUpgradeSystem;
import ai.AbstractNpcAI;
@ -220,8 +219,9 @@ public class GameAssistant extends AbstractNpcAI
}
case "items_conversion":
{
player.setTarget(player);
player.sendPacket(new ExShowUpgradeSystem());
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
// Multisell

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -70,6 +70,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -294,6 +295,7 @@ public class GameServer
BuyListData.getInstance();
MultisellData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RaidTeleportListData.getInstance();
RecipeData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -84,6 +84,7 @@ import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElement
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
@ -519,7 +520,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, RequestPurchaseLimitShopItemBuy::new, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,453 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
<upgrade id="1" type="1" chance="50" commission="5000000">
<upgradeItem id="6660" count="1" enchantLevel="0" /> <!-- Queen Ant's Ring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="2" type="1" chance="50" commission="5000000">
<upgradeItem id="6661" count="1" enchantLevel="0" /> <!-- Orfen's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="3" type="1" chance="20" commission="2000000">
<upgradeItem id="6662" count="1" enchantLevel="0" /> <!-- Ring of Core -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="4" type="1" chance="23" commission="7500000">
<upgradeItem id="49580" count="1" enchantLevel="0" /> <!-- Baium's Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="5" type="1" chance="80" commission="7500000">
<upgradeItem id="90763" count="1" enchantLevel="0" /> <!-- Zaken's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="6" type="1" chance="40" commission="10000000">
<upgradeItem id="90992" count="1" enchantLevel="0" /> <!-- Antharas' Earring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="2" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="7" type="1" chance="40" commission="10000000">
<upgradeItem id="91550" count="1" enchantLevel="0" /> <!-- Frintezza's Necklace -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="8" type="1" chance="100" commission="50000">
<upgradeItem id="91046" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="9" type="1" chance="100" commission="50000">
<upgradeItem id="91047" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="10" type="1" chance="100" commission="50000">
<upgradeItem id="91048" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="11" type="1" chance="100" commission="100000">
<upgradeItem id="91118" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="12" type="1" chance="100" commission="200000">
<upgradeItem id="91119" count="1" enchantLevel="0" /> <!-- Ignis' Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="13" type="1" chance="100" commission="300000">
<upgradeItem id="91119" count="1" enchantLevel="1" /> <!-- Ignis' Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="14" type="1" chance="100" commission="500000">
<upgradeItem id="91119" count="1" enchantLevel="2" /> <!-- Ignis' Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="15" type="1" chance="100" commission="700000">
<upgradeItem id="91119" count="1" enchantLevel="3" /> <!-- Ignis' Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="16" type="1" chance="100" commission="1000000">
<upgradeItem id="91119" count="1" enchantLevel="4" /> <!-- Ignis' Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="17" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="5" /> <!-- Ignis' Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="18" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="6" /> <!-- Ignis' Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="19" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="7" /> <!-- Ignis' Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="20" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="8" /> <!-- Ignis' Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="21" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="9" /> <!-- Ignis' Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="22" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="10" /> <!-- Ignis' Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="23" type="1" chance="100" commission="50000">
<upgradeItem id="91043" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="24" type="1" chance="100" commission="50000">
<upgradeItem id="91044" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="25" type="1" chance="100" commission="50000">
<upgradeItem id="91045" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="26" type="1" chance="100" commission="100000">
<upgradeItem id="91116" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="27" type="1" chance="100" commission="200000">
<upgradeItem id="91117" count="1" enchantLevel="0" /> <!-- Nebula's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="28" type="1" chance="100" commission="300000">
<upgradeItem id="91117" count="1" enchantLevel="1" /> <!-- Nebula's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="29" type="1" chance="100" commission="500000">
<upgradeItem id="91117" count="1" enchantLevel="2" /> <!-- Nebula's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="30" type="1" chance="100" commission="700000">
<upgradeItem id="91117" count="1" enchantLevel="3" /> <!-- Nebula's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="31" type="1" chance="100" commission="1000000">
<upgradeItem id="91117" count="1" enchantLevel="4" /> <!-- Nebula's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="32" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="5" /> <!-- Nebula's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="33" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="6" /> <!-- Nebula's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="34" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="7" /> <!-- Nebula's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="35" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="8" /> <!-- Nebula's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="36" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="9" /> <!-- Nebula's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="37" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="10" /> <!-- Nebula's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="38" type="1" chance="100" commission="50000">
<upgradeItem id="91049" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="39" type="1" chance="100" commission="50000">
<upgradeItem id="91050" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="40" type="1" chance="100" commission="50000">
<upgradeItem id="91051" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="41" type="1" chance="100" commission="100000">
<upgradeItem id="91120" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="42" type="1" chance="100" commission="200000">
<upgradeItem id="91121" count="1" enchantLevel="0" /> <!-- Procella's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="43" type="1" chance="100" commission="300000">
<upgradeItem id="91121" count="1" enchantLevel="1" /> <!-- Procella's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="44" type="1" chance="100" commission="500000">
<upgradeItem id="91121" count="1" enchantLevel="2" /> <!-- Procella's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="45" type="1" chance="100" commission="700000">
<upgradeItem id="91121" count="1" enchantLevel="3" /> <!-- Procella's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="46" type="1" chance="100" commission="1000000">
<upgradeItem id="91121" count="1" enchantLevel="4" /> <!-- Procella's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="47" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="5" /> <!-- Procella's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="48" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="6" /> <!-- Procella's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="49" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="7" /> <!-- Procella's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="50" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="8" /> <!-- Procella's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="51" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="9" /> <!-- Procella's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="52" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="10" /> <!-- Procella's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="53" type="1" chance="100" commission="50000">
<upgradeItem id="91052" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="54" type="1" chance="100" commission="50000">
<upgradeItem id="91053" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="55" type="1" chance="100" commission="50000">
<upgradeItem id="91054" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="56" type="1" chance="100" commission="100000">
<upgradeItem id="91122" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="57" type="1" chance="100" commission="200000">
<upgradeItem id="91123" count="1" enchantLevel="0" /> <!-- Petram's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="58" type="1" chance="100" commission="300000">
<upgradeItem id="91123" count="1" enchantLevel="1" /> <!-- Petram's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="59" type="1" chance="100" commission="500000">
<upgradeItem id="91123" count="1" enchantLevel="2" /> <!-- Petram's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="60" type="1" chance="100" commission="700000">
<upgradeItem id="91123" count="1" enchantLevel="3" /> <!-- Petram's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="61" type="1" chance="100" commission="1000000">
<upgradeItem id="91123" count="1" enchantLevel="4" /> <!-- Petram's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="62" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="5" /> <!-- Petram's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="63" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="6" /> <!-- Petram's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="64" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="7" /> <!-- Petram's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="65" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="8" /> <!-- Petram's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="66" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="9" /> <!-- Petram's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="67" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="10" /> <!-- Petram's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="68" type="1" chance="23" commission="7500000">
<upgradeItem id="96600" count="1" enchantLevel="0" /> <!-- Beleth' Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
</list>

View File

@ -38,7 +38,6 @@ import org.l2jmobius.gameserver.network.serverpackets.PackageToList;
import org.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgrade.ExShowUpgradeSystem;
import ai.AbstractNpcAI;
@ -238,8 +237,9 @@ public class GameAssistant extends AbstractNpcAI
}
case "items_conversion":
{
player.setTarget(player);
player.sendPacket(new ExShowUpgradeSystem());
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
// Multisell

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -71,6 +71,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -296,6 +297,7 @@ public class GameServer
CombinationItemsData.getInstance();
CombinationDyeData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RaidTeleportListData.getInstance();
RecipeData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

View File

@ -0,0 +1,116 @@
/*
* 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.model.holders;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
public class EquipmentUpgradeNormalHolder
{
private final int _id;
private final int _type;
private final long _commission;
private final double _chance;
private final ItemEnchantHolder _initialItem;
private final double _chanceToReceiveBonusItems;
private final Map<UpgradeDataType, List<ItemEnchantHolder>> _items = new HashMap<>();
/**
* @implNote Holder for "UpgradeNormal" equipment system; <list>
* <li>Final Holder will be have getter getItems which get UpgradeDataType;</li>
* <li>Don't forget to check in isHasCategory category type in getItems, for don`t get null or empty collections;</li> </list>
* @param id Upgrade ID in DAT file; (yep, duplication);
* @param type Upgrade type in DAT file (1 / 2 (used in classic);
* @param commission Default Adena count, needed for make "Transformation";
* @param chance Success chance of made "Transformation";
* @param initialItem Item for upgrade; (cannot be empty)
* @param materialItems Materials for upgrade; (can be empty)
* @param onSuccessItems Items, which player gets if RND will be < chance (if win);
* @param onFailureItems Items, which player gets if RND will be > chance (if lose);
* @param chanceToReceiveBonusItems Chance to obtain additional reward on Success (if win);
* @param bonusItems Bonus Items;
*/
public EquipmentUpgradeNormalHolder(int id, int type, long commission, double chance, ItemEnchantHolder initialItem, List<ItemEnchantHolder> materialItems, List<ItemEnchantHolder> onSuccessItems, List<ItemEnchantHolder> onFailureItems, double chanceToReceiveBonusItems, List<ItemEnchantHolder> bonusItems)
{
_id = id;
_type = type;
_commission = commission;
_chance = chance;
_initialItem = initialItem;
_chanceToReceiveBonusItems = chanceToReceiveBonusItems;
if (materialItems != null)
{
_items.put(UpgradeDataType.MATERIAL, materialItems);
}
_items.put(UpgradeDataType.ON_SUCCESS, onSuccessItems);
if (onFailureItems != null)
{
_items.put(UpgradeDataType.ON_FAILURE, onFailureItems);
}
if (bonusItems != null)
{
_items.put(UpgradeDataType.BONUS_TYPE, bonusItems);
}
}
public int getId()
{
return _id;
}
public int getType()
{
return _type;
}
public long getCommission()
{
return _commission;
}
public double getChance()
{
return _chance;
}
public ItemEnchantHolder getInitialItem()
{
return _initialItem;
}
public double getChanceToReceiveBonusItems()
{
return _chanceToReceiveBonusItems;
}
public List<ItemEnchantHolder> getItems(UpgradeDataType upgradeDataType)
{
return _items.get(upgradeDataType);
}
public boolean isHasCategory(UpgradeDataType upgradeDataType)
{
if (_items.isEmpty())
{
return false;
}
return _items.containsKey(upgradeDataType);
}
}

View File

@ -0,0 +1,73 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.StatSet;
/**
* @author Index, Mobius
*/
public class ItemEnchantHolder extends ItemHolder
{
private final int _enchantLevel;
public ItemEnchantHolder(StatSet set)
{
super(set);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count)
{
super(id, count);
_enchantLevel = 0;
}
public ItemEnchantHolder(int id, long count, int enchantLevel)
{
super(id, count);
_enchantLevel = enchantLevel;
}
/**
* @return enchant level of items contained in this object
*/
public int getEnchantLevel()
{
return _enchantLevel;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof ItemEnchantHolder objInstance))
{
return false;
}
else if (obj == this)
{
return true;
}
return (getId() == objInstance.getId()) && ((getCount() == objInstance.getCount()) && (_enchantLevel == objInstance.getEnchantLevel()));
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", count: " + getCount() + ", enchant level: " + _enchantLevel;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.model.holders;
import org.l2jmobius.gameserver.model.interfaces.IUniqueId;
/**
* @author Index, Mobius
*/
public class UniqueItemEnchantHolder extends ItemEnchantHolder implements IUniqueId
{
private final int _objectId;
public UniqueItemEnchantHolder(int id, int objectId)
{
this(id, objectId, 1);
}
public UniqueItemEnchantHolder(int id, int objectId, long count)
{
super(id, count);
_objectId = objectId;
}
public UniqueItemEnchantHolder(ItemEnchantHolder itemHolder, int objectId)
{
super(itemHolder.getId(), itemHolder.getCount(), itemHolder.getEnchantLevel());
_objectId = objectId;
}
@Override
public int getObjectId()
{
return _objectId;
}
@Override
public String toString()
{
return "[" + getClass().getSimpleName() + "] ID: " + getId() + ", object ID: " + _objectId + ", count: " + getCount() + ", enchant level: " + getEnchantLevel();
}
}

View File

@ -85,6 +85,7 @@ import org.l2jmobius.gameserver.network.clientpackets.elementalspirits.ExElement
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
import org.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgrade.RequestUpgradeSystemResult;
import org.l2jmobius.gameserver.network.clientpackets.equipmentupgradenormal.ExUpgradeSystemNormalRequest;
import org.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneEnter;
import org.l2jmobius.gameserver.network.clientpackets.huntingzones.ExTimedHuntingZoneList;
@ -531,7 +532,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
REQUEST_USER_BAN_INFO(0x15E, null, ConnectionState.IN_GAME),
EX_INTERACT_MODIFY(0x15F, null, ConnectionState.IN_GAME),
EX_TRY_ENCHANT_ARTIFACT(0x160, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, null, ConnectionState.IN_GAME),
EX_UPGRADE_SYSTEM_NORMAL_REQUEST(0x161, ExUpgradeSystemNormalRequest::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_LIST(0x162, RequestPurchaseLimitShopItemList::new, ConnectionState.IN_GAME),
EX_PURCHASE_LIMIT_SHOP_ITEM_BUY(0x163, RequestPurchaseLimitShopItemBuy::new, ConnectionState.IN_GAME),
// 228

View File

@ -0,0 +1,193 @@
/*
* 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.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.enums.UpgradeDataType;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.PacketLogger;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class ExUpgradeSystemNormalRequest implements IClientIncomingPacket
{
private int _objectId;
private int _typeId;
private int _upgradeId;
private final List<UniqueItemEnchantHolder> _resultItems = new ArrayList<>();
private final List<UniqueItemEnchantHolder> _bonusItems = new ArrayList<>();
private final Map<Integer, Long> _discount = new HashMap<>();
private boolean isNeedToSendUpdate = false;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_objectId = packet.readD();
_typeId = packet.readD();
_upgradeId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item requestedItem = player.getInventory().getItemByObjectId(_objectId);
if (requestedItem == null)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final EquipmentUpgradeNormalHolder upgradeHolder = EquipmentUpgradeNormalData.getInstance().getUpgrade(_upgradeId);
if ((upgradeHolder == null) || (upgradeHolder.getType() != _typeId))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
final Inventory inventory = player.getInventory();
if ((inventory.getItemByItemId(upgradeHolder.getInitialItem().getId()) == null) || (inventory.getInventoryItemCount(upgradeHolder.getInitialItem().getId(), -1) < upgradeHolder.getInitialItem().getCount()))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemEnchantHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
if (material.getCount() < 0)
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
PacketLogger.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + upgradeHolder.getId() + " cant be less than 0! Aborting current request!");
return;
}
if (inventory.getInventoryItemCount(material.getId(), material.getEnchantLevel()) < material.getCount())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
for (ItemHolder discount : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
if (discount.getId() == material.getId())
{
_discount.put(material.getId(), discount.getCount());
break;
}
}
}
}
final long adena = upgradeHolder.getCommission();
if ((adena > 0) && (inventory.getAdena() < adena))
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
return;
}
// Get materials.
player.destroyItem("UpgradeNormalEquipment", _objectId, 1, player, true);
if (upgradeHolder.isHasCategory(UpgradeDataType.MATERIAL))
{
for (ItemHolder material : upgradeHolder.getItems(UpgradeDataType.MATERIAL))
{
player.destroyItemByItemId("UpgradeNormalEquipment", material.getId(), material.getCount() - (_discount.isEmpty() ? 0 : _discount.get(material.getId())), player, true);
}
}
if (adena > 0)
{
player.reduceAdena("UpgradeNormalEquipment", adena, player, true);
}
if (Rnd.get(100d) < upgradeHolder.getChance())
{
for (ItemEnchantHolder successItem : upgradeHolder.getItems(UpgradeDataType.ON_SUCCESS))
{
final Item addedSuccessItem = player.addItem("UpgradeNormalEquipment", successItem.getId(), successItem.getCount(), player, true);
if (successItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedSuccessItem.setEnchantLevel(successItem.getEnchantLevel());
}
addedSuccessItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(successItem, addedSuccessItem.getObjectId()));
}
if (upgradeHolder.isHasCategory(UpgradeDataType.BONUS_TYPE) && (Rnd.get(100d) < upgradeHolder.getChanceToReceiveBonusItems()))
{
for (ItemEnchantHolder bonusItem : upgradeHolder.getItems(UpgradeDataType.BONUS_TYPE))
{
final Item addedBonusItem = player.addItem("UpgradeNormalEquipment", bonusItem.getId(), bonusItem.getCount(), player, true);
if (bonusItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedBonusItem.setEnchantLevel(bonusItem.getEnchantLevel());
}
addedBonusItem.updateDatabase(true);
_bonusItems.add(new UniqueItemEnchantHolder(bonusItem, addedBonusItem.getObjectId()));
}
}
}
else
{
if (upgradeHolder.isHasCategory(UpgradeDataType.ON_FAILURE))
{
for (ItemEnchantHolder failureItem : upgradeHolder.getItems(UpgradeDataType.ON_FAILURE))
{
final Item addedFailureItem = player.addItem("UpgradeNormalEquipment", failureItem.getId(), failureItem.getCount(), player, true);
if (failureItem.getEnchantLevel() != 0)
{
isNeedToSendUpdate = true;
addedFailureItem.setEnchantLevel(failureItem.getEnchantLevel());
}
addedFailureItem.updateDatabase(true);
_resultItems.add(new UniqueItemEnchantHolder(failureItem, addedFailureItem.getObjectId()));
}
}
else
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
}
if (isNeedToSendUpdate)
{
player.sendItemList(); // for see enchant level in Upgrade UI
}
// Why need map of item and count? because method "addItem" return item, and if it exists in result will be count of all items, not of obtained.
player.sendPacket(new ExUpgradeSystemNormalResult(1, _typeId, true, _resultItems, _bonusItems));
}
}

View File

@ -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.serverpackets.equipmentupgradenormal;
import java.util.ArrayList;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExShowUpgradeSystemNormal extends AbstractItemPacket
{
private final int _mode;
private final int _type;
private final int _commission;
private final List<Integer> _materials = new ArrayList<>();
private final List<Integer> _discountRatio = new ArrayList<>();
public ExShowUpgradeSystemNormal(int mode, int type)
{
_mode = mode;
_type = type;
_commission = EquipmentUpgradeNormalData.getInstance().getCommission();
for (ItemHolder item : EquipmentUpgradeNormalData.getInstance().getDiscount())
{
_materials.add(item.getId());
_discountRatio.add((int) item.getCount());
}
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_UPGRADE_SYSTEM_NORMAL.writeId(packet);
packet.writeH(_mode);
packet.writeH(_type);
packet.writeH(_commission); // default - 100
packet.writeD(_materials.size()); // array of materials with discount
for (int id : _materials)
{
packet.writeD(id);
}
packet.writeD(_discountRatio.size()); // array of discount count
for (int discount : _discountRatio)
{
packet.writeD(discount);
}
return true;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.equipmentupgradenormal;
import java.util.Collections;
import java.util.List;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.UniqueItemEnchantHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.AbstractItemPacket;
/**
* @author Index
*/
public class ExUpgradeSystemNormalResult extends AbstractItemPacket
{
public static final ExUpgradeSystemNormalResult FAIL = new ExUpgradeSystemNormalResult(0, 0, false, Collections.emptyList(), Collections.emptyList());
private final int _result;
private final int _upgradeId;
private final boolean _success;
private final List<UniqueItemEnchantHolder> _resultItems;
private final List<UniqueItemEnchantHolder> _bonusItems;
public ExUpgradeSystemNormalResult(int result, int upgradeId, boolean success, List<UniqueItemEnchantHolder> resultItems, List<UniqueItemEnchantHolder> bonusItems)
{
_result = result;
_upgradeId = upgradeId;
_success = success;
_resultItems = resultItems;
_bonusItems = bonusItems;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_UPGRADE_SYSTEM_NORMAL_RESULT.writeId(packet);
packet.writeH(_result); // Result ID
packet.writeD(_upgradeId); // Upgrade ID
packet.writeC(_success ? 1 : 0); // Success
packet.writeD(_resultItems.size()); // Array of result items (success/failure) start.
for (UniqueItemEnchantHolder item : _resultItems)
{
packet.writeD(item.getObjectId());
packet.writeD(item.getId());
packet.writeD(item.getEnchantLevel());
packet.writeD(Math.toIntExact(item.getCount()));
}
packet.writeC(0); // Is bonus? Do not see any effect.
packet.writeD(_bonusItems.size()); // Array of bonus items start.
for (UniqueItemEnchantHolder bonus : _bonusItems)
{
packet.writeD(bonus.getObjectId());
packet.writeD(bonus.getId());
packet.writeD(bonus.getEnchantLevel());
packet.writeD(Math.toIntExact(bonus.getCount()));
}
return true;
}
}

View File

@ -0,0 +1,453 @@
<?xml version="1.0" encoding="utf-8" ?>
<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/EquipmentUpgradeNormalData.xsd">
<!--
Commission in params its Adena multiplier, which apply to commission from upgrade.
Commission in upgrade its adena, which request for change item type.
Upgrade commission value 5 000 000:
* commission 100 - upgrade commission will be 5 000 000 // default value
* commission 1 000 - upgrade commission will be 50 000 000
Calculation formula -> (Upgrade commission / 100) * (params commission)
-->
<params commission="100" />
<discount>
<!--
Working only for material items in upgrade.
For change adena tax - use commission in params.
<item id="57" count="0" />
<item id="57" count="0" />
<item id="57" count="0" />
-->
</discount>
<upgrade id="1" type="1" chance="50" commission="5000000">
<upgradeItem id="6660" count="1" enchantLevel="0" /> <!-- Queen Ant's Ring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="2" type="1" chance="50" commission="5000000">
<upgradeItem id="6661" count="1" enchantLevel="0" /> <!-- Orfen's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="3" type="1" chance="20" commission="2000000">
<upgradeItem id="6662" count="1" enchantLevel="0" /> <!-- Ring of Core -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="4" type="1" chance="23" commission="7500000">
<upgradeItem id="49580" count="1" enchantLevel="0" /> <!-- Baium's Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="5" type="1" chance="80" commission="7500000">
<upgradeItem id="90763" count="1" enchantLevel="0" /> <!-- Zaken's Earring -->
<successItems>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94208" count="1" enchantLevel="0" /> <!-- Scroll of Blessing (Sealed) -->
</failure_items>
</upgrade>
<upgrade id="6" type="1" chance="40" commission="10000000">
<upgradeItem id="90992" count="1" enchantLevel="0" /> <!-- Antharas' Earring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="2" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="7" type="1" chance="40" commission="10000000">
<upgradeItem id="91550" count="1" enchantLevel="0" /> <!-- Frintezza's Necklace -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
<upgrade id="8" type="1" chance="100" commission="50000">
<upgradeItem id="91046" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="9" type="1" chance="100" commission="50000">
<upgradeItem id="91047" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="10" type="1" chance="100" commission="50000">
<upgradeItem id="91048" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="11" type="1" chance="100" commission="100000">
<upgradeItem id="91118" count="1" enchantLevel="0" /> <!-- Ignis' Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="12" type="1" chance="100" commission="200000">
<upgradeItem id="91119" count="1" enchantLevel="0" /> <!-- Ignis' Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="13" type="1" chance="100" commission="300000">
<upgradeItem id="91119" count="1" enchantLevel="1" /> <!-- Ignis' Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="14" type="1" chance="100" commission="500000">
<upgradeItem id="91119" count="1" enchantLevel="2" /> <!-- Ignis' Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="15" type="1" chance="100" commission="700000">
<upgradeItem id="91119" count="1" enchantLevel="3" /> <!-- Ignis' Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="16" type="1" chance="100" commission="1000000">
<upgradeItem id="91119" count="1" enchantLevel="4" /> <!-- Ignis' Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="17" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="5" /> <!-- Ignis' Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="18" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="6" /> <!-- Ignis' Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="19" type="1" chance="100" commission="2000000">
<upgradeItem id="91119" count="1" enchantLevel="7" /> <!-- Ignis' Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="20" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="8" /> <!-- Ignis' Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="21" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="9" /> <!-- Ignis' Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="22" type="1" chance="100" commission="5000000">
<upgradeItem id="91119" count="1" enchantLevel="10" /> <!-- Ignis' Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="23" type="1" chance="100" commission="50000">
<upgradeItem id="91043" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="24" type="1" chance="100" commission="50000">
<upgradeItem id="91044" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="25" type="1" chance="100" commission="50000">
<upgradeItem id="91045" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="26" type="1" chance="100" commission="100000">
<upgradeItem id="91116" count="1" enchantLevel="0" /> <!-- Nebula's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="27" type="1" chance="100" commission="200000">
<upgradeItem id="91117" count="1" enchantLevel="0" /> <!-- Nebula's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="28" type="1" chance="100" commission="300000">
<upgradeItem id="91117" count="1" enchantLevel="1" /> <!-- Nebula's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="29" type="1" chance="100" commission="500000">
<upgradeItem id="91117" count="1" enchantLevel="2" /> <!-- Nebula's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="30" type="1" chance="100" commission="700000">
<upgradeItem id="91117" count="1" enchantLevel="3" /> <!-- Nebula's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="31" type="1" chance="100" commission="1000000">
<upgradeItem id="91117" count="1" enchantLevel="4" /> <!-- Nebula's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="32" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="5" /> <!-- Nebula's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="33" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="6" /> <!-- Nebula's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="34" type="1" chance="100" commission="2000000">
<upgradeItem id="91117" count="1" enchantLevel="7" /> <!-- Nebula's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="35" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="8" /> <!-- Nebula's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="36" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="9" /> <!-- Nebula's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="37" type="1" chance="100" commission="5000000">
<upgradeItem id="91117" count="1" enchantLevel="10" /> <!-- Nebula's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="38" type="1" chance="100" commission="50000">
<upgradeItem id="91049" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="39" type="1" chance="100" commission="50000">
<upgradeItem id="91050" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="40" type="1" chance="100" commission="50000">
<upgradeItem id="91051" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="41" type="1" chance="100" commission="100000">
<upgradeItem id="91120" count="1" enchantLevel="0" /> <!-- Procella's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="42" type="1" chance="100" commission="200000">
<upgradeItem id="91121" count="1" enchantLevel="0" /> <!-- Procella's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="43" type="1" chance="100" commission="300000">
<upgradeItem id="91121" count="1" enchantLevel="1" /> <!-- Procella's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="44" type="1" chance="100" commission="500000">
<upgradeItem id="91121" count="1" enchantLevel="2" /> <!-- Procella's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="45" type="1" chance="100" commission="700000">
<upgradeItem id="91121" count="1" enchantLevel="3" /> <!-- Procella's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="46" type="1" chance="100" commission="1000000">
<upgradeItem id="91121" count="1" enchantLevel="4" /> <!-- Procella's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="47" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="5" /> <!-- Procella's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="48" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="6" /> <!-- Procella's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="49" type="1" chance="100" commission="2000000">
<upgradeItem id="91121" count="1" enchantLevel="7" /> <!-- Procella's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="50" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="8" /> <!-- Procella's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="51" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="9" /> <!-- Procella's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="52" type="1" chance="100" commission="5000000">
<upgradeItem id="91121" count="1" enchantLevel="10" /> <!-- Procella's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="53" type="1" chance="100" commission="50000">
<upgradeItem id="91052" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 1 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="54" type="1" chance="100" commission="50000">
<upgradeItem id="91053" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 2 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="55" type="1" chance="100" commission="50000">
<upgradeItem id="91054" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 3 -->
<successItems>
<item id="94682" count="1" enchantLevel="0" /> <!-- Necklace of Spirits -->
</successItems>
</upgrade>
<upgrade id="56" type="1" chance="100" commission="100000">
<upgradeItem id="91122" count="1" enchantLevel="0" /> <!-- Petram's Old Necklace Lv. 4 -->
<successItems>
<item id="94682" count="1" enchantLevel="1" /> <!-- Necklace of Spirits +1 -->
</successItems>
</upgrade>
<upgrade id="57" type="1" chance="100" commission="200000">
<upgradeItem id="91123" count="1" enchantLevel="0" /> <!-- Petram's Necklace -->
<successItems>
<item id="94682" count="1" enchantLevel="2" /> <!-- Necklace of Spirits +2 -->
</successItems>
</upgrade>
<upgrade id="58" type="1" chance="100" commission="300000">
<upgradeItem id="91123" count="1" enchantLevel="1" /> <!-- Petram's Necklace +1 -->
<successItems>
<item id="94682" count="1" enchantLevel="3" /> <!-- Necklace of Spirits +3 -->
</successItems>
</upgrade>
<upgrade id="59" type="1" chance="100" commission="500000">
<upgradeItem id="91123" count="1" enchantLevel="2" /> <!-- Petram's Necklace +2 -->
<successItems>
<item id="94682" count="1" enchantLevel="4" /> <!-- Necklace of Spirits +4 -->
</successItems>
</upgrade>
<upgrade id="60" type="1" chance="100" commission="700000">
<upgradeItem id="91123" count="1" enchantLevel="3" /> <!-- Petram's Necklace +3 -->
<successItems>
<item id="94682" count="1" enchantLevel="5" /> <!-- Necklace of Spirits +5 -->
</successItems>
</upgrade>
<upgrade id="61" type="1" chance="100" commission="1000000">
<upgradeItem id="91123" count="1" enchantLevel="4" /> <!-- Petram's Necklace +4 -->
<successItems>
<item id="94682" count="1" enchantLevel="6" /> <!-- Necklace of Spirits +6 -->
</successItems>
</upgrade>
<upgrade id="62" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="5" /> <!-- Petram's Necklace +5 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="63" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="6" /> <!-- Petram's Necklace +6 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="64" type="1" chance="100" commission="2000000">
<upgradeItem id="91123" count="1" enchantLevel="7" /> <!-- Petram's Necklace +7 -->
<successItems>
<item id="94682" count="1" enchantLevel="7" /> <!-- Necklace of Spirits +7 -->
</successItems>
</upgrade>
<upgrade id="65" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="8" /> <!-- Petram's Necklace +8 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="66" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="9" /> <!-- Petram's Necklace +9 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="67" type="1" chance="100" commission="5000000">
<upgradeItem id="91123" count="1" enchantLevel="10" /> <!-- Petram's Necklace +10 -->
<successItems>
<item id="94682" count="1" enchantLevel="8" /> <!-- Necklace of Spirits +8 -->
</successItems>
</upgrade>
<upgrade id="68" type="1" chance="23" commission="7500000">
<upgradeItem id="96600" count="1" enchantLevel="0" /> <!-- Beleth' Ring -->
<successItems>
<item id="94385" count="1" enchantLevel="0" /> <!-- Improved Scroll: Enchant Rare Accessories -->
</successItems>
<failure_items>
<item id="94383" count="1" enchantLevel="0" /> <!-- Scroll: Enchant Rare Accessories -->
</failure_items>
</upgrade>
</list>

View File

@ -37,7 +37,6 @@ import org.l2jmobius.gameserver.network.serverpackets.PackageToList;
import org.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulExtractionWindow;
import org.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgrade.ExShowUpgradeSystem;
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationCancelWindow;
import ai.AbstractNpcAI;
@ -238,8 +237,9 @@ public class GameAssistant extends AbstractNpcAI
}
case "items_conversion":
{
player.setTarget(player);
player.sendPacket(new ExShowUpgradeSystem());
// TODO: Add to html.
// player.setTarget(player);
// player.sendPacket(new ExShowUpgradeSystemNormal(1, 1));
break;
}
// Multisell

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="list" type="listType"/>
<xs:complexType name="paramsType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="commission"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="itemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="discountType">
<xs:sequence>
<xs:element type="itemType" name="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeItemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="count" use="optional"/>
<xs:attribute type="xs:string" name="enchantLevel" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="successItemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="failure_itemsType">
<xs:sequence>
<xs:element type="itemType" name="item"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="upgradeType">
<xs:sequence>
<xs:element type="upgradeItemType" name="upgradeItem"/>
<xs:element type="successItemsType" name="successItems"/>
<xs:element type="failure_itemsType" name="failure_items" minOccurs="0"/>
</xs:sequence>
<xs:attribute type="xs:string" name="id" use="optional"/>
<xs:attribute type="xs:string" name="type" use="optional"/>
<xs:attribute type="xs:string" name="chance" use="optional"/>
<xs:attribute type="xs:string" name="commission" use="optional"/>
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>
<xs:element type="paramsType" name="params"/>
<xs:element type="discountType" name="discount"/>
<xs:element type="upgradeType" name="upgrade" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@ -71,6 +71,7 @@ import org.l2jmobius.gameserver.data.xml.EnchantItemOptionsData;
import org.l2jmobius.gameserver.data.xml.EnchantSkillGroupsData;
import org.l2jmobius.gameserver.data.xml.EnsoulData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeData;
import org.l2jmobius.gameserver.data.xml.EquipmentUpgradeNormalData;
import org.l2jmobius.gameserver.data.xml.ExperienceData;
import org.l2jmobius.gameserver.data.xml.FakePlayerData;
import org.l2jmobius.gameserver.data.xml.FenceData;
@ -296,6 +297,7 @@ public class GameServer
CombinationItemsData.getInstance();
CombinationDyeData.getInstance();
EquipmentUpgradeData.getInstance();
EquipmentUpgradeNormalData.getInstance();
AgathionData.getInstance();
RaidTeleportListData.getInstance();
RecipeData.getInstance();

View File

@ -0,0 +1,180 @@
/*
* 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.data.xml;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import org.l2jmobius.commons.util.IXmlReader;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.holders.EquipmentUpgradeNormalHolder;
import org.l2jmobius.gameserver.model.holders.ItemEnchantHolder;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.serverpackets.equipmentupgradenormal.ExUpgradeSystemNormalResult;
/**
* @author Index
*/
public class EquipmentUpgradeNormalData implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(EquipmentUpgradeNormalData.class.getName());
private static final Map<Integer, EquipmentUpgradeNormalHolder> _upgrades = new HashMap<>();
private static final Set<ItemHolder> _discount = new HashSet<>();
private static int _commission;
protected EquipmentUpgradeNormalData()
{
load();
}
public void reload()
{
for (Player player : World.getInstance().getPlayers())
{
player.sendPacket(ExUpgradeSystemNormalResult.FAIL);
}
load();
}
@Override
public void load()
{
_commission = -1;
_discount.clear();
_upgrades.clear();
parseDatapackFile("data/EquipmentUpgradeNormalData.xml");
if (!_upgrades.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _upgrades.size() + " upgrade-normal equipment data. Adena commission is " + _commission + ".");
}
if (!_discount.isEmpty())
{
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _discount.size() + " upgrade-normal discount data.");
}
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode -> forEach(listNode, "params", paramNode -> _commission = new StatSet(parseAttributes(paramNode)).getInt("commission")));
if (_commission < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Commission in file EquipmentUpgradeNormalData.xml not set or less than 0! Setting up default value - 100!");
_commission = 100;
}
forEach(doc, "list", listNode -> forEach(listNode, "discount", discountNode -> forEach(discountNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
_discount.add(new ItemHolder(successSet.getInt("id"), successSet.getLong("count")));
})));
forEach(doc, "list", listNode -> forEach(listNode, "upgrade", upgradeNode ->
{
final AtomicReference<ItemEnchantHolder> initialItem = new AtomicReference<>();
final AtomicReference<List<ItemEnchantHolder>> materialItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onSuccessItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> onFailureItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<List<ItemEnchantHolder>> bonusItems = new AtomicReference<>(new ArrayList<>());
final AtomicReference<Double> bonusChance = new AtomicReference<>();
final StatSet headerSet = new StatSet(parseAttributes(upgradeNode));
final int id = headerSet.getInt("id");
final int type = headerSet.getInt("type");
final double chance = headerSet.getDouble("chance");
final long commission = _commission == 0 ? 0 : ((headerSet.getLong("commission") / 100) * _commission);
forEach(upgradeNode, "upgradeItem", upgradeItemNode ->
{
final StatSet initialSet = new StatSet(parseAttributes(upgradeItemNode));
initialItem.set(new ItemEnchantHolder(initialSet.getInt("id"), initialSet.getLong("count"), initialSet.getByte("enchantLevel")));
if (initialItem.get() == null)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " seems like broken!");
}
if (initialItem.get().getCount() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": upgradeItem -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
});
forEach(upgradeNode, "material", materialItemNode -> forEach(materialItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
materialItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
// {
// LOGGER.warning(getClass().getSimpleName() + ": material -> item -> count in file EquipmentUpgradeNormalData.xml for upgrade id " + id +" cant be less than 0!");
// }
}));
forEach(upgradeNode, "successItems", successItemNode -> forEach(successItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onSuccessItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "failure_items", failureItemNode -> forEach(failureItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
onFailureItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
}));
forEach(upgradeNode, "bonus_items", bonusItemNode ->
{
bonusChance.set(new StatSet(parseAttributes(bonusItemNode)).getDouble("chance"));
if (bonusChance.get() < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": bonus_items -> chance in file EquipmentUpgradeNormalData.xml for upgrade id " + id + " cant be less than 0!");
}
forEach(bonusItemNode, "item", itemNode ->
{
final StatSet successSet = new StatSet(parseAttributes(itemNode));
bonusItems.get().add(new ItemEnchantHolder(successSet.getInt("id"), successSet.getLong("count"), successSet.getInt("enchantLevel")));
});
});
_upgrades.put(id, new EquipmentUpgradeNormalHolder(id, type, commission, chance, initialItem.get(), materialItems.get(), onSuccessItems.get(), onFailureItems.get(), bonusChance.get() == null ? 0 : bonusChance.get(), bonusItems.get()));
}));
}
public EquipmentUpgradeNormalHolder getUpgrade(int id)
{
return _upgrades.get(id);
}
public Set<ItemHolder> getDiscount()
{
return _discount;
}
public int getCommission()
{
return _commission;
}
public static EquipmentUpgradeNormalData getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final EquipmentUpgradeNormalData INSTANCE = new EquipmentUpgradeNormalData();
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.enums;
public enum UpgradeDataType
{
MATERIAL,
ON_SUCCESS,
ON_FAILURE,
BONUS_TYPE;
}

Some files were not shown because too many files have changed in this diff Show More