SHOW:
|
|
- or go back to the newest paste.
1 | ============================================= | |
2 | Index: RequestBypassToServer | |
3 | ||
4 | + else if (_command.startsWith("droplist")) | |
5 | + { | |
6 | + StringTokenizer st = new StringTokenizer(_command, " "); | |
7 | + st.nextToken(); | |
8 | + | |
9 | + int npcId = Integer.parseInt(st.nextToken()); | |
10 | + int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1; | |
11 | + | |
12 | + if (st.hasMoreTokens()) | |
13 | + activeChar.ignored(Integer.parseInt(st.nextToken())); | |
14 | + | |
15 | + L2Npc.sendNpcDrop(activeChar, npcId, page); | |
16 | + } | |
17 | ||
18 | ============================================= | |
19 | Index: L2Npc | |
20 | ||
21 | + public static void sendNpcDrop(Player player, int npcId, int page) | |
22 | + { | |
23 | + final int ITEMS_PER_LIST = 7; | |
24 | + final NpcTemplate npc = NpcTable.getInstance().getTemplate(npcId); | |
25 | + if (npc == null) | |
26 | + return; | |
27 | + | |
28 | + if (npc.getDropData().isEmpty()) | |
29 | + { | |
30 | + player.sendMessage("This target have not drop info."); | |
31 | + return; | |
32 | + } | |
33 | + | |
34 | + final List<DropCategory> list = new ArrayList<>(); | |
35 | + npc.getDropData().forEach(c -> list.add(c)); | |
36 | + Collections.reverse(list); | |
37 | + | |
38 | + int myPage = 1; | |
39 | + int i = 0; | |
40 | + int shown = 0; | |
41 | + boolean hasMore = false; | |
42 | + | |
43 | + final StringBuilder sb = new StringBuilder(); | |
44 | + for (DropCategory cat : list) | |
45 | + { | |
46 | + if (shown == ITEMS_PER_LIST) | |
47 | + { | |
48 | + hasMore = true; | |
49 | + break; | |
50 | + } | |
51 | + | |
52 | + for (DropData drop : cat.getAllDrops()) | |
53 | + { | |
54 | + double chance = (drop.getItemId() == 57 ? drop.getChance() * Config.RATE_DROP_ADENA : drop.getChance() * Config.RATE_DROP_ITEMS) / 10000; | |
55 | + chance = chance > 100 ? 100 : chance; | |
56 | + | |
57 | + String percent = null; | |
58 | + if (chance <= 0.001) | |
59 | + { | |
60 | + DecimalFormat df = new DecimalFormat("#.####"); | |
61 | + percent = df.format(chance); | |
62 | + } | |
63 | + else if (chance <= 0.01) | |
64 | + { | |
65 | + DecimalFormat df = new DecimalFormat("#.###"); | |
66 | + percent = df.format(chance); | |
67 | + } | |
68 | + else | |
69 | + { | |
70 | + DecimalFormat df = new DecimalFormat("##.##"); | |
71 | + percent = df.format(chance); | |
72 | + } | |
73 | + | |
74 | + Item item = ItemTable.getInstance().getTemplate(drop.getItemId()); | |
75 | + String name = item.getName(); | |
76 | + | |
77 | + if (name.startsWith("Recipe: ")) | |
78 | + name = "R: " + name.substring(8); | |
79 | + | |
80 | + if (name.length() >= 40) | |
81 | + name = name.substring(0, 37) + "..."; | |
82 | + | |
83 | + if (myPage != page) | |
84 | + { | |
85 | + i++; | |
86 | + if (i == ITEMS_PER_LIST) | |
87 | + { | |
88 | + myPage++; | |
89 | + i = 0; | |
90 | + } | |
91 | + continue; | |
92 | + } | |
93 | + | |
94 | + if (shown == ITEMS_PER_LIST) | |
95 | + { | |
96 | + hasMore = true; | |
97 | + break; | |
98 | + } | |
99 | + | |
100 | + String check = player.ignoredDropContain(item.getItemId()) ? "L2UI.CheckBox" : "L2UI.CheckBox_checked"; | |
101 | + sb.append("<table width=280 bgcolor=000000><tr>"); | |
102 | + sb.append("<td width=44 height=41 align=center><table bgcolor=" + (cat.isSweep() ? "FF00FF" : "FFFFFF") + " cellpadding=6 cellspacing=\"-5\"><tr><td><button width=32 height=32 back=" +IconTable.getIcon(item.getItemId())+ " fore=" +IconTable.getIcon(item.getItemId())+ "></td></tr></table></td>"); | |
103 | + sb.append("<td width=240>" + (cat.isSweep() ? "<font color=ff00ff>" + name + "</font>" : name) + "<br1><font color=B09878>" + (cat.isSweep() ? "Spoil" : "Drop") + " Chance : " + percent + "%</font></td>"); | |
104 | + sb.append("<td width=20><button action=\"bypass droplist " + npcId + " " + page + " " + item.getItemId() + "\" width=12 height=12 back=\"" + check + "\" fore=\"" + check + "\"/></td>"); | |
105 | + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>"); | |
106 | + shown++; | |
107 | + } | |
108 | + } | |
109 | + sb.append("<img height=" + (294 - (shown * 42)) + ">"); | |
110 | + sb.append("<img height=8><img src=L2UI.SquareGray width=280 height=1>"); | |
111 | + sb.append("<table width=280 bgcolor=000000><tr>"); | |
112 | + sb.append("<td align=center width=70>" + (page > 1 ? "<button value=\"< PREV\" action=\"bypass droplist " + npcId + " " + (page - 1) + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>"); | |
113 | + sb.append("<td align=center width=140>Page " + page + "</td>"); | |
114 | + sb.append("<td align=center width=70>" + (hasMore ? "<button value=\"NEXT >\" action=\"bypass droplist " + npcId + " " + (page + 1) + "\" width=65 height=19 back=L2UI_ch3.smallbutton2_over fore=L2UI_ch3.smallbutton2>" : "") + "</td>"); | |
115 | + sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>"); | |
116 | + | |
117 | + final NpcHtmlMessage html = new NpcHtmlMessage(200); | |
118 | + html.setFile("data/html/droplist.htm"); | |
119 | + html.replace("%list%", sb.toString()); | |
120 | + html.replace("%name%", npc.getName()); | |
121 | + player.sendPacket(html); | |
122 | + } | |
123 | ||
124 | ||
125 | @Override | |
126 | public void onActionShift(Player player) | |
127 | { | |
128 | ||
129 | ||
130 | +else if (this instanceof L2MonsterInstance || this instanceof L2RaidBossInstance || this instanceof L2GrandBossInstance || this instanceof L2ChestInstance) | |
131 | +sendNpcDrop(player, getTemplate().getNpcId(), 1); | |
132 | ||
133 | ||
134 | if (player.getTarget() != this) | |
135 | { | |
136 | // Set the target of the Player player | |
137 | player.setTarget(this); | |
138 | ||
139 | =============================================== | |
140 | Index: data/html/droplist.htm | |
141 | ||
142 | +<html><title>Droplist : %name%</title><body><img height=14> | |
143 | +<font color=B09878>* NOTE : Uncheck to ignore specific drop.</font> | |
144 | +<img src=L2UI.SquareGray width=280 height=1> | |
145 | +%list% | |
146 | +</body></html> |