Advertisement
warc222

hitman event

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