Addition of ensoul extraction.
This commit is contained in:
@ -17,6 +17,8 @@
|
||||
package com.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -122,6 +124,11 @@ public class EnsoulData implements IGameXmlReader
|
||||
parseReFee(feeNode, fee, 2);
|
||||
break;
|
||||
}
|
||||
case "remove":
|
||||
{
|
||||
parseRemove(feeNode, fee);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -143,6 +150,14 @@ public class EnsoulData implements IGameXmlReader
|
||||
fee.setResoul(index, new ItemHolder(id, count));
|
||||
}
|
||||
|
||||
private void parseRemove(Node ensoulNode, EnsoulFee fee)
|
||||
{
|
||||
final NamedNodeMap attrs = ensoulNode.getAttributes();
|
||||
final int id = parseInteger(attrs, "itemId");
|
||||
final int count = parseInteger(attrs, "count");
|
||||
fee.addRemovalFee(new ItemHolder(id, count));
|
||||
}
|
||||
|
||||
private void parseOptions(Node ensoulNode)
|
||||
{
|
||||
final NamedNodeMap attrs = ensoulNode.getAttributes();
|
||||
@ -177,6 +192,12 @@ public class EnsoulData implements IGameXmlReader
|
||||
return fee != null ? fee.getResoul(index) : null;
|
||||
}
|
||||
|
||||
public Collection<ItemHolder> getRemovalFee(CrystalType type)
|
||||
{
|
||||
final EnsoulFee fee = _ensoulFees.get(type);
|
||||
return fee != null ? fee.getRemovalFee() : Collections.emptyList();
|
||||
}
|
||||
|
||||
public EnsoulOption getOption(int id)
|
||||
{
|
||||
return _ensoulOptions.get(id);
|
||||
@ -187,6 +208,24 @@ public class EnsoulData implements IGameXmlReader
|
||||
return _ensoulStones.get(id);
|
||||
}
|
||||
|
||||
public int getStone(int type, int optionId)
|
||||
{
|
||||
for (EnsoulStone stone : _ensoulStones.values())
|
||||
{
|
||||
if (stone.getSlotType() == type)
|
||||
{
|
||||
for (int id : stone.getOptions())
|
||||
{
|
||||
if (id == optionId)
|
||||
{
|
||||
return stone.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of EnsoulData.
|
||||
* @return single instance of EnsoulData
|
||||
|
@ -16,6 +16,9 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.ensoul;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
|
||||
@ -28,6 +31,7 @@ public class EnsoulFee
|
||||
|
||||
private final ItemHolder[] _ensoulFee = new ItemHolder[3];
|
||||
private final ItemHolder[] _resoulFees = new ItemHolder[3];
|
||||
private final List<ItemHolder> _removalFee = new ArrayList<>();
|
||||
|
||||
public EnsoulFee(CrystalType type)
|
||||
{
|
||||
@ -49,6 +53,11 @@ public class EnsoulFee
|
||||
_resoulFees[index] = item;
|
||||
}
|
||||
|
||||
public void addRemovalFee(ItemHolder itemHolder)
|
||||
{
|
||||
_removalFee.add(itemHolder);
|
||||
}
|
||||
|
||||
public ItemHolder getEnsoul(int index)
|
||||
{
|
||||
return _ensoulFee[index];
|
||||
@ -58,4 +67,9 @@ public class EnsoulFee
|
||||
{
|
||||
return _resoulFees[index];
|
||||
}
|
||||
|
||||
public List<ItemHolder> getRemovalFee()
|
||||
{
|
||||
return _removalFee;
|
||||
}
|
||||
}
|
||||
|
@ -2175,6 +2175,28 @@ public final class L2ItemInstance extends L2Object
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSpecialAbility(int position, int type)
|
||||
{
|
||||
if (type == 1)
|
||||
{
|
||||
final EnsoulOption option = _ensoulOptions.get(position);
|
||||
if (option != null)
|
||||
{
|
||||
removeSpecialAbility(option);
|
||||
_ensoulOptions.remove(position);
|
||||
}
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
final EnsoulOption option = _ensoulSpecialOptions.get(position);
|
||||
if (option != null)
|
||||
{
|
||||
removeSpecialAbility(option);
|
||||
_ensoulSpecialOptions.remove(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSpecialAbilities()
|
||||
{
|
||||
_ensoulOptions.values().forEach(this::clearSpecialAbility);
|
||||
|
@ -68,6 +68,7 @@ import com.l2jmobius.gameserver.network.clientpackets.compound.RequestNewEnchant
|
||||
import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeEstimate;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.crystalization.RequestCrystallizeItemCancel;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestItemEnsoul;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.ensoul.RequestTryEnSoulExtraction;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.faction.RequestUserFactionInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.friend.RequestFriendDetailInfo;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.luckygame.RequestLuckyGamePlay;
|
||||
@ -396,7 +397,7 @@ public enum ExIncomingPackets implements IIncomingPackets<L2GameClient>
|
||||
REQUEST_SSO_AUTHN_TOKEN(0x125, null, ConnectionState.IN_GAME),
|
||||
REQUEST_QUEUE_TICKET_LOGIN(0x126, null, ConnectionState.IN_GAME),
|
||||
REQUEST_BLOCK_MEMO_INFO(0x127, null, ConnectionState.IN_GAME),
|
||||
REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, null, ConnectionState.IN_GAME),
|
||||
REQUEST_TRY_EN_SOUL_EXTRACTION(0x128, RequestTryEnSoulExtraction::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RAIDBOSS_SPAWN_INFO(0x129, RequestRaidBossSpawnInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_RAID_SERVER_INFO(0x12A, RequestRaidServerInfo::new, ConnectionState.IN_GAME),
|
||||
REQUEST_SHOW_AGIT_SIEGE_INFO(0x12B, null, ConnectionState.IN_GAME),
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.ensoul;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnsoulData;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.ensoul.EnsoulOption;
|
||||
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.ensoul.ExEnSoulExtractionResult;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RequestTryEnSoulExtraction implements IClientIncomingPacket
|
||||
{
|
||||
private int _itemObjectId;
|
||||
private int _type;
|
||||
private int _position;
|
||||
|
||||
@Override
|
||||
public boolean read(L2GameClient client, PacketReader packet)
|
||||
{
|
||||
_itemObjectId = packet.readD();
|
||||
_type = packet.readC();
|
||||
_position = packet.readC() - 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(L2GameClient client)
|
||||
{
|
||||
L2PcInstance player = client.getActiveChar();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final L2ItemInstance item = player.getInventory().getItemByObjectId(_itemObjectId);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnsoulOption option = null;
|
||||
if (_type == 1)
|
||||
{
|
||||
option = item.getSpecialAbility(_position);
|
||||
}
|
||||
if (_type == 2)
|
||||
{
|
||||
option = item.getAdditionalSpecialAbility(_position);
|
||||
}
|
||||
if (option == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Collection<ItemHolder> removalFee = EnsoulData.getInstance().getRemovalFee(item.getItem().getCrystalType());
|
||||
if (removalFee.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player has required items.
|
||||
for (ItemHolder itemHolder : removalFee)
|
||||
{
|
||||
if (player.getInventory().getInventoryItemCount(itemHolder.getId(), -1) < itemHolder.getCount())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT);
|
||||
player.sendPacket(new ExEnSoulExtractionResult(false, item));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Take required items.
|
||||
for (ItemHolder itemHolder : removalFee)
|
||||
{
|
||||
player.destroyItemByItemId("Rune Extract", itemHolder.getId(), itemHolder.getCount(), player, true);
|
||||
}
|
||||
|
||||
// Remove equipped rune.
|
||||
item.removeSpecialAbility(_position, _type);
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(item);
|
||||
|
||||
// Add rune in player inventory.
|
||||
final int runeId = EnsoulData.getInstance().getStone(_type, option.getId());
|
||||
if (runeId > 0)
|
||||
{
|
||||
iu.addItem(player.addItem("Rune Extract", runeId, 1, player, true));
|
||||
}
|
||||
|
||||
player.sendInventoryUpdate(iu);
|
||||
player.sendPacket(new ExEnSoulExtractionResult(true, item));
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.ensoul;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.model.ensoul.EnsoulOption;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ExEnSoulExtractionResult implements IClientOutgoingPacket
|
||||
{
|
||||
private final boolean _success;
|
||||
private final L2ItemInstance _item;
|
||||
|
||||
public ExEnSoulExtractionResult(boolean success, L2ItemInstance item)
|
||||
{
|
||||
_success = success;
|
||||
_item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENSOUL_EXTRACTION_RESULT.writeId(packet);
|
||||
packet.writeC(_success ? 1 : 0);
|
||||
if (_success)
|
||||
{
|
||||
packet.writeC(_item.getSpecialAbilities().size());
|
||||
for (EnsoulOption option : _item.getSpecialAbilities())
|
||||
{
|
||||
packet.writeD(option.getId());
|
||||
}
|
||||
packet.writeC(_item.getAdditionalSpecialAbilities().size());
|
||||
for (EnsoulOption option : _item.getAdditionalSpecialAbilities())
|
||||
{
|
||||
packet.writeD(option.getId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.ensoul;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ExShowEnsoulExtractionWindow implements IClientOutgoingPacket
|
||||
{
|
||||
public static final ExShowEnsoulExtractionWindow STATIC_PACKET = new ExShowEnsoulExtractionWindow();
|
||||
|
||||
private ExShowEnsoulExtractionWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_ENSOUL_EXTRACTION_SHOW.writeId(packet);
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user