Advertisement
Bluur

Kill The Mob Event !

Jan 12th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.08 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. Index: java/net/sf/l2j/gameserver/model/KillTheMobEvent.java
  3. ===================================================================
  4. --- java/net/sf/l2j/gameserver/model/KillTheMobEvent.java    (revision 0)
  5. +++ java/net/sf/l2j/gameserver/model/KillTheMobEvent.java    (working copy)
  6. @@ -0,0 +1,84 @@
  7. +/*
  8. + * This program is free software: you can redistribute it and/or modify it under
  9. + * the terms of the GNU General Public License as published by the Free Software
  10. + * Foundation, either version 3 of the License, or (at your option) any later
  11. + * version.
  12. + *
  13. + * This program is distributed in the hope that it will be useful, but WITHOUT
  14. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  16. + * details.
  17. + *
  18. + * You should have received a copy of the GNU General Public License along with
  19. + * this program. If not, see <http://www.gnu.org/licenses/>.
  20. + */
  21. +package net.sf.l2j.gameserver.model;
  22. +
  23. +import net.sf.l2j.Config;
  24. +import net.sf.l2j.gameserver.ThreadPoolManager;
  25. +import net.sf.l2j.gameserver.datatables.NpcTable;
  26. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  27. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  28. +import net.sf.l2j.gameserver.util.Broadcast;
  29. +import net.sf.l2j.util.Rnd;
  30. +
  31. +/**
  32. + * @author Bluur
  33. + * @version 1.1
  34. + *
  35. + */
  36. +public class KillTheMobEvent
  37. +{
  38. +    private static boolean eventEnabled = false;
  39. +    private static int mobSelected;
  40. +
  41. +    protected static void start()
  42. +    {
  43. +        mobSelected = Config.KILL_THE_MOB_MOB_IDS[Rnd.get(Config.KILL_THE_MOB_MOB_IDS.length)];
  44. +        NpcTemplate mob = NpcTable.getInstance().getTemplate(mobSelected);
  45. +        
  46. +        if (mob == null)
  47. +        {
  48. +            System.out.println("[Kill The Mob]: ID incorreto, evento cancelado...");    
  49. +            return;
  50. +        }
  51. +        
  52. +        eventEnabled = true;
  53. +        
  54. +        Broadcast.announceToOnlinePlayers("[Kill The Mob]: The event was started!", true);
  55. +        Broadcast.announceToOnlinePlayers("[Kill The Mob]: Search and kill the " + mob.getName(), true);
  56. +        
  57. +        sleep(Config.KILL_THE_MOB_DURATION_EVENT); //event time        
  58. +        eventEnabled = false;
  59. +        Broadcast.announceToOnlinePlayers("[Kill The Mob]: The event is over!", true);
  60. +    }
  61. +    
  62. +    public static void checkerToReward(int id, L2PcInstance player)
  63. +    {
  64. +        if (id == mobSelected && player.getLevel() >= Config.KILL_THE_MOB_MIN_LEVEL && player.getLevel() <= Config.KILL_THE_MOB_MAX_LEVEL)
  65. +            player.addItem("", Config.KILL_THE_MOB_REWARD_ID, Config.KILL_THE_MOB_REWARD_COUNT, player, true);
  66. +    }
  67. +    
  68. +    public static int getMobSelected()
  69. +    {
  70. +        return mobSelected;
  71. +    }
  72. +    
  73. +    public static boolean isEventEnabled()
  74. +    {
  75. +        return eventEnabled;
  76. +    }
  77. +    
  78. +    public static void init()
  79. +    {
  80. +        ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(new Runnable()
  81. +        {
  82. +            @Override
  83. +            public void run()
  84. +            {
  85. +                start();
  86. +            }
  87. +        }, Config.KILL_THE_MOB_INTERVAL_EVENT*1000*60, Config.KILL_THE_MOB_INTERVAL_EVENT*1000*60);
  88. +    }
  89. +    
  90. +    private static void sleep(int value)
  91. +    {
  92. +        try
  93. +        {
  94. +            Thread.sleep(value * 1000 * 60);
  95. +        }
  96. +        catch (InterruptedException e)
  97. +        {
  98. +            e.printStackTrace();
  99. +        }
  100. +    }
  101. +}
  102. Index: java/net/sf/l2j/gameserver/GameServer.java
  103. ===================================================================
  104. --- java/net/sf/l2j/gameserver/GameServer.java    (revision 1)
  105. +++ java/net/sf/l2j/gameserver/GameServer.java    (working copy)
  106. @@ -93,6 +93,7 @@
  107.  import net.sf.l2j.gameserver.instancemanager.SiegeManager;
  108.  import net.sf.l2j.gameserver.instancemanager.ZoneManager;
  109.  import net.sf.l2j.gameserver.instancemanager.games.MonsterRace;
  110. +import net.sf.l2j.gameserver.model.KillTheMobEvent;
  111.  import net.sf.l2j.gameserver.model.L2Manor;
  112.  import net.sf.l2j.gameserver.model.L2World;
  113.  import net.sf.l2j.gameserver.model.entity.Hero;
  114. @@ -292,6 +293,9 @@
  115.          if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
  116.              FishingChampionshipManager.getInstance();
  117.          
  118. +        if (Config.KILL_THE_MOB_ENABLE)
  119. +            KillTheMobEvent.init();
  120. +        
  121.          Util.printSection("System");
  122.          TaskManager.getInstance();
  123. Index: java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java
  124. ===================================================================
  125. --- java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java    (revision 1)
  126. +++ java/net/sf/l2j/gameserver/network/serverpackets/AbstractNpcInfo.java    (working copy)
  127. @@ -16,6 +16,7 @@
  128.  
  129.  import net.sf.l2j.Config;
  130.  import net.sf.l2j.gameserver.datatables.ClanTable;
  131. +import net.sf.l2j.gameserver.model.KillTheMobEvent;
  132.  import net.sf.l2j.gameserver.model.L2Clan;
  133.  import net.sf.l2j.gameserver.model.actor.L2Character;
  134.  import net.sf.l2j.gameserver.model.actor.L2Npc;
  135. @@ -78,6 +79,8 @@
  136.              
  137.              if (_npc.isChampion())
  138.                  _title = ("Champion");
  139. +            else if (KillTheMobEvent.isEventEnabled() && _npc.getNpcId() == KillTheMobEvent.getMobSelected())
  140. +                _title = (Config.KILL_THE_MOB_TITLE);
  141.              else if (_npc.getTemplate().isCustomNpc())
  142.                  _title = _npc.getTemplate().getTitle();
  143.              else
  144. Index: java/net/sf/l2j/Config.java
  145. ===================================================================
  146. --- java/net/sf/l2j/Config.java    (revision 1)
  147. +++ java/net/sf/l2j/Config.java    (working copy)
  148. @@ -226,6 +226,31 @@
  149.      public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
  150.      public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
  151.      
  152. +    /** Kill The Mob */
  153. +    public static boolean KILL_THE_MOB_ENABLE;
  154. +    public static String KILL_THE_MOB_MOB_IDS_LIST;
  155. +    public static int[] KILL_THE_MOB_MOB_IDS;
  156. +    public static String KILL_THE_MOB_TITLE;
  157. +    public static int KILL_THE_MOB_MIN_LEVEL;
  158. +    public static int KILL_THE_MOB_MAX_LEVEL;
  159. +    public static int KILL_THE_MOB_REWARD_ID;
  160. +    public static int KILL_THE_MOB_REWARD_COUNT;
  161. +    public static int KILL_THE_MOB_DURATION_EVENT;
  162. +    public static int KILL_THE_MOB_INTERVAL_EVENT;
  163. +    
  164.    
  165.      // --------------------------------------------------
  166.      // HexID
  167.      // --------------------------------------------------
  168. @@ -879,6 +904,28 @@
  169.              ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
  170.              ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
  171.              
  172. +            KILL_THE_MOB_ENABLE = events.getProperty("KillTheMobEnable", false);
  173. +            KILL_THE_MOB_INTERVAL_EVENT = events.getProperty("KillTheMobIntervalEvent", 60);
  174. +            KILL_THE_MOB_DURATION_EVENT = events.getProperty("KillTheMobDurationEvent", 10);            
  175. +            KILL_THE_MOB_MOB_IDS_LIST = events.getProperty("KillTheMobListID", "20941,20940");            
  176. +            KILL_THE_MOB_TITLE = events.getProperty("KillTheMobTitle", "");
  177. +            KILL_THE_MOB_MIN_LEVEL = events.getProperty("KillTheMobMinLevelPlayer", 20);
  178. +            KILL_THE_MOB_MAX_LEVEL = events.getProperty("KillTheMobMaxLevelPlayer", 80);
  179. +            KILL_THE_MOB_REWARD_ID = events.getProperty("KillTheMobRewardID", 57);
  180. +            KILL_THE_MOB_REWARD_COUNT = events.getProperty("KillTheMobRewardCount", 100);        
  181. +            String[] mobsList = KILL_THE_MOB_MOB_IDS_LIST.split(",");
  182. +            KILL_THE_MOB_MOB_IDS = new int[mobsList.length];
  183. +            for (int i = 0; i < mobsList.length; i++)
  184. +                KILL_THE_MOB_MOB_IDS[i] = Integer.parseInt(mobsList[i]);
  185. +            
  186.              // FloodProtector
  187.              ExProperties security = load(FLOOD_PROTECTOR_FILE);
  188.              loadFloodProtectorConfig(security, FLOOD_PROTECTOR_ROLL_DICE, "RollDice", "42");
  189. Index: config/events.properties
  190. ===================================================================
  191. --- config/events.properties    (revision 1)
  192. +++ config/events.properties    (working copy)
  193. @@ -251,4 +251,26 @@
  194.  AltFishChampionshipReward2 = 500000
  195.  AltFishChampionshipReward3 = 300000
  196.  AltFishChampionshipReward4 = 200000
  197. -AltFishChampionshipReward5 = 100000
  198. \ No newline at end of file
  199. +AltFishChampionshipReward5 = 100000
  200. +
  201. +#=============================================================
  202. +#                           Kill The Mob
  203. +#=============================================================
  204. +# Enable event?
  205. +KillTheMobEnable = False
  206. +# Event interval in minutes
  207. +KillTheMobIntervalEvent = 10
  208. +# Event duration in minutes
  209. +KillTheMobDurationEvent = 5
  210. +# List of ID random
  211. +KillTheMobListID = 20938,20939,20941,20940
  212. +# Mob title to be killed
  213. +KillTheMobTitle = [Kill The Mob]
  214. +# Minimum player level
  215. +KillTheMobMinLevelPlayer = 20
  216. +# Maximum player level
  217. +KillTheMobMaxLevelPlayer = 80
  218. +# Reward item_ID
  219. +KillTheMobRewardID = 6393
  220. +# Reward item_count
  221. +KillTheMobRewardCount = 1
  222. Index: java/net/sf/l2j/gameserver/model/actor/L2Attackable.java
  223. ===================================================================
  224. --- java/net/sf/l2j/gameserver/model/actor/L2Attackable.java    (revision 1)
  225. +++ java/net/sf/l2j/gameserver/model/actor/L2Attackable.java    (working copy)
  226. @@ -30,6 +30,7 @@
  227.  import net.sf.l2j.gameserver.datatables.HerbDropTable;
  228.  import net.sf.l2j.gameserver.datatables.ItemTable;
  229.  import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;
  230. +import net.sf.l2j.gameserver.model.KillTheMobEvent;
  231.  import net.sf.l2j.gameserver.model.L2CharPosition;
  232.  import net.sf.l2j.gameserver.model.L2CommandChannel;
  233.  import net.sf.l2j.gameserver.model.L2Manor;
  234. @@ -1312,6 +1313,9 @@
  235.              }
  236.          }
  237.          
  238. +        if (KillTheMobEvent.isEventEnabled())        
  239. +            KillTheMobEvent.checkerToReward(getNpcId(), player);
  240. +        
  241.          // Apply special item drop for champions.
  242.          if (isChampion() && Config.CHAMPION_REWARD > 0)
  243.          {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement