Fixed merchant tax problems.

This commit is contained in:
MobiusDev 2017-08-19 14:07:40 +00:00
parent 921e27c486
commit 0c183135c2
21 changed files with 135 additions and 141 deletions

View File

@ -15,27 +15,27 @@ SiegeHourList = 16,20
# Taxes for castles # Taxes for castles
# Buy tax in percent when is castle owned by npc's. # Buy tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
BuyTaxForNeutralSide = 15 BuyTaxForNeutralSide = 15
# Buy tax in percent when is castle owned by player's and castle is on light side. # Buy tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
BuyTaxForLightSide = 0 BuyTaxForLightSide = 0
# Buy tax in percent when is castle owned by player's and castle is on dark side. # Buy tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
BuyTaxForDarkSide = 30 BuyTaxForDarkSide = 30
# Sell tax in percent when is castle owned by npc's. # Sell tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
SellTaxForNeutralSide = 15 SellTaxForNeutralSide = 15
# Sell tax in percent when is castle owned by player's and castle is on light side. # Sell tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
SellTaxForLightSide = 0 SellTaxForLightSide = 0
# Sell tax in percent when is castle owned by player's and castle is on dark side. # Sell tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
SellTaxForDarkSide = 30 SellTaxForDarkSide = 30
# Teleport Function price # Teleport Function price

View File

@ -100,11 +100,6 @@ public class L2MerchantInstance extends L2NpcInstance
return getCastle() != null; return getCastle() != null;
} }
public double getCastleTaxRate()
{
return hasCastle() ? getCastle().getTaxRate() : 0.0;
}
public int getTotalTax(TaxType taxType) public int getTotalTax(TaxType taxType)
{ {
return hasCastle() ? getCastle().getTaxPercent(taxType) : 0; return hasCastle() ? getCastle().getTaxPercent(taxType) : 0;

View File

@ -25,8 +25,8 @@ import java.util.List;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -102,7 +102,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld())) if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld()))
@ -110,11 +110,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
double castleTaxRate = 0;
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
@ -128,6 +126,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
double castleTaxRate = 0;
if (merchant != null) if (merchant != null)
{ {
if (!buyList.isNpcAllowed(merchant.getId())) if (!buyList.isNpcAllowed(merchant.getId()))
@ -135,8 +134,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
castleTaxRate = merchant.getTotalTaxRate(TaxType.BUY);
castleTaxRate = ((L2MerchantInstance) merchant).getCastleTaxRate();
} }
long subTotal = 0; long subTotal = 0;
@ -146,8 +144,6 @@ public final class RequestBuyItem implements IClientIncomingPacket
long weight = 0; long weight = 0;
for (ItemHolder i : _items) for (ItemHolder i : _items)
{ {
long price = -1;
final Product product = buyList.getProductByItemId(i.getId()); final Product product = buyList.getProductByItemId(i.getId());
if (product == null) if (product == null)
{ {
@ -162,7 +158,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
price = product.getPrice(); long price = product.getPrice();
if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026)) if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026))
{ {
price *= Config.RATE_SIEGE_GUARDS_PRICE; price *= Config.RATE_SIEGE_GUARDS_PRICE;
@ -259,9 +255,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate)); merchant.getCastle().addToTreasury((long) (subTotal * castleTaxRate));
} }
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));

View File

