Fixed special product separation.

Contributed by Norvox.
This commit is contained in:
MobiusDevelopment
2021-04-28 09:15:10 +00:00
parent 845bf8a2c8
commit 3146b66547
3 changed files with 110 additions and 216 deletions

View File

@@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.LCoinShopData; import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest; import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder; import org.l2jmobius.gameserver.model.holders.LCoinShopProductHolder;
@@ -38,13 +39,34 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
{ {
private int _productId; private int _productId;
private int _amount; private int _amount;
private LCoinShopProductHolder _product;
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
{ {
packet.readC(); // category? final int shopIndex = packet.readC(); // shopIndex 3 = Lcoin Store , 4 = Special Craft?
_productId = packet.readD(); _productId = packet.readD();
_amount = packet.readD(); _amount = packet.readD();
switch (shopIndex) // 3 = Lcoin Shop - 4 = Special Craft
{
case 3: // Normal Lcoin Shop
{
_product = LCoinShopData.getInstance().getProduct(_productId);
break;
}
case 4: // Lcoin Special Craft
{
_product = LCoinShopSpecialCraftData.getInstance().getProduct(_productId);
break;
}
case 100: // Clan Shop
default:
{
_product = LCoinShopData.getInstance().getProduct(_productId);
}
}
return true; return true;
} }
@@ -62,13 +84,12 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
return; return;
} }
final LCoinShopProductHolder product = LCoinShopData.getInstance().getProduct(_productId); if (_product == null)
if (product == null)
{ {
return; return;
} }
if ((player.getLevel() < product.getMinLevel()) || (player.getLevel() > product.getMaxLevel())) if ((player.getLevel() < _product.getMinLevel()) || (player.getLevel() > _product.getMaxLevel()))
{ {
player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM); player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM);
return; return;
@@ -84,23 +105,23 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
player.addRequest(new PrimeShopRequest(player)); player.addRequest(new PrimeShopRequest(player));
// Check limits. // Check limits.
if (product.getAccountDailyLimit() > 0) // Sale period. if (_product.getAccountDailyLimit() > 0) // Sale period.
{ {
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit()) if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) >= _product.getAccountDailyLimit())
{ {
if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis()) if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + _product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
{ {
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message? player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
return; return;
} }
// Reset limit. // Reset limit.
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0);
} }
} }
else if (product.getAccountBuyLimit() > 0) // Count limit. else if (_product.getAccountBuyLimit() > 0) // Count limit.
{ {
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit()) if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) >= _product.getAccountBuyLimit())
{ {
player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message? player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message?
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
@@ -111,20 +132,20 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
// Check existing items. // Check existing items.
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
if (product.getIngredientIds()[i] == 0) if (_product.getIngredientIds()[i] == 0)
{ {
continue; continue;
} }
if (product.getIngredientIds()[i] == Inventory.ADENA_ID) if (_product.getIngredientIds()[i] == Inventory.ADENA_ID)
{ {
if (player.getAdena() < (product.getIngredientQuantities()[i] * _amount)) if (player.getAdena() < (_product.getIngredientQuantities()[i] * _amount))
{ {
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2); player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
return; return;
} }
} }
else if (player.getInventory().getInventoryItemCount(product.getIngredientIds()[i], -1, true) < (product.getIngredientQuantities()[i] * _amount)) else if (player.getInventory().getInventoryItemCount(_product.getIngredientIds()[i], -1, true) < (_product.getIngredientQuantities()[i] * _amount))
{ {
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2); player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
@@ -135,50 +156,50 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
// Remove items. // Remove items.
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
if (product.getIngredientIds()[i] == 0) if (_product.getIngredientIds()[i] == 0)
{ {
continue; continue;
} }
if (product.getIngredientIds()[i] == Inventory.ADENA_ID) if (_product.getIngredientIds()[i] == Inventory.ADENA_ID)
{ {
player.reduceAdena("LCoinShop", product.getIngredientQuantities()[i] * _amount, player, true); player.reduceAdena("LCoinShop", _product.getIngredientQuantities()[i] * _amount, player, true);
} }
else else
{ {
player.destroyItemByItemId("LCoinShop", product.getIngredientIds()[i], product.getIngredientQuantities()[i] * _amount, player, true); player.destroyItemByItemId("LCoinShop", _product.getIngredientIds()[i], _product.getIngredientQuantities()[i] * _amount, player, true);
} }
} }
// Reward. // Reward.
if (product.getProductionId2() > 0) if (_product.getProductionId2() > 0)
{ {
if (Rnd.get(100) < product.getChance()) if (Rnd.get(100) < _product.getChance())
{ {
player.addItem("LCoinShop", product.getProductionId(), product.getCount(), player, true); player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
} }
else if (Rnd.get(100) < product.getChance2()) else if (Rnd.get(100) < _product.getChance2())
{ {
player.addItem("LCoinShop", product.getProductionId2(), product.getCount2(), player, true); player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
} }
else if (product.getProductionId3() > 0) else if (_product.getProductionId3() > 0)
{ {
player.addItem("LCoinShop", product.getProductionId3(), product.getCount3(), player, true); player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
} }
} }
else else
{ {
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true); player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
} }
// Update account variables. // Update account variables.
if (product.getAccountDailyLimit() > 0) if (_product.getAccountDailyLimit() > 0)
{ {
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), Chronos.currentTimeMillis()); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + _product.getProductionId(), Chronos.currentTimeMillis());
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
} }
else if (product.getAccountBuyLimit() > 0) else if (_product.getAccountBuyLimit() > 0)
{ {
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
} }
// Remove request. // Remove request.

