JVBarbosa

[Hellas]DropEvent

Jun 27th, 2016
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.00 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2JHellasC
  3. Index: java/com/l2jhellas/Config.java
  4. ===================================================================
  5. --- java/com/l2jhellas/Config.java  (revision 519)
  6. +++ java/com/l2jhellas/Config.java  (working copy)
  7. @@ -81,12 +82,16 @@
  8.     private static final String EVENT_RAID_CONFIG_FILE = "./config/Events/Raid.ini";
  9.     private static final String EVENT_WEDDING_CONFIG_FILE = "./config/Events/Wedding.ini";
  10.     // Mods Folder
  11. +   private static final String MOD_OTHERS_CONFIG_FILE = "./config/Mods/Others.ini";
  12.     private static final String MOD_CHAMPIONS_CONFIG_FILE = "./config/Mods/Champions.ini";
  13.     private static final String MOD_L2JHellas_CONFIG_FILE = "./config/Mods/L2JHellas.ini";
  14.     private static final String MOD_RANK_CONFIG_FILE = "./config/Mods/Rank PvP System.ini";
  15.  
  16. @@ -347,6 +352,37 @@
  17.     public static boolean CHAMPION_ENABLE;
  18.  
  19.     /**
  20. +    * Others Mods Config File
  21. +    */
  22. +   // DropEvent
  23. +   public static boolean ENABLE_DROP_EVENT;
  24. +   public static float EVENT_RATE_XP;
  25. +   public static float EVENT_RATE_SP;
  26. +   public static float EVENT_RATE_ADENA;
  27. +   public static float EVENT_RATE_SPOIL;
  28. +
  29. +   /**
  30.      * PvP Config File
  31.      */
  32.     public static boolean REMOVE_BUFFS_ON_DIE;
  33. @@ -1592,6 +1628,76 @@
  34.             CHAMPION_SPCL_LVL_DIFF = Integer.parseInt(ChampionSettings.getProperty("ChampionSpecialItemLevelDiff", "0"));
  35.  
  36.             /**
  37. +            * Others Mods
  38. +            */
  39. +           // EventDrop
  40. +           ENABLE_DROP_EVENT = Boolean.parseBoolean(OthersSettings.getProperty("EnableDropEvent", "true"));
  41. +           EVENT_RATE_XP = Float.parseFloat(OthersSettings.getProperty("EventRateXp", "2.0"));
  42. +           EVENT_RATE_SP = Float.parseFloat(OthersSettings.getProperty("EventRateSp", "2.0"));
  43. +           EVENT_RATE_ADENA = Float.parseFloat(OthersSettings.getProperty("EventRateAdena", "2.0"));
  44. +           EVENT_RATE_SPOIL = Float.parseFloat(OthersSettings.getProperty("EventRateSpoil", "2.0"));
  45. +          
  46. +           /**
  47.              * PvP
  48.              */
  49.             Properties PvPSettings = new Properties();
  50. Index: java/com/l2jhellas/gameserver/custom/DropEvent.java
  51. ===================================================================
  52. --- java/com/l2jhellas/gameserver/custom/DropEvent.java (revision 0)
  53. +++ java/com/l2jhellas/gameserver/custom/DropEvent.java (working copy)
  54. @@ -0,0 +1,95 @@
  55. +package com.l2jhellas.gameserver.custom;
  56. +
  57. +import java.util.Calendar;
  58. +import java.util.Date;
  59. +import java.util.Timer;
  60. +import java.util.TimerTask;
  61. +
  62. +import com.l2jhellas.Config;
  63. +import com.l2jhellas.gameserver.Announcements;
  64. +import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  65. +
  66. +/**
  67. + * @author João Vitor Barbosa
  68. + *
  69. + */
  70. +public class DropEvent {
  71. +
  72. +   private static boolean status;
  73. +   private float rateXp = Config.EVENT_RATE_XP;
  74. +   private float rateSp = Config.EVENT_RATE_SP;
  75. +   private float rateAdena = Config.EVENT_RATE_ADENA;
  76. +   private float rateSpoil = Config.EVENT_RATE_SPOIL;
  77. +   private int[] daysEvent = {1, 6, 7}; // Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7
  78. +   private int delayMinAnnounce = 60; // 60 = 1 hour
  79. +  
  80. +   public void verificationDay() {
  81. +       Calendar c = Calendar.getInstance();
  82. +       c.set(Calendar.HOUR_OF_DAY, 0);
  83. +       c.set(Calendar.MINUTE, 0);
  84. +       c.set(Calendar.SECOND, 0);
  85. +      
  86. +       Date time = c.getTime();
  87. +      
  88. +       Timer timer = new Timer();
  89. +       timer.schedule(new TimerTask() {
  90. +           @Override
  91. +           public void run() {
  92. +               updateStatus();
  93. +               if(status) {
  94. +                   announceEventOn();
  95. +               }
  96. +           }
  97. +       }, time, 24* 60* 60 * 1000);
  98. +   }
  99. +  
  100. +   public void announceEventOn() {
  101. +       Timer timer = new Timer();
  102. +       timer.schedule(new TimerTask() {
  103. +           @Override
  104. +           public void run() {
  105. +               if(status) {
  106. +                   Announcements.getInstance().announceToAll("DropEvent is running!");
  107. +               } else {
  108. +                   timer.cancel();
  109. +               }
  110. +           }
  111. +       }, 0, delayMinAnnounce * 60000);
  112. +   }
  113. +  
  114. +   public void sendMessage(L2PcInstance player) {
  115. +       if(status) {
  116. +           player.sendMessage("DropEvent is running!");
  117. +       }
  118. +   }
  119. +  
  120. +   public int getDayWeek() {
  121. +       return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
  122. +   }
  123. +  
  124. +   public boolean updateStatus() {
  125. +       for(int day : daysEvent) {
  126. +           if(day == getDayWeek()) {
  127. +               return status = true;
  128. +           }
  129. +       }
  130. +       return status = false;
  131. +   }
  132. +  
  133. +   public float getRateXp() {
  134. +       return status ? rateXp : 1;
  135. +   }
  136. +  
  137. +   public float getRateSp() {
  138. +       return status ? rateSp : 1;
  139. +   }
  140. +  
  141. +   public float getRateAdena() {
  142. +       return status ? rateAdena : 1;
  143. +   }
  144. +  
  145. +   public float getRateSpoil() {
  146. +       return status ? rateSpoil : 1;
  147. +   }
  148. +
  149. +}
  150. Index: java/com/l2jhellas/gameserver/model/actor/L2Attackable.java
  151. ===================================================================
  152. --- java/com/l2jhellas/gameserver/model/actor/L2Attackable.java (revision 519)
  153. +++ java/com/l2jhellas/gameserver/model/actor/L2Attackable.java (working copy)
  154. @@ -30,6 +30,7 @@
  155.  import com.l2jhellas.gameserver.ai.L2AttackableAI;
  156.  import com.l2jhellas.gameserver.ai.L2CharacterAI;
  157.  import com.l2jhellas.gameserver.ai.L2SiegeGuardAI;
  158. +import com.l2jhellas.gameserver.custom.DropEvent;
  159.  import com.l2jhellas.gameserver.datatables.sql.ItemTable;
  160.  import com.l2jhellas.gameserver.instancemanager.CursedWeaponsManager;
  161.  import com.l2jhellas.gameserver.model.L2CharPosition;
  162. @@ -1182,10 +1183,11 @@
  163.         }
  164.        
  165.         // Applies Drop rates
  166. +       DropEvent event = new DropEvent();
  167.         if (drop.getItemId() == 57)
  168. -           dropChance *= (lastAttacker.getPremiumService() == 1 ? Config.PREMIUM_RATE_DROP_ADENA : Config.RATE_DROP_ADENA);
  169. +           dropChance *= (lastAttacker.getPremiumService() == 1 ? (Config.PREMIUM_RATE_DROP_ADENA * event.getRateAdena()) : (Config.RATE_DROP_ADENA * event.getRateAdena()));
  170.         else if (isSweep)
  171. -           dropChance *= (lastAttacker.getPremiumService() == 1 ? Config.PREMIUM_RATE_DROP_SPOIL : Config.RATE_DROP_SPOIL);
  172. +           dropChance *= (lastAttacker.getPremiumService() == 1 ? (Config.PREMIUM_RATE_DROP_SPOIL * event.getRateSpoil()) : (Config.RATE_DROP_SPOIL * event.getRateSpoil()));
  173.         else
  174.             if (lastAttacker.getPremiumService() == 1)
  175.                 dropChance *= isRaid() && !isRaidMinion() ? Config.PREMIUM_RATE_DROP_ITEMS_BY_RAID : Config.PREMIUM_RATE_DROP_ITEMS;
  176. Index: java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java
  177. ===================================================================
  178. --- java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (revision 519)
  179. +++ java/com/l2jhellas/gameserver/network/clientpackets/EnterWorld.java (working copy)
  180. @@ -14,10 +14,16 @@
  181.   */
  182.  package com.l2jhellas.gameserver.network.clientpackets;
  183.  
  184.  import com.l2jhellas.gameserver.TaskPriority;
  185. +import com.l2jhellas.gameserver.custom.DropEvent;
  186.  import com.l2jhellas.gameserver.model.actor.instance.L2PcInstance;
  187. +import com.l2jhellas.gameserver.network.serverpackets.CreatureSay;
  188.  
  189.  /**
  190.   * Enter World Packet Handler
  191. @@ -44,9 +50,77 @@
  192.             _log.warning(EnterWorld.class.getName() + ": EnterWorld failed! activeChar is null...");
  193.             getClient().closeNow();
  194.             return;
  195. -       }  
  196. -       activeChar.checks();   
  197. +       }
  198. +      
  199. +       activeChar.checks();
  200. +      
  201. +       DropEvent event = new DropEvent();
  202. +       event.sendMessage(activeChar);
  203.  
  204.     @Override
  205.     public String getType()
  206. Index: config/Mods/Others.ini
  207. ===================================================================
  208. --- config/Mods/Others.ini  (revision 0)
  209. +++ config/Mods/Others.ini  (working copy)
  210. @@ -0,0 +1,63 @@
  211. +#=============================================================
  212. +#             DropEvent - By João Vitor Barbosa
  213. +#=============================================================
  214. +# How to disable only an rate drop? Add 1.0, example: EventRateAdena = 1.0
  215. +EnableDropEvent = true
  216. +EventRateXp = 5.0
  217. +EventRateSp = 5.0
  218. +EventRateAdena = 5.0
  219. +EventRateSpoil = 5.0
  220. \ No newline at end of file
  221. Index: java/com/l2jhellas/gameserver/GameServer.java
  222. ===================================================================
  223. --- java/com/l2jhellas/gameserver/GameServer.java   (revision 519)
  224. +++ java/com/l2jhellas/gameserver/GameServer.java   (working copy)
  225. @@ -43,6 +43,9 @@
  226.  import com.l2jhellas.gameserver.controllers.GameTimeController;
  227.  import com.l2jhellas.gameserver.controllers.RecipeController;
  228.  import com.l2jhellas.gameserver.controllers.TradeController;
  229. +import com.l2jhellas.gameserver.custom.DropEvent;
  230.  import com.l2jhellas.gameserver.datatables.EventDroplist;
  231.  import com.l2jhellas.gameserver.datatables.csv.ExtractableItemsData;
  232.  import com.l2jhellas.gameserver.datatables.sql.BuffTemplateTable;
  233. @@ -373,6 +376,19 @@
  234.         {
  235.             CoupleManager.getInstance();
  236.         }
  237. +      
  238. +       // DropEvent
  239. +       if (Config.ENABLE_DROP_EVENT) {
  240. +           new DropEvent().verificationDay();
  241. +           _log.info("DropEvent loaded");
  242. +       }
  243.  
  244.         IpCatcher.ipsLoad();
  245.         // run garbage collector
  246. Index: java/com/l2jhellas/gameserver/model/actor/L2Npc.java
  247. ===================================================================
  248. --- java/com/l2jhellas/gameserver/model/actor/L2Npc.java    (revision 519)
  249. +++ java/com/l2jhellas/gameserver/model/actor/L2Npc.java    (working copy)
  250. @@ -18,7 +18,6 @@
  251.  
  252.  import java.text.DateFormat;
  253.  import java.util.ArrayList;
  254. -import java.util.Calendar;
  255.  import java.util.List;
  256.  
  257.  import com.l2jhellas.Config;
  258. @@ -27,6 +26,7 @@
  259.  import com.l2jhellas.gameserver.ThreadPoolManager;
  260.  import com.l2jhellas.gameserver.ai.CtrlIntention;
  261.  import com.l2jhellas.gameserver.cache.HtmCache;
  262. +import com.l2jhellas.gameserver.custom.DropEvent;
  263.  import com.l2jhellas.gameserver.datatables.sql.BuffTemplateTable;
  264.  import com.l2jhellas.gameserver.datatables.sql.ClanTable;
  265.  import com.l2jhellas.gameserver.datatables.sql.ItemTable;
  266. @@ -2305,29 +2305,14 @@
  267.         player.sendPacket(ActionFailed.STATIC_PACKET);
  268.     }
  269.  
  270. -   private int Savvato()
  271. -   {
  272. -      return Calendar.SATURDAY;
  273. -   }
  274. -   private int dayofweek()
  275. -   {
  276. -      return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
  277. -   }
  278. -  
  279.     /**
  280.      * Return the Exp Reward of this L2Npc contained in the L2NpcTemplate (modified by RATE_XP).<BR><BR>
  281.      */
  282.     public int getExpReward()
  283.     {
  284.         final double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  285. -       int exp=0;
  286. -      
  287. -        if(Config.ALLOW_SATURDAY_RATE_XP_SP && dayofweek() == Savvato())        
  288. -         exp = (int) (getTemplate().rewardExp * rateXp * Config.SATURDAY_RATE_XP);
  289. -        else
  290. -         exp = (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  291. -        
  292. -        return exp;
  293. +       DropEvent event = new DropEvent();
  294. +       return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP * event.getRateXp());
  295.     }
  296.    
  297.     /**
  298. @@ -2336,14 +2321,8 @@
  299.     public int getSpReward()
  300.     {
  301.         double rateSp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  302. -       int sp=0;
  303. -      
  304. -        if(Config.ALLOW_SATURDAY_RATE_XP_SP && dayofweek() == Savvato())        
  305. -            sp = (int) (getTemplate().rewardSp * rateSp * Config.SATURDAY_RATE_SP);
  306. -        else
  307. -            sp = (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP);
  308. -        
  309. -        return sp;
  310. +       DropEvent event = new DropEvent();
  311. +       return (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP * event.getRateSp());
  312.     }
  313.    
  314.     /**
  315. @@ -2353,10 +2332,11 @@
  316.     public int getExpReward(int isPremium)
  317.     {
  318.         double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  319. +       DropEvent event = new DropEvent();
  320.         if (isPremium == 1)
  321. -           return (int) (getTemplate().rewardExp * rateXp * Config.PREMIUM_RATE_XP);
  322. +           return (int) (getTemplate().rewardExp * rateXp * Config.PREMIUM_RATE_XP * event.getRateXp());
  323.         else
  324. -           return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  325. +           return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP * event.getRateXp());
  326.     }
  327.  
  328.     /**
  329. @@ -2366,10 +2346,11 @@
  330.     public int getSpReward(int isPremium)
  331.     {
  332.         double rateSp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  333. +       DropEvent event = new DropEvent();
  334.         if (isPremium == 1)
  335. -           return (int) (getTemplate().rewardSp * rateSp * Config.PREMIUM_RATE_SP);
  336. +           return (int) (getTemplate().rewardSp * rateSp * Config.PREMIUM_RATE_SP * event.getRateSp());
  337.         else
  338. -           return (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP);
  339. +           return (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP * event.getRateSp());
  340.     }
  341.  
  342.     /**
Add Comment
Please, Sign In to add comment