Moved alchemy packets to seperate folders.

This commit is contained in:
MobiusDev 2015-11-16 20:33:26 +00:00
parent a4630cae9b
commit 3864680edd
9 changed files with 216 additions and 144 deletions

View File

@ -32,6 +32,9 @@ import com.l2jserver.gameserver.network.clientpackets.*;
import com.l2jserver.gameserver.network.clientpackets.adenadistribution.RequestDivideAdena;
import com.l2jserver.gameserver.network.clientpackets.adenadistribution.RequestDivideAdenaCancel;
import com.l2jserver.gameserver.network.clientpackets.adenadistribution.RequestDivideAdenaStart;
import com.l2jserver.gameserver.network.clientpackets.alchemy.RequestAlchemyConversion;
import com.l2jserver.gameserver.network.clientpackets.alchemy.RequestAlchemySkillList;
import com.l2jserver.gameserver.network.clientpackets.alchemy.RequestAlchemyTryMixCube;
import com.l2jserver.gameserver.network.clientpackets.appearance.RequestExCancelShape_Shifting_Item;
import com.l2jserver.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingEnchantSupportItem;
import com.l2jserver.gameserver.network.clientpackets.appearance.RequestExTryToPutShapeShiftingTargetItem;

View File

@ -48,7 +48,6 @@ import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillDone;
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList;
import com.l2jserver.gameserver.network.serverpackets.ExAcquirableSkillListByClass;
import com.l2jserver.gameserver.network.serverpackets.ExAlchemySkillList;
import com.l2jserver.gameserver.network.serverpackets.ExBasicActionList;
import com.l2jserver.gameserver.network.serverpackets.ExStorageMaxCount;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
@ -56,6 +55,7 @@ import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
import com.l2jserver.gameserver.network.serverpackets.ShortCutInit;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
import com.l2jserver.gameserver.network.serverpackets.alchemy.ExAlchemySkillList;
import com.l2jserver.gameserver.util.Util;
/**

View File

@ -1,118 +0,0 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExTryMixCube;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
/**
* @author GenCloud
*/
public class RequestAlchemyTryMixCube extends L2GameClientPacket
{
private int _activeItems;
private int[] _objId;
private long[] _itemCounts;
private long _allPrice = 0;
private long _stoneCount;
private final int _stoneID = 39461;
@SuppressWarnings("unused")
private final boolean _isActiveMegaStone = false;
@Override
protected void readImpl()
{
_activeItems = readD();
_objId = new int[5];
_itemCounts = new long[5];
switch (_activeItems)
{
case 1:
{
_objId[1] = readD();
_itemCounts[1] = readQ();
break;
}
case 2:
{
_objId[1] = readD();
_itemCounts[1] = readQ();
_objId[2] = readD();
_itemCounts[2] = readQ();
break;
}
case 3:
{
_objId[1] = readD();
_itemCounts[1] = readQ();
_objId[2] = readD();
_itemCounts[2] = readQ();
_objId[3] = readD();
_itemCounts[3] = readQ();
break;
}
case 4:
{
_objId[1] = readD();
_itemCounts[1] = readQ();
_objId[2] = readD();
_itemCounts[2] = readQ();
_objId[3] = readD();
_itemCounts[3] = readQ();
_objId[4] = readD();
_itemCounts[4] = readQ();
break;
}
}
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if ((activeChar == null) || (activeChar.getRace() != Race.ERTHEIA))
{
return;
}
for (int i = 1; i <= _activeItems; i++)
{
_allPrice = _allPrice + (_itemCounts[i] * activeChar.getInventory().getItemByObjectId(_objId[i]).getReferencePrice());
activeChar.getInventory().destroyItem("Alchemy", _objId[i], _itemCounts[i], activeChar, null);
}
_stoneCount = _allPrice / 10000; // TODO: formula is not the correct ratio
activeChar.getInventory().addItem("Alchemy", _stoneID, _stoneCount, activeChar, null);
activeChar.sendPacket(new ExTryMixCube(_stoneCount, _stoneID, 0));
activeChar.sendPacket(new ItemList(activeChar, false));
}
@Override
public String getType()
{
return getClass().getSimpleName();
}
}

View File

@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
package com.l2jserver.gameserver.network.clientpackets.alchemy;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.enums.Race;
@ -25,8 +25,9 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.ItemHolder;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExAlchemyConversion;
import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2jserver.gameserver.network.serverpackets.ItemList;
import com.l2jserver.gameserver.network.serverpackets.alchemy.ExAlchemyConversion;
import com.l2jserver.util.Rnd;
/**

View File

@ -16,11 +16,12 @@
* 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.l2jserver.gameserver.network.clientpackets;
package com.l2jserver.gameserver.network.clientpackets.alchemy;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.ExAlchemySkillList;
import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2jserver.gameserver.network.serverpackets.alchemy.ExAlchemySkillList;
/**
* @author UnAfraid

View File

@ -0,0 +1,175 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.network.clientpackets.alchemy;
import java.util.HashMap;
import java.util.Map;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2jserver.gameserver.network.serverpackets.alchemy.ExTryMixCube;
public class RequestAlchemyTryMixCube extends L2GameClientPacket
{
private final static int AIR_STONE = 39461;
private final static int ELCYUM_CRYSTAL = 36514;
private final Map<Integer, Long> _items = new HashMap<>();
public RequestAlchemyTryMixCube()
{
_items.clear();
}
@Override
protected void readImpl()
{
final int count = readD();
for (int i = 0; i < count; ++i)
{
final int itemObjectId = readD();
final long itemCount = readQ();
_items.put(itemObjectId, itemCount);
}
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if ((_items == null) || _items.isEmpty())
{
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isInCombat())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_DURING_BATTLE);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isInStoreMode() || activeChar.isInStoreMode())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_TRADING_OR_USING_A_PRIVATE_STORE_OR_SHOP);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isDead())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_DEAD);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isMovementDisabled())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_IMMOBILE);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
long totalPrice = 0;
long count = 0;
for (int itemId : _items.keySet())
{
final int itemObjectId = itemId;
final long itemCount = _items.get(itemId);
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(itemObjectId);
if (item != null)
{
if (item.getCount() < itemCount)
{
continue;
}
if (!item.isDestroyable())
{
continue;
}
if (item.getEnchantLevel() > 0)
{
continue;
}
if (item.isAugmented())
{
continue;
}
if (item.isShadowItem())
{
continue;
}
if (item.getId() == ELCYUM_CRYSTAL)
{
if (_items.size() <= 3)
{
continue;
}
count = itemCount;
}
else
{
final long price = item.getId() == Inventory.ADENA_ID ? itemCount : item.getReferencePrice();
if (price <= 0)
{
continue;
}
totalPrice += price;
}
activeChar.destroyItem("AlchemyMixCube", itemObjectId, itemCount, activeChar, true);
}
}
long stoneCount = 0;
if (totalPrice > 0)
{
if (_items.size() >= 3)
{
stoneCount = totalPrice / 10000;
stoneCount += count * 1000;
}
else if ((totalPrice >= 20000) && (totalPrice < 35000))
{
stoneCount = 1;
}
else if ((totalPrice >= 35000) && (totalPrice < 50000))
{
stoneCount = 2;
}
else if (totalPrice >= 50000)
{
stoneCount = (long) Math.floor(totalPrice / 16666.666666666668);
}
}
if (stoneCount > 0)
{
activeChar.addItem("AlchemyMixCube", AIR_STONE, stoneCount, activeChar, true);
}
activeChar.sendPacket(new ExTryMixCube(AIR_STONE, stoneCount));
}
@Override
public String getType()
{
return getClass().getSimpleName();
}
}

View File

@ -16,7 +16,9 @@
* 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.l2jserver.gameserver.network.serverpackets;
package com.l2jserver.gameserver.network.serverpackets.alchemy;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* @author Mobius
@ -35,7 +37,7 @@ public class ExAlchemyConversion extends L2GameServerPacket
@Override
protected void writeImpl()
{
writeC(0x00); // Unk
writeC(0x00); // Unk???
writeD(_itemCount);
writeD(_failCount);
}

View File

@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
package com.l2jserver.gameserver.network.serverpackets.alchemy;
import java.util.ArrayList;
import java.util.List;
@ -24,12 +24,14 @@ import java.util.List;
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* @author UnAfraid
*/
public class ExAlchemySkillList extends L2GameServerPacket
{
private final static int ALCHEMY_CUBE_SKILL = 17943;
private final List<Skill> _skills = new ArrayList<>();
public ExAlchemySkillList(final L2PcInstance player)
@ -55,7 +57,7 @@ public class ExAlchemySkillList extends L2GameServerPacket
writeD(skill.getId());
writeD(skill.getLevel());
writeQ(0x00); // Always 0 on Naia, SP i guess?
writeC(0x01); // Always 1 on Naia
writeC(skill.getId() == ALCHEMY_CUBE_SKILL ? 0 : 1);
}
}
}

View File

@ -16,32 +16,38 @@
* 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.l2jserver.gameserver.network.serverpackets;
package com.l2jserver.gameserver.network.serverpackets.alchemy;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* @author GenCloud
*/
public class ExTryMixCube extends L2GameServerPacket
{
private final int _stoneID;
private final long _count;
@SuppressWarnings("unused")
private final int _typePacket;
public static final L2GameServerPacket FAIL = new ExTryMixCube(6);
private final int _result;
private final int _itemId;
private final long _itemCount;
public ExTryMixCube(long count, int stoneId, int type)
public ExTryMixCube(final int result)
{
_count = count;
_typePacket = type;
_stoneID = stoneId;
_result = result;
_itemId = 0;
_itemCount = 0;
}
public ExTryMixCube(final int itemId, final long itemCount)
{
_result = 0;
_itemId = itemId;
_itemCount = itemCount;
}
@Override
protected void writeImpl()
{
writeC(0x00); // Unk
writeC(0x01); // Type
writeD(0x00); // Unk
writeD(_stoneID); // StoneID
writeQ(_count); // Count
writeC(_result);
writeD(0x01);
writeC(0x00);
writeD(_itemId);
writeQ(_itemCount);
}
}