CreateItemRandom cleanup.

This commit is contained in:
MobiusDev
2018-09-01 18:07:03 +00:00
parent 03da47d5c6
commit 771f40bd3b
7 changed files with 49 additions and 70 deletions

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }

View File

@@ -26,6 +26,7 @@ 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.skills.Skill; import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
/** /**
* @author UnAfraid * @author UnAfraid
@@ -63,19 +64,15 @@ public class CreateItemRandom extends AbstractEffect
return; return;
} }
final double random = Rnd.nextDouble() * 100; for (ItemChanceHolder holder : item.getItem().getCreateItems())
double comulativeChance = 0;
for (int attempt = 0; attempt <= 1000; attempt++) // 1000 attempts! TODO: Remove this whole handler.
{ {
for (ItemChanceHolder holder : item.getItem().getCreateItems()) if (holder.getChance() < Rnd.get(100))
{ {
comulativeChance += holder.getChance(); player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
if (comulativeChance >= random) return;
{
player.addItem("CreateItems", holder.getId(), holder.getCount(), player, true);
return;
}
} }
} }
player.sendPacket(SystemMessageId.THERE_WAS_NOTHING_FOUND_INSIDE);
} }
} }