Advertisement
Guest User

hitman event

a guest
Dec 22nd, 2012
834
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 1 0
  1.  
  2. ### Eclipse Workspace Patch 1.0
  3. #P L2J_Server
  4. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  5. ===================================================================
  6. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 5667)
  7. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  8. @@ -302,6 +313,96 @@
  9. */
  10. public final class L2PcInstance extends L2Playable
  11. {
  12.  
  13. + public boolean _hitman = false;
  14.  
  15. + public void setHitman(boolean h)
  16. + {
  17. +
  18. + _hitman = h;
  19. + }
  20. +
  21. + public boolean isHitman()
  22. + {
  23. + return _hitman;
  24. + }
  25. +
  26. @@ -5814,6 +6019,17 @@
  27. public boolean doDie(L2Character killer)
  28. {
  29. // Kill the L2PcInstance
  30. + if (isHitman())
  31. + {
  32. + L2PcInstance killer1 = killer.getActingPlayer();
  33. + Hitman event = new Hitman();
  34. + event.rewardWinner(killer1);
  35. + event.annoucneWinner(killer1);
  36. + setHitman(false);
  37. +
  38. + event.state = event.state.INACTIVE;
  39. + event.clear();
  40. + }
  41. if (!super.doDie(killer))
  42. {
  43. return false;
  44. Index: java/com/l2jserver/gameserver/model/entity/Hitman.java
  45. ===================================================================
  46. --- java/com/l2jserver/gameserver/model/entity/Hitman.java (revision 0)
  47. +++ java/com/l2jserver/gameserver/model/entity/Hitman.java (revision 0)
  48. @@ -0,0 +1,159 @@
  49. +/* This program is free software; you can redistribute it and/or modify
  50. + * it under the terms of the GNU General Public License as published by
  51. + * the Free Software Foundation; either version 2, or (at your option)
  52. + * any later version.
  53. + *
  54. + * This program is distributed in the hope that it will be useful,
  55. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  56. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  57. + * GNU General Public License for more details.
  58. + *
  59. + * You should have received a copy of the GNU General Public License
  60. + * along with this program; if not, write to the Free Software
  61. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  62. + * 02111-1307, USA.
  63. + *
  64. + * http://www.gnu.org/copyleft/gpl.html
  65. + */
  66. +package com.l2jserver.gameserver.model.entity;
  67. +
  68. +import javolution.util.FastList;
  69. +
  70. +import com.l2jserver.gameserver.Announcements;
  71. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  72. +import com.l2jserver.util.Rnd;
  73. +
  74. +/**
  75. + * @author Marwan
  76. + */
  77. +public class Hitman
  78. +{
  79. + @SuppressWarnings("unused")
  80. + public static FastList<L2PcInstance> _players = new FastList<L2PcInstance>();
  81. + public static L2PcInstance chossenPlayer = null;
  82. +
  83. + public static enum State
  84. + {
  85. + INACTIVE,
  86. + ACTIVE
  87. + }
  88. +
  89. + public static State state = State.INACTIVE;
  90. +
  91. + public class Start implements Runnable
  92. + {
  93. + @Override
  94. + public void run()
  95. + {
  96. + startEvent();
  97. + }
  98. + }
  99. +
  100. + public void startEvent()
  101. + {
  102. + Announcements.getInstance().announceToAll("Hitman event started.");
  103. + Announcements.getInstance().announceToAll("Player will be chossen in 30 seconds to be the hitman.");
  104. + pickplayer();
  105. + waitSecs(30);
  106. + announce();
  107. + chosse(chossenPlayer);
  108. +
  109. + if (state == State.ACTIVE)
  110. + {
  111. + Announcements.getInstance().announceToAll("Hitman Event will end in 5 minutes.");
  112. + wait(4);
  113. +
  114. + Announcements.getInstance().announceToAll("Hitman Event will end in 1 minutes.");
  115. + wait(1);
  116. + end();
  117. + }
  118. +
  119. + }
  120. +
  121. + public void pickplayer()
  122. + {
  123. + state = State.ACTIVE;
  124. + chossenPlayer = _players.get(Rnd.get(0, _players.size() - 1));
  125. + }
  126. +
  127. + public void end()
  128. + {
  129. + Announcements.getInstance().announceToAll("No one killed the Hitman");
  130. + Announcements.getInstance().announceToAll("Hitman event has end");
  131. + _players.clear();
  132. +
  133. + }
  134. +
  135. + public void announce()
  136. + {
  137. + Announcements.getInstance().announceToAll("Player :" + chossenPlayer.getName() + " has been chossen");
  138. + Announcements.getInstance().announceToAll("The first who kills him wil be rewarded");
  139. + Announcements.getInstance().announceToAll("Event will end in 10 minutes.");
  140. + }
  141. +
  142. + public void chosse(L2PcInstance pl)
  143. + {
  144. + pl.setHitman(true);
  145. + pl.setTitle("HitMan Target");
  146. + pl.getAppearance().setTitleColor(255, 0, 0);
  147. + }
  148. +
  149. + public void rewardWinner(L2PcInstance a)
  150. + {
  151. +
  152. + a.addItem("hitman", 57, 10000, a, false);
  153. +
  154. + }
  155. +
  156. + public void annoucneWinner(L2PcInstance a)
  157. + {
  158. +
  159. + Announcements.getInstance().announceToAll(a.getName() + " has won Hitman Event");
  160. +
  161. + }
  162. +
  163. + public void clear()
  164. + {
  165. + _players.clear();
  166. + }
  167. +
  168. + public void waitSecs(int i)
  169. + {
  170. + try
  171. + {
  172. + Thread.sleep(i * 1000);
  173. + }
  174. + catch (InterruptedException ie)
  175. + {
  176. + ie.printStackTrace();
  177. + }
  178. + }
  179. +
  180. + public void wait(int i)
  181. + {
  182. + try
  183. + {
  184. + Thread.sleep(i * 60000);
  185. + }
  186. + catch (InterruptedException ie)
  187. + {
  188. + ie.printStackTrace();
  189. + }
  190. + }
  191. +
  192. + public Hitman()
  193. + {
  194. + // ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Start(), 600000, 600000);
  195. + }
  196. +
  197. + public static Hitman getInstance()
  198. + {
  199. + return SingletonHolder._instance;
  200. + }
  201. +
  202. + private static class SingletonHolder
  203. + {
  204. + @SuppressWarnings("synthetic-access")
  205. + protected static final Hitman _instance = new Hitman();
  206. + }
  207. +}
  208. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement