Advertisement
Sarada-L2

Boss Event L2jfrozen Yo: Sarada

Mar 10th, 2021 (edited)
1,947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.84 KB | None | 0 0
  1. diff --git a/config/CustomMods/Events/BossEvent.ini b/config/CustomMods/Events/BossEvent.ini
  2. new file mode 100644
  3. index 0000000..cc4a763
  4. --- /dev/null
  5. +++ b/config/CustomMods/Events/BossEvent.ini
  6. @@ -0,0 +1,42 @@
  7. +# ================================================
  8. +# BossEvent #
  9. +# ================================================
  10. +#General
  11. +# Event Hour
  12. +EventTime = 20:55,00:00
  13. +# List of bosses randomly selected
  14. +# e.g 29046;29029
  15. +BossList = 29046
  16. +# Id of registration NPC
  17. +RegisterNpcID = 10003
  18. +# Npc location
  19. +RegisterNpcLocation = 82727,148605,-3471
  20. +# List of locations randomly selected
  21. +# e.g 10468,-24569,-3645;174229,-88032,-5116
  22. +LocationsList = 174229,-88032,-5116
  23. +# Min players to start event
  24. +MinPlayers = 1
  25. +# Min damage to boss to receive rewards
  26. +MinDamage = 2000
  27. +# if true countdown will be shown on screen
  28. +EventTimeOnScreen = True
  29. +
  30. +# Timing
  31. +# reg time in seconds
  32. +RegistrationTime = 30
  33. +# Wait time in seconds
  34. +WaitTime = 15
  35. +# Teleport time in seconds
  36. +TeleportTime = 10
  37. +# time to despawn boss
  38. +TimeToDespawnBoss = 300
  39. +
  40. +# Rewards
  41. +# Rewards for players who hitted min damage on boss
  42. +GeneralRewards = 57,100000;3470,10
  43. +# Reward last hit player
  44. +RewardLastAttacker = True
  45. +LastAttackerRewards = 3470,5;3470,5
  46. +# Reward Player with bigger dmg
  47. +RewardMainDamageDealer = True
  48. +MainDamageDealerRewards = 3470,5;3470,5
  49. \ No newline at end of file
  50. diff --git a/head-src/com/l2jfrozen/Config.java b/head-src/com/l2jfrozen/Config.java
  51. index f8a728a..0c125cf 100644
  52. --- a/head-src/com/l2jfrozen/Config.java
  53. +++ b/head-src/com/l2jfrozen/Config.java
  54. @@ -46,6 +46,7 @@
  55. import org.apache.log4j.Logger;
  56.  
  57. import com.l2jfrozen.commons.config.ExProperties;
  58. +import com.l2jfrozen.gameserver.model.Location;
  59. import com.l2jfrozen.gameserver.model.entity.olympiad.OlympiadPeriod;
  60. import com.l2jfrozen.gameserver.model.holder.RewardHolder;
  61. import com.l2jfrozen.gameserver.util.FloodProtectorConfig;
  62. @@ -72,7 +73,7 @@
  63. public static final String EVENT_DM_FILE = "./config/CustomMods/Events/DM.ini";
  64. public static final String EVENT_TVT_FILE = "./config/CustomMods/Events/TvT.ini";
  65. public static final String EVENT_TW_FILE = "./config/CustomMods/Events/TW.ini";
  66. -
  67. + public static final String BOSS_EVENT_INSTANCED = "./config/CustomMods/Events/BossEvent.ini";
  68.  
  69.  
  70. //============================================================
  71. @@ -390,7 +391,90 @@
  72. throw new Error("Failed to Load " + COMMANDS + " File.");
  73. }
  74. }
  75. -
  76. + // ============================================================
  77. + /** Boss Event */
  78. + public static boolean BOSS_EVENT_TIME_ON_SCREEN;
  79. + public static int BOSS_EVENT_TIME_TO_DESPAWN_BOSS;
  80. + public static int BOSS_EVENT_REGISTRATION_NPC_ID;
  81. + public static Map<Integer, Integer> BOSS_EVENT_GENERAL_REWARDS = new HashMap<>();
  82. + public static Map<Integer, Integer> BOSS_EVENT_LAST_ATTACKER_REWARDS = new HashMap<>();
  83. + public static Map<Integer, Integer> BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS = new HashMap<>();
  84. + public static boolean BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER;
  85. + public static boolean BOSS_EVENT_REWARD_LAST_ATTACKER;
  86. + public static List<Location> BOSS_EVENT_LOCATION = new ArrayList<>();
  87. + public static int BOSS_EVENT_REWARD_ID;
  88. + public static int BOSS_EVENT_REWARD_COUNT;
  89. + public static int BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD;
  90. + public static List<Integer> BOSS_EVENT_ID = new ArrayList<>();
  91. + public static Location BOSS_EVENT_NPC_REGISTER_LOC;
  92. + public static int BOSS_EVENT_TIME_TO_WAIT;
  93. + public static int BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS;
  94. + public static int BOSS_EVENT_MIN_PLAYERS;
  95. + public static int BOSS_EVENT_REGISTRATION_TIME;
  96. + public static String[] BOSS_EVENT_BY_TIME_OF_DAY;
  97. + // ============================================================
  98. + public static void loadEventBoss()
  99. + {
  100. + final String BOSS_EVENT_INSTANCED = Config.BOSS_EVENT_INSTANCED;
  101. +
  102. + try
  103. + {
  104. + final Properties bossEvent = new Properties();
  105. + final InputStream is = new FileInputStream(new File(BOSS_EVENT_INSTANCED));
  106. + bossEvent.load(is);
  107. + is.close();
  108. + BOSS_EVENT_BY_TIME_OF_DAY = bossEvent.getProperty("EventTime", "20:00").split(",");
  109. + for (String bossList : bossEvent.getProperty("BossList", "29046;29029").split(";"))
  110. + {
  111. + BOSS_EVENT_ID.add(Integer.parseInt(bossList));
  112. + }
  113. + bossEvent.getProperty("EventLocation", "174229,-88032,-5116").split(",");
  114. + for (String locationsList : bossEvent.getProperty("LocationsList", "10468,-24569,-3645;174229,-88032,-5116").split(";"))
  115. + {
  116. + String[] coords = locationsList.split(",");
  117. + int x = Integer.parseInt(coords[0]);
  118. + int y = Integer.parseInt(coords[1]);
  119. + int z = Integer.parseInt(coords[2]);
  120. + BOSS_EVENT_LOCATION.add(new Location(x, y, z));
  121. + }
  122. +
  123. + BOSS_EVENT_MIN_PLAYERS = Integer.parseInt(bossEvent.getProperty("MinPlayers", "1"));
  124. + BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD = Integer.parseInt(bossEvent.getProperty("MinDamage", "2000"));
  125. + BOSS_EVENT_REGISTRATION_TIME = Integer.parseInt(bossEvent.getProperty("RegistrationTime", "120"));
  126. + BOSS_EVENT_REWARD_ID = Integer.parseInt(bossEvent.getProperty("RewardId", "3470"));
  127. + BOSS_EVENT_REWARD_COUNT = Integer.parseInt(bossEvent.getProperty("RewardCount", "10"));
  128. + BOSS_EVENT_TIME_TO_WAIT = Integer.parseInt(bossEvent.getProperty("WaitTime", "30"));
  129. + BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS = Integer.parseInt(bossEvent.getProperty("TeleportTime", "15"));
  130. + BOSS_EVENT_REWARD_LAST_ATTACKER = Boolean.parseBoolean(bossEvent.getProperty("RewardLastAttacker", "true"));
  131. + BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER = Boolean.parseBoolean(bossEvent.getProperty("RewardMainDamageDealer", "true"));
  132. + for (String rewards : bossEvent.getProperty("GeneralRewards", "57,100000;3470,10").split(";"))
  133. + {
  134. + String[] reward = rewards.split(",");
  135. + BOSS_EVENT_GENERAL_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  136. + }
  137. + for (String rewards : bossEvent.getProperty("MainDamageDealerRewards", "57,100000;3470,10").split(";"))
  138. + {
  139. + String[] reward = rewards.split(",");
  140. + BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  141. + }
  142. + for (String rewards : bossEvent.getProperty("LastAttackerRewards", "57,100000;3470,10").split(";"))
  143. + {
  144. + String[] reward = rewards.split(",");
  145. + BOSS_EVENT_LAST_ATTACKER_REWARDS.put(Integer.parseInt(reward[0]), Integer.parseInt(reward[1]));
  146. + }
  147. + BOSS_EVENT_REGISTRATION_NPC_ID = Integer.parseInt(bossEvent.getProperty("RegisterNpcID", "10003"));
  148. + BOSS_EVENT_TIME_TO_DESPAWN_BOSS = Integer.parseInt(bossEvent.getProperty("TimeToDespawnBoss", "300"));
  149. + String[] regLoc = bossEvent.getProperty("RegisterNpcLocation", "82727,148605,-3471").split(",");
  150. + BOSS_EVENT_NPC_REGISTER_LOC = new Location(Integer.parseInt(regLoc[0]), Integer.parseInt(regLoc[1]), Integer.parseInt(regLoc[2]));
  151. + BOSS_EVENT_TIME_ON_SCREEN = Boolean.parseBoolean(bossEvent.getProperty("EventTimeOnScreen", "true"));
  152. +
  153. + }
  154. + catch (final Exception e)
  155. + {
  156. + e.printStackTrace();
  157. + throw new Error("Failed to Load " + BOSS_EVENT_INSTANCED + " File.");
  158. + }
  159. +}
  160.  
  161. // ============================================================
  162. public static String ENTER_FLAGZONE_MESSEGE;
  163. @@ -5292,6 +5376,7 @@
  164. loadTVTConfig();
  165. loadTWConfig();
  166. loadFlagZone();
  167. + loadEventBoss();
  168. loadCommands();
  169. loadPTFARMConfig();
  170. loadNPCSConfig();
  171. diff --git a/head-src/com/l2jfrozen/gameserver/GameServer.java b/head-src/com/l2jfrozen/gameserver/GameServer.java
  172. index 0be4989..c1e530c 100644
  173. --- a/head-src/com/l2jfrozen/gameserver/GameServer.java
  174. +++ b/head-src/com/l2jfrozen/gameserver/GameServer.java
  175. @@ -95,6 +95,7 @@
  176. import com.l2jfrozen.gameserver.managers.AutoSaveManager;
  177. import com.l2jfrozen.gameserver.managers.AwayManager;
  178. import com.l2jfrozen.gameserver.managers.BoatManager;
  179. +import com.l2jfrozen.gameserver.managers.BossEvent;
  180. import com.l2jfrozen.gameserver.managers.CastleManager;
  181. import com.l2jfrozen.gameserver.managers.CastleManorManager;
  182. import com.l2jfrozen.gameserver.managers.ClanHallManager;
  183. @@ -612,7 +613,7 @@
  184. }
  185. else
  186. LOGGER.info("All events are Disabled.");
  187. -
  188. + BossEvent.getInstance();
  189. ArenaConfig.init();
  190. if (ArenaConfig.TOURNAMENT_EVENT_TIME)
  191. {
  192. diff --git a/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
  193. new file mode 100644
  194. index 0000000..df5078e
  195. --- /dev/null
  196. +++ b/head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/BossEventCMD.java
  197. @@ -0,0 +1,49 @@
  198. +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
  199. +
  200. +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
  201. +import com.l2jfrozen.gameserver.managers.BossEvent;
  202. +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
  203. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  204. +
  205. +public class BossEventCMD implements IVoicedCommandHandler
  206. +{
  207. + @Override
  208. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  209. + {
  210. + if (command.startsWith("bossevent"))
  211. + {
  212. + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
  213. + {
  214. + activeChar.sendMessage("Boss Event is not running!");
  215. + return false;
  216. + }
  217. + if (!BossEvent.getInstance().isRegistered(activeChar))
  218. + {
  219. + if (BossEvent.getInstance().addPlayer(activeChar))
  220. + {
  221. + activeChar.sendMessage("You have been successfully registered in Boss Event!");
  222. + }
  223. +
  224. + }
  225. + else
  226. + {
  227. + if (BossEvent.getInstance().removePlayer(activeChar))
  228. + {
  229. + activeChar.sendMessage("You have been successfully removed of Boss Event!");
  230. + }
  231. + }
  232. + }
  233. + return false;
  234. + }
  235. +
  236. + @Override
  237. + public String[] getVoicedCommandList()
  238. + {
  239. +
  240. + return new String[]
  241. + {
  242. + "bossevent"
  243. + };
  244. + }
  245. +
  246. +}
  247. \ No newline at end of file
  248. diff --git a/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java b/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java
  249. new file mode 100644
  250. index 0000000..3dd5deb
  251. --- /dev/null
  252. +++ b/head-src/com/l2jfrozen/gameserver/managers/BossEvent.java
  253. @@ -0,0 +1,636 @@
  254. +package com.l2jfrozen.gameserver.managers;
  255. +
  256. +import java.util.ArrayList;
  257. +import java.util.Collection;
  258. +import java.util.HashMap;
  259. +import java.util.List;
  260. +import java.util.Map;
  261. +import java.util.concurrent.ScheduledFuture;
  262. +import java.util.logging.Logger;
  263. +
  264. +import com.l2jfrozen.Config;
  265. +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  266. +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
  267. +import com.l2jfrozen.gameserver.handler.VoicedCommandHandler;
  268. +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BossEventCMD;
  269. +import com.l2jfrozen.gameserver.model.L2World;
  270. +import com.l2jfrozen.gameserver.model.Location;
  271. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  272. +import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  273. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  274. +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  275. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage;
  276. +import com.l2jfrozen.gameserver.network.serverpackets.ExShowScreenMessage.SMPOS;
  277. +import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
  278. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  279. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  280. +import com.l2jfrozen.util.random.Rnd;
  281. +
  282. +public class BossEvent
  283. +{
  284. + public L2Spawn bossSpawn;
  285. + public List<Location> locList = new ArrayList<>();
  286. + public Location loc;
  287. + public List<Integer> bossList = new ArrayList<>();
  288. + public int bossId;
  289. + public int objectId;
  290. + public List<L2PcInstance> eventPlayers = new ArrayList<>();
  291. + protected static final Logger _log = Logger.getLogger(BossEvent.class.getName());
  292. + private EventState state = EventState.INACTIVE;
  293. + public boolean started = false;
  294. + public boolean aborted = false;
  295. + private L2PcInstance lastAttacker = null;
  296. + private Map<Integer, Integer> generalRewards = new HashMap<>();
  297. + @SuppressWarnings("unused")
  298. + private Map<Integer, Integer> lastAttackerRewards = new HashMap<>();
  299. + private Map<Integer, Integer> mainDamageDealerRewards = new HashMap<>();
  300. + public ScheduledFuture<?> despawnBoss = null;
  301. + public ScheduledFuture<?> countDownTask = null;
  302. + private String bossName = "";
  303. + public boolean bossKilled = false;
  304. + public L2Spawn eventNpc = null;
  305. + public long startTime;
  306. +
  307. + public enum EventState
  308. + {
  309. + REGISTRATION, TELEPORTING, WAITING, FIGHTING, FINISHING, INACTIVE
  310. + }
  311. +
  312. + public BossEvent()
  313. + {
  314. + VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new BossEventCMD());
  315. + NextBossEvent.getInstance().startCalculationOfNextEventTime();
  316. + _log.info("Boss Event loaded.");
  317. +
  318. + }
  319. +
  320. + public boolean addPlayer(L2PcInstance player)
  321. + {
  322. + return eventPlayers.add(player);
  323. + }
  324. +
  325. + public boolean removePlayer(L2PcInstance player)
  326. + {
  327. + return eventPlayers.remove(player);
  328. + }
  329. +
  330. + public boolean isRegistered(L2PcInstance player)
  331. + {
  332. + return eventPlayers.contains(player);
  333. + }
  334. +
  335. + class Registration implements Runnable
  336. + {
  337. + @Override
  338. + public void run()
  339. + {
  340. + startRegistration();
  341. +
  342. + }
  343. +
  344. + }
  345. +
  346. + public void teleToTown()
  347. + {
  348. + for (L2PcInstance p : eventPlayers)
  349. + {
  350. + p.teleToLocation(new Location(83374, 148081, -3407),true);
  351. + }
  352. + setState(EventState.INACTIVE);
  353. + }
  354. +
  355. + public void delay(int delay)
  356. + {
  357. + try
  358. + {
  359. + Thread.sleep(delay);
  360. + }
  361. + catch (InterruptedException e)
  362. + {
  363. + // TODO Auto-generated catch block
  364. + e.printStackTrace();
  365. + }
  366. + }
  367. +
  368. + class Teleporting implements Runnable
  369. + {
  370. + Location teleTo;
  371. + List<L2PcInstance> toTeleport = new ArrayList<>();
  372. +
  373. + public Teleporting(List<L2PcInstance> toTeleport, Location teleTo)
  374. + {
  375. + this.teleTo = teleTo;
  376. + this.toTeleport = toTeleport;
  377. + }
  378. +
  379. + @Override
  380. + public void run()
  381. + {
  382. + if (eventPlayers.size() >= Config.BOSS_EVENT_MIN_PLAYERS)
  383. + {
  384. + despawnNpc(eventNpc);
  385. + setState(EventState.TELEPORTING);
  386. + announce("Event Started!", false);
  387. + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
  388. +
  389. + for (L2PcInstance p : toTeleport)
  390. + {
  391. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  392. + {
  393. +
  394. + @Override
  395. + public void run()
  396. + {
  397. + p.teleToLocation(teleTo, true);
  398. +
  399. + }
  400. + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  401. +
  402. + }
  403. + delay(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  404. + setState(EventState.WAITING);
  405. + startCountDown(Config.BOSS_EVENT_TIME_TO_WAIT, true);
  406. + ThreadPoolManager.getInstance().scheduleGeneral(new Fighting(bossId, teleTo), Config.BOSS_EVENT_TIME_TO_WAIT * 1000);
  407. +
  408. + }
  409. + else
  410. + {
  411. + announce("Event was cancelled due to lack of participation!", false);
  412. + setState(EventState.INACTIVE);
  413. + despawnNpc(eventNpc);
  414. + eventPlayers.clear();
  415. + objectId = 0;
  416. +
  417. + }
  418. +
  419. + }
  420. +
  421. + }
  422. +
  423. + public void reward(L2PcInstance p, Map<Integer, Integer> rewardType)
  424. + {
  425. +
  426. + for (Map.Entry<Integer, Integer> entry : rewardType.entrySet())
  427. + {
  428. + p.addItem("BossEventReward", entry.getKey(), entry.getValue(), null, true);
  429. + }
  430. +
  431. + }
  432. +
  433. + public void rewardPlayers()
  434. + {
  435. + for (L2PcInstance p : eventPlayers)
  436. + {
  437. + if (p.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
  438. + {
  439. + reward(p, generalRewards);
  440. + }
  441. + else
  442. + {
  443. + p.sendPacket(new ExShowScreenMessage("You didn't caused min damage to receive rewards!", 5000));
  444. + p.sendMessage("You didn't caused min damage to receive rewards! Min. Damage: " + Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD + ". Your Damage: " + p.getBossEventDamage());
  445. + }
  446. + }
  447. +
  448. + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
  449. + {
  450. + if (getMainDamageDealer() != null)
  451. + {
  452. + reward(getMainDamageDealer(), mainDamageDealerRewards);
  453. + getMainDamageDealer().sendMessage("Congratulations, you was the damage dealer! So you will receive wonderful rewards.");
  454. + //getMainDamageDealer().sendChatMessage(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the damage dealer! So you will receive wonderful rewards.");
  455. + }
  456. +
  457. + }
  458. + }
  459. +
  460. + public void finishEvent()
  461. + {
  462. + started = false;
  463. + // if (!AdminBossEvent.manual)
  464. + // {
  465. + NextBossEvent.getInstance().startCalculationOfNextEventTime();
  466. + // }
  467. + // else
  468. + // {
  469. + // AdminBossEvent.manual = false;
  470. + // }
  471. + rewardPlayers();
  472. + if (bossKilled) announce(bossName + " has been defeated!", false);
  473. + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
  474. + {
  475. + if (lastAttacker != null)
  476. + {
  477. + announce("LastAttacker: " + lastAttacker.getName(), false);
  478. + }
  479. + }
  480. +
  481. + if (Config.BOSS_EVENT_REWARD_MAIN_DAMAGE_DEALER)
  482. + {
  483. + if (getMainDamageDealer() != null)
  484. + {
  485. + announce("Main Damage Dealer: " + getMainDamageDealer().getName() + ". Total Damage = " + getMainDamageDealer().getBossEventDamage(), false);
  486. + }
  487. + }
  488. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  489. + {
  490. +
  491. + @Override
  492. + public void run()
  493. + {
  494. + teleToTown();
  495. + eventPlayers.clear();
  496. +
  497. + }
  498. + }, Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS * 1000);
  499. +
  500. + setState(EventState.FINISHING);
  501. + startCountDown(Config.BOSS_EVENT_TIME_TO_TELEPORT_PLAYERS, true);
  502. + if (despawnBoss != null)
  503. + {
  504. + despawnBoss.cancel(true);
  505. + despawnBoss = null;
  506. + }
  507. + objectId = 0;
  508. +
  509. + }
  510. +
  511. + class Fighting implements Runnable
  512. + {
  513. + int bossId;
  514. + Location spawnLoc;
  515. +
  516. + public Fighting(int bossId, Location spawnLoc)
  517. + {
  518. + this.bossId = bossId;
  519. + this.spawnLoc = spawnLoc;
  520. + }
  521. +
  522. + @Override
  523. + public void run()
  524. + {
  525. + if (spawnNpc(bossId, loc.getX(), loc.getY(), loc.getZ()))
  526. + {
  527. + setState(EventState.FIGHTING);
  528. + if (Config.BOSS_EVENT_TIME_ON_SCREEN)
  529. + {
  530. + startCountDown(Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS, true);
  531. + }
  532. + despawnBoss = ThreadPoolManager.getInstance().scheduleGeneral(new DespawnBossTask(bossSpawn), Config.BOSS_EVENT_TIME_TO_DESPAWN_BOSS * 1000);
  533. + objectId = bossSpawn.getLastSpawn().getObjectId();
  534. + for (L2PcInstance p : eventPlayers)
  535. + {
  536. + p.sendPacket(new ExShowScreenMessage("Boss " + bossSpawn.getLastSpawn().getName() + " has been spawned. Go and Defeat him!", 5000));
  537. + }
  538. +
  539. + }
  540. +
  541. + }
  542. +
  543. + }
  544. +
  545. + public void despawnNpc(L2Spawn spawn)
  546. + {
  547. + if (spawn != null)
  548. + {
  549. + spawn.getLastSpawn().deleteMe();
  550. + spawn.stopRespawn();
  551. + SpawnTable.getInstance().deleteSpawn(spawn, true);
  552. + }
  553. +
  554. + }
  555. +
  556. + class DespawnBossTask implements Runnable
  557. + {
  558. + L2Spawn spawn;
  559. +
  560. + public DespawnBossTask(L2Spawn spawn)
  561. + {
  562. + this.spawn = spawn;
  563. + }
  564. +
  565. + @Override
  566. + public void run()
  567. + {
  568. + if (spawn != null)
  569. + {
  570. + announceScreen("Your time is over " + spawn.getLastSpawn().getName() + " returned to his home!", true);
  571. + announce("Your time is over " + spawn.getLastSpawn().getName() + " returned to his home!", true);
  572. + announce("You will be teleported to town.", true);
  573. + despawnNpc(spawn);
  574. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  575. + {
  576. +
  577. + @Override
  578. + public void run()
  579. + {
  580. + teleToTown();
  581. + eventPlayers.clear();
  582. + setState(EventState.INACTIVE);
  583. + objectId = 0;
  584. +
  585. + }
  586. + }, 10000);
  587. + }
  588. + }
  589. +
  590. + }
  591. +
  592. + public void startRegistration()
  593. + {
  594. + try
  595. + {
  596. + resetPlayersDamage();
  597. + bossKilled = false;
  598. + bossList = Config.BOSS_EVENT_ID;
  599. + bossId = bossList.get(Rnd.get(bossList.size()));
  600. + locList = Config.BOSS_EVENT_LOCATION;
  601. + loc = locList.get(Rnd.get(locList.size()));
  602. + if (NpcTable.getInstance().getTemplate(bossId) != null)
  603. + {
  604. + startTime = System.currentTimeMillis() + Config.BOSS_EVENT_REGISTRATION_TIME * 1000;
  605. + eventNpc = spawnEventNpc(Config.BOSS_EVENT_NPC_REGISTER_LOC._x, Config.BOSS_EVENT_NPC_REGISTER_LOC._y, Config.BOSS_EVENT_NPC_REGISTER_LOC._z);
  606. + generalRewards = Config.BOSS_EVENT_GENERAL_REWARDS;
  607. + lastAttackerRewards = Config.BOSS_EVENT_LAST_ATTACKER_REWARDS;
  608. + mainDamageDealerRewards = Config.BOSS_EVENT_MAIN_DAMAGE_DEALER_REWARDS;
  609. + started = true;
  610. + aborted = false;
  611. + bossName = NpcTable.getInstance().getTemplate(bossId).getName();
  612. + setState(EventState.REGISTRATION);
  613. + announce("Registration started!", false);
  614. + announce("Joinable in giran or use command \".bossevent\" to register to event", false);
  615. + startCountDown(Config.BOSS_EVENT_REGISTRATION_TIME, false);
  616. +
  617. + ThreadPoolManager.getInstance().scheduleGeneral(new Teleporting(eventPlayers, loc), Config.BOSS_EVENT_REGISTRATION_TIME * 1000);
  618. +
  619. + }
  620. + else
  621. + {
  622. + _log.warning(getClass().getName() + ": cannot be started. Invalid BossId: " + bossList);
  623. + return;
  624. + }
  625. + }
  626. + catch (Exception e)
  627. + {
  628. + _log.warning("[Boss Event]: Couldn't be started");
  629. + e.printStackTrace();
  630. + }
  631. +
  632. + }
  633. +
  634. + public int timeInMillisToStart()
  635. + {
  636. + return (int) (startTime - System.currentTimeMillis()) / 1000;
  637. + }
  638. +
  639. + public void startCountDownEnterWorld(L2PcInstance player)
  640. + {
  641. + if (getState() == EventState.REGISTRATION)
  642. + {
  643. + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(player, timeInMillisToStart(), getState()), 0);
  644. + }
  645. + }
  646. +
  647. + public boolean spawnNpc(int npcId, int x, int y, int z)
  648. + {
  649. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(npcId);
  650. + try
  651. + {
  652. + bossSpawn = new L2Spawn(tmpl);
  653. +
  654. + bossSpawn.setLocx(x);
  655. + bossSpawn.setLocy(y);
  656. + bossSpawn.setLocz(z);
  657. + bossSpawn.setRespawnDelay(1);
  658. +
  659. + SpawnTable.getInstance().addNewSpawn(bossSpawn, false);
  660. +
  661. + bossSpawn.doSpawn();
  662. + bossSpawn.getLastSpawn().isAggressive();
  663. + bossSpawn.getLastSpawn().decayMe();
  664. + bossSpawn.getLastSpawn().spawnMe(bossSpawn.getLastSpawn().getX(), bossSpawn.getLastSpawn().getY(), bossSpawn.getLastSpawn().getZ());
  665. + bossSpawn.getLastSpawn().broadcastPacket(new MagicSkillUser(bossSpawn.getLastSpawn(), bossSpawn.getLastSpawn(), 1034, 1, 1, 1));
  666. + return true;
  667. + }
  668. + catch (Exception e)
  669. + {
  670. + e.printStackTrace();
  671. + return false;
  672. + }
  673. + }
  674. +
  675. + public void resetPlayersDamage()
  676. + {
  677. + for (L2PcInstance p : L2World.getInstance().getAllPlayers())
  678. + {
  679. + p.setBossEventDamage(0);
  680. + }
  681. + }
  682. +
  683. + public L2Spawn spawnEventNpc(int x, int y, int z)
  684. + {
  685. + L2Spawn spawn = null;
  686. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.BOSS_EVENT_REGISTRATION_NPC_ID);
  687. + try
  688. + {
  689. + spawn = new L2Spawn(tmpl);
  690. + spawn.setLocx(x);
  691. + spawn.setLocy(y);
  692. + spawn.setLocz(z);
  693. + spawn.setRespawnDelay(1);
  694. + spawn.setAmount(1);
  695. + SpawnTable.getInstance().addNewSpawn(spawn, false);
  696. + spawn.doSpawn();
  697. + spawn.getLastSpawn().isAggressive();
  698. + spawn.getLastSpawn().decayMe();
  699. + spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
  700. + spawn.getLastSpawn().broadcastPacket(new MagicSkillUser(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
  701. +
  702. +
  703. + return spawn;
  704. + }
  705. + catch (Exception e)
  706. + {
  707. + e.printStackTrace();
  708. + return spawn;
  709. + }
  710. + }
  711. +
  712. + public final L2PcInstance getMainDamageDealer()
  713. + {
  714. + int dmg = 0;
  715. + L2PcInstance mainDamageDealer = null;
  716. + for (L2PcInstance p : eventPlayers)
  717. + {
  718. + if (p.getBossEventDamage() > dmg)
  719. + {
  720. + dmg = p.getBossEventDamage();
  721. + mainDamageDealer = p;
  722. + }
  723. + }
  724. + return mainDamageDealer;
  725. + }
  726. +
  727. + public static BossEvent getInstance()
  728. + {
  729. + return SingleTonHolder._instance;
  730. + }
  731. +
  732. + private static class SingleTonHolder
  733. + {
  734. + protected static final BossEvent _instance = new BossEvent();
  735. + }
  736. +
  737. + public void startCountDown(int time, boolean eventOnly)
  738. + {
  739. + Collection<L2PcInstance> players = new ArrayList<>();
  740. + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
  741. + for (L2PcInstance player : players)
  742. + {
  743. + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(player, time, getState()), 0L);
  744. + }
  745. +
  746. + }
  747. +
  748. + public void announce(String text, boolean eventOnly)
  749. + {
  750. + Collection<L2PcInstance> players = new ArrayList<>();
  751. + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
  752. + for (L2PcInstance player : players)
  753. + {
  754. + player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text));
  755. + }
  756. + }
  757. +
  758. + public void announceScreen(String text, boolean eventOnly)
  759. + {
  760. + Collection<L2PcInstance> players = new ArrayList<>();
  761. + players = eventOnly ? eventPlayers : L2World.getInstance().getAllPlayers();
  762. + for (L2PcInstance player : players)
  763. + {
  764. + player.sendPacket(new ExShowScreenMessage(text, 4000));
  765. + }
  766. + }
  767. +
  768. + /**
  769. + * @return the state
  770. + */
  771. + public EventState getState()
  772. + {
  773. + return state;
  774. + }
  775. +
  776. + /**
  777. + * @param state the state to set
  778. + */
  779. + public void setState(EventState state)
  780. + {
  781. + this.state = state;
  782. + }
  783. +
  784. + /**
  785. + * @return the lastAttacker
  786. + */
  787. + public L2PcInstance getLastAttacker()
  788. + {
  789. + return lastAttacker;
  790. + }
  791. +
  792. + /**
  793. + * @param lastAttacker the lastAttacker to set
  794. + */
  795. + public void setLastAttacker(L2PcInstance lastAttacker)
  796. + {
  797. + this.lastAttacker = lastAttacker;
  798. + }
  799. +
  800. + protected class Countdown implements Runnable
  801. + {
  802. + private final L2PcInstance _player;
  803. + private final int _time;
  804. + private String text = "";
  805. + EventState evtState;
  806. +
  807. + public Countdown(L2PcInstance player, int time, EventState evtState)
  808. + {
  809. + _time = time;
  810. + _player = player;
  811. + switch (evtState)
  812. + {
  813. + case REGISTRATION:
  814. + text = "Boss Event registration ends in: ";
  815. + break;
  816. + case TELEPORTING:
  817. + text = "You will be teleported to Boss Event in: ";
  818. + break;
  819. + case WAITING:
  820. + text = "Boss will spawn in: ";
  821. + break;
  822. + case FINISHING:
  823. + text = "You will be teleported to City in: ";
  824. + break;
  825. + }
  826. + this.evtState = evtState;
  827. + }
  828. +
  829. + @Override
  830. + public void run()
  831. + {
  832. + if (getState() == EventState.INACTIVE)
  833. + {
  834. + return;
  835. + }
  836. + if (_player.isOnline() == 1)
  837. + {
  838. + switch (evtState)
  839. + {
  840. + case REGISTRATION:
  841. + case TELEPORTING:
  842. + case WAITING:
  843. + case FINISHING:
  844. + switch (_time)
  845. + {
  846. +
  847. + case 60:
  848. + case 120:
  849. + case 180:
  850. + case 240:
  851. + case 300:
  852. + _player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time / 60 + " minute(s)"));
  853. + break;
  854. + case 45:
  855. + case 30:
  856. + case 15:
  857. + case 10:
  858. + case 5:
  859. + case 4:
  860. + case 3:
  861. + case 2:
  862. + case 1:
  863. + _player.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", text + _time + " second(s)"));
  864. + break;
  865. +
  866. + }
  867. + if (_time > 1)
  868. + {
  869. + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(_player, _time - 1, evtState), 1000L);
  870. + }
  871. + break;
  872. + case FIGHTING:
  873. + int minutes = _time / 60;
  874. + int second = _time % 60;
  875. + String timing = ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((second < 10) ? ("0" + second) : second);
  876. +
  877. + _player.sendPacket(new ExShowScreenMessage("Time Left: " + timing, 1100, SMPOS.BOTTOM_RIGHT, true));
  878. + if (_time > 1)
  879. + {
  880. + ThreadPoolManager.getInstance().scheduleGeneral(new Countdown(_player, _time - 1, evtState), 1000L);
  881. + }
  882. + break;
  883. + }
  884. +
  885. + }
  886. + }
  887. + }
  888. +
  889. +}
  890. \ No newline at end of file
  891. diff --git a/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java b/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java
  892. new file mode 100644
  893. index 0000000..43933f5
  894. --- /dev/null
  895. +++ b/head-src/com/l2jfrozen/gameserver/managers/NextBossEvent.java
  896. @@ -0,0 +1,95 @@
  897. +package com.l2jfrozen.gameserver.managers;
  898. +
  899. +import java.text.SimpleDateFormat;
  900. +import java.util.Calendar;
  901. +import java.util.concurrent.ScheduledFuture;
  902. +import java.util.logging.Logger;
  903. +
  904. +import com.l2jfrozen.Config;
  905. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  906. +
  907. +public class NextBossEvent
  908. +{
  909. + private static NextBossEvent _instance = null;
  910. + protected static final Logger _log = Logger.getLogger(NextBossEvent.class.getName());
  911. + private Calendar nextEvent;
  912. + private final SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  913. + public ScheduledFuture<?> task = null;
  914. +
  915. + public static NextBossEvent getInstance()
  916. + {
  917. + if (_instance == null)
  918. + {
  919. + _instance = new NextBossEvent();
  920. + }
  921. + return _instance;
  922. + }
  923. +
  924. + public String getNextTime()
  925. + {
  926. + if (nextEvent.getTime() != null)
  927. + {
  928. + return format.format(nextEvent.getTime());
  929. + }
  930. + return "Erro";
  931. + }
  932. +
  933. + public void startCalculationOfNextEventTime()
  934. + {
  935. + try
  936. + {
  937. + Calendar currentTime = Calendar.getInstance();
  938. + Calendar testStartTime = null;
  939. + long flush2 = 0L;
  940. + long timeL = 0L;
  941. + int count = 0;
  942. + for (String timeOfDay : Config.BOSS_EVENT_BY_TIME_OF_DAY)
  943. + {
  944. + testStartTime = Calendar.getInstance();
  945. + testStartTime.setLenient(true);
  946. + String[] splitTimeOfDay = timeOfDay.split(":");
  947. + testStartTime.set(11, Integer.parseInt(splitTimeOfDay[0]));
  948. + testStartTime.set(12, Integer.parseInt(splitTimeOfDay[1]));
  949. + testStartTime.set(13, 0);
  950. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  951. + {
  952. + testStartTime.add(5, 1);
  953. + }
  954. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  955. + if (count == 0)
  956. + {
  957. + flush2 = timeL;
  958. + nextEvent = testStartTime;
  959. + }
  960. + if (timeL < flush2)
  961. + {
  962. + flush2 = timeL;
  963. + nextEvent = testStartTime;
  964. + }
  965. + count++;
  966. + }
  967. + _log.info("[Boss Event]: Next Event Time -> " + nextEvent.getTime().toString());
  968. + ThreadPoolManager.getInstance().scheduleGeneral(new StartEventTask(), flush2);
  969. + }
  970. + catch (Exception e)
  971. + {
  972. + System.out.println("[Boss Event]: " + e);
  973. + }
  974. + }
  975. +
  976. + class StartEventTask implements Runnable
  977. + {
  978. + StartEventTask()
  979. + {
  980. + }
  981. +
  982. + @Override
  983. + public void run()
  984. + {
  985. + NextBossEvent._log.info("----------------------------------------------------------------------------");
  986. + NextBossEvent._log.info("[Boss Event]: Event Started.");
  987. + NextBossEvent._log.info("----------------------------------------------------------------------------");
  988. + BossEvent.getInstance().startRegistration();
  989. + }
  990. + }
  991. +}
  992. \ No newline at end of file
  993. diff --git a/head-src/com/l2jfrozen/gameserver/model/L2Character.java b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  994. index 3bc645a..78939bb 100644
  995. --- a/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  996. +++ b/head-src/com/l2jfrozen/gameserver/model/L2Character.java
  997. @@ -53,6 +53,8 @@
  998. import com.l2jfrozen.gameserver.handler.ISkillHandler;
  999. import com.l2jfrozen.gameserver.handler.SkillHandler;
  1000. import com.l2jfrozen.gameserver.handler.itemhandlers.Potions;
  1001. +import com.l2jfrozen.gameserver.managers.BossEvent;
  1002. +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
  1003. import com.l2jfrozen.gameserver.managers.BotsPreventionManager;
  1004. import com.l2jfrozen.gameserver.managers.DimensionalRiftManager;
  1005. import com.l2jfrozen.gameserver.managers.DuelManager;
  1006. @@ -99,6 +101,7 @@
  1007. import com.l2jfrozen.gameserver.model.zone.type.L2BossZone;
  1008. import com.l2jfrozen.gameserver.model.zone.type.L2TownZone;
  1009. import com.l2jfrozen.gameserver.network.SystemMessageId;
  1010. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  1011. import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  1012. import com.l2jfrozen.gameserver.network.serverpackets.Attack;
  1013. import com.l2jfrozen.gameserver.network.serverpackets.BeginRotation;
  1014. @@ -106,6 +109,7 @@
  1015. import com.l2jfrozen.gameserver.network.serverpackets.ChangeWaitType;
  1016. import com.l2jfrozen.gameserver.network.serverpackets.CharInfo;
  1017. import com.l2jfrozen.gameserver.network.serverpackets.CharMoveToLocation;
  1018. +import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
  1019. import com.l2jfrozen.gameserver.network.serverpackets.ExOlympiadSpelledInfo;
  1020. import com.l2jfrozen.gameserver.network.serverpackets.L2GameServerPacket;
  1021. import com.l2jfrozen.gameserver.network.serverpackets.MagicEffectIcons;
  1022. @@ -2293,6 +2297,34 @@
  1023. {
  1024. BotsPreventionManager.getInstance().updatecounter(killer,this);
  1025. }
  1026. + if (BossEvent.getInstance().getState() == EventState.FIGHTING)
  1027. + {
  1028. + if (BossEvent.getInstance().bossSpawn.getLastSpawn() == this)
  1029. + {
  1030. + BossEvent.getInstance().finishEvent();
  1031. + BossEvent.getInstance().bossKilled = true;
  1032. + if (killer instanceof L2PcInstance)
  1033. + {
  1034. + L2PcInstance lastAttacker = killer.getActingPlayer();
  1035. + BossEvent.getInstance().setLastAttacker(lastAttacker);
  1036. + LOGGER.info("Boss Event Finished. Last Attacker : " + lastAttacker.getName());
  1037. + LOGGER.info("Players rewarded: " + BossEvent.getInstance().eventPlayers.size());
  1038. + if (Config.BOSS_EVENT_REWARD_LAST_ATTACKER)
  1039. + {
  1040. +
  1041. + if (lastAttacker.getBossEventDamage() > Config.BOSS_EVENT_MIN_DAMAGE_TO_OBTAIN_REWARD)
  1042. + {
  1043. + BossEvent.getInstance().reward(lastAttacker, Config.BOSS_EVENT_LAST_ATTACKER_REWARDS);
  1044. + lastAttacker.sendPacket(new CreatureSay(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards."));
  1045. + //lastAttacker.sendChatMessage(0, Say2.CRITICAL_ANNOUNCE, "[Boss Event]", "Congratulations, you was the last attacker! So you will receive wonderful rewards.");
  1046. +
  1047. + }
  1048. +
  1049. + }
  1050. + }
  1051. +
  1052. + }
  1053. + }
  1054. // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
  1055. broadcastStatusUpdate();
  1056.  
  1057. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java
  1058. new file mode 100644
  1059. index 0000000..4e34195
  1060. --- /dev/null
  1061. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2BossEventInstance.java
  1062. @@ -0,0 +1,95 @@
  1063. +package com.l2jfrozen.gameserver.model.actor.instance;
  1064. +
  1065. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  1066. +import com.l2jfrozen.gameserver.managers.BossEvent;
  1067. +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
  1068. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  1069. +import com.l2jfrozen.gameserver.network.serverpackets.MoveToPawn;
  1070. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  1071. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  1072. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  1073. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  1074. +
  1075. +public class L2BossEventInstance extends L2NpcInstance
  1076. +{
  1077. + /**
  1078. + * @param objectId
  1079. + * @param template
  1080. + */
  1081. + public L2BossEventInstance(int objectId, L2NpcTemplate template)
  1082. + {
  1083. + super(objectId, template);
  1084. + // TODO Auto-generated constructor stub
  1085. + }
  1086. +
  1087. + @Override
  1088. + public void onAction(L2PcInstance player)
  1089. + {
  1090. + if (this != player.getTarget())
  1091. + {
  1092. + player.setTarget(this);
  1093. + player.sendPacket(new MyTargetSelected(getObjectId(), 0));
  1094. + player.sendPacket(new ValidateLocation(this));
  1095. + }
  1096. + else
  1097. + {
  1098. + if (!canInteract(player))
  1099. + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  1100. + else
  1101. + {
  1102. + // Rotate the player to face the instance
  1103. + player.sendPacket(new MoveToPawn(player, this, L2NpcInstance.INTERACTION_DISTANCE));
  1104. +
  1105. + if (hasRandomAnimation())
  1106. + onRandomAnimation();
  1107. +
  1108. + showMainWindow(player);
  1109. +
  1110. + // Send ActionFailed to the player in order to avoid he stucks
  1111. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1112. + }
  1113. + }
  1114. + }
  1115. +
  1116. + private void showMainWindow(L2PcInstance player)
  1117. + {
  1118. +
  1119. + NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  1120. + html.setFile("data/html/mods/BossEvent.htm");
  1121. + html.replace("%objectId%", String.valueOf(getObjectId()));
  1122. + html.replace("%npcname%", getName());
  1123. + html.replace("%regCount%", String.valueOf(BossEvent.getInstance().eventPlayers.size()));
  1124. + player.sendPacket(html);
  1125. + }
  1126. +
  1127. + @Override
  1128. + public void onBypassFeedback(L2PcInstance activeChar, String command)
  1129. + {
  1130. +
  1131. + super.onBypassFeedback(activeChar, command);
  1132. + if (command.startsWith("register"))
  1133. + {
  1134. + if (BossEvent.getInstance().getState() != EventState.REGISTRATION)
  1135. + {
  1136. + activeChar.sendMessage("Boss Event is not running!");
  1137. + return;
  1138. + }
  1139. + if (!BossEvent.getInstance().isRegistered(activeChar))
  1140. + {
  1141. + if (BossEvent.getInstance().addPlayer(activeChar))
  1142. + {
  1143. + activeChar.sendMessage("You have been successfully registered in Boss Event!");
  1144. + }
  1145. +
  1146. + }
  1147. + else
  1148. + {
  1149. + if (BossEvent.getInstance().removePlayer(activeChar))
  1150. + {
  1151. + activeChar.sendMessage("You have been successfully removed of Boss Event!");
  1152. + }
  1153. + }
  1154. + }
  1155. + }
  1156. +
  1157. +}
  1158. \ No newline at end of file
  1159. diff --git a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  1160. index 7498ee2..e749d0e 100644
  1161. --- a/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  1162. +++ b/head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  1163. @@ -86,6 +86,8 @@
  1164. import com.l2jfrozen.gameserver.handler.skillhandlers.SiegeFlag;
  1165. import com.l2jfrozen.gameserver.handler.skillhandlers.StrSiegeAssault;
  1166. import com.l2jfrozen.gameserver.handler.skillhandlers.TakeCastle;
  1167. +import com.l2jfrozen.gameserver.managers.BossEvent;
  1168. +import com.l2jfrozen.gameserver.managers.BossEvent.EventState;
  1169. import com.l2jfrozen.gameserver.managers.CastleManager;
  1170. import com.l2jfrozen.gameserver.managers.CoupleManager;
  1171. import com.l2jfrozen.gameserver.managers.CursedWeaponsManager;
  1172. @@ -17941,7 +17943,13 @@
  1173. sendPacket(new SystemMessage(SystemMessageId.MISSED_TARGET));
  1174. return;
  1175. }
  1176. -
  1177. + if (BossEvent.getInstance().getState() == EventState.FIGHTING && BossEvent.getInstance().eventPlayers.contains(this))
  1178. + {
  1179. + if (target.getObjectId() == BossEvent.getInstance().objectId)
  1180. + {
  1181. + bossEventDamage += damage;
  1182. + }
  1183. + }
  1184. // Check if hit is critical
  1185. if (pcrit)
  1186. {
  1187. @@ -19720,6 +19728,22 @@
  1188. {
  1189. _nameChangeItemId = itemId;
  1190. }
  1191. + private int bossEventDamage = 0;
  1192. + /**
  1193. + * @return the bossEventDamage
  1194. + */
  1195. + public int getBossEventDamage()
  1196. + {
  1197. + return bossEventDamage;
  1198. + }
  1199. +
  1200. + /**
  1201. + * @param bossEventDamage the bossEventDamage to set
  1202. + */
  1203. + public void setBossEventDamage(int bossEventDamage)
  1204. + {
  1205. + this.bossEventDamage = bossEventDamage;
  1206. + }
  1207. //inicio classitem
  1208. private int _classChangeItemId = 0;
  1209.  
  1210.  
  1211. diff --git a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  1212. index b9f83d0..436a078 100644
  1213. --- a/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  1214. +++ b/head-src/com/l2jfrozen/gameserver/handler/VoicedCommandHandler.java
  1215. @@ -30,6 +30,7 @@
  1216. import com.l2jfrozen.gameserver.GameServer;
  1217. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.AwayCmd;
  1218. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BankingCmd;
  1219. +import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BossEventCMD;
  1220. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.BuffCommand;
  1221. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.CTFCmd;
  1222. import com.l2jfrozen.gameserver.handler.voicedcommandhandlers.DMCmd;
  1223. @@ -74,6 +75,7 @@
  1224. private VoicedCommandHandler()
  1225. {
  1226. _datatable = new FastMap<>();
  1227. + registerVoicedCommandHandler(new BossEventCMD());
  1228. registerVoicedCommandHandler(new Shiff_Mod());
  1229. registerVoicedCommandHandler(new Voting());
  1230. if(Config.ENABLE_COMMAND_XPON_OFF)
  1231.  
  1232. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement