Changed back to previous drop system.

This commit is contained in:
MobiusDev
2016-04-29 14:47:47 +00:00
parent 570cd3e457
commit 58b33a463e
26 changed files with 587 additions and 1469 deletions

View File

@@ -77,7 +77,7 @@ public class NpcViewMod implements IBypassHandler
{
target = L2World.getInstance().findObject(Integer.parseInt(st.nextToken()));
}
catch (NumberFormatException e)
catch (final NumberFormatException e)
{
return false;
}
@@ -116,11 +116,11 @@ public class NpcViewMod implements IBypassHandler
}
sendNpcDropList(activeChar, npc, dropListScope, st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0);
}
catch (NumberFormatException e)
catch (final NumberFormatException e)
{
return false;
}
catch (IllegalArgumentException e)
catch (final IllegalArgumentException e)
{
_log.warning("Bypass[NpcViewMod] unknown drop list scope: " + dropListScopeString);
return false;
@@ -155,7 +155,7 @@ public class NpcViewMod implements IBypassHandler
{
TimeUnit timeUnit = TimeUnit.MILLISECONDS;
long min = Long.MAX_VALUE;
for (TimeUnit tu : TimeUnit.values())
for (final TimeUnit tu : TimeUnit.values())
{
final long minTimeFromMillis = tu.convert(npcSpawn.getRespawnMinDelay(), TimeUnit.MILLISECONDS);
final long maxTimeFromMillis = tu.convert(npcSpawn.getRespawnMaxDelay(), TimeUnit.MILLISECONDS);
@@ -287,7 +287,34 @@ public class NpcViewMod implements IBypassHandler
final IDropItem dropItem = dropList.get(i);
if (dropItem instanceof GeneralDropItem)
{
addGeneralDropItem(activeChar, npc, amountFormat, chanceFormat, sb, (GeneralDropItem) dropItem);
final GeneralDropItem generalDropItem = (GeneralDropItem) dropItem;
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
else if (dropItem instanceof GroupedGeneralDropItem)
{
@@ -295,21 +322,46 @@ public class NpcViewMod implements IBypassHandler
if (generalGroupedDropItem.getItems().size() == 1)
{
final GeneralDropItem generalDropItem = generalGroupedDropItem.getItems().get(0);
addGeneralDropItem(activeChar, npc, amountFormat, chanceFormat, sb, new GeneralDropItem(generalDropItem.getItemId(), generalDropItem.getMin(), generalDropItem.getMax(), (generalDropItem.getChance(npc, activeChar) * generalGroupedDropItem.getChance()) / 100, generalDropItem.getAmountStrategy(), generalDropItem.getChanceStrategy(), generalGroupedDropItem.getPreciseStrategy(), generalGroupedDropItem.getKillerChanceModifierStrategy(), generalDropItem.getDropCalculationStrategy()));
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
if (min == max)
{
sb.append(amountFormat.format(min));
}
else
{
sb.append(amountFormat.format(min));
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
else
{
final GroupedGeneralDropItem normalized = generalGroupedDropItem.normalizeMe(npc, activeChar);
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top><img src=\"L2UI_CT1.ICON_DF_premiumItem\" width=32 height=32></td>");
sb.append("<td fixwidth=300 align=center><font name=\"ScreenMessageSmall\" color=\"CD9000\">One from group</font>");
sb.append("</td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0><tr>");
sb.append("<td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(normalized.getChance(), 100)));
sb.append(chanceFormat.format(Math.min(generalGroupedDropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table><br>");
for (GeneralDropItem generalDropItem : normalized.getItems())
for (final GeneralDropItem generalDropItem : generalGroupedDropItem.getItems())
{
final L2Item item = ItemTable.getInstance().getTemplate(generalDropItem.getItemId());
sb.append("<table width=291 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
@@ -324,9 +376,9 @@ public class NpcViewMod implements IBypassHandler
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=259><table width=253 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td><td width=205 align=center>");
final MinMax minMax = getPreciseMinMax(normalized.getChance(), generalDropItem.getMin(npc, activeChar), generalDropItem.getMax(npc, activeChar), generalDropItem.isPreciseCalculated());
final long min = minMax.min;
final long max = minMax.max;
final long min = generalDropItem.getMin(npc, activeChar);
final long max = generalDropItem.getMax(npc, activeChar);
sb.append(amountFormat.format(min));
if (min != max)
{
@@ -379,62 +431,4 @@ public class NpcViewMod implements IBypassHandler
html = html.replaceAll("%items%", bodySb.toString());
Util.sendCBHtml(activeChar, html);
}
/**
* @param activeChar
* @param npc
* @param amountFormat
* @param chanceFormat
* @param sb
* @param dropItem
*/
private static void addGeneralDropItem(L2PcInstance activeChar, L2Npc npc, DecimalFormat amountFormat, DecimalFormat chanceFormat, StringBuilder sb, GeneralDropItem dropItem)
{
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
sb.append("<table width=332 cellpadding=2 cellspacing=0 background=\"L2UI_CT1.Windows.Windows_DF_TooltipBG\">");
sb.append("<tr><td width=32 valign=top>");
sb.append("<img src=\"" + item.getIcon() + "\" width=32 height=32>");
sb.append("</td><td fixwidth=300 align=center><font name=\"hs9\" color=\"CD9000\">");
sb.append(item.getName());
sb.append("</font></td></tr><tr><td width=32></td><td width=300><table width=295 cellpadding=0 cellspacing=0>");
sb.append("<tr><td width=48 align=right valign=top><font color=\"LEVEL\">Amount:</font></td>");
sb.append("<td width=247 align=center>");
final MinMax minMax = getPreciseMinMax(dropItem.getChance(npc, activeChar), dropItem.getMin(npc, activeChar), dropItem.getMax(npc, activeChar), dropItem.isPreciseCalculated());
final long min = minMax.min;
final long max = minMax.max;
sb.append(amountFormat.format(min));
if (min != max)
{
sb.append(" - ");
sb.append(amountFormat.format(max));
}
sb.append("</td></tr><tr><td width=48 align=right valign=top><font color=\"LEVEL\">Chance:</font></td>");
sb.append("<td width=247 align=center>");
sb.append(chanceFormat.format(Math.min(dropItem.getChance(npc, activeChar), 100)));
sb.append("%</td></tr></table></td></tr><tr><td width=32></td><td width=300>&nbsp;</td></tr></table>");
}
private static class MinMax
{
public final long min, max;
public MinMax(long min, long max)
{
this.min = min;
this.max = max;
}
}
private static MinMax getPreciseMinMax(double chance, long min, long max, boolean isPrecise)
{
if (!isPrecise || (chance <= 100))
{
return new MinMax(min, max);
}
final int mult = (int) chance / 100;
return new MinMax(mult * min, (chance % 100) > 0 ? (mult + 1) * max : mult * max);
}
}