Advertisement
Nik

Find out why other drops are null

Nik
Sep 12th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.60 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2World-DataPack-HF
  3. Index: data/scripts/handlers/admincommandhandlers/AdminEditNpc.java
  4. ===================================================================
  5. --- data/scripts/handlers/admincommandhandlers/AdminEditNpc.java    (revision 165)
  6. +++ data/scripts/handlers/admincommandhandlers/AdminEditNpc.java    (working copy)
  7. @@ -77,7 +77,8 @@
  8.         "admin_add_skill_npc",
  9.         "admin_edit_skill_npc",
  10.         "admin_del_skill_npc",
  11. -       "admin_log_npc_spawn"
  12. +       "admin_log_npc_spawn",
  13. +       "admin_clone_drop_category"
  14.     };
  15.    
  16.     @Override
  17. @@ -356,6 +357,70 @@
  18.                 activeChar.sendMessage("Usage: //del_skill_npc <npc_id> <skill_id>");
  19.             }
  20.         }
  21. +       else if (command.startsWith("admin_clone_drop_category"))
  22. +       {
  23. +           try
  24. +           {
  25. +               StringTokenizer st = new StringTokenizer(command, " ");
  26. +               st.nextToken();
  27. +               int npcId = Integer.parseInt(st.nextToken());
  28. +               int cloneFromCat = Integer.parseInt(st.nextToken());
  29. +               int clonedCat = Integer.parseInt(st.nextToken());
  30. +              
  31. +               if (cloneFromCat == clonedCat)
  32. +               {
  33. +                   activeChar.sendMessage("<category_to_clone_from> and <cloned_category> must NOT match.");
  34. +                   return false;
  35. +               }
  36. +              
  37. +               //NpcTable.getInstance().reloadNpc(npcId);
  38. +              
  39. +               if (NpcTable.getInstance().getTemplate(npcId) == null)
  40. +               {
  41. +                   activeChar.sendMessage("Template for npcId:"+npcId+" not found.");
  42. +                   return false;
  43. +               }
  44. +              
  45. +               if (NpcTable.getInstance().getTemplate(npcId).getDropData() == null)
  46. +               {
  47. +                   activeChar.sendMessage("DropCategory at template for npcId:"+npcId+" not found.");
  48. +                   return false;
  49. +               }
  50. +              
  51. +               L2DropCategory cat = null;
  52. +               for (L2DropCategory dc : NpcTable.getInstance().getTemplate(npcId).getDropData())
  53. +               {
  54. +                   if (dc.getCategoryType() == cloneFromCat)
  55. +                       cat = dc;
  56. +               }
  57. +              
  58. +               if (cat == null)
  59. +               {
  60. +                   activeChar.sendMessage("<category_to_clone_from> not found.");
  61. +                   return false;
  62. +               }
  63. +              
  64. +               int i = 0;
  65. +               int j = 0;
  66. +               for (L2DropData dd : cat.getAllDrops())
  67. +               {
  68. +                   if (dd == null)
  69. +                   {
  70. +                       j++;
  71. +                       continue;
  72. +                   }
  73. +                   addDropData(activeChar, npcId, dd.getItemId(), dd.getMinDrop(), dd.getMaxDrop(), clonedCat, (int)dd.getChance());
  74. +                   i++;
  75. +               }
  76. +              
  77. +               activeChar.sendMessage(i+" DropData(s) successfuly cloned from category "+cloneFromCat+" to category "+clonedCat+". "+j+" drops were null.");
  78. +           }
  79. +           catch (Exception e)
  80. +           {
  81. +               e.printStackTrace();
  82. +               activeChar.sendMessage("Usage: //clone_drop_category <npc_id> <category_to_clone_from> <cloned_category>");
  83. +           }
  84. +       }
  85.        
  86.         return true;
  87.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement