Advertisement
Guest User

Engine aCis

a guest
Oct 29th, 2022
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 86.17 KB | None | 0 0
  1. diff --git a/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml b/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml
  2. new file mode 100644
  3. index 0000000..1403ec3
  4. --- /dev/null
  5. +++ b/L2jOne_C6_Interlude/data/xml/events/DeathMatch.xml
  6. @@ -0,0 +1,79 @@
  7. +<?xml version="1.0" encoding="UTF-8"?>
  8. +<!-- Death Match Event -->
  9. +<dm>
  10. + <!-- Times Death Match will occur (24h format) -->
  11. + <EventTimeInterval val="17:21" />
  12. +
  13. + <!-- Event duration time (in minutes) -->
  14. + <Duration val="10" />
  15. +
  16. + <!-- The minimum and maximum number of players to start the event -->
  17. + <Participants min="2" max="50" />
  18. +
  19. + <!-- The minimum and maximum level allowed to participate at the event -->
  20. + <Level min="76" max="85" />
  21. +
  22. + <!-- Time for registration (in minutes) -->
  23. + <TimeToRegistration val="10" />
  24. +
  25. + <!-- Time for registration (in seconds) -->
  26. + <TimeToTeleport val="10" />
  27. +
  28. + <!-- Require item to register in the event? -->
  29. + <AllowTakeItems val="false" />
  30. + <!-- Item ID and Count required to register -->
  31. + <TakeItems id="57" count="100000" />
  32. +
  33. + <!-- Allow give reward for kill? -->
  34. + <AllowKillBonus val="false" />
  35. + <!-- Reward ID and Count for each kill -->
  36. + <KillReward id="57" count="100000" />
  37. +
  38. + <!-- Coordinates where the players will spawn -->
  39. + <PlayerEventCoordinates x="-213471" y="244903" z="2021" h="32768" />
  40. +
  41. + <!-- Stop all effects at the start of the event? -->
  42. + <StopAllEffects val="true" />
  43. +
  44. + <!-- Hide the player names and titles at the event? -->
  45. + <HidePlayersIdentity val="true" />
  46. +
  47. + <!-- Enable / Disable the participation with multiple boxes -->
  48. + <AllowMultipleBoxes val="false" />
  49. +
  50. + <!-- Reward ID and Count for the winner. For multiple rewards separate with (,) -->
  51. + <Rewards1stPlace id="3470,9627,6673" count="25,3,1" />
  52. +
  53. + <!-- Reward ID and Count for the second place. For multiple rewards separate with (,) -->
  54. + <Rewards2ndPlace id="3470,9627,6673" count="15,2,1" />
  55. +
  56. + <!-- Reward ID and Count for the third place. For multiple rewards separate with (,) -->
  57. + <Rewards3rdPlace id="3470,9627,6673" count="5,1,1" />
  58. +
  59. + <!-- Reward in case of tie? -->
  60. + <RewardTie val="true" />
  61. +
  62. + <!-- List of buffs given to the players, separate with (,) -->
  63. + <ListMageSupport val="1078,1085,1303,1517,1518,1519,1535,1536,1537,1538" />
  64. + <ListFighterSupport val="1499,1500,1501,1502,1503,1504,1517" />
  65. +
  66. + <!-- List of the restricted items on the event, separate with (,) -->
  67. + <!--<RestrictItems val="" />-->
  68. +
  69. + <!-- List of the restricted skills on the event, separate with (,) -->
  70. + <!--<RestrictSkills val="" />-->
  71. +
  72. + <!-- Allow player to use potions during the event? -->
  73. + <AllowPotions val="false" />
  74. +
  75. + <!-- Allow player to use scrolls during the event? -->
  76. + <AllowScrolls val="false" />
  77. +
  78. + <!-- Allow player to use summons by items during the event? -->
  79. + <AllowSummonByItem val="false" />
  80. +
  81. + <!-- Require a minimal amount of kills to receive the reward? -->
  82. + <RequireMinFragsToReward val="false" />
  83. + <!-- Minimal amount of kills to receive the reward -->
  84. + <MinFragsRequired val="1" />
  85. +</dm>
  86. \ No newline at end of file
  87. diff --git a/L2jOne_C6_Interlude/data/xml/events/TvT.xml b/L2jOne_C6_Interlude/data/xml/events/TvT.xml
  88. new file mode 100644
  89. index 0000000..530e237
  90. --- /dev/null
  91. +++ b/L2jOne_C6_Interlude/data/xml/events/TvT.xml
  92. @@ -0,0 +1,84 @@
  93. +<?xml version='1.0' encoding='utf-8'?>
  94. +<!-- TvT Event -->
  95. +<tvt>
  96. + <!-- Times TvT will occur (24h format) -->
  97. + <EventTimeInterval val="18:11" />
  98. +
  99. + <!-- Event duration time (in minutes) -->
  100. + <Duration val="1" />
  101. +
  102. + <!-- The minimum and maximum number of players to start the event -->
  103. + <Participants min="5" max="250" />
  104. +
  105. + <!-- The minimum and maximum level allowed to participate at the event -->
  106. + <Level min="76" max="85" />
  107. +
  108. + <!-- Time for registration (in minutes) -->
  109. + <TimeToRegistration val="10" />
  110. +
  111. + <!-- Time for registration (in seconds) -->
  112. + <TimeToTeleport val="10" />
  113. +
  114. + <!-- Require item to register in the event? -->
  115. + <AllowTakeItems val="true" />
  116. + <!-- Item ID and Count required to register -->
  117. + <TakeItems id="57" count="100000" />
  118. +
  119. + <!-- Allow give reward for kill? -->
  120. + <AllowKillBonus val="false" />
  121. + <!-- Reward ID and Count for each kill -->
  122. + <KillReward id="57" count="100000" />
  123. +
  124. + <!-- Stop all effects at the start of the event? -->
  125. + <StopAllEffects val="true" />
  126. +
  127. + <!-- Hide the player names and titles at the event? -->
  128. + <HidePlayersIdentity val="true" />
  129. +
  130. + <!-- Team ids, colors, names and coordinates. Min. 2 teams -->
  131. + <Team id="1" name="Green" color="009933" coordinates="-84640,-45360,-10683,-9380" />
  132. + <Team id="2" name="Blue" color="CC6600" coordinates="-79120,-45440,-10683,-23248" />
  133. + <Team id="3" name="Red" color="000099" coordinates="-77408,-50656,-10683,29664" />
  134. + <Team id="4" name="Orange" color="0099FF" coordinates="-81904,-53904,-10683,17044" />
  135. + <Team id="5" name="Yellow" color="00CCFF" coordinates="-86359,-50593,-10649,3704" />
  136. +
  137. + <!-- Reward ID and Count for the players of the winner team. For multiple rewards separate with (,) -->
  138. + <Rewards id="3470,9627,6673" count="10,1,1" />
  139. +
  140. + <!-- Reward all winner teams in case of tie? -->
  141. + <RewardTeamTie val="true" />
  142. +
  143. + <!-- List of buffs given to the players, separate with (,) -->
  144. + <ListMageSupport val="1078,1085,1303,1517,1518,1519,1535,1536,1537,1538" />
  145. + <ListFighterSupport val="1499,1500,1501,1502,1503,1504,1517" />
  146. +
  147. + <!-- List of the restricted items on the event, separate with (,) -->
  148. + <!--<RestrictItems val="" />-->
  149. +
  150. + <!-- List of the restricted skills on the event, separate with (,) -->
  151. + <!--<RestrictSkills val="" />-->
  152. +
  153. + <!-- Allow player to use potions during the event? -->
  154. + <AllowPotions val="false" />
  155. +
  156. + <!-- Allow player to use scrolls during the event? -->
  157. + <AllowScrolls val="false" />
  158. +
  159. + <!-- Allow player to use summons by items during the event? -->
  160. + <AllowSummonByItem val="false" />
  161. +
  162. + <!-- Allow player to target team members during the event? -->
  163. + <AllowTargetTeamMembers val="false" />
  164. +
  165. + <!-- Require a minimal amount of kills to receive the reward? -->
  166. + <RequireMinFragsToReward val="true" />
  167. + <!-- Minimal amount of kills to receive the reward -->
  168. + <MinFragsRequired val="1" />
  169. +
  170. + <!-- In total there are 2 types of TvT: (1) The winning team is determined
  171. + by number of dead characters rivals. (2) The winning team is determined by number
  172. + of rounds won. In this case, you must use the <NumberOfRounds val="5"/> number
  173. + of rounds. Also the "Duration" in this case stands for each round! Do not
  174. + use together! -->
  175. + <NumberOfRounds val="1" />
  176. +</tvt>
  177. \ No newline at end of file
  178. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
  179. index c0e585c..e2069af 100644
  180. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
  181. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/actor/Player.java
  182. @@ -133,6 +133,7 @@
  183. import net.sf.l2j.gameserver.model.craft.ManufactureList;
  184. import net.sf.l2j.gameserver.model.entity.Castle;
  185. import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  186. +import net.sf.l2j.gameserver.model.gameevent.GameEvent;
  187. import net.sf.l2j.gameserver.model.group.CommandChannel;
  188. import net.sf.l2j.gameserver.model.group.Party;
  189. import net.sf.l2j.gameserver.model.group.PartyMatchRoom;
  190. @@ -463,6 +464,7 @@
  191. private final int[] _loto = new int[5];
  192. private final int[] _race = new int[2];
  193.  
  194. + private GameEvent _event;
  195. private TeamType _team = TeamType.NONE;
  196.  
  197. private int _alliedVarkaKetra; // lvl of alliance with ketra orcs or varka silenos, used in quests and aggro checks [-5,-1] varka, 0 neutral, [1,5] ketra
  198. @@ -2747,6 +2749,9 @@
  199. stopFakeDeath(true);
  200. }
  201.  
  202. + if (getEvent() != null)
  203. + getEvent().onKill(killer, this);
  204. +
  205. if (killer != null)
  206. {
  207. final Player pk = killer.getActingPlayer();
  208. @@ -6085,6 +6090,22 @@
  209. return _lvlJoinedAcademy > 0;
  210. }
  211.  
  212. + public void setEvent(GameEvent event)
  213. + {
  214. + _event = event;
  215. + }
  216. +
  217. + public GameEvent getEvent()
  218. + {
  219. + return _event;
  220. + }
  221. +
  222. + public boolean isInEvent()
  223. + {
  224. + final GameEvent event = getEvent();
  225. + return (event != null) && (event.isRunning() && event.isParticipant(getObjectId()));
  226. + }
  227. +
  228. public void setTeam(TeamType team)
  229. {
  230. _team = team;
  231. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java
  232. new file mode 100644
  233. index 0000000..74b7153
  234. --- /dev/null
  235. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEvent.java
  236. @@ -0,0 +1,499 @@
  237. +package net.sf.l2j.gameserver.model.gameevent;
  238. +
  239. +import java.util.Collection;
  240. +
  241. +import net.sf.l2j.commons.logging.CLogger;
  242. +import net.sf.l2j.commons.random.Rnd;
  243. +
  244. +import net.sf.l2j.gameserver.data.SkillTable;
  245. +import net.sf.l2j.gameserver.data.xml.DoorData;
  246. +import net.sf.l2j.gameserver.data.xml.ItemData;
  247. +import net.sf.l2j.gameserver.model.actor.Creature;
  248. +import net.sf.l2j.gameserver.model.actor.Npc;
  249. +import net.sf.l2j.gameserver.model.actor.Player;
  250. +import net.sf.l2j.gameserver.model.actor.instance.Door;
  251. +import net.sf.l2j.gameserver.model.gameevent.config.GameEventConfig;
  252. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  253. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  254. +import net.sf.l2j.gameserver.network.SystemMessageId;
  255. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  256. +import net.sf.l2j.gameserver.skills.L2Skill;
  257. +
  258. +public abstract class GameEvent
  259. +{
  260. + protected static final CLogger LOGGER = new CLogger(GameEvent.class.getName());
  261. +
  262. + public enum EventState
  263. + {
  264. + INACTIVE,
  265. + REGISTER,
  266. + STARTED,
  267. + REWARDING
  268. + }
  269. +
  270. + private EventState _state = EventState.INACTIVE;
  271. + protected String _eventName = "";
  272. +
  273. + public abstract GameEventConfig getConfigs();
  274. + public abstract void init();
  275. + protected abstract String calculateRewards();
  276. + protected abstract void teleportPlayersToArena();
  277. + protected abstract void teleportPlayersBack();
  278. + protected abstract void clear();
  279. + public abstract boolean isParticipant(int objectId);
  280. + public abstract int getCountPlayers();
  281. + public abstract boolean addParticipant(GameEventPlayer eventPlayer);
  282. + public abstract boolean removeParticipant(Player player);
  283. +
  284. + public abstract void sysMsgToAllParticipants(String message);
  285. +
  286. + public abstract void onKill(Creature killerCharacter, Player killedplayer);
  287. +
  288. + public abstract boolean onSkillUse(Player caster, L2Skill skill);
  289. +
  290. + public abstract void onLogin(Player player);
  291. +
  292. + public abstract boolean onAction(Player player, int targetObjectId);
  293. +
  294. + /**
  295. + * Gets the Game Event state
  296. + * @return EventState: _state
  297. + */
  298. + public EventState getState()
  299. + {
  300. + synchronized (_state)
  301. + {
  302. + return _state;
  303. + }
  304. + }
  305. +
  306. + /**
  307. + * Sets the Game Event state
  308. + * @param state as EventState
  309. + */
  310. + protected void setState(EventState state)
  311. + {
  312. + synchronized (_state)
  313. + {
  314. + _state = state;
  315. + }
  316. + }
  317. +
  318. + public String getName()
  319. + {
  320. + return _eventName;
  321. + }
  322. +
  323. + public boolean isInactive()
  324. + {
  325. + return getState() == EventState.INACTIVE;
  326. + }
  327. +
  328. + public boolean isRunning()
  329. + {
  330. + return getState() == EventState.STARTED;
  331. + }
  332. +
  333. + public boolean isRegistrating()
  334. + {
  335. + return getState() == EventState.REGISTER;
  336. + }
  337. +
  338. + /**
  339. + * Method called to check if a player can register at the event
  340. + * @param player as Player
  341. + * @param first as Integer
  342. + * @return boolean: true if the player can register, otherwise false
  343. + */
  344. + protected boolean canRegister(Player player, boolean first)
  345. + {
  346. + if (first && getConfigs().ALLOW_TAKE_ITEM)
  347. + {
  348. + if (player.getInventory().getItemCount(getConfigs().TAKE_ITEM_ID, -1) < getConfigs().TAKE_COUNT)
  349. + {
  350. + player.sendMessage("You don't have enough " + ItemData.getInstance().getTemplate(getConfigs().TAKE_ITEM_ID).getName() + " to participate.");
  351. + return false;
  352. + }
  353. + }
  354. +
  355. + if (first && !isRegistrating())
  356. + {
  357. + player.sendMessage("The registration process is not active.");
  358. + return false;
  359. + }
  360. +
  361. + if (first && isParticipant(player.getObjectId()))
  362. + {
  363. + player.sendMessage("You are already registred.");
  364. + return false;
  365. + }
  366. +
  367. + if (player.isTeleporting())
  368. + {
  369. + player.sendMessage("You are in a teleporting process.");
  370. + return false;
  371. + }
  372. +
  373. + if (!player.isOnline())
  374. + {
  375. + player.sendMessage("You have to be online to register.");
  376. + return false;
  377. + }
  378. +
  379. + if (player.isMounted())
  380. + {
  381. + player.sendMessage("Revoke your pet before register.");
  382. + return false;
  383. + }
  384. +
  385. + if (player.isInDuel())
  386. + {
  387. + player.sendMessage("You must complete the duel before register.");
  388. + return false;
  389. + }
  390. +
  391. + if (first && (player.getEvent() != null))
  392. + {
  393. + player.sendMessage("You are already registered in another event.");
  394. + return false;
  395. + }
  396. +
  397. + if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegistered(player))
  398. + {
  399. + player.sendMessage("You are already registered in the Olympics.");
  400. + return false;
  401. + }
  402. +
  403. + if (player.isInParty() && player.getParty().isInDimensionalRift())
  404. + {
  405. + player.sendMessage("You are already registered in another event.");
  406. + return false;
  407. + }
  408. +
  409. + if (player.isCursedWeaponEquipped())
  410. + {
  411. + player.sendMessage("You can't register to the event with a cursed weapon.");
  412. + return false;
  413. + }
  414. +
  415. + if (player.isDead())
  416. + {
  417. + player.sendMessage("You can't register while you are dead.");
  418. + return false;
  419. + }
  420. +
  421. + if (player.getKarma() > 0)
  422. + {
  423. + player.sendMessage("PK's can't participate in the opening event.");
  424. + return false;
  425. + }
  426. +
  427. + if ((player.getStatus().getLevel() < getConfigs().MIN_LEVEL) || (player.getStatus().getLevel() > getConfigs().MAX_LEVEL))
  428. + {
  429. + player.sendMessage("You are not eligible to participate in the opening event with this level.");
  430. + return false;
  431. + }
  432. +
  433. + if (first && (getCountPlayers() >= getConfigs().MAX_PARTICIPANTS))
  434. + {
  435. + player.sendMessage("The opening event has reached the maximum number of participants.");
  436. + return false;
  437. + }
  438. +
  439. + return true;
  440. + }
  441. +
  442. + /**
  443. + * Method called to start the event registration process
  444. + */
  445. + public void startRegistration()
  446. + {
  447. + setState(EventState.REGISTER);
  448. + }
  449. +
  450. + /**
  451. + * Method called to register a player in the event
  452. + * @param player as Player
  453. + * @return boolean: true if success, otherwise false
  454. + */
  455. + public boolean register(Player player)
  456. + {
  457. + if (player == null)
  458. + return false;
  459. +
  460. + if (!canRegister(player, true))
  461. + return false;
  462. +
  463. + final GameEventPlayer eventPlayer = new GameEventPlayer(player, getConfigs().PLAYER_CREDITS);
  464. +
  465. + if (getConfigs().ALLOW_TAKE_ITEM)
  466. + {
  467. + if (player.destroyItemByItemId("Event Participation Fee", getConfigs().TAKE_ITEM_ID, getConfigs().TAKE_COUNT, null, true))
  468. + {
  469. + if (addParticipant(eventPlayer))
  470. + return true;
  471. + }
  472. + }
  473. +
  474. + if (addParticipant(eventPlayer))
  475. + return true;
  476. +
  477. + return false;
  478. + }
  479. +
  480. + /**
  481. + * Method called to remove the player registration in the event
  482. + * @param player as Player
  483. + * @return boolean: true if success, otherwise false
  484. + */
  485. + public boolean unRegister(Player player)
  486. + {
  487. + if (player == null)
  488. + return false;
  489. +
  490. + if ((getState() == EventState.STARTED) || !isParticipant(player.getObjectId()))
  491. + {
  492. + player.sendMessage("You can't cancel your registration to the event at this moment!");
  493. + return false;
  494. + }
  495. +
  496. + if (removeParticipant(player))
  497. + {
  498. + player.sendMessage("Your registration at the " + _eventName + " Event was cancelled!");
  499. + return true;
  500. + }
  501. +
  502. + return false;
  503. + }
  504. +
  505. + /**
  506. + * Method called to start the event
  507. + * @return boolean: true if success, otherwise false
  508. + */
  509. + public boolean start()
  510. + {
  511. + if (getCountPlayers() >= getConfigs().MIN_PARTICIPANTS)
  512. + {
  513. + setState(EventState.STARTED);
  514. + closeDoors();
  515. + teleportPlayersToArena();
  516. + return true;
  517. + }
  518. + clear();
  519. + setState(EventState.INACTIVE);
  520. + return false;
  521. + }
  522. +
  523. + /**
  524. + * Method called to stop the running event
  525. + */
  526. + public void stop()
  527. + {
  528. + openDoors();
  529. + teleportPlayersBack();
  530. + clear();
  531. + setState(EventState.INACTIVE);
  532. + }
  533. +
  534. + /**
  535. + * Method used to close the instance door(s)
  536. + */
  537. + protected void closeDoors()
  538. + {
  539. + Collection<Door> doorsToClose = DoorData.getInstance().getDoors();
  540. +
  541. + for (Door door : doorsToClose)
  542. + {
  543. + if (door != null)
  544. + door.closeMe();
  545. + }
  546. + }
  547. +
  548. + /**
  549. + * Method used to open the instance door(s)
  550. + */
  551. + protected void openDoors()
  552. + {
  553. + Collection<Door> doorsToOpen = DoorData.getInstance().getDoors();
  554. +
  555. + for (Door door : doorsToOpen)
  556. + {
  557. + if (door != null)
  558. + door.openMe();
  559. + }
  560. + }
  561. +
  562. + /**
  563. + * Method called to put the kill rewards into the players inventory
  564. + * @param player as Player
  565. + */
  566. + protected void giveKillBonus(Player player)
  567. + {
  568. + SystemMessage systemMessage = null;
  569. +
  570. + player.addItem(_eventName, getConfigs().TAKE_ITEM_ID, getConfigs().TAKE_COUNT, player, true);
  571. +
  572. + if (getConfigs().TAKE_COUNT > 1)
  573. + {
  574. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  575. + systemMessage.addItemName(getConfigs().TAKE_ITEM_ID);
  576. + systemMessage.addItemNumber(getConfigs().TAKE_COUNT);
  577. + }
  578. + else
  579. + {
  580. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  581. + systemMessage.addItemName(getConfigs().TAKE_ITEM_ID);
  582. + }
  583. +
  584. + player.sendPacket(systemMessage);
  585. + }
  586. +
  587. + /**
  588. + * Method called to put the rewards into the players inventory
  589. + * @param player as Player
  590. + * @param rewards as Integer
  591. + */
  592. + protected void deliverRewards(Player player, int[][] rewards)
  593. + {
  594. + SystemMessage systemMessage = null;
  595. +
  596. + for (int[] reward : rewards)
  597. + {
  598. + player.getInventory().addItem(_eventName, reward[0], reward[1], player, player);
  599. +
  600. + if (reward[1] > 1)
  601. + {
  602. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  603. + systemMessage.addItemName(reward[0]);
  604. + systemMessage.addItemNumber(reward[1]);
  605. + }
  606. + else
  607. + {
  608. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  609. + systemMessage.addItemName(reward[0]);
  610. + }
  611. +
  612. + player.sendPacket(systemMessage);
  613. + }
  614. + }
  615. +
  616. + /**
  617. + * Method called on Appearing packet received (player finished teleporting)<br>
  618. + * Buff player's with event buffs
  619. + * @param player
  620. + */
  621. + public void onTeleported(Player player)
  622. + {
  623. + if (!isRunning() || (player == null) || !isParticipant(player.getObjectId()))
  624. + return;
  625. +
  626. + if ((getConfigs().LIST_MAGE_SUPPORT != null) && (getConfigs().LIST_MAGE_SUPPORT.length != 0) || (getConfigs().LIST_FIGHTER_SUPPORT != null) && (getConfigs().LIST_FIGHTER_SUPPORT.length != 0))
  627. + {
  628. + for (Integer skillId : player.isMageClass() ? getConfigs().LIST_MAGE_SUPPORT : getConfigs().LIST_FIGHTER_SUPPORT)
  629. + {
  630. + final L2Skill skill = SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId));
  631. + if (skill != null)
  632. + skill.getEffects(player, player);
  633. + }
  634. + }
  635. + }
  636. +
  637. + /**
  638. + * Called when a player logs out
  639. + * @param player as Player
  640. + */
  641. + public void onLogout(Player player)
  642. + {
  643. + if ((player != null) && (isRunning() || isRegistrating()))
  644. + {
  645. + if (removeParticipant(player))
  646. + player.setXYZInvisible((83447 + Rnd.get(101)) - 50, (148638 + Rnd.get(101)) - 50, -3400); // Giran
  647. + }
  648. + }
  649. +
  650. + /**
  651. + * Method called on every summon item use
  652. + * @param objectId as Integer
  653. + * @return boolean: true if player is allowed to summon by item, otherwise false
  654. + */
  655. + public boolean onItemSummon(int objectId)
  656. + {
  657. + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_SUMMON_BY_ITEM)
  658. + return false;
  659. +
  660. + return true;
  661. + }
  662. +
  663. + /**
  664. + * Method called on every Scroll use
  665. + * @param objectId as Integer
  666. + * @return boolean: true if player is allowed to use scroll, otherwise false
  667. + */
  668. + public boolean onScrollUse(int objectId)
  669. + {
  670. + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_SCROLLS)
  671. + return false;
  672. +
  673. + return true;
  674. + }
  675. +
  676. + /**
  677. + * Method called on every Potion use
  678. + * @param objectId as Integer
  679. + * @return boolean: true if player is allowed to use potion, otherwise false
  680. + */
  681. + public boolean onPotionUse(int objectId)
  682. + {
  683. + if (isRunning() && isParticipant(objectId) && !getConfigs().ALLOW_POTIONS)
  684. + return false;
  685. +
  686. + return true;
  687. + }
  688. +
  689. + /**
  690. + * Method called on every Escape use
  691. + * @param objectId as Integer
  692. + * @return boolean: true if player is allowed to use escape, otherwise false
  693. + */
  694. + public boolean onEscapeUse(int objectId)
  695. + {
  696. + if (isRunning() && isParticipant(objectId))
  697. + return false;
  698. +
  699. + return true;
  700. + }
  701. +
  702. + /**
  703. + * Method called on every Item use
  704. + * @param actor as Player
  705. + * @param item as ItemInstance
  706. + * @return boolean: true if the player is allowed to use the item, otherwise false
  707. + */
  708. + public boolean onItemUse(Player actor, ItemInstance item)
  709. + {
  710. + if (!isRunning() || !isParticipant(actor.getObjectId()))
  711. + return true;
  712. +
  713. + if ((getConfigs().RESTRICT_ITEMS != null) && (getConfigs().RESTRICT_ITEMS.length != 0))
  714. + {
  715. + for (int itemId : getConfigs().RESTRICT_ITEMS)
  716. + {
  717. + if (item.getItemId() == itemId)
  718. + return false;
  719. + }
  720. + }
  721. +
  722. + return true;
  723. + }
  724. +
  725. + /**
  726. + * Method called when a player interact with an event npc
  727. + * @param player as Player
  728. + * @param npc as Npc
  729. + * @return boolean: true if implemented by the event, otherwise false
  730. + */
  731. + public boolean onInteract(Player player, Npc npc)
  732. + {
  733. + return false;
  734. + }
  735. +}
  736. \ No newline at end of file
  737. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java
  738. new file mode 100644
  739. index 0000000..51f7689
  740. --- /dev/null
  741. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventManager.java
  742. @@ -0,0 +1,246 @@
  743. +package net.sf.l2j.gameserver.model.gameevent;
  744. +
  745. +import java.util.Calendar;
  746. +import java.util.HashMap;
  747. +import java.util.Map;
  748. +import java.util.concurrent.ScheduledFuture;
  749. +
  750. +import net.sf.l2j.commons.logging.CLogger;
  751. +import net.sf.l2j.commons.pool.ThreadPool;
  752. +
  753. +import net.sf.l2j.gameserver.model.World;
  754. +
  755. +public class GameEventManager
  756. +{
  757. + protected static final CLogger LOGGER = new CLogger(GameEventManager.class.getName());
  758. +
  759. + private final Map<String, GameEvent> _events;
  760. + private GameEvent _event;
  761. + private GameEventStartTask task;
  762. + private String _currentEventName = "-";
  763. + private String _nextEventInfo = "-";
  764. +
  765. + public GameEventManager()
  766. + {
  767. + _events = new HashMap<>();
  768. + _event = null;
  769. + }
  770. +
  771. + public void registerEvent(GameEvent gameEvent)
  772. + {
  773. + _events.put(gameEvent.getName(), gameEvent);
  774. + LOGGER.info("Game Event Engine - Event registered: " + gameEvent.getName());
  775. + }
  776. +
  777. + public GameEvent getEvent()
  778. + {
  779. + return _event;
  780. + }
  781. +
  782. + public void startRegistration()
  783. + {
  784. + _currentEventName = getEvent().getName();
  785. + _nextEventInfo = "-";
  786. + getEvent().startRegistration();
  787. + World.announceToOnlinePlayers(getEvent().getName() + " Event: Registration opened for " + getEvent().getConfigs().REGISTRATION_TIME + " minute(s). Type .join to register!", true);
  788. + task.setStartTime(System.currentTimeMillis() + (60000L * getEvent().getConfigs().REGISTRATION_TIME));
  789. + ThreadPool.execute(task);
  790. + }
  791. +
  792. + public void startEvent()
  793. + {
  794. + if (!getEvent().start())
  795. + {
  796. + World.announceToOnlinePlayers(getEvent().getName() + " Event: Event cancelled due to lack of Participation.", true);
  797. + scheduleNextEvent();
  798. + _currentEventName = "-";
  799. + }
  800. + else
  801. + {
  802. + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: Teleporting participants to an arena in " + getEvent().getConfigs().TELEPORT_TIME + " second(s).");
  803. + task.setStartTime(System.currentTimeMillis() + (60000L * getEvent().getConfigs().EVENT_DURATION_TIME));
  804. + ThreadPool.execute(task);
  805. + }
  806. + }
  807. +
  808. + public void endEvent()
  809. + {
  810. + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + getEvent().calculateRewards(), true);
  811. + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: Teleporting back in " + getEvent().getConfigs().TELEPORT_TIME + " second(s).");
  812. + getEvent().stop();
  813. + scheduleNextEvent();
  814. + _currentEventName = "-";
  815. + }
  816. +
  817. + public Calendar nextEventStartTime(GameEvent gameEvent)
  818. + {
  819. + Calendar currentTime = Calendar.getInstance();
  820. + Calendar nextStartTime = null;
  821. +
  822. + if (gameEvent.getConfigs().EVENT_INTERVAL != null)
  823. + {
  824. + for (String timeOfDay : gameEvent.getConfigs().EVENT_INTERVAL)
  825. + {
  826. + Calendar testStartTime = Calendar.getInstance();
  827. + testStartTime.setLenient(true);
  828. +
  829. + String[] splitTimeOfDay = timeOfDay.split(":");
  830. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  831. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  832. +
  833. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  834. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  835. +
  836. + if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
  837. + nextStartTime = testStartTime;
  838. + }
  839. + }
  840. + return nextStartTime;
  841. + }
  842. +
  843. + public void scheduleNextEvent()
  844. + {
  845. + if ((_events != null) && !_events.isEmpty())
  846. + {
  847. + Calendar nextStartTime = null;
  848. +
  849. + for (GameEvent gameEvent : _events.values())
  850. + {
  851. + final Calendar tempNextStartTime = nextEventStartTime(gameEvent);
  852. + if (tempNextStartTime == null)
  853. + continue;
  854. +
  855. + if (nextStartTime == null)
  856. + {
  857. + nextStartTime = tempNextStartTime;
  858. + _event = gameEvent;
  859. + }
  860. + else
  861. + {
  862. + if (tempNextStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
  863. + {
  864. + nextStartTime = tempNextStartTime;
  865. + _event = gameEvent;
  866. + }
  867. + }
  868. + }
  869. +
  870. + if (nextStartTime != null)
  871. + {
  872. + _nextEventInfo = _event.getName() + " in " + ((nextStartTime.getTimeInMillis() - System.currentTimeMillis()) / 60000L) + " minutes!";
  873. + task = new GameEventStartTask(nextStartTime.getTimeInMillis());
  874. + ThreadPool.execute(task);
  875. + LOGGER.info("Game Event Engine - Next Event: " + _event.getName() + " in " + ((nextStartTime.getTimeInMillis() - System.currentTimeMillis()) / 60000L) + " minutes!");
  876. + }
  877. + }
  878. + }
  879. +
  880. + public void skipDelay()
  881. + {
  882. + if (task.nextRun.cancel(false))
  883. + {
  884. + task.setStartTime(System.currentTimeMillis());
  885. + ThreadPool.execute(task);
  886. + }
  887. + }
  888. +
  889. + public String getCurrentEventName()
  890. + {
  891. + return _currentEventName;
  892. + }
  893. +
  894. + public String getNextEventInfo()
  895. + {
  896. + return _nextEventInfo;
  897. + }
  898. +
  899. + public class GameEventStartTask implements Runnable
  900. + {
  901. + private long _startTime;
  902. + public ScheduledFuture<?> nextRun;
  903. +
  904. + public GameEventStartTask(long startTime)
  905. + {
  906. + _startTime = startTime;
  907. + }
  908. +
  909. + public void setStartTime(long startTime)
  910. + {
  911. + _startTime = startTime;
  912. + }
  913. +
  914. + @Override
  915. + public void run()
  916. + {
  917. + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  918. +
  919. + if (delay > 0)
  920. + announce(delay);
  921. +
  922. + int nextMsg = 0;
  923. + if (delay > 3600)
  924. + nextMsg = delay - 3600;
  925. + else if (delay > 1800)
  926. + nextMsg = delay - 1800;
  927. + else if (delay > 900)
  928. + nextMsg = delay - 900;
  929. + else if (delay > 600)
  930. + nextMsg = delay - 600;
  931. + else if (delay > 300)
  932. + nextMsg = delay - 300;
  933. + else if (delay > 60)
  934. + nextMsg = delay - 60;
  935. + else if (delay > 5)
  936. + nextMsg = delay - 5;
  937. + else if (delay > 0)
  938. + nextMsg = delay;
  939. + else
  940. + {
  941. + if (getEvent().isInactive())
  942. + startRegistration();
  943. + else if (getEvent().isRegistrating())
  944. + startEvent();
  945. + else
  946. + endEvent();
  947. + }
  948. +
  949. + if (delay > 0)
  950. + nextRun = ThreadPool.schedule(this, nextMsg * 1000);
  951. + }
  952. +
  953. + private void announce(long time)
  954. + {
  955. + if ((time >= 3600) && ((time % 3600) == 0))
  956. + {
  957. + if (getEvent().isRegistrating())
  958. + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + (time / 60 / 60) + " hour(s) until registration is closed! Type .join to register!", true);
  959. + else if (getEvent().isRunning())
  960. + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
  961. + }
  962. + else if (time >= 60)
  963. + {
  964. + if (getEvent().isRegistrating())
  965. + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + (time / 60) + " minute(s) until registration is closed! Type .join to register!", true);
  966. + else if (getEvent().isRunning())
  967. + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + (time / 60) + " minute(s) until the event is finished!");
  968. + }
  969. + else
  970. + {
  971. + if (getEvent().isRegistrating())
  972. + World.announceToOnlinePlayers(getEvent().getName() + " Event: " + time + " second(s) until registration is closed! Type .join to register!", true);
  973. + else if (getEvent().isRunning())
  974. + getEvent().sysMsgToAllParticipants(getEvent().getName() + " Event: " + time + " second(s) until the event is finished!");
  975. + }
  976. + }
  977. + }
  978. +
  979. + public static GameEventManager getInstance()
  980. + {
  981. + return SingletonHolder.INSTANCE;
  982. + }
  983. +
  984. + private static class SingletonHolder
  985. + {
  986. + protected static final GameEventManager INSTANCE = new GameEventManager();
  987. + }
  988. +}
  989. \ No newline at end of file
  990. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java
  991. new file mode 100644
  992. index 0000000..c20a952
  993. --- /dev/null
  994. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventPlayer.java
  995. @@ -0,0 +1,109 @@
  996. +package net.sf.l2j.gameserver.model.gameevent;
  997. +
  998. +import net.sf.l2j.gameserver.model.actor.Player;
  999. +
  1000. +public class GameEventPlayer implements Comparable<GameEventPlayer>
  1001. +{
  1002. + private Player _player;
  1003. + private int _kills;
  1004. + private int _deaths;
  1005. + private int _credits;
  1006. + private int _originalNameColor;
  1007. + private int _originalTitleColor;
  1008. + private int[] _originalCoordinates;
  1009. +
  1010. + public GameEventPlayer(Player player, int playerCredits)
  1011. + {
  1012. + _player = player;
  1013. + _kills = 0;
  1014. + _deaths = 0;
  1015. + _credits = playerCredits;
  1016. + }
  1017. +
  1018. + public Player getPlayer()
  1019. + {
  1020. + return _player;
  1021. + }
  1022. +
  1023. + public void setPlayer(Player player)
  1024. + {
  1025. + _player = player;
  1026. + }
  1027. +
  1028. + public int getKills()
  1029. + {
  1030. + return _kills;
  1031. + }
  1032. +
  1033. + public void increaseKills()
  1034. + {
  1035. + ++_kills;
  1036. + }
  1037. +
  1038. + public int getDeaths()
  1039. + {
  1040. + return _deaths;
  1041. + }
  1042. +
  1043. + public int getCredits()
  1044. + {
  1045. + return _credits;
  1046. + }
  1047. +
  1048. + public void increaseDeaths()
  1049. + {
  1050. + ++_deaths;
  1051. + }
  1052. +
  1053. + public void decreaseCredits()
  1054. + {
  1055. + --_credits;
  1056. + }
  1057. +
  1058. + public int getOriginalNameColor()
  1059. + {
  1060. + return _originalNameColor;
  1061. + }
  1062. +
  1063. + public int getOriginalTitleColor()
  1064. + {
  1065. + return _originalTitleColor;
  1066. + }
  1067. +
  1068. + public void setOriginalNameColor(int originalNameColor)
  1069. + {
  1070. + _originalNameColor = originalNameColor;
  1071. + }
  1072. +
  1073. + public void setOriginalTitleColor(int originalTitleColor)
  1074. + {
  1075. + _originalTitleColor = originalTitleColor;
  1076. + }
  1077. +
  1078. + public int[] getOriginalCoordinates()
  1079. + {
  1080. + return _originalCoordinates;
  1081. + }
  1082. +
  1083. + public void setOriginalCoordinates(int[] originalCoordinates)
  1084. + {
  1085. + _originalCoordinates = originalCoordinates;
  1086. + }
  1087. +
  1088. + @Override
  1089. + public int compareTo(GameEventPlayer anotherEventPlayer)
  1090. + {
  1091. + Integer c1 = Integer.valueOf(anotherEventPlayer.getKills() - getKills());
  1092. + Integer c2 = Integer.valueOf(getDeaths() - anotherEventPlayer.getDeaths());
  1093. + Integer c3 = getPlayer().getName().compareTo(anotherEventPlayer.getPlayer().getName());
  1094. +
  1095. + if (c1 == 0)
  1096. + {
  1097. + if (c2 == 0)
  1098. + return c3;
  1099. +
  1100. + return c2;
  1101. + }
  1102. + return c1;
  1103. + }
  1104. +}
  1105. \ No newline at end of file
  1106. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java
  1107. new file mode 100644
  1108. index 0000000..8eec94f
  1109. --- /dev/null
  1110. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeam.java
  1111. @@ -0,0 +1,95 @@
  1112. +package net.sf.l2j.gameserver.model.gameevent;
  1113. +
  1114. +import java.util.Map;
  1115. +import java.util.concurrent.ConcurrentHashMap;
  1116. +
  1117. +public class GameEventTeam
  1118. +{
  1119. + private final int _id;
  1120. + private final String _name;
  1121. + private final int _color;
  1122. + private final int[] _coordinates;
  1123. + private int _points;
  1124. + private final Map<Integer, GameEventPlayer> _participatedPlayers;
  1125. +
  1126. + public GameEventTeam(int id, String name, int color, int[] coordinates)
  1127. + {
  1128. + _id = id;
  1129. + _name = name;
  1130. + _color = color;
  1131. + _coordinates = coordinates;
  1132. + _points = 0;
  1133. + _participatedPlayers = new ConcurrentHashMap<>();
  1134. + }
  1135. +
  1136. + public boolean addPlayer(GameEventPlayer eventPlayer)
  1137. + {
  1138. + if (eventPlayer == null)
  1139. + return false;
  1140. +
  1141. + _participatedPlayers.put(eventPlayer.getPlayer().getObjectId(), eventPlayer);
  1142. +
  1143. + return true;
  1144. + }
  1145. +
  1146. + public void removePlayer(int objectId)
  1147. + {
  1148. + _participatedPlayers.remove(objectId);
  1149. + }
  1150. +
  1151. + public void increasePoints()
  1152. + {
  1153. + ++_points;
  1154. + }
  1155. +
  1156. + public void cleanMe()
  1157. + {
  1158. + _participatedPlayers.clear();
  1159. + _points = 0;
  1160. + }
  1161. +
  1162. + public boolean containsPlayer(int objectId)
  1163. + {
  1164. + return _participatedPlayers.containsKey(objectId);
  1165. + }
  1166. +
  1167. + public int getId()
  1168. + {
  1169. + return _id;
  1170. + }
  1171. +
  1172. + public String getName()
  1173. + {
  1174. + return _name;
  1175. + }
  1176. +
  1177. + public int getColor()
  1178. + {
  1179. + return _color;
  1180. + }
  1181. +
  1182. + public int[] getCoordinates()
  1183. + {
  1184. + return _coordinates;
  1185. + }
  1186. +
  1187. + public int getPoints()
  1188. + {
  1189. + return _points;
  1190. + }
  1191. +
  1192. + public Map<Integer, GameEventPlayer> getParticipatedPlayers()
  1193. + {
  1194. + return _participatedPlayers;
  1195. + }
  1196. +
  1197. + public int getParticipatedPlayerCount()
  1198. + {
  1199. + return _participatedPlayers.size();
  1200. + }
  1201. +
  1202. + public GameEventPlayer getEventPlayer(int objectId)
  1203. + {
  1204. + return _participatedPlayers.get(objectId);
  1205. + }
  1206. +}
  1207. \ No newline at end of file
  1208. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java
  1209. new file mode 100644
  1210. index 0000000..4c66e71
  1211. --- /dev/null
  1212. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/GameEventTeleporter.java
  1213. @@ -0,0 +1,107 @@
  1214. +package net.sf.l2j.gameserver.model.gameevent;
  1215. +
  1216. +import net.sf.l2j.commons.pool.ThreadPool;
  1217. +import net.sf.l2j.commons.random.Rnd;
  1218. +
  1219. +import net.sf.l2j.gameserver.enums.MessageType;
  1220. +import net.sf.l2j.gameserver.enums.TeamType;
  1221. +import net.sf.l2j.gameserver.model.actor.Player;
  1222. +import net.sf.l2j.gameserver.model.actor.Summon;
  1223. +import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  1224. +import net.sf.l2j.gameserver.model.group.Party;
  1225. +
  1226. +public class GameEventTeleporter implements Runnable
  1227. +{
  1228. + private GameEventPlayer _eventPlayer = null;
  1229. + private GameEvent _event = null;
  1230. + private int[] _coordinates = new int[3];
  1231. +
  1232. + public GameEventTeleporter(GameEventPlayer eventPlayer, int[] coordinates, boolean fastSchedule)
  1233. + {
  1234. + _eventPlayer = eventPlayer;
  1235. + _event = eventPlayer.getPlayer().getEvent();
  1236. + _coordinates = coordinates;
  1237. + ThreadPool.schedule(this, fastSchedule ? 0 : _event.getConfigs().TELEPORT_TIME * 1000);
  1238. + }
  1239. +
  1240. + @Override
  1241. + public void run()
  1242. + {
  1243. + if ((_eventPlayer == null) || (_event == null))
  1244. + return;
  1245. +
  1246. + final Player player = _eventPlayer.getPlayer();
  1247. + if (player == null)
  1248. + return;
  1249. +
  1250. + final Summon summon = player.getSummon();
  1251. + if (summon != null)
  1252. + summon.unSummon(player);
  1253. +
  1254. + if (_event.getConfigs().STOP_ALL_EFFECTS == true)
  1255. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  1256. +
  1257. + if (player.isInParty())
  1258. + {
  1259. + final Party party = player.getParty();
  1260. + party.removePartyMember(player, MessageType.EXPELLED);
  1261. + }
  1262. +
  1263. + if (player.isInDuel())
  1264. + player.setDuelState(DuelState.INTERRUPTED);
  1265. +
  1266. + player.doRevive();
  1267. +
  1268. + player.teleportTo((_coordinates[0] + Rnd.get(101)) - 50, (_coordinates[1] + Rnd.get(101)) - 50, _coordinates[2], 0);
  1269. +
  1270. + if (_event.isRunning())
  1271. + {
  1272. + _eventPlayer.setOriginalNameColor(player.getAppearance().getNameColor());
  1273. + _eventPlayer.setOriginalTitleColor(player.getAppearance().getTitleColor());
  1274. +
  1275. + if (_event instanceof TeamGameEvent)
  1276. + {
  1277. + TeamGameEvent teamGameEvent = (TeamGameEvent) _event;
  1278. +
  1279. + final GameEventTeam team = teamGameEvent.getParticipantTeam(player.getObjectId());
  1280. + if (team != null)
  1281. + {
  1282. + if (teamGameEvent.getConfigs().TEAMS.size() <= 2)
  1283. + player.setTeam(team.getId() == 1 ? TeamType.BLUE : TeamType.RED);
  1284. + else
  1285. + player.getAppearance().setNameColor(team.getColor());
  1286. + }
  1287. + }
  1288. + else if (_event instanceof IndividualGameEvent)
  1289. + player.setTeam(TeamType.BLUE);
  1290. +
  1291. + if (_event.getConfigs().HIDE_PLAYERS_IDENTITY)
  1292. + player.getAppearance().setTitleColor(Integer.decode("0x" + "333333"));
  1293. +
  1294. + player.doRevive();
  1295. + }
  1296. + else
  1297. + {
  1298. + if (_event instanceof TeamGameEvent)
  1299. + {
  1300. + TeamGameEvent teamGameEvent = (TeamGameEvent) _event;
  1301. +
  1302. + if (teamGameEvent.getConfigs().TEAMS.size() <= 2)
  1303. + player.setTeam(TeamType.NONE);
  1304. + else
  1305. + player.getAppearance().setNameColor(_eventPlayer.getOriginalNameColor());
  1306. + }
  1307. + else if (_event instanceof IndividualGameEvent)
  1308. + player.setTeam(TeamType.NONE);
  1309. +
  1310. + if (_event.getConfigs().HIDE_PLAYERS_IDENTITY)
  1311. + player.getAppearance().setTitleColor(_eventPlayer.getOriginalTitleColor());
  1312. +
  1313. + player.doRevive();
  1314. + player.setEvent(null);
  1315. + }
  1316. +
  1317. + player.getStatus().setMaxCpHpMp();
  1318. + player.broadcastUserInfo();
  1319. + }
  1320. +}
  1321. \ No newline at end of file
  1322. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java
  1323. new file mode 100644
  1324. index 0000000..521dbd5
  1325. --- /dev/null
  1326. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/IndividualGameEvent.java
  1327. @@ -0,0 +1,245 @@
  1328. +package net.sf.l2j.gameserver.model.gameevent;
  1329. +
  1330. +import java.util.Map;
  1331. +import java.util.TreeSet;
  1332. +
  1333. +import net.sf.l2j.gameserver.enums.SayType;
  1334. +import net.sf.l2j.gameserver.model.actor.Player;
  1335. +import net.sf.l2j.gameserver.model.gameevent.config.IndividualGameEventConfig;
  1336. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  1337. +import net.sf.l2j.gameserver.skills.L2Skill;
  1338. +
  1339. +public abstract class IndividualGameEvent extends GameEvent
  1340. +{
  1341. + protected Map<Integer, GameEventPlayer> _participants;
  1342. +
  1343. + @Override
  1344. + public abstract IndividualGameEventConfig getConfigs();
  1345. +
  1346. + /**
  1347. + * Method called to verify if a player is participant at the event
  1348. + * @param eventPlayerObjectId as Integer
  1349. + * @return boolean: true if the player is participant, otherwise false
  1350. + */
  1351. + @Override
  1352. + public boolean isParticipant(int eventPlayerObjectId)
  1353. + {
  1354. + return _participants.containsKey(eventPlayerObjectId);
  1355. + }
  1356. +
  1357. + /**
  1358. + * Method that returns the total of the event players
  1359. + * @return Integer playersCount
  1360. + */
  1361. + @Override
  1362. + public int getCountPlayers()
  1363. + {
  1364. + return _participants.size();
  1365. + }
  1366. +
  1367. + /**
  1368. + * Add a GameEvent player to a team
  1369. + * @param eventPlayer as GameEventPlayer
  1370. + * @return boolean: true if success, otherwise false
  1371. + */
  1372. + @Override
  1373. + public boolean addParticipant(GameEventPlayer eventPlayer)
  1374. + {
  1375. + if (_participants.containsKey(eventPlayer.getPlayer().getObjectId()))
  1376. + return false;
  1377. +
  1378. + _participants.put(eventPlayer.getPlayer().getObjectId(), eventPlayer);
  1379. + eventPlayer.getPlayer().setEvent(this);
  1380. +
  1381. + return true;
  1382. + }
  1383. +
  1384. + /**
  1385. + * Removes a GameEvent player from it's team
  1386. + * @param player as Player
  1387. + * @return boolean: true if success, otherwise false
  1388. + */
  1389. + @Override
  1390. + public boolean removeParticipant(Player player)
  1391. + {
  1392. + if (!_participants.containsKey(player.getObjectId()))
  1393. + return false;
  1394. +
  1395. + _participants.remove(player.getObjectId());
  1396. + player.setEvent(null);
  1397. +
  1398. + return true;
  1399. + }
  1400. +
  1401. + /**
  1402. + * Method called to teleport players to the arena
  1403. + */
  1404. + @Override
  1405. + public void teleportPlayersToArena()
  1406. + {
  1407. + for (GameEventPlayer eventPlayer : _participants.values())
  1408. + {
  1409. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1410. + {
  1411. + int[] playerCoordinates = new int[]
  1412. + {
  1413. + eventPlayer.getPlayer().getX(),
  1414. + eventPlayer.getPlayer().getY(),
  1415. + eventPlayer.getPlayer().getZ(),
  1416. + };
  1417. + eventPlayer.setOriginalCoordinates(playerCoordinates);
  1418. + new GameEventTeleporter(eventPlayer, getConfigs().EVENT_COORDINATES, false);
  1419. + }
  1420. + }
  1421. + }
  1422. +
  1423. + /**
  1424. + * Method called to teleport players back
  1425. + */
  1426. + @Override
  1427. + public void teleportPlayersBack()
  1428. + {
  1429. + for (GameEventPlayer eventPlayer : _participants.values())
  1430. + {
  1431. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1432. + new GameEventTeleporter(eventPlayer, eventPlayer.getOriginalCoordinates(), false);
  1433. + }
  1434. + }
  1435. +
  1436. + /**
  1437. + * Method used to send messages to all the event participants
  1438. + * @param message as String
  1439. + */
  1440. + @Override
  1441. + public void sysMsgToAllParticipants(String message)
  1442. + {
  1443. + for (GameEventPlayer eventPlayer : _participants.values())
  1444. + {
  1445. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1446. + eventPlayer.getPlayer().sendPacket(new CreatureSay(SayType.CRITICAL_ANNOUNCE, _eventName, message));
  1447. + }
  1448. + }
  1449. +
  1450. + /**
  1451. + * Method called to get the informations about the 1st position player
  1452. + * @param countPos as Integer
  1453. + * @return String: player informations
  1454. + */
  1455. + public String[] getFirstPosition(int countPos)
  1456. + {
  1457. + TreeSet<GameEventPlayer> players = new TreeSet<>();
  1458. + players.addAll(_participants.values());
  1459. +
  1460. + String text = "";
  1461. +
  1462. + for (int i = 0; i < countPos; i++)
  1463. + {
  1464. + if (players.isEmpty())
  1465. + break;
  1466. +
  1467. + GameEventPlayer player = players.first();
  1468. + if (player.getKills() == 0)
  1469. + break;
  1470. +
  1471. + text = player.getPlayer().getName() + "," + String.valueOf(player.getKills()) + ";";
  1472. + players.remove(player);
  1473. +
  1474. + int playerPointPrev = player.getKills();
  1475. +
  1476. + if (!getConfigs().REWARD_EVENT_TIE)
  1477. + continue;
  1478. +
  1479. + while (!players.isEmpty())
  1480. + {
  1481. + player = players.first();
  1482. + if (player.getKills() != playerPointPrev)
  1483. + break;
  1484. +
  1485. + text = player.getPlayer().getName() + "," + String.valueOf(player.getKills()) + ";";
  1486. + players.remove(player);
  1487. + }
  1488. + }
  1489. +
  1490. + if (text != "")
  1491. + return text.split("\\;");
  1492. +
  1493. + return null;
  1494. + }
  1495. +
  1496. + /**
  1497. + * Method called on every Skill use
  1498. + * @param caster as Player
  1499. + * @param skill as L2Skill
  1500. + * @return boolean: true if the player is allowed to use the skill, otherwise false
  1501. + */
  1502. + @Override
  1503. + public boolean onSkillUse(Player caster, L2Skill skill)
  1504. + {
  1505. + if (!isRunning() || !isParticipant(caster.getObjectId()))
  1506. + return true;
  1507. +
  1508. + if ((getConfigs().RESTRICT_SKILLS != null) && (getConfigs().RESTRICT_SKILLS.length != 0))
  1509. + {
  1510. + for (int skillId : getConfigs().RESTRICT_SKILLS)
  1511. + {
  1512. + if (skillId == skill.getId())
  1513. + return false;
  1514. + }
  1515. + }
  1516. +
  1517. + return true;
  1518. + }
  1519. +
  1520. + /**
  1521. + * Method called on every onAction in L2PcIstance
  1522. + * @param player as Player
  1523. + * @param targetedPlayerObjectId as Integer
  1524. + * @return boolean: true if player is allowed to target, otherwise false
  1525. + */
  1526. + @Override
  1527. + public boolean onAction(Player player, int targetedPlayerObjectId)
  1528. + {
  1529. + if ((player == null) || !isRunning())
  1530. + return true;
  1531. +
  1532. + if (player.isGM())
  1533. + return true;
  1534. +
  1535. + if (!isParticipant(player.getObjectId()) && isParticipant(targetedPlayerObjectId))
  1536. + return false;
  1537. +
  1538. + if (isParticipant(player.getObjectId()) && !isParticipant(targetedPlayerObjectId))
  1539. + return false;
  1540. +
  1541. + return true;
  1542. + }
  1543. +
  1544. + /**
  1545. + * Method called when a player logs in
  1546. + * @param player as Player
  1547. + */
  1548. + @Override
  1549. + public void onLogin(Player player)
  1550. + {
  1551. + if ((player == null) || (!isRunning()))
  1552. + return;
  1553. +
  1554. + if (isParticipant(player.getObjectId()))
  1555. + {
  1556. + final GameEventPlayer eventPlayer = _participants.get(player.getObjectId());
  1557. + if (eventPlayer == null)
  1558. + return;
  1559. +
  1560. + new GameEventTeleporter(eventPlayer, getConfigs().EVENT_COORDINATES, true);
  1561. + }
  1562. + }
  1563. +
  1564. + /**
  1565. + * Method called to clear event attributes
  1566. + */
  1567. + @Override
  1568. + protected void clear()
  1569. + {
  1570. + _participants.clear();
  1571. + }
  1572. +}
  1573. \ No newline at end of file
  1574. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java
  1575. new file mode 100644
  1576. index 0000000..87e7cab
  1577. --- /dev/null
  1578. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/TeamGameEvent.java
  1579. @@ -0,0 +1,360 @@
  1580. +package net.sf.l2j.gameserver.model.gameevent;
  1581. +
  1582. +import java.util.ArrayList;
  1583. +import java.util.List;
  1584. +
  1585. +import net.sf.l2j.gameserver.enums.SayType;
  1586. +import net.sf.l2j.gameserver.model.actor.Player;
  1587. +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig;
  1588. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  1589. +import net.sf.l2j.gameserver.skills.L2Skill;
  1590. +
  1591. +public abstract class TeamGameEvent extends GameEvent
  1592. +{
  1593. + protected GameEventTeam[] _teams;
  1594. + protected int _rounds = 1;
  1595. +
  1596. + @Override
  1597. + public abstract TeamGameEventConfig getConfigs();
  1598. +
  1599. + /**
  1600. + * Method called to verify if a player is participant at the event
  1601. + * @param objectId as Integer
  1602. + * @return boolean: true if the player is participant, otherwise false
  1603. + */
  1604. + @Override
  1605. + public boolean isParticipant(int objectId)
  1606. + {
  1607. + boolean isParticipant = false;
  1608. + for (GameEventTeam team : _teams)
  1609. + {
  1610. + if (team.containsPlayer(objectId))
  1611. + isParticipant = true;
  1612. + }
  1613. + return isParticipant;
  1614. + }
  1615. +
  1616. + /**
  1617. + * Method that returns the total of the event players
  1618. + * @return Integer playersCount
  1619. + */
  1620. + @Override
  1621. + public int getCountPlayers()
  1622. + {
  1623. + int playersCount = 0;
  1624. +
  1625. + for (GameEventTeam team : _teams)
  1626. + playersCount = team.getParticipatedPlayerCount();
  1627. +
  1628. + return playersCount;
  1629. + }
  1630. +
  1631. + /**
  1632. + * Method that returns a list of the event teams
  1633. + * @return GameEventTeam[]: _teams
  1634. + */
  1635. + public GameEventTeam[] getTeams()
  1636. + {
  1637. + return _teams;
  1638. + }
  1639. +
  1640. + /**
  1641. + * Method that returns the team id with less players
  1642. + * @return GameEventTeam team
  1643. + */
  1644. + private GameEventTeam getTeamWithMinPlayers()
  1645. + {
  1646. + GameEventTeam teamWithMinPlayers = null;
  1647. + int playersCount = getConfigs().MAX_PARTICIPANTS;
  1648. +
  1649. + for (GameEventTeam team : _teams)
  1650. + {
  1651. + if (playersCount > team.getParticipatedPlayerCount())
  1652. + {
  1653. + playersCount = team.getParticipatedPlayerCount();
  1654. + teamWithMinPlayers = team;
  1655. + }
  1656. + }
  1657. + return teamWithMinPlayers;
  1658. + }
  1659. +
  1660. + /**
  1661. + * Method used to retrieve the Team of the event player
  1662. + * @param objectId as Integer
  1663. + * @return GameEventTeam participantTeam
  1664. + */
  1665. + public GameEventTeam getParticipantTeam(int objectId)
  1666. + {
  1667. + GameEventTeam participantTeam = null;
  1668. + for (GameEventTeam team : _teams)
  1669. + {
  1670. + if (team.containsPlayer(objectId))
  1671. + participantTeam = team;
  1672. + }
  1673. +
  1674. + return participantTeam;
  1675. + }
  1676. +
  1677. + /**
  1678. + * Add a GameEvent player to a team
  1679. + * @param eventPlayer as GameEventPlayer
  1680. + * @return boolean: true if success, otherwise false
  1681. + */
  1682. + @Override
  1683. + public boolean addParticipant(GameEventPlayer eventPlayer)
  1684. + {
  1685. + if (getTeamWithMinPlayers().addPlayer(eventPlayer))
  1686. + {
  1687. + eventPlayer.getPlayer().setEvent(this);
  1688. + return true;
  1689. + }
  1690. + return false;
  1691. + }
  1692. +
  1693. + /**
  1694. + * Removes a GameEvent player from it's team
  1695. + * @param player as Player
  1696. + * @return boolean: true if success, otherwise false
  1697. + */
  1698. + @Override
  1699. + public boolean removeParticipant(Player player)
  1700. + {
  1701. + final GameEventTeam playerTeam = getParticipantTeam(player.getObjectId());
  1702. + if (playerTeam != null)
  1703. + {
  1704. + playerTeam.removePlayer(player.getObjectId());
  1705. + player.setEvent(null);
  1706. +
  1707. + return true;
  1708. + }
  1709. +
  1710. + return false;
  1711. + }
  1712. +
  1713. + /**
  1714. + * Method called to teleport players to the arena
  1715. + */
  1716. + @Override
  1717. + public void teleportPlayersToArena()
  1718. + {
  1719. + for (GameEventTeam team : _teams)
  1720. + {
  1721. + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
  1722. + {
  1723. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1724. + {
  1725. + int[] playerCoordinates = new int[]
  1726. + {
  1727. + eventPlayer.getPlayer().getX(),
  1728. + eventPlayer.getPlayer().getY(),
  1729. + eventPlayer.getPlayer().getZ(),
  1730. + };
  1731. + eventPlayer.setOriginalCoordinates(playerCoordinates);
  1732. + eventPlayer.getPlayer().doRevive();
  1733. + new GameEventTeleporter(eventPlayer, team.getCoordinates(), false);
  1734. + }
  1735. + }
  1736. + }
  1737. + }
  1738. +
  1739. + /**
  1740. + * Method called to teleport players back
  1741. + */
  1742. + @Override
  1743. + public void teleportPlayersBack()
  1744. + {
  1745. + for (GameEventTeam team : _teams)
  1746. + {
  1747. + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
  1748. + {
  1749. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1750. + new GameEventTeleporter(eventPlayer, eventPlayer.getOriginalCoordinates(), false);
  1751. + }
  1752. + }
  1753. + }
  1754. +
  1755. + /**
  1756. + * Method called to set the winner teams
  1757. + * @return String: msg
  1758. + */
  1759. + @Override
  1760. + public String calculateRewards()
  1761. + {
  1762. + List<GameEventTeam> winners = new ArrayList<>(getConfigs().TEAMS.size());
  1763. + GameEventTeam winnerTeam = null;
  1764. + int maxPoints = 0;
  1765. + String msg = "";
  1766. +
  1767. + for (GameEventTeam team : _teams)
  1768. + {
  1769. + if ((maxPoints == 0) && (team.getPoints() > 0))
  1770. + {
  1771. + maxPoints = team.getPoints();
  1772. + winnerTeam = team;
  1773. + }
  1774. + else if ((team.getPoints() == maxPoints) && (team.getPoints() > 0))
  1775. + {
  1776. + maxPoints = team.getPoints();
  1777. + winners.add(team);
  1778. + winners.add(winnerTeam);
  1779. + winnerTeam = null;
  1780. + }
  1781. + else if ((team.getPoints() > maxPoints))
  1782. + {
  1783. + maxPoints = team.getPoints();
  1784. + winnerTeam = team;
  1785. + winners.clear();
  1786. + }
  1787. + }
  1788. +
  1789. + setState(EventState.REWARDING);
  1790. +
  1791. + if (winnerTeam != null)
  1792. + {
  1793. + reward(winnerTeam);
  1794. + msg = _eventName + ": Event finish. Team " + winnerTeam.getName() + " won with " + winnerTeam.getPoints() + " kills.";
  1795. + }
  1796. + else if (winners.size() >= 2)
  1797. + {
  1798. + if (getConfigs().REWARD_EVENT_TIE)
  1799. + {
  1800. + for (GameEventTeam team : winners)
  1801. + reward(team);
  1802. + }
  1803. + msg = _eventName + ": Event has ended with both teams tying!";
  1804. + }
  1805. + else if (winners.isEmpty())
  1806. + msg = _eventName + ": Event has ended with both teams tying without any points!";
  1807. +
  1808. + winners.clear();
  1809. +
  1810. + return msg;
  1811. + }
  1812. +
  1813. + /**
  1814. + * Method used to reward the winner team(s)
  1815. + * @param team as GameEventTeam
  1816. + */
  1817. + public void reward(GameEventTeam team)
  1818. + {
  1819. + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
  1820. + {
  1821. + if (eventPlayer == null)
  1822. + continue;
  1823. +
  1824. + final Player player = eventPlayer.getPlayer();
  1825. + if (player == null)
  1826. + continue;
  1827. +
  1828. + if (getConfigs().REQUIRE_MIN_FRAGS_TO_REWARD && (eventPlayer.getKills() < getConfigs().MIN_FRAGS_TO_REWARD))
  1829. + {
  1830. + player.sendMessage("You did not killed enough players at the event to receive the reward!");
  1831. + continue;
  1832. + }
  1833. +
  1834. + if (getConfigs().REWARDS != null)
  1835. + deliverRewards(player, getConfigs().REWARDS);
  1836. + }
  1837. + }
  1838. +
  1839. + /**
  1840. + * Method used to send messages to all the event participants
  1841. + * @param message as String
  1842. + */
  1843. + @Override
  1844. + public void sysMsgToAllParticipants(String message)
  1845. + {
  1846. + for (GameEventTeam team : _teams)
  1847. + {
  1848. + for (GameEventPlayer eventPlayer : team.getParticipatedPlayers().values())
  1849. + {
  1850. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  1851. + {
  1852. + final CreatureSay cs = new CreatureSay(SayType.CRITICAL_ANNOUNCE, _eventName, message);
  1853. + eventPlayer.getPlayer().sendPacket(cs);
  1854. + }
  1855. + }
  1856. + }
  1857. + }
  1858. +
  1859. + /**
  1860. + * Method called on every Skill use
  1861. + * @param caster as Player
  1862. + * @param skill as L2Skill
  1863. + * @return boolean: true if the player is allowed to use the skill, otherwise false
  1864. + */
  1865. + @Override
  1866. + public boolean onSkillUse(Player caster, L2Skill skill)
  1867. + {
  1868. + if (!isRunning() || !isParticipant(caster.getObjectId()))
  1869. + return true;
  1870. +
  1871. + if ((getConfigs().RESTRICT_SKILLS != null) && (getConfigs().RESTRICT_SKILLS.length != 0))
  1872. + {
  1873. + for (int skillId : getConfigs().RESTRICT_SKILLS)
  1874. + {
  1875. + if (skillId == skill.getId())
  1876. + return false;
  1877. + }
  1878. + }
  1879. + return true;
  1880. + }
  1881. +
  1882. + /**
  1883. + * Method called on every onAction in L2PcIstance
  1884. + * @param player as Player
  1885. + * @param targetedPlayerObjectId as Integer
  1886. + * @return boolean: true if player is allowed to target, otherwise false
  1887. + */
  1888. + @Override
  1889. + public boolean onAction(Player player, int targetedPlayerObjectId)
  1890. + {
  1891. + if ((player == null) || !isRunning())
  1892. + return true;
  1893. +
  1894. + if (player.isGM())
  1895. + return true;
  1896. +
  1897. + GameEventTeam playerTeam = getParticipantTeam(player.getObjectId());
  1898. + GameEventTeam targetedPlayerTeam = getParticipantTeam(targetedPlayerObjectId);
  1899. +
  1900. + if (((playerTeam != null) && (targetedPlayerTeam == null)) || ((playerTeam == null) && (targetedPlayerTeam != null)))
  1901. + return false;
  1902. +
  1903. + if ((playerTeam != null) && (targetedPlayerTeam != null) && (playerTeam == targetedPlayerTeam) && (player.getObjectId() != targetedPlayerObjectId) && !getConfigs().ALLOW_TARGET_TEAM_MEMBERS)
  1904. + return false;
  1905. +
  1906. + return true;
  1907. + }
  1908. +
  1909. + /**
  1910. + * Method called when a player logs in
  1911. + * @param player as Player
  1912. + */
  1913. + @Override
  1914. + public void onLogin(Player player)
  1915. + {
  1916. + if ((player == null) || (!isRunning()))
  1917. + return;
  1918. +
  1919. + final GameEventTeam team = getParticipantTeam(player.getObjectId());
  1920. + if (team == null)
  1921. + return;
  1922. +
  1923. + final GameEventPlayer eventPlayer = team.getEventPlayer(player.getObjectId());
  1924. + if (eventPlayer == null)
  1925. + return;
  1926. +
  1927. + new GameEventTeleporter(eventPlayer, team.getCoordinates(), true);
  1928. + }
  1929. +
  1930. + /**
  1931. + * Method called to clear event attributes
  1932. + */
  1933. + @Override
  1934. + protected void clear()
  1935. + {
  1936. + for (GameEventTeam team : _teams)
  1937. + team.cleanMe();
  1938. + }
  1939. +}
  1940. \ No newline at end of file
  1941. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java
  1942. new file mode 100644
  1943. index 0000000..3e7eea3
  1944. --- /dev/null
  1945. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/GameEventConfig.java
  1946. @@ -0,0 +1,33 @@
  1947. +package net.sf.l2j.gameserver.model.gameevent.config;
  1948. +
  1949. +public abstract class GameEventConfig
  1950. +{
  1951. + public String[] EVENT_INTERVAL;
  1952. + public byte EVENT_DURATION_TIME = 10;
  1953. + public byte TELEPORT_TIME = 15;
  1954. + public byte REGISTRATION_TIME = 10;
  1955. + public short MIN_PARTICIPANTS = 2;
  1956. + public short MAX_PARTICIPANTS = 10;
  1957. + public byte MIN_LEVEL = 1;
  1958. + public byte MAX_LEVEL = 85;
  1959. + public boolean ALLOW_TAKE_ITEM = false;
  1960. + public short TAKE_ITEM_ID = 0;
  1961. + public int TAKE_COUNT = 0;
  1962. + public boolean ALLOW_KILL_BONUS = false;
  1963. + public short KILL_BONUS_ID = 0;
  1964. + public int KILL_BONUS_COUNT = 0;
  1965. + public boolean STOP_ALL_EFFECTS = true;
  1966. + public int[] LIST_MAGE_SUPPORT;
  1967. + public int[] LIST_FIGHTER_SUPPORT;
  1968. + public int[] RESTRICT_ITEMS;
  1969. + public int[] RESTRICT_SKILLS;
  1970. + public boolean HIDE_PLAYERS_IDENTITY = false;
  1971. + public boolean REWARD_EVENT_TIE = false;
  1972. + public int[][] REWARDS;
  1973. + public boolean ALLOW_POTIONS = false;
  1974. + public boolean ALLOW_SCROLLS = false;
  1975. + public boolean ALLOW_SUMMON_BY_ITEM = false;
  1976. + public boolean REQUIRE_MIN_FRAGS_TO_REWARD = false;
  1977. + public byte MIN_FRAGS_TO_REWARD = 0;
  1978. + public byte PLAYER_CREDITS = 0;
  1979. +}
  1980. \ No newline at end of file
  1981. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java
  1982. new file mode 100644
  1983. index 0000000..ec08693
  1984. --- /dev/null
  1985. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IGameEventConfig.java
  1986. @@ -0,0 +1,6 @@
  1987. +package net.sf.l2j.gameserver.model.gameevent.config;
  1988. +
  1989. +public interface IGameEventConfig
  1990. +{
  1991. + public void load();
  1992. +}
  1993. \ No newline at end of file
  1994. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java
  1995. new file mode 100644
  1996. index 0000000..3bd4ede
  1997. --- /dev/null
  1998. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/IndividualGameEventConfig.java
  1999. @@ -0,0 +1,6 @@
  2000. +package net.sf.l2j.gameserver.model.gameevent.config;
  2001. +
  2002. +public class IndividualGameEventConfig extends GameEventConfig
  2003. +{
  2004. + public int[] EVENT_COORDINATES;
  2005. +}
  2006. \ No newline at end of file
  2007. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java
  2008. new file mode 100644
  2009. index 0000000..6bf05e6
  2010. --- /dev/null
  2011. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/config/TeamGameEventConfig.java
  2012. @@ -0,0 +1,46 @@
  2013. +package net.sf.l2j.gameserver.model.gameevent.config;
  2014. +
  2015. +import java.util.ArrayList;
  2016. +import java.util.List;
  2017. +
  2018. +public abstract class TeamGameEventConfig extends GameEventConfig
  2019. +{
  2020. + public List<GameEventTeamConfig> TEAMS = new ArrayList<>();
  2021. + public boolean ALLOW_TARGET_TEAM_MEMBERS = false;
  2022. +
  2023. + public class GameEventTeamConfig
  2024. + {
  2025. + private final int _id;
  2026. + private final String _name;
  2027. + private final int _color;
  2028. + private final int[] _coordinates;
  2029. +
  2030. + public GameEventTeamConfig(int id, String name, int color, int[] coordinates)
  2031. + {
  2032. + _id = id;
  2033. + _name = name;
  2034. + _color = color;
  2035. + _coordinates = coordinates;
  2036. + }
  2037. +
  2038. + public int getId()
  2039. + {
  2040. + return _id;
  2041. + }
  2042. +
  2043. + public String getName()
  2044. + {
  2045. + return _name;
  2046. + }
  2047. +
  2048. + public int getColor()
  2049. + {
  2050. + return _color;
  2051. + }
  2052. +
  2053. + public int[] getCoordinates()
  2054. + {
  2055. + return _coordinates;
  2056. + }
  2057. + }
  2058. +}
  2059. \ No newline at end of file
  2060. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java
  2061. new file mode 100644
  2062. index 0000000..0a411d2
  2063. --- /dev/null
  2064. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMConfig.java
  2065. @@ -0,0 +1,264 @@
  2066. +package net.sf.l2j.gameserver.model.gameevent.dm;
  2067. +
  2068. +import java.io.File;
  2069. +
  2070. +import javax.xml.parsers.DocumentBuilderFactory;
  2071. +
  2072. +import net.sf.l2j.commons.logging.CLogger;
  2073. +
  2074. +import net.sf.l2j.gameserver.model.gameevent.config.IGameEventConfig;
  2075. +import net.sf.l2j.gameserver.model.gameevent.config.IndividualGameEventConfig;
  2076. +
  2077. +import org.w3c.dom.Document;
  2078. +import org.w3c.dom.NamedNodeMap;
  2079. +import org.w3c.dom.Node;
  2080. +
  2081. +public class DMConfig extends IndividualGameEventConfig implements IGameEventConfig
  2082. +{
  2083. + private static final CLogger LOGGER = new CLogger(DMConfig.class.getName());
  2084. +
  2085. + public int[][] REWARDS_1ST_PLACE;
  2086. + public int[][] REWARDS_2ND_PLACE;
  2087. + public int[][] REWARDS_3RD_PLACE;
  2088. +
  2089. + private DMConfig()
  2090. + {
  2091. + load();
  2092. + }
  2093. +
  2094. + @Override
  2095. + public void load()
  2096. + {
  2097. + try
  2098. + {
  2099. + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2100. + factory.setValidating(false);
  2101. + factory.setIgnoringComments(true);
  2102. +
  2103. + File file = new File("./data/xml/events/DeathMatch.xml");
  2104. +
  2105. + Document doc = factory.newDocumentBuilder().parse(file);
  2106. +
  2107. + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  2108. + {
  2109. + if (!"dm".equalsIgnoreCase(n.getNodeName()))
  2110. + continue;
  2111. +
  2112. + NamedNodeMap attrs = n.getAttributes();
  2113. +
  2114. + for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
  2115. + {
  2116. + if ("EventTimeInterval".equalsIgnoreCase(cd.getNodeName()))
  2117. + {
  2118. + attrs = cd.getAttributes();
  2119. + EVENT_INTERVAL = attrs.getNamedItem("val").getNodeValue().split(",");
  2120. + }
  2121. + else if ("Duration".equalsIgnoreCase(cd.getNodeName()))
  2122. + {
  2123. + attrs = cd.getAttributes();
  2124. + EVENT_DURATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2125. + }
  2126. + else if ("Participants".equalsIgnoreCase(cd.getNodeName()))
  2127. + {
  2128. + attrs = cd.getAttributes();
  2129. + MIN_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("min").getNodeValue());
  2130. + MAX_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("max").getNodeValue());
  2131. + }
  2132. + else if ("Level".equalsIgnoreCase(cd.getNodeName()))
  2133. + {
  2134. + attrs = cd.getAttributes();
  2135. + MIN_LEVEL = Byte.parseByte(attrs.getNamedItem("min").getNodeValue());
  2136. + MAX_LEVEL = Byte.parseByte(attrs.getNamedItem("max").getNodeValue());
  2137. + }
  2138. + else if ("TimeToRegistration".equalsIgnoreCase(cd.getNodeName()))
  2139. + {
  2140. + attrs = cd.getAttributes();
  2141. + REGISTRATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2142. + }
  2143. + else if ("TimeToTeleport".equalsIgnoreCase(cd.getNodeName()))
  2144. + {
  2145. + attrs = cd.getAttributes();
  2146. + TELEPORT_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2147. + }
  2148. + else if ("AllowTakeItem".equalsIgnoreCase(cd.getNodeName()))
  2149. + {
  2150. + attrs = cd.getAttributes();
  2151. + ALLOW_TAKE_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2152. + }
  2153. + else if ("TakeItem".equalsIgnoreCase(cd.getNodeName()))
  2154. + {
  2155. + attrs = cd.getAttributes();
  2156. + TAKE_ITEM_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
  2157. + TAKE_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
  2158. + }
  2159. + else if ("AllowKillBonus".equalsIgnoreCase(cd.getNodeName()))
  2160. + {
  2161. + attrs = cd.getAttributes();
  2162. + ALLOW_KILL_BONUS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2163. + }
  2164. + else if ("KillReward".equalsIgnoreCase(cd.getNodeName()))
  2165. + {
  2166. + attrs = cd.getAttributes();
  2167. + KILL_BONUS_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
  2168. + KILL_BONUS_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
  2169. + }
  2170. + else if ("PlayerEventCoordinates".equalsIgnoreCase(cd.getNodeName()))
  2171. + {
  2172. + attrs = cd.getAttributes();
  2173. + int x = Integer.parseInt(attrs.getNamedItem("x").getNodeValue());
  2174. + int y = Integer.parseInt(attrs.getNamedItem("y").getNodeValue());
  2175. + int z = Integer.parseInt(attrs.getNamedItem("z").getNodeValue());
  2176. + int h = Integer.parseInt(attrs.getNamedItem("h").getNodeValue());
  2177. + EVENT_COORDINATES = new int[]
  2178. + {
  2179. + x,
  2180. + y,
  2181. + z,
  2182. + h
  2183. + };
  2184. + }
  2185. + else if ("StopAllEffects".equalsIgnoreCase(cd.getNodeName()))
  2186. + {
  2187. + attrs = cd.getAttributes();
  2188. + STOP_ALL_EFFECTS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2189. + }
  2190. + else if ("HidePlayersIdentity".equalsIgnoreCase(cd.getNodeName()))
  2191. + {
  2192. + attrs = cd.getAttributes();
  2193. + HIDE_PLAYERS_IDENTITY = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2194. + }
  2195. + else if ("Rewards1stPlace".equalsIgnoreCase(cd.getNodeName()))
  2196. + {
  2197. + attrs = cd.getAttributes();
  2198. + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
  2199. + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
  2200. + REWARDS_1ST_PLACE = new int[itemIds.length][];
  2201. + for (int i = 0; i < itemIds.length; i++)
  2202. + {
  2203. + REWARDS_1ST_PLACE[i] = new int[]
  2204. + {
  2205. + Integer.parseInt(itemIds[i]),
  2206. + Integer.parseInt(counts[i])
  2207. + };
  2208. + }
  2209. + }
  2210. + else if ("Rewards2ndPlace".equalsIgnoreCase(cd.getNodeName()))
  2211. + {
  2212. + attrs = cd.getAttributes();
  2213. + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
  2214. + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
  2215. + REWARDS_2ND_PLACE = new int[itemIds.length][];
  2216. + for (int i = 0; i < itemIds.length; i++)
  2217. + {
  2218. + REWARDS_2ND_PLACE[i] = new int[]
  2219. + {
  2220. + Integer.parseInt(itemIds[i]),
  2221. + Integer.parseInt(counts[i])
  2222. + };
  2223. + }
  2224. + }
  2225. + else if ("Rewards3rdPlace".equalsIgnoreCase(cd.getNodeName()))
  2226. + {
  2227. + attrs = cd.getAttributes();
  2228. + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
  2229. + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
  2230. + REWARDS_3RD_PLACE = new int[itemIds.length][];
  2231. + for (int i = 0; i < itemIds.length; i++)
  2232. + {
  2233. + REWARDS_3RD_PLACE[i] = new int[]
  2234. + {
  2235. + Integer.parseInt(itemIds[i]),
  2236. + Integer.parseInt(counts[i])
  2237. + };
  2238. + }
  2239. + }
  2240. + else if ("RewardTie".equalsIgnoreCase(cd.getNodeName()))
  2241. + {
  2242. + attrs = cd.getAttributes();
  2243. + REWARD_EVENT_TIE = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2244. + }
  2245. + else if ("ListMageSupport".equalsIgnoreCase(cd.getNodeName()))
  2246. + {
  2247. + attrs = cd.getAttributes();
  2248. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2249. + LIST_MAGE_SUPPORT = new int[skills.length];
  2250. + for (int i = 0; i < skills.length; i++)
  2251. + {
  2252. + LIST_MAGE_SUPPORT[i] = Integer.parseInt(skills[i]);
  2253. + }
  2254. + }
  2255. + else if ("ListFighterSupport".equalsIgnoreCase(cd.getNodeName()))
  2256. + {
  2257. + attrs = cd.getAttributes();
  2258. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2259. + LIST_FIGHTER_SUPPORT = new int[skills.length];
  2260. + for (int i = 0; i < skills.length; i++)
  2261. + {
  2262. + LIST_FIGHTER_SUPPORT[i] = Integer.parseInt(skills[i]);
  2263. + }
  2264. + }
  2265. + else if ("RestrictItems".equalsIgnoreCase(cd.getNodeName()))
  2266. + {
  2267. + attrs = cd.getAttributes();
  2268. + String[] items = attrs.getNamedItem("val").getNodeValue().split(",");
  2269. + RESTRICT_ITEMS = new int[items.length];
  2270. + for (int i = 0; i < items.length; i++)
  2271. + {
  2272. + RESTRICT_ITEMS[i] = Integer.parseInt(items[i]);
  2273. + }
  2274. +
  2275. + }
  2276. + else if ("RestrictSkills".equalsIgnoreCase(cd.getNodeName()))
  2277. + {
  2278. + attrs = cd.getAttributes();
  2279. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2280. + RESTRICT_SKILLS = new int[skills.length];
  2281. + for (int i = 0; i < skills.length; i++)
  2282. + {
  2283. + RESTRICT_SKILLS[i] = Integer.parseInt(skills[i]);
  2284. + }
  2285. + }
  2286. + else if ("AllowPotions".equalsIgnoreCase(cd.getNodeName()))
  2287. + {
  2288. + attrs = cd.getAttributes();
  2289. + ALLOW_POTIONS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2290. + }
  2291. + else if ("AllowScrolls".equalsIgnoreCase(cd.getNodeName()))
  2292. + {
  2293. + attrs = cd.getAttributes();
  2294. + ALLOW_SCROLLS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2295. + }
  2296. + else if ("AllowSummonByItem".equalsIgnoreCase(cd.getNodeName()))
  2297. + {
  2298. + attrs = cd.getAttributes();
  2299. + ALLOW_SUMMON_BY_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2300. + }
  2301. + else if ("RequireMinFragsToReward".equalsIgnoreCase(cd.getNodeName()))
  2302. + {
  2303. + attrs = cd.getAttributes();
  2304. + REQUIRE_MIN_FRAGS_TO_REWARD = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2305. + }
  2306. + else if ("MinFragsRequired".equalsIgnoreCase(cd.getNodeName()))
  2307. + {
  2308. + attrs = cd.getAttributes();
  2309. + MIN_FRAGS_TO_REWARD = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2310. + }
  2311. + }
  2312. + }
  2313. + }
  2314. + catch (Exception e)
  2315. + {
  2316. + LOGGER.warn("Error parsing DeathMatch.xml, by error: " + e.getMessage());
  2317. + }
  2318. + }
  2319. +
  2320. + public static DMConfig getInstance()
  2321. + {
  2322. + return SingletonHolder.INSTANCE;
  2323. + }
  2324. +
  2325. + private static class SingletonHolder
  2326. + {
  2327. + protected static final DMConfig INSTANCE = new DMConfig();
  2328. + }
  2329. +}
  2330. \ No newline at end of file
  2331. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java
  2332. new file mode 100644
  2333. index 0000000..5b7d6a6
  2334. --- /dev/null
  2335. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/dm/DMEvent.java
  2336. @@ -0,0 +1,174 @@
  2337. +package net.sf.l2j.gameserver.model.gameevent.dm;
  2338. +
  2339. +import java.util.HashMap;
  2340. +import java.util.TreeSet;
  2341. +
  2342. +import net.sf.l2j.gameserver.model.gameevent.GameEventTeleporter;
  2343. +import net.sf.l2j.gameserver.model.gameevent.IndividualGameEvent;
  2344. +import net.sf.l2j.gameserver.enums.SayType;
  2345. +import net.sf.l2j.gameserver.model.World;
  2346. +import net.sf.l2j.gameserver.model.actor.Creature;
  2347. +import net.sf.l2j.gameserver.model.actor.Player;
  2348. +import net.sf.l2j.gameserver.model.actor.Summon;
  2349. +import net.sf.l2j.gameserver.model.gameevent.GameEventManager;
  2350. +import net.sf.l2j.gameserver.model.gameevent.GameEventPlayer;
  2351. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  2352. +
  2353. +public final class DMEvent extends IndividualGameEvent
  2354. +{
  2355. + @Override
  2356. + public void init()
  2357. + {
  2358. + _eventName = "Death Match";
  2359. + _participants = new HashMap<>();
  2360. +
  2361. + setState(EventState.INACTIVE);
  2362. +
  2363. + GameEventManager.getInstance().registerEvent(this);
  2364. + }
  2365. +
  2366. + @Override
  2367. + public DMConfig getConfigs()
  2368. + {
  2369. + return DMConfig.getInstance();
  2370. + }
  2371. +
  2372. + /**
  2373. + * Method called to set the winners
  2374. + * @return String: msg
  2375. + */
  2376. + @Override
  2377. + public String calculateRewards()
  2378. + {
  2379. + TreeSet<GameEventPlayer> players = new TreeSet<>();
  2380. + players.addAll(_participants.values());
  2381. +
  2382. + for (int i = 0; i < 3; i++)
  2383. + {
  2384. + if (players.isEmpty())
  2385. + break;
  2386. +
  2387. + GameEventPlayer player = players.first();
  2388. +
  2389. + if (player.getKills() == 0)
  2390. + break;
  2391. +
  2392. + reward(player, i + 1);
  2393. + players.remove(player);
  2394. +
  2395. + int playerPointPrev = player.getKills();
  2396. +
  2397. + if (getConfigs().REWARD_EVENT_TIE)
  2398. + continue;
  2399. +
  2400. + while (!players.isEmpty())
  2401. + {
  2402. + player = players.first();
  2403. +
  2404. + if (player.getKills() != playerPointPrev)
  2405. + break;
  2406. +
  2407. + reward(player, i + 1);
  2408. + players.remove(player);
  2409. + }
  2410. + }
  2411. +
  2412. + setState(EventState.REWARDING);
  2413. +
  2414. + String[] topPositions;
  2415. + topPositions = getFirstPosition(3);
  2416. +
  2417. + if (topPositions != null)
  2418. + {
  2419. + World.announceToOnlinePlayers(_eventName + " Event: Winners", true);
  2420. + for (String topPosition : topPositions)
  2421. + {
  2422. + String[] row = topPosition.split("\\,");
  2423. + World.announceToOnlinePlayers(_eventName + " Event: " + row[0] + " with " + row[1] + " kills.", true);
  2424. + }
  2425. + }
  2426. + else
  2427. + World.announceToOnlinePlayers(_eventName + " Event: No players win the match (nobody was killed).", true);
  2428. +
  2429. + return "Ended, thanks to everyone who participated!";
  2430. + }
  2431. +
  2432. + private void reward(GameEventPlayer eventPlayer, int pos)
  2433. + {
  2434. + if (eventPlayer == null)
  2435. + return;
  2436. +
  2437. + final Player player = eventPlayer.getPlayer();
  2438. + if (player == null)
  2439. + return;
  2440. +
  2441. + int[][] rewards = null;
  2442. + if (pos == 1)
  2443. + rewards = getConfigs().REWARDS_1ST_PLACE;
  2444. + else if (pos == 2)
  2445. + rewards = getConfigs().REWARDS_2ND_PLACE;
  2446. + else if (pos == 3)
  2447. + rewards = getConfigs().REWARDS_3RD_PLACE;
  2448. +
  2449. + if (rewards != null)
  2450. + deliverRewards(player, rewards);
  2451. + }
  2452. +
  2453. + /**
  2454. + * Method called when a player is killed
  2455. + * @param killer as Creature
  2456. + * @param killed as Player
  2457. + */
  2458. + @Override
  2459. + public void onKill(Creature killer, Player killed)
  2460. + {
  2461. + if ((killed == null) || (killer == null) || !isRunning() || !isParticipant(killed.getObjectId()))
  2462. + return;
  2463. +
  2464. + final GameEventPlayer killedEventPlayer = _participants.get(killed.getObjectId());
  2465. + if (killedEventPlayer == null)
  2466. + return;
  2467. +
  2468. + new GameEventTeleporter(killedEventPlayer, getConfigs().EVENT_COORDINATES, false);
  2469. +
  2470. + Player killerPlayer = null;
  2471. +
  2472. + if (killer.getSummon() != null)
  2473. + {
  2474. + killerPlayer = ((Summon) killer).getOwner();
  2475. +
  2476. + if (killerPlayer == null)
  2477. + return;
  2478. + }
  2479. + else
  2480. + killerPlayer = (Player) killer;
  2481. +
  2482. + if (isParticipant(killerPlayer.getObjectId()))
  2483. + {
  2484. + GameEventPlayer killerEventPlayer = _participants.get(killerPlayer.getObjectId());
  2485. +
  2486. + killerEventPlayer.increaseKills();
  2487. + killerPlayer.sendPacket(new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I have killed " + killed.getName() + "!"));
  2488. + killerPlayer.sendMessage("Your kills: " + killerEventPlayer.getKills());
  2489. + killerPlayer.sendMessage("Your deaths: " + killerEventPlayer.getDeaths());
  2490. +
  2491. + killedEventPlayer.increaseDeaths();
  2492. + killed.sendPacket(new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I killed you!"));
  2493. + killed.sendMessage("Your kills: " + killerEventPlayer.getKills());
  2494. + killed.sendMessage("Your deaths: " + killedEventPlayer.getDeaths());
  2495. + }
  2496. +
  2497. + if (getConfigs().ALLOW_KILL_BONUS)
  2498. + giveKillBonus(killerPlayer);
  2499. + }
  2500. +
  2501. + public static DMEvent getInstance()
  2502. + {
  2503. + return SingletonHolder.INSTANCE;
  2504. + }
  2505. +
  2506. + private static class SingletonHolder
  2507. + {
  2508. + protected static final DMEvent INSTANCE = new DMEvent();
  2509. + }
  2510. +}
  2511. \ No newline at end of file
  2512. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java
  2513. new file mode 100644
  2514. index 0000000..81ef484
  2515. --- /dev/null
  2516. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTConfig.java
  2517. @@ -0,0 +1,236 @@
  2518. +package net.sf.l2j.gameserver.model.gameevent.tvt;
  2519. +
  2520. +import java.io.File;
  2521. +
  2522. +import javax.xml.parsers.DocumentBuilderFactory;
  2523. +
  2524. +import org.w3c.dom.Document;
  2525. +import org.w3c.dom.NamedNodeMap;
  2526. +import org.w3c.dom.Node;
  2527. +
  2528. +import net.sf.l2j.commons.logging.CLogger;
  2529. +
  2530. +import net.sf.l2j.gameserver.model.gameevent.config.IGameEventConfig;
  2531. +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig;
  2532. +
  2533. +public class TvTConfig extends TeamGameEventConfig implements IGameEventConfig
  2534. +{
  2535. + protected static final CLogger LOGGER = new CLogger(TvTConfig.class.getName());
  2536. +
  2537. + /* TODO: IMPLEMENT */
  2538. + public byte NUMBER_OF_ROUNDS = 0;
  2539. + /* ------------------------------ */
  2540. +
  2541. + private TvTConfig()
  2542. + {
  2543. + load();
  2544. + }
  2545. +
  2546. + @Override
  2547. + public void load()
  2548. + {
  2549. + try
  2550. + {
  2551. + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  2552. + factory.setValidating(false);
  2553. + factory.setIgnoringComments(true);
  2554. +
  2555. + File file = new File("./data/xml/events/TvT.xml");
  2556. +
  2557. + Document doc = factory.newDocumentBuilder().parse(file);
  2558. +
  2559. + for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling())
  2560. + {
  2561. + if (!"tvt".equalsIgnoreCase(n.getNodeName()))
  2562. + continue;
  2563. +
  2564. + for (Node cd = n.getFirstChild(); cd != null; cd = cd.getNextSibling())
  2565. + {
  2566. + NamedNodeMap attrs = n.getAttributes();
  2567. +
  2568. + if ("EventTimeInterval".equalsIgnoreCase(cd.getNodeName()))
  2569. + {
  2570. + attrs = cd.getAttributes();
  2571. + EVENT_INTERVAL = attrs.getNamedItem("val").getNodeValue().split(",");
  2572. + }
  2573. + else if ("Duration".equalsIgnoreCase(cd.getNodeName()))
  2574. + {
  2575. + attrs = cd.getAttributes();
  2576. + EVENT_DURATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2577. + }
  2578. + else if ("Participants".equalsIgnoreCase(cd.getNodeName()))
  2579. + {
  2580. + attrs = cd.getAttributes();
  2581. + MIN_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("min").getNodeValue());
  2582. + MAX_PARTICIPANTS = Short.parseShort(attrs.getNamedItem("max").getNodeValue());
  2583. + }
  2584. + else if ("Level".equalsIgnoreCase(cd.getNodeName()))
  2585. + {
  2586. + attrs = cd.getAttributes();
  2587. + MIN_LEVEL = Byte.parseByte(attrs.getNamedItem("min").getNodeValue());
  2588. + MAX_LEVEL = Byte.parseByte(attrs.getNamedItem("max").getNodeValue());
  2589. + }
  2590. + else if ("TimeToRegistration".equalsIgnoreCase(cd.getNodeName()))
  2591. + {
  2592. + attrs = cd.getAttributes();
  2593. + REGISTRATION_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2594. + }
  2595. + else if ("TimeToTeleport".equalsIgnoreCase(cd.getNodeName()))
  2596. + {
  2597. + attrs = cd.getAttributes();
  2598. + TELEPORT_TIME = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2599. + }
  2600. + else if ("AllowTakeItem".equalsIgnoreCase(cd.getNodeName()))
  2601. + {
  2602. + attrs = cd.getAttributes();
  2603. + ALLOW_TAKE_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2604. + }
  2605. + else if ("TakeItem".equalsIgnoreCase(cd.getNodeName()))
  2606. + {
  2607. + attrs = cd.getAttributes();
  2608. + TAKE_ITEM_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
  2609. + TAKE_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
  2610. + }
  2611. + else if ("AllowKillBonus".equalsIgnoreCase(cd.getNodeName()))
  2612. + {
  2613. + attrs = cd.getAttributes();
  2614. + ALLOW_KILL_BONUS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2615. + }
  2616. + else if ("KillReward".equalsIgnoreCase(cd.getNodeName()))
  2617. + {
  2618. + attrs = cd.getAttributes();
  2619. + KILL_BONUS_ID = Short.parseShort(attrs.getNamedItem("id").getNodeValue());
  2620. + KILL_BONUS_COUNT = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
  2621. + }
  2622. + else if ("StopAllEffects".equalsIgnoreCase(cd.getNodeName()))
  2623. + {
  2624. + attrs = cd.getAttributes();
  2625. + STOP_ALL_EFFECTS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2626. + }
  2627. + else if ("HidePlayersIdentity".equalsIgnoreCase(cd.getNodeName()))
  2628. + {
  2629. + attrs = cd.getAttributes();
  2630. + HIDE_PLAYERS_IDENTITY = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2631. + }
  2632. + else if ("Team".equalsIgnoreCase(cd.getNodeName()))
  2633. + {
  2634. + attrs = cd.getAttributes();
  2635. + byte teamId = Byte.parseByte(attrs.getNamedItem("id").getNodeValue());
  2636. + String name = attrs.getNamedItem("name").getNodeValue();
  2637. + int color = Integer.decode("0x" + attrs.getNamedItem("color").getNodeValue());
  2638. + String[] coord = attrs.getNamedItem("coordinates").getNodeValue().split(",");
  2639. + int[] coordinates = new int[4];
  2640. +
  2641. + for (int i = 0; i < coord.length; i++)
  2642. + coordinates[i] = Integer.parseInt(coord[i]);
  2643. +
  2644. + TEAMS.add(new GameEventTeamConfig(teamId, name, color, coordinates));
  2645. + }
  2646. + else if ("Rewards".equalsIgnoreCase(cd.getNodeName()))
  2647. + {
  2648. + attrs = cd.getAttributes();
  2649. + String[] itemIds = attrs.getNamedItem("id").getNodeValue().split(",");
  2650. + String[] counts = attrs.getNamedItem("count").getNodeValue().split(",");
  2651. + REWARDS = new int[itemIds.length][];
  2652. + for (int i = 0; i < itemIds.length; i++)
  2653. + {
  2654. + REWARDS[i] = new int[]
  2655. + {
  2656. + Integer.parseInt(itemIds[i]),
  2657. + Integer.parseInt(counts[i])
  2658. + };
  2659. + }
  2660. + }
  2661. + else if ("RewardTeamTie".equalsIgnoreCase(cd.getNodeName()))
  2662. + {
  2663. + attrs = cd.getAttributes();
  2664. + REWARD_EVENT_TIE = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2665. + }
  2666. + else if ("ListMageSupport".equalsIgnoreCase(cd.getNodeName()))
  2667. + {
  2668. + attrs = cd.getAttributes();
  2669. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2670. + LIST_MAGE_SUPPORT = new int[skills.length];
  2671. +
  2672. + for (int i = 0; i < skills.length; i++)
  2673. + LIST_MAGE_SUPPORT[i] = Integer.parseInt(skills[i]);
  2674. + }
  2675. + else if ("ListFighterSupport".equalsIgnoreCase(cd.getNodeName()))
  2676. + {
  2677. + attrs = cd.getAttributes();
  2678. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2679. + LIST_FIGHTER_SUPPORT = new int[skills.length];
  2680. +
  2681. + for (int i = 0; i < skills.length; i++)
  2682. + LIST_FIGHTER_SUPPORT[i] = Integer.parseInt(skills[i]);
  2683. + }
  2684. + else if ("RestrictItems".equalsIgnoreCase(cd.getNodeName()))
  2685. + {
  2686. + attrs = cd.getAttributes();
  2687. + String[] items = attrs.getNamedItem("val").getNodeValue().split(",");
  2688. + RESTRICT_ITEMS = new int[items.length];
  2689. + for (int i = 0; i < items.length; i++)
  2690. + RESTRICT_ITEMS[i] = Integer.parseInt(items[i]);
  2691. + }
  2692. + else if ("RestrictSkills".equalsIgnoreCase(cd.getNodeName()))
  2693. + {
  2694. + attrs = cd.getAttributes();
  2695. + String[] skills = attrs.getNamedItem("val").getNodeValue().split(",");
  2696. + RESTRICT_SKILLS = new int[skills.length];
  2697. + for (int i = 0; i < skills.length; i++)
  2698. + RESTRICT_SKILLS[i] = Integer.parseInt(skills[i]);
  2699. + }
  2700. + else if ("AllowPotions".equalsIgnoreCase(cd.getNodeName()))
  2701. + {
  2702. + attrs = cd.getAttributes();
  2703. + ALLOW_POTIONS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2704. + }
  2705. + else if ("AllowScrolls".equalsIgnoreCase(cd.getNodeName()))
  2706. + {
  2707. + attrs = cd.getAttributes();
  2708. + ALLOW_SCROLLS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2709. + }
  2710. + else if ("AllowSummonByItem".equalsIgnoreCase(cd.getNodeName()))
  2711. + {
  2712. + attrs = cd.getAttributes();
  2713. + ALLOW_SUMMON_BY_ITEM = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2714. + }
  2715. + else if ("AllowTargetTeamMembers".equalsIgnoreCase(cd.getNodeName()))
  2716. + {
  2717. + attrs = cd.getAttributes();
  2718. + ALLOW_TARGET_TEAM_MEMBERS = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2719. + }
  2720. + else if ("RequireMinFragsToReward".equalsIgnoreCase(cd.getNodeName()))
  2721. + {
  2722. + attrs = cd.getAttributes();
  2723. + REQUIRE_MIN_FRAGS_TO_REWARD = Boolean.parseBoolean(attrs.getNamedItem("val").getNodeValue());
  2724. + }
  2725. + else if ("MinFragsRequired".equalsIgnoreCase(cd.getNodeName()))
  2726. + {
  2727. + attrs = cd.getAttributes();
  2728. + MIN_FRAGS_TO_REWARD = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2729. + }
  2730. + else if ("NumberOfRounds".equalsIgnoreCase(cd.getNodeName()))
  2731. + {
  2732. + attrs = cd.getAttributes();
  2733. + NUMBER_OF_ROUNDS = Byte.parseByte(attrs.getNamedItem("val").getNodeValue());
  2734. + }
  2735. + }
  2736. + }
  2737. + }
  2738. + catch (Exception e)
  2739. + {
  2740. + LOGGER.warn("Error parsing TvT.xml, by error: " + e.getMessage());
  2741. + }
  2742. + }
  2743. +
  2744. + public static TvTConfig getInstance()
  2745. + {
  2746. + return SingletonHolder.INSTANCE;
  2747. + }
  2748. +
  2749. + private static class SingletonHolder
  2750. + {
  2751. + protected static final TvTConfig INSTANCE = new TvTConfig();
  2752. + }
  2753. +}
  2754. \ No newline at end of file
  2755. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java
  2756. new file mode 100644
  2757. index 0000000..bc8787a
  2758. --- /dev/null
  2759. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/model/gameevent/tvt/TvTEvent.java
  2760. @@ -0,0 +1,109 @@
  2761. +package net.sf.l2j.gameserver.model.gameevent.tvt;
  2762. +
  2763. +import java.util.List;
  2764. +
  2765. +import net.sf.l2j.gameserver.enums.SayType;
  2766. +import net.sf.l2j.gameserver.model.actor.Creature;
  2767. +import net.sf.l2j.gameserver.model.actor.Player;
  2768. +import net.sf.l2j.gameserver.model.actor.Summon;
  2769. +import net.sf.l2j.gameserver.model.gameevent.GameEventManager;
  2770. +import net.sf.l2j.gameserver.model.gameevent.GameEventPlayer;
  2771. +import net.sf.l2j.gameserver.model.gameevent.GameEventTeam;
  2772. +import net.sf.l2j.gameserver.model.gameevent.GameEventTeleporter;
  2773. +import net.sf.l2j.gameserver.model.gameevent.TeamGameEvent;
  2774. +import net.sf.l2j.gameserver.model.gameevent.config.TeamGameEventConfig.GameEventTeamConfig;
  2775. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  2776. +
  2777. +public final class TvTEvent extends TeamGameEvent
  2778. +{
  2779. + @Override
  2780. + public void init()
  2781. + {
  2782. + _eventName = "Team vs Team";
  2783. +
  2784. + List<GameEventTeamConfig> teamsConfig = getConfigs().TEAMS;
  2785. + _teams = new GameEventTeam[teamsConfig.size()];
  2786. + for (int i = 0; i < teamsConfig.size(); i++)
  2787. + _teams[i] = new GameEventTeam(teamsConfig.get(i).getId(), teamsConfig.get(i).getName(), teamsConfig.get(i).getColor(), teamsConfig.get(i).getCoordinates());
  2788. +
  2789. + setState(EventState.INACTIVE);
  2790. +
  2791. + GameEventManager.getInstance().registerEvent(this);
  2792. + }
  2793. +
  2794. + @Override
  2795. + public TvTConfig getConfigs()
  2796. + {
  2797. + return TvTConfig.getInstance();
  2798. + }
  2799. +
  2800. + /**
  2801. + * Method called when a player is killed
  2802. + * @param killer as Creature
  2803. + * @param killed as Player
  2804. + */
  2805. + @Override
  2806. + public void onKill(Creature killer, Player killed)
  2807. + {
  2808. + if ((killed == null) || (killer == null) || !isRunning())
  2809. + return;
  2810. +
  2811. + final GameEventTeam killedTeam = getParticipantTeam(killed.getObjectId());
  2812. + if (killedTeam == null)
  2813. + return;
  2814. +
  2815. + final GameEventPlayer killedEventPlayer = killedTeam.getEventPlayer(killed.getObjectId());
  2816. + if (killedEventPlayer == null)
  2817. + return;
  2818. +
  2819. + new GameEventTeleporter(killedEventPlayer, killedTeam.getCoordinates(), false);
  2820. +
  2821. + Player killerPlayer = null;
  2822. +
  2823. + if (killer.getSummon() != null)
  2824. + {
  2825. + killerPlayer = ((Summon) killer).getOwner();
  2826. +
  2827. + if (killerPlayer == null)
  2828. + return;
  2829. + }
  2830. + else
  2831. + killerPlayer = (Player) killer;
  2832. +
  2833. + final GameEventTeam killerTeam = getParticipantTeam(killerPlayer.getObjectId());
  2834. + if (killerTeam == null)
  2835. + return;
  2836. +
  2837. + final GameEventPlayer killerEventPlayer = killerTeam.getEventPlayer(killerPlayer.getObjectId());
  2838. + if (killerEventPlayer == null)
  2839. + return;
  2840. +
  2841. + if (killerTeam.getId() != killedTeam.getId())
  2842. + {
  2843. + killedEventPlayer.increaseDeaths();
  2844. + killedEventPlayer.increaseKills();
  2845. + killerTeam.increasePoints();
  2846. +
  2847. + CreatureSay cs = new CreatureSay(killerPlayer.getObjectId(), SayType.PARTYROOM_ALL, killerPlayer.getName(), "I have killed " + killed.getName() + "!");
  2848. +
  2849. + for (GameEventPlayer eventPlayer : killerTeam.getParticipatedPlayers().values())
  2850. + {
  2851. + if ((eventPlayer != null) && (eventPlayer.getPlayer() != null))
  2852. + eventPlayer.getPlayer().sendPacket(cs);
  2853. + }
  2854. + }
  2855. +
  2856. + if (getConfigs().ALLOW_KILL_BONUS)
  2857. + giveKillBonus(killerPlayer);
  2858. + }
  2859. +
  2860. + public static TvTEvent getInstance()
  2861. + {
  2862. + return SingletonHolder.INSTANCE;
  2863. + }
  2864. +
  2865. + private static class SingletonHolder
  2866. + {
  2867. + protected static final TvTEvent INSTANCE = new TvTEvent();
  2868. + }
  2869. +}
  2870. \ No newline at end of file
  2871.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement