Removed Alchemy packets.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,51 +0,0 @@
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="list">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="skill" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ingredients">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:int" name="id" use="required" />
|
||||
<xs:attribute type="xs:short" name="count" use="required" />
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="production">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="item" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
<xs:extension base="xs:string">
|
||||
<xs:attribute type="xs:int" name="id" use="required" />
|
||||
<xs:attribute type="xs:byte" name="count" use="required" />
|
||||
<xs:attribute type="xs:string" name="type" use="required" />
|
||||
</xs:extension>
|
||||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute type="xs:short" name="id" use="required" />
|
||||
<xs:attribute type="xs:byte" name="level" use="required" />
|
||||
<xs:attribute type="xs:byte" name="grade" use="required" />
|
||||
<xs:attribute type="xs:byte" name="category" use="required" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@@ -40,7 +40,6 @@ import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.OfflineTradersTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ActionData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AlchemyData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AttendanceRewardData;
|
||||
@@ -238,7 +237,6 @@ public class GameServer
|
||||
PrimeShopData.getInstance();
|
||||
PcCafePointsManager.getInstance();
|
||||
AppearanceItemData.getInstance();
|
||||
AlchemyData.getInstance();
|
||||
CommissionManager.getInstance();
|
||||
LuckyGameData.getInstance();
|
||||
AttendanceRewardData.getInstance();
|
||||
|
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.alchemy.AlchemyCraftData;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class AlchemyData implements IGameXmlReader
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AlchemyData.class.getName());
|
||||
|
||||
private final Map<Long, AlchemyCraftData> _alchemy = new HashMap<>();
|
||||
|
||||
protected AlchemyData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_alchemy.clear();
|
||||
parseDatapackFile("data/AlchemyData.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _alchemy.size() + " alchemy craft skills.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
StatsSet set;
|
||||
Node att;
|
||||
NamedNodeMap attrs;
|
||||
for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
if ("list".equalsIgnoreCase(n.getNodeName()))
|
||||
{
|
||||
for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
|
||||
{
|
||||
if ("skill".equalsIgnoreCase(d.getNodeName()))
|
||||
{
|
||||
attrs = d.getAttributes();
|
||||
set = new StatsSet();
|
||||
for (int i = 0; i < attrs.getLength(); i++)
|
||||
{
|
||||
att = attrs.item(i);
|
||||
set.set(att.getNodeName(), att.getNodeValue());
|
||||
}
|
||||
|
||||
final AlchemyCraftData alchemyCraft = new AlchemyCraftData(set);
|
||||
|
||||
for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
|
||||
{
|
||||
if ("ingredients".equalsIgnoreCase(c.getNodeName()))
|
||||
{
|
||||
for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
|
||||
{
|
||||
if ("item".equalsIgnoreCase(b.getNodeName()))
|
||||
{
|
||||
final int ingId = Integer.parseInt(b.getAttributes().getNamedItem("id").getNodeValue());
|
||||
final int ingCount = Integer.parseInt(b.getAttributes().getNamedItem("count").getNodeValue());
|
||||
alchemyCraft.addIngredient(new ItemHolder(ingId, ingCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("production".equalsIgnoreCase(c.getNodeName()))
|
||||
{
|
||||
for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
|
||||
{
|
||||
if ("item".equalsIgnoreCase(b.getNodeName()))
|
||||
{
|
||||
final String type = b.getAttributes().getNamedItem("type").getNodeValue();
|
||||
final int prodId = Integer.parseInt(b.getAttributes().getNamedItem("id").getNodeValue());
|
||||
final int prodCount = Integer.parseInt(b.getAttributes().getNamedItem("count").getNodeValue());
|
||||
|
||||
if (type.equalsIgnoreCase("ON_SUCCESS"))
|
||||
{
|
||||
alchemyCraft.setProductionSuccess(new ItemHolder(prodId, prodCount));
|
||||
}
|
||||
else if (type.equalsIgnoreCase("ON_FAILURE"))
|
||||
{
|
||||
alchemyCraft.setProductionFailure(new ItemHolder(prodId, prodCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_alchemy.put(SkillData.getSkillHashCode(set.getInt("id"), set.getInt("level")), alchemyCraft);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AlchemyCraftData getCraftData(int skillId, int skillLevel)
|
||||
{
|
||||
return _alchemy.get(SkillData.getSkillHashCode(skillId, skillLevel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of AlchemyData.
|
||||
* @return single instance of AlchemyData
|
||||
*/
|
||||
public static AlchemyData getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AlchemyData _instance = new AlchemyData();
|
||||
}
|
||||
}
|
@@ -28,8 +28,6 @@ import com.l2jmobius.gameserver.network.clientpackets.*;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.adenadistribution.RequestDivideAdena;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.adenadistribution.RequestDivideAdenaCancel;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.adenadistribution.RequestDivideAdenaStart;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.alchemy.RequestAlchemyConversion;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.alchemy.RequestAlchemyTryMixCube;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExCancelShape_Shifting_Item;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;
|
||||
@@ -340,8 +338,8 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
REQUEST_NEW_ENCHANT_TRY(0xF9, RequestNewEnchantTry::new, ConnectionState.IN_GAME),
|
||||
EX_SEND_SELECTED_QUEST_ZONE_ID(0xFF, ExSendSelectedQuestZoneID::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_SKILL_LIST(0x100, RequestAlchemySkillList::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_TRY_MIX_CUBE(0x101, RequestAlchemyTryMixCube::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_CONVERSION(0x102, RequestAlchemyConversion::new, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_TRY_MIX_CUBE(0x101, null, ConnectionState.IN_GAME),
|
||||
REQUEST_ALCHEMY_CONVERSION(0x102, null, ConnectionState.IN_GAME),
|
||||
SEND_EXECUTED_UI_EVENTS_COUNT(0x103, null, ConnectionState.IN_GAME),
|
||||
EX_SEND_CLIENT_INI(0x104, null, ConnectionState.AUTHENTICATED),
|
||||
REQUEST_EX_AUTO_FISH(0x105, ExRequestAutoFish::new, ConnectionState.IN_GAME),
|
||||
|
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.alchemy;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AlchemyData;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.alchemy.AlchemyCraftData;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.alchemy.ExAlchemyConversion;
|
||||
import com.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestAlchemyConversion implements IClientIncomingPacket
|
||||
{
|
||||
private int _craftTimes;
|
||||
private int _skillId;
|
||||
private int _skillLevel;
|
||||
|
||||
private final Set<ItemHolder> _ingredients = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_craftTimes = packet.readD();
|
||||
packet.readH(); // TODO: Find me
|
||||
_skillId = packet.readD();
|
||||
_skillLevel = packet.readD();
|
||||
|
||||
final int ingredientsSize = packet.readD();
|
||||
for (int i = 0; i < ingredientsSize; i++)
|
||||
{
|
||||
_ingredients.add(new ItemHolder(packet.readD(), packet.readQ()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if ((player == null) || (player.getRace() != Race.ERTHEIA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_DURING_BATTLE);
|
||||
return;
|
||||
}
|
||||
else if (player.isInStoreMode() || (player.getPrivateStoreType() != PrivateStoreType.NONE))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_TRADING_OR_USING_A_PRIVATE_STORE_OR_SHOP);
|
||||
return;
|
||||
}
|
||||
else if (player.isDead())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_DEAD);
|
||||
return;
|
||||
}
|
||||
else if (player.isMovementDisabled())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_IMMOBILE);
|
||||
return;
|
||||
}
|
||||
|
||||
final AlchemyCraftData data = AlchemyData.getInstance().getCraftData(_skillId, _skillLevel);
|
||||
if (data == null)
|
||||
{
|
||||
_log.warning("Missing AlchemyData for skillId: " + _skillId + ", skillLevel: " + _skillLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO : Implement this
|
||||
// if (!_ingredients.equals(data.getIngredients()))
|
||||
// {
|
||||
// LOGGER.warning("Client ingredients are not same as server ingredients for alchemy conversion player: "+ +"", player);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// TODO: Figure out the chance
|
||||
final int baseChance;
|
||||
switch (data.getGrade())
|
||||
{
|
||||
case 1: // Elementary
|
||||
{
|
||||
baseChance = 100;
|
||||
break;
|
||||
}
|
||||
case 2: // Intermediate
|
||||
{
|
||||
baseChance = 80;
|
||||
break;
|
||||
}
|
||||
case 3: // Advanced
|
||||
{
|
||||
baseChance = 60;
|
||||
break;
|
||||
}
|
||||
default: // Master
|
||||
{
|
||||
baseChance = 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
int failureCount = 0;
|
||||
|
||||
// Run _craftItems iteration of item craft
|
||||
final InventoryUpdate ui = new InventoryUpdate();
|
||||
CRAFTLOOP: for (int i = 0; i < _craftTimes; i++)
|
||||
{
|
||||
// for each tries, check if player have enough items and destroy
|
||||
for (ItemHolder ingredient : data.getIngredients())
|
||||
{
|
||||
final L2ItemInstance item = player.getInventory().getItemByItemId(ingredient.getId());
|
||||
if (item == null)
|
||||
{
|
||||
break CRAFTLOOP;
|
||||
}
|
||||
if (item.getCount() < ingredient.getCount())
|
||||
{
|
||||
break CRAFTLOOP;
|
||||
}
|
||||
|
||||
player.getInventory().destroyItem("Alchemy", item, ingredient.getCount(), player, null);
|
||||
ui.addItem(item);
|
||||
}
|
||||
|
||||
if (Rnd.get(100) < baseChance)
|
||||
{
|
||||
successCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
failureCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0)
|
||||
{
|
||||
final L2ItemInstance item = player.getInventory().addItem("Alchemy", data.getProductionSuccess().getId(), data.getProductionSuccess().getCount() * successCount, player, null);
|
||||
ui.addItem(item);
|
||||
}
|
||||
|
||||
if (failureCount > 0)
|
||||
{
|
||||
final L2ItemInstance item = player.getInventory().addItem("Alchemy", data.getProductionFailure().getId(), data.getProductionFailure().getCount() * failureCount, player, null);
|
||||
ui.addItem(item);
|
||||
}
|
||||
|
||||
player.sendPacket(new ExAlchemyConversion(successCount, failureCount));
|
||||
player.sendInventoryUpdate(ui);
|
||||
|
||||
}
|
||||
}
|
@@ -1,220 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets.alchemy;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.enums.TryMixCubeResultType;
|
||||
import com.l2jmobius.gameserver.enums.TryMixCubeType;
|
||||
import com.l2jmobius.gameserver.model.PcCondOverride;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.AlchemyResult;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.CommonSkill;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.alchemy.ExTryMixCube;
|
||||
import com.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class RequestAlchemyTryMixCube implements IClientIncomingPacket
|
||||
{
|
||||
// TODO: Figure out how much stones are given
|
||||
private static final int TEMPEST_STONE_AMOUNT = 1;
|
||||
|
||||
private final List<ItemHolder> _items = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
final int itemsCount = packet.readD();
|
||||
if ((itemsCount <= 0) || (itemsCount > 4))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
{
|
||||
_items.add(new ItemHolder(packet.readD(), packet.readQ()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
final L2PcInstance player = client.getActiveChar();
|
||||
if ((player == null) || (player.getRace() != Race.ERTHEIA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_DURING_BATTLE);
|
||||
return;
|
||||
}
|
||||
else if (player.isInStoreMode() || (player.getPrivateStoreType() != PrivateStoreType.NONE))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_TRADING_OR_USING_A_PRIVATE_STORE_OR_SHOP);
|
||||
return;
|
||||
}
|
||||
else if (player.isDead())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_DEAD);
|
||||
return;
|
||||
}
|
||||
else if (player.isMovementDisabled())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_IMMOBILE);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((player.getKnownSkill(CommonSkill.ALCHEMY_CUBE.getId()) == null) && !player.canOverrideCond(PcCondOverride.SKILL_CONDITIONS))
|
||||
{
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_SKILL_WRONG));
|
||||
return;
|
||||
}
|
||||
|
||||
int position = 0;
|
||||
long itemsPrice = 0;
|
||||
|
||||
// First loop for safety check + price calculation
|
||||
for (ItemHolder item : _items)
|
||||
{
|
||||
final L2ItemInstance itemInstance = player.getInventory().getItemByObjectId(item.getId());
|
||||
if (itemInstance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((itemInstance.getCount() <= 0) || (itemInstance.getCount() < item.getCount()))
|
||||
{
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_ITEM_WRONG));
|
||||
return;
|
||||
}
|
||||
|
||||
final int price = itemInstance.getReferencePrice();
|
||||
if (itemInstance.getReferencePrice() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THIS_ITEM_CANNOT_BE_COMBINED);
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_ITEM_WRONG));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((itemInstance.getEnchantLevel() > 0) || itemInstance.isAugmented())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_COMBINE_ITEMS_THAT_HAVE_BEEN_ENCHANTED_OR_AUGMENTED);
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_ITEM_WRONG));
|
||||
return;
|
||||
}
|
||||
|
||||
itemsPrice += price * item.getCount();
|
||||
position++;
|
||||
|
||||
if ((position == 4) && (itemInstance.getId() != Inventory.ELCYUM_CRYSTAL_ID))
|
||||
{
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_ITEM_WRONG));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the amount of air stones the player should received based on the total price of items he mixed.
|
||||
int airStonesCount = (int) Math.floor((itemsPrice / 5_000) * (_items.size() < 3 ? 0.3f : 0.5f));
|
||||
|
||||
// Process only if there is at least one air stone to give
|
||||
if (airStonesCount > 0)
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
|
||||
long elcyumCrystals = 0;
|
||||
|
||||
// Second loop for items deletion if we're still in the game
|
||||
for (ItemHolder item : _items)
|
||||
{
|
||||
final L2ItemInstance itemInstance = player.getInventory().getItemByObjectId(item.getId());
|
||||
if (itemInstance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInstance.getCount() < item.getCount())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemInstance.getId() == Inventory.ELCYUM_CRYSTAL_ID)
|
||||
{
|
||||
elcyumCrystals = item.getCount();
|
||||
}
|
||||
|
||||
player.getInventory().destroyItem("Alchemy", itemInstance, item.getCount(), player, null);
|
||||
iu.addItem(itemInstance);
|
||||
}
|
||||
|
||||
final ExTryMixCube mixCubeResult = new ExTryMixCube(TryMixCubeType.SUCCESS_NORMAL);
|
||||
|
||||
// Whenever there is Elcyum Crystal applied there's a chance to receive Tempest Stone
|
||||
// TODO: Figure out the chance
|
||||
if ((elcyumCrystals > 0) && (Rnd.get(100) < 50))
|
||||
{
|
||||
// Broadcast animation on success
|
||||
player.broadcastPacket(new MagicSkillUse(player, CommonSkill.ALCHEMY_CUBE_RANDOM_SUCCESS.getId(), TEMPEST_STONE_AMOUNT, 500, 1500));
|
||||
|
||||
// Give Tempest Stone to the player
|
||||
final L2ItemInstance tempestStonesInstance = player.addItem("Alchemy", Inventory.TEMPEST_STONE_ID, TEMPEST_STONE_AMOUNT, null, true);
|
||||
iu.addItem(tempestStonesInstance);
|
||||
|
||||
// Add the alchemy result entry to the packet
|
||||
mixCubeResult.addItem(new AlchemyResult(Inventory.TEMPEST_STONE_ID, TEMPEST_STONE_AMOUNT, TryMixCubeResultType.EXTRA));
|
||||
}
|
||||
|
||||
// Calculate the elcyum crystals bonus
|
||||
final boolean bonusSuccess = ((100. * Rnd.nextDouble()) < (elcyumCrystals / 1000));
|
||||
if (bonusSuccess)
|
||||
{
|
||||
airStonesCount *= Math.min(elcyumCrystals, 2);
|
||||
}
|
||||
|
||||
final L2ItemInstance airStonesInstance = player.addItem("Alchemy", Inventory.AIR_STONE_ID, airStonesCount, null, true);
|
||||
iu.addItem(airStonesInstance);
|
||||
|
||||
// Add the Air Stones
|
||||
mixCubeResult.addItem(new AlchemyResult(Inventory.AIR_STONE_ID, airStonesCount, bonusSuccess ? TryMixCubeResultType.BONUS : TryMixCubeResultType.NORMAL));
|
||||
|
||||
// send packets
|
||||
player.sendPacket(mixCubeResult);
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExTryMixCube(TryMixCubeType.FAIL_ITEM_WRONG));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.alchemy;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExAlchemyConversion implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _successCount;
|
||||
private final int _failureCount;
|
||||
|
||||
public ExAlchemyConversion(int successCount, int failureCount)
|
||||
{
|
||||
_successCount = successCount;
|
||||
_failureCount = failureCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ALCHEMY_CONVERSION.writeId(packet);
|
||||
|
||||
packet.writeC(0x00); // TODO: Find me
|
||||
packet.writeD(_successCount);
|
||||
packet.writeD(_failureCount);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.serverpackets.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.enums.TryMixCubeType;
|
||||
import com.l2jmobius.gameserver.model.holders.AlchemyResult;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExTryMixCube implements IClientOutgoingPacket
|
||||
{
|
||||
private final TryMixCubeType _type;
|
||||
private final List<AlchemyResult> _items = new ArrayList<>();
|
||||
|
||||
public ExTryMixCube(TryMixCubeType type)
|
||||
{
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public void addItem(AlchemyResult item)
|
||||
{
|
||||
_items.add(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_TRY_MIX_CUBE.writeId(packet);
|
||||
|
||||
packet.writeC(_type.ordinal());
|
||||
packet.writeD(_items.size());
|
||||
for (AlchemyResult holder : _items)
|
||||
{
|
||||
packet.writeC(holder.getType().ordinal());
|
||||
packet.writeD(holder.getId());
|
||||
packet.writeQ(holder.getCount());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user