Advertisement
Guest User

Untitled

a guest
Dec 12th, 2013
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.68 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server
  3. Index: java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java
  4. ===================================================================
  5. --- java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java   (revision 0)
  6. +++ java/com/l2jserver/gameserver/model/entity/PkHunterEvent.java   (revision 0)
  7. @@ -0,0 +1,158 @@
  8. +/*
  9. + * This program is free software: you can redistribute it and/or modify it under
  10. + * the terms of the GNU General Public License as published by the Free Software
  11. + * Foundation, either version 3 of the License, or (at your option) any later
  12. + * version.
  13. + *
  14. + * This program is distributed in the hope that it will be useful, but WITHOUT
  15. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17. + * details.
  18. + *
  19. + * You should have received a copy of the GNU General Public License along with
  20. + * this program. If not, see <http://www.gnu.org/licenses/>.
  21. + */
  22. +package com.l2jserver.gameserver.model.entity;
  23. +
  24. +import com.l2jserver.gameserver.model.L2World;
  25. +import com.l2jserver.gameserver.model.actor.L2Character;
  26. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. +import com.l2jserver.gameserver.util.Util;
  28. +
  29. +/**
  30. + *
  31. + * @author Wyatt
  32. + *
  33. + */
  34. +
  35. +public class PkHunterEvent
  36. +{
  37. +   private static boolean isActive = false;
  38. +   private static L2PcInstance Pk = null;
  39. +   private static int[] PkLocation = {0,0,0};
  40. +  
  41. +   public static boolean isActive()
  42. +   {
  43. +       return isActive;
  44. +   }
  45. +  
  46. +   public static L2PcInstance getPk()
  47. +   {
  48. +       return Pk;
  49. +   }
  50. +  
  51. +   public static void setPk(L2PcInstance player)
  52. +   {
  53. +       Pk = player;
  54. +   }
  55. +  
  56. +   public static void setActive(Boolean active)
  57. +   {
  58. +       isActive = active;
  59. +   }
  60. +  
  61. +   public static void setPkLocation(int x, int y, int z)
  62. +   {
  63. +       PkLocation[0] = x;
  64. +       PkLocation[1] = y;
  65. +       PkLocation[2] = z;
  66. +   }
  67. +  
  68. +   public static int[] getPkLocation()
  69. +   {
  70. +       return PkLocation;
  71. +   }
  72. +  
  73. +   public static boolean isPk(L2Character pk)
  74. +   {
  75. +       if(pk != null && getPk() != null && pk.getName().equals(getPk().getName()))
  76. +       {
  77. +           return true;
  78. +       }
  79. +       return false;
  80. +   }
  81. +  
  82. +   public static boolean isPkOnline()
  83. +   {
  84. +       if(getPk() != null && getPk().isOnline())
  85. +       {
  86. +           return true;
  87. +       }
  88. +       return false;
  89. +   }
  90. +  
  91. +   public static void sendLocationMessage(L2PcInstance activeChar)
  92. +   {
  93. +       if(isPkOnline())
  94. +       {
  95. +           L2PcInstance target = L2World.getInstance().getPlayer(PkHunterEvent.getPk().getName());
  96. +           double angle = activeChar.getHeading()/182.044444444;
  97. +           double angle2 = Util.calculateAngleFrom(activeChar, target);
  98. +           String location = "";
  99. +           String distance = "";
  100. +           double finalAngle = angle - angle2;
  101. +          
  102. +           if(finalAngle < 0)
  103. +               finalAngle +=360;
  104. +          
  105. +           double octamore = 22.5;
  106. +          
  107. +           if(finalAngle>=octamore*15 && finalAngle <octamore*17)
  108. +           {
  109. +               location = " infront of you";
  110. +           }
  111. +           else if(finalAngle >= octamore*1 && finalAngle < octamore * 3)
  112. +           {
  113. +               location = " infront of you, on your left";
  114. +           }
  115. +           else if(finalAngle >= octamore*3 && finalAngle < octamore * 5)
  116. +           {
  117. +               location = " on your left";
  118. +           }
  119. +           else if(finalAngle >= octamore*5 && finalAngle < octamore * 7)
  120. +           {
  121. +               location = " behind you, on your left";
  122. +           }
  123. +           else if(finalAngle >= octamore*7 && finalAngle < octamore * 9)
  124. +           {
  125. +               location = " behind you";
  126. +           }
  127. +           else if(finalAngle >= octamore*9 && finalAngle < octamore * 11)
  128. +           {
  129. +               location = " behind you, on your right";
  130. +           }
  131. +           else if(finalAngle >= octamore*11 && finalAngle < octamore * 13)
  132. +           {
  133. +               location = " on your right";
  134. +           }
  135. +           else if(finalAngle >= octamore*13 && finalAngle < octamore * 15)
  136. +           {
  137. +               location = " infront of you, on your right";
  138. +           }
  139. +           else
  140. +           {
  141. +               location = " infront of you";
  142. +           }
  143. +          
  144. +           double dist = Util.calculateDistance(activeChar, target, false);
  145. +          
  146. +           if(dist < 400)
  147. +               distance = ", very close";
  148. +           else if(dist < 1000)
  149. +               distance = ", close";
  150. +           else if(dist < 4000)
  151. +               distance = ", at medium range";
  152. +           else if(dist < 12000)
  153. +               distance = ", quite some distance away";
  154. +           else if(dist < 20000)
  155. +               distance = ", far away";
  156. +           else
  157. +               distance = ", very very far away";
  158. +               activeChar.sendMessage(target.getName()+ " is" + location + " "+ distance+".");
  159. +       }
  160. +       else
  161. +       {
  162. +           activeChar.sendMessage("The PK is Offline now.");
  163. +       }
  164. +   }
  165. +}
  166. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  167. ===================================================================
  168. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 5822)
  169. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  170. @@ -160,6 +160,8 @@
  171.  import com.l2jserver.gameserver.model.entity.Hero;
  172.  import com.l2jserver.gameserver.model.entity.Instance;
  173.  import com.l2jserver.gameserver.model.entity.L2Event;
  174. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  175. +import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
  176.  import com.l2jserver.gameserver.model.entity.Siege;
  177.  import com.l2jserver.gameserver.model.entity.TvTEvent;
  178.  import com.l2jserver.gameserver.model.fishing.L2Fish;
  179. @@ -5507,6 +5533,7 @@
  180.             L2PcInstance pk = killer.getActingPlayer();
  181.            
  182.             TvTEvent.onKill(killer, this);
  183. +           PkHunterEventConditions.checkDie(killer, this);
  184.            
  185.             if (L2Event.isParticipant(pk) && pk != null)
  186.                 pk.getEventStatus().kills.add(this);
  187. @@ -5673,6 +5703,11 @@
  188.         )
  189.             return;
  190.        
  191. +       if(PkHunterEvent.isPk(killer) && !Config.DROP_PKHUNTEREVENT)
  192. +       {
  193. +           return;
  194. +       }
  195. +      
  196.         if ((!isInsideZone(ZONE_PVP) || pk == null) && (!isGM() || Config.KARMA_DROP_GM))
  197.         {
  198.             boolean isKarmaDrop = false;
  199. @@ -5914,6 +6003,7 @@
  200.                 && AntiFeedManager.getInstance().check(this, target))
  201.             setPkKills(getPkKills() + 1);
  202.        
  203. +       PkHunterEventConditions.checkPk(this, target);
  204.         // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  205.         sendPacket(new UserInfo(this));
  206.         sendPacket(new ExBrExtraUserInfo(this));
  207. Index: java/com/l2jserver/gameserver/network/clientpackets/Logout.java
  208. ===================================================================
  209. --- java/com/l2jserver/gameserver/network/clientpackets/Logout.java (revision 5822)
  210. +++ java/com/l2jserver/gameserver/network/clientpackets/Logout.java (working copy)
  211. @@ -23,6 +23,7 @@
  212.  import com.l2jserver.gameserver.model.L2Party;
  213.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  214.  import com.l2jserver.gameserver.model.entity.L2Event;
  215. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  216.  import com.l2jserver.gameserver.network.SystemMessageId;
  217.  import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  218.  import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  219. @@ -59,6 +60,13 @@
  220.             return;
  221.         }
  222.        
  223. +       if (PkHunterEvent.isPk(player))
  224. +       {
  225. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  226. +           player.sendMessage("You can't logout while in event.");
  227. +           return;
  228. +       }
  229. +      
  230.         if (player.isLocked())
  231.         {
  232.             _log.warning("Player " + player.getName() + " tried to logout during class change.");
  233. Index: java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java
  234. ===================================================================
  235. --- java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java   (revision 5822)
  236. +++ java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java   (working copy)
  237. @@ -28,6 +28,7 @@
  238.  import com.l2jserver.gameserver.model.L2World;
  239.  import com.l2jserver.gameserver.model.StatsSet;
  240.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  241. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  242.  import com.l2jserver.gameserver.model.entity.TvTEvent;
  243.  import com.l2jserver.gameserver.network.SystemMessageId;
  244.  import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  245. @@ -456,6 +457,12 @@
  246.             return false;
  247.         }
  248.        
  249. +       if (PkHunterEvent.isPk(player))
  250. +       {
  251. +           player.sendMessage("You can't participate in Olympiads while in event.");
  252. +           return false;
  253. +       }
  254. +      
  255.         final int charId = noble.getObjectId();
  256.         if (TvTEvent.isPlayerParticipant(charId))
  257.         {
  258. Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java
  259. ===================================================================
  260. --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java    (revision 5822)
  261. +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java    (working copy)
  262. @@ -23,6 +23,7 @@
  263.  import com.l2jserver.gameserver.model.StatsSet;
  264.  import com.l2jserver.gameserver.model.actor.L2Character;
  265.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  266. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  267.  import com.l2jserver.gameserver.model.entity.TvTEvent;
  268.  import com.l2jserver.gameserver.model.skills.L2Skill;
  269.  import com.l2jserver.gameserver.model.skills.L2SkillType;
  270. @@ -63,6 +64,12 @@
  271.                 return;
  272.             }
  273.            
  274. +           if (PkHunterEvent.isPk(activeChar))
  275. +           {
  276. +               activeChar.sendMessage("You can't use escape skills while in event.");
  277. +               return;
  278. +           }
  279. +          
  280.             if (activeChar.isAfraid())
  281.             {
  282.                 activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  283. Index: java/com/l2jserver/Config.java
  284. ===================================================================
  285. --- java/com/l2jserver/Config.java  (revision 5822)
  286. +++ java/com/l2jserver/Config.java  (working copy)
  287. @@ -765,7 +765,14 @@
  288.     public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
  289.     public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
  290.     public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
  291. +   public static boolean ENABLE_PKHUNTEREVENT;
  292. +   public static boolean DROP_PKHUNTEREVENT;
  293. +   public static int PKHUNTEREVENT_CHANCE;
  294. +   public static int TIME_PKHUNTEREVENT;
  295. +   public static List<int[]> PKHUNTEREVENT_REWARD;
  296. +   public static List<int[]> PKHUNTEREVENT_PK_REWARD;
  297.    
  298. +  
  299.     // --------------------------------------------------
  300.     // NPC Settings
  301.     // --------------------------------------------------
  302. @@ -2728,6 +2735,57 @@
  303.                     }
  304.                 }
  305.                 L2JMOD_ALLOW_CHANGE_PASSWORD = Boolean.parseBoolean(L2JModSettings.getProperty("AllowChangePassword", "False"));
  306. +               ENABLE_PKHUNTEREVENT = Boolean.parseBoolean(L2JModSettings.getProperty("EnablePKHunterEvent", "True"));
  307. +               DROP_PKHUNTEREVENT = Boolean.parseBoolean(L2JModSettings.getProperty("PKHunterEventDrop", "False"));
  308. +               PKHUNTEREVENT_CHANCE = Integer.parseInt(L2JModSettings.getProperty("PKHunterEventChance", "20"));
  309. +               TIME_PKHUNTEREVENT = Integer.parseInt(L2JModSettings.getProperty("PKHunterEventTime", "5"));
  310. +              
  311. +               if(PKHUNTEREVENT_CHANCE < 1)
  312. +               {
  313. +                   PKHUNTEREVENT_CHANCE = 1;
  314. +               }
  315. +               PKHUNTEREVENT_REWARD = new ArrayList<>();
  316. +               propertySplit = L2JModSettings.getProperty("PKHunterEventRewards", "14720,5;14721,2").split(";");
  317. +              
  318. +               for (String reward : propertySplit)
  319. +               {
  320. +                   String[] rewardSplit = reward.split(",");
  321. +                   if (rewardSplit.length != 2)
  322. +                       _log.warning(StringUtil.concat("PkHunterEvent: invalid config property ->PkHunterEventRewards \"", reward, "\""));
  323. +                   else
  324. +                   {
  325. +                       try
  326. +                       {
  327. +                           PKHUNTEREVENT_REWARD.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  328. +                       }
  329. +                       catch (NumberFormatException nfe)
  330. +                       {
  331. +                           if (!reward.isEmpty())
  332. +                               _log.warning(StringUtil.concat("PkHunterEvent: invalid config property -> PkHunterEventRewards \"", reward, "\""));
  333. +                       }
  334. +                   }
  335. +               }
  336. +               PKHUNTEREVENT_PK_REWARD = new ArrayList<>();
  337. +               propertySplit = L2JModSettings.getProperty("PKHunterEventPkRewards", "14720,5;14721,2").split(";");
  338. +              
  339. +               for (String reward : propertySplit)
  340. +               {
  341. +                   String[] rewardSplit = reward.split(",");
  342. +                   if (rewardSplit.length != 2)
  343. +                       _log.warning(StringUtil.concat("PkHunterEvent: invalid config property ->PkHunterEventPkRewards \"", reward, "\""));
  344. +                   else
  345. +                   {
  346. +                       try
  347. +                       {
  348. +                           PKHUNTEREVENT_PK_REWARD.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  349. +                       }
  350. +                       catch (NumberFormatException nfe)
  351. +                       {
  352. +                           if (!reward.isEmpty())
  353. +                               _log.warning(StringUtil.concat("PkHunterEvent: invalid config property -> PkHunterEventPkRewards \"", reward, "\""));
  354. +                       }
  355. +                   }
  356. +               }
  357.             }
  358.             catch (Exception e)
  359.             {
  360. Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java
  361. ===================================================================
  362. --- java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java (revision 5822)
  363. +++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java (working copy)
  364. @@ -26,9 +26,11 @@
  365.  import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
  366.  import com.l2jserver.gameserver.model.L2Party;
  367.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  368. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  369.  import com.l2jserver.gameserver.network.L2GameClient;
  370.  import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
  371.  import com.l2jserver.gameserver.network.SystemMessageId;
  372. +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  373.  import com.l2jserver.gameserver.network.serverpackets.CharSelectionInfo;
  374.  import com.l2jserver.gameserver.network.serverpackets.RestartResponse;
  375.  import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.PlayerDespawnListener;
  376. @@ -65,6 +67,13 @@
  377.             return;
  378.         }
  379.        
  380. +       if (PkHunterEvent.isPk(player))
  381. +       {
  382. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  383. +           sendPacket(RestartResponse.valueOf(false));
  384. +           return;
  385. +       }
  386. +      
  387.         if (player.isLocked())
  388.         {
  389.             _log.warning("Player " + player.getName() + " tried to restart during class change.");
  390. Index: java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java
  391. ===================================================================
  392. --- java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java (revision 0)
  393. +++ java/com/l2jserver/gameserver/model/entity/PkHunterEventConditions.java (revision 0)
  394. @@ -0,0 +1,199 @@
  395. +/*
  396. + * This program is free software: you can redistribute it and/or modify it under
  397. + * the terms of the GNU General Public License as published by the Free Software
  398. + * Foundation, either version 3 of the License, or (at your option) any later
  399. + * version.
  400. + *
  401. + * This program is distributed in the hope that it will be useful, but WITHOUT
  402. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  403. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  404. + * details.
  405. + *
  406. + * You should have received a copy of the GNU General Public License along with
  407. + * this program. If not, see <http://www.gnu.org/licenses/>.
  408. + */
  409. +package com.l2jserver.gameserver.model.entity;
  410. +
  411. +import java.util.concurrent.ScheduledFuture;
  412. +
  413. +import com.l2jserver.Config;
  414. +import com.l2jserver.gameserver.Announcements;
  415. +import com.l2jserver.gameserver.ThreadPoolManager;
  416. +import com.l2jserver.gameserver.datatables.ItemTable;
  417. +import com.l2jserver.gameserver.model.L2Object;
  418. +import com.l2jserver.gameserver.model.actor.L2Character;
  419. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  420. +import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  421. +import com.l2jserver.gameserver.network.SystemMessageId;
  422. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  423. +import com.l2jserver.util.Rnd;
  424. +
  425. +/**
  426. + *
  427. + * @author Wyatt
  428. + *
  429. + */
  430. +
  431. +public class PkHunterEventConditions
  432. +{
  433. +   private static ScheduledFuture<?> _timerTask;
  434. +  
  435. +   public static void checkFinishByMobs(L2PcInstance killer)
  436. +   {
  437. +       if (PkHunterEvent.isPk(killer) && Config.ENABLE_PKHUNTEREVENT)
  438. +       {
  439. +           if(killer.getKarma() == 0)
  440. +           {
  441. +               Announcements.getInstance().announceToAll("PkHunter Event ended. "+killer.getName()+" has survived.", true);
  442. +               PkHunterEvent.setPk(null);
  443. +               PkHunterEvent.setActive(false);
  444. +               killer.setTeam(0);
  445. +               endTask();
  446. +               rewardPk(killer);
  447. +           }
  448. +       }
  449. +   }
  450. +  
  451. +   public static void checkDie(L2Object killer, final L2PcInstance killed)
  452. +   {
  453. +       if(PkHunterEvent.isPk(killed) && Config.ENABLE_PKHUNTEREVENT)
  454. +       {
  455. +           if(killer instanceof L2PcInstance)
  456. +           {
  457. +               L2PcInstance kr = ((L2PcInstance)killer);
  458. +               SystemMessage systemMessage = null;
  459. +              
  460. +               for (int[] reward : Config.PKHUNTEREVENT_REWARD)
  461. +               {
  462. +                   PcInventory inv = kr.getInventory();
  463. +                  
  464. +                   if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
  465. +                   {
  466. +                       inv.addItem("PKHunter Event", reward[0], reward[1], kr, kr);
  467. +                      
  468. +                       if (reward[1] > 1)
  469. +                       {
  470. +                           systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  471. +                           systemMessage.addItemName(reward[0]);
  472. +                           systemMessage.addItemNumber(reward[1]);
  473. +                       }
  474. +                       else
  475. +                       {
  476. +                           systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  477. +                           systemMessage.addItemName(reward[0]);
  478. +                       }
  479. +                       kr.sendPacket(systemMessage);
  480. +                   }
  481. +                   else
  482. +                   {
  483. +                       for (int i = 0; i < reward[1]; ++i)
  484. +                       {
  485. +                           inv.addItem("PkHunter Event", reward[0], 1, kr, kr);
  486. +                           systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  487. +                           systemMessage.addItemName(reward[0]);
  488. +                           kr.sendPacket(systemMessage);
  489. +                       }
  490. +                   }
  491. +               }
  492. +           }
  493. +           Announcements.getInstance().announceToAll("Pk Hunting Event: Event ended. "+killer.getName()+" killed the Pk.", true); 
  494. +           killed.setTeam(0);
  495. +           PkHunterEvent.setActive(false);
  496. +           PkHunterEvent.setPk(null);
  497. +           endTask();
  498. +          
  499. +           ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  500. +           {
  501. +               @Override
  502. +               public void run()
  503. +               {
  504. +                   killed.setKarma(0);    
  505. +               }
  506. +           },100);    
  507. +       }
  508. +   }
  509. +  
  510. +   public static void checkPk(L2PcInstance killer, L2Character target)
  511. +   {
  512. +       if (Config.ENABLE_PKHUNTEREVENT && !PkHunterEvent.isActive())
  513. +       {
  514. +           switch(Rnd.get(1, Config.PKHUNTEREVENT_CHANCE))
  515. +           {
  516. +               case 1:
  517. +                   killer.setKarma(900000);
  518. +                   killer.setTeam(2);
  519. +                   PkHunterEvent.setActive(true);
  520. +                   PkHunterEvent.setPk(killer);
  521. +                   PkHunterEvent.setPkLocation(killer.getX(), killer.getY(), killer.getZ());
  522. +                   startEvent();
  523. +                   break;
  524. +           }      
  525. +       }  
  526. +   }
  527. +  
  528. +   public static void endCoward(L2PcInstance activeChar)
  529. +   {
  530. +       if(PkHunterEvent.isActive())
  531. +       {
  532. +           PkHunterEvent.setActive(false);
  533. +           PkHunterEvent.setPk(null);
  534. +           Announcements.getInstance().announceToAll("PkHunter Event ended.", true);
  535. +           endTask();
  536. +       }
  537. +       activeChar.setKarma(10000);
  538. +       activeChar.sendMessage("You karma updated to 10.000 due to be a coward, PkHunter Event ended.");
  539. +   }
  540. +  
  541. +   public static void startEvent()
  542. +   {
  543. +       Announcements.getInstance().announceToAll("PkHunter Event started: "+PkHunterEvent.getPk().getName()+" is the PK, write .gopk to teleport where the pk was done. Write .pkinfo to know if you are far or near to him.", true);
  544. +       _timerTask = ThreadPoolManager.getInstance().scheduleGeneral(new PkHunterEventTask(), Config.TIME_PKHUNTEREVENT * 60000);
  545. +   }
  546. +  
  547. +   static void endTask()
  548. +   {
  549. +       if(_timerTask != null)
  550. +       {
  551. +           _timerTask.cancel(false);
  552. +       }
  553. +       _timerTask = null;
  554. +   }
  555. +  
  556. +   public static void rewardPk(L2PcInstance kr)
  557. +   {
  558. +       SystemMessage systemMessage = null;
  559. +      
  560. +       for (int[] reward : Config.PKHUNTEREVENT_PK_REWARD)
  561. +       {
  562. +           PcInventory inv = kr.getInventory();
  563. +          
  564. +           if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
  565. +           {
  566. +               inv.addItem("PKHunter Event", reward[0], reward[1], kr, kr);
  567. +              
  568. +               if (reward[1] > 1)
  569. +               {
  570. +                   systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  571. +                   systemMessage.addItemName(reward[0]);
  572. +                   systemMessage.addItemNumber(reward[1]);
  573. +               }
  574. +               else
  575. +               {
  576. +                   systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  577. +                   systemMessage.addItemName(reward[0]);
  578. +               }
  579. +               kr.sendPacket(systemMessage);
  580. +           }
  581. +           else
  582. +           {
  583. +               for (int i = 0; i < reward[1]; ++i)
  584. +               {
  585. +                   inv.addItem("PkHunter Event", reward[0], 1, kr, kr);
  586. +                   systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  587. +                   systemMessage.addItemName(reward[0]);
  588. +                   kr.sendPacket(systemMessage);
  589. +               }
  590. +           }
  591. +       }
  592. +   }
  593. +}
  594. Index: java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java
  595. ===================================================================
  596. --- java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java   (revision 0)
  597. +++ java/com/l2jserver/gameserver/model/entity/PkHunterEventTask.java   (revision 0)
  598. @@ -0,0 +1,42 @@
  599. +/*
  600. + * This program is free software: you can redistribute it and/or modify it under
  601. + * the terms of the GNU General Public License as published by the Free Software
  602. + * Foundation, either version 3 of the License, or (at your option) any later
  603. + * version.
  604. + *
  605. + * This program is distributed in the hope that it will be useful, but WITHOUT
  606. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  607. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  608. + * details.
  609. + *
  610. + * You should have received a copy of the GNU General Public License along with
  611. + * this program. If not, see <http://www.gnu.org/licenses/>.
  612. + */
  613. +package com.l2jserver.gameserver.model.entity;
  614. +
  615. +import com.l2jserver.gameserver.Announcements;
  616. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  617. +
  618. +/**
  619. + *
  620. + * @author Wyatt
  621. + *
  622. + */
  623. +
  624. +public class PkHunterEventTask implements Runnable
  625. +{
  626. +       @Override
  627. +       public void run()
  628. +       {
  629. +           if(PkHunterEvent.isPkOnline())
  630. +           {
  631. +               L2PcInstance kr = PkHunterEvent.getPk();
  632. +               kr.setKarma(0);
  633. +               kr.setTeam(0);
  634. +               PkHunterEventConditions.rewardPk(kr);
  635. +           }
  636. +           Announcements.getInstance().announceToAll("PkHunter Event ended. "+PkHunterEvent.getPk().getName()+" has survived.", true);
  637. +           PkHunterEvent.setActive(false);
  638. +           PkHunterEvent.setPk(null);
  639. +       }
  640. +}
  641. Index: dist/game/config/l2jmods.properties
  642. ===================================================================
  643. --- dist/game/config/l2jmods.properties (revision 5822)
  644. +++ dist/game/config/l2jmods.properties (working copy)
  645. @@ -461,4 +461,29 @@
  646.  # ---------------------------------------------------------------------------
  647.  # Enables .changepassword voiced command which allows the players to change their account's password ingame.
  648. # Default: False
  649. -AllowChangePassword = False
  650. \ No newline at end of file
  651. +AllowChangePassword = False
  652. +
  653. +# ---------------------------------------------------------------------------
  654. +# PkHunter - Event      
  655. +# ---------------------------------------------------------------------------
  656. +# Enable/Disable PkHunter Event, Default: True
  657. +EnablePKHunterEvent = True
  658. +
  659. +# Chance to start the event when someone gets PK. The probability will be 1/20 if its default.
  660. +# Default: 20
  661. +PKHunterEventChance = 20
  662. +
  663. +# Reward for the player that kills the PK.
  664. +# Example: PKHunterEventRewards = itemId,amount;itemId,amount;itemId,amount
  665. +PKHunterEventRewards = 14720,5;14721,2
  666. +
  667. +# Reward for the PK if he survives.
  668. +# Example: PKHunterEventRewards = itemId,amount;itemId,amount;itemId,amount
  669. +PKHunterEventPkRewards = 14720,25;14721,10
  670. +
  671. +# Enable/Disable if the PK of the event will have chances to drop or not, Default: False
  672. +PKHunterEventDrop = False
  673. +
  674. +# Time that will take the event to end if noone kills the PK. In minutes.
  675. +# Default: 5
  676. +PKHunterEventTime = 5
  677. \ No newline at end of file
  678. Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java
  679. ===================================================================
  680. --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java   (revision 5822)
  681. +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java   (working copy)
  682. @@ -18,6 +18,7 @@
  683. import com.l2jserver.gameserver.model.StatsSet;
  684. import com.l2jserver.gameserver.model.actor.L2Character;
  685. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  686. +import com.l2jserver.gameserver.model.entity.PkHunterEvent;
  687. import com.l2jserver.gameserver.model.entity.TvTEvent;
  688. import com.l2jserver.gameserver.model.skills.L2Skill;
  689. import com.l2jserver.gameserver.network.SystemMessageId;
  690. @@ -54,6 +55,12 @@
  691.             return;
  692.         }
  693.        
  694. +       if (PkHunterEvent.isPk(activePlayer))
  695. +       {
  696. +           activePlayer.sendMessage("You can't mount while in event.");
  697. +           return;
  698. +       }
  699. +      
  700.         // Dismount Action
  701.         if (_npcId == 0)
  702.         {
  703. Index: java/com/l2jserver/gameserver/model/actor/L2Attackable.java
  704. ===================================================================
  705. --- java/com/l2jserver/gameserver/model/actor/L2Attackable.java (revision 5822)
  706. +++ java/com/l2jserver/gameserver/model/actor/L2Attackable.java (working copy)
  707. @@ -52,6 +52,7 @@
  708. import com.l2jserver.gameserver.model.actor.knownlist.AttackableKnownList;
  709. import com.l2jserver.gameserver.model.actor.status.AttackableStatus;
  710. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  711. +import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
  712. import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  713. import com.l2jserver.gameserver.model.items.L2Item;
  714. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  715. @@ -540,6 +541,8 @@
  716.            
  717.             if (player != null)
  718.             {
  719. +               PkHunterEventConditions.checkFinishByMobs(player);
  720. +              
  721.                 if (getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL) != null)
  722.                 {
  723.                     for (Quest quest : getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL))
  724. Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
  725. ===================================================================
  726. --- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 5822)
  727. +++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
  728. @@ -53,6 +53,7 @@
  729. import com.l2jserver.gameserver.model.entity.Fort;
  730. import com.l2jserver.gameserver.model.entity.FortSiege;
  731. import com.l2jserver.gameserver.model.entity.L2Event;
  732. +import com.l2jserver.gameserver.model.entity.PkHunterEventConditions;
  733. import com.l2jserver.gameserver.model.entity.Siege;
  734. import com.l2jserver.gameserver.model.entity.TvTEvent;
  735. import com.l2jserver.gameserver.model.entity.clanhall.AuctionableHall;
  736. @@ -218,6 +219,13 @@
  737.                 SkillTreesData.getInstance().addSkills(activeChar, true);
  738.             }
  739.         }
  740. +       else
  741. +       {
  742. +           if (activeChar.getKarma() >= 500000 && !activeChar.isCursedWeaponEquipped() && Config.ENABLE_PKHUNTEREVENT)
  743. +           {
  744. +                   PkHunterEventConditions.endCoward(activeChar);     
  745. +           }  
  746. +       }
  747.        
  748.         // Set dead status if applies
  749.         if (activeChar.getCurrentHp() < 0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement