Fixed CreateItemRandom handler consuming more than one reagent.
This commit is contained in:
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
|||||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||||
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
import com.l2jmobius.gameserver.model.holders.ItemChanceHolder;
|
||||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||||
import com.l2jmobius.gameserver.model.items.type.ActionType;
|
|
||||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author UnAfraid
|
* @author UnAfraid
|
||||||
@@ -65,28 +63,19 @@ public class CreateItemRandom extends AbstractEffect
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemChanceHolder selectedItem = null;
|
|
||||||
final double random = Rnd.nextDouble() * 100;
|
final double random = Rnd.nextDouble() * 100;
|
||||||
double comulativeChance = 0;
|
double comulativeChance = 0;
|
||||||
|
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
|
||||||
|
{
|
||||||
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
for (ItemChanceHolder holder : item.getItem().getCreateItems())
|
||||||
{
|
{
|
||||||
comulativeChance += holder.getChance();
|
comulativeChance += holder.getChance();
|
||||||
if (comulativeChance >= random)
|
if (comulativeChance >= random)
|
||||||
{
|
{
|
||||||
selectedItem = holder;
|
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedItem == null)
|
|
||||||
{
|
|
||||||
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ((item.getItem().getDefaultAction() != ActionType.SKILL_REDUCE_ON_SKILL_SUCCESS) || player.destroyItem("Consume", item.getObjectId(), 1, player, true))
|
|
||||||
{
|
|
||||||
player.addItem("CreateItems", selectedItem.getId(), selectedItem.getCount(), player, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user