JVBarbosa

[Frozen]DropEvent

Jun 27th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.55 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jFrozen_GameServer
  3. Index: head-src/com/l2jfrozen/gameserver/custom/DropEvent.java
  4. ===================================================================
  5. --- head-src/com/l2jfrozen/gameserver/custom/DropEvent.java (revision 0)
  6. +++ head-src/com/l2jfrozen/gameserver/custom/DropEvent.java (working copy)
  7. @@ -0,0 +1,95 @@
  8. +package com.l2jfrozen.gameserver.custom;
  9. +
  10. +import java.util.Calendar;
  11. +import java.util.Date;
  12. +import java.util.Timer;
  13. +import java.util.TimerTask;
  14. +
  15. +import com.l2jfrozen.Config;
  16. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  17. +import com.l2jfrozen.gameserver.model.entity.Announcements;
  18. +
  19. +/**
  20. + * @author João Vitor Barbosa
  21. + *
  22. + */
  23. +public class DropEvent {
  24. +
  25. +   private static boolean status;
  26. +   private float rateXp = Config.EVENT_RATE_XP;
  27. +   private float rateSp = Config.EVENT_RATE_SP;
  28. +   private float rateAdena = Config.EVENT_RATE_ADENA;
  29. +   private float rateSpoil = Config.EVENT_RATE_SPOIL;
  30. +   private int[] daysEvent = {1, 6, 7}; // Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7
  31. +   private int delayMinAnnounce = 60; // 60 = 1 hour
  32. +  
  33. +   public void verificationDay() {
  34. +       Calendar c = Calendar.getInstance();
  35. +       c.set(Calendar.HOUR_OF_DAY, 0);
  36. +       c.set(Calendar.MINUTE, 0);
  37. +       c.set(Calendar.SECOND, 0);
  38. +      
  39. +       Date time = c.getTime();
  40. +      
  41. +       Timer timer = new Timer();
  42. +       timer.schedule(new TimerTask() {
  43. +           @Override
  44. +           public void run() {
  45. +               updateStatus();
  46. +               if(status) {
  47. +                   announceEventOn();
  48. +               }
  49. +           }
  50. +       }, time, 24* 60* 60 * 1000);
  51. +   }
  52. +  
  53. +   public void announceEventOn() {
  54. +       final Timer timer = new Timer();
  55. +       timer.schedule(new TimerTask() {
  56. +           @Override
  57. +           public void run() {
  58. +               if(status) {
  59. +                   Announcements.getInstance().gameAnnounceToAll("DropEvent is running!");
  60. +               } else {
  61. +                   timer.cancel();
  62. +               }
  63. +           }
  64. +       }, 0, delayMinAnnounce * 60000);
  65. +   }
  66. +  
  67. +   public void sendMessage(L2PcInstance player) {
  68. +       if(status) {
  69. +           player.sendMessage("DropEvent is running!");
  70. +       }
  71. +   }
  72. +  
  73. +   public int getDayWeek() {
  74. +       return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
  75. +   }
  76. +  
  77. +   public boolean updateStatus() {
  78. +       for(int day : daysEvent) {
  79. +           if(day == getDayWeek()) {
  80. +               return status = true;
  81. +           }
  82. +       }
  83. +       return status = false;
  84. +   }
  85. +  
  86. +   public float getRateXp() {
  87. +       return status ? rateXp : 1;
  88. +   }
  89. +  
  90. +   public float getRateSp() {
  91. +       return status ? rateSp : 1;
  92. +   }
  93. +  
  94. +   public float getRateAdena() {
  95. +       return status ? rateAdena : 1;
  96. +   }
  97. +  
  98. +   public float getRateSpoil() {
  99. +       return status ? rateSpoil : 1;
  100. +   }
  101. +
  102. +}
  103. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java
  104. ===================================================================
  105. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java   (revision 1118)
  106. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2NpcInstance.java   (working copy)
  107. @@ -33,6 +33,7 @@
  108.  import com.l2jfrozen.Config;
  109.  import com.l2jfrozen.gameserver.ai.CtrlIntention;
  110.  import com.l2jfrozen.gameserver.cache.HtmCache;
  111. +import com.l2jfrozen.gameserver.custom.DropEvent;
  112.  import com.l2jfrozen.gameserver.datatables.MobGroupTable;
  113.  import com.l2jfrozen.gameserver.datatables.SkillTable;
  114.  import com.l2jfrozen.gameserver.datatables.sql.ClanTable;
  115. @@ -3023,7 +3024,8 @@
  116.     public int getExpReward()
  117.     {
  118.         final double rateXp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  119. -       return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP);
  120. +       DropEvent event = new DropEvent();
  121. +       return (int) (getTemplate().rewardExp * rateXp * Config.RATE_XP * event.getRateXp());
  122.     }
  123.    
  124.     /**
  125. @@ -3034,7 +3036,8 @@
  126.     public int getSpReward()
  127.     {
  128.         final double rateSp = getStat().calcStat(Stats.MAX_HP, 1, this, null);
  129. -       return (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP);
  130. +       DropEvent event = new DropEvent();
  131. +       return (int) (getTemplate().rewardSp * rateSp * Config.RATE_SP * event.getRateSp());
  132.     }
  133.    
  134.     /**
  135. Index: head-src/com/l2jfrozen/gameserver/model/L2Attackable.java
  136. ===================================================================
  137. --- head-src/com/l2jfrozen/gameserver/model/L2Attackable.java   (revision 1118)
  138. +++ head-src/com/l2jfrozen/gameserver/model/L2Attackable.java   (working copy)
  139. @@ -32,6 +32,7 @@
  140.  import com.l2jfrozen.gameserver.ai.L2CharacterAI;
  141.  import com.l2jfrozen.gameserver.ai.L2FortSiegeGuardAI;
  142.  import com.l2jfrozen.gameserver.ai.L2SiegeGuardAI;
  143. +import com.l2jfrozen.gameserver.custom.DropEvent;
  144.  import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
  145.  import com.l2jfrozen.gameserver.managers.CursedWeaponsManager;
  146.  import com.l2jfrozen.gameserver.model.actor.instance.L2DoorInstance;
  147. @@ -1339,6 +1340,9 @@
  148.                 {
  149.                     dropChance *= Config.DONATOR_ADENA_RATE;
  150.                 }
  151. +              
  152. +               DropEvent event = new DropEvent();
  153. +               dropChance *= event.getRateAdena();
  154.             }
  155.            
  156.         }
  157. @@ -1364,6 +1368,9 @@
  158.                 {
  159.                     dropChance *= Config.DONATOR_SPOIL_RATE;
  160.                 }
  161. +              
  162. +               DropEvent event = new DropEvent();
  163. +               dropChance *= event.getRateSpoil();
  164.             }
  165.         }
  166.         else
  167. Index: head-src/com/l2jfrozen/Config.java
  168. ===================================================================
  169. --- head-src/com/l2jfrozen/Config.java  (revision 1118)
  170. +++ head-src/com/l2jfrozen/Config.java  (working copy)
  171. @@ -2428,6 +2428,13 @@
  172.     public static String PVP1_CUSTOM_MESSAGE;
  173.     public static String PVP2_CUSTOM_MESSAGE;
  174.    
  175. +   // DropEvent
  176. +   public static boolean ENABLE_DROP_EVENT;
  177. +   public static float EVENT_RATE_XP;
  178. +   public static float EVENT_RATE_SP;
  179. +   public static float EVENT_RATE_ADENA;
  180. +   public static float EVENT_RATE_SPOIL;
  181. +  
  182.     // ============================================================
  183.     public static void loadL2JFrozenConfig()
  184.     {
  185. @@ -2546,6 +2553,13 @@
  186.             FARM2_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("Farm2CustomMeesage", "You have been teleported to Farm Zone 2!");
  187.             PVP1_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP1CustomMeesage", "You have been teleported to PvP Zone 1!");
  188.             PVP2_CUSTOM_MESSAGE = L2JFrozenSettings.getProperty("PvP2CustomMeesage", "You have been teleported to PvP Zone 2!");
  189. +          
  190. +           // EventDrop
  191. +           ENABLE_DROP_EVENT = Boolean.parseBoolean(L2JFrozenSettings.getProperty("EnableDropEvent", "true"));
  192. +           EVENT_RATE_XP = Float.parseFloat(L2JFrozenSettings.getProperty("EventRateXp", "2.0"));
  193. +           EVENT_RATE_SP = Float.parseFloat(L2JFrozenSettings.getProperty("EventRateSp", "2.0"));
  194. +           EVENT_RATE_ADENA = Float.parseFloat(L2JFrozenSettings.getProperty("EventRateAdena", "2.0"));
  195. +           EVENT_RATE_SPOIL = Float.parseFloat(L2JFrozenSettings.getProperty("EventRateSpoil", "2.0"));
  196.         }
  197.         catch (final Exception e)
  198.         {
  199. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java
  200. ===================================================================
  201. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (revision 1118)
  202. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/EnterWorld.java (working copy)
  203. @@ -31,6 +31,7 @@
  204.  import com.l2jfrozen.crypt.nProtect.RestrictionType;
  205.  import com.l2jfrozen.gameserver.communitybbs.Manager.RegionBBSManager;
  206.  import com.l2jfrozen.gameserver.controllers.GameTimeController;
  207. +import com.l2jfrozen.gameserver.custom.DropEvent;
  208.  import com.l2jfrozen.gameserver.datatables.CharSchemesTable;
  209.  import com.l2jfrozen.gameserver.datatables.GmListTable;
  210.  import com.l2jfrozen.gameserver.datatables.SkillTable;
  211. @@ -256,6 +257,9 @@
  212.             }
  213.         }
  214.        
  215. +       DropEvent event = new DropEvent();
  216. +       event.sendMessage(activeChar);
  217. +      
  218.         // Restores custom status
  219.         activeChar.restoreCustomStatus();
  220.        
  221. Index: head-src/com/l2jfrozen/gameserver/GameServer.java
  222. ===================================================================
  223. --- head-src/com/l2jfrozen/gameserver/GameServer.java   (revision 1118)
  224. +++ head-src/com/l2jfrozen/gameserver/GameServer.java   (working copy)
  225. @@ -44,6 +44,7 @@
  226.  import com.l2jfrozen.gameserver.controllers.GameTimeController;
  227.  import com.l2jfrozen.gameserver.controllers.RecipeController;
  228.  import com.l2jfrozen.gameserver.controllers.TradeController;
  229. +import com.l2jfrozen.gameserver.custom.DropEvent;
  230.  import com.l2jfrozen.gameserver.datatables.GmListTable;
  231.  import com.l2jfrozen.gameserver.datatables.HeroSkillTable;
  232.  import com.l2jfrozen.gameserver.datatables.NobleSkillTable;
  233. @@ -541,6 +542,11 @@
  234.         }
  235.        
  236.         Util.printSection("Custom Mods");
  237. +       // DropEvent
  238. +       if (Config.ENABLE_DROP_EVENT) {
  239. +           new DropEvent().verificationDay();
  240. +           LOGGER.info("DropEvent loaded");
  241. +       }
  242.        
  243.         if (Config.L2JMOD_ALLOW_WEDDING || Config.ALLOW_AWAY_STATUS || Config.PCB_ENABLE || Config.POWERPAK_ENABLED)
  244.         {
  245. Index: config/functions/l2jfrozen.properties
  246. ===================================================================
  247. --- config/functions/l2jfrozen.properties   (revision 1118)
  248. +++ config/functions/l2jfrozen.properties   (working copy)
  249. @@ -281,4 +281,14 @@
  250.  ProtectorSkillLevel = 13
  251.  ProtectorSkillTime = 600
  252.  # Npc Protector Message
  253. -ProtectorMessage = Hey You!, Never Kill On This Area, Go Read The Rules!
  254. \ No newline at end of file
  255. +ProtectorMessage = Hey You!, Never Kill On This Area, Go Read The Rules!
  256. +
  257. +#=============================================================
  258. +#             DropEvent - By João Vitor Barbosa
  259. +#=============================================================
  260. +# How to disable only an rate drop? Add 1.0, example: EventRateAdena = 1.0
  261. +EnableDropEvent = true
  262. +EventRateXp = 5.0
  263. +EventRateSp = 5.0
  264. +EventRateAdena = 5.0
  265. +EventRateSpoil = 5.0
  266. \ No newline at end of file
Add Comment
Please, Sign In to add comment