Addition of auto peel system.

This commit is contained in:
MobiusDevelopment 2022-10-20 21:30:47 +00:00
parent c457a227e6
commit eba7966d32
14 changed files with 503 additions and 7 deletions

View File

@ -18,6 +18,7 @@ package handlers.itemhandlers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -30,11 +31,14 @@ import org.l2jmobius.gameserver.instancemanager.DailyTaskManager;
import org.l2jmobius.gameserver.model.ExtractableProduct;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.model.item.EtcItem;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExResultItemAutoPeel;
/**
* Extractable Items handler.
@ -232,7 +236,19 @@ public class ExtractableItems implements IItemHandler
for (Entry<Item, Long> entry : extractedItems.entrySet())
{
sendMessage(player, entry.getKey(), entry.getValue().longValue());
sendMessage(player, entry.getKey(), entry.getValue());
}
final AutoPeelRequest request = player.getRequest(AutoPeelRequest.class);
if ((request != null) && request.isProcessing())
{
request.setProcessing(false);
final List<ItemHolder> rewards = new LinkedList<>();
for (Entry<Item, Long> entry : extractedItems.entrySet())
{
rewards.add(new ItemHolder(entry.getKey().getId(), entry.getValue()));
}
player.sendPacket(new ExResultItemAutoPeel(true, request.getTotalPeelCount(), request.getRemainingPeelCount() - 1, rewards));
}
return true;

View File

@ -182,6 +182,7 @@ import org.l2jmobius.gameserver.model.actor.instance.Shuttle;
import org.l2jmobius.gameserver.model.actor.instance.TamedBeast;
import org.l2jmobius.gameserver.model.actor.instance.Trap;
import org.l2jmobius.gameserver.model.actor.request.AbstractRequest;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.actor.request.SayuneRequest;
import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
import org.l2jmobius.gameserver.model.actor.status.PlayerStatus;
@ -379,6 +380,8 @@ import org.l2jmobius.gameserver.network.serverpackets.TradeOtherDone;
import org.l2jmobius.gameserver.network.serverpackets.TradeStart;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExReadyItemAutoPeel;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExStopItemAutoPeel;
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExAutoPlaySettingSend;
import org.l2jmobius.gameserver.network.serverpackets.commission.ExResponseCommissionInfo;
@ -5017,6 +5020,14 @@ public class Player extends Playable
@Override
public boolean doDie(Creature killer)
{
// Stop auto peel.
if (hasRequest(AutoPeelRequest.class))
{
sendPacket(new ExStopItemAutoPeel(true));
sendPacket(new ExReadyItemAutoPeel(false, 0));
removeRequest(AutoPeelRequest.class);
}
Collection<Item> droppedItems = null;
if (killer != null)
@ -10879,6 +10890,14 @@ public class Player extends Playable
{
super.onTeleported();
// Stop auto peel.
if (hasRequest(AutoPeelRequest.class))
{
sendPacket(new ExStopItemAutoPeel(true));
sendPacket(new ExReadyItemAutoPeel(false, 0));
removeRequest(AutoPeelRequest.class);
}
if (isInAirShip())
{
getAirShip().sendInfo(this);

View File

@ -0,0 +1,79 @@
/*
* 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.actor.request;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.item.instance.Item;
/**
* @author Mobius
*/
public class AutoPeelRequest extends AbstractRequest
{
private final Item _item;
private long _totalPeelCount;
private long _remainingPeelCount;
public AutoPeelRequest(Player player, Item item)
{
super(player);
_item = item;
}
public Item getItem()
{
return _item;
}
public long getTotalPeelCount()
{
return _totalPeelCount;
}
public void setTotalPeelCount(long count)
{
_totalPeelCount = count;
}
public long getRemainingPeelCount()
{
return _remainingPeelCount;
}
public void setRemainingPeelCount(long count)
{
_remainingPeelCount = count;
}
@Override
public boolean isItemRequest()
{
return true;
}
@Override
public boolean canWorkWith(AbstractRequest request)
{
return !request.isItemRequest();
}
@Override
public boolean isUsing(int objectId)
{
return _item.getObjectId() == objectId;
}
}

View File

