Minimum range for private stores.

This commit is contained in:
mobius
2015-01-02 11:43:45 +00:00
parent 45e2a035cd
commit ffc1c885bc
9 changed files with 138 additions and 0 deletions

View File

@@ -7073,4 +7073,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
return getTemplate().getRace();
}
public int getMinShopDistance()
{
return 0;
}
}

View File

@@ -1939,4 +1939,10 @@ public class L2Npc extends L2Character
_summonedNpcs.clear();
}
}
@Override
public int getMinShopDistance()
{
return Config.SHOP_MIN_RANGE_FROM_NPC;
}
}

View File

@@ -4712,9 +4712,27 @@ public final class L2PcInstance extends L2Playable
public boolean canOpenPrivateStore()
{
if ((Config.SHOP_MIN_RANGE_FROM_NPC > 0) || (Config.SHOP_MIN_RANGE_FROM_PLAYER > 0))
{
for (L2Character cha : getKnownList().getKnownCharacters())
{
if (Util.checkIfInRange(cha.getMinShopDistance(), this, cha, true))
{
sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_OPEN_A_PRIVATE_STORE_HERE));
return false;
}
}
}
return !isAlikeDead() && !isInOlympiadMode() && !isMounted() && !isInsideZone(ZoneId.NO_STORE) && !isCastingNow();
}
@Override
public int getMinShopDistance()
{
return (isSitting()) ? Config.SHOP_MIN_RANGE_FROM_PLAYER : 0;
}
public void tryOpenPrivateBuyStore()
{
// Player shouldn't be able to set stores if he/she is alike dead (dead or fake death)

View File

@@ -101,6 +101,12 @@ public final class RequestRecipeShopListSet extends L2GameClientPacket
return;
}
if (!player.canOpenPrivateStore())
{
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
List<L2RecipeList> dwarfRecipes = Arrays.asList(player.getDwarvenRecipeBook());
List<L2RecipeList> commonRecipes = Arrays.asList(player.getCommonRecipeBook());

View File

@@ -116,6 +116,13 @@ public final class SetPrivateStoreListBuy extends L2GameClientPacket
return;
}
if (!player.canOpenPrivateStore())
{
player.sendPacket(new PrivateStoreManageListBuy(player));
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
TradeList tradeList = player.getBuyList();
tradeList.clear();

View File

@@ -111,6 +111,13 @@ public class SetPrivateStoreListSell extends L2GameClientPacket
return;
}
if (!player.canOpenPrivateStore())
{
player.sendPacket(new PrivateStoreManageListSell(player, _packageSale));
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Check maximum number of allowed slots for pvt shops
if (_items.length > player.getPrivateSellStoreLimit())
{