Continue with merchant tax changes.

This commit is contained in:
MobiusDev 2017-08-19 14:37:32 +00:00
parent 0c183135c2
commit eacee48ca7
10 changed files with 50 additions and 56 deletions

View File

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

View File

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

View File

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

View File

@ -21,8 +21,8 @@ import static com.l2jmobius.gameserver.model.actor.L2Npc.INTERACTION_DISTANCE;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
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.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -92,7 +92,7 @@ public final class RequestRefundItem implements IClientIncomingPacket
}
final L2Object target = player.getTarget();
L2Character merchant = null;
L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{
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);
return;
}
merchant = (L2Character) target;
merchant = (L2MerchantInstance) target;
}
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();
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())
{
slots += count;
@ -208,6 +213,6 @@ public final class RequestRefundItem implements IClientIncomingPacket
// Update current load status on 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.enums.TaxType;
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.L2PcInstance;
import com.l2jmobius.gameserver.model.buylist.L2BuyList;
@ -105,7 +104,7 @@ public final class RequestSellItem implements IClientIncomingPacket
}
final L2Object target = player.getTarget();
L2Character merchant = null;
L2MerchantInstance merchant = null;
if (!player.isGM() && (_listId != CUSTOM_CB_SELL_LIST))
{
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)
{
merchant = (L2Character) target;
merchant = (L2MerchantInstance) target;
}
else
{
@ -153,7 +152,11 @@ public final class RequestSellItem implements IClientIncomingPacket
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();
if (((MAX_ADENA / i.getCount()) < price) || (totalPrice > MAX_ADENA))
{
@ -171,19 +174,17 @@ public final class RequestSellItem implements IClientIncomingPacket
}
}
// add to castle treasury
if (merchant instanceof L2MerchantInstance)
{
final L2MerchantInstance npc = ((L2MerchantInstance) merchant);
final long taxCollection = (long) (totalPrice * (1.0 - npc.getTotalTaxRate(TaxType.SELL)));
npc.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection;
}
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury?
if (merchant != null)
{
final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
merchant.getCastle().addToTreasury(taxCollection);
}
// Update current load as well
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);
packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount());
packet.writeQ((long) ((item.getItem().getReferencePrice() / 2) * _taxRate));
}
}
else

View File

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

View File

@ -176,12 +176,11 @@ public final class RequestSellItem implements IClientIncomingPacket
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury
// add to castle treasury?
if (merchant != null)
{
final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
merchant.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection;
}
// Update current load as well

View File

@ -176,12 +176,11 @@ public final class RequestSellItem implements IClientIncomingPacket
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury
// add to castle treasury?
if (merchant != null)
{
final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
merchant.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection;
}
// Update current load as well

View File

@ -176,12 +176,11 @@ public final class RequestSellItem implements IClientIncomingPacket
player.addAdena("Sell", totalPrice, merchant, false);
// add to castle treasury
// add to castle treasury?
if (merchant != null)
{
final long taxCollection = (long) (totalPrice * (1.0 - merchant.getTotalTaxRate(TaxType.SELL)));
merchant.getCastle().addToTreasury(taxCollection);
totalPrice -= taxCollection;
}
// Update current load as well