@ -61,6 +61,7 @@ import org.l2jmobius.gameserver.model.WorldRegion;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.conditions.Condition;
import org.l2jmobius.gameserver.model.ensoul.EnsoulOption;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
@ -1841,8 +1842,8 @@ public class Item extends WorldObject
return true;
}
final Creature owner = getActingPlayer();
if (owner != null)
final Player player = getActingPlayer();
if (player != null)
{
for (Condition condition : _itemTemplate.getConditions())
{
@ -1851,7 +1852,16 @@ public class Item extends WorldObject
continue;
}
if (!condition.testImpl(owner, owner, null, _itemTemplate))
if (!condition.testImpl(player, player, null, _itemTemplate))
{
return false;
}
}
if (player.hasRequest(AutoPeelRequest.class))
{
final EtcItem etcItem = getEtcItem();
if ((etcItem != null) && (etcItem.getExtractableItems() != null))
{
return false;
}

View File

@ -38,6 +38,9 @@ import org.l2jmobius.gameserver.network.clientpackets.attendance.RequestVipAtten
import org.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeCancel;
import org.l2jmobius.gameserver.network.clientpackets.attributechange.RequestChangeAttributeItem;
import org.l2jmobius.gameserver.network.clientpackets.attributechange.SendChangeAttributeTargetItem;
import org.l2jmobius.gameserver.network.clientpackets.autopeel.ExRequestItemAutoPeel;
import org.l2jmobius.gameserver.network.clientpackets.autopeel.ExRequestReadyItemAutoPeel;
import org.l2jmobius.gameserver.network.clientpackets.autopeel.ExRequestStopItemAutoPeel;
import org.l2jmobius.gameserver.network.clientpackets.autoplay.ExAutoPlaySetting;
import org.l2jmobius.gameserver.network.clientpackets.autoplay.ExRequestActivateAutoShortcut;
import org.l2jmobius.gameserver.network.clientpackets.blessing.RequestBlessOptionCancel;
@ -799,9 +802,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_WORLD_EXCHANGE_BUY_ITEM(0x23F, ExWorldExchangeBuyItem::new, ConnectionState.IN_GAME),
EX_WORLD_EXCHANGE_SETTLE_LIST(0x240, ExWorldExchangeSettleList::new, ConnectionState.IN_GAME),
EX_WORLD_EXCHANGE_SETTLE_RECV_RESULT(0x241, ExWorldExchangeSettleRecvResult::new, ConnectionState.IN_GAME),
EX_READY_ITEM_AUTO_PEEL(0x242, null, ConnectionState.IN_GAME),
EX_REQUEST_ITEM_AUTO_PEEL(0x243, null, ConnectionState.IN_GAME),
EX_STOP_ITEM_AUTO_PEEL(0x244, null, ConnectionState.IN_GAME),
EX_READY_ITEM_AUTO_PEEL(0x242, ExRequestReadyItemAutoPeel::new, ConnectionState.IN_GAME),
EX_REQUEST_ITEM_AUTO_PEEL(0x243, ExRequestItemAutoPeel::new, ConnectionState.IN_GAME),
EX_STOP_ITEM_AUTO_PEEL(0x244, ExRequestStopItemAutoPeel::new, ConnectionState.IN_GAME),
EX_VARIATION_OPEN_UI(0x245, ExVariationOpenUi::new, ConnectionState.IN_GAME),
EX_VARIATION_CLOSE_UI(0x246, ExVariationCloseUi::new, ConnectionState.IN_GAME),
EX_APPLY_VARIATION_OPTION(0x247, ExApplyVariationOption::new, ConnectionState.IN_GAME),

View File

@ -37,6 +37,7 @@ import org.l2jmobius.gameserver.instancemanager.FortSiegeManager;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.effects.EffectType;
import org.l2jmobius.gameserver.model.events.EventDispatcher;
import org.l2jmobius.gameserver.model.events.EventType;
@ -312,6 +313,11 @@ public class UseItem implements IClientIncomingPacket
else
{
final EtcItem etcItem = item.getEtcItem();
if ((etcItem != null) && (etcItem.getExtractableItems() != null) && (player.hasRequest(AutoPeelRequest.class)))
{
return;
}
final IItemHandler handler = ItemHandler.getInstance().getHandler(etcItem);
if (handler == null)
{

View File

@ -0,0 +1,97 @@
/*
* 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.autopeel;
import java.util.Collections;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.handler.ItemHandler;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.item.EtcItem;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExResultItemAutoPeel;
/**
* @author Mobius
*/
public class ExRequestItemAutoPeel implements IClientIncomingPacket
{
private int _itemObjectId;
private long _totalPeelCount;
private long _remainingPeelCount;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_itemObjectId = packet.readD();
_totalPeelCount = packet.readQ();
_remainingPeelCount = packet.readQ();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
AutoPeelRequest request = player.getRequest(AutoPeelRequest.class);
if (request == null)
{
final Item item = player.getInventory().getItemByObjectId(_itemObjectId);
if ((item == null) || !item.isEtcItem() || (item.getEtcItem().getExtractableItems() == null) || item.getEtcItem().getExtractableItems().isEmpty())
{
return;
}
request = new AutoPeelRequest(player, item);
player.addRequest(request);
}
else if (request.isProcessing())
{
return;
}
request.setProcessing(true);
final Item item = request.getItem();
if ((item.getObjectId() != _itemObjectId) || (item.getOwnerId() != player.getObjectId()))
{
player.removeRequest(request.getClass());
return;
}
request.setTotalPeelCount(_totalPeelCount);
request.setRemainingPeelCount(_remainingPeelCount);
final EtcItem etcItem = (EtcItem) item.getTemplate();
if ((etcItem.getExtractableItems() != null) && !etcItem.getExtractableItems().isEmpty())
{
final IItemHandler handler = ItemHandler.getInstance().getHandler(item.getEtcItem());
if ((handler != null) && !handler.useItem(player, item, false))
{
request.setProcessing(false);
player.sendPacket(new ExResultItemAutoPeel(false, _totalPeelCount, _remainingPeelCount, Collections.emptyList()));
}
}
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.autopeel;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExReadyItemAutoPeel;
/**
* @author Mobius
*/
public class ExRequestReadyItemAutoPeel implements IClientIncomingPacket
{
private int _itemObjectId;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_itemObjectId = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item item = player.getInventory().getItemByObjectId(_itemObjectId);
if ((item == null) || !item.isEtcItem() || (item.getEtcItem().getExtractableItems() == null) || item.getEtcItem().getExtractableItems().isEmpty())
{
player.sendPacket(new ExReadyItemAutoPeel(false, _itemObjectId));
return;
}
player.addRequest(new AutoPeelRequest(player, item));
player.sendPacket(new ExReadyItemAutoPeel(true, _itemObjectId));
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.autopeel;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExReadyItemAutoPeel;
import org.l2jmobius.gameserver.network.serverpackets.autopeel.ExStopItemAutoPeel;
/**
* @author Mobius
*/
public class ExRequestStopItemAutoPeel implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
packet.readC();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
player.removeRequest(AutoPeelRequest.class);
player.sendPacket(new ExStopItemAutoPeel(true));
player.sendPacket(new ExReadyItemAutoPeel(false, 0));
}
}

View File

@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.clientpackets.collection;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.request.AutoPeelRequest;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.collection.ExCollectionOpenUI;
@ -43,6 +44,11 @@ public class RequestExCollectionOpenUI implements IClientIncomingPacket
return;
}
if (player.hasRequest(AutoPeelRequest.class))
{
return;
}
player.setTarget(null);
player.sendPacket(new ExCollectionOpenUI());
}

View File

@ -0,0 +1,45 @@
/*
* 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.autopeel;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExReadyItemAutoPeel implements IClientOutgoingPacket
{
private final boolean _result;
private final int _itemObjectId;
public ExReadyItemAutoPeel(boolean result, int itemObjectId)
{
_result = result;
_itemObjectId = itemObjectId;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_READY_ITEM_AUTO_PEEL.writeId(packet);
packet.writeC(_result ? 1 : 0);
packet.writeD(_itemObjectId);
return true;
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.autopeel;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExResultItemAutoPeel implements IClientOutgoingPacket
{
private final boolean _result;
private final long _totalPeelCount;
private final long _remainingPeelCount;
private final Collection<ItemHolder> _itemList;
public ExResultItemAutoPeel(boolean result, long totalPeelCount, long remainingPeelCount, Collection<ItemHolder> itemList)
{
_result = result;
_totalPeelCount = totalPeelCount;
_remainingPeelCount = remainingPeelCount;
_itemList = itemList;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_RESULT_ITEM_AUTO_PEEL.writeId(packet);
packet.writeC(_result ? 1 : 0);
packet.writeQ(_totalPeelCount);
packet.writeQ(_remainingPeelCount);
packet.writeD(_itemList.size());
for (ItemHolder holder : _itemList)
{
packet.writeD(holder.getId());
packet.writeQ(holder.getCount());
packet.writeD(0); // TODO: Announce level.
}
return true;
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.autopeel;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExStopItemAutoPeel implements IClientOutgoingPacket
{
private final boolean _result;
public ExStopItemAutoPeel(boolean result)
{
_result = result;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_RESULT_ITEM_AUTO_PEEL.writeId(packet);
packet.writeC(_result ? 1 : 0);
return true;
}
}

View File

@ -145,6 +145,7 @@ Battle Chronicle: https://eu.4game.com/patchnotes/lineage2essence/353/
Vanguard: https://eu.4game.com/patchnotes/lineage2essence/387/
-Vanguard creation support
-New enchant system
-Chest and box auto-use
Customs:
-Newbie Helper NPC location info