@ -21,8 +21,8 @@ import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -92,7 +92,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -100,7 +100,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
@ -164,7 +164,12 @@ public final class RequestRefundItem implements IClientIncomingPacket
final long count = item.getCount(); final long count = item.getCount();
weight += count * template.getWeight(); weight += count * template.getWeight();
adena += (count * template.getReferencePrice()) / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
adena += price * count;
if (!template.isStackable()) if (!template.isStackable())
{ {
slots += count; slots += count;
@ -208,6 +213,6 @@ public final class RequestRefundItem implements IClientIncomingPacket
// Update current load status on player // Update current load status on player
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -27,7 +27,6 @@ import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType; import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -105,7 +104,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -115,7 +114,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
if (target instanceof L2MerchantInstance) if (target instanceof L2MerchantInstance)
{ {
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
else else
{ {
@ -153,7 +152,11 @@ public final class RequestSellItem implements IClientIncomingPacket
continue; continue;
} }
final long price = item.getReferencePrice() / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
totalPrice += price * i.getCount(); totalPrice += price * i.getCount();
if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA)) if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA))
{ {
@ -171,19 +174,18 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
} }
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
final L2MerchantInstance npc = ((L2MerchantInstance) merchant); final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
final long taxCollection = (long) (totalPrice * (1.0 - npc.getTotalTaxRate(TaxType.SELL))); merchant.getCastle().addToTreasury(taxCollection);
npc.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection; totalPrice -= taxCollection;
} }
player.addAdena("Sell", totalPrice, merchant, false);
// Update current load as well // Update current load as well
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -79,7 +79,7 @@ public class ExBuySellList extends AbstractItemPacket
{ {
writeItem(packet, item); writeItem(packet, item);
packet.writeD(i++); packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount()); packet.writeQ((long) ((item.getItem().getReferencePrice() / 2) * _taxRate));
} }
} }
else else

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.network.OutgoingPackets;
public class SellList implements IClientOutgoingPacket public class SellList implements IClientOutgoingPacket
{ {
private final L2PcInstance _activeChar; private final L2PcInstance _activeChar;
private final L2MerchantInstance _lease; private final L2MerchantInstance _merchant;
private final long _money; private final long _money;
private final List<L2ItemInstance> _sellList; private final List<L2ItemInstance> _sellList;
@ -44,10 +44,10 @@ public class SellList implements IClientOutgoingPacket
public SellList(L2PcInstance player, L2MerchantInstance lease) public SellList(L2PcInstance player, L2MerchantInstance lease)
{ {
_activeChar = player; _activeChar = player;
_lease = lease; _merchant = lease;
_money = _activeChar.getAdena(); _money = _activeChar.getAdena();
if (_lease == null) if (_merchant == null)
{ {
_sellList = new LinkedList<>(); _sellList = new LinkedList<>();
final L2Summon pet = _activeChar.getPet(); final L2Summon pet = _activeChar.getPet();
@ -71,15 +71,15 @@ public class SellList implements IClientOutgoingPacket
OutgoingPackets.SELL_LIST.writeId(packet); OutgoingPackets.SELL_LIST.writeId(packet);
packet.writeQ(_money); packet.writeQ(_money);
packet.writeD(_lease == null ? 0x00 : 1000000 + _lease.getTemplate().getId()); packet.writeD(_merchant == null ? 0x00 : 1000000 + _merchant.getTemplate().getId());
packet.writeH(_sellList.size()); packet.writeH(_sellList.size());
for (L2ItemInstance item : _sellList) for (L2ItemInstance item : _sellList)
{ {
int price = item.getItem().getReferencePrice() / 2; int price = item.getItem().getReferencePrice() / 2;
if (_lease != null) if (_merchant != null)
{ {
price -= (price * _lease.getTotalTaxRate(TaxType.SELL)); price -= (price * _merchant.getTotalTaxRate(TaxType.SELL));
} }
packet.writeH(item.getItem().getType1()); packet.writeH(item.getItem().getType1());
@ -92,7 +92,7 @@ public class SellList implements IClientOutgoingPacket
packet.writeH(item.getEnchantLevel()); packet.writeH(item.getEnchantLevel());
packet.writeH(0x00); // TODO: Verify me packet.writeH(0x00); // TODO: Verify me
packet.writeH(item.getCustomType2()); packet.writeH(item.getCustomType2());
packet.writeQ(item.getItem().getReferencePrice() / 2); packet.writeQ(price);
// T1 // T1
packet.writeH(item.getAttackAttributeType().getClientId()); packet.writeH(item.getAttackAttributeType().getClientId());
packet.writeH(item.getAttackAttributePower()); packet.writeH(item.getAttackAttributePower());

View File

@ -15,27 +15,27 @@ SiegeHourList = 16,20
# Taxes for castles # Taxes for castles
# Buy tax in percent when is castle owned by npc's. # Buy tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
BuyTaxForNeutralSide = 15 BuyTaxForNeutralSide = 15
# Buy tax in percent when is castle owned by player's and castle is on light side. # Buy tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
BuyTaxForLightSide = 0 BuyTaxForLightSide = 0
# Buy tax in percent when is castle owned by player's and castle is on dark side. # Buy tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
BuyTaxForDarkSide = 30 BuyTaxForDarkSide = 30
# Sell tax in percent when is castle owned by npc's. # Sell tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
SellTaxForNeutralSide = 15 SellTaxForNeutralSide = 15
# Sell tax in percent when is castle owned by player's and castle is on light side. # Sell tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
SellTaxForLightSide = 0 SellTaxForLightSide = 0
# Sell tax in percent when is castle owned by player's and castle is on dark side. # Sell tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
SellTaxForDarkSide = 30 SellTaxForDarkSide = 30
# Teleport Function price # Teleport Function price

View File

@ -100,11 +100,6 @@ public class L2MerchantInstance extends L2NpcInstance
return getCastle() != null; return getCastle() != null;
} }
public double getCastleTaxRate()
{
return hasCastle() ? getCastle().getTaxRate() : 0.0;
}
public int getTotalTax(TaxType taxType) public int getTotalTax(TaxType taxType)
{ {
return hasCastle() ? getCastle().getTaxPercent(taxType) : 0; return hasCastle() ? getCastle().getTaxPercent(taxType) : 0;

View File

@ -25,8 +25,8 @@ import java.util.List;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -102,7 +102,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld())) if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld()))
@ -110,11 +110,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
double castleTaxRate = 0;
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
@ -128,6 +126,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
double castleTaxRate = 0;
if (merchant != null) if (merchant != null)
{ {
if (!buyList.isNpcAllowed(merchant.getId())) if (!buyList.isNpcAllowed(merchant.getId()))
@ -135,8 +134,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
castleTaxRate = merchant.getTotalTaxRate(TaxType.BUY);
castleTaxRate = ((L2MerchantInstance) merchant).getCastleTaxRate();
} }
long subTotal = 0; long subTotal = 0;
@ -146,8 +144,6 @@ public final class RequestBuyItem implements IClientIncomingPacket
long weight = 0; long weight = 0;
for (ItemHolder i : _items) for (ItemHolder i : _items)
{ {
long price = -1;
final Product product = buyList.getProductByItemId(i.getId()); final Product product = buyList.getProductByItemId(i.getId());
if (product == null) if (product == null)
{ {
@ -162,7 +158,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
price = product.getPrice(); long price = product.getPrice();
if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026)) if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026))
{ {
price *= Config.RATE_SIEGE_GUARDS_PRICE; price *= Config.RATE_SIEGE_GUARDS_PRICE;
@ -259,9 +255,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate)); merchant.getCastle().addToTreasury((long) (subTotal * castleTaxRate));
} }
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));

