Jump to content

[Share]Mob Drop Preview Panel


Darule

Recommended Posts

Hi there i'd like to share a Drop Preview Panel for Mobs.

 

So what this system does?

When you Shift + Click a mob you can view its Drops.

 

Drop Preview Panel Supports: (for each item)

Item Icon

Item Name

Item Min+Max Drop

Item Drop Quantity

Item Percentage Drop % (enhanced for low drops)

 

 

Here is a preview pic of the system

droppreview.png

 

This is the patch file for the latest action shift for l2jhi5.

 

Index: L2NpcActionShift.java
===================================================================
--- L2NpcActionShift.java	(revision 8584)
+++ L2NpcActionShift.java	(working copy)
@@ -183,77 +183,13 @@
				activeChar.sendPacket(su);
			}

-			NpcHtmlMessage html = new NpcHtmlMessage(0);
-			int hpMul = Math.round((float)(((L2Character)target).getStat().calcStat(Stats.MAX_HP, 1, (L2Character)target, null) / BaseStats.CON.calcBonus((L2Character)target)));
-			if (hpMul == 0)
-				hpMul = 1;
-			final StringBuilder html1 = StringUtil.startAppend(
+			NpcHtmlMessage html = new NpcHtmlMessage(0);final StringBuilder html1 = StringUtil.startAppend(
					1000,
-					"<html><body>" +
-					"<br><center><font color=\"LEVEL\">[Combat Stats]</font></center>" +
-					"<table border=0 width=\"100%\">" +
-					"<tr><td>Max.HP</td><td>",
-					String.valueOf(((L2Character)target).getMaxHp() / hpMul),
-					"*",
-					String.valueOf(hpMul),
-					"</td><td>Max.MP</td><td>",
-					String.valueOf(((L2Character)target).getMaxMp()),
-					"</td></tr>" +
-					"<tr><td>P.Atk.</td><td>",
-					String.valueOf(((L2Character)target).getPAtk(null)),
-					"</td><td>M.Atk.</td><td>",
-					String.valueOf(((L2Character)target).getMAtk(null, null)),
-					"</td></tr>" +
-					"<tr><td>P.Def.</td><td>",
-					String.valueOf(((L2Character)target).getPDef(null)),
-					"</td><td>M.Def.</td><td>",
-					String.valueOf(((L2Character)target).getMDef(null, null)),
-					"</td></tr>" +
-					"<tr><td>Accuracy</td><td>",
-					String.valueOf(((L2Character)target).getAccuracy()),
-					"</td><td>Evasion</td><td>",
-					String.valueOf(((L2Character)target).getEvasionRate(null)),
-					"</td></tr>" +
-					"<tr><td>Critical</td><td>",
-					String.valueOf(((L2Character)target).getCriticalHit(null, null)),
-					"</td><td>Speed</td><td>",
-					String.valueOf(((L2Character)target).getRunSpeed()),
-					"</td></tr>" +
-					"<tr><td>Atk.Speed</td><td>",
-					String.valueOf(((L2Character)target).getPAtkSpd()),
-					"</td><td>Cast.Speed</td><td>",
-					String.valueOf(((L2Character)target).getMAtkSpd()),
-					"</td></tr>" +
-					"<tr><td>Race</td><td>",
-					((L2Npc)target).getTemplate().getRace().toString(),
-					"</td><td></td><td></td></tr>" +
-					"</table>" +
-					"<br><center><font color=\"LEVEL\">[basic Stats]</font></center>" +
-					"<table border=0 width=\"100%\">" +
-					"<tr><td>STR</td><td>",
-					String.valueOf(((L2Character)target).getSTR()),
-					"</td><td>DEX</td><td>",
-					String.valueOf(((L2Character)target).getDEX()),
-					"</td><td>CON</td><td>",
-					String.valueOf(((L2Character)target).getCON()),
-					"</td></tr>" +
-					"<tr><td>INT</td><td>",
-					String.valueOf(((L2Character)target).getINT()),
-					"</td><td>WIT</td><td>",
-					String.valueOf(((L2Character)target).getWIT()),
-					"</td><td>MEN</td><td>",
-					String.valueOf(((L2Character)target).getMEN()),
-					"</td></tr>" +
-					"</table>"
+					"<html><head><title>"+((L2Npc) target).getName()+"</title><body><table bgcolor=444444 border=1 cellspacing=2 cellpadding=0 width=293><tr><td align=center>Drop Panel</td></tr></table><br><table  bgcolor=333333 cellpadding=0 cellspacing=0 width=274><tr><td align=center><font color=fff600>Legend</font></td></tr></table><table bgcolor=333333 width=276><tr><td align=center>[D]= Drop   [s]= Spoil   [Q]= Quest</td></tr><tr><td align=center>(CI)= Common Item</td></tr></table><br><table bgcolor=444444 cellspacing=2 cellpadding=1 border=1 width=280>"
			);

			if (!((L2Npc) target).getTemplate().getDropData().isEmpty())
			{
-				StringUtil.append(html1,
-						"<br><center><font color=\"LEVEL\">[Drop Info]</font></center>" +
-						"<br>Rates legend: <font color=\"ff9999\">50%+</font> <font color=\"00ff00\">30%+</font> <font color=\"0066ff\">less than 30%</font>" +
-						"<table border=0 width=\"100%\">"
-				);
				for (L2DropCategory cat : ((L2Npc)target).getTemplate().getDropData())
				{
					for (L2DropData drop : cat.getAllDrops())
@@ -261,31 +197,76 @@
						final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
						if (item == null)
							continue;
+						int mind = 0,maxd = 0;
+						String smind = null,smaxd = null,drops = null;
+						String name = item.getName();
+						double chance = 100/(1000000/(drop.getChance()));

-						final String color;
-						
-						if (drop.getChance() >= 500000)
-							color = "ff9999";
-						else if (drop.getChance() >= 300000)
-							color = "00ff00";
+						if (cat.isSweep())
+						{
+							mind = (int) (Config.RATE_DROP_SPOIL * drop.getMinDrop());
+							maxd = (int) (Config.RATE_DROP_SPOIL * drop.getMaxDrop());
+						}
+						else if (drop.getItemId()==57)
+						{
+							mind = 300 * drop.getMinDrop();
+							maxd = 300 * drop.getMaxDrop();
+						}
						else
-							color = "0066ff";
+						{
+							mind = (int) (Config.RATE_DROP_ITEMS * drop.getMinDrop());
+							maxd = (int) (Config.RATE_DROP_ITEMS * drop.getMaxDrop());
+						}
+						if (mind > 999999)
+						{
+							DecimalFormat df = new DecimalFormat("###.#");
+							smind = df.format(((double)(mind))/1000000)+" KK";
+							smaxd = df.format(((double)(maxd))/1000000)+" KK";
+						}
+						else if (mind > 999)
+						{
+							smind = ((int)(mind/1000))+" K";
+							smaxd = ((int)(maxd/1000))+" K";
+						}

+						else
+						{ 
+							smind = Integer.toString(mind);
+							smaxd = Integer.toString(maxd);
+						}
+						if (chance <= 0.001)
+						{
+							DecimalFormat df = new DecimalFormat("#.####");
+							drops = df.format(chance);
+						}
+						else if (chance <= 0.01)
+						{
+							DecimalFormat df = new DecimalFormat("#.###");
+							drops = df.format(chance);
+						}
+						else
+						{
+							DecimalFormat df = new DecimalFormat("##.##");
+							drops = df.format(chance);
+						}
+						if (name.startsWith("Common Item - "))
+						{
+							name = "(CI)" + name.substring(14);
+						}
+						if (name.length() >= 36)
+						{
+							name = name.substring(0, 33) + "...";
+						}
						StringUtil.append(html1,
-								"<tr>",
-								"<td><img src=\"" + item.getIcon() + "\" height=32 width=32></td>" + 
-								"<td><font color=\"", color, "\">", item.getName(), "</font></td>",
-								"<td>", (drop.isQuestDrop() ? "Quest" : (cat.isSweep() ? "Sweep" : "Drop")),"</td>",
-								"</tr>"
-						);
+						"<tr><td valign=top align=center height=38 width=40><img src=\""+item.getIcon()+"\" height=32 width=32></td><td><table cellpadding=0 cellspacing=1 width=237><tr><td>"+drops+"%</td></tr><tr><td>"+(drop.isQuestDrop() ? "[Q]" : (cat.isSweep() ? "[s]" : "[D]"))+"<font color=fff600>"+name+"</font>"+(maxd==1 ? "[1]" : "["+smind+" - "+smaxd+"]") + "</td></tr></table></td>"
+                        );
					}
				}
-				html1.append("</table>");
			}
-			html1.append("</body></html>");
-			
+			html1.append("</tr></table></body></html>");
			html.setHtml(html1.toString());
			activeChar.sendPacket(html);
+		
		}
		return true;
	}

 

This code can be done better, if you have any suggestion tell me here. We can do this with a config file too for more options.

Link to comment
Share on other sites

Try deleting the border to the table (table border=0), deleting the quest drop items who are shown on the droplist (i supouse).

The [D]Drop and [s Spoil delete the [s and [D] and put the indications with colors.

That would be a nice code :)

I'll try to do it by myself and if you want i can post it :)

Very good share, and keep sharing :D

Link to comment
Share on other sites

I havent test it on Interlude, maybe you need some adaptions for it.

Is there a file for shift clicking mobs on il like the L2NpcActionShift.java if yes then you can try it.

Link to comment
Share on other sites

Thanks for the share... But onlu handy for those who like to use the shift+click feature in theirs production server,... a questios, did the properties have already something like shift+click drop list?

Link to comment
Share on other sites

Thanks for the share... But onlu handy for those who like to use the shift+click feature in theirs production server,... a questios, did the properties have already something like shift+click drop list?

 

Stop using the google translator man...

Link to comment
Share on other sites

Thanks for the share... But onlu handy for those who like to use the shift+click feature in theirs production server,... a questios, did the properties have already something like shift+click drop list?

 

Yes the feature is only for servers that want to use such a feature, btw as you said there is in the configs  a shift+click feature already but its not like this system.

Link to comment
Share on other sites

  • 4 weeks later...

Erro L2Brick server

 

 

 

----------

1. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 38)

        public class L2NpcActionShift implements IActionHandler

                    ^^^^^^^^^^^^^^^^

The type L2NpcActionShift must implement the inherited abstract method IActionHa

ndler.getInstanceType()

----------

2. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 228)

        DecimalFormat df = new DecimalFormat("000.0");

        ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

3. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 228)

        DecimalFormat df = new DecimalFormat("000.0");

                              ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

4. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 245)

        DecimalFormat df = new DecimalFormat("0.0000");

        ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

5. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 245)

        DecimalFormat df = new DecimalFormat("0.0000");

                              ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

6. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 250)

        DecimalFormat df = new DecimalFormat("0.000");

        ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

7. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 250)

        DecimalFormat df = new DecimalFormat("0.000");

                              ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

8. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 255)

        DecimalFormat df = new DecimalFormat("00.00");

        ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

9. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcAc

tionShift.java (at line 255)

        DecimalFormat df = new DecimalFormat("00.00");

                              ^^^^^^^^^^^^^

DecimalFormat cannot be resolved to a type

----------

10. ERROR in D:\L2Brick-Rev1608\game\data\scripts\handlers\actionhandlers\L2NpcA

ctionShift.java (at line 279)

        }

        ^

Syntax error, insert "}" to complete ClassBody

----------

 

Link to comment
Share on other sites

working for interlude, but IL don't have getIcon() so there is two way:

1) remove getIcon, but then you dont see icon

2) add getIcon(), its easy, but you need to add all icons to etc, armor and weapons.sql

 

btw, interlude dont have L2NpcActionShift.java, so we add to L2NpcInstance this code.

Link to comment
Share on other sites

  • 3 weeks later...

wow amazing share where all servers need (low rate)

 

thx for share keep ur work

 

Thanks a lot, although i think that even high rate servers can use it too, its good for the player to know the drops cause they are sometimes distrustfull xD

Link to comment
Share on other sites

  • 9 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...