Send RequestNewEnchantTry ExEnchantSucess or ExEnchantFail before creating item.
This commit is contained in:
parent
42d5d76bb6
commit
bba8642e8c
@ -30,7 +30,6 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ClientPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantOneFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantSucess;
|
||||
@ -107,20 +106,25 @@ public class RequestNewEnchantTry implements ClientPacket
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate compound result.
|
||||
final double random = (Rnd.nextDouble() * 100);
|
||||
final boolean success = random <= combinationItem.getChance();
|
||||
final CombinationItemReward rewardItem = combinationItem.getReward(success ? CombinationItemType.ON_SUCCESS : CombinationItemType.ON_FAILURE);
|
||||
|
||||
// Send success or fail packet.
|
||||
if (success)
|
||||
{
|
||||
player.sendPacket(new ExEnchantSucess(rewardItem.getId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExEnchantFail(itemOne.getId(), itemTwo.getId()));
|
||||
}
|
||||
|
||||
// Take required items and add result item.
|
||||
if (player.destroyItem("Compound-Item-One", itemOne, 1, null, true) && player.destroyItem("Compound-Item-Two", itemTwo, 1, null, true) && ((combinationItem.getCommission() <= 0) || player.reduceAdena("Compound-Commission", combinationItem.getCommission(), player, true)))
|
||||
{
|
||||
final double random = (Rnd.nextDouble() * 100);
|
||||
final boolean success = random <= combinationItem.getChance();
|
||||
final CombinationItemReward rewardItem = combinationItem.getReward(success ? CombinationItemType.ON_SUCCESS : CombinationItemType.ON_FAILURE);
|
||||
final Item item = player.addItem("Compound-Result", rewardItem.getId(), rewardItem.getCount(), null, true);
|
||||
if (success)
|
||||
{
|
||||
player.sendPacket(new ExEnchantSucess(item.getId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExEnchantFail(itemOne.getId(), itemTwo.getId()));
|
||||
}
|
||||
|
||||
// Notify to scripts.
|
||||
if (EventDispatcher.getInstance().hasListener(EventType.ON_ITEM_COMPOUND))
|
||||
@ -129,25 +133,6 @@ public class RequestNewEnchantTry implements ClientPacket
|
||||
}
|
||||
}
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
if (itemOne.isStackable() && (itemOne.getCount() > 0))
|
||||
{
|
||||
iu.addModifiedItem(itemOne);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addRemovedItem(itemOne);
|
||||
}
|
||||
if (itemTwo.isStackable() && (itemTwo.getCount() > 0))
|
||||
{
|
||||
iu.addModifiedItem(itemTwo);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addRemovedItem(itemTwo);
|
||||
}
|
||||
player.sendInventoryUpdate(iu);
|
||||
|
||||
player.removeRequest(request.getClass());
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ClientPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantOneFail;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.compound.ExEnchantSucess;
|
||||
@ -104,40 +103,26 @@ public class RequestNewEnchantTry implements ClientPacket
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.destroyItem("Compound-Item-One", itemOne, 1, null, true) && player.destroyItem("Compound-Item-Two", itemTwo, 1, null, true) && ((combinationItem.getCommission() <= 0) || player.reduceAdena("Compound-Commission", combinationItem.getCommission(), player, true)))
|
||||
// Calculate compound result.
|
||||
final double random = (Rnd.nextDouble() * 100);
|
||||
final boolean success = random <= combinationItem.getChance();
|
||||
final CombinationItemReward rewardItem = combinationItem.getReward(success ? CombinationItemType.ON_SUCCESS : CombinationItemType.ON_FAILURE);
|
||||
|
||||
// Send success or fail packet.
|
||||
if (success)
|
||||
{
|
||||
final double random = (Rnd.nextDouble() * 100);
|
||||
final boolean success = random <= combinationItem.getChance();
|
||||
final CombinationItemReward rewardItem = combinationItem.getReward(success ? CombinationItemType.ON_SUCCESS : CombinationItemType.ON_FAILURE);
|
||||
final Item item = player.addItem("Compound-Result", rewardItem.getId(), rewardItem.getCount(), null, true);
|
||||
if (success)
|
||||
{
|
||||
player.sendPacket(new ExEnchantSucess(item.getId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExEnchantFail(itemOne.getId(), itemTwo.getId()));
|
||||
}
|
||||
player.sendPacket(new ExEnchantSucess(rewardItem.getId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new ExEnchantFail(itemOne.getId(), itemTwo.getId()));
|
||||
}
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
if (itemOne.isStackable() && (itemOne.getCount() > 0))
|
||||
// Take required items and add result item.
|
||||
if (player.destroyItem("Compound-Item-One", itemOne, 1, null, true) && player.destroyItem("Compound-Item-Two", itemTwo, 1, null, true) && ((combinationItem.getCommission() <= 0) || player.reduceAdena("Compound-Commission", combinationItem.getCommission(), player, true)))
|
||||
{
|
||||
iu.addModifiedItem(itemOne);
|
||||
player.addItem("Compound-Result", rewardItem.getId(), rewardItem.getCount(), null, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addRemovedItem(itemOne);
|
||||
}
|
||||
if (itemTwo.isStackable() && (itemTwo.getCount() > 0))
|
||||
{
|
||||
iu.addModifiedItem(itemTwo);
|
||||
}
|
||||
else
|
||||
{
|
||||
iu.addRemovedItem(itemTwo);
|
||||
}
|
||||
player.sendInventoryUpdate(iu);
|
||||
|
||||
player.removeRequest(request.getClass());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user