View File

@ -21,8 +21,8 @@ import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -92,7 +92,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -100,7 +100,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
@ -164,7 +164,12 @@ public final class RequestRefundItem implements IClientIncomingPacket
final long count = item.getCount(); final long count = item.getCount();
weight += count * template.getWeight(); weight += count * template.getWeight();
adena += (count * template.getReferencePrice()) / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
adena += price * count;
if (!template.isStackable()) if (!template.isStackable())
{ {
slots += count; slots += count;
@ -208,6 +213,6 @@ public final class RequestRefundItem implements IClientIncomingPacket
// Update current load status on player // Update current load status on player
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -27,7 +27,6 @@ import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType; import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -105,7 +104,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -115,7 +114,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
if (target instanceof L2MerchantInstance) if (target instanceof L2MerchantInstance)
{ {
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
else else
{ {
@ -153,7 +152,11 @@ public final class RequestSellItem implements IClientIncomingPacket
continue; continue;
} }
final long price = item.getReferencePrice() / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
totalPrice += price * i.getCount(); totalPrice += price * i.getCount();
if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA)) if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA))
{ {
@ -171,19 +174,18 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
} }
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
final L2MerchantInstance npc = ((L2MerchantInstance) merchant); final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
final long taxCollection = (long) (totalPrice * (1.0 - npc.getTotalTaxRate(TaxType.SELL))); merchant.getCastle().addToTreasury(taxCollection);
npc.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection; totalPrice -= taxCollection;
} }
player.addAdena("Sell", totalPrice, merchant, false);
// Update current load as well // Update current load as well
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -79,7 +79,7 @@ public class ExBuySellList extends AbstractItemPacket
{ {
writeItem(packet, item); writeItem(packet, item);
packet.writeD(i++); packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount()); packet.writeQ((long) ((item.getItem().getReferencePrice() / 2) * _taxRate));
} }
} }
else else

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.network.OutgoingPackets;
public class SellList implements IClientOutgoingPacket public class SellList implements IClientOutgoingPacket
{ {
private final L2PcInstance _activeChar; private final L2PcInstance _activeChar;
private final L2MerchantInstance _lease; private final L2MerchantInstance _merchant;
private final long _money; private final long _money;
private final List<L2ItemInstance> _sellList; private final List<L2ItemInstance> _sellList;
@ -44,10 +44,10 @@ public class SellList implements IClientOutgoingPacket
public SellList(L2PcInstance player, L2MerchantInstance lease) public SellList(L2PcInstance player, L2MerchantInstance lease)
{ {
_activeChar = player; _activeChar = player;
_lease = lease; _merchant = lease;
_money = _activeChar.getAdena(); _money = _activeChar.getAdena();
if (_lease == null) if (_merchant == null)
{ {
_sellList = new LinkedList<>(); _sellList = new LinkedList<>();
final L2Summon pet = _activeChar.getPet(); final L2Summon pet = _activeChar.getPet();
@ -71,15 +71,15 @@ public class SellList implements IClientOutgoingPacket
OutgoingPackets.SELL_LIST.writeId(packet); OutgoingPackets.SELL_LIST.writeId(packet);
packet.writeQ(_money); packet.writeQ(_money);
packet.writeD(_lease == null ? 0x00 : 1000000 + _lease.getTemplate().getId()); packet.writeD(_merchant == null ? 0x00 : 1000000 + _merchant.getTemplate().getId());
packet.writeH(_sellList.size()); packet.writeH(_sellList.size());
for (L2ItemInstance item : _sellList) for (L2ItemInstance item : _sellList)
{ {
int price = item.getItem().getReferencePrice() / 2; int price = item.getItem().getReferencePrice() / 2;
if (_lease != null) if (_merchant != null)
{ {
price -= (price * _lease.getTotalTaxRate(TaxType.SELL)); price -= (price * _merchant.getTotalTaxRate(TaxType.SELL));
} }
packet.writeH(item.getItem().getType1()); packet.writeH(item.getItem().getType1());
@ -92,7 +92,7 @@ public class SellList implements IClientOutgoingPacket
packet.writeH(item.getEnchantLevel()); packet.writeH(item.getEnchantLevel());
packet.writeH(0x00); // TODO: Verify me packet.writeH(0x00); // TODO: Verify me
packet.writeH(item.getCustomType2()); packet.writeH(item.getCustomType2());
packet.writeQ(item.getItem().getReferencePrice() / 2); packet.writeQ(price);
// T1 // T1
packet.writeH(item.getAttackAttributeType().getClientId()); packet.writeH(item.getAttackAttributeType().getClientId());
packet.writeH(item.getAttackAttributePower()); packet.writeH(item.getAttackAttributePower());

View File

@ -15,27 +15,27 @@ SiegeHourList = 16,20
# Taxes for castles # Taxes for castles
# Buy tax in percent when is castle owned by npc's. # Buy tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
BuyTaxForNeutralSide = 15 BuyTaxForNeutralSide = 15
# Buy tax in percent when is castle owned by player's and castle is on light side. # Buy tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
BuyTaxForLightSide = 0 BuyTaxForLightSide = 0
# Buy tax in percent when is castle owned by player's and castle is on dark side. # Buy tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
BuyTaxForDarkSide = 30 BuyTaxForDarkSide = 30
# Sell tax in percent when is castle owned by npc's. # Sell tax in percent when is castle owned by npc's.
# Defualt: 15 # Default: 15
SellTaxForNeutralSide = 15 SellTaxForNeutralSide = 15
# Sell tax in percent when is castle owned by player's and castle is on light side. # Sell tax in percent when is castle owned by player's and castle is on light side.
# Defualt: 0 # Default: 0
SellTaxForLightSide = 0 SellTaxForLightSide = 0
# Sell tax in percent when is castle owned by player's and castle is on dark side. # Sell tax in percent when is castle owned by player's and castle is on dark side.
# Defualt: 30 # Default: 30
SellTaxForDarkSide = 30 SellTaxForDarkSide = 30
# Teleport Function price # Teleport Function price

View File

@ -100,11 +100,6 @@ public class L2MerchantInstance extends L2NpcInstance
return getCastle() != null; return getCastle() != null;
} }
public double getCastleTaxRate()
{
return hasCastle() ? getCastle().getTaxRate() : 0.0;
}
public int getTotalTax(TaxType taxType) public int getTotalTax(TaxType taxType)
{ {
return hasCastle() ? getCastle().getTaxPercent(taxType) : 0; return hasCastle() ? getCastle().getTaxPercent(taxType) : 0;

View File

@ -25,8 +25,8 @@ import java.util.List;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -102,7 +102,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld())) if (!(target instanceof L2MerchantInstance) || (!player.isInsideRadius(target, INTERACTION_DISTANCE, true, false)) || (player.getInstanceWorld() != target.getInstanceWorld()))
@ -110,11 +110,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
double castleTaxRate = 0;
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
@ -128,6 +126,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
double castleTaxRate = 0;
if (merchant != null) if (merchant != null)
{ {
if (!buyList.isNpcAllowed(merchant.getId())) if (!buyList.isNpcAllowed(merchant.getId()))
@ -135,8 +134,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
castleTaxRate = merchant.getTotalTaxRate(TaxType.BUY);
castleTaxRate = ((L2MerchantInstance) merchant).getCastleTaxRate();
} }
long subTotal = 0; long subTotal = 0;
@ -146,8 +144,6 @@ public final class RequestBuyItem implements IClientIncomingPacket
long weight = 0; long weight = 0;
for (ItemHolder i : _items) for (ItemHolder i : _items)
{ {
long price = -1;
final Product product = buyList.getProductByItemId(i.getId()); final Product product = buyList.getProductByItemId(i.getId());
if (product == null) if (product == null)
{ {
@ -162,7 +158,7 @@ public final class RequestBuyItem implements IClientIncomingPacket
return; return;
} }
price = product.getPrice(); long price = product.getPrice();
if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026)) if ((product.getItemId() >= 3960) && (product.getItemId() <= 4026))
{ {
price *= Config.RATE_SIEGE_GUARDS_PRICE; price *= Config.RATE_SIEGE_GUARDS_PRICE;
@ -259,9 +255,9 @@ public final class RequestBuyItem implements IClientIncomingPacket
} }
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
((L2MerchantInstance) merchant).getCastle().addToTreasury((long) (subTotal * castleTaxRate)); merchant.getCastle().addToTreasury((long) (subTotal * castleTaxRate));
} }
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));

View File

@ -21,8 +21,8 @@ import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader; import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -92,7 +92,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if (!(target instanceof L2MerchantInstance) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -100,7 +100,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
client.sendPacket(ActionFailed.STATIC_PACKET); client.sendPacket(ActionFailed.STATIC_PACKET);
return; return;
} }
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if ((merchant == null) && !player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
@ -164,7 +164,12 @@ public final class RequestRefundItem implements IClientIncomingPacket
final long count = item.getCount(); final long count = item.getCount();
weight += count * template.getWeight(); weight += count * template.getWeight();
adena += (count * template.getReferencePrice()) / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
adena += price * count;
if (!template.isStackable()) if (!template.isStackable())
{ {
slots += count; slots += count;
@ -208,6 +213,6 @@ public final class RequestRefundItem implements IClientIncomingPacket
// Update current load status on player // Update current load status on player
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -27,7 +27,6 @@ import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData; import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.enums.TaxType; import com.l2jmobius.gameserver.enums.TaxType;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance; import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList; import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -105,7 +104,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
final L2Object target = player.getTarget(); final L2Object target = player.getTarget();
L2Character merchant = null; L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST)) if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{ {
if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId())) if ((target == null) || !player.isInsideRadius(target, INTERACTION_DISTANCE, true, false) || (player.getInstanceId() != target.getInstanceId()))
@ -115,7 +114,7 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
if (target instanceof L2MerchantInstance) if (target instanceof L2MerchantInstance)
{ {
merchant = (L2Character) target; merchant = (L2MerchantInstance) target;
} }
else else
{ {
@ -153,7 +152,11 @@ public final class RequestSellItem implements IClientIncomingPacket
continue; continue;
} }
final long price = item.getReferencePrice() / 2; long price = item.getReferencePrice() / 2;
if (merchant != null)
{
price -= (price * merchant.getTotalTaxRate(TaxType.SELL));
}
totalPrice += price * i.getCount(); totalPrice += price * i.getCount();
if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA)) if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA))
{ {
@ -171,19 +174,18 @@ public final class RequestSellItem implements IClientIncomingPacket
} }
} }
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury // add to castle treasury
if (merchant instanceof L2MerchantInstance) if (merchant != null)
{ {
final L2MerchantInstance npc = ((L2MerchantInstance) merchant); final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
final long taxCollection = (long) (totalPrice * (1.0 - npc.getTotalTaxRate(TaxType.SELL))); merchant.getCastle().addToTreasury(taxCollection);
npc.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection; totalPrice -= taxCollection;
} }
player.addAdena("Sell", totalPrice, merchant, false);
// Update current load as well // Update current load as well
client.sendPacket(new ExUserInfoInvenWeight(player)); client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true)); client.sendPacket(new ExBuySellList(player, true, merchant != null ? merchant.getTotalTaxRate(TaxType.SELL) : 0));
} }
} }

View File

@ -79,7 +79,7 @@ public class ExBuySellList extends AbstractItemPacket
{ {
writeItem(packet, item); writeItem(packet, item);
packet.writeD(i++); packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount()); packet.writeQ((long) ((item.getItem().getReferencePrice() / 2) * _taxRate));
} }
} }
else else

View File

@ -32,7 +32,7 @@ import com.l2jmobius.gameserver.network.OutgoingPackets;
public class SellList implements IClientOutgoingPacket public class SellList implements IClientOutgoingPacket
{ {
private final L2PcInstance _activeChar; private final L2PcInstance _activeChar;
private final L2MerchantInstance _lease; private final L2MerchantInstance _merchant;
private final long _money; private final long _money;
private final List<L2ItemInstance> _sellList; private final List<L2ItemInstance> _sellList;
@ -44,10 +44,10 @@ public class SellList implements IClientOutgoingPacket
public SellList(L2PcInstance player, L2MerchantInstance lease) public SellList(L2PcInstance player, L2MerchantInstance lease)
{ {
_activeChar = player; _activeChar = player;
_lease = lease; _merchant = lease;
_money = _activeChar.getAdena(); _money = _activeChar.getAdena();
if (_lease == null) if (_merchant == null)
{ {
_sellList = new LinkedList<>(); _sellList = new LinkedList<>();
final L2Summon pet = _activeChar.getPet(); final L2Summon pet = _activeChar.getPet();
@ -71,15 +71,15 @@ public class SellList implements IClientOutgoingPacket
OutgoingPackets.SELL_LIST.writeId(packet); OutgoingPackets.SELL_LIST.writeId(packet);
packet.writeQ(_money); packet.writeQ(_money);
packet.writeD(_lease == null ? 0x00 : 1000000 + _lease.getTemplate().getId()); packet.writeD(_merchant == null ? 0x00 : 1000000 + _merchant.getTemplate().getId());
packet.writeH(_sellList.size()); packet.writeH(_sellList.size());
for (L2ItemInstance item : _sellList) for (L2ItemInstance item : _sellList)
{ {
int price = item.getItem().getReferencePrice() / 2; int price = item.getItem().getReferencePrice() / 2;
if (_lease != null) if (_merchant != null)
{ {
price -= (price * _lease.getTotalTaxRate(TaxType.SELL)); price -= (price * _merchant.getTotalTaxRate(TaxType.SELL));
} }
packet.writeH(item.getItem().getType1()); packet.writeH(item.getItem().getType1());
@ -92,7 +92,7 @@ public class SellList implements IClientOutgoingPacket
packet.writeH(item.getEnchantLevel()); packet.writeH(item.getEnchantLevel());
packet.writeH(0x00); // TODO: Verify me packet.writeH(0x00); // TODO: Verify me
packet.writeH(item.getCustomType2()); packet.writeH(item.getCustomType2());
packet.writeQ(item.getItem().getReferencePrice() / 2); packet.writeQ(price);
// T1 // T1
packet.writeH(item.getAttackAttributeType().getClientId()); packet.writeH(item.getAttackAttributeType().getClientId());
packet.writeH(item.getAttackAttributePower()); packet.writeH(item.getAttackAttributePower());