Advertisement
Guest User

droplist_panel

a guest
Jun 11th, 2019
2,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.59 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_datapack
  3. Index: data/html/droplist.htm
  4. ===================================================================
  5. --- data/html/droplist.htm  (revision 0)
  6. +++ data/html/droplist.htm  (working copy)
  7. @@ -0,0 +1,5 @@
  8. +<html><title>Droplist : %name%</title><body><img height=14>
  9. +<font color=B09878>* NOTE : Uncheck to ignore specific drop.</font>
  10. +<img src=L2UI.SquareGray width=280 height=1>
  11. +%list%
  12. +</body></html>
  13. \ No newline at end of file
  14. #P aCis_gameserver
  15. Index: java/net/sf/l2j/gameserver/model/actor/Npc.java
  16. ===================================================================
  17. --- java/net/sf/l2j/gameserver/model/actor/Npc.java (revision 7)
  18. +++ java/net/sf/l2j/gameserver/model/actor/Npc.java (working copy)
  19. @@ -1,7 +1,9 @@
  20.  package net.sf.l2j.gameserver.model.actor;
  21.  
  22. +import java.text.DecimalFormat;
  23.  import java.util.ArrayList;
  24.  import java.util.Arrays;
  25. +import java.util.Collections;
  26.  import java.util.List;
  27.  
  28.  import net.sf.l2j.commons.concurrent.ThreadPool;
  29. @@ -14,6 +16,7 @@
  30.  import net.sf.l2j.gameserver.data.cache.HtmCache;
  31.  import net.sf.l2j.gameserver.data.sql.ClanTable;
  32.  import net.sf.l2j.gameserver.data.xml.MultisellData;
  33. +import net.sf.l2j.gameserver.data.xml.NpcData;
  34.  import net.sf.l2j.gameserver.data.xml.ScriptData;
  35.  import net.sf.l2j.gameserver.enums.IntentionType;
  36.  import net.sf.l2j.gameserver.enums.ScriptEventType;
  37. @@ -21,8 +24,11 @@
  38.  import net.sf.l2j.gameserver.geoengine.GeoEngine;
  39.  import net.sf.l2j.gameserver.model.L2Skill;
  40.  import net.sf.l2j.gameserver.model.WorldObject;
  41. +import net.sf.l2j.gameserver.model.actor.instance.Chest;
  42. +import net.sf.l2j.gameserver.model.actor.instance.GrandBoss;
  43.  import net.sf.l2j.gameserver.model.actor.instance.Merchant;
  44.  import net.sf.l2j.gameserver.model.actor.instance.Monster;
  45. +import net.sf.l2j.gameserver.model.actor.instance.RaidBoss;
  46.  import net.sf.l2j.gameserver.model.actor.stat.NpcStat;
  47.  import net.sf.l2j.gameserver.model.actor.status.NpcStatus;
  48.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  49. @@ -30,6 +36,8 @@
  50.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate.Race;
  51.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate.SkillType;
  52.  import net.sf.l2j.gameserver.model.entity.Castle;
  53. +import net.sf.l2j.gameserver.model.item.DropCategory;
  54. +import net.sf.l2j.gameserver.model.item.DropData;
  55.  import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  56.  import net.sf.l2j.gameserver.model.item.kind.Item;
  57.  import net.sf.l2j.gameserver.model.item.kind.Weapon;
  58. @@ -231,6 +239,8 @@
  59.         // Check if the Player is a GM ; send him NPC infos if true.
  60.         if (player.isGM())
  61.             sendNpcInfos(player);
  62. +       else if (this instanceof Monster || this instanceof RaidBoss || this instanceof GrandBoss || this instanceof Chest)
  63. +           sendNpcDrop(player, getTemplate().getNpcId(), 1);
  64.        
  65.         if (player.getTarget() != this)
  66.             player.setTarget(this);
  67. @@ -771,6 +781,109 @@
  68.         player.sendPacket(html);
  69.     }
  70.    
  71. +   public static void sendNpcDrop(Player player, int npcId, int page)
  72. +   {
  73. +       final int ITEMS_PER_LIST = 7;
  74. +       final NpcTemplate npc = NpcData.getInstance().getTemplate(npcId);
  75. +       if (npc == null)
  76. +           return;
  77. +      
  78. +       if (npc.getDropData().isEmpty())
  79. +       {
  80. +           player.sendMessage("This target have not drop info.");
  81. +           return;
  82. +       }
  83. +      
  84. +       final List<DropCategory> list = new ArrayList<>();
  85. +       npc.getDropData().forEach(c -> list.add(c));
  86. +       Collections.reverse(list);
  87. +      
  88. +       int myPage = 1;
  89. +       int i = 0;
  90. +       int shown = 0;
  91. +       boolean hasMore = false;
  92. +      
  93. +       final StringBuilder sb = new StringBuilder();
  94. +       for (DropCategory cat : list)
  95. +       {
  96. +           if (shown == ITEMS_PER_LIST)
  97. +           {
  98. +               hasMore = true;
  99. +               break;
  100. +           }
  101. +          
  102. +           for (DropData drop : cat.getAllDrops())
  103. +           {
  104. +               double chance = (drop.getItemId() == 57 ? drop.getChance() * Config.RATE_DROP_ADENA : drop.getChance() * Config.RATE_DROP_ITEMS) / 10000;
  105. +               chance = chance > 100 ? 100 : chance;
  106. +              
  107. +               String percent = null;
  108. +               if (chance <= 0.001)
  109. +               {
  110. +                   DecimalFormat df = new DecimalFormat("#.####");
  111. +                   percent = df.format(chance);
  112. +               }
  113. +               else if (chance <= 0.01)
  114. +               {
  115. +                   DecimalFormat df = new DecimalFormat("#.###");
  116. +                   percent = df.format(chance);
  117. +               }
  118. +               else
  119. +               {
  120. +                   DecimalFormat df = new DecimalFormat("##.##");
  121. +                   percent = df.format(chance);
  122. +               }
  123. +              
  124. +               Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
  125. +               String name = item.getName();
  126. +              
  127. +               if (name.startsWith("Recipe: "))
  128. +                   name = "R: " + name.substring(8);
  129. +              
  130. +               if (name.length() >= 40)
  131. +                   name = name.substring(0, 37) + "...";
  132. +              
  133. +               if (myPage != page)
  134. +               {
  135. +                   i++;
  136. +                   if (i == ITEMS_PER_LIST)
  137. +                   {
  138. +                       myPage++;
  139. +                       i = 0;
  140. +                   }
  141. +                   continue;
  142. +               }
  143. +              
  144. +               if (shown == ITEMS_PER_LIST)
  145. +               {
  146. +                   hasMore = true;
  147. +                   break;
  148. +               }
  149. +              
  150. +               String check = player.ignoredDropContain(item.getItemId()) ? "L2UI.CheckBox" : "L2UI.CheckBox_checked";
  151. +               sb.append("<table width=280 bgcolor=000000><tr>");
  152. +               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=" + item.getIcon() + " fore=" + item.getIcon() + "></td></tr></table></td>");
  153. +               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>");
  154. +               sb.append("<td width=20><button action=\"bypass droplist " + npcId + " " + page + " " + item.getItemId() + "\" width=12 height=12 back=\"" + check + "\" fore=\"" + check + "\"/></td>");
  155. +               sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
  156. +               shown++;
  157. +           }
  158. +       }
  159. +       sb.append("<img height=" + (294 - (shown * 42)) + ">");
  160. +       sb.append("<img height=8><img src=L2UI.SquareGray width=280 height=1>");
  161. +       sb.append("<table width=280 bgcolor=000000><tr>");
  162. +       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>");
  163. +       sb.append("<td align=center width=140>Page " + page + "</td>");
  164. +       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>");
  165. +       sb.append("</tr></table><img src=L2UI.SquareGray width=280 height=1>");
  166. +      
  167. +       final NpcHtmlMessage html = new NpcHtmlMessage(200);
  168. +       html.setFile("data/html/droplist.htm");
  169. +       html.replace("%list%", sb.toString());
  170. +       html.replace("%name%", npc.getName());
  171. +       player.sendPacket(html);
  172. +   }
  173. +  
  174.     /**
  175.      * Open a quest or chat window on client with the text of this {@link Npc} in function of the command.
  176.      * @param player :The player to test.
  177. Index: java/net/sf/l2j/gameserver/model/actor/Player.java
  178. ===================================================================
  179. --- java/net/sf/l2j/gameserver/model/actor/Player.java  (revision 9)
  180. +++ java/net/sf/l2j/gameserver/model/actor/Player.java  (working copy)
  181. @@ -474,6 +474,8 @@
  182.    
  183.     private Door _requestedGate;
  184.    
  185. +   private List<Integer> _ignored = new ArrayList<>();
  186. +  
  187.     /**
  188.      * Constructor of Player (use Creature constructor).
  189.      * <ul>
  190. @@ -8683,6 +8685,19 @@
  191.         _requestedGate = door;
  192.     }
  193.    
  194. +   public void ignored(Integer itemId)
  195. +   {
  196. +       if (_ignored.contains(itemId))
  197. +           _ignored.remove(itemId);
  198. +       else
  199. +           _ignored.add(itemId);
  200. +   }
  201. +  
  202. +   public boolean ignoredDropContain(int itemId)
  203. +   {
  204. +       return _ignored.contains(itemId);
  205. +   }
  206. +  
  207.     @Override
  208.     public boolean polymorph(PolyType type, int npcId)
  209.     {
  210. Index: java/net/sf/l2j/gameserver/model/actor/instance/Monster.java
  211. ===================================================================
  212. --- java/net/sf/l2j/gameserver/model/actor/instance/Monster.java    (revision 7)
  213. +++ java/net/sf/l2j/gameserver/model/actor/instance/Monster.java    (working copy)
  214. @@ -1108,7 +1108,7 @@
  215.                     for (DropData drop : cat.getAllDrops())
  216.                     {
  217.                         item = calculateRewardItem(drop, levelModifier, true);
  218. -                       if (item == null)
  219. +                       if (item == null || player.ignoredDropContain(item.getId()))
  220.                             continue;
  221.                        
  222.                         _sweepItems.add(item);
  223. @@ -1130,6 +1130,9 @@
  224.                
  225.                 if (item != null)
  226.                 {
  227. +                   if (player.ignoredDropContain(item.getId()))
  228. +                       continue;
  229. +                  
  230.                     // Check if the autoLoot mode is active
  231.                     if ((isRaidBoss() && Config.AUTO_LOOT_RAID) || (!isRaidBoss() && Config.AUTO_LOOT))
  232.                         player.doAutoLoot(this, item);
  233.  
  234. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  235. ===================================================================
  236. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 9)
  237. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  238. @@ -137,5 +137,18 @@
  239.             final int arenaId = Integer.parseInt(_command.substring(12).trim());
  240.             player.enterOlympiadObserverMode(arenaId);
  241.         }
  242. +       else if (_command.startsWith("droplist"))
  243. +       {
  244. +           StringTokenizer st = new StringTokenizer(_command, " ");
  245. +           st.nextToken();
  246. +          
  247. +           int npcId = Integer.parseInt(st.nextToken());
  248. +           int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 1;
  249. +          
  250. +           if (st.hasMoreTokens())
  251. +               player.ignored(Integer.parseInt(st.nextToken()));
  252. +          
  253. +           Npc.sendNpcDrop(player, npcId, page);
  254. +       }
  255.     }
  256.  }
  257. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement