AdminMonsterRace.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.admincommandhandlers;
  20. import com.l2jserver.gameserver.MonsterRace;
  21. import com.l2jserver.gameserver.ThreadPoolManager;
  22. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.DeleteObject;
  26. import com.l2jserver.gameserver.network.serverpackets.MonRaceInfo;
  27. import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  28. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  29. /**
  30. * This class handles following admin commands: - invul = turns invulnerability on/off
  31. * @version $Revision: 1.1.6.4 $ $Date: 2007/07/31 10:06:00 $
  32. */
  33. public class AdminMonsterRace implements IAdminCommandHandler
  34. {
  35. // private static Logger _log = Logger.getLogger(AdminMonsterRace.class.getName());
  36. private static final String[] ADMIN_COMMANDS =
  37. {
  38. "admin_mons"
  39. };
  40. protected static int state = -1;
  41. @Override
  42. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  43. {
  44. if (command.equalsIgnoreCase("admin_mons"))
  45. {
  46. handleSendPacket(activeChar);
  47. }
  48. return true;
  49. }
  50. @Override
  51. public String[] getAdminCommandList()
  52. {
  53. return ADMIN_COMMANDS;
  54. }
  55. private void handleSendPacket(L2PcInstance activeChar)
  56. {
  57. /*
  58. * -1 0 to initialize the race 0 15322 to start race 13765 -1 in middle of race -1 0 to end the race 8003 to 8027
  59. */
  60. int[][] codes =
  61. {
  62. {
  63. -1,
  64. 0
  65. },
  66. {
  67. 0,
  68. 15322
  69. },
  70. {
  71. 13765,
  72. -1
  73. },
  74. {
  75. -1,
  76. 0
  77. }
  78. };
  79. MonsterRace race = MonsterRace.getInstance();
  80. if (state == -1)
  81. {
  82. state++;
  83. race.newRace();
  84. race.newSpeeds();
  85. MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
  86. activeChar.sendPacket(spk);
  87. activeChar.broadcastPacket(spk);
  88. }
  89. else if (state == 0)
  90. {
  91. state++;
  92. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.MONSRACE_RACE_START);
  93. sm.addInt(0);
  94. activeChar.sendPacket(sm);
  95. PlaySound SRace = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
  96. activeChar.sendPacket(SRace);
  97. activeChar.broadcastPacket(SRace);
  98. PlaySound SRace2 = new PlaySound(0, "ItemSound2.race_start", 1, 121209259, 12125, 182487, -3559);
  99. activeChar.sendPacket(SRace2);
  100. activeChar.broadcastPacket(SRace2);
  101. MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
  102. activeChar.sendPacket(spk);
  103. activeChar.broadcastPacket(spk);
  104. ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
  105. }
  106. }
  107. class RunRace implements Runnable
  108. {
  109. private final int[][] codes;
  110. private final L2PcInstance activeChar;
  111. public RunRace(int[][] pCodes, L2PcInstance pActiveChar)
  112. {
  113. codes = pCodes;
  114. activeChar = pActiveChar;
  115. }
  116. @Override
  117. public void run()
  118. {
  119. // int[][] speeds1 = MonsterRace.getInstance().getSpeeds();
  120. // MonsterRace.getInstance().newSpeeds();
  121. // int[][] speeds2 = MonsterRace.getInstance().getSpeeds();
  122. /*
  123. * int[] speed = new int[8]; for (int i=0; i<8; i++) { for (int j=0; j<20; j++) { //_log.info("Adding "+speeds1[i][j] +" and "+ speeds2[i][j]); speed[i] += (speeds1[i][j]*1);// + (speeds2[i][j]*1); } _log.info("Total speed for "+(i+1)+" = "+speed[i]); }
  124. */
  125. MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
  126. activeChar.sendPacket(spk);
  127. activeChar.broadcastPacket(spk);
  128. ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
  129. }
  130. }
  131. private static class RunEnd implements Runnable
  132. {
  133. private final L2PcInstance activeChar;
  134. public RunEnd(L2PcInstance pActiveChar)
  135. {
  136. activeChar = pActiveChar;
  137. }
  138. @Override
  139. public void run()
  140. {
  141. DeleteObject obj = null;
  142. for (int i = 0; i < 8; i++)
  143. {
  144. obj = new DeleteObject(MonsterRace.getInstance().getMonsters()[i]);
  145. activeChar.sendPacket(obj);
  146. activeChar.broadcastPacket(obj);
  147. }
  148. state = -1;
  149. }
  150. }
  151. }