View File

@@ -1,155 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LCoinShop.xsd"> <list enabled="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/LCoinShop.xsd">
<product id="1001" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Sirra's Blade (+0) and 33% chance of giving 6 Giran Seals --> <product id="1200" category="1">
<ingredient id="92314" count="41" /> <!-- Giran Seal --> <ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94573" /> <!-- Package: +5 Sirra's Blade --> <production id="93801" /> <!-- Package: Sirra's Blade Sealed -->
</product>
<product id="1002" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Sword of Ipos (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94574" /> <!-- Package: +5 Sword of Ipos -->
</product>
<product id="1003" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Barakiel's Axe (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94575" /> <!-- Package: +5 Barakiel's Axe -->
</product>
<product id="1004" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Behemoth' Tuning Fork (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94576" /> <!-- Package: +5 Behemoth' Tuning Fork -->
</product>
<product id="1005" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Naga's Storm (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94577" /> <!-- Package: +5 Naga's Storm -->
</product>
<product id="1006" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Tiphon's Spear (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94578" /> <!-- Package: +5 Tiphon's Spear -->
</product>
<product id="1007" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Shyeed's Bow (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94579" /> <!-- Package: +5 Shyeed's Bow -->
</product>
<product id="1008" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Sobekk's Hurricane (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94580" /> <!-- Package: +5 Sobekk's Hurricane -->
</product>
<product id="1009" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Themis' Tongue (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94581" /> <!-- Package: +5 Themis' Tongue -->
</product>
<product id="1010" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Cabrio's Hand (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94582" /> <!-- Package: +5 Cabrio's Hand -->
</product>
<product id="1011" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Daimon Crystal (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94583" /> <!-- Package: +5 Daimon Crystal -->
</product>
<product id="1012" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Tallum Blade*Damascus (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94584" /> <!-- Package: +5 Tallum Blade*Damascus -->
</product>
<product id="1013" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Eclair Bijou (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94585" /> <!-- Package: +5 Eclair Bijou -->
</product>
<product id="1014" category="1"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Durendal (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="41" /> <!-- Giran Seal -->
<production id="94586" /> <!-- Package: +5 Durendal -->
</product>
<product id="1016" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Armor of Nightmare (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94587" /> <!-- Package: +5 Armor of Nightmare (Heavy) Armor -->
</product>
<product id="1017" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Helm of Nightmare (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94588" /> <!-- Package: +5 Helm of Nightmare (Heavy) Armor -->
</product>
<product id="1018" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Gauntlets of Nightmare (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94589" /> <!-- Package: +5 Gauntlets of Nightmare (Heavy) Armor -->
</product>
<product id="1019" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Boots of Nightmare (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94590" /> <!-- Package: +5 Boots of Nightmare (Heavy) Armor -->
</product>
<product id="1020" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Plate Armor (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94591" /> <!-- Package: +5 Majestic Plate Armor (Heavy) Armor -->
</product>
<product id="1021" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Circlet (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94592" /> <!-- Package: +5 Majestic Circlet (Heavy) Armor -->
</product>
<product id="1022" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Gauntlets (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94593" /> <!-- Package: +5 Majestic Gauntlets (Heavy) Armor -->
</product>
<product id="1023" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Boots (Heavy) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94594" /> <!-- Package: +5 Majestic Boots (Heavy) Armor -->
</product>
<product id="1024" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Leather Armor of Nightmare (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94595" /> <!-- Package: +5 Leather Armor of Nightmare (Light) Armor -->
</product>
<product id="1025" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Helm of Nightmare (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94596" /> <!-- Package: +5 Helm of Nightmare (Light) Armor -->
</product>
<product id="1026" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Gauntlets of Nightmare (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94597" /> <!-- Package: +5 Gauntlets of Nightmare (Light) Armor -->
</product>
<product id="1027" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Boots of Nightmare (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94598" /> <!-- Package: +5 Boots of Nightmare (Light) Armor -->
</product>
<product id="1028" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Leather Armor (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94599" /> <!-- Package: +5 Majestic Leather Armor (Light) Armor -->
</product>
<product id="1029" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Circlet (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94600" /> <!-- Package: +5 Majestic Circlet (Light) Armor -->
</product>
<product id="1030" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Gauntlets (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94601" /> <!-- Package: +5 Majestic Gauntlets (Light) Armor -->
</product>
<product id="1031" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Boots (Light) Armor (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94602" /> <!-- Package: +5 Majestic Boots (Light) Armor -->
</product>
<product id="1032" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Robe of Nightmare (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94603" /> <!-- Package: +5 Robe of Nightmare (Robe) -->
</product>
<product id="1033" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Helm of Nightmare (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94604" /> <!-- Package: +5 Helm of Nightmare (Robe) -->
</product>
<product id="1034" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Gauntlets of Nightmare (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94605" /> <!-- Package: +5 Gauntlets of Nightmare (Robe) -->
</product>
<product id="1035" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Boots of Nightmare (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94606" /> <!-- Package: +5 Boots of Nightmare (Robe) -->
</product>
<product id="1036" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Robe (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94607" /> <!-- Package: +5 Majestic Robe (Robe) -->
</product>
<product id="1037" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Circlet (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94608" /> <!-- Package: +5 Majestic Circlet (Robe) -->
</product>
<product id="1038" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Gauntlets (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94609" /> <!-- Package: +5 Majestic Gauntlets (Robe) -->
</product>
<product id="1039" category="2"> <!-- TODO: It has a 33% chance of giving the item, or 33% chance of giving a Package: Majestic Boots (Robe) (+0) and 33% chance of giving 6 Giran Seals -->
<ingredient id="92314" count="31" /> <!-- Giran Seal -->
<production id="94610" /> <!-- Package: +5 Majestic Boots (Robe) -->
</product> </product>
</list> </list>

View File

@@ -20,6 +20,7 @@ import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.commons.util.Rnd; import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.data.xml.LCoinShopData; import org.l2jmobius.gameserver.data.xml.LCoinShopData;
import org.l2jmobius.gameserver.data.xml.LCoinShopSpecialCraftData;
import org.l2jmobius.gameserver.enums.SpecialItemType; import org.l2jmobius.gameserver.enums.SpecialItemType;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest; import org.l2jmobius.gameserver.model.actor.request.PrimeShopRequest;
@@ -39,13 +40,34 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
{ {
private int _productId; private int _productId;
private int _amount; private int _amount;
private LCoinShopProductHolder _product;
@Override @Override
public boolean read(GameClient client, PacketReader packet) public boolean read(GameClient client, PacketReader packet)
{ {
packet.readC(); // category? final int shopIndex = packet.readC(); // shopIndex 3 = Lcoin Store , 4 = Special Craft?
_productId = packet.readD(); _productId = packet.readD();
_amount = packet.readD(); _amount = packet.readD();
switch (shopIndex) // 3 = Lcoin Shop - 4 = Special Craft
{
case 3: // Normal Lcoin Shop
{
_product = LCoinShopData.getInstance().getProduct(_productId);
break;
}
case 4: // Lcoin Special Craft
{
_product = LCoinShopSpecialCraftData.getInstance().getProduct(_productId);
break;
}
case 100: // Clan Shop
default:
{
_product = LCoinShopData.getInstance().getProduct(_productId);
}
}
return true; return true;
} }
@@ -63,13 +85,12 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
return; return;
} }
final LCoinShopProductHolder product = LCoinShopData.getInstance().getProduct(_productId); if (_product == null)
if (product == null)
{ {
return; return;
} }
if ((player.getLevel() < product.getMinLevel()) || (player.getLevel() > product.getMaxLevel())) if ((player.getLevel() < _product.getMinLevel()) || (player.getLevel() > _product.getMaxLevel()))
{ {
player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM); player.sendPacket(SystemMessageId.YOUR_LEVEL_CANNOT_PURCHASE_THIS_ITEM);
return; return;
@@ -85,23 +106,23 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
player.addRequest(new PrimeShopRequest(player)); player.addRequest(new PrimeShopRequest(player));
// Check limits. // Check limits.
if (product.getAccountDailyLimit() > 0) // Sale period. if (_product.getAccountDailyLimit() > 0) // Sale period.
{ {
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountDailyLimit()) if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) >= _product.getAccountDailyLimit())
{ {
if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis()) if ((player.getAccountVariables().getLong(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + _product.getProductionId(), 0) + 86400000) > Chronos.currentTimeMillis())
{ {
player.sendMessage("You have reached your daily limit."); // TODO: Retail system message? player.sendMessage("You have reached your daily limit."); // TODO: Retail system message?
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
return; return;
} }
// Reset limit. // Reset limit.
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0);
} }
} }
else if (product.getAccountBuyLimit() > 0) // Count limit. else if (_product.getAccountBuyLimit() > 0) // Count limit.
{ {
if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) >= product.getAccountBuyLimit()) if (player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) >= _product.getAccountBuyLimit())
{ {
player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message? player.sendMessage("You cannot buy any more of this item."); // TODO: Retail system message?
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
@@ -112,29 +133,29 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
// Check existing items. // Check existing items.
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
if (product.getIngredientIds()[i] == 0) if (_product.getIngredientIds()[i] == 0)
{ {
continue; continue;
} }
if (product.getIngredientIds()[i] == Inventory.ADENA_ID) if (_product.getIngredientIds()[i] == Inventory.ADENA_ID)
{ {
if (player.getAdena() < (product.getIngredientQuantities()[i] * _amount)) if (player.getAdena() < (_product.getIngredientQuantities()[i] * _amount))
{ {
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2); player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
return; return;
} }
} }
else if (product.getIngredientIds()[i] == SpecialItemType.HONOR_POINTS.getClientId()) else if (_product.getIngredientIds()[i] == SpecialItemType.HONOR_POINTS.getClientId())
{ {
if (player.getHonorPoints() < (product.getIngredientQuantities()[i] * _amount)) if (player.getHonorPoints() < (_product.getIngredientQuantities()[i] * _amount))
{ {
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2); player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
return; return;
} }
} }
else if (player.getInventory().getInventoryItemCount(product.getIngredientIds()[i], -1, true) < (product.getIngredientQuantities()[i] * _amount)) else if (player.getInventory().getInventoryItemCount(_product.getIngredientIds()[i], -1, true) < (_product.getIngredientQuantities()[i] * _amount))
{ {
player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2); player.sendPacket(SystemMessageId.INCORRECT_ITEM_COUNT_2);
player.removeRequest(PrimeShopRequest.class); player.removeRequest(PrimeShopRequest.class);
@@ -145,54 +166,54 @@ public class RequestPurchaseLimitShopItemBuy implements IClientIncomingPacket
// Remove items. // Remove items.
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
if (product.getIngredientIds()[i] == 0) if (_product.getIngredientIds()[i] == 0)
{ {
continue; continue;
} }
if (product.getIngredientIds()[i] == Inventory.ADENA_ID) if (_product.getIngredientIds()[i] == Inventory.ADENA_ID)
{ {
player.reduceAdena("LCoinShop", product.getIngredientQuantities()[i] * _amount, player, true); player.reduceAdena("LCoinShop", _product.getIngredientQuantities()[i] * _amount, player, true);
} }
else if (product.getIngredientIds()[i] == SpecialItemType.HONOR_POINTS.getClientId()) else if (_product.getIngredientIds()[i] == SpecialItemType.HONOR_POINTS.getClientId())
{ {
player.setHonorPoints(player.getHonorPoints() - (product.getIngredientQuantities()[i] * _amount)); player.setHonorPoints(player.getHonorPoints() - (_product.getIngredientQuantities()[i] * _amount));
} }
else else
{ {
player.destroyItemByItemId("LCoinShop", product.getIngredientIds()[i], product.getIngredientQuantities()[i] * _amount, player, true); player.destroyItemByItemId("LCoinShop", _product.getIngredientIds()[i], _product.getIngredientQuantities()[i] * _amount, player, true);
} }
} }
// Reward. // Reward.
if (product.getProductionId2() > 0) if (_product.getProductionId2() > 0)
{ {
if (Rnd.get(100) < product.getChance()) if (Rnd.get(100) < _product.getChance())
{ {
player.addItem("LCoinShop", product.getProductionId(), product.getCount(), player, true); player.addItem("LCoinShop", _product.getProductionId(), _product.getCount(), player, true);
} }
else if (Rnd.get(100) < product.getChance2()) else if (Rnd.get(100) < _product.getChance2())
{ {
player.addItem("LCoinShop", product.getProductionId2(), product.getCount2(), player, true); player.addItem("LCoinShop", _product.getProductionId2(), _product.getCount2(), player, true);
} }
else if (product.getProductionId3() > 0) else if (_product.getProductionId3() > 0)
{ {
player.addItem("LCoinShop", product.getProductionId3(), product.getCount3(), player, true); player.addItem("LCoinShop", _product.getProductionId3(), _product.getCount3(), player, true);
} }
} }
else else
{ {
player.addItem("LCoinShop", product.getProductionId(), _amount, player, true); player.addItem("LCoinShop", _product.getProductionId(), _amount, player, true);
} }
// Update account variables. // Update account variables.
if (product.getAccountDailyLimit() > 0) if (_product.getAccountDailyLimit() > 0)
{ {
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + product.getProductionId(), Chronos.currentTimeMillis()); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_TIME + _product.getProductionId(), Chronos.currentTimeMillis());
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
} }
else if (product.getAccountBuyLimit() > 0) else if (_product.getAccountBuyLimit() > 0)
{ {
player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + product.getProductionId(), 0) + 1); player.getAccountVariables().set(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), player.getAccountVariables().getInt(AccountVariables.LCOIN_SHOP_PRODUCT_COUNT + _product.getProductionId(), 0) + 1);
} }
// Remove request. // Remove request.