Augmentation system additions.
Contributed by Index.
This commit is contained in:
		@@ -21,8 +21,8 @@ import java.util.logging.Level;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.IBypassHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Creature;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationCancelWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationMakeWindow;
 | 
			
		||||
 | 
			
		||||
public class Augment implements IBypassHandler
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,72 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class VariationRequest extends AbstractRequest
 | 
			
		||||
{
 | 
			
		||||
	private Item _augmented;
 | 
			
		||||
	private Item _mineral;
 | 
			
		||||
	private VariationInstance _augmentation;
 | 
			
		||||
	
 | 
			
		||||
	public VariationRequest(Player player)
 | 
			
		||||
	{
 | 
			
		||||
		super(player);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setAugmentedItem(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		_augmented = getActiveChar().getInventory().getItemByObjectId(objectId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized Item getAugmentedItem()
 | 
			
		||||
	{
 | 
			
		||||
		return _augmented;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setMineralItem(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		_mineral = getActiveChar().getInventory().getItemByObjectId(objectId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized Item getMineralItem()
 | 
			
		||||
	{
 | 
			
		||||
		return _mineral;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setAugment(VariationInstance augment)
 | 
			
		||||
	{
 | 
			
		||||
		_augmentation = augment;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized VariationInstance getAugment()
 | 
			
		||||
	{
 | 
			
		||||
		return _augmentation;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isUsing(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -162,7 +162,12 @@ import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTelepor
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleportFavoritesAddDel;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTeleportFavoritesUIToggle;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExApplyVariationOption;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExVariationCloseUi;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExVariationOpenUi;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.RequestRefine;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.RequestExRemoveEnchantSupportItem;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.RequestConfirmGemStone;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sdw
 | 
			
		||||
@@ -755,9 +760,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
 | 
			
		||||
	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_VARIATION_OPEN_UI(0x245, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_VARIATION_CLOSE_UI(0x246, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_APPLY_VARIATION_OPTION(0x247, null, 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),
 | 
			
		||||
	EX_BR_VERSION(0x248, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_MAX(0x249, null, ConnectionState.IN_GAME);
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -47,9 +47,9 @@ import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.PacketLogger;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExUseSharedGroupItem;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationMakeWindow;
 | 
			
		||||
 | 
			
		||||
public class UseItem implements IClientIncomingPacket
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,93 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.model.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
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.InventoryUpdate;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ApplyVariationOption;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExApplyVariationOption implements IClientIncomingPacket
 | 
			
		||||
{
 | 
			
		||||
	private int _enchantedObjectId;
 | 
			
		||||
	private int _option1;
 | 
			
		||||
	private int _option2;
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean read(GameClient client, PacketReader packet)
 | 
			
		||||
	{
 | 
			
		||||
		_enchantedObjectId = packet.readD();
 | 
			
		||||
		_option1 = packet.readD();
 | 
			
		||||
		_option2 = packet.readD();
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run(GameClient client)
 | 
			
		||||
	{
 | 
			
		||||
		final Player player = client.getPlayer();
 | 
			
		||||
		if (player == null)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final VariationRequest request = player.getRequest(VariationRequest.class);
 | 
			
		||||
		final Item targetItem = request.getAugmentedItem();
 | 
			
		||||
		final VariationInstance augment = request.getAugment();
 | 
			
		||||
		final int option1Id = augment.getOption1Id();
 | 
			
		||||
		final int option2Id = augment.getOption2Id();
 | 
			
		||||
		
 | 
			
		||||
		if ((targetItem.getObjectId() != _enchantedObjectId) || (_option1 != option1Id) || (_option2 != option2Id))
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(new ApplyVariationOption(0, 0, 0, 0));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Remove the augmentation if any (286).
 | 
			
		||||
		if (targetItem.isAugmented())
 | 
			
		||||
		{
 | 
			
		||||
			targetItem.removeAugmentation();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		targetItem.setAugmentation(augment, true);
 | 
			
		||||
		
 | 
			
		||||
		// Unequip item.
 | 
			
		||||
		final InventoryUpdate iu = new InventoryUpdate();
 | 
			
		||||
		if (targetItem.isEquipped())
 | 
			
		||||
		{
 | 
			
		||||
			for (Item itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
 | 
			
		||||
			{
 | 
			
		||||
				iu.addModifiedItem(itm);
 | 
			
		||||
			}
 | 
			
		||||
			player.broadcastUserInfo();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		iu.addModifiedItem(targetItem);
 | 
			
		||||
		player.sendInventoryUpdate(iu);
 | 
			
		||||
		
 | 
			
		||||
		player.removeRequest(VariationRequest.class);
 | 
			
		||||
		player.sendPacket(new ApplyVariationOption(1, _enchantedObjectId, _option1, _option2));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,53 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExVariationCloseUi 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.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
 | 
			
		||||
		
 | 
			
		||||
		if (player.getRequest(VariationRequest.class) != null)
 | 
			
		||||
		{
 | 
			
		||||
			player.removeRequest(VariationRequest.class);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExVariationOpenUi 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.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -14,19 +14,20 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.clientpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.VariationData;
 | 
			
		||||
import org.l2jmobius.gameserver.model.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.Variation;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.VariationFee;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.AbstractRefinePacket;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExVariationResult;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Format:(ch) dddd
 | 
			
		||||
@@ -88,8 +89,6 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// TODO: Update XMLs.
 | 
			
		||||
		// if (_feeCount != fee.getItemCount())
 | 
			
		||||
		if (_feeCount <= 0)
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(new ExVariationResult(0, 0, false));
 | 
			
		||||
@@ -138,17 +137,6 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Unequip item.
 | 
			
		||||
		final InventoryUpdate iu = new InventoryUpdate();
 | 
			
		||||
		if (targetItem.isEquipped())
 | 
			
		||||
		{
 | 
			
		||||
			for (Item itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
 | 
			
		||||
			{
 | 
			
		||||
				iu.addModifiedItem(itm);
 | 
			
		||||
			}
 | 
			
		||||
			player.broadcastUserInfo();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Consume the life stone.
 | 
			
		||||
		if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
 | 
			
		||||
		{
 | 
			
		||||
@@ -167,15 +155,17 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Remove the augmentation if any (286).
 | 
			
		||||
		if (targetItem.isAugmented())
 | 
			
		||||
		if (player.getRequest(VariationRequest.class) == null)
 | 
			
		||||
		{
 | 
			
		||||
			targetItem.removeAugmentation();
 | 
			
		||||
			player.addRequest(new VariationRequest(player));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		targetItem.setAugmentation(augment, true);
 | 
			
		||||
		VariationRequest request = player.getRequest(VariationRequest.class);
 | 
			
		||||
		request.setAugmentedItem(_targetItemObjId);
 | 
			
		||||
		request.setMineralItem(_mineralItemObjId);
 | 
			
		||||
		request.setAugment(augment);
 | 
			
		||||
		
 | 
			
		||||
		player.sendPacket(new ExVariationResult(augment.getOption1Id(), augment.getOption2Id(), true));
 | 
			
		||||
		iu.addModifiedItem(targetItem);
 | 
			
		||||
		player.sendInventoryUpdate(iu);
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ApplyVariationOption implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	private final int _result;
 | 
			
		||||
	private final int _enchantedObjectId;
 | 
			
		||||
	private final int _option1;
 | 
			
		||||
	private final int _option2;
 | 
			
		||||
	
 | 
			
		||||
	public ApplyVariationOption(int result, int enchantedObjectId, int option1, int option2)
 | 
			
		||||
	{
 | 
			
		||||
		_result = result;
 | 
			
		||||
		_enchantedObjectId = enchantedObjectId;
 | 
			
		||||
		_option1 = option1;
 | 
			
		||||
		_option2 = option2;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean write(PacketWriter packet)
 | 
			
		||||
	{
 | 
			
		||||
		OutgoingPackets.EX_APPLY_VARIATION_OPTION.writeId(packet);
 | 
			
		||||
		packet.writeC(_result);
 | 
			
		||||
		packet.writeD(_enchantedObjectId);
 | 
			
		||||
		packet.writeD(_option1);
 | 
			
		||||
		packet.writeD(_option2);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -14,11 +14,15 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExPutCommissionResultForVariationMake implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	private final int _gemstoneObjId;
 | 
			
		||||
@@ -14,10 +14,11 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author KenM
 | 
			
		||||
@@ -25,8 +26,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
public class ExShowVariationCancelWindow implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	public static final ExShowVariationCancelWindow STATIC_PACKET = new ExShowVariationCancelWindow();
 | 
			
		||||
	
 | 
			
		||||
	private ExShowVariationCancelWindow()
 | 
			
		||||
 | 
			
		||||
	public ExShowVariationCancelWindow()
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -14,10 +14,11 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Trigger packet
 | 
			
		||||
@@ -27,7 +28,7 @@ public class ExShowVariationMakeWindow implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	public static final ExShowVariationMakeWindow STATIC_PACKET = new ExShowVariationMakeWindow();
 | 
			
		||||
	
 | 
			
		||||
	private ExShowVariationMakeWindow()
 | 
			
		||||
	public ExShowVariationMakeWindow()
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -14,7 +14,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 org.l2jmobius.gameserver.network.clientpackets;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.VariationData;
 | 
			
		||||
@@ -23,7 +23,7 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.VariationFee;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.AbstractRefinePacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Format:(ch) dddd
 | 
			
		||||
@@ -80,7 +80,7 @@ public class RequestConfirmGemStone extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Check for fee count
 | 
			
		||||
		// Check for fee count.
 | 
			
		||||
		if (_feeCount != fee.getItemCount())
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
 | 
			
		||||
@@ -32,13 +32,13 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
import org.l2jmobius.gameserver.model.itemcontainer.PlayerFreight;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExPremiumManagerShowHtml;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,8 +21,8 @@ import java.util.logging.Level;
 | 
			
		||||
import org.l2jmobius.gameserver.handler.IBypassHandler;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Creature;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationCancelWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationMakeWindow;
 | 
			
		||||
 | 
			
		||||
public class Augment implements IBypassHandler
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,72 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class VariationRequest extends AbstractRequest
 | 
			
		||||
{
 | 
			
		||||
	private Item _augmented;
 | 
			
		||||
	private Item _mineral;
 | 
			
		||||
	private VariationInstance _augmentation;
 | 
			
		||||
	
 | 
			
		||||
	public VariationRequest(Player player)
 | 
			
		||||
	{
 | 
			
		||||
		super(player);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setAugmentedItem(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		_augmented = getActiveChar().getInventory().getItemByObjectId(objectId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized Item getAugmentedItem()
 | 
			
		||||
	{
 | 
			
		||||
		return _augmented;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setMineralItem(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		_mineral = getActiveChar().getInventory().getItemByObjectId(objectId);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized Item getMineralItem()
 | 
			
		||||
	{
 | 
			
		||||
		return _mineral;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized void setAugment(VariationInstance augment)
 | 
			
		||||
	{
 | 
			
		||||
		_augmentation = augment;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public synchronized VariationInstance getAugment()
 | 
			
		||||
	{
 | 
			
		||||
		return _augmentation;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isUsing(int objectId)
 | 
			
		||||
	{
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -176,9 +176,14 @@ import org.l2jmobius.gameserver.network.clientpackets.teleports.ExRequestTelepor
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.ExTeleportToRaidPosition;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.teleports.RequestRaidTeleportInfo;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.training.NotifyTrainingRoomEnd;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExApplyVariationOption;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExVariationCloseUi;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.ExVariationOpenUi;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.variation.RequestRefine;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.vip.ExRequestVipInfo;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.vip.RequestVipLuckGameInfo;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.enchant.RequestExRemoveEnchantSupportItem;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.RequestConfirmGemStone;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Sdw
 | 
			
		||||
@@ -771,9 +776,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
 | 
			
		||||
	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_VARIATION_OPEN_UI(0x245, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_VARIATION_CLOSE_UI(0x246, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_APPLY_VARIATION_OPTION(0x247, null, 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),
 | 
			
		||||
	EX_BR_VERSION(0x248, null, ConnectionState.IN_GAME),
 | 
			
		||||
	EX_MAX(0x249, null, ConnectionState.IN_GAME);
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -52,9 +52,9 @@ import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.PacketLogger;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExUseSharedGroupItem;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ExShowVariationMakeWindow;
 | 
			
		||||
 | 
			
		||||
public class UseItem implements IClientIncomingPacket
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,93 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.model.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
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.InventoryUpdate;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.variation.ApplyVariationOption;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExApplyVariationOption implements IClientIncomingPacket
 | 
			
		||||
{
 | 
			
		||||
	private int _enchantedObjectId;
 | 
			
		||||
	private int _option1;
 | 
			
		||||
	private int _option2;
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean read(GameClient client, PacketReader packet)
 | 
			
		||||
	{
 | 
			
		||||
		_enchantedObjectId = packet.readD();
 | 
			
		||||
		_option1 = packet.readD();
 | 
			
		||||
		_option2 = packet.readD();
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run(GameClient client)
 | 
			
		||||
	{
 | 
			
		||||
		final Player player = client.getPlayer();
 | 
			
		||||
		if (player == null)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		final VariationRequest request = player.getRequest(VariationRequest.class);
 | 
			
		||||
		final Item targetItem = request.getAugmentedItem();
 | 
			
		||||
		final VariationInstance augment = request.getAugment();
 | 
			
		||||
		final int option1Id = augment.getOption1Id();
 | 
			
		||||
		final int option2Id = augment.getOption2Id();
 | 
			
		||||
		
 | 
			
		||||
		if ((targetItem.getObjectId() != _enchantedObjectId) || (_option1 != option1Id) || (_option2 != option2Id))
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(new ApplyVariationOption(0, 0, 0, 0));
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Remove the augmentation if any (286).
 | 
			
		||||
		if (targetItem.isAugmented())
 | 
			
		||||
		{
 | 
			
		||||
			targetItem.removeAugmentation();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		targetItem.setAugmentation(augment, true);
 | 
			
		||||
		
 | 
			
		||||
		// Unequip item.
 | 
			
		||||
		final InventoryUpdate iu = new InventoryUpdate();
 | 
			
		||||
		if (targetItem.isEquipped())
 | 
			
		||||
		{
 | 
			
		||||
			for (Item itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
 | 
			
		||||
			{
 | 
			
		||||
				iu.addModifiedItem(itm);
 | 
			
		||||
			}
 | 
			
		||||
			player.broadcastUserInfo();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		iu.addModifiedItem(targetItem);
 | 
			
		||||
		player.sendInventoryUpdate(iu);
 | 
			
		||||
		
 | 
			
		||||
		player.removeRequest(VariationRequest.class);
 | 
			
		||||
		player.sendPacket(new ApplyVariationOption(1, _enchantedObjectId, _option1, _option2));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,53 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExVariationCloseUi 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.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
 | 
			
		||||
		
 | 
			
		||||
		if (player.getRequest(VariationRequest.class) != null)
 | 
			
		||||
		{
 | 
			
		||||
			player.removeRequest(VariationRequest.class);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,46 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExVariationOpenUi 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.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -14,19 +14,20 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.clientpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.VariationData;
 | 
			
		||||
import org.l2jmobius.gameserver.model.VariationInstance;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.request.VariationRequest;
 | 
			
		||||
import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.Variation;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.VariationFee;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.AbstractRefinePacket;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExVariationResult;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Format:(ch) dddd
 | 
			
		||||
@@ -88,8 +89,6 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// TODO: Update XMLs.
 | 
			
		||||
		// if (_feeCount != fee.getItemCount())
 | 
			
		||||
		if (_feeCount <= 0)
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(new ExVariationResult(0, 0, false));
 | 
			
		||||
@@ -138,17 +137,6 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Unequip item.
 | 
			
		||||
		final InventoryUpdate iu = new InventoryUpdate();
 | 
			
		||||
		if (targetItem.isEquipped())
 | 
			
		||||
		{
 | 
			
		||||
			for (Item itm : player.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot()))
 | 
			
		||||
			{
 | 
			
		||||
				iu.addModifiedItem(itm);
 | 
			
		||||
			}
 | 
			
		||||
			player.broadcastUserInfo();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Consume the life stone.
 | 
			
		||||
		if (!player.destroyItem("RequestRefine", mineralItem, 1, null, false))
 | 
			
		||||
		{
 | 
			
		||||
@@ -167,15 +155,17 @@ public class RequestRefine extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Remove the augmentation if any (286).
 | 
			
		||||
		if (targetItem.isAugmented())
 | 
			
		||||
		if (player.getRequest(VariationRequest.class) == null)
 | 
			
		||||
		{
 | 
			
		||||
			targetItem.removeAugmentation();
 | 
			
		||||
			player.addRequest(new VariationRequest(player));
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		targetItem.setAugmentation(augment, true);
 | 
			
		||||
		VariationRequest request = player.getRequest(VariationRequest.class);
 | 
			
		||||
		request.setAugmentedItem(_targetItemObjId);
 | 
			
		||||
		request.setMineralItem(_mineralItemObjId);
 | 
			
		||||
		request.setAugment(augment);
 | 
			
		||||
		
 | 
			
		||||
		player.sendPacket(new ExVariationResult(augment.getOption1Id(), augment.getOption2Id(), true));
 | 
			
		||||
		iu.addModifiedItem(targetItem);
 | 
			
		||||
		player.sendInventoryUpdate(iu);
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,51 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ApplyVariationOption implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	private final int _result;
 | 
			
		||||
	private final int _enchantedObjectId;
 | 
			
		||||
	private final int _option1;
 | 
			
		||||
	private final int _option2;
 | 
			
		||||
	
 | 
			
		||||
	public ApplyVariationOption(int result, int enchantedObjectId, int option1, int option2)
 | 
			
		||||
	{
 | 
			
		||||
		_result = result;
 | 
			
		||||
		_enchantedObjectId = enchantedObjectId;
 | 
			
		||||
		_option1 = option1;
 | 
			
		||||
		_option2 = option2;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean write(PacketWriter packet)
 | 
			
		||||
	{
 | 
			
		||||
		OutgoingPackets.EX_APPLY_VARIATION_OPTION.writeId(packet);
 | 
			
		||||
		packet.writeC(_result);
 | 
			
		||||
		packet.writeD(_enchantedObjectId);
 | 
			
		||||
		packet.writeD(_option1);
 | 
			
		||||
		packet.writeD(_option2);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -14,11 +14,15 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Index
 | 
			
		||||
 */
 | 
			
		||||
public class ExPutCommissionResultForVariationMake implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	private final int _gemstoneObjId;
 | 
			
		||||
@@ -14,10 +14,11 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author KenM
 | 
			
		||||
@@ -25,8 +26,8 @@ import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
public class ExShowVariationCancelWindow implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	public static final ExShowVariationCancelWindow STATIC_PACKET = new ExShowVariationCancelWindow();
 | 
			
		||||
	
 | 
			
		||||
	private ExShowVariationCancelWindow()
 | 
			
		||||
 | 
			
		||||
	public ExShowVariationCancelWindow()
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -14,10 +14,11 @@
 | 
			
		||||
 * 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;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketWriter;
 | 
			
		||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Trigger packet
 | 
			
		||||
@@ -27,7 +28,7 @@ public class ExShowVariationMakeWindow implements IClientOutgoingPacket
 | 
			
		||||
{
 | 
			
		||||
	public static final ExShowVariationMakeWindow STATIC_PACKET = new ExShowVariationMakeWindow();
 | 
			
		||||
	
 | 
			
		||||
	private ExShowVariationMakeWindow()
 | 
			
		||||
	public ExShowVariationMakeWindow()
 | 
			
		||||
	{
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -14,7 +14,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 org.l2jmobius.gameserver.network.clientpackets;
 | 
			
		||||
package org.l2jmobius.gameserver.network.serverpackets.variation;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.commons.network.PacketReader;
 | 
			
		||||
import org.l2jmobius.gameserver.data.xml.VariationData;
 | 
			
		||||
@@ -23,7 +23,7 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
 | 
			
		||||
import org.l2jmobius.gameserver.model.options.VariationFee;
 | 
			
		||||
import org.l2jmobius.gameserver.network.GameClient;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
 | 
			
		||||
import org.l2jmobius.gameserver.network.clientpackets.AbstractRefinePacket;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Format:(ch) dddd
 | 
			
		||||
@@ -80,7 +80,7 @@ public class RequestConfirmGemStone extends AbstractRefinePacket
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Check for fee count
 | 
			
		||||
		// Check for fee count.
 | 
			
		||||
		if (_feeCount != fee.getItemCount())
 | 
			
		||||
		{
 | 
			
		||||
			player.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
 | 
			
		||||
		Reference in New Issue
	
	Block a user