Addition of merchant zero sell price configuration.

This commit is contained in:
MobiusDevelopment
2020-01-04 02:29:32 +00:00
parent d268e06690
commit 1cdcd2f8b0
104 changed files with 399 additions and 377 deletions

View File

@ -124,6 +124,7 @@ public class Config
private static final String CUSTOM_FACTION_SYSTEM_CONFIG_FILE = "./config/Custom/FactionSystem.ini";
private static final String CUSTOM_FAKE_PLAYERS_CONFIG_FILE = "./config/Custom/FakePlayers.ini";
private static final String CUSTOM_FIND_PVP_CONFIG_FILE = "./config/Custom/FindPvP.ini";
private static final String CUSTOM_MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE = "./config/Custom/MerchantZeroSellPrice.ini";
private static final String CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE = "./config/Custom/MultilingualSupport.ini";
private static final String CUSTOM_NPC_STAT_MULTIPLIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
@ -1234,6 +1235,7 @@ public class Config
public static boolean FAKE_PLAYER_CAN_DROP_ITEMS;
public static boolean FAKE_PLAYER_CAN_PICKUP;
public static boolean ENABLE_FIND_PVP;
public static boolean MERCHANT_ZERO_SELL_PRICE;
public static boolean PREMIUM_SYSTEM_ENABLED;
public static float PREMIUM_RATE_XP;
public static float PREMIUM_RATE_SP;
@ -3172,6 +3174,10 @@ public class Config
final PropertiesParser FindPvP = new PropertiesParser(CUSTOM_FIND_PVP_CONFIG_FILE);
ENABLE_FIND_PVP = FindPvP.getBoolean("EnableFindPvP", false);
// Load MerchantZeroSellPrice config file (if exists)
final PropertiesParser MerchantZeroSellPrice = new PropertiesParser(CUSTOM_MERCHANT_ZERO_SELL_PRICE_CONFIG_FILE);
MERCHANT_ZERO_SELL_PRICE = MerchantZeroSellPrice.getBoolean("MerchantZeroSellPrice", false);
// Load MultilingualSupport config file (if exists)
final PropertiesParser MultilingualSupport = new PropertiesParser(CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE);

View File

@ -88,6 +88,6 @@ public class MerchantInstance extends NpcInstance
player.setInventoryBlockingStatus(true);
player.sendPacket(new BuyList(buyList, player, (applyCastleTax) ? getCastleTaxRate(TaxType.BUY) : 0));
player.sendPacket(new ExBuySellList(player, false, (applyCastleTax) ? getCastleTaxRate(TaxType.SELL) : 0));
player.sendPacket(new ExBuySellList(player, false));
}
}

View File

@ -157,7 +157,7 @@ public class RequestRefundItem implements IClientIncomingPacket
final long count = item.getCount();
weight += count * template.getWeight();
adena += (count * template.getReferencePrice()) / 2;
adena += count * (template.getReferencePrice() / 2);
if (!template.isStackable())
{
slots += count;
@ -182,7 +182,7 @@ public class RequestRefundItem implements IClientIncomingPacket
return;
}
if ((adena < 0) || !player.reduceAdena("Refund", adena, player.getLastFolkNPC(), false))
if (!Config.MERCHANT_ZERO_SELL_PRICE && ((adena < 0) || !player.reduceAdena("Refund", adena, player.getLastFolkNPC(), false)))
{
client.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
client.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -25,7 +25,6 @@ import java.util.List;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.impl.BuyListData;
import org.l2jmobius.gameserver.enums.TaxType;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.instance.MerchantInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@ -170,17 +169,11 @@ public class RequestSellItem implements IClientIncomingPacket
}
}
// add to castle treasury
if (merchant != null)
if (!Config.MERCHANT_ZERO_SELL_PRICE)
{
// Keep here same formula as in {@link ExBuySellList} to produce same result.
final long profit = (long) (totalPrice * (1.0 - merchant.getCastleTaxRate(TaxType.SELL)));
merchant.handleTaxPayment(totalPrice - profit);
totalPrice = profit;
player.addAdena("Sell", totalPrice, merchant, false);
}
player.addAdena("Sell", totalPrice, merchant, false);
// Update current load as well
client.sendPacket(new ExUserInfoInvenWeight(player));
client.sendPacket(new ExBuySellList(player, true));

View File

@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.network.serverpackets;
import java.util.Collection;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@ -33,7 +34,6 @@ public class ExBuySellList extends AbstractItemPacket
private Collection<ItemInstance> _refundList = null;
private final boolean _done;
private final int _inventorySlots;
private double _castleTaxRate = 1;
public ExBuySellList(PlayerInstance player, boolean done)
{
@ -47,12 +47,6 @@ public class ExBuySellList extends AbstractItemPacket
_done = done;
}
public ExBuySellList(PlayerInstance player, boolean done, double castleTaxRate)
{
this(player, done);
_castleTaxRate = 1 - castleTaxRate;
}
@Override
public boolean write(PacketWriter packet)
{
@ -67,7 +61,7 @@ public class ExBuySellList extends AbstractItemPacket
for (ItemInstance item : _sellList)
{
writeItem(packet, item);
packet.writeQ((long) ((item.getItem().getReferencePrice() / 2) * _castleTaxRate));
packet.writeQ(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : item.getItem().getReferencePrice() / 2);
}
}
else
@ -83,7 +77,7 @@ public class ExBuySellList extends AbstractItemPacket
{
writeItem(packet, item);
packet.writeD(i++);
packet.writeQ((item.getItem().getReferencePrice() / 2) * item.getCount());
packet.writeQ(Config.MERCHANT_ZERO_SELL_PRICE ? 0 : (item.getItem().getReferencePrice() / 2) * item.getCount());
}
}
else