Elfocrash

Hidden Bastard Event by Elfocrash

Oct 3rd, 2012
1,219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.31 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P HideAndSeek
  3. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java
  4. ===================================================================
  5. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (revision 952)
  6. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/RequestRestart.java (working copy)
  7. @@ -27,6 +27,7 @@
  8.  import com.l2jfrozen.gameserver.model.Inventory;
  9.  import com.l2jfrozen.gameserver.model.L2Party;
  10.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  11. +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
  12.  import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  13.  import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
  14.  import com.l2jfrozen.gameserver.network.L2GameClient;
  15. @@ -85,6 +86,13 @@
  16.             return;
  17.         }
  18.        
  19. +       if(player == HiddenBastard.bastard)
  20. +       {
  21. +           player.sendMessage("You cannot restart while being the hidden bastard");
  22. +           sendPacket(RestartResponse.valueOf(false));
  23. +           return;
  24. +       }
  25. +      
  26.         // Check if player is in combat
  27.         if(AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !(player.isGM() && Config.GM_RESTART_FIGHTING))
  28.         {
  29. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  30. ===================================================================
  31. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (revision 952)
  32. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (working copy)
  33. @@ -36,6 +36,7 @@
  34.  import com.l2jfrozen.gameserver.model.L2World;
  35.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  36.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance.PunishLevel;
  37. +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
  38.  import com.l2jfrozen.gameserver.network.SystemChatChannelId;
  39.  import com.l2jfrozen.gameserver.network.SystemMessageId;
  40.  import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  41. @@ -131,6 +132,11 @@
  42.            return;
  43.         }
  44.        
  45. +       if(activeChar == HiddenBastard.bastard)
  46. +       {
  47. +           activeChar.sendMessage("You are the hidden bastard. You are not supposed to talk");
  48. +           return;
  49. +       }
  50.         if(activeChar == null)
  51.         {
  52.             _log.warning("[Say2.java] Active Character is null.");
  53. Index: head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java
  54. ===================================================================
  55. --- head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java (revision 0)
  56. +++ head-src/com/l2jfrozen/gameserver/model/entity/event/HiddenBastard.java (working copy)
  57. @@ -0,0 +1,166 @@
  58. +/* This program is free software; you can redistribute it and/or modify
  59. + * it under the terms of the GNU General Public License as published by
  60. + * the Free Software Foundation; either version 2, or (at your option)
  61. + * any later version.
  62. + *
  63. + * This program is distributed in the hope that it will be useful,
  64. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  65. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  66. + * GNU General Public License for more details.
  67. + *
  68. + * You should have received a copy of the GNU General Public License
  69. + * along with this program; if not, write to the Free Software
  70. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  71. + * 02111-1307, USA.
  72. + *
  73. + * http://www.gnu.org/copyleft/gpl.html
  74. + */
  75. +
  76. +package com.l2jfrozen.gameserver.model.entity.event;
  77. +
  78. +import java.util.Collection;
  79. +
  80. +import com.l2jfrozen.gameserver.managers.TownManager;
  81. +import com.l2jfrozen.gameserver.model.L2Character;
  82. +import com.l2jfrozen.gameserver.model.L2World;
  83. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  84. +import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
  85. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  86. +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  87. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  88. +import com.l2jfrozen.util.random.Rnd;
  89. +
  90. +import javolution.util.FastList;
  91. +
  92. +
  93. +/**
  94. + *
  95. + * @author  Elfocrash
  96. + */
  97. +
  98. +public class HiddenBastard
  99. +{
  100. +   public static FastList<L2PcInstance> _players = new FastList<L2PcInstance>();
  101. +   public static State state = State.INACTIVE;
  102. +   public static L2PcInstance bastard = null;
  103. +   public static enum State  { INACTIVE,
  104. +                               PICKING,
  105. +                               SEARCHING
  106. +                               }
  107. +  
  108. +   public class Task implements Runnable
  109. +   {
  110. +       @Override
  111. +       public void run()
  112. +       {
  113. +           if (state != State.INACTIVE)
  114. +           {
  115. +               return;
  116. +           }
  117. +           Runner();
  118. +       }
  119. +   }
  120. +  
  121. +   public void Runner()
  122. +   {
  123. +       Announce("Hide And Seek Event Started. In 20 seconds a random player from Giran will be picked to become the hidden bastard.");
  124. +       state = State.PICKING;
  125. +       waitSecs(20);
  126. +       Announce("The event started! Someone in Giran is the Hidden Bastard. Use .bastard command while targeting a player to check if he is the bastard!");
  127. +       Announce("You have 5 minutes to search for him.");
  128. +       pickBastard();
  129. +       wait(4);
  130. +       while(state == State.SEARCHING)
  131. +       {
  132. +           Announce("One minute left! Still searching for him!");
  133. +           wait(1);
  134. +           Announce("No one found the hidden bastard. And that's just sad. " + bastard + "was the bastard.");
  135. +           bastard.setIsBastard(false);
  136. +           bastard.setIsImobilised(false);
  137. +           clear();
  138. +       }
  139. +   }
  140. +   public static void Announce(String msg)
  141. +   {
  142. +       Collection<L2PcInstance> plrs = L2World.getInstance().getAllPlayers();
  143. +       CreatureSay cs = new CreatureSay(1, Say2.ANNOUNCEMENT, "", msg);
  144. +      
  145. +       for (L2PcInstance pls : plrs)
  146. +       {
  147. +           pls.sendPacket(cs);
  148. +       }
  149. +   }
  150. +  
  151. +  
  152. +   public static void pickBastard()
  153. +   {      
  154. +       state = State.SEARCHING;
  155. +      
  156. +       L2ZoneType zone = TownManager.getInstance().getTown(9);
  157. +
  158. +           for (L2Character character : zone.getCharactersInside().values())
  159. +                   if (character instanceof L2PcInstance)
  160. +                           _players.add((L2PcInstance) character);
  161. +                          
  162. +           bastard = _players.get(Rnd.get(0, _players.size() - 1));
  163. +           bastard.setIsBastard(true);
  164. +           bastard.sendMessage("You are the secret bastard. You are not allowed to move or talk.");
  165. +           bastard.setIsImobilised(true);
  166. +   }
  167. +  
  168. +  
  169. +  
  170. +   public static void endAndReward()
  171. +   {
  172. +       //reward with the way you want to
  173. +       //bastard.blabla
  174. +   }
  175. +  
  176. +   public static void clear()
  177. +   {
  178. +       _players.clear();
  179. +       bastard = null;
  180. +       state = State.INACTIVE;
  181. +      
  182. +   }
  183. +  
  184. +   private HiddenBastard()
  185. +   {
  186. +       ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new Task(), 100000, 600000);
  187. +   }
  188. +  
  189. +   public void waitSecs(int i)
  190. +   {
  191. +       try
  192. +       {
  193. +           Thread.sleep(i * 1000);
  194. +       }
  195. +       catch (InterruptedException ie)
  196. +       {
  197. +           ie.printStackTrace();
  198. +       }
  199. +   }
  200. +  
  201. +   public void wait(int i)
  202. +   {
  203. +       try
  204. +       {
  205. +           Thread.sleep(i * 60000);
  206. +       }
  207. +       catch (InterruptedException ie)
  208. +       {
  209. +           ie.printStackTrace();
  210. +       }
  211. +   }
  212. +  
  213. +   public static HiddenBastard getInstance()
  214. +   {
  215. +       return SingletonHolder._instance;
  216. +   }
  217. +  
  218. +   private static class SingletonHolder
  219. +   {
  220. +       @SuppressWarnings("synthetic-access")
  221. +       protected static final HiddenBastard _instance = new HiddenBastard();
  222. +   }
  223. +}
  224. \ No newline at end of file
  225. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java
  226. ===================================================================
  227. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (revision 952)
  228. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Logout.java (working copy)
  229. @@ -21,6 +21,7 @@
  230.  import com.l2jfrozen.gameserver.datatables.SkillTable;
  231.  import com.l2jfrozen.gameserver.model.L2Party;
  232.  import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  233. +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
  234.  import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  235.  import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSignsFestival;
  236.  import com.l2jfrozen.gameserver.network.SystemMessageId;
  237. @@ -77,6 +78,12 @@
  238.             return;
  239.         }
  240.        
  241. +       if(player == HiddenBastard.bastard)
  242. +       {
  243. +           player.sendMessage("You cannot logout while being the hidden bastard.");  
  244. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  245. +           return;
  246. +       }
  247.         // Dont allow leaving if player is teleporting
  248.         if (player.isTeleporting() && !player.isGM())
  249.         {
  250. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  251. ===================================================================
  252. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java    (revision 952)
  253. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  254. @@ -290,6 +290,8 @@
  255.     /** The _last teleport action. */
  256.     private long _lastTeleportAction = 0;
  257.    
  258. +  
  259. +  
  260.     /**
  261.      * Gets the actual status.
  262.      *
  263. @@ -19132,7 +19134,17 @@
  264.          _isLocked = a;  
  265.      } 
  266.      
  267. -
  268. +   private boolean bastard = false;
  269. +  
  270. +   public void setIsBastard(boolean bastardaki)
  271. +   {
  272. +       bastardaki = this.bastard;
  273. +   }
  274. +  
  275. +   public boolean isBastard()
  276. +   {
  277. +       return bastard;
  278. +   }
  279.      
  280.      /** The _punish level. */
  281.      private PunishLevel _punishLevel = PunishLevel.NONE;
  282. Index: head-src/com/l2jfrozen/gameserver/model/L2Character.java
  283. ===================================================================
  284. --- head-src/com/l2jfrozen/gameserver/model/L2Character.java    (revision 952)
  285. +++ head-src/com/l2jfrozen/gameserver/model/L2Character.java    (working copy)
  286. @@ -2760,6 +2760,8 @@
  287.         _isImobilised = value;
  288.     }
  289.  
  290. +
  291. +  
  292.     /**
  293.      * Checks if is block buff.
  294.      *
  295. Index: head-src/com/l2jfrozen/gameserver/GameServer.java
  296. ===================================================================
  297. --- head-src/com/l2jfrozen/gameserver/GameServer.java   (revision 952)
  298. +++ head-src/com/l2jfrozen/gameserver/GameServer.java   (working copy)
  299. @@ -118,6 +118,7 @@
  300.  import com.l2jfrozen.gameserver.model.entity.Announcements;
  301.  import com.l2jfrozen.gameserver.model.entity.Hero;
  302.  import com.l2jfrozen.gameserver.model.entity.MonsterRace;
  303. +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
  304.  import com.l2jfrozen.gameserver.model.entity.event.manager.EventManager;
  305.  import com.l2jfrozen.gameserver.model.entity.olympiad.Olympiad;
  306.  import com.l2jfrozen.gameserver.model.entity.sevensigns.SevenSigns;
  307. @@ -410,6 +411,8 @@
  308.         AdminCommandHandler.getInstance();
  309.         UserCommandHandler.getInstance();
  310.         VoicedCommandHandler.getInstance();
  311. +      
  312. +       HiddenBastard.getInstance();
  313.  
  314.        
  315.         _log.info("AutoChatHandler : Loaded " + AutoChatHandler.getInstance().size() + " handlers in total.");
  316. Index: head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  317. ===================================================================
  318. --- head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (revision 952)
  319. +++ head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java (working copy)
  320. @@ -30,6 +30,7 @@
  321.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.CTFCmd;
  322.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.DMCmd;
  323.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.FarmPvpCmd;
  324. +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.HiddenBastardCmd;
  325.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.Online;
  326.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.StatsCmd;
  327.  import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.TvTCmd;
  328. @@ -71,6 +72,8 @@
  329.             registerVoicedCommandHandler(new BankingCmd());
  330.         }
  331.  
  332. +       registerVoicedCommandHandler(new HiddenBastardCmd());
  333. +      
  334.         if(Config.CTF_COMMAND)
  335.         {
  336.             registerVoicedCommandHandler(new CTFCmd());
  337. Index: head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java
  338. ===================================================================
  339. --- head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java   (revision 0)
  340. +++ head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/HiddenBastardCmd.java   (working copy)
  341. @@ -0,0 +1,74 @@
  342. +/*
  343. + * This program is free software: you can redistribute it and/or modify it under
  344. + * the terms of the GNU General Public License as published by the Free Software
  345. + * Foundation, either version 3 of the License, or (at your option) any later
  346. + * version.
  347. + *
  348. + * This program is distributed in the hope that it will be useful, but WITHOUT
  349. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  350. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  351. + * details.
  352. + *
  353. + * You should have received a copy of the GNU General Public License along with
  354. + * this program. If not, see <http://www.gnu.org/licenses/>.
  355. + */
  356. +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
  357. +
  358. +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
  359. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  360. +import com.l2jfrozen.gameserver.model.entity.event.HiddenBastard;
  361. +
  362. +/**
  363. + *
  364. + * @author  Elfocrash
  365. + */
  366. +
  367. +public class HiddenBastardCmd implements IVoicedCommandHandler
  368. +{
  369. +   private static String[] _voicedCommands =
  370. +   {
  371. +       "bastard"
  372. +   };
  373. +
  374. +   @Override
  375. +   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  376. +   {
  377. +       if(command.equalsIgnoreCase(_voicedCommands[0]))
  378. +       {
  379. +           if(!(activeChar.getTarget() instanceof L2PcInstance))
  380. +           {
  381. +               activeChar.sendMessage("Only players can be bastards.");
  382. +               return false;
  383. +           }
  384. +          
  385. +           if(activeChar.getTarget() == activeChar)
  386. +           {
  387. +               activeChar.sendMessage("You are too good to be the bastard.");
  388. +               return false;
  389. +           }
  390. +          
  391. +           if(activeChar.getTarget() == null)
  392. +           {
  393. +               activeChar.sendMessage("You have to target someone.");
  394. +               return false;
  395. +           }
  396. +          
  397. +           if(((L2PcInstance) activeChar.getTarget()) == HiddenBastard.bastard)
  398. +           {
  399. +               activeChar.sendMessage("You found him!" + activeChar.getTarget().getName() + " is the bastard.");
  400. +               HiddenBastard.Announce(activeChar.getName() + " found the hidden bastard who was " + HiddenBastard.bastard);
  401. +               HiddenBastard.endAndReward();
  402. +               HiddenBastard.bastard.setIsBastard(false);
  403. +               HiddenBastard.bastard.setIsImobilised(false);
  404. +               HiddenBastard.clear();
  405. +           }
  406. +           else
  407. +           {
  408. +               activeChar.sendMessage("No! " + activeChar.getTarget().getName() + " is not the bastard.");
  409. +               return false;
  410. +           }
  411. +       }
  412. +       return true;
  413. +   }
  414. +
  415. +   @Override
  416. +   public String[] getVoicedCommandList()
  417. +   {
  418. +       return _voicedCommands;
  419. +   }
  420. +}
Advertisement
Add Comment
Please, Sign In to add comment