Advertisement
Reanimation06

L2j TVT Event l2jmobius H5

Nov 20th, 2023
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 160.48 KB | Gaming | 0 0
  1. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
  2. index f5dcd3b..db67d4b 100644
  3. --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
  4. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
  5. @@ -562,6 +562,11 @@
  6.     <admin command="admin_stats" accessLevel="100" />
  7.     <admin command="admin_skill_test" accessLevel="100" />
  8.  
  9. +   <!-- ADMIN TVT EVENT -->
  10. +   <admin command="admin_tvt_add" accessLevel="100" />
  11. +   <admin command="admin_tvt_remove" accessLevel="100" />
  12. +   <admin command="admin_tvt_advance" accessLevel="100" />
  13. +
  14.     <!-- ADMIN VITALITY -->
  15.     <admin command="admin_set_vitality" accessLevel="100" />
  16.     <admin command="admin_set_vitality_level" accessLevel="100" />
  17. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini
  18. new file mode 100644
  19. index 0000000..b72ff18
  20. --- /dev/null
  21. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Custom/TeamVersusTeam.ini
  22. @@ -0,0 +1,116 @@
  23. +# ---------------------------------------------------------------------------
  24. +# Team vs. Team Event Engine (by HorridoJoho)
  25. +# ---------------------------------------------------------------------------
  26. +
  27. +# <u><b><font color="red">WARNING: this mod require custom NPC table support turned on !</font></b></u>
  28. +# CustomNpcTable = True in General.properties
  29. +# ---------------------------------------------------------------------------
  30. +# Enable/Disable TvTEvent System
  31. +# Default: False
  32. +TvTEventEnabled = True
  33. +
  34. +# TvT in instance
  35. +# Default: False
  36. +TvTEventInInstance = True
  37. +
  38. +# Id of the instance template for TvT
  39. +# Default: 3049 (coliseum.xml)
  40. +TvTEventInstanceId = 3049
  41. +
  42. +# Times TvT will occur (24h format).
  43. +# Default: 9:00,15:00,21:00,3:00
  44. +TvTEventInterval = 9:00,16:10,21:00,3:00
  45. +
  46. +# Registration timer from start of event (in minutes).
  47. +# Default: 30
  48. +TvTEventParticipationTime = 5
  49. +
  50. +# Event running time (in minutes).
  51. +# Default: 20
  52. +TvTEventRunningTime = 20
  53. +
  54. +# TvT Event NPC (create a custom npc of type L2TvTEventNpc).
  55. +# Default: 70010
  56. +TvTEventParticipationNpcId = 70010
  57. +
  58. +# TvT Event Participation Fee (itemId, number). Fee is not returned.
  59. +# Example: 57,100000
  60. +# Default: 0,0
  61. +TvTEventParticipationFee = 0,0
  62. +
  63. +# Location for TvTEvent NPC to spawn in form x,y,z[,heading]
  64. +# Default: 83425,148585,-3406
  65. +TvTEventParticipationNpcCoordinates = 83425,148585,-3406
  66. +
  67. +# Minimum amount of players allowed in each team.
  68. +# Default: 1
  69. +TvTEventMinPlayersInTeams = 1
  70. +# Maximum amount of players allowed in each team.
  71. +# Default: 20
  72. +TvTEventMaxPlayersInTeams = 20
  73. +
  74. +# Minimum level of players that may join the event.
  75. +# Default: 1
  76. +TvTEventMinPlayerLevel = 1
  77. +# Maximum level of players that may join the event.
  78. +# Default: 85
  79. +TvTEventMaxPlayerLevel = 85
  80. +
  81. +# Respawn delay timer (in seconds).
  82. +# Default: 10
  83. +TvTEventRespawnTeleportDelay = 10
  84. +# Exit delay timer (in seconds).
  85. +# Default: 10
  86. +TvTEventStartLeaveTeleportDelay = 10
  87. +
  88. +# First Team - Name, Start/Death x,y,z location.
  89. +TvTEventTeam1Name = Team1
  90. +TvTEventTeam1Coordinates = 148695,46725,-3414
  91. +
  92. +# Second Team - Name, Start/Death x,y,z location.
  93. +TvTEventTeam2Name = Team2
  94. +TvTEventTeam2Coordinates = 149999,46728,-3414
  95. +
  96. +# Reward for winning team.
  97. +# Example: TvTEventReward = itemId,amount;itemId,amount;itemId,amount
  98. +TvTEventReward = 57,100000
  99. +
  100. +# TvTEvent Rules
  101. +TvTEventTargetTeamMembersAllowed = True
  102. +TvTEventScrollsAllowed = False
  103. +TvTEventPotionsAllowed = False
  104. +TvTEventSummonByItemAllowed = False
  105. +
  106. +# Door ID's to open/close on start/end.
  107. +# Not supported in instance, use xml template for defining doors.
  108. +# Example: TvTDoorsToOpen = 1;2;3;4;5;6
  109. +TvTDoorsToOpen =
  110. +TvTDoorsToClose =
  111. +
  112. +# Should both teams get reward if there's a tie?
  113. +TvTRewardTeamTie = False
  114. +
  115. +# Participant's effects handling on teleport/death.
  116. +# Effects lasting through death never removed.
  117. +# 0 - always remove all effects.
  118. +# 1 - remove all effects only during port to event (noblesse blessing can be used)
  119. +# 2 - never remove any effect
  120. +# Default: 0
  121. +TvTEventEffectsRemoval = 0
  122. +
  123. +# Fighter-class participants will be buffed with those buffs each respawn
  124. +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
  125. +# Example: 1504,1;1501,1;1502,1;1499,1
  126. +TvTEventFighterBuffs =
  127. +
  128. +# Mage-class participants will be buffed with those buffs each respawn
  129. +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
  130. +# Example: 1504,1;1500,1;1501,1;1085,3
  131. +TvTEventMageBuffs =
  132. +
  133. +# Maximum number of allowed participants per IP address (dualbox check)
  134. +# Default: 0 (no limits)
  135. +TvTEventMaxParticipantsPerIP = 0
  136. +
  137. +# Voiced command (.tvt) working during TVT event to get information about event status
  138. +TvTAllowVoicedInfoCommand = True
  139. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html
  140. new file mode 100644
  141. index 0000000..77e95f2
  142. --- /dev/null
  143. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/CursedWeaponEquipped.html
  144. @@ -0,0 +1,8 @@
  145. +<html>
  146. +   <head>
  147. +       <title>TvT Event</title>
  148. +   </head>
  149. +   <body>
  150. +       Cursed weapon holders are not allowed to participate.
  151. +   </body>
  152. +</html>
  153. \ No newline at end of file
  154. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html
  155. new file mode 100644
  156. index 0000000..74d580f
  157. --- /dev/null
  158. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/IPRestriction.html
  159. @@ -0,0 +1,8 @@
  160. +<html>
  161. +   <head>
  162. +       <title>TvT Event</title>
  163. +   </head>
  164. +   <body>
  165. +       Maximum of %max% participant(s) per IP address is allowed.
  166. +   </body>
  167. +</html>
  168. \ No newline at end of file
  169. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html
  170. new file mode 100644
  171. index 0000000..4ad6698
  172. --- /dev/null
  173. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Karma.html
  174. @@ -0,0 +1,8 @@
  175. +<html>
  176. +   <head>
  177. +       <title>TvT Event</title>
  178. +   </head>
  179. +   <body>
  180. +       Chaotic players are not allowed to participate.
  181. +   </body>
  182. +</html>
  183. \ No newline at end of file
  184. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html
  185. new file mode 100644
  186. index 0000000..5d1e0d7
  187. --- /dev/null
  188. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Level.html
  189. @@ -0,0 +1,8 @@
  190. +<html>
  191. +   <head>
  192. +       <title>TvT Event</title>
  193. +   </head>
  194. +   <body>
  195. +       Only players from level %min% to level %max% are allowed to participate.
  196. +   </body>
  197. +</html>
  198. \ No newline at end of file
  199. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html
  200. new file mode 100644
  201. index 0000000..b482928
  202. --- /dev/null
  203. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Olympiad.html
  204. @@ -0,0 +1,8 @@
  205. +<html>
  206. +   <head>
  207. +       <title>TvT Event</title>
  208. +   </head>
  209. +   <body>
  210. +       You can not participate while registered for Olympiad.
  211. +   </body>
  212. +</html>
  213. \ No newline at end of file
  214. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html
  215. new file mode 100644
  216. index 0000000..65db8d2
  217. --- /dev/null
  218. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Participation.html
  219. @@ -0,0 +1,13 @@
  220. +<html>
  221. +   <head>
  222. +       <title>TvT Event</title>
  223. +   </head>
  224. +   <body>
  225. +       Registration for TvT Event:<br>
  226. +       <center>
  227. +           %playercount% players in.<br>
  228. +           Participation Fee: %fee%<br>
  229. +           <button action="bypass -h Quest TvTManager join" value="Participate" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Apply_Down" fore="L2UI_CT1.OlympiadWnd_DF_Apply">
  230. +       </center>
  231. +   </body>
  232. +</html>
  233. \ No newline at end of file
  234. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html
  235. new file mode 100644
  236. index 0000000..9aea7de
  237. --- /dev/null
  238. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/ParticipationFee.html
  239. @@ -0,0 +1,8 @@
  240. +<html>
  241. +   <head>
  242. +       <title>TvT Event</title>
  243. +   </head>
  244. +   <body>
  245. +       You need %fee% for participation.
  246. +   </body>
  247. +</html>
  248. \ No newline at end of file
  249. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html
  250. new file mode 100644
  251. index 0000000..f6eb819
  252. --- /dev/null
  253. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Registered.html
  254. @@ -0,0 +1,8 @@
  255. +<html>
  256. +   <head>
  257. +       <title>TvT Event</title>
  258. +   </head>
  259. +   <body>
  260. +       You are registered for a TvT Event.
  261. +   </body>
  262. +</html>
  263. \ No newline at end of file
  264. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html
  265. new file mode 100644
  266. index 0000000..110efb0
  267. --- /dev/null
  268. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/RemoveParticipation.html
  269. @@ -0,0 +1,13 @@
  270. +<html>
  271. +   <head>
  272. +       </head><title>TvT Event</title>
  273. +   </head>
  274. +   <body>
  275. +       Cancel registration for TvT Event:<br>
  276. +       You are already registered for this event. Do you wish to cancel your participation in this Event?<br>
  277. +       <center>
  278. +           Participation fee is not returned!<br>
  279. +           <button action="bypass -h Quest TvTManager remove" msg="1480" value="Cancel" width="200" height="31" back="L2UI_CT1.OlympiadWnd_DF_Back_Down" fore="L2UI_CT1.OlympiadWnd_DF_Back">
  280. +       </center>
  281. +   </body>
  282. +</html>
  283. \ No newline at end of file
  284. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html
  285. new file mode 100644
  286. index 0000000..be404a4
  287. --- /dev/null
  288. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Reward.html
  289. @@ -0,0 +1,9 @@
  290. +<html>
  291. +   <head>
  292. +       <title>TvT Event</title>
  293. +   </head>
  294. +   <body>
  295. +       <font color="LEVEL">Your team won the event!</font><br>
  296. +       Look in your inventory, there should be your reward.
  297. +   </body>
  298. +</html>
  299. \ No newline at end of file
  300. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html
  301. new file mode 100644
  302. index 0000000..9da25b6
  303. --- /dev/null
  304. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Status.html
  305. @@ -0,0 +1,12 @@
  306. +<html>
  307. +   <head>
  308. +       <title>TvT Event</title>
  309. +   </head>
  310. +   <body>
  311. +       Status:<br>
  312. +       <center>
  313. +           %team1name% with %team1playercount% players and %team1points% points.<br>
  314. +           %team2name% with %team2playercount% players and %team2points% points.
  315. +       </center>
  316. +   </body>
  317. +</html>
  318. \ No newline at end of file
  319. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html
  320. new file mode 100644
  321. index 0000000..3117072
  322. --- /dev/null
  323. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TeamsFull.html
  324. @@ -0,0 +1,8 @@
  325. +<html>
  326. +   <head>
  327. +       <title>TvT Event</title>
  328. +   </head>
  329. +   <body>
  330. +       The event is full! Only %max% players are allowed per team.
  331. +   </body>
  332. +</html>
  333. \ No newline at end of file
  334. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java
  335. new file mode 100644
  336. index 0000000..8fa27b4
  337. --- /dev/null
  338. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/TvTManager.java
  339. @@ -0,0 +1,220 @@
  340. +/*
  341. + * This file is part of the L2J Mobius project.
  342. + *
  343. + * This program is free software: you can redistribute it and/or modify
  344. + * it under the terms of the GNU General Public License as published by
  345. + * the Free Software Foundation, either version 3 of the License, or
  346. + * (at your option) any later version.
  347. + *
  348. + * This program is distributed in the hope that it will be useful,
  349. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  350. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  351. + * General Public License for more details.
  352. + *
  353. + * You should have received a copy of the GNU General Public License
  354. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  355. + */
  356. +package custom.events.TvT.TvTManager;
  357. +
  358. +import org.l2jmobius.Config;
  359. +import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
  360. +import org.l2jmobius.gameserver.handler.VoicedCommandHandler;
  361. +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
  362. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  363. +import org.l2jmobius.gameserver.model.actor.Npc;
  364. +import org.l2jmobius.gameserver.model.actor.Player;
  365. +import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
  366. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  367. +
  368. +import ai.AbstractNpcAI;
  369. +
  370. +/**
  371. + * TvT Manager AI.
  372. + * @author Zoey76
  373. + */
  374. +public class TvTManager extends AbstractNpcAI implements IVoicedCommandHandler
  375. +{
  376. +   private static final int MANAGER_ID = 70010;
  377. +   private static final String[] COMMANDS =
  378. +   {
  379. +       "tvt",
  380. +       "tvtjoin",
  381. +       "tvtleave"
  382. +   };
  383. +  
  384. +   public TvTManager()
  385. +   {
  386. +       addFirstTalkId(MANAGER_ID);
  387. +       addTalkId(MANAGER_ID);
  388. +       addStartNpc(MANAGER_ID);
  389. +      
  390. +       if (Config.TVT_ALLOW_VOICED_COMMAND)
  391. +       {
  392. +           VoicedCommandHandler.getInstance().registerHandler(this);
  393. +       }
  394. +   }
  395. +  
  396. +   @Override
  397. +   public String onAdvEvent(String event, Npc npc, Player player)
  398. +   {
  399. +       if ((player == null) || !TvTEvent.isParticipating())
  400. +       {
  401. +           return super.onAdvEvent(event, npc, player);
  402. +       }
  403. +      
  404. +       String htmltext = null;
  405. +       switch (event)
  406. +       {
  407. +           case "join":
  408. +           {
  409. +               final int playerLevel = player.getLevel();
  410. +               final int team1Count = TvTEvent.getTeamsPlayerCounts()[0];
  411. +               final int team2Count = TvTEvent.getTeamsPlayerCounts()[1];
  412. +               if (player.isCursedWeaponEquipped())
  413. +               {
  414. +                   htmltext = getHtm(player, "CursedWeaponEquipped.html");
  415. +               }
  416. +               else if (OlympiadManager.getInstance().isRegistered(player))
  417. +               {
  418. +                   htmltext = getHtm(player, "Olympiad.html");
  419. +               }
  420. +               else if (player.getKarma() > 0)
  421. +               {
  422. +                   htmltext = getHtm(player, "Karma.html");
  423. +               }
  424. +               else if ((playerLevel < Config.TVT_EVENT_MIN_LEVEL) || (playerLevel > Config.TVT_EVENT_MAX_LEVEL))
  425. +               {
  426. +                   htmltext = getHtm(player, "Level.html");
  427. +                   htmltext = htmltext.replace("%min%", String.valueOf(Config.TVT_EVENT_MIN_LEVEL));
  428. +                   htmltext = htmltext.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_LEVEL));
  429. +               }
  430. +               else if ((team1Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS) && (team2Count == Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS))
  431. +               {
  432. +                   htmltext = getHtm(player, "TeamsFull.html");
  433. +                   htmltext = htmltext.replace("%max%", String.valueOf(Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS));
  434. +               }
  435. +               else if ((Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP))
  436. +               {
  437. +                   htmltext = getHtm(player, "IPRestriction.html");
  438. +                   htmltext = htmltext.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP)));
  439. +               }
  440. +               else if (TvTEvent.needParticipationFee() && !TvTEvent.hasParticipationFee(player))
  441. +               {
  442. +                   htmltext = getHtm(player, "ParticipationFee.html");
  443. +                   htmltext = htmltext.replace("%fee%", TvTEvent.getParticipationFee());
  444. +               }
  445. +               else if (TvTEvent.addParticipant(player))
  446. +               {
  447. +                   htmltext = getHtm(player, "Registered.html");
  448. +               }
  449. +               break;
  450. +           }
  451. +           case "remove":
  452. +           {
  453. +               if (TvTEvent.removeParticipant(player.getObjectId()))
  454. +               {
  455. +                   if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
  456. +                   {
  457. +                       AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, player);
  458. +                   }
  459. +                   htmltext = getHtm(player, "Unregistered.html");
  460. +               }
  461. +               else
  462. +               {
  463. +                   player.sendMessage("You cannot unregister to this event.");
  464. +               }
  465. +               break;
  466. +           }
  467. +       }
  468. +       return htmltext;
  469. +   }
  470. +  
  471. +   @Override
  472. +   public String onFirstTalk(Npc npc, Player player)
  473. +   {
  474. +       String htmltext = null;
  475. +       if (TvTEvent.isParticipating())
  476. +       {
  477. +           final boolean isParticipant = TvTEvent.isPlayerParticipant(player.getObjectId());
  478. +           final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  479. +           htmltext = getHtm(player, (!isParticipant ? "Participation.html" : "RemoveParticipation.html"));
  480. +           htmltext = htmltext.replace("%objectId%", String.valueOf(npc.getObjectId()));
  481. +           htmltext = htmltext.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  482. +           htmltext = htmltext.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  483. +           htmltext = htmltext.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  484. +           htmltext = htmltext.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  485. +           htmltext = htmltext.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
  486. +           if (!isParticipant)
  487. +           {
  488. +               htmltext = htmltext.replace("%fee%", TvTEvent.getParticipationFee());
  489. +           }
  490. +       }
  491. +       else if (TvTEvent.isStarting() || TvTEvent.isStarted())
  492. +       {
  493. +           htmltext = getTvTStatus(player);
  494. +       }
  495. +       return htmltext;
  496. +   }
  497. +  
  498. +   @Override
  499. +   public boolean useVoicedCommand(String command, Player player, String params)
  500. +   {
  501. +       String html = null;
  502. +       switch (command)
  503. +       {
  504. +           case "tvt":
  505. +           {
  506. +               if (TvTEvent.isStarting() || TvTEvent.isStarted())
  507. +               {
  508. +                   html = getTvTStatus(player);
  509. +               }
  510. +               else
  511. +               {
  512. +                   html = "The event has not started.";
  513. +               }
  514. +               break;
  515. +           }
  516. +           case "tvtjoin":
  517. +           {
  518. +               html = onAdvEvent("join", null, player);
  519. +               break;
  520. +           }
  521. +           case "tvtleave":
  522. +           {
  523. +               html = onAdvEvent("remove", null, player);
  524. +               break;
  525. +           }
  526. +       }
  527. +      
  528. +       if (html != null)
  529. +       {
  530. +           player.sendPacket(new NpcHtmlMessage(html));
  531. +       }
  532. +       return true;
  533. +   }
  534. +  
  535. +   private String getTvTStatus(Player player)
  536. +   {
  537. +       final int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  538. +       final int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  539. +       String htmltext = getHtm(player, "Status.html");
  540. +       htmltext = htmltext.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  541. +       htmltext = htmltext.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  542. +       htmltext = htmltext.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  543. +       htmltext = htmltext.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  544. +       htmltext = htmltext.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  545. +       htmltext = htmltext.replace("%team2points%", String.valueOf(teamsPointsCounts[1]));
  546. +       return htmltext;
  547. +   }
  548. +  
  549. +   @Override
  550. +   public String[] getVoicedCommandList()
  551. +   {
  552. +       return COMMANDS;
  553. +   }
  554. +  
  555. +   public static void main(String[] args)
  556. +   {
  557. +       new TvTManager();
  558. +   }
  559. +}
  560. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html
  561. new file mode 100644
  562. index 0000000..0223caf
  563. --- /dev/null
  564. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/custom/events/TvT/TvTManager/Unregistered.html
  565. @@ -0,0 +1,8 @@
  566. +<html>
  567. +   <head>
  568. +       <title>TvT Event</title>
  569. +   </head>
  570. +   <body>
  571. +       You have been unregistered from the TvT Event.
  572. +   </body>
  573. +</html>
  574. \ No newline at end of file
  575. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  576. index 58c86d8..411c1bc 100644
  577. --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  578. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  579. @@ -71,6 +71,7 @@
  580. import handlers.admincommandhandlers.AdminEffects;
  581. import handlers.admincommandhandlers.AdminElement;
  582. import handlers.admincommandhandlers.AdminEnchant;
  583. +import handlers.admincommandhandlers.AdminEventEngine;
  584. import handlers.admincommandhandlers.AdminEvents;
  585. import handlers.admincommandhandlers.AdminExpSp;
  586. import handlers.admincommandhandlers.AdminFakePlayers;
  587. @@ -130,6 +131,7 @@
  588. import handlers.admincommandhandlers.AdminTerritoryWar;
  589. import handlers.admincommandhandlers.AdminTest;
  590. import handlers.admincommandhandlers.AdminTransform;
  591. +import handlers.admincommandhandlers.AdminTvTEvent;
  592. import handlers.admincommandhandlers.AdminVitality;
  593. import handlers.admincommandhandlers.AdminZone;
  594. import handlers.admincommandhandlers.AdminZones;
  595.  
  596. /**
  597. @@ -348,6 +351,7 @@
  598.             AdminElement.class,
  599.             AdminEnchant.class,
  600.             AdminEvents.class,
  601. +           AdminEventEngine.class,
  602.             AdminExpSp.class,
  603.             AdminFakePlayers.class,
  604.             AdminFence.class,
  605. @@ -406,6 +410,7 @@
  606.             AdminTerritoryWar.class,
  607.             AdminTest.class,
  608.             AdminTransform.class,
  609. +           AdminTvTEvent.class,
  610.             AdminVitality.class,
  611.             AdminZone.class,
  612.         },
  613.  
  614. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java
  615. new file mode 100644
  616. index 0000000..dde9416
  617. --- /dev/null
  618. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminEventEngine.java
  619. @@ -0,0 +1,556 @@
  620. +/*
  621. + * This file is part of the L2J Mobius project.
  622. + *
  623. + * This program is free software: you can redistribute it and/or modify
  624. + * it under the terms of the GNU General Public License as published by
  625. + * the Free Software Foundation, either version 3 of the License, or
  626. + * (at your option) any later version.
  627. + *
  628. + * This program is distributed in the hope that it will be useful,
  629. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  630. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  631. + * General Public License for more details.
  632. + *
  633. + * You should have received a copy of the GNU General Public License
  634. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  635. + */
  636. +package handlers.admincommandhandlers;
  637. +
  638. +import java.io.BufferedInputStream;
  639. +import java.io.BufferedReader;
  640. +import java.io.DataInputStream;
  641. +import java.io.File;
  642. +import java.io.FileInputStream;
  643. +import java.io.FileOutputStream;
  644. +import java.io.InputStreamReader;
  645. +import java.io.PrintStream;
  646. +import java.util.StringTokenizer;
  647. +import java.util.logging.Logger;
  648. +
  649. +import org.l2jmobius.Config;
  650. +import org.l2jmobius.commons.util.Rnd;
  651. +import org.l2jmobius.gameserver.data.xml.AdminData;
  652. +import org.l2jmobius.gameserver.data.xml.TransformData;
  653. +import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
  654. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  655. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent.EventState;
  656. +import org.l2jmobius.gameserver.model.World;
  657. +import org.l2jmobius.gameserver.model.actor.Player;
  658. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  659. +import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
  660. +import org.l2jmobius.gameserver.util.Broadcast;
  661. +
  662. +/**
  663. + * This class handles following admin commands: - admin = shows menu
  664. + * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
  665. + */
  666. +public class AdminEventEngine implements IAdminCommandHandler
  667. +{
  668. +   private static final Logger LOGGER = Logger.getLogger(AdminEventEngine.class.getName());
  669. +  
  670. +   private static final String[] ADMIN_COMMANDS =
  671. +   {
  672. +       "admin_event",
  673. +       "admin_event_new",
  674. +       "admin_event_choose",
  675. +       "admin_event_store",
  676. +       "admin_event_set",
  677. +       "admin_event_change_teams_number",
  678. +       "admin_event_announce",
  679. +       "admin_event_panel",
  680. +       "admin_event_control_begin",
  681. +       "admin_event_control_teleport",
  682. +       "admin_add",
  683. +       "admin_event_see",
  684. +       "admin_event_del",
  685. +       "admin_delete_buffer",
  686. +       "admin_event_control_sit",
  687. +       "admin_event_name",
  688. +       "admin_event_control_kill",
  689. +       "admin_event_control_res",
  690. +       "admin_event_control_transform",
  691. +       "admin_event_control_untransform",
  692. +       "admin_event_control_prize",
  693. +       "admin_event_control_chatban",
  694. +       "admin_event_control_kick",
  695. +       "admin_event_control_finish"
  696. +   };
  697. +  
  698. +   private static String tempBuffer = "";
  699. +   private static String tempName = "";
  700. +   private static boolean npcsDeleted = false;
  701. +  
  702. +   @Override
  703. +   public boolean useAdminCommand(String command, Player activeChar)
  704. +   {
  705. +       StringTokenizer st = new StringTokenizer(command);
  706. +       final String actualCommand = st.nextToken();
  707. +       try
  708. +       {
  709. +           if (actualCommand.equals("admin_event"))
  710. +           {
  711. +               if (GameEvent.eventState != EventState.OFF)
  712. +               {
  713. +                   showEventControl(activeChar);
  714. +               }
  715. +               else
  716. +               {
  717. +                   showMainPage(activeChar);
  718. +               }
  719. +           }
  720. +          
  721. +           else if (actualCommand.equals("admin_event_new"))
  722. +           {
  723. +               showNewEventPage(activeChar);
  724. +           }
  725. +           else if (actualCommand.startsWith("admin_add"))
  726. +           {
  727. +               // There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
  728. +               tempBuffer += command.substring(10);
  729. +               showNewEventPage(activeChar);
  730. +              
  731. +           }
  732. +           else if (actualCommand.startsWith("admin_event_see"))
  733. +           {
  734. +               // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  735. +               final String eventName = command.substring(16);
  736. +               try
  737. +               {
  738. +                   final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  739. +                   final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName)));
  740. +                   final BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
  741. +                   adminReply.setFile(null, "data/html/mods/EventEngine/Participation.htm");
  742. +                   adminReply.replace("%eventName%", eventName);
  743. +                   adminReply.replace("%eventCreator%", inbr.readLine());
  744. +                   adminReply.replace("%eventInfo%", inbr.readLine());
  745. +                   adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
  746. +                   adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
  747. +                   activeChar.sendPacket(adminReply);
  748. +                   inbr.close();
  749. +               }
  750. +               catch (Exception e)
  751. +               {
  752. +                   LOGGER.warning("Problem with AdminEventEngine: " + e.getMessage());
  753. +               }
  754. +           }
  755. +           else if (actualCommand.startsWith("admin_event_del"))
  756. +           {
  757. +               // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  758. +               final String eventName = command.substring(16);
  759. +               final File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
  760. +               file.delete();
  761. +               showMainPage(activeChar);
  762. +           }
  763. +           else if (actualCommand.startsWith("admin_event_name"))
  764. +           {
  765. +               // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  766. +               tempName += command.substring(17);
  767. +               showNewEventPage(activeChar);
  768. +           }
  769. +           else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
  770. +           {
  771. +               tempBuffer = "";
  772. +               showNewEventPage(activeChar);
  773. +           }
  774. +           else if (actualCommand.startsWith("admin_event_store"))
  775. +           {
  776. +               try
  777. +               {
  778. +                   final FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
  779. +                   final PrintStream p = new PrintStream(file);
  780. +                   p.println(activeChar.getName());
  781. +                   p.println(tempBuffer);
  782. +                   file.close();
  783. +                   p.close();
  784. +               }
  785. +               catch (Exception e)
  786. +               {
  787. +                   LOGGER.warning("Problem with AdminEventEngine: " + e.getMessage());
  788. +               }
  789. +              
  790. +               tempBuffer = "";
  791. +               tempName = "";
  792. +               showMainPage(activeChar);
  793. +           }
  794. +           else if (actualCommand.startsWith("admin_event_set"))
  795. +           {
  796. +               // There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
  797. +               GameEvent._eventName = command.substring(16);
  798. +               showEventParameters(activeChar, 2);
  799. +           }
  800. +           else if (actualCommand.startsWith("admin_event_change_teams_number"))
  801. +           {
  802. +               showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
  803. +           }
  804. +           else if (actualCommand.startsWith("admin_event_panel"))
  805. +           {
  806. +               showEventControl(activeChar);
  807. +           }
  808. +           else if (actualCommand.startsWith("admin_event_announce"))
  809. +           {
  810. +               GameEvent._npcId = Integer.parseInt(st.nextToken());
  811. +               GameEvent._teamsNumber = Integer.parseInt(st.nextToken());
  812. +               String temp = " ";
  813. +               String temp2 = "";
  814. +               while (st.hasMoreElements())
  815. +               {
  816. +                   temp += st.nextToken() + " ";
  817. +               }
  818. +              
  819. +               st = new StringTokenizer(temp, "-");
  820. +               Integer i = 1;
  821. +              
  822. +               while (st.hasMoreElements())
  823. +               {
  824. +                   temp2 = st.nextToken();
  825. +                   if (!temp2.equals(" "))
  826. +                   {
  827. +                       GameEvent._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
  828. +                   }
  829. +               }
  830. +              
  831. +               activeChar.sendMessage(GameEvent.startEventParticipation());
  832. +               Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");
  833. +              
  834. +               final PlaySound snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
  835. +               activeChar.sendPacket(snd);
  836. +               activeChar.broadcastPacket(snd);
  837. +              
  838. +               final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  839. +               final String replyMSG = "<html><title>[ EVENT ENGINE ]</title><body><br><center>The event <font color=\"LEVEL\">" + GameEvent._eventName + "</font> has been announced, now you can type //event_panel to see the event panel control</center><br></body></html>";
  840. +               adminReply.setHtml(replyMSG);
  841. +               activeChar.sendPacket(adminReply);
  842. +           }
  843. +           else if (actualCommand.startsWith("admin_event_control_begin"))
  844. +           {
  845. +               // Starts the event and sends a message of the result
  846. +               activeChar.sendMessage(GameEvent.startEvent());
  847. +               showEventControl(activeChar);
  848. +           }
  849. +           else if (actualCommand.startsWith("admin_event_control_finish"))
  850. +           {
  851. +               // Finishes the event and sends a message of the result
  852. +               activeChar.sendMessage(GameEvent.finishEvent());
  853. +           }
  854. +           else if (actualCommand.startsWith("admin_event_control_teleport"))
  855. +           {
  856. +               while (st.hasMoreElements()) // Every next ST should be a team number
  857. +               {
  858. +                   final int teamId = Integer.parseInt(st.nextToken());
  859. +                   for (Player player : GameEvent._teams.get(teamId))
  860. +                   {
  861. +                       player.setTitle(GameEvent._teamNames.get(teamId));
  862. +                       player.teleToLocation(activeChar.getLocation(), true);
  863. +                       player.setInstanceId(activeChar.getInstanceId());
  864. +                   }
  865. +               }
  866. +               showEventControl(activeChar);
  867. +           }
  868. +           else if (actualCommand.startsWith("admin_event_control_sit"))
  869. +           {
  870. +               while (st.hasMoreElements()) // Every next ST should be a team number
  871. +               {
  872. +                   // Integer.parseInt(st.nextToken()) == teamId
  873. +                   for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
  874. +                   {
  875. +                       if (player.getEventStatus() == null)
  876. +                       {
  877. +                           continue;
  878. +                       }
  879. +                      
  880. +                       player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
  881. +                       if (player.getEventStatus().isSitForced())
  882. +                       {
  883. +                           player.sitDown();
  884. +                       }
  885. +                       else
  886. +                       {
  887. +                           player.standUp();
  888. +                       }
  889. +                   }
  890. +               }
  891. +               showEventControl(activeChar);
  892. +           }
  893. +           else if (actualCommand.startsWith("admin_event_control_kill"))
  894. +           {
  895. +               while (st.hasMoreElements()) // Every next ST should be a team number
  896. +               {
  897. +                   for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
  898. +                   {
  899. +                       player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
  900. +                   }
  901. +               }
  902. +               showEventControl(activeChar);
  903. +           }
  904. +           else if (actualCommand.startsWith("admin_event_control_res"))
  905. +           {
  906. +               while (st.hasMoreElements()) // Every next ST should be a team number
  907. +               {
  908. +                   for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
  909. +                   {
  910. +                       if ((player == null) || !player.isDead())
  911. +                       {
  912. +                           continue;
  913. +                       }
  914. +                       player.restoreExp(100.0);
  915. +                       player.doRevive();
  916. +                       player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  917. +                       player.setCurrentCp(player.getMaxCp());
  918. +                   }
  919. +               }
  920. +               showEventControl(activeChar);
  921. +           }
  922. +           else if (actualCommand.startsWith("admin_event_control_transform"))
  923. +           {
  924. +               final int teamId = Integer.parseInt(st.nextToken());
  925. +               final int[] transIds = new int[st.countTokens()];
  926. +               int i = 0;
  927. +               while (st.hasMoreElements()) // Every next ST should be a transform ID
  928. +               {
  929. +                   transIds[i++] = Integer.parseInt(st.nextToken());
  930. +               }
  931. +              
  932. +               for (Player player : GameEvent._teams.get(teamId))
  933. +               {
  934. +                   final int transId = transIds[Rnd.get(transIds.length)];
  935. +                   if (!TransformData.getInstance().transformPlayer(transId, player))
  936. +                   {
  937. +                       AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
  938. +                   }
  939. +               }
  940. +               showEventControl(activeChar);
  941. +           }
  942. +           else if (actualCommand.startsWith("admin_event_control_untransform"))
  943. +           {
  944. +               while (st.hasMoreElements()) // Every next ST should be a team number
  945. +               {
  946. +                   for (Player player : GameEvent._teams.get(Integer.parseInt(st.nextToken())))
  947. +                   {
  948. +                       player.stopTransformation(true);
  949. +                   }
  950. +               }
  951. +               showEventControl(activeChar);
  952. +           }
  953. +           else if (actualCommand.startsWith("admin_event_control_kick"))
  954. +           {
  955. +               if (st.hasMoreElements()) // If has next token, it should be player name.
  956. +               {
  957. +                   while (st.hasMoreElements())
  958. +                   {
  959. +                       final Player player = World.getInstance().getPlayer(st.nextToken());
  960. +                       if (player != null)
  961. +                       {
  962. +                           GameEvent.removeAndResetPlayer(player);
  963. +                       }
  964. +                   }
  965. +               }
  966. +               else
  967. +               {
  968. +                   if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
  969. +                   {
  970. +                       GameEvent.removeAndResetPlayer((Player) activeChar.getTarget());
  971. +                   }
  972. +               }
  973. +               showEventControl(activeChar);
  974. +           }
  975. +           else if (actualCommand.startsWith("admin_event_control_prize"))
  976. +           {
  977. +               final int[] teamIds = new int[st.countTokens() - 2];
  978. +               int i = 0;
  979. +               while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
  980. +               {
  981. +                   teamIds[i++] = Integer.parseInt(st.nextToken());
  982. +               }
  983. +              
  984. +               final String[] n = st.nextToken().split("\\*");
  985. +               final int itemId = Integer.parseInt(st.nextToken());
  986. +               for (int teamId : teamIds)
  987. +               {
  988. +                   rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
  989. +               }
  990. +               showEventControl(activeChar);
  991. +           }
  992. +       }
  993. +       catch (Exception e)
  994. +       {
  995. +           AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
  996. +       }
  997. +       return true;
  998. +   }
  999. +  
  1000. +   @Override
  1001. +   public String[] getAdminCommandList()
  1002. +   {
  1003. +       return ADMIN_COMMANDS;
  1004. +   }
  1005. +  
  1006. +   private String showStoredEvents()
  1007. +   {
  1008. +       final File dir = new File(Config.DATAPACK_ROOT, "/data/events");
  1009. +       if (dir.isFile())
  1010. +       {
  1011. +           return "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' is a file or is corrupted!</font><br>";
  1012. +       }
  1013. +      
  1014. +       String note = "";
  1015. +       if (!dir.exists())
  1016. +       {
  1017. +           note = "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' does not exist!</font><br><font color=\"0099FF\">Trying to create it now...<br></font><br>";
  1018. +           if (dir.mkdirs())
  1019. +           {
  1020. +               note += "<font color=\"006600\">The directory '" + dir.getAbsolutePath() + "' has been created!</font><br>";
  1021. +           }
  1022. +           else
  1023. +           {
  1024. +               note += "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' hasn't been created!</font><br>";
  1025. +               return note;
  1026. +           }
  1027. +       }
  1028. +      
  1029. +       final String[] files = dir.list();
  1030. +       final StringBuilder result = new StringBuilder(files.length * 500);
  1031. +       result.append("<table>");
  1032. +       for (String fileName : files)
  1033. +       {
  1034. +           result.append("<tr><td align=center>");
  1035. +           result.append(fileName);
  1036. +           result.append(" </td></tr><tr><td><table cellspacing=0><tr><td><button value=\"Select Event\" action=\"bypass -h admin_event_set ");
  1037. +           result.append(fileName);
  1038. +           result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"View Event\" action=\"bypass -h admin_event_see ");
  1039. +           result.append(fileName);
  1040. +           result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Delete Event\" action=\"bypass -h admin_event_del ");
  1041. +           result.append(fileName);
  1042. +           result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>");
  1043. +       }
  1044. +      
  1045. +       result.append("</table>");
  1046. +      
  1047. +       return note + result;
  1048. +   }
  1049. +  
  1050. +   public void showMainPage(Player activeChar)
  1051. +   {
  1052. +       final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  1053. +       final String replyMSG = "<html><title>[ L2J EVENT ENGINE ]</title><body><br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=150 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><center><br><font color=LEVEL>Stored Events:</font><br></center>" + showStoredEvents() + "</body></html>";
  1054. +       adminReply.setHtml(replyMSG);
  1055. +       activeChar.sendPacket(adminReply);
  1056. +   }
  1057. +  
  1058. +   public void showNewEventPage(Player activeChar)
  1059. +   {
  1060. +       final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  1061. +       final StringBuilder replyMSG = new StringBuilder(512);
  1062. +       replyMSG.append("<html><title>[ L2J EVENT ENGINE ]</title><body><br><br><center><font color=LEVEL>Event name:</font><br>");
  1063. +       if (tempName.isEmpty())
  1064. +       {
  1065. +           replyMSG.append("You can also use //event_name text to insert a new title");
  1066. +           replyMSG.append("<center><multiedit var=\"name\" width=260 height=24> <button value=\"Set Event Name\" action=\"bypass -h admin_event_name $name\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1067. +       }
  1068. +       else
  1069. +       {
  1070. +           replyMSG.append(tempName);
  1071. +       }
  1072. +      
  1073. +       replyMSG.append("<br><br><font color=LEVEL>Event description:</font><br></center>");
  1074. +       if (tempBuffer.isEmpty())
  1075. +       {
  1076. +           replyMSG.append("You can also use //add text to add text or //delete_buffer to remove the text.");
  1077. +       }
  1078. +       else
  1079. +       {
  1080. +           replyMSG.append(tempBuffer);
  1081. +       }
  1082. +      
  1083. +       replyMSG.append("<center><multiedit var=\"txt\" width=270 height=100> <button value=\"Add text\" action=\"bypass -h admin_add $txt\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1084. +       replyMSG.append("<button value=\"Remove text\" action=\"bypass -h admin_delete_buffer\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1085. +       if (!(tempName.isEmpty() && tempBuffer.isEmpty()))
  1086. +       {
  1087. +           replyMSG.append("<br><button value=\"Store Event Data\" action=\"bypass -h admin_event_store\" width=160 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1088. +       }
  1089. +      
  1090. +       replyMSG.append("</center></body></html>");
  1091. +      
  1092. +       adminReply.setHtml(replyMSG.toString());
  1093. +       activeChar.sendPacket(adminReply);
  1094. +   }
  1095. +  
  1096. +   public void showEventParameters(Player activeChar, int teamnumbers)
  1097. +   {
  1098. +       final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  1099. +       final StringBuilder sb = new StringBuilder();
  1100. +       sb.append("<html><body><title>[ L2J EVENT ENGINE ]</title><br><center> Current event: <font color=\"LEVEL\">");
  1101. +       sb.append(GameEvent._eventName);
  1102. +       sb.append("</font></center><br>INFO: To start an event, you must first set the number of teams, then type their names in the boxes and finally type the NPC ID that will be the event manager (can be any existing npc) next to the \"Announce Event!\" button.<br><table width=100%>");
  1103. +       sb.append("<tr><td><button value=\"Announce Event!\" action=\"bypass -h admin_event_announce $event_npcid ");
  1104. +       sb.append(teamnumbers);
  1105. +       sb.append(" ");
  1106. +       for (int i = 1; (i - 1) < teamnumbers; i++) // Event announce params
  1107. +       {
  1108. +           sb.append("$event_teams_name");
  1109. +           sb.append(i);
  1110. +           sb.append(" - ");
  1111. +       }
  1112. +       sb.append("\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  1113. +       sb.append("<td><edit var=\"event_npcid\" width=100 height=20></td></tr>");
  1114. +       sb.append("<tr><td><button value=\"Set number of teams\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  1115. +       sb.append("<td><edit var=\"event_teams_number\" width=100 height=20></td></tr>");
  1116. +       sb.append("</table><br><center><br><br>");
  1117. +       sb.append("<font color=\"LEVEL\">Teams' names:</font><br><table width=100% cellspacing=8>");
  1118. +       for (int i = 1; (i - 1) < teamnumbers; i++) // Team names params
  1119. +       {
  1120. +           sb.append("<tr><td align=center>Team #");
  1121. +           sb.append(i);
  1122. +           sb.append(" name:</td><td><edit var=\"event_teams_name");
  1123. +           sb.append(i);
  1124. +           sb.append("\" width=150 height=15></td></tr>");
  1125. +       }
  1126. +       sb.append("</table></body></html>");
  1127. +      
  1128. +       adminReply.setHtml(sb.toString());
  1129. +       activeChar.sendPacket(adminReply);
  1130. +   }
  1131. +  
  1132. +   private void showEventControl(Player activeChar)
  1133. +   {
  1134. +       final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  1135. +       final StringBuilder sb = new StringBuilder();
  1136. +       sb.append("<html><title>[ EVENT ENGINE ]</title><body><br><center>Current event: <font color=\"LEVEL\">");
  1137. +       sb.append(GameEvent._eventName);
  1138. +       sb.append("</font></center><br><table cellspacing=-1 width=280><tr><td align=center>Type the team ID(s) that will be affected by the commands. Commands with '*' work with only 1 team ID in the field, while '!' - none.</td></tr><tr><td align=center><edit var=\"team_number\" width=100 height=15></td></tr>");
  1139. +       sb.append("<tr><td>&nbsp;</td></tr><tr><td><table width=200>");
  1140. +       if (!npcsDeleted)
  1141. +       {
  1142. +           sb.append("<tr><td><button value=\"Start!\" action=\"bypass -h admin_event_control_begin\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Destroys all event npcs so no more people can't participate now on</font></td></tr>");
  1143. +       }
  1144. +      
  1145. +       sb.append("<tr><td>&nbsp;</td></tr><tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Teleports the specified team to your position</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Sit/Stand\" action=\"bypass -h admin_event_control_sit $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Sits/Stands up the team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Kill\" action=\"bypass -h admin_event_control_kill $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Finish with the life of all the players in the selected team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Resurrect\" action=\"bypass -h admin_event_control_res $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Resurrect Team's members</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Transform*\" action=\"bypass -h admin_event_control_transform $team_number $transf_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"transf_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Transforms the team into the transformation with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"UnTransform\" action=\"bypass -h admin_event_control_untransform $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Untransforms the team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><table><tr><td width=32>Num</td><td><edit var=\"n\" width=60 height=15></td></tr><tr><td>ID</td><td><edit var=\"id\" width=60 height=15></td></tr></table></td><td><font color=\"LEVEL\">Give the specified item id to every single member of the team, you can put 5*level, 5*kills or 5 in the number field for example</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Kick Player\" action=\"bypass -h admin_event_control_kick $player_name\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"player_name\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Kicks the specified player(s) from the event. Blank field kicks target.</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"End!\" action=\"bypass -h admin_event_control_finish\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Will finish the event teleporting back all the players</font></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table></body></html>");
  1146. +       adminReply.setHtml(sb.toString());
  1147. +       activeChar.sendPacket(adminReply);
  1148. +   }
  1149. +  
  1150. +   private void rewardTeam(Player activeChar, int team, int n, int id, String type)
  1151. +   {
  1152. +       int num = n;
  1153. +       for (Player player : GameEvent._teams.get(team))
  1154. +       {
  1155. +           if (type.equalsIgnoreCase("level"))
  1156. +           {
  1157. +               num = n * player.getLevel();
  1158. +           }
  1159. +           else if (type.equalsIgnoreCase("kills") && (player.getEventStatus() != null))
  1160. +           {
  1161. +               num = n * player.getEventStatus().getKills().size();
  1162. +           }
  1163. +           else
  1164. +           {
  1165. +               num = n;
  1166. +           }
  1167. +          
  1168. +           player.addItem("Event", id, num, activeChar, true);
  1169. +          
  1170. +           final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  1171. +           adminReply.setHtml("<html><body>CONGRATULATIONS! You should have been rewarded.</body></html>");
  1172. +           player.sendPacket(adminReply);
  1173. +       }
  1174. +   }
  1175. +}
  1176. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
  1177. new file mode 100644
  1178. index 0000000..8c1c73f
  1179. --- /dev/null
  1180. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
  1181. @@ -0,0 +1,109 @@
  1182. +/*
  1183. + * This file is part of the L2J Mobius project.
  1184. + *
  1185. + * This program is free software: you can redistribute it and/or modify
  1186. + * it under the terms of the GNU General Public License as published by
  1187. + * the Free Software Foundation, either version 3 of the License, or
  1188. + * (at your option) any later version.
  1189. + *
  1190. + * This program is distributed in the hope that it will be useful,
  1191. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1192. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1193. + * General Public License for more details.
  1194. + *
  1195. + * You should have received a copy of the GNU General Public License
  1196. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1197. + */
  1198. +package handlers.admincommandhandlers;
  1199. +
  1200. +import org.l2jmobius.Config;
  1201. +import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
  1202. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  1203. +import org.l2jmobius.gameserver.instancemanager.events.TvTEventTeleporter;
  1204. +import org.l2jmobius.gameserver.instancemanager.events.TvTManager;
  1205. +import org.l2jmobius.gameserver.model.WorldObject;
  1206. +import org.l2jmobius.gameserver.model.actor.Player;
  1207. +import org.l2jmobius.gameserver.util.BuilderUtil;
  1208. +
  1209. +/**
  1210. + * @author HorridoJoho
  1211. + */
  1212. +public class AdminTvTEvent implements IAdminCommandHandler
  1213. +{
  1214. +   private static final String[] ADMIN_COMMANDS =
  1215. +   {
  1216. +       "admin_tvt_add",
  1217. +       "admin_tvt_remove",
  1218. +       "admin_tvt_advance"
  1219. +   };
  1220. +  
  1221. +   @Override
  1222. +   public boolean useAdminCommand(String command, Player activeChar)
  1223. +   {
  1224. +       if (command.equals("admin_tvt_add"))
  1225. +       {
  1226. +           final WorldObject target = activeChar.getTarget();
  1227. +           if ((target == null) || !target.isPlayer())
  1228. +           {
  1229. +               BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
  1230. +               return true;
  1231. +           }
  1232. +          
  1233. +           add(activeChar, (Player) target);
  1234. +       }
  1235. +       else if (command.equals("admin_tvt_remove"))
  1236. +       {
  1237. +           final WorldObject target = activeChar.getTarget();
  1238. +           if ((target == null) || !target.isPlayer())
  1239. +           {
  1240. +               BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
  1241. +               return true;
  1242. +           }
  1243. +          
  1244. +           remove(activeChar, (Player) target);
  1245. +       }
  1246. +       else if (command.equals("admin_tvt_advance"))
  1247. +       {
  1248. +           TvTManager.getInstance().skipDelay();
  1249. +       }
  1250. +      
  1251. +       return true;
  1252. +   }
  1253. +  
  1254. +   @Override
  1255. +   public String[] getAdminCommandList()
  1256. +   {
  1257. +       return ADMIN_COMMANDS;
  1258. +   }
  1259. +  
  1260. +   private void add(Player activeChar, Player Player)
  1261. +   {
  1262. +       if (Player.isOnEvent())
  1263. +       {
  1264. +           BuilderUtil.sendSysMessage(activeChar, "Player already participated in the event!");
  1265. +           return;
  1266. +       }
  1267. +      
  1268. +       if (!TvTEvent.addParticipant(Player))
  1269. +       {
  1270. +           BuilderUtil.sendSysMessage(activeChar, "Player instance could not be added, it seems to be null!");
  1271. +           return;
  1272. +       }
  1273. +      
  1274. +       if (TvTEvent.isStarted())
  1275. +       {
  1276. +           new TvTEventTeleporter(Player, TvTEvent.getParticipantTeamCoordinates(Player.getObjectId()), true, false);
  1277. +       }
  1278. +   }
  1279. +  
  1280. +   private void remove(Player activeChar, Player Player)
  1281. +   {
  1282. +       if (!TvTEvent.removeParticipant(Player.getObjectId()))
  1283. +       {
  1284. +           BuilderUtil.sendSysMessage(activeChar, "Player is not part of the event!");
  1285. +           return;
  1286. +       }
  1287. +      
  1288. +       new TvTEventTeleporter(Player, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
  1289. +   }
  1290. +}
  1291. \ No newline at end of file
  1292. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  1293. index f984695..516c492 100644
  1294. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  1295. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  1296. @@ -147,6 +147,9 @@
  1297.     private static final String CUSTOM_WAREHOUSE_SORTING_CONFIG_FILE = "./config/Custom/WarehouseSorting.ini";
  1298.     private static final String CUSTOM_WEDDING_CONFIG_FILE = "./config/Custom/Wedding.ini";
  1299.     private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
  1300.     private static final String CUSTOM_SUB_STUCK_CONFIG_FILE = "./config/Custom/SubStuck.ini";
  1301. +   private static final String VOTE_SYSTEM_FILE = "./config/Custom/votesystemm.ini";
  1302.    
  1303.     // --------------------------------------------------
  1304.     // Variable Definitions
  1305.  
  1306. @@ -1351,6 +1395,46 @@
  1307.     public static long SELLBUFF_MAX_PRICE;
  1308.     public static int SELLBUFF_MAX_BUFFS;
  1309.    
  1310.     /** SUBSTUCK MOD **/
  1311.     public static boolean ACUMULATIVE_SUBCLASS_SKILLS;
  1312.     public static boolean ACUMULATIVE_SUBCLASS_PASIVE;
  1313.     public static boolean ACUMULATIVE_SUBCLASS_DONT_SKILLS;
  1314.     public static String[] ACUMULATIVE_SUBCLASS_DONT_SKILLS_ID;
  1315. +  
  1316. +   /** TVT MOD **/
  1317. +   public static boolean TVT_EVENT_ENABLED;
  1318. +   public static boolean TVT_EVENT_IN_INSTANCE;
  1319. +   public static int TVT_EVENT_INSTANCE_ID;
  1320. +   public static String[] TVT_EVENT_INTERVAL;
  1321. +   public static int TVT_EVENT_PARTICIPATION_TIME;
  1322. +   public static int TVT_EVENT_RUNNING_TIME;
  1323. +   public static int TVT_EVENT_PARTICIPATION_NPC_ID;
  1324. +   public static int[] TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  1325. +   public static int[] TVT_EVENT_PARTICIPATION_FEE = new int[2];
  1326. +   public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
  1327. +   public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
  1328. +   public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
  1329. +   public static int TVT_EVENT_START_LEAVE_TELEPORT_DELAY;
  1330. +   public static String TVT_EVENT_TEAM_1_NAME;
  1331. +   public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  1332. +   public static String TVT_EVENT_TEAM_2_NAME;
  1333. +   public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  1334. +   public static List<int[]> TVT_EVENT_REWARDS;
  1335. +   public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
  1336. +   public static boolean TVT_EVENT_SCROLL_ALLOWED;
  1337. +   public static boolean TVT_EVENT_POTIONS_ALLOWED;
  1338. +   public static boolean TVT_EVENT_SUMMON_BY_ITEM_ALLOWED;
  1339. +   public static List<Integer> TVT_DOORS_IDS_TO_OPEN;
  1340. +   public static List<Integer> TVT_DOORS_IDS_TO_CLOSE;
  1341. +   public static boolean TVT_REWARD_TEAM_TIE;
  1342. +   public static byte TVT_EVENT_MIN_LEVEL;
  1343. +   public static byte TVT_EVENT_MAX_LEVEL;
  1344. +   public static int TVT_EVENT_EFFECTS_REMOVAL;
  1345. +   public static Map<Integer, Integer> TVT_EVENT_FIGHTER_BUFFS;
  1346. +   public static Map<Integer, Integer> TVT_EVENT_MAGE_BUFFS;
  1347. +   public static int TVT_EVENT_MAX_PARTICIPANTS_PER_IP;
  1348. +   public static boolean TVT_ALLOW_VOICED_COMMAND;
  1349. +  
  1350.     public static boolean ENABLE_GUI;
  1351.     public static boolean DARK_THEME;
  1352.    
  1353. @@ -3125,6 +3252,217 @@
  1354.             SELLBUFF_MAX_PRICE = sellBuffConfig.getLong("MaximumPrice", 100000000);
  1355.             SELLBUFF_MAX_BUFFS = sellBuffConfig.getInt("MaxBuffs", 15);
  1356.            
  1357.             // Load substuck config file (if exists)
  1358.             final PropertiesParser substuckConfig = new PropertiesParser(CUSTOM_SUB_STUCK_CONFIG_FILE);
  1359.             ACUMULATIVE_SUBCLASS_SKILLS = substuckConfig.getBoolean("AcumulativeSkills", false);
  1360.             ACUMULATIVE_SUBCLASS_PASIVE = substuckConfig.getBoolean("AcumulativeSkillsPasive", false);
  1361.             ACUMULATIVE_SUBCLASS_DONT_SKILLS = substuckConfig.getBoolean("DontAcumulativeSkills", true);
  1362.             ACUMULATIVE_SUBCLASS_DONT_SKILLS_ID = substuckConfig.getString("DontAcumulativeSkillsId", "351").split(";");
  1363. +          
  1364. +           // Load TeamVersusTeam config file (if exists)
  1365. +           final PropertiesParser TeamVersusTeam = new PropertiesParser(CUSTOM_TVT_CONFIG_FILE);
  1366. +           TVT_EVENT_ENABLED = TeamVersusTeam.getBoolean("TvTEventEnabled", false);
  1367. +           TVT_EVENT_IN_INSTANCE = TeamVersusTeam.getBoolean("TvTEventInInstance", false);
  1368. +           TVT_EVENT_INSTANCE_ID = TeamVersusTeam.getInt("TvTEventInstanceId", 3049);
  1369. +           TVT_EVENT_INTERVAL = TeamVersusTeam.getString("TvTEventInterval", "20:00").split(",");
  1370. +           TVT_EVENT_PARTICIPATION_TIME = TeamVersusTeam.getInt("TvTEventParticipationTime", 3600);
  1371. +           TVT_EVENT_RUNNING_TIME = TeamVersusTeam.getInt("TvTEventRunningTime", 1800);
  1372. +           TVT_EVENT_PARTICIPATION_NPC_ID = TeamVersusTeam.getInt("TvTEventParticipationNpcId", 0);
  1373. +           if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
  1374. +           {
  1375. +               TVT_EVENT_ENABLED = false;
  1376. +               LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcId");
  1377. +           }
  1378. +           else
  1379. +           {
  1380. +               String[] tvtNpcCoords = TeamVersusTeam.getString("TvTEventParticipationNpcCoordinates", "0,0,0").split(",");
  1381. +               if (tvtNpcCoords.length < 3)
  1382. +               {
  1383. +                   TVT_EVENT_ENABLED = false;
  1384. +                   LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcCoordinates");
  1385. +               }
  1386. +               else
  1387. +               {
  1388. +                   TVT_EVENT_REWARDS = new ArrayList<>();
  1389. +                   TVT_DOORS_IDS_TO_OPEN = new ArrayList<>();
  1390. +                   TVT_DOORS_IDS_TO_CLOSE = new ArrayList<>();
  1391. +                   TVT_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  1392. +                   TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  1393. +                   TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  1394. +                   TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
  1395. +                   TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
  1396. +                   TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
  1397. +                   if (tvtNpcCoords.length == 4)
  1398. +                   {
  1399. +                       TVT_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(tvtNpcCoords[3]);
  1400. +                   }
  1401. +                   TVT_EVENT_MIN_PLAYERS_IN_TEAMS = TeamVersusTeam.getInt("TvTEventMinPlayersInTeams", 1);
  1402. +                   TVT_EVENT_MAX_PLAYERS_IN_TEAMS = TeamVersusTeam.getInt("TvTEventMaxPlayersInTeams", 20);
  1403. +                   TVT_EVENT_MIN_LEVEL = TeamVersusTeam.getByte("TvTEventMinPlayerLevel", (byte) 1);
  1404. +                   TVT_EVENT_MAX_LEVEL = TeamVersusTeam.getByte("TvTEventMaxPlayerLevel", (byte) 80);
  1405. +                   TVT_EVENT_RESPAWN_TELEPORT_DELAY = TeamVersusTeam.getInt("TvTEventRespawnTeleportDelay", 20);
  1406. +                   TVT_EVENT_START_LEAVE_TELEPORT_DELAY = TeamVersusTeam.getInt("TvTEventStartLeaveTeleportDelay", 20);
  1407. +                   TVT_EVENT_EFFECTS_REMOVAL = TeamVersusTeam.getInt("TvTEventEffectsRemoval", 0);
  1408. +                   TVT_EVENT_MAX_PARTICIPANTS_PER_IP = TeamVersusTeam.getInt("TvTEventMaxParticipantsPerIP", 0);
  1409. +                   TVT_ALLOW_VOICED_COMMAND = TeamVersusTeam.getBoolean("TvTAllowVoicedInfoCommand", false);
  1410. +                   TVT_EVENT_TEAM_1_NAME = TeamVersusTeam.getString("TvTEventTeam1Name", "Team1");
  1411. +                   tvtNpcCoords = TeamVersusTeam.getString("TvTEventTeam1Coordinates", "0,0,0").split(",");
  1412. +                   if (tvtNpcCoords.length < 3)
  1413. +                   {
  1414. +                       TVT_EVENT_ENABLED = false;
  1415. +                       LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam1Coordinates");
  1416. +                   }
  1417. +                   else
  1418. +                   {
  1419. +                       TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
  1420. +                       TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
  1421. +                       TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
  1422. +                       TVT_EVENT_TEAM_2_NAME = TeamVersusTeam.getString("TvTEventTeam2Name", "Team2");
  1423. +                       tvtNpcCoords = TeamVersusTeam.getString("TvTEventTeam2Coordinates", "0,0,0").split(",");
  1424. +                       if (tvtNpcCoords.length < 3)
  1425. +                       {
  1426. +                           TVT_EVENT_ENABLED = false;
  1427. +                           LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam2Coordinates");
  1428. +                       }
  1429. +                       else
  1430. +                       {
  1431. +                           TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(tvtNpcCoords[0]);
  1432. +                           TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(tvtNpcCoords[1]);
  1433. +                           TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(tvtNpcCoords[2]);
  1434. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTEventParticipationFee", "0,0").split(",");
  1435. +                           try
  1436. +                           {
  1437. +                               TVT_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(tvtNpcCoords[0]);
  1438. +                               TVT_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(tvtNpcCoords[1]);
  1439. +                           }
  1440. +                           catch (NumberFormatException nfe)
  1441. +                           {
  1442. +                               if (tvtNpcCoords.length > 0)
  1443. +                               {
  1444. +                                   LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationFee");
  1445. +                               }
  1446. +                           }
  1447. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTEventReward", "57,100000").split(";");
  1448. +                           for (String reward : tvtNpcCoords)
  1449. +                           {
  1450. +                               final String[] rewardSplit = reward.split(",");
  1451. +                               if (rewardSplit.length != 2)
  1452. +                               {
  1453. +                                   LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  1454. +                               }
  1455. +                               else
  1456. +                               {
  1457. +                                   try
  1458. +                                   {
  1459. +                                       TVT_EVENT_REWARDS.add(new int[]
  1460. +                                       {
  1461. +                                           Integer.parseInt(rewardSplit[0]),
  1462. +                                           Integer.parseInt(rewardSplit[1])
  1463. +                                       });
  1464. +                                   }
  1465. +                                   catch (NumberFormatException nfe)
  1466. +                                   {
  1467. +                                       if (!reward.isEmpty())
  1468. +                                       {
  1469. +                                           LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  1470. +                                       }
  1471. +                                   }
  1472. +                               }
  1473. +                           }
  1474. +                           TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = TeamVersusTeam.getBoolean("TvTEventTargetTeamMembersAllowed", true);
  1475. +                           TVT_EVENT_SCROLL_ALLOWED = TeamVersusTeam.getBoolean("TvTEventScrollsAllowed", false);
  1476. +                           TVT_EVENT_POTIONS_ALLOWED = TeamVersusTeam.getBoolean("TvTEventPotionsAllowed", false);
  1477. +                           TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = TeamVersusTeam.getBoolean("TvTEventSummonByItemAllowed", false);
  1478. +                           TVT_REWARD_TEAM_TIE = TeamVersusTeam.getBoolean("TvTRewardTeamTie", false);
  1479. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTDoorsToOpen", "").split(";");
  1480. +                           for (String door : tvtNpcCoords)
  1481. +                           {
  1482. +                               try
  1483. +                               {
  1484. +                                   TVT_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  1485. +                               }
  1486. +                               catch (NumberFormatException nfe)
  1487. +                               {
  1488. +                                   if (!door.isEmpty())
  1489. +                                   {
  1490. +                                       LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTDoorsToOpen \"" + door + "\"");
  1491. +                                   }
  1492. +                               }
  1493. +                           }
  1494. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTDoorsToClose", "").split(";");
  1495. +                           for (String door : tvtNpcCoords)
  1496. +                           {
  1497. +                               try
  1498. +                               {
  1499. +                                   TVT_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  1500. +                               }
  1501. +                               catch (NumberFormatException nfe)
  1502. +                               {
  1503. +                                   if (!door.isEmpty())
  1504. +                                   {
  1505. +                                       LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTDoorsToClose \"" + door + "\"");
  1506. +                                   }
  1507. +                               }
  1508. +                           }
  1509. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTEventFighterBuffs", "").split(";");
  1510. +                           if (!tvtNpcCoords[0].isEmpty())
  1511. +                           {
  1512. +                               TVT_EVENT_FIGHTER_BUFFS = new HashMap<>(tvtNpcCoords.length);
  1513. +                               for (String skill : tvtNpcCoords)
  1514. +                               {
  1515. +                                   final String[] skillSplit = skill.split(",");
  1516. +                                   if (skillSplit.length != 2)
  1517. +                                   {
  1518. +                                       LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventFighterBuffs \"" + skill + "\"");
  1519. +                                   }
  1520. +                                   else
  1521. +                                   {
  1522. +                                       try
  1523. +                                       {
  1524. +                                           TVT_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  1525. +                                       }
  1526. +                                       catch (NumberFormatException nfe)
  1527. +                                       {
  1528. +                                           if (!skill.isEmpty())
  1529. +                                           {
  1530. +                                               LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventFighterBuffs \"" + skill + "\"");
  1531. +                                           }
  1532. +                                       }
  1533. +                                   }
  1534. +                               }
  1535. +                           }
  1536. +                           tvtNpcCoords = TeamVersusTeam.getString("TvTEventMageBuffs", "").split(";");
  1537. +                           if (!tvtNpcCoords[0].isEmpty())
  1538. +                           {
  1539. +                               TVT_EVENT_MAGE_BUFFS = new HashMap<>(tvtNpcCoords.length);
  1540. +                               for (String skill : tvtNpcCoords)
  1541. +                               {
  1542. +                                   final String[] skillSplit = skill.split(",");
  1543. +                                   if (skillSplit.length != 2)
  1544. +                                   {
  1545. +                                       LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventMageBuffs \"" + skill + "\"");
  1546. +                                   }
  1547. +                                   else
  1548. +                                   {
  1549. +                                       try
  1550. +                                       {
  1551. +                                           TVT_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  1552. +                                       }
  1553. +                                       catch (NumberFormatException nfe)
  1554. +                                       {
  1555. +                                           if (!skill.isEmpty())
  1556. +                                           {
  1557. +                                               LOGGER.warning("TvTEventEngine[Config.load()]: invalid config property -> TvTEventMageBuffs \"" + skill + "\"");
  1558. +                                           }
  1559. +                                       }
  1560. +                                   }
  1561. +                               }
  1562. +                           }
  1563. +                       }
  1564. +                   }
  1565. +               }
  1566. +           }
  1567. +          
  1568.             // Load ServerTime config file (if exists)
  1569.             final PropertiesParser serverTimeConfig = new PropertiesParser(CUSTOM_SERVER_TIME_CONFIG_FILE);
  1570.             DISPLAY_SERVER_TIME = serverTimeConfig.getBoolean("DisplayServerTime", false);
  1571. @@ -3161,6 +3499,7 @@
  1572.             // Load WalkerBotProtection config file (if exists)
  1573.             final PropertiesParser walkerBotProtectionConfig = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);
  1574.             L2WALKER_PROTECTION = walkerBotProtectionConfig.getBoolean("L2WalkerProtection", false);
  1575. +          
  1576.         }
  1577.         else if (SERVER_MODE == ServerMode.LOGIN)
  1578.         {
  1579. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  1580. index 192c862..636ef8a 100644
  1581. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  1582. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  1583. @@ -137,6 +137,7 @@
  1584.  import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
  1585.  import org.l2jmobius.gameserver.instancemanager.WalkingManager;
  1586.  import org.l2jmobius.gameserver.instancemanager.ZoneManager;
  1587. +import org.l2jmobius.gameserver.instancemanager.events.TvTManager;
  1588.  import org.l2jmobius.gameserver.instancemanager.games.Lottery;
  1589.  import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
  1590.  import org.l2jmobius.gameserver.model.AutoSpawnHandler;
  1591.  
  1592.  
  1593.  
  1594.  public class GameServer
  1595.  {
  1596.  
  1597. @@ -430,6 +440,8 @@
  1598.        
  1599.         LOGGER.info("IdManager: Free ObjectID's remaining: " + IdManager.getInstance().size());
  1600.        
  1601. +       TvTManager.getInstance();
  1602. +      
  1603.         if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
  1604.         {
  1605.             OfflineTraderTable.getInstance().restoreOfflineTraders();
  1606. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java
  1607. new file mode 100644
  1608. index 0000000..ec9409c
  1609. --- /dev/null
  1610. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/EventTask.java
  1611. @@ -0,0 +1,27 @@
  1612. +/*
  1613. + * This file is part of the L2J Mobius project.
  1614. + *
  1615. + * This program is free software: you can redistribute it and/or modify
  1616. + * it under the terms of the GNU General Public License as published by
  1617. + * the Free Software Foundation, either version 3 of the License, or
  1618. + * (at your option) any later version.
  1619. + *
  1620. + * This program is distributed in the hope that it will be useful,
  1621. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1622. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1623. + * General Public License for more details.
  1624. + *
  1625. + * You should have received a copy of the GNU General Public License
  1626. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1627. + */
  1628. +package org.l2jmobius.gameserver.instancemanager.events;
  1629. +
  1630. +/**
  1631. + * @author Shyla
  1632. + */
  1633. +public interface EventTask extends Runnable
  1634. +{
  1635. +   String getEventIdentifier();
  1636. +  
  1637. +   String getEventStartTime(); // hh:mm (es. 01:05)
  1638. +}
  1639. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
  1640. new file mode 100644
  1641. index 0000000..35c9498
  1642. --- /dev/null
  1643. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/GameEvent.java
  1644. @@ -0,0 +1,544 @@
  1645. +/*
  1646. + * This file is part of the L2J Mobius project.
  1647. + *
  1648. + * This program is free software: you can redistribute it and/or modify
  1649. + * it under the terms of the GNU General Public License as published by
  1650. + * the Free Software Foundation, either version 3 of the License, or
  1651. + * (at your option) any later version.
  1652. + *
  1653. + * This program is distributed in the hope that it will be useful,
  1654. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1655. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1656. + * General Public License for more details.
  1657. + *
  1658. + * You should have received a copy of the GNU General Public License
  1659. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1660. + */
  1661. +package org.l2jmobius.gameserver.instancemanager.events;
  1662. +
  1663. +import java.io.BufferedReader;
  1664. +import java.io.FileReader;
  1665. +import java.util.ArrayList;
  1666. +import java.util.Collection;
  1667. +import java.util.Comparator;
  1668. +import java.util.HashMap;
  1669. +import java.util.LinkedHashMap;
  1670. +import java.util.LinkedList;
  1671. +import java.util.List;
  1672. +import java.util.Map;
  1673. +import java.util.Map.Entry;
  1674. +import java.util.concurrent.ConcurrentHashMap;
  1675. +import java.util.concurrent.CopyOnWriteArrayList;
  1676. +import java.util.logging.Level;
  1677. +import java.util.logging.Logger;
  1678. +
  1679. +import org.l2jmobius.Config;
  1680. +import org.l2jmobius.gameserver.cache.HtmCache;
  1681. +import org.l2jmobius.gameserver.data.SpawnTable;
  1682. +import org.l2jmobius.gameserver.data.xml.NpcData;
  1683. +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
  1684. +import org.l2jmobius.gameserver.model.Spawn;
  1685. +import org.l2jmobius.gameserver.model.World;
  1686. +import org.l2jmobius.gameserver.model.actor.Npc;
  1687. +import org.l2jmobius.gameserver.model.actor.Player;
  1688. +import org.l2jmobius.gameserver.model.holders.PlayerEventHolder;
  1689. +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
  1690. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  1691. +
  1692. +/**
  1693. + * @author Nik
  1694. + * @Since 2011/05/17 21:51:39
  1695. + */
  1696. +public class GameEvent
  1697. +{
  1698. +   protected static final Logger LOGGER = Logger.getLogger(GameEvent.class.getName());
  1699. +   public static EventState eventState = EventState.OFF;
  1700. +   public static String _eventName = "";
  1701. +   public static String _eventCreator = "";
  1702. +   public static String _eventInfo = "";
  1703. +   public static int _teamsNumber = 0;
  1704. +   public static final Map<Integer, String> _teamNames = new ConcurrentHashMap<>();
  1705. +   public static final Collection<Player> _registeredPlayers = ConcurrentHashMap.newKeySet();
  1706. +   public static final Map<Integer, List<Player>> _teams = new ConcurrentHashMap<>();
  1707. +   public static int _npcId = 0;
  1708. +   private static final Map<Player, PlayerEventHolder> _connectionLossData = new ConcurrentHashMap<>();
  1709. +  
  1710. +   public enum EventState
  1711. +   {
  1712. +       OFF, // Not running
  1713. +       STANDBY, // Waiting for participants to register
  1714. +       ON // Registration is over and the event has started.
  1715. +   }
  1716. +  
  1717. +   /**
  1718. +    * @param player
  1719. +    * @return The team ID where the player is in, or -1 if player is null or team not found.
  1720. +    */
  1721. +   public static int getPlayerTeamId(Player player)
  1722. +   {
  1723. +       if (player == null)
  1724. +       {
  1725. +           return -1;
  1726. +       }
  1727. +      
  1728. +       for (Entry<Integer, List<Player>> team : _teams.entrySet())
  1729. +       {
  1730. +           if (team.getValue().contains(player))
  1731. +           {
  1732. +               return team.getKey();
  1733. +           }
  1734. +       }
  1735. +      
  1736. +       return -1;
  1737. +   }
  1738. +  
  1739. +   public static List<Player> getTopNKillers(int n)
  1740. +   {
  1741. +       final Map<Player, Integer> tmp = new HashMap<>();
  1742. +       for (List<Player> teamList : _teams.values())
  1743. +       {
  1744. +           for (Player player : teamList)
  1745. +           {
  1746. +               if (player.getEventStatus() == null)
  1747. +               {
  1748. +                   continue;
  1749. +               }
  1750. +               tmp.put(player, player.getEventStatus().getKills().size());
  1751. +           }
  1752. +       }
  1753. +      
  1754. +       sortByValue(tmp);
  1755. +       return tmp.size() <= n ? new ArrayList<>(tmp.keySet()) : (new ArrayList<>(tmp.keySet())).subList(1, n);
  1756. +   }
  1757. +  
  1758. +   public static void showEventHtml(Player player, String objectid)
  1759. +   {
  1760. +       // TODO: work on this
  1761. +       if (eventState == EventState.STANDBY)
  1762. +       {
  1763. +           try
  1764. +           {
  1765. +               final String htmContent;
  1766. +               final NpcHtmlMessage html = new NpcHtmlMessage(Integer.parseInt(objectid));
  1767. +               if (_registeredPlayers.contains(player))
  1768. +               {
  1769. +                   htmContent = HtmCache.getInstance().getHtm(player, "data/html/mods/EventEngine/Participating.htm");
  1770. +               }
  1771. +               else
  1772. +               {
  1773. +                   htmContent = HtmCache.getInstance().getHtm(player, "data/html/mods/EventEngine/Participation.htm");
  1774. +               }
  1775. +              
  1776. +               if (htmContent != null)
  1777. +               {
  1778. +                   html.setHtml(htmContent);
  1779. +               }
  1780. +              
  1781. +               html.replace("%objectId%", objectid); // Yeah, we need this.
  1782. +               html.replace("%eventName%", _eventName);
  1783. +               html.replace("%eventCreator%", _eventCreator);
  1784. +               html.replace("%eventInfo%", _eventInfo);
  1785. +               player.sendPacket(html);
  1786. +           }
  1787. +           catch (Exception e)
  1788. +           {
  1789. +               LOGGER.log(Level.WARNING, "Exception on showEventHtml(): " + e.getMessage(), e);
  1790. +           }
  1791. +       }
  1792. +   }
  1793. +  
  1794. +   /**
  1795. +    * Spawns an event participation NPC near the player. The npc id used to spawning is GameEvent._npcId
  1796. +    * @param target
  1797. +    */
  1798. +   public static void spawnEventNpc(Player target)
  1799. +   {
  1800. +       try
  1801. +       {
  1802. +           final Spawn spawn = new Spawn(_npcId);
  1803. +           spawn.setXYZ(target.getX() + 50, target.getY() + 50, target.getZ());
  1804. +           spawn.setAmount(1);
  1805. +           spawn.setHeading(target.getHeading());
  1806. +           spawn.stopRespawn();
  1807. +           SpawnTable.getInstance().addNewSpawn(spawn, false);
  1808. +           spawn.init();
  1809. +           spawn.getLastSpawn().setCurrentHp(999999999);
  1810. +           spawn.getLastSpawn().setTitle(_eventName);
  1811. +           spawn.getLastSpawn().setEventMob(true);
  1812. +           // spawn.getLastSpawn().decayMe();
  1813. +           // spawn.getLastSpawn().spawnMe(spawn.getLastSpawn().getX(), spawn.getLastSpawn().getY(), spawn.getLastSpawn().getZ());
  1814. +           spawn.getLastSpawn().broadcastPacket(new MagicSkillUse(spawn.getLastSpawn(), spawn.getLastSpawn(), 1034, 1, 1, 1));
  1815. +          
  1816. +           // _npcs.add(spawn.getLastSpawn());
  1817. +       }
  1818. +       catch (Exception e)
  1819. +       {
  1820. +           LOGGER.log(Level.WARNING, "Exception on spawn(): " + e.getMessage(), e);
  1821. +       }
  1822. +   }
  1823. +  
  1824. +   /**
  1825. +    * Zoey76: TODO: Rewrite this in a way that doesn't iterate over all spawns.
  1826. +    */
  1827. +   public static void unspawnEventNpcs()
  1828. +   {
  1829. +       SpawnTable.getInstance().forEachSpawn(spawn ->
  1830. +       {
  1831. +           final Npc npc = spawn.getLastSpawn();
  1832. +           if ((npc != null) && npc.isEventMob())
  1833. +           {
  1834. +               npc.deleteMe();
  1835. +               spawn.stopRespawn();
  1836. +               SpawnTable.getInstance().deleteSpawn(spawn, false);
  1837. +           }
  1838. +           return true;
  1839. +       });
  1840. +   }
  1841. +  
  1842. +   /**
  1843. +    * @param player
  1844. +    * @return False: If player is null, his event status is null or the event state is off. True: if the player is inside the _registeredPlayers list while the event state is STANDBY. If the event state is ON, it will check if the player is inside in one of the teams.
  1845. +    */
  1846. +   public static boolean isParticipant(Player player)
  1847. +   {
  1848. +       if ((player == null) || (player.getEventStatus() == null))
  1849. +       {
  1850. +           return false;
  1851. +       }
  1852. +      
  1853. +       switch (eventState)
  1854. +       {
  1855. +           case OFF:
  1856. +           {
  1857. +               return false;
  1858. +           }
  1859. +           case STANDBY:
  1860. +           {
  1861. +               return _registeredPlayers.contains(player);
  1862. +           }
  1863. +           case ON:
  1864. +           {
  1865. +               for (List<Player> teamList : _teams.values())
  1866. +               {
  1867. +                   if (teamList.contains(player))
  1868. +                   {
  1869. +                       return true;
  1870. +                   }
  1871. +               }
  1872. +           }
  1873. +       }
  1874. +       return false;
  1875. +   }
  1876. +  
  1877. +   /**
  1878. +    * Adds the player to the list of participants. If the event state is NOT STANDBY, the player wont be registered.
  1879. +    * @param player
  1880. +    */
  1881. +   public static void registerPlayer(Player player)
  1882. +   {
  1883. +       if (eventState != EventState.STANDBY)
  1884. +       {
  1885. +           player.sendMessage("The registration period for this event is over.");
  1886. +           return;
  1887. +       }
  1888. +      
  1889. +       if ((Config.DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP == 0) || AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.L2EVENT_ID, player, Config.DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP))
  1890. +       {
  1891. +           _registeredPlayers.add(player);
  1892. +       }
  1893. +       else
  1894. +       {
  1895. +           player.sendMessage("You have reached the maximum allowed participants per IP.");
  1896. +       }
  1897. +   }
  1898. +  
  1899. +   /**
  1900. +    * Removes the player from the participating players and the teams and restores his init stats before he registered at the event (loc, pvp, pk, title etc)
  1901. +    * @param player
  1902. +    */
  1903. +   public static void removeAndResetPlayer(Player player)
  1904. +   {
  1905. +       try
  1906. +       {
  1907. +           if (isParticipant(player))
  1908. +           {
  1909. +               if (player.isDead())
  1910. +               {
  1911. +                   player.restoreExp(100.0);
  1912. +                   player.doRevive();
  1913. +                   player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  1914. +                   player.setCurrentCp(player.getMaxCp());
  1915. +               }
  1916. +              
  1917. +               player.decayMe();
  1918. +               player.spawnMe(player.getX(), player.getY(), player.getZ());
  1919. +               player.broadcastUserInfo();
  1920. +              
  1921. +               player.stopTransformation(true);
  1922. +           }
  1923. +          
  1924. +           if (player.getEventStatus() != null)
  1925. +           {
  1926. +               player.getEventStatus().restorePlayerStats();
  1927. +           }
  1928. +          
  1929. +           player.setEventStatus(null);
  1930. +          
  1931. +           _registeredPlayers.remove(player);
  1932. +           final int teamId = getPlayerTeamId(player);
  1933. +           if (_teams.containsKey(teamId))
  1934. +           {
  1935. +               _teams.get(teamId).remove(player);
  1936. +           }
  1937. +       }
  1938. +       catch (Exception e)
  1939. +       {
  1940. +           LOGGER.log(Level.WARNING, "Error at unregisterAndResetPlayer in the event:" + e.getMessage(), e);
  1941. +       }
  1942. +   }
  1943. +  
  1944. +   /**
  1945. +    * The player's event status will be saved at _connectionLossData
  1946. +    * @param player
  1947. +    */
  1948. +   public static void savePlayerEventStatus(Player player)
  1949. +   {
  1950. +       _connectionLossData.put(player, player.getEventStatus());
  1951. +   }
  1952. +  
  1953. +   /**
  1954. +    * If _connectionLossData contains the player, it will restore the player's event status. Also it will remove the player from the _connectionLossData.
  1955. +    * @param player
  1956. +    */
  1957. +   public static void restorePlayerEventStatus(Player player)
  1958. +   {
  1959. +       if (_connectionLossData.containsKey(player))
  1960. +       {
  1961. +           player.setEventStatus(_connectionLossData.get(player));
  1962. +           _connectionLossData.remove(player);
  1963. +       }
  1964. +   }
  1965. +  
  1966. +   /**
  1967. +    * If the event is ON or STANDBY, it will not start. Sets the event state to STANDBY and spawns registration NPCs
  1968. +    * @return a string with information if the event participation has been successfully started or not.
  1969. +    */
  1970. +   public static String startEventParticipation()
  1971. +   {
  1972. +       try
  1973. +       {
  1974. +           switch (eventState)
  1975. +           {
  1976. +               case ON:
  1977. +               {
  1978. +                   return "Cannot start event, it is already on.";
  1979. +               }
  1980. +               case STANDBY:
  1981. +               {
  1982. +                   return "Cannot start event, it is on standby mode.";
  1983. +               }
  1984. +               case OFF: // Event is off, so no problem turning it on.
  1985. +               {
  1986. +                   eventState = EventState.STANDBY;
  1987. +                   break;
  1988. +               }
  1989. +           }
  1990. +          
  1991. +           // Register the event at AntiFeedManager and clean it for just in case if the event is already registered.
  1992. +           AntiFeedManager.getInstance().registerEvent(AntiFeedManager.L2EVENT_ID);
  1993. +           AntiFeedManager.getInstance().clear(AntiFeedManager.L2EVENT_ID);
  1994. +          
  1995. +           // Just in case
  1996. +           unspawnEventNpcs();
  1997. +           _registeredPlayers.clear();
  1998. +           // _npcs.clear();
  1999. +           if (NpcData.getInstance().getTemplate(_npcId) == null)
  2000. +           {
  2001. +               return "Cannot start event, invalid npc id.";
  2002. +           }
  2003. +          
  2004. +           try (FileReader fr = new FileReader(Config.DATAPACK_ROOT + "/data/events/" + _eventName);
  2005. +               BufferedReader br = new BufferedReader(fr))
  2006. +           {
  2007. +               _eventCreator = br.readLine();
  2008. +               _eventInfo = br.readLine();
  2009. +           }
  2010. +          
  2011. +           final List<Player> temp = new LinkedList<>();
  2012. +           for (Player player : World.getInstance().getPlayers())
  2013. +           {
  2014. +               if (!player.isOnline())
  2015. +               {
  2016. +                   continue;
  2017. +               }
  2018. +              
  2019. +               if (!temp.contains(player))
  2020. +               {
  2021. +                   spawnEventNpc(player);
  2022. +                   temp.add(player);
  2023. +               }
  2024. +               World.getInstance().forEachVisibleObject(player, Player.class, playertemp ->
  2025. +               {
  2026. +                   if ((Math.abs(playertemp.getX() - player.getX()) < 1000) && (Math.abs(playertemp.getY() - player.getY()) < 1000) && (Math.abs(playertemp.getZ() - player.getZ()) < 1000))
  2027. +                   {
  2028. +                       temp.add(playertemp);
  2029. +                   }
  2030. +               });
  2031. +           }
  2032. +       }
  2033. +       catch (Exception e)
  2034. +       {
  2035. +           LOGGER.warning("Event: " + e.getMessage());
  2036. +           return "Cannot start event participation, an error has occured.";
  2037. +       }
  2038. +      
  2039. +       return "The event participation has been successfully started.";
  2040. +   }
  2041. +  
  2042. +   /**
  2043. +    * If the event is ON or OFF, it will not start. Sets the event state to ON, creates the teams, adds the registered players ordered by level at the teams and adds a new event status to the players.
  2044. +    * @return a string with information if the event has been successfully started or not.
  2045. +    */
  2046. +   public static String startEvent()
  2047. +   {
  2048. +       try
  2049. +       {
  2050. +           switch (eventState)
  2051. +           {
  2052. +               case ON:
  2053. +               {
  2054. +                   return "Cannot start event, it is already on.";
  2055. +               }
  2056. +               case STANDBY:
  2057. +               {
  2058. +                   eventState = EventState.ON;
  2059. +                   break;
  2060. +               }
  2061. +               case OFF: // Event is off, so no problem turning it on.
  2062. +               {
  2063. +                   return "Cannot start event, it is off. Participation start is required.";
  2064. +               }
  2065. +           }
  2066. +          
  2067. +           // Clean the things we will use, just in case.
  2068. +           unspawnEventNpcs();
  2069. +           _teams.clear();
  2070. +           _connectionLossData.clear();
  2071. +          
  2072. +           // Insert empty lists at _teams.
  2073. +           for (int i = 0; i < _teamsNumber; i++)
  2074. +           {
  2075. +               _teams.put(i + 1, new CopyOnWriteArrayList<>());
  2076. +           }
  2077. +          
  2078. +           int i = 0;
  2079. +           while (!_registeredPlayers.isEmpty())
  2080. +           {
  2081. +               // Get the player with the biggest level
  2082. +               int max = 0;
  2083. +               Player biggestLvlPlayer = null;
  2084. +               for (Player player : _registeredPlayers)
  2085. +               {
  2086. +                   if (player == null)
  2087. +                   {
  2088. +                       continue;
  2089. +                   }
  2090. +                  
  2091. +                   if (max < player.getLevel())
  2092. +                   {
  2093. +                       max = player.getLevel();
  2094. +                       biggestLvlPlayer = player;
  2095. +                   }
  2096. +               }
  2097. +              
  2098. +               if (biggestLvlPlayer == null)
  2099. +               {
  2100. +                   continue;
  2101. +               }
  2102. +              
  2103. +               _registeredPlayers.remove(biggestLvlPlayer);
  2104. +               _teams.get(i + 1).add(biggestLvlPlayer);
  2105. +               biggestLvlPlayer.setEventStatus();
  2106. +               i = (i + 1) % _teamsNumber;
  2107. +           }
  2108. +       }
  2109. +       catch (Exception e)
  2110. +       {
  2111. +           LOGGER.warning("Event: " + e.getMessage());
  2112. +           return "Cannot start event, an error has occured.";
  2113. +       }
  2114. +      
  2115. +       return "The event has been successfully started.";
  2116. +   }
  2117. +  
  2118. +   /**
  2119. +    * If the event state is OFF, it will not finish. Sets the event state to OFF, unregisters and resets the players, unspawns and clers the event NPCs, clears the teams, registered players, connection loss data, sets the teams number to 0, sets the event name to empty.
  2120. +    * @return a string with information if the event has been successfully stopped or not.
  2121. +    */
  2122. +   public static String finishEvent()
  2123. +   {
  2124. +       switch (eventState)
  2125. +       {
  2126. +           case OFF:
  2127. +           {
  2128. +               return "Cannot finish event, it is already off.";
  2129. +           }
  2130. +           case STANDBY:
  2131. +           {
  2132. +               for (Player player : _registeredPlayers)
  2133. +               {
  2134. +                   removeAndResetPlayer(player);
  2135. +               }
  2136. +              
  2137. +               unspawnEventNpcs();
  2138. +               // _npcs.clear();
  2139. +               _registeredPlayers.clear();
  2140. +               _teams.clear();
  2141. +               _connectionLossData.clear();
  2142. +               _teamsNumber = 0;
  2143. +               _eventName = "";
  2144. +               eventState = EventState.OFF;
  2145. +               return "The event has been stopped at STANDBY mode, all players unregistered and all event npcs unspawned.";
  2146. +           }
  2147. +           case ON:
  2148. +           {
  2149. +               for (List<Player> teamList : _teams.values())
  2150. +               {
  2151. +                   for (Player player : teamList)
  2152. +                   {
  2153. +                       removeAndResetPlayer(player);
  2154. +                   }
  2155. +               }
  2156. +              
  2157. +               eventState = EventState.OFF;
  2158. +               AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
  2159. +               unspawnEventNpcs(); // Just in case
  2160. +               // _npcs.clear();
  2161. +               _registeredPlayers.clear();
  2162. +               _teams.clear();
  2163. +               _connectionLossData.clear();
  2164. +               _teamsNumber = 0;
  2165. +               _eventName = "";
  2166. +               _npcId = 0;
  2167. +               _eventCreator = "";
  2168. +               _eventInfo = "";
  2169. +               return "The event has been stopped, all players unregistered and all event npcs unspawned.";
  2170. +           }
  2171. +       }
  2172. +      
  2173. +       return "The event has been successfully finished.";
  2174. +   }
  2175. +  
  2176. +   private static Map<Player, Integer> sortByValue(Map<Player, Integer> unsortMap)
  2177. +   {
  2178. +       final List<Entry<Player, Integer>> list = new LinkedList<>(unsortMap.entrySet());
  2179. +       list.sort(Comparator.comparing(Entry::getValue));
  2180. +      
  2181. +       final Map<Player, Integer> sortedMap = new LinkedHashMap<>();
  2182. +       for (Entry<Player, Integer> entry : list)
  2183. +       {
  2184. +           sortedMap.put(entry.getKey(), entry.getValue());
  2185. +       }
  2186. +       return sortedMap;
  2187. +   }
  2188. +}
  2189. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java
  2190. new file mode 100644
  2191. index 0000000..456c25f
  2192. --- /dev/null
  2193. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEvent.java
  2194. @@ -0,0 +1,1097 @@
  2195. +/*
  2196. + * This file is part of the L2J Mobius project.
  2197. + *
  2198. + * This program is free software: you can redistribute it and/or modify
  2199. + * it under the terms of the GNU General Public License as published by
  2200. + * the Free Software Foundation, either version 3 of the License, or
  2201. + * (at your option) any later version.
  2202. + *
  2203. + * This program is distributed in the hope that it will be useful,
  2204. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2205. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2206. + * General Public License for more details.
  2207. + *
  2208. + * You should have received a copy of the GNU General Public License
  2209. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  2210. + */
  2211. +package org.l2jmobius.gameserver.instancemanager.events;
  2212. +
  2213. +import java.util.HashMap;
  2214. +import java.util.List;
  2215. +import java.util.Map;
  2216. +import java.util.Map.Entry;
  2217. +import java.util.logging.Level;
  2218. +import java.util.logging.Logger;
  2219. +
  2220. +import org.l2jmobius.Config;
  2221. +import org.l2jmobius.commons.util.Rnd;
  2222. +import org.l2jmobius.gameserver.cache.HtmCache;
  2223. +import org.l2jmobius.gameserver.data.ItemTable;
  2224. +import org.l2jmobius.gameserver.data.SpawnTable;
  2225. +import org.l2jmobius.gameserver.data.xml.DoorData;
  2226. +import org.l2jmobius.gameserver.data.xml.SkillData;
  2227. +import org.l2jmobius.gameserver.enums.ChatType;
  2228. +import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
  2229. +import org.l2jmobius.gameserver.instancemanager.InstanceManager;
  2230. +import org.l2jmobius.gameserver.model.Spawn;
  2231. +import org.l2jmobius.gameserver.model.World;
  2232. +import org.l2jmobius.gameserver.model.actor.Creature;
  2233. +import org.l2jmobius.gameserver.model.actor.Npc;
  2234. +import org.l2jmobius.gameserver.model.actor.Player;
  2235. +import org.l2jmobius.gameserver.model.actor.Summon;
  2236. +import org.l2jmobius.gameserver.model.actor.instance.Door;
  2237. +import org.l2jmobius.gameserver.model.events.EventDispatcher;
  2238. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventFinish;
  2239. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventKill;
  2240. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventRegistrationStart;
  2241. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventStart;
  2242. +import org.l2jmobius.gameserver.model.instancezone.Instance;
  2243. +import org.l2jmobius.gameserver.model.itemcontainer.PlayerInventory;
  2244. +import org.l2jmobius.gameserver.model.skill.Skill;
  2245. +import org.l2jmobius.gameserver.network.SystemMessageId;
  2246. +import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
  2247. +import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
  2248. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  2249. +import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
  2250. +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
  2251. +
  2252. +/**
  2253. + * @author HorridoJoho
  2254. + */
  2255. +public class TvTEvent
  2256. +{
  2257. +   enum EventState
  2258. +   {
  2259. +       INACTIVE,
  2260. +       INACTIVATING,
  2261. +       PARTICIPATING,
  2262. +       STARTING,
  2263. +       STARTED,
  2264. +       REWARDING
  2265. +   }
  2266. +  
  2267. +   protected static final Logger LOGGER = Logger.getLogger(TvTEvent.class.getName());
  2268. +  
  2269. +   private static final String HTML_PATH = "data/scripts/custom/events/TvT/TvTManager/";
  2270. +  
  2271. +   private static TvTEventTeam[] _teams = new TvTEventTeam[2];
  2272. +   private static EventState _state = EventState.INACTIVE;
  2273. +   private static Spawn _npcSpawn = null;
  2274. +   private static Npc _lastNpcSpawn = null;
  2275. +   private static int _TvTEventInstance = 0;
  2276. +  
  2277. +   private TvTEvent()
  2278. +   {
  2279. +       // Prevent external initialization.
  2280. +   }
  2281. +  
  2282. +   /**
  2283. +    * Teams initializing
  2284. +    */
  2285. +   public static void init()
  2286. +   {
  2287. +       AntiFeedManager.getInstance().registerEvent(AntiFeedManager.TVT_ID);
  2288. +       _teams[0] = new TvTEventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
  2289. +       _teams[1] = new TvTEventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
  2290. +   }
  2291. +  
  2292. +   /**
  2293. +    * Starts the participation of the TvTEvent<br>
  2294. +    * 1. Get NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
  2295. +    * 2. Try to spawn a new npc of it
  2296. +    * @return boolean: true if success, otherwise false
  2297. +    */
  2298. +   public static boolean startParticipation()
  2299. +   {
  2300. +       try
  2301. +       {
  2302. +           _npcSpawn = new Spawn(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
  2303. +           _npcSpawn.setXYZ(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1], Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
  2304. +           _npcSpawn.setAmount(1);
  2305. +           _npcSpawn.setHeading(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[3]);
  2306. +           _npcSpawn.setRespawnDelay(1);
  2307. +           // later no need to delete spawn from db, we don't store it (false)
  2308. +           SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  2309. +           _npcSpawn.init();
  2310. +           _lastNpcSpawn = _npcSpawn.getLastSpawn();
  2311. +           _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
  2312. +           _lastNpcSpawn.setTitle("TvT Event Participation");
  2313. +           _lastNpcSpawn.isAggressive();
  2314. +           _lastNpcSpawn.decayMe();
  2315. +           _lastNpcSpawn.spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  2316. +           _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1));
  2317. +       }
  2318. +       catch (Exception e)
  2319. +       {
  2320. +           LOGGER.log(Level.WARNING, "TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e.getMessage(), e);
  2321. +           return false;
  2322. +       }
  2323. +      
  2324. +       setState(EventState.PARTICIPATING);
  2325. +       EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventRegistrationStart());
  2326. +       return true;
  2327. +   }
  2328. +  
  2329. +   private static int highestLevelPcInstanceOf(Map<Integer, Player> players)
  2330. +   {
  2331. +       int maxLevel = Integer.MIN_VALUE;
  2332. +       int maxLevelId = -1;
  2333. +       for (Player player : players.values())
  2334. +       {
  2335. +           if (player.getLevel() >= maxLevel)
  2336. +           {
  2337. +               maxLevel = player.getLevel();
  2338. +               maxLevelId = player.getObjectId();
  2339. +           }
  2340. +       }
  2341. +       return maxLevelId;
  2342. +   }
  2343. +  
  2344. +   /**
  2345. +    * Starts the TvTEvent fight<br>
  2346. +    * 1. Set state EventState.STARTING<br>
  2347. +    * 2. Close doors specified in configs<br>
  2348. +    * 3. Abort if not enough participants(return false)<br>
  2349. +    * 4. Set state EventState.STARTED<br>
  2350. +    * 5. Teleport all participants to team spot
  2351. +    * @return boolean: true if success, otherwise false
  2352. +    */
  2353. +   public static boolean startFight()
  2354. +   {
  2355. +       // Set state to STARTING
  2356. +       setState(EventState.STARTING);
  2357. +      
  2358. +       // Randomize and balance team distribution
  2359. +       final Map<Integer, Player> allParticipants = new HashMap<>();
  2360. +       allParticipants.putAll(_teams[0].getParticipatedPlayers());
  2361. +       allParticipants.putAll(_teams[1].getParticipatedPlayers());
  2362. +       _teams[0].cleanMe();
  2363. +       _teams[1].cleanMe();
  2364. +      
  2365. +       if (needParticipationFee())
  2366. +       {
  2367. +           for (Player player : allParticipants.values())
  2368. +           {
  2369. +               if (!hasParticipationFee(player))
  2370. +               {
  2371. +                   allParticipants.remove(player.getObjectId());
  2372. +               }
  2373. +           }
  2374. +       }
  2375. +      
  2376. +       final int[] balance =
  2377. +       {
  2378. +           0,
  2379. +           0
  2380. +       };
  2381. +       int priority = 0;
  2382. +       int highestLevelPlayerId;
  2383. +       Player highestLevelPlayer;
  2384. +       // TODO: allParticipants should be sorted by level instead of using highestLevelPcInstanceOf for every fetch
  2385. +       while (!allParticipants.isEmpty())
  2386. +       {
  2387. +           // Priority team gets one player
  2388. +           highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
  2389. +           highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
  2390. +           allParticipants.remove(highestLevelPlayerId);
  2391. +           _teams[priority].addPlayer(highestLevelPlayer);
  2392. +           balance[priority] += highestLevelPlayer.getLevel();
  2393. +           // Exiting if no more players
  2394. +           if (allParticipants.isEmpty())
  2395. +           {
  2396. +               break;
  2397. +           }
  2398. +           // The other team gets one player
  2399. +           // TODO: Code not dry
  2400. +           priority = 1 - priority;
  2401. +           highestLevelPlayerId = highestLevelPcInstanceOf(allParticipants);
  2402. +           highestLevelPlayer = allParticipants.get(highestLevelPlayerId);
  2403. +           allParticipants.remove(highestLevelPlayerId);
  2404. +           _teams[priority].addPlayer(highestLevelPlayer);
  2405. +           balance[priority] += highestLevelPlayer.getLevel();
  2406. +           // Recalculating priority
  2407. +           priority = balance[0] > balance[1] ? 1 : 0;
  2408. +       }
  2409. +      
  2410. +       // Check for enought participants
  2411. +       if ((_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS) || (_teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS))
  2412. +       {
  2413. +           // Set state INACTIVE
  2414. +           setState(EventState.INACTIVE);
  2415. +           // Cleanup of teams
  2416. +           _teams[0].cleanMe();
  2417. +           _teams[1].cleanMe();
  2418. +           // Unspawn the event NPC
  2419. +           unSpawnNpc();
  2420. +           AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
  2421. +           return false;
  2422. +       }
  2423. +      
  2424. +       if (needParticipationFee())
  2425. +       {
  2426. +           for (Player player : _teams[0].getParticipatedPlayers().values())
  2427. +           {
  2428. +               if (!payParticipationFee(player))
  2429. +               {
  2430. +                   _teams[0].removePlayer(player.getObjectId());
  2431. +               }
  2432. +           }
  2433. +           for (Player player : _teams[1].getParticipatedPlayers().values())
  2434. +           {
  2435. +               if (!payParticipationFee(player))
  2436. +               {
  2437. +                   _teams[1].removePlayer(player.getObjectId());
  2438. +               }
  2439. +           }
  2440. +       }
  2441. +      
  2442. +       if (Config.TVT_EVENT_IN_INSTANCE)
  2443. +       {
  2444. +           try
  2445. +           {
  2446. +               _TvTEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.TVT_EVENT_INSTANCE_ID).getId();
  2447. +               InstanceManager.getInstance().getInstance(_TvTEventInstance).setAllowSummon(false);
  2448. +               InstanceManager.getInstance().getInstance(_TvTEventInstance).setPvP(true);
  2449. +               InstanceManager.getInstance().getInstance(_TvTEventInstance).setEmptyDestroyTime((Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000);
  2450. +           }
  2451. +           catch (Exception e)
  2452. +           {
  2453. +               _TvTEventInstance = 0;
  2454. +               LOGGER.log(Level.WARNING, "TvTEventEngine[TvTEvent.createDynamicInstance]: exception: " + e.getMessage(), e);
  2455. +           }
  2456. +       }
  2457. +      
  2458. +       // Opens all doors specified in configs for tvt
  2459. +       openDoors(Config.TVT_DOORS_IDS_TO_OPEN);
  2460. +       // Closes all doors specified in configs for tvt
  2461. +       closeDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
  2462. +       // Set state STARTED
  2463. +       setState(EventState.STARTED);
  2464. +      
  2465. +       // Iterate over all teams
  2466. +       for (TvTEventTeam team : _teams)
  2467. +       {
  2468. +           // Iterate over all participated player instances in this team
  2469. +           for (Player Player : team.getParticipatedPlayers().values())
  2470. +           {
  2471. +               if (Player != null)
  2472. +               {
  2473. +                   // Disable player revival.
  2474. +                   Player.setCanRevive(false);
  2475. +                   // Teleporter implements Runnable and starts itself
  2476. +                   new TvTEventTeleporter(Player, team.getCoordinates(), false, false);
  2477. +               }
  2478. +           }
  2479. +       }
  2480. +      
  2481. +       // Notify to scripts.
  2482. +       EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventStart());
  2483. +       return true;
  2484. +   }
  2485. +  
  2486. +   /**
  2487. +    * Calculates the TvTEvent reward<br>
  2488. +    * 1. If both teams are at a tie(points equals), send it as system message to all participants, if one of the teams have 0 participants left online abort rewarding<br>
  2489. +    * 2. Wait till teams are not at a tie anymore<br>
  2490. +    * 3. Set state EvcentState.REWARDING<br>
  2491. +    * 4. Reward team with more points<br>
  2492. +    * 5. Show win html to wining team participants
  2493. +    * @return String: winning team name
  2494. +    */
  2495. +   public static String calculateRewards()
  2496. +   {
  2497. +       if (_teams[0].getPoints() == _teams[1].getPoints())
  2498. +       {
  2499. +           // Check if one of the teams have no more players left
  2500. +           if ((_teams[0].getParticipatedPlayerCount() == 0) || (_teams[1].getParticipatedPlayerCount() == 0))
  2501. +           {
  2502. +               // set state to rewarding
  2503. +               setState(EventState.REWARDING);
  2504. +               // return here, the fight can't be completed
  2505. +               return "TvT Event: Event has ended. No team won due to inactivity!";
  2506. +           }
  2507. +          
  2508. +           // Both teams have equals points
  2509. +           sysMsgToAllParticipants("TvT Event: Event has ended, both teams have tied.");
  2510. +           if (Config.TVT_REWARD_TEAM_TIE)
  2511. +           {
  2512. +               rewardTeam(_teams[0]);
  2513. +               rewardTeam(_teams[1]);
  2514. +               return "TvT Event: Event has ended with both teams tying.";
  2515. +           }
  2516. +           return "TvT Event: Event has ended with both teams tying.";
  2517. +       }
  2518. +      
  2519. +       // Set state REWARDING so nobody can point anymore
  2520. +       setState(EventState.REWARDING);
  2521. +      
  2522. +       // Get team which has more points
  2523. +       final TvTEventTeam team = _teams[_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1];
  2524. +       rewardTeam(team);
  2525. +      
  2526. +       // Notify to scripts.
  2527. +       EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventFinish());
  2528. +       return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
  2529. +   }
  2530. +  
  2531. +   private static void rewardTeam(TvTEventTeam team)
  2532. +   {
  2533. +       // Iterate over all participated player instances of the winning team
  2534. +       for (Player Player : team.getParticipatedPlayers().values())
  2535. +       {
  2536. +           // Check for nullpointer
  2537. +           if (Player == null)
  2538. +           {
  2539. +               continue;
  2540. +           }
  2541. +          
  2542. +           SystemMessage systemMessage = null;
  2543. +          
  2544. +           // Iterate over all tvt event rewards
  2545. +           for (int[] reward : Config.TVT_EVENT_REWARDS)
  2546. +           {
  2547. +               final PlayerInventory inv = Player.getInventory();
  2548. +              
  2549. +               // Check for stackable item, non stackabe items need to be added one by one
  2550. +               if (ItemTable.getInstance().getTemplate(reward[0]).isStackable())
  2551. +               {
  2552. +                   inv.addItem("TvT Event", reward[0], reward[1], Player, Player);
  2553. +                   if (reward[1] > 1)
  2554. +                   {
  2555. +                       systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
  2556. +                       systemMessage.addItemName(reward[0]);
  2557. +                       systemMessage.addLong(reward[1]);
  2558. +                   }
  2559. +                   else
  2560. +                   {
  2561. +                       systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
  2562. +                       systemMessage.addItemName(reward[0]);
  2563. +                   }
  2564. +                  
  2565. +                   Player.sendPacket(systemMessage);
  2566. +               }
  2567. +               else
  2568. +               {
  2569. +                   for (int i = 0; i < reward[1]; ++i)
  2570. +                   {
  2571. +                       inv.addItem("TvT Event", reward[0], 1, Player, Player);
  2572. +                       systemMessage = new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
  2573. +                       systemMessage.addItemName(reward[0]);
  2574. +                       Player.sendPacket(systemMessage);
  2575. +                   }
  2576. +               }
  2577. +           }
  2578. +          
  2579. +           final StatusUpdate statusUpdate = new StatusUpdate(Player);
  2580. +           final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage();
  2581. +           statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, Player.getCurrentLoad());
  2582. +           npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(Player, HTML_PATH + "Reward.html"));
  2583. +           Player.sendPacket(statusUpdate);
  2584. +           Player.sendPacket(npcHtmlMessage);
  2585. +       }
  2586. +   }
  2587. +  
  2588. +   /**
  2589. +    * Stops the TvTEvent fight<br>
  2590. +    * 1. Set state EventState.INACTIVATING<br>
  2591. +    * 2. Remove tvt npc from world<br>
  2592. +    * 3. Open doors specified in configs<br>
  2593. +    * 4. Teleport all participants back to participation npc location<br>
  2594. +    * 5. Teams cleaning<br>
  2595. +    * 6. Set state EventState.INACTIVE
  2596. +    */
  2597. +   public static void stopFight()
  2598. +   {
  2599. +       // Set state INACTIVATING
  2600. +       setState(EventState.INACTIVATING);
  2601. +       // Unspawn event npc
  2602. +       unSpawnNpc();
  2603. +       // Opens all doors specified in configs for tvt
  2604. +       openDoors(Config.TVT_DOORS_IDS_TO_CLOSE);
  2605. +       // Closes all doors specified in Configs for tvt
  2606. +       closeDoors(Config.TVT_DOORS_IDS_TO_OPEN);
  2607. +      
  2608. +       // Iterate over all teams
  2609. +       for (TvTEventTeam team : _teams)
  2610. +       {
  2611. +           for (Player Player : team.getParticipatedPlayers().values())
  2612. +           {
  2613. +               // Check for nullpointer
  2614. +               if (Player != null)
  2615. +               {
  2616. +                   // Enable player revival.
  2617. +                   Player.setCanRevive(true);
  2618. +                   // Teleport back.
  2619. +                   new TvTEventTeleporter(Player, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
  2620. +               }
  2621. +           }
  2622. +       }
  2623. +      
  2624. +       // Cleanup of teams
  2625. +       _teams[0].cleanMe();
  2626. +       _teams[1].cleanMe();
  2627. +       // Set state INACTIVE
  2628. +       setState(EventState.INACTIVE);
  2629. +       AntiFeedManager.getInstance().clear(AntiFeedManager.TVT_ID);
  2630. +   }
  2631. +  
  2632. +   /**
  2633. +    * Adds a player to a TvTEvent team<br>
  2634. +    * 1. Calculate the id of the team in which the player should be added<br>
  2635. +    * 2. Add the player to the calculated team
  2636. +    * @param Player as Player
  2637. +    * @return boolean: true if success, otherwise false
  2638. +    */
  2639. +   public static synchronized boolean addParticipant(Player Player)
  2640. +   {
  2641. +       // Check for nullpoitner
  2642. +       if (Player == null)
  2643. +       {
  2644. +           return false;
  2645. +       }
  2646. +      
  2647. +       byte teamId = 0;
  2648. +      
  2649. +       // Check to which team the player should be added
  2650. +       if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
  2651. +       {
  2652. +           teamId = (byte) Rnd.get(2);
  2653. +       }
  2654. +       else
  2655. +       {
  2656. +           teamId = (byte) (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
  2657. +       }
  2658. +       Player.addEventListener(new TvTEventListener(Player));
  2659. +       return _teams[teamId].addPlayer(Player);
  2660. +   }
  2661. +  
  2662. +   /**
  2663. +    * Removes a TvTEvent player from it's team<br>
  2664. +    * 1. Get team id of the player<br>
  2665. +    * 2. Remove player from it's team
  2666. +    * @param playerObjectId
  2667. +    * @return boolean: true if success, otherwise false
  2668. +    */
  2669. +   public static boolean removeParticipant(int playerObjectId)
  2670. +   {
  2671. +       // Get the teamId of the player
  2672. +       final byte teamId = getParticipantTeamId(playerObjectId);
  2673. +      
  2674. +       // Check if the player is participant
  2675. +       if (teamId != -1)
  2676. +       {
  2677. +           // Remove the player from team
  2678. +           _teams[teamId].removePlayer(playerObjectId);
  2679. +          
  2680. +           final Player player = World.getInstance().getPlayer(playerObjectId);
  2681. +           if (player != null)
  2682. +           {
  2683. +               player.removeEventListener(TvTEventListener.class);
  2684. +           }
  2685. +           return true;
  2686. +       }
  2687. +       return false;
  2688. +   }
  2689. +  
  2690. +   public static boolean needParticipationFee()
  2691. +   {
  2692. +       return (Config.TVT_EVENT_PARTICIPATION_FEE[0] != 0) && (Config.TVT_EVENT_PARTICIPATION_FEE[1] != 0);
  2693. +   }
  2694. +  
  2695. +   public static boolean hasParticipationFee(Player Player)
  2696. +   {
  2697. +       return Player.getInventory().getInventoryItemCount(Config.TVT_EVENT_PARTICIPATION_FEE[0], -1) >= Config.TVT_EVENT_PARTICIPATION_FEE[1];
  2698. +   }
  2699. +  
  2700. +   public static boolean payParticipationFee(Player Player)
  2701. +   {
  2702. +       return Player.destroyItemByItemId("TvT Participation Fee", Config.TVT_EVENT_PARTICIPATION_FEE[0], Config.TVT_EVENT_PARTICIPATION_FEE[1], _lastNpcSpawn, true);
  2703. +   }
  2704. +  
  2705. +   public static String getParticipationFee()
  2706. +   {
  2707. +       final int itemId = Config.TVT_EVENT_PARTICIPATION_FEE[0];
  2708. +       final int itemNum = Config.TVT_EVENT_PARTICIPATION_FEE[1];
  2709. +       if ((itemId == 0) || (itemNum == 0))
  2710. +       {
  2711. +           return "-";
  2712. +       }
  2713. +       return itemNum + " " + ItemTable.getInstance().getTemplate(itemId).getName();
  2714. +   }
  2715. +  
  2716. +   /**
  2717. +    * Send a SystemMessage to all participated players<br>
  2718. +    * 1. Send the message to all players of team number one<br>
  2719. +    * 2. Send the message to all players of team number two
  2720. +    * @param message as String
  2721. +    */
  2722. +   public static void sysMsgToAllParticipants(String message)
  2723. +   {
  2724. +       for (Player Player : _teams[0].getParticipatedPlayers().values())
  2725. +       {
  2726. +           if (Player != null)
  2727. +           {
  2728. +               Player.sendMessage(message);
  2729. +           }
  2730. +       }
  2731. +      
  2732. +       for (Player Player : _teams[1].getParticipatedPlayers().values())
  2733. +       {
  2734. +           if (Player != null)
  2735. +           {
  2736. +               Player.sendMessage(message);
  2737. +           }
  2738. +       }
  2739. +   }
  2740. +  
  2741. +   private static Door getDoor(int doorId)
  2742. +   {
  2743. +       Door door = null;
  2744. +       if (_TvTEventInstance <= 0)
  2745. +       {
  2746. +           door = DoorData.getInstance().getDoor(doorId);
  2747. +       }
  2748. +       else
  2749. +       {
  2750. +           final Instance inst = InstanceManager.getInstance().getInstance(_TvTEventInstance);
  2751. +           if (inst != null)
  2752. +           {
  2753. +               door = inst.getDoor(doorId);
  2754. +           }
  2755. +       }
  2756. +       return door;
  2757. +   }
  2758. +  
  2759. +   /**
  2760. +    * Close doors specified in configs
  2761. +    * @param doors
  2762. +    */
  2763. +   private static void closeDoors(List<Integer> doors)
  2764. +   {
  2765. +       for (int doorId : doors)
  2766. +       {
  2767. +           final Door Door = getDoor(doorId);
  2768. +           if (Door != null)
  2769. +           {
  2770. +               Door.closeMe();
  2771. +           }
  2772. +       }
  2773. +   }
  2774. +  
  2775. +   /**
  2776. +    * Open doors specified in configs
  2777. +    * @param doors
  2778. +    */
  2779. +   private static void openDoors(List<Integer> doors)
  2780. +   {
  2781. +       for (int doorId : doors)
  2782. +       {
  2783. +           final Door Door = getDoor(doorId);
  2784. +           if (Door != null)
  2785. +           {
  2786. +               Door.openMe();
  2787. +           }
  2788. +       }
  2789. +   }
  2790. +  
  2791. +   /**
  2792. +    * UnSpawns the TvTEvent npc
  2793. +    */
  2794. +   private static void unSpawnNpc()
  2795. +   {
  2796. +       // Delete the npc
  2797. +       _lastNpcSpawn.deleteMe();
  2798. +       SpawnTable.getInstance().deleteSpawn(_lastNpcSpawn.getSpawn(), false);
  2799. +       // Stop respawning of the npc
  2800. +       _npcSpawn.stopRespawn();
  2801. +       _npcSpawn = null;
  2802. +       _lastNpcSpawn = null;
  2803. +   }
  2804. +  
  2805. +   /**
  2806. +    * Called when a player logs in
  2807. +    * @param Player as Player
  2808. +    */
  2809. +   public static void onLogin(Player Player)
  2810. +   {
  2811. +       if ((Player == null) || (!isStarting() && !isStarted()))
  2812. +       {
  2813. +           return;
  2814. +       }
  2815. +      
  2816. +       final byte teamId = getParticipantTeamId(Player.getObjectId());
  2817. +       if (teamId == -1)
  2818. +       {
  2819. +           return;
  2820. +       }
  2821. +      
  2822. +       _teams[teamId].addPlayer(Player);
  2823. +       new TvTEventTeleporter(Player, _teams[teamId].getCoordinates(), true, false);
  2824. +   }
  2825. +  
  2826. +   /**
  2827. +    * Called when a player logs out
  2828. +    * @param Player as Player
  2829. +    */
  2830. +   public static void onLogout(Player Player)
  2831. +   {
  2832. +       if ((Player != null) && (isStarting() || isStarted() || isParticipating()) && removeParticipant(Player.getObjectId()))
  2833. +       {
  2834. +           Player.setXYZInvisible((Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50, (Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
  2835. +       }
  2836. +   }
  2837. +  
  2838. +   /**
  2839. +    * Called on every onAction in PlayerIstance
  2840. +    * @param Player
  2841. +    * @param targetedPlayerObjectId
  2842. +    * @return boolean: true if player is allowed to target, otherwise false
  2843. +    */
  2844. +   public static boolean onAction(Player Player, int targetedPlayerObjectId)
  2845. +   {
  2846. +       if ((Player == null) || !isStarted())
  2847. +       {
  2848. +           return true;
  2849. +       }
  2850. +      
  2851. +       if (Player.isGM())
  2852. +       {
  2853. +           return true;
  2854. +       }
  2855. +      
  2856. +       final byte playerTeamId = getParticipantTeamId(Player.getObjectId());
  2857. +       final byte targetedPlayerTeamId = getParticipantTeamId(targetedPlayerObjectId);
  2858. +       if (((playerTeamId != -1) && (targetedPlayerTeamId == -1)) || ((playerTeamId == -1) && (targetedPlayerTeamId != -1)))
  2859. +       {
  2860. +           return false;
  2861. +       }
  2862. +      
  2863. +       if ((playerTeamId != -1) && (targetedPlayerTeamId != -1) && (playerTeamId == targetedPlayerTeamId) && (Player.getObjectId() != targetedPlayerObjectId) && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
  2864. +       {
  2865. +           return false;
  2866. +       }
  2867. +      
  2868. +       return true;
  2869. +   }
  2870. +  
  2871. +   /**
  2872. +    * Called on every scroll use
  2873. +    * @param playerObjectId
  2874. +    * @return boolean: true if player is allowed to use scroll, otherwise false
  2875. +    */
  2876. +   public static boolean onScrollUse(int playerObjectId)
  2877. +   {
  2878. +       if (!isStarted())
  2879. +       {
  2880. +           return true;
  2881. +       }
  2882. +      
  2883. +       if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SCROLL_ALLOWED)
  2884. +       {
  2885. +           return false;
  2886. +       }
  2887. +      
  2888. +       return true;
  2889. +   }
  2890. +  
  2891. +   /**
  2892. +    * Called on every potion use
  2893. +    * @param playerObjectId
  2894. +    * @return boolean: true if player is allowed to use potions, otherwise false
  2895. +    */
  2896. +   public static boolean onPotionUse(int playerObjectId)
  2897. +   {
  2898. +       if (!isStarted())
  2899. +       {
  2900. +           return true;
  2901. +       }
  2902. +      
  2903. +       if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_POTIONS_ALLOWED)
  2904. +       {
  2905. +           return false;
  2906. +       }
  2907. +      
  2908. +       return true;
  2909. +   }
  2910. +  
  2911. +   /**
  2912. +    * Called on every escape use(thanks to nbd)
  2913. +    * @param playerObjectId
  2914. +    * @return boolean: true if player is not in tvt event, otherwise false
  2915. +    */
  2916. +   public static boolean onEscapeUse(int playerObjectId)
  2917. +   {
  2918. +       if (!isStarted())
  2919. +       {
  2920. +           return true;
  2921. +       }
  2922. +      
  2923. +       if (isPlayerParticipant(playerObjectId))
  2924. +       {
  2925. +           return false;
  2926. +       }
  2927. +      
  2928. +       return true;
  2929. +   }
  2930. +  
  2931. +   /**
  2932. +    * Called on every summon item use
  2933. +    * @param playerObjectId
  2934. +    * @return boolean: true if player is allowed to summon by item, otherwise false
  2935. +    */
  2936. +   public static boolean onItemSummon(int playerObjectId)
  2937. +   {
  2938. +       if (!isStarted())
  2939. +       {
  2940. +           return true;
  2941. +       }
  2942. +      
  2943. +       if (isPlayerParticipant(playerObjectId) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
  2944. +       {
  2945. +           return false;
  2946. +       }
  2947. +      
  2948. +       return true;
  2949. +   }
  2950. +  
  2951. +   /**
  2952. +    * Is called when a player is killed
  2953. +    * @param killerCharacter as Creature
  2954. +    * @param killedPlayer as Player
  2955. +    */
  2956. +   public static void onKill(Creature killerCharacter, Player killedPlayer)
  2957. +   {
  2958. +       if ((killedPlayer == null) || !isStarted())
  2959. +       {
  2960. +           return;
  2961. +       }
  2962. +      
  2963. +       final byte killedTeamId = getParticipantTeamId(killedPlayer.getObjectId());
  2964. +       if (killedTeamId == -1)
  2965. +       {
  2966. +           return;
  2967. +       }
  2968. +      
  2969. +       new TvTEventTeleporter(killedPlayer, _teams[killedTeamId].getCoordinates(), false, false);
  2970. +       if (killerCharacter == null)
  2971. +       {
  2972. +           return;
  2973. +       }
  2974. +      
  2975. +       Player killerPlayer = null;
  2976. +       if (killerCharacter.isPet() || killerCharacter.isServitor())
  2977. +       {
  2978. +           killerPlayer = ((Summon) killerCharacter).getOwner();
  2979. +           if (killerPlayer == null)
  2980. +           {
  2981. +               return;
  2982. +           }
  2983. +       }
  2984. +       else if (killerCharacter.isPlayer())
  2985. +       {
  2986. +           killerPlayer = (Player) killerCharacter;
  2987. +       }
  2988. +       else
  2989. +       {
  2990. +           return;
  2991. +       }
  2992. +      
  2993. +       final byte killerTeamId = getParticipantTeamId(killerPlayer.getObjectId());
  2994. +       if ((killerTeamId != -1) && (killedTeamId != -1) && (killerTeamId != killedTeamId))
  2995. +       {
  2996. +           final TvTEventTeam killerTeam = _teams[killerTeamId];
  2997. +           killerTeam.increasePoints();
  2998. +          
  2999. +           final CreatureSay cs = new CreatureSay(killerPlayer, ChatType.WHISPER, killerPlayer.getName(), "I have killed " + killedPlayer.getName() + "!");
  3000. +           for (Player Player : _teams[killerTeamId].getParticipatedPlayers().values())
  3001. +           {
  3002. +               if (Player != null)
  3003. +               {
  3004. +                   Player.sendPacket(cs);
  3005. +               }
  3006. +           }
  3007. +          
  3008. +           // Notify to scripts.
  3009. +           EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventKill(killerPlayer, killedPlayer, killerTeam));
  3010. +       }
  3011. +   }
  3012. +  
  3013. +   /**
  3014. +    * Called on Appearing packet received (player finished teleporting)
  3015. +    * @param Player
  3016. +    */
  3017. +   public static void onTeleported(Player Player)
  3018. +   {
  3019. +       if (!isStarted() || (Player == null) || !isPlayerParticipant(Player.getObjectId()))
  3020. +       {
  3021. +           return;
  3022. +       }
  3023. +      
  3024. +       if (Player.isMageClass())
  3025. +       {
  3026. +           if ((Config.TVT_EVENT_MAGE_BUFFS != null) && !Config.TVT_EVENT_MAGE_BUFFS.isEmpty())
  3027. +           {
  3028. +               for (Entry<Integer, Integer> e : Config.TVT_EVENT_MAGE_BUFFS.entrySet())
  3029. +               {
  3030. +                   final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
  3031. +                   if (skill != null)
  3032. +                   {
  3033. +                       skill.applyEffects(Player, Player);
  3034. +                   }
  3035. +               }
  3036. +           }
  3037. +       }
  3038. +       else if ((Config.TVT_EVENT_FIGHTER_BUFFS != null) && !Config.TVT_EVENT_FIGHTER_BUFFS.isEmpty())
  3039. +       {
  3040. +           for (Entry<Integer, Integer> e : Config.TVT_EVENT_FIGHTER_BUFFS.entrySet())
  3041. +           {
  3042. +               final Skill skill = SkillData.getInstance().getSkill(e.getKey(), e.getValue());
  3043. +               if (skill != null)
  3044. +               {
  3045. +                   skill.applyEffects(Player, Player);
  3046. +               }
  3047. +           }
  3048. +       }
  3049. +   }
  3050. +  
  3051. +   /**
  3052. +    * @param source
  3053. +    * @param target
  3054. +    * @param skill
  3055. +    * @return true if player valid for skill
  3056. +    */
  3057. +   public static boolean checkForTvTSkill(Player source, Player target, Skill skill)
  3058. +   {
  3059. +       if (!isStarted())
  3060. +       {
  3061. +           return true;
  3062. +       }
  3063. +       // TvT is started
  3064. +       final int sourcePlayerId = source.getObjectId();
  3065. +       final int targetPlayerId = target.getObjectId();
  3066. +       final boolean isSourceParticipant = isPlayerParticipant(sourcePlayerId);
  3067. +       final boolean isTargetParticipant = isPlayerParticipant(targetPlayerId);
  3068. +      
  3069. +       // both players not participating
  3070. +       if (!isSourceParticipant && !isTargetParticipant)
  3071. +       {
  3072. +           return true;
  3073. +       }
  3074. +       // one player not participating
  3075. +       if (!(isSourceParticipant && isTargetParticipant))
  3076. +       {
  3077. +           return false;
  3078. +       }
  3079. +       // players in the different teams ?
  3080. +       if ((getParticipantTeamId(sourcePlayerId) != getParticipantTeamId(targetPlayerId)) && !skill.isBad())
  3081. +       {
  3082. +           return false;
  3083. +       }
  3084. +       return true;
  3085. +   }
  3086. +  
  3087. +   /**
  3088. +    * Sets the TvTEvent state
  3089. +    * @param state as EventState
  3090. +    */
  3091. +   private static void setState(EventState state)
  3092. +   {
  3093. +       synchronized (_state)
  3094. +       {
  3095. +           _state = state;
  3096. +       }
  3097. +   }
  3098. +  
  3099. +   /**
  3100. +    * Is TvTEvent inactive?
  3101. +    * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false
  3102. +    */
  3103. +   public static boolean isInactive()
  3104. +   {
  3105. +       boolean isInactive;
  3106. +      
  3107. +       synchronized (_state)
  3108. +       {
  3109. +           isInactive = _state == EventState.INACTIVE;
  3110. +       }
  3111. +       return isInactive;
  3112. +   }
  3113. +  
  3114. +   /**
  3115. +    * Is TvTEvent in inactivating?
  3116. +    * @return boolean: true if event is in inactivating progress, otherwise false
  3117. +    */
  3118. +   public static boolean isInactivating()
  3119. +   {
  3120. +       boolean isInactivating;
  3121. +      
  3122. +       synchronized (_state)
  3123. +       {
  3124. +           isInactivating = _state == EventState.INACTIVATING;
  3125. +       }
  3126. +       return isInactivating;
  3127. +   }
  3128. +  
  3129. +   /**
  3130. +    * Is TvTEvent in participation?
  3131. +    * @return boolean: true if event is in participation progress, otherwise false
  3132. +    */
  3133. +   public static boolean isParticipating()
  3134. +   {
  3135. +       boolean isParticipating;
  3136. +      
  3137. +       synchronized (_state)
  3138. +       {
  3139. +           isParticipating = _state == EventState.PARTICIPATING;
  3140. +       }
  3141. +       return isParticipating;
  3142. +   }
  3143. +  
  3144. +   /**
  3145. +    * Is TvTEvent starting?
  3146. +    * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false
  3147. +    */
  3148. +   public static boolean isStarting()
  3149. +   {
  3150. +       boolean isStarting;
  3151. +      
  3152. +       synchronized (_state)
  3153. +       {
  3154. +           isStarting = _state == EventState.STARTING;
  3155. +       }
  3156. +       return isStarting;
  3157. +   }
  3158. +  
  3159. +   /**
  3160. +    * Is TvTEvent started?
  3161. +    * @return boolean: true if event is started, otherwise false
  3162. +    */
  3163. +   public static boolean isStarted()
  3164. +   {
  3165. +       boolean isStarted;
  3166. +      
  3167. +       synchronized (_state)
  3168. +       {
  3169. +           isStarted = _state == EventState.STARTED;
  3170. +       }
  3171. +       return isStarted;
  3172. +   }
  3173. +  
  3174. +   /**
  3175. +    * Is TvTEvent rewarding?
  3176. +    * @return boolean: true if event is currently rewarding, otherwise false
  3177. +    */
  3178. +   public static boolean isRewarding()
  3179. +   {
  3180. +       boolean isRewarding;
  3181. +      
  3182. +       synchronized (_state)
  3183. +       {
  3184. +           isRewarding = _state == EventState.REWARDING;
  3185. +       }
  3186. +       return isRewarding;
  3187. +   }
  3188. +  
  3189. +   /**
  3190. +    * Returns the team id of a player, if player is not participant it returns -1
  3191. +    * @param playerObjectId
  3192. +    * @return byte: team name of the given playerName, if not in event -1
  3193. +    */
  3194. +   public static byte getParticipantTeamId(int playerObjectId)
  3195. +   {
  3196. +       return (byte) (_teams[0].containsPlayer(playerObjectId) ? 0 : (_teams[1].containsPlayer(playerObjectId) ? 1 : -1));
  3197. +   }
  3198. +  
  3199. +   /**
  3200. +    * Returns the team of a player, if player is not participant it returns null
  3201. +    * @param playerObjectId
  3202. +    * @return TvTEventTeam: team of the given playerObjectId, if not in event null
  3203. +    */
  3204. +   public static TvTEventTeam getParticipantTeam(int playerObjectId)
  3205. +   {
  3206. +       return _teams[0].containsPlayer(playerObjectId) ? _teams[0] : (_teams[1].containsPlayer(playerObjectId) ? _teams[1] : null);
  3207. +   }
  3208. +  
  3209. +   /**
  3210. +    * Returns the enemy team of a player, if player is not participant it returns null
  3211. +    * @param playerObjectId
  3212. +    * @return TvTEventTeam: enemy team of the given playerObjectId, if not in event null
  3213. +    */
  3214. +   public static TvTEventTeam getParticipantEnemyTeam(int playerObjectId)
  3215. +   {
  3216. +       return (_teams[0].containsPlayer(playerObjectId) ? _teams[1] : (_teams[1].containsPlayer(playerObjectId) ? _teams[0] : null));
  3217. +   }
  3218. +  
  3219. +   /**
  3220. +    * Returns the team coordinates in which the player is in, if player is not in a team return null
  3221. +    * @param playerObjectId
  3222. +    * @return int[]: coordinates of teams, 2 elements, index 0 for team 1 and index 1 for team 2
  3223. +    */
  3224. +   public static int[] getParticipantTeamCoordinates(int playerObjectId)
  3225. +   {
  3226. +       return _teams[0].containsPlayer(playerObjectId) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerObjectId) ? _teams[1].getCoordinates() : null);
  3227. +   }
  3228. +  
  3229. +   /**
  3230. +    * Is given player participant of the event?
  3231. +    * @param playerObjectId
  3232. +    * @return boolean: true if player is participant, ohterwise false
  3233. +    */
  3234. +   public static boolean isPlayerParticipant(int playerObjectId)
  3235. +   {
  3236. +       return (isParticipating() || isStarting() || isStarted()) && (_teams[0].containsPlayer(playerObjectId) || _teams[1].containsPlayer(playerObjectId));
  3237. +   }
  3238. +  
  3239. +   /**
  3240. +    * Returns participated player count
  3241. +    * @return int: amount of players registered in the event
  3242. +    */
  3243. +   public static int getParticipatedPlayersCount()
  3244. +   {
  3245. +       return !isParticipating() && !isStarting() && !isStarted() ? 0 : _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
  3246. +   }
  3247. +  
  3248. +   /**
  3249. +    * Returns teams names
  3250. +    * @return String[]: names of teams, 2 elements, index 0 for team 1 and index 1 for team 2
  3251. +    */
  3252. +   public static String[] getTeamNames()
  3253. +   {
  3254. +       return new String[]
  3255. +       {
  3256. +           _teams[0].getName(),
  3257. +           _teams[1].getName()
  3258. +       };
  3259. +   }
  3260. +  
  3261. +   /**
  3262. +    * Returns player count of both teams
  3263. +    * @return int[]: player count of teams, 2 elements, index 0 for team 1 and index 1 for team 2
  3264. +    */
  3265. +   public static int[] getTeamsPlayerCounts()
  3266. +   {
  3267. +       return new int[]
  3268. +       {
  3269. +           _teams[0].getParticipatedPlayerCount(),
  3270. +           _teams[1].getParticipatedPlayerCount()
  3271. +       };
  3272. +   }
  3273. +  
  3274. +   /**
  3275. +    * Returns points count of both teams
  3276. +    * @return int[]: points of teams, 2 elements, index 0 for team 1 and index 1 for team 2
  3277. +    */
  3278. +   public static int[] getTeamsPoints()
  3279. +   {
  3280. +       return new int[]
  3281. +       {
  3282. +           _teams[0].getPoints(),
  3283. +           _teams[1].getPoints()
  3284. +       };
  3285. +   }
  3286. +  
  3287. +   public static int getTvTEventInstance()
  3288. +   {
  3289. +       return _TvTEventInstance;
  3290. +   }
  3291. +}
  3292. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java
  3293. new file mode 100644
  3294. index 0000000..2af0e3f
  3295. --- /dev/null
  3296. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventListener.java
  3297. @@ -0,0 +1,63 @@
  3298. +/*
  3299. + * This file is part of the L2J Mobius project.
  3300. + *
  3301. + * This program is free software: you can redistribute it and/or modify
  3302. + * it under the terms of the GNU General Public License as published by
  3303. + * the Free Software Foundation, either version 3 of the License, or
  3304. + * (at your option) any later version.
  3305. + *
  3306. + * This program is distributed in the hope that it will be useful,
  3307. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3308. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3309. + * General Public License for more details.
  3310. + *
  3311. + * You should have received a copy of the GNU General Public License
  3312. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3313. + */
  3314. +package org.l2jmobius.gameserver.instancemanager.events;
  3315. +
  3316. +import org.l2jmobius.gameserver.model.actor.Player;
  3317. +import org.l2jmobius.gameserver.model.interfaces.IEventListener;
  3318. +
  3319. +/**
  3320. + * @author UnAfraid
  3321. + */
  3322. +public class TvTEventListener implements IEventListener
  3323. +{
  3324. +   private final Player _player;
  3325. +  
  3326. +   protected TvTEventListener(Player player)
  3327. +   {
  3328. +       _player = player;
  3329. +   }
  3330. +  
  3331. +   @Override
  3332. +   public boolean isOnEvent()
  3333. +   {
  3334. +       return TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_player.getObjectId());
  3335. +   }
  3336. +  
  3337. +   @Override
  3338. +   public boolean isBlockingExit()
  3339. +   {
  3340. +       return true;
  3341. +   }
  3342. +  
  3343. +   @Override
  3344. +   public boolean isBlockingDeathPenalty()
  3345. +   {
  3346. +       return true;
  3347. +   }
  3348. +  
  3349. +   @Override
  3350. +   public boolean canRevive()
  3351. +   {
  3352. +       return false;
  3353. +   }
  3354. +  
  3355. +   @Override
  3356. +   public Player getPlayer()
  3357. +   {
  3358. +       return _player;
  3359. +   }
  3360. +}
  3361. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java
  3362. new file mode 100644
  3363. index 0000000..692b4b8
  3364. --- /dev/null
  3365. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventPlayer.java
  3366. @@ -0,0 +1,57 @@
  3367. +/*
  3368. + * This file is part of the L2J Mobius project.
  3369. + *
  3370. + * This program is free software: you can redistribute it and/or modify
  3371. + * it under the terms of the GNU General Public License as published by
  3372. + * the Free Software Foundation, either version 3 of the License, or
  3373. + * (at your option) any later version.
  3374. + *
  3375. + * This program is distributed in the hope that it will be useful,
  3376. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3377. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3378. + * General Public License for more details.
  3379. + *
  3380. + * You should have received a copy of the GNU General Public License
  3381. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3382. + */
  3383. +package org.l2jmobius.gameserver.instancemanager.events;
  3384. +
  3385. +import org.l2jmobius.gameserver.model.actor.Player;
  3386. +
  3387. +/**
  3388. + * @author UnAfraid
  3389. + */
  3390. +public class TvTEventPlayer
  3391. +{
  3392. +   private final Player _player;
  3393. +  
  3394. +   protected TvTEventPlayer(Player player)
  3395. +   {
  3396. +       _player = player;
  3397. +   }
  3398. +  
  3399. +   public boolean isOnEvent()
  3400. +   {
  3401. +       return TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_player.getObjectId());
  3402. +   }
  3403. +  
  3404. +   public boolean isBlockingExit()
  3405. +   {
  3406. +       return true;
  3407. +   }
  3408. +  
  3409. +   public boolean isBlockingDeathPenalty()
  3410. +   {
  3411. +       return true;
  3412. +   }
  3413. +  
  3414. +   public boolean canRevive()
  3415. +   {
  3416. +       return false;
  3417. +   }
  3418. +  
  3419. +   public Player getPlayer()
  3420. +   {
  3421. +       return _player;
  3422. +   }
  3423. +}
  3424. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java
  3425. new file mode 100644
  3426. index 0000000..49a7953
  3427. --- /dev/null
  3428. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeam.java
  3429. @@ -0,0 +1,153 @@
  3430. +/*
  3431. + * This file is part of the L2J Mobius project.
  3432. + *
  3433. + * This program is free software: you can redistribute it and/or modify
  3434. + * it under the terms of the GNU General Public License as published by
  3435. + * the Free Software Foundation, either version 3 of the License, or
  3436. + * (at your option) any later version.
  3437. + *
  3438. + * This program is distributed in the hope that it will be useful,
  3439. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3440. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3441. + * General Public License for more details.
  3442. + *
  3443. + * You should have received a copy of the GNU General Public License
  3444. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3445. + */
  3446. +package org.l2jmobius.gameserver.instancemanager.events;
  3447. +
  3448. +import java.util.Map;
  3449. +import java.util.concurrent.ConcurrentHashMap;
  3450. +
  3451. +import org.l2jmobius.gameserver.model.actor.Player;
  3452. +
  3453. +/**
  3454. + * @author HorridoJoho
  3455. + */
  3456. +public class TvTEventTeam
  3457. +{
  3458. +   /**
  3459. +    * The name of the team
  3460. +    */
  3461. +   private final String _name;
  3462. +   /**
  3463. +    * The team spot coordinated
  3464. +    */
  3465. +   private int[] _coordinates = new int[3];
  3466. +   /**
  3467. +    * The points of the team
  3468. +    */
  3469. +   private short _points;
  3470. +   /** Name and instance of all participated players in map. */
  3471. +   private final Map<Integer, Player> _participatedPlayers = new ConcurrentHashMap<>();
  3472. +  
  3473. +   /**
  3474. +    * C'tor initialize the team
  3475. +    * @param name as String
  3476. +    * @param coordinates as int[]
  3477. +    */
  3478. +   public TvTEventTeam(String name, int[] coordinates)
  3479. +   {
  3480. +       _name = name;
  3481. +       _coordinates = coordinates;
  3482. +       _points = 0;
  3483. +   }
  3484. +  
  3485. +   /**
  3486. +    * Adds a player to the team
  3487. +    * @param Player as Player
  3488. +    * @return boolean: true if success, otherwise false
  3489. +    */
  3490. +   public boolean addPlayer(Player Player)
  3491. +   {
  3492. +       if (Player == null)
  3493. +       {
  3494. +           return false;
  3495. +       }
  3496. +      
  3497. +       _participatedPlayers.put(Player.getObjectId(), Player);
  3498. +      
  3499. +       return true;
  3500. +   }
  3501. +  
  3502. +   /**
  3503. +    * Removes a player from the team
  3504. +    * @param playerObjectId
  3505. +    */
  3506. +   public void removePlayer(int playerObjectId)
  3507. +   {
  3508. +       _participatedPlayers.remove(playerObjectId);
  3509. +   }
  3510. +  
  3511. +   /**
  3512. +    * Increases the points of the team
  3513. +    */
  3514. +   public void increasePoints()
  3515. +   {
  3516. +       ++_points;
  3517. +   }
  3518. +  
  3519. +   /**
  3520. +    * Cleanup the team and make it ready for adding players again
  3521. +    */
  3522. +   public void cleanMe()
  3523. +   {
  3524. +       _participatedPlayers.clear();
  3525. +       _points = 0;
  3526. +   }
  3527. +  
  3528. +   /**
  3529. +    * Is given player in this team?
  3530. +    * @param playerObjectId
  3531. +    * @return boolean: true if player is in this team, otherwise false
  3532. +    */
  3533. +   public boolean containsPlayer(int playerObjectId)
  3534. +   {
  3535. +       return _participatedPlayers.containsKey(playerObjectId);
  3536. +   }
  3537. +  
  3538. +   /**
  3539. +    * Returns the name of the team
  3540. +    * @return String: name of the team
  3541. +    */
  3542. +   public String getName()
  3543. +   {
  3544. +       return _name;
  3545. +   }
  3546. +  
  3547. +   /**
  3548. +    * Returns the coordinates of the team spot
  3549. +    * @return int[]: team coordinates
  3550. +    */
  3551. +   public int[] getCoordinates()
  3552. +   {
  3553. +       return _coordinates;
  3554. +   }
  3555. +  
  3556. +   /**
  3557. +    * Returns the points of the team
  3558. +    * @return short: team points
  3559. +    */
  3560. +   public short getPoints()
  3561. +   {
  3562. +       return _points;
  3563. +   }
  3564. +  
  3565. +   /**
  3566. +    * Returns name and instance of all participated players in Map
  3567. +    * @return Map<String, Player>: map of players in this team
  3568. +    */
  3569. +   public Map<Integer, Player> getParticipatedPlayers()
  3570. +   {
  3571. +       return _participatedPlayers;
  3572. +   }
  3573. +  
  3574. +   /**
  3575. +    * Returns player count of this team
  3576. +    * @return int: number of players in team
  3577. +    */
  3578. +   public int getParticipatedPlayerCount()
  3579. +   {
  3580. +       return _participatedPlayers.size();
  3581. +   }
  3582. +}
  3583. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java
  3584. new file mode 100644
  3585. index 0000000..1ba695b
  3586. --- /dev/null
  3587. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTEventTeleporter.java
  3588. @@ -0,0 +1,137 @@
  3589. +/*
  3590. + * This file is part of the L2J Mobius project.
  3591. + *
  3592. + * This program is free software: you can redistribute it and/or modify
  3593. + * it under the terms of the GNU General Public License as published by
  3594. + * the Free Software Foundation, either version 3 of the License, or
  3595. + * (at your option) any later version.
  3596. + *
  3597. + * This program is distributed in the hope that it will be useful,
  3598. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3599. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3600. + * General Public License for more details.
  3601. + *
  3602. + * You should have received a copy of the GNU General Public License
  3603. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3604. + */
  3605. +package org.l2jmobius.gameserver.instancemanager.events;
  3606. +
  3607. +import org.l2jmobius.Config;
  3608. +import org.l2jmobius.commons.threads.ThreadPool;
  3609. +import org.l2jmobius.commons.util.Rnd;
  3610. +import org.l2jmobius.gameserver.enums.Team;
  3611. +import org.l2jmobius.gameserver.model.Duel;
  3612. +import org.l2jmobius.gameserver.model.actor.Player;
  3613. +import org.l2jmobius.gameserver.model.actor.Summon;
  3614. +
  3615. +public class TvTEventTeleporter implements Runnable
  3616. +{
  3617. +   /** The instance of the player to teleport */
  3618. +   private Player _Player = null;
  3619. +   /** Coordinates of the spot to teleport to */
  3620. +   private int[] _coordinates = new int[3];
  3621. +   /** Admin removed this player from event */
  3622. +   private boolean _adminRemove = false;
  3623. +  
  3624. +   /**
  3625. +    * Initialize the teleporter and start the delayed task.
  3626. +    * @param Player
  3627. +    * @param coordinates
  3628. +    * @param fastSchedule
  3629. +    * @param adminRemove
  3630. +    */
  3631. +   public TvTEventTeleporter(Player Player, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  3632. +   {
  3633. +       _Player = Player;
  3634. +       _coordinates = coordinates;
  3635. +       _adminRemove = adminRemove;
  3636. +       ThreadPool.schedule(this, fastSchedule ? 0 : (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000);
  3637. +   }
  3638. +  
  3639. +   /**
  3640. +    * The task method to teleport the player<br>
  3641. +    * 1. Unsummon pet if there is one<br>
  3642. +    * 2. Remove all effects<br>
  3643. +    * 3. Revive and full heal the player<br>
  3644. +    * 4. Teleport the player<br>
  3645. +    * 5. Broadcast status and user info
  3646. +    */
  3647. +   @Override
  3648. +   public void run()
  3649. +   {
  3650. +       if (_Player == null)
  3651. +       {
  3652. +           return;
  3653. +       }
  3654. +      
  3655. +       final Summon summon = _Player.getSummon();
  3656. +       if (summon != null)
  3657. +       {
  3658. +           summon.unSummon(_Player);
  3659. +       }
  3660. +      
  3661. +       if ((Config.TVT_EVENT_EFFECTS_REMOVAL == 0) || ((Config.TVT_EVENT_EFFECTS_REMOVAL == 1) && ((_Player.getTeam() == Team.NONE) || (_Player.isInDuel() && (_Player.getDuelState() != Duel.DUELSTATE_INTERRUPTED)))))
  3662. +       {
  3663. +           _Player.stopAllEffectsExceptThoseThatLastThroughDeath();
  3664. +       }
  3665. +      
  3666. +       if (_Player.isInDuel())
  3667. +       {
  3668. +           _Player.setDuelState(Duel.DUELSTATE_INTERRUPTED);
  3669. +       }
  3670. +      
  3671. +       final int TvTInstance = TvTEvent.getTvTEventInstance();
  3672. +       if (TvTInstance != 0)
  3673. +       {
  3674. +           if (TvTEvent.isStarted() && !_adminRemove)
  3675. +           {
  3676. +               _Player.setInstanceId(TvTInstance);
  3677. +           }
  3678. +           else
  3679. +           {
  3680. +               _Player.setInstanceId(0);
  3681. +           }
  3682. +       }
  3683. +       else
  3684. +       {
  3685. +           _Player.setInstanceId(0);
  3686. +       }
  3687. +      
  3688. +       _Player.doRevive();
  3689. +      
  3690. +       _Player.teleToLocation((_coordinates[0] + Rnd.get(101)) - 50, (_coordinates[1] + Rnd.get(101)) - 50, _coordinates[2], false);
  3691. +       if (TvTEvent.isStarted() && !_adminRemove)
  3692. +       {
  3693. +           final int teamId = TvTEvent.getParticipantTeamId(_Player.getObjectId()) + 1;
  3694. +           switch (teamId)
  3695. +           {
  3696. +               case 0:
  3697. +               {
  3698. +                   _Player.setTeam(Team.NONE);
  3699. +                   break;
  3700. +               }
  3701. +               case 1:
  3702. +               {
  3703. +                   _Player.setTeam(Team.BLUE);
  3704. +                   break;
  3705. +               }
  3706. +               case 2:
  3707. +               {
  3708. +                   _Player.setTeam(Team.RED);
  3709. +                   break;
  3710. +               }
  3711. +           }
  3712. +       }
  3713. +       else
  3714. +       {
  3715. +           _Player.setTeam(Team.NONE);
  3716. +       }
  3717. +      
  3718. +       _Player.setCurrentCp(_Player.getMaxCp());
  3719. +       _Player.setCurrentHp(_Player.getMaxHp());
  3720. +       _Player.setCurrentMp(_Player.getMaxMp());
  3721. +      
  3722. +       _Player.broadcastStatusUpdate();
  3723. +       _Player.broadcastUserInfo();
  3724. +   }
  3725. +}
  3726. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java
  3727. new file mode 100644
  3728. index 0000000..9806f64
  3729. --- /dev/null
  3730. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/instancemanager/events/TvTManager.java
  3731. @@ -0,0 +1,287 @@
  3732. +/*
  3733. + * This file is part of the L2J Mobius project.
  3734. + *
  3735. + * This program is free software: you can redistribute it and/or modify
  3736. + * it under the terms of the GNU General Public License as published by
  3737. + * the Free Software Foundation, either version 3 of the License, or
  3738. + * (at your option) any later version.
  3739. + *
  3740. + * This program is distributed in the hope that it will be useful,
  3741. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3742. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3743. + * General Public License for more details.
  3744. + *
  3745. + * You should have received a copy of the GNU General Public License
  3746. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3747. + */
  3748. +package org.l2jmobius.gameserver.instancemanager.events;
  3749. +
  3750. +import java.util.Calendar;
  3751. +import java.util.concurrent.ScheduledFuture;
  3752. +import java.util.logging.Logger;
  3753. +
  3754. +import org.l2jmobius.Config;
  3755. +import org.l2jmobius.commons.threads.ThreadPool;
  3756. +import org.l2jmobius.gameserver.util.Broadcast;
  3757. +
  3758. +/**
  3759. + * @author HorridoJoho
  3760. + */
  3761. +public class TvTManager
  3762. +{
  3763. +   protected static final Logger LOGGER = Logger.getLogger(TvTManager.class.getName());
  3764. +  
  3765. +   /**
  3766. +    * Task for event cycles
  3767. +    */
  3768. +   private TvTStartTask _task;
  3769. +  
  3770. +   /**
  3771. +    * New instance only by getInstance()
  3772. +    */
  3773. +   protected TvTManager()
  3774. +   {
  3775. +       if (Config.TVT_EVENT_ENABLED)
  3776. +       {
  3777. +           TvTEvent.init();
  3778. +          
  3779. +           scheduleEventStart();
  3780. +           LOGGER.info("TvTEventEngine[TvTManager.TvTManager()]: Started.");
  3781. +       }
  3782. +       else
  3783. +       {
  3784. +           LOGGER.info("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled.");
  3785. +       }
  3786. +   }
  3787. +  
  3788. +   /**
  3789. +    * Initialize new/Returns the one and only instance
  3790. +    * @return TvTManager
  3791. +    */
  3792. +   public static TvTManager getInstance()
  3793. +   {
  3794. +       return SingletonHolder.INSTANCE;
  3795. +   }
  3796. +  
  3797. +   /**
  3798. +    * Starts TvTStartTask
  3799. +    */
  3800. +   public void scheduleEventStart()
  3801. +   {
  3802. +       try
  3803. +       {
  3804. +           final Calendar currentTime = Calendar.getInstance();
  3805. +           Calendar nextStartTime = null;
  3806. +           Calendar testStartTime = null;
  3807. +           for (String timeOfDay : Config.TVT_EVENT_INTERVAL)
  3808. +           {
  3809. +               // Creating a Calendar object from the specified interval value
  3810. +               testStartTime = Calendar.getInstance();
  3811. +               testStartTime.setLenient(true);
  3812. +               final String[] splitTimeOfDay = timeOfDay.split(":");
  3813. +               testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  3814. +               testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  3815. +               // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  3816. +               if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  3817. +               {
  3818. +                   testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  3819. +               }
  3820. +               // Check for the test date to be the minimum (smallest in the specified list)
  3821. +               if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
  3822. +               {
  3823. +                   nextStartTime = testStartTime;
  3824. +               }
  3825. +           }
  3826. +           if (nextStartTime != null)
  3827. +           {
  3828. +               _task = new TvTStartTask(nextStartTime.getTimeInMillis());
  3829. +               ThreadPool.execute(_task);
  3830. +           }
  3831. +       }
  3832. +       catch (Exception e)
  3833. +       {
  3834. +           LOGGER.warning("TvTEventEngine[TvTManager.scheduleEventStart()]: Error figuring out a start time. Check TvTEventInterval in config file.");
  3835. +       }
  3836. +   }
  3837. +  
  3838. +   /**
  3839. +    * Method to start participation
  3840. +    */
  3841. +   public void startReg()
  3842. +   {
  3843. +       if (!TvTEvent.startParticipation())
  3844. +       {
  3845. +           Broadcast.toAllOnlinePlayers("TvT Event: Event was cancelled.");
  3846. +           LOGGER.warning("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
  3847. +           scheduleEventStart();
  3848. +       }
  3849. +       else
  3850. +       {
  3851. +           Broadcast.toAllOnlinePlayers("TvT Event: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).");
  3852. +          
  3853. +           // schedule registration end
  3854. +           _task.setStartTime(System.currentTimeMillis() + (60000 * Config.TVT_EVENT_PARTICIPATION_TIME));
  3855. +           ThreadPool.execute(_task);
  3856. +       }
  3857. +   }
  3858. +  
  3859. +   /**
  3860. +    * Method to start the fight
  3861. +    */
  3862. +   public void startEvent()
  3863. +   {
  3864. +       if (!TvTEvent.startFight())
  3865. +       {
  3866. +           Broadcast.toAllOnlinePlayers("TvT Event: Event cancelled due to lack of Participation.");
  3867. +           LOGGER.info("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
  3868. +           scheduleEventStart();
  3869. +       }
  3870. +       else
  3871. +       {
  3872. +           TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  3873. +           _task.setStartTime(System.currentTimeMillis() + (60000 * Config.TVT_EVENT_RUNNING_TIME));
  3874. +           ThreadPool.execute(_task);
  3875. +       }
  3876. +   }
  3877. +  
  3878. +   /**
  3879. +    * Method to end the event and reward
  3880. +    */
  3881. +   public void endEvent()
  3882. +   {
  3883. +       Broadcast.toAllOnlinePlayers(TvTEvent.calculateRewards());
  3884. +       TvTEvent.sysMsgToAllParticipants("TvT Event: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  3885. +       TvTEvent.stopFight();
  3886. +      
  3887. +       scheduleEventStart();
  3888. +   }
  3889. +  
  3890. +   public void skipDelay()
  3891. +   {
  3892. +       if (_task.nextRun.cancel(false))
  3893. +       {
  3894. +           _task.setStartTime(System.currentTimeMillis());
  3895. +           ThreadPool.execute(_task);
  3896. +       }
  3897. +   }
  3898. +  
  3899. +   /**
  3900. +    * Class for TvT cycles
  3901. +    */
  3902. +   class TvTStartTask implements Runnable
  3903. +   {
  3904. +       private long _startTime;
  3905. +       public ScheduledFuture<?> nextRun;
  3906. +      
  3907. +       public TvTStartTask(long startTime)
  3908. +       {
  3909. +           _startTime = startTime;
  3910. +       }
  3911. +      
  3912. +       public void setStartTime(long startTime)
  3913. +       {
  3914. +           _startTime = startTime;
  3915. +       }
  3916. +      
  3917. +       @Override
  3918. +       public void run()
  3919. +       {
  3920. +           final int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  3921. +           if (delay > 0)
  3922. +           {
  3923. +               announce(delay);
  3924. +           }
  3925. +          
  3926. +           int nextMsg = 0;
  3927. +           if (delay > 3600)
  3928. +           {
  3929. +               nextMsg = delay - 3600;
  3930. +           }
  3931. +           else if (delay > 1800)
  3932. +           {
  3933. +               nextMsg = delay - 1800;
  3934. +           }
  3935. +           else if (delay > 900)
  3936. +           {
  3937. +               nextMsg = delay - 900;
  3938. +           }
  3939. +           else if (delay > 600)
  3940. +           {
  3941. +               nextMsg = delay - 600;
  3942. +           }
  3943. +           else if (delay > 300)
  3944. +           {
  3945. +               nextMsg = delay - 300;
  3946. +           }
  3947. +           else if (delay > 60)
  3948. +           {
  3949. +               nextMsg = delay - 60;
  3950. +           }
  3951. +           else if (delay > 5)
  3952. +           {
  3953. +               nextMsg = delay - 5;
  3954. +           }
  3955. +           else if (delay > 0)
  3956. +           {
  3957. +               nextMsg = delay;
  3958. +           }
  3959. +           // start
  3960. +           else if (TvTEvent.isInactive())
  3961. +           {
  3962. +               startReg();
  3963. +           }
  3964. +           else if (TvTEvent.isParticipating())
  3965. +           {
  3966. +               startEvent();
  3967. +           }
  3968. +           else
  3969. +           {
  3970. +               endEvent();
  3971. +           }
  3972. +          
  3973. +           if (delay > 0)
  3974. +           {
  3975. +               nextRun = ThreadPool.schedule(this, nextMsg * 1000);
  3976. +           }
  3977. +       }
  3978. +      
  3979. +       private void announce(long time)
  3980. +       {
  3981. +           if ((time >= 3600) && ((time % 3600) == 0))
  3982. +           {
  3983. +               if (TvTEvent.isParticipating())
  3984. +               {
  3985. +                   Broadcast.toAllOnlinePlayers("TvT Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
  3986. +               }
  3987. +               else if (TvTEvent.isStarted())
  3988. +               {
  3989. +                   TvTEvent.sysMsgToAllParticipants("TvT Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
  3990. +               }
  3991. +           }
  3992. +           else if (time >= 60)
  3993. +           {
  3994. +               if (TvTEvent.isParticipating())
  3995. +               {
  3996. +                   Broadcast.toAllOnlinePlayers("TvT Event: " + (time / 60) + " minute(s) until registration is closed!");
  3997. +               }
  3998. +               else if (TvTEvent.isStarted())
  3999. +               {
  4000. +                   TvTEvent.sysMsgToAllParticipants("TvT Event: " + (time / 60) + " minute(s) until the event is finished!");
  4001. +               }
  4002. +           }
  4003. +           else if (TvTEvent.isParticipating())
  4004. +           {
  4005. +               Broadcast.toAllOnlinePlayers("TvT Event: " + time + " second(s) until registration is closed!");
  4006. +           }
  4007. +           else if (TvTEvent.isStarted())
  4008. +           {
  4009. +               TvTEvent.sysMsgToAllParticipants("TvT Event: " + time + " second(s) until the event is finished!");
  4010. +           }
  4011. +       }
  4012. +   }
  4013. +  
  4014. +   private static class SingletonHolder
  4015. +   {
  4016. +       protected static final TvTManager INSTANCE = new TvTManager();
  4017. +   }
  4018. +}
  4019. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4020. index 5e6042b..4e8eddd 100644
  4021. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4022. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Npc.java
  4023. @@ -128,6 +128,7 @@
  4024.     /** The fortress index in the array of Fort this Npc belongs to */
  4025.     private int _fortIndex = -2;
  4026.     private boolean _isInTown = false;
  4027. +   private boolean _eventMob = false;
  4028.     /** True if this Npc is autoattackable **/
  4029.     private boolean _isAutoAttackable = false;
  4030.     /** Time of last social packet broadcast */
  4031. @@ -2090,4 +2091,14 @@
  4032.         sb.append("]");
  4033.         return sb.toString();
  4034.     }
  4035. +  
  4036. +   public boolean isEventMob()
  4037. +   {
  4038. +       return _eventMob;
  4039. +   }
  4040. +  
  4041. +   public void setEventMob(boolean value)
  4042. +   {
  4043. +       _eventMob = value;
  4044. +   }
  4045.  }
  4046. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  4047. index ec575d7..bd517ee 100644
  4048. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  4049. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/Player.java
  4050. @@ -119,6 +119,8 @@
  4051.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  4052.  import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
  4053.  import org.l2jmobius.gameserver.instancemanager.ZoneManager;
  4054. +import org.l2jmobius.gameserver.instancemanager.events.GameEvent;
  4055. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4056.  import org.l2jmobius.gameserver.model.AccessLevel;
  4057.  import org.l2jmobius.gameserver.model.ArenaParticipantsHolder;
  4058.  import org.l2jmobius.gameserver.model.BlockList;
  4059. @@ -208,6 +210,7 @@
  4060.  import org.l2jmobius.gameserver.model.holders.AdditionalSkillHolder;
  4061.  import org.l2jmobius.gameserver.model.holders.ItemHolder;
  4062.  import org.l2jmobius.gameserver.model.holders.MovieHolder;
  4063. +import org.l2jmobius.gameserver.model.holders.PlayerEventHolder;
  4064.  import org.l2jmobius.gameserver.model.holders.SellBuffHolder;
  4065.  import org.l2jmobius.gameserver.model.holders.SkillHolder;
  4066.  import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
  4067. @@ -747,6 +752,9 @@
  4068.     protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1);
  4069.    
  4070.     /** Event parameters */
  4071. +   private PlayerEventHolder eventStatus = null;
  4072. +  
  4073. +   /** Event parameters */
  4074.     private boolean _isRegisteredOnEvent = false;
  4075.     private boolean _isOnSoloEvent = false;
  4076.     private boolean _isOnEvent = false;
  4077. @@ -5000,9 +5008,12 @@
  4078.             {
  4079.                 if (pk != null)
  4080.                 {
  4081. -                   if (EventDispatcher.getInstance().hasListener(EventType.ON_PLAYER_PVP_KILL, this))
  4082. +                   EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPvPKill(pk, this), this);
  4083. +                   TvTEvent.onKill(killer, this);
  4084. +                  
  4085. +                   if (GameEvent.isParticipant(pk))
  4086.                     {
  4087. -                       EventDispatcher.getInstance().notifyEventAsync(new OnPlayerPvPKill(pk, this), this);
  4088. +                       pk.getEventStatus().getKills().add(this);
  4089.                     }
  4090.                    
  4091.                     // pvp/pk item rewards
  4092. @@ -14005,6 +14114,21 @@
  4093.         return _contactList;
  4094.     }
  4095.    
  4096. +   public void setEventStatus()
  4097. +   {
  4098. +       eventStatus = new PlayerEventHolder(this);
  4099. +   }
  4100. +  
  4101. +   public void setEventStatus(PlayerEventHolder pes)
  4102. +   {
  4103. +       eventStatus = pes;
  4104. +   }
  4105. +  
  4106. +   public PlayerEventHolder getEventStatus()
  4107. +   {
  4108. +       return eventStatus;
  4109. +   }
  4110. +  
  4111.     public long getNotMoveUntil()
  4112.     {
  4113.         return _notMoveUntil;
  4114. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
  4115. index 90bb4fe..d6527f0 100644
  4116. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
  4117. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCallPc.java
  4118. @@ -16,6 +16,7 @@
  4119.   */
  4120.  package org.l2jmobius.gameserver.model.conditions;
  4121.  
  4122. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4123.  import org.l2jmobius.gameserver.model.actor.Creature;
  4124.  import org.l2jmobius.gameserver.model.actor.Player;
  4125.  import org.l2jmobius.gameserver.model.item.ItemTemplate;
  4126. @@ -54,7 +55,7 @@
  4127.         {
  4128.             canCallPlayer = false;
  4129.         }
  4130. -       else if (player.isOnEvent())
  4131. +       else if (!TvTEvent.onEscapeUse(player.getObjectId()))
  4132.         {
  4133.             player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  4134.             canCallPlayer = false;
  4135. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
  4136. index 591bbf1..eed4f5f 100644
  4137. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
  4138. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerCanEscape.java
  4139. @@ -18,6 +18,7 @@
  4140.  
  4141.  import org.l2jmobius.gameserver.enums.PlayerCondOverride;
  4142.  import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
  4143. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4144.  import org.l2jmobius.gameserver.model.actor.Creature;
  4145.  import org.l2jmobius.gameserver.model.actor.Player;
  4146.  import org.l2jmobius.gameserver.model.item.ItemTemplate;
  4147. @@ -45,7 +46,7 @@
  4148.         {
  4149.             canTeleport = false;
  4150.         }
  4151. -       else if (player.isOnEvent())
  4152. +       else if (!TvTEvent.onEscapeUse(player.getObjectId()))
  4153.         {
  4154.             canTeleport = false;
  4155.         }
  4156. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java
  4157. new file mode 100644
  4158. index 0000000..493aab9
  4159. --- /dev/null
  4160. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/conditions/ConditionPlayerTvTEvent.java
  4161. @@ -0,0 +1,47 @@
  4162. +/*
  4163. + * This file is part of the L2J Mobius project.
  4164. + *
  4165. + * This program is free software: you can redistribute it and/or modify
  4166. + * it under the terms of the GNU General Public License as published by
  4167. + * the Free Software Foundation, either version 3 of the License, or
  4168. + * (at your option) any later version.
  4169. + *
  4170. + * This program is distributed in the hope that it will be useful,
  4171. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4172. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4173. + * General Public License for more details.
  4174. + *
  4175. + * You should have received a copy of the GNU General Public License
  4176. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4177. + */
  4178. +package org.l2jmobius.gameserver.model.conditions;
  4179. +
  4180. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4181. +import org.l2jmobius.gameserver.model.actor.Creature;
  4182. +import org.l2jmobius.gameserver.model.actor.Player;
  4183. +import org.l2jmobius.gameserver.model.item.ItemTemplate;
  4184. +import org.l2jmobius.gameserver.model.skill.Skill;
  4185. +
  4186. +/**
  4187. + * The Class ConditionPlayerTvTEvent.
  4188. + */
  4189. +public class ConditionPlayerTvTEvent extends Condition
  4190. +{
  4191. +   private final boolean _value;
  4192. +  
  4193. +   /**
  4194. +    * Instantiates a new condition player tv t event.
  4195. +    * @param value the value
  4196. +    */
  4197. +   public ConditionPlayerTvTEvent(boolean value)
  4198. +   {
  4199. +       _value = value;
  4200. +   }
  4201. +  
  4202. +   @Override
  4203. +   public boolean testImpl(Creature effector, Creature effected, Skill skill, ItemTemplate item)
  4204. +   {
  4205. +       final Player player = effector.getActingPlayer();
  4206. +       return (player == null) || !TvTEvent.isStarted() ? !_value : TvTEvent.isPlayerParticipant(player.getObjectId()) == _value;
  4207. +   }
  4208. +}
  4209. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
  4210. index d8f84b7..7b913c5 100644
  4211. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
  4212. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/EventType.java
  4213. @@ -92,6 +92,10 @@
  4214.  import org.l2jmobius.gameserver.model.events.impl.creature.player.inventory.OnPlayerItemPickup;
  4215.  import org.l2jmobius.gameserver.model.events.impl.creature.player.inventory.OnPlayerItemTransfer;
  4216.  import org.l2jmobius.gameserver.model.events.impl.creature.trap.OnTrapAction;
  4217. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventFinish;
  4218. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventKill;
  4219. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventRegistrationStart;
  4220. +import org.l2jmobius.gameserver.model.events.impl.events.OnTvTEventStart;
  4221.  import org.l2jmobius.gameserver.model.events.impl.item.OnItemBypassEvent;
  4222.  import org.l2jmobius.gameserver.model.events.impl.item.OnItemCreate;
  4223.  import org.l2jmobius.gameserver.model.events.impl.item.OnItemTalk;
  4224. @@ -220,6 +224,12 @@
  4225.     // Trap events
  4226.     ON_TRAP_ACTION(OnTrapAction.class, void.class),
  4227.    
  4228. +   // TvT events.
  4229. +   ON_TVT_EVENT_FINISH(OnTvTEventFinish.class, void.class),
  4230. +   ON_TVT_EVENT_KILL(OnTvTEventKill.class, void.class),
  4231. +   ON_TVT_EVENT_REGISTRATION_START(OnTvTEventRegistrationStart.class, void.class),
  4232. +   ON_TVT_EVENT_START(OnTvTEventStart.class, void.class),
  4233. +  
  4234.     // Server events
  4235.     ON_SERVER_START(OnServerStart.class, void.class);
  4236.    
  4237. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java
  4238. new file mode 100644
  4239. index 0000000..b20449d
  4240. --- /dev/null
  4241. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventFinish.java
  4242. @@ -0,0 +1,32 @@
  4243. +/*
  4244. + * This file is part of the L2J Mobius project.
  4245. + *
  4246. + * This program is free software: you can redistribute it and/or modify
  4247. + * it under the terms of the GNU General Public License as published by
  4248. + * the Free Software Foundation, either version 3 of the License, or
  4249. + * (at your option) any later version.
  4250. + *
  4251. + * This program is distributed in the hope that it will be useful,
  4252. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4253. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4254. + * General Public License for more details.
  4255. + *
  4256. + * You should have received a copy of the GNU General Public License
  4257. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4258. + */
  4259. +package org.l2jmobius.gameserver.model.events.impl.events;
  4260. +
  4261. +import org.l2jmobius.gameserver.model.events.EventType;
  4262. +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
  4263. +
  4264. +/**
  4265. + * @author UnAfraid
  4266. + */
  4267. +public class OnTvTEventFinish implements IBaseEvent
  4268. +{
  4269. +   @Override
  4270. +   public EventType getType()
  4271. +   {
  4272. +       return EventType.ON_TVT_EVENT_FINISH;
  4273. +   }
  4274. +}
  4275. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java
  4276. new file mode 100644
  4277. index 0000000..15900f2
  4278. --- /dev/null
  4279. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventKill.java
  4280. @@ -0,0 +1,60 @@
  4281. +/*
  4282. + * This file is part of the L2J Mobius project.
  4283. + *
  4284. + * This program is free software: you can redistribute it and/or modify
  4285. + * it under the terms of the GNU General Public License as published by
  4286. + * the Free Software Foundation, either version 3 of the License, or
  4287. + * (at your option) any later version.
  4288. + *
  4289. + * This program is distributed in the hope that it will be useful,
  4290. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4291. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4292. + * General Public License for more details.
  4293. + *
  4294. + * You should have received a copy of the GNU General Public License
  4295. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4296. + */
  4297. +package org.l2jmobius.gameserver.model.events.impl.events;
  4298. +
  4299. +import org.l2jmobius.gameserver.instancemanager.events.TvTEventTeam;
  4300. +import org.l2jmobius.gameserver.model.actor.Player;
  4301. +import org.l2jmobius.gameserver.model.events.EventType;
  4302. +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
  4303. +
  4304. +/**
  4305. + * @author UnAfraid
  4306. + */
  4307. +public class OnTvTEventKill implements IBaseEvent
  4308. +{
  4309. +   private final Player _killer;
  4310. +   private final Player _victim;
  4311. +   private final TvTEventTeam _killerTeam;
  4312. +  
  4313. +   public OnTvTEventKill(Player killer, Player victim, TvTEventTeam killerTeam)
  4314. +   {
  4315. +       _killer = killer;
  4316. +       _victim = victim;
  4317. +       _killerTeam = killerTeam;
  4318. +   }
  4319. +  
  4320. +   public Player getKiller()
  4321. +   {
  4322. +       return _killer;
  4323. +   }
  4324. +  
  4325. +   public Player getVictim()
  4326. +   {
  4327. +       return _victim;
  4328. +   }
  4329. +  
  4330. +   public TvTEventTeam getKillerTeam()
  4331. +   {
  4332. +       return _killerTeam;
  4333. +   }
  4334. +  
  4335. +   @Override
  4336. +   public EventType getType()
  4337. +   {
  4338. +       return EventType.ON_TVT_EVENT_KILL;
  4339. +   }
  4340. +}
  4341. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java
  4342. new file mode 100644
  4343. index 0000000..383858c
  4344. --- /dev/null
  4345. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventRegistrationStart.java
  4346. @@ -0,0 +1,32 @@
  4347. +/*
  4348. + * This file is part of the L2J Mobius project.
  4349. + *
  4350. + * This program is free software: you can redistribute it and/or modify
  4351. + * it under the terms of the GNU General Public License as published by
  4352. + * the Free Software Foundation, either version 3 of the License, or
  4353. + * (at your option) any later version.
  4354. + *
  4355. + * This program is distributed in the hope that it will be useful,
  4356. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4357. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4358. + * General Public License for more details.
  4359. + *
  4360. + * You should have received a copy of the GNU General Public License
  4361. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4362. + */
  4363. +package org.l2jmobius.gameserver.model.events.impl.events;
  4364. +
  4365. +import org.l2jmobius.gameserver.model.events.EventType;
  4366. +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
  4367. +
  4368. +/**
  4369. + * @author UnAfraid
  4370. + */
  4371. +public class OnTvTEventRegistrationStart implements IBaseEvent
  4372. +{
  4373. +   @Override
  4374. +   public EventType getType()
  4375. +   {
  4376. +       return EventType.ON_TVT_EVENT_REGISTRATION_START;
  4377. +   }
  4378. +}
  4379. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java
  4380. new file mode 100644
  4381. index 0000000..7f9293c
  4382. --- /dev/null
  4383. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/events/impl/events/OnTvTEventStart.java
  4384. @@ -0,0 +1,32 @@
  4385. +/*
  4386. + * This file is part of the L2J Mobius project.
  4387. + *
  4388. + * This program is free software: you can redistribute it and/or modify
  4389. + * it under the terms of the GNU General Public License as published by
  4390. + * the Free Software Foundation, either version 3 of the License, or
  4391. + * (at your option) any later version.
  4392. + *
  4393. + * This program is distributed in the hope that it will be useful,
  4394. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4395. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4396. + * General Public License for more details.
  4397. + *
  4398. + * You should have received a copy of the GNU General Public License
  4399. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4400. + */
  4401. +package org.l2jmobius.gameserver.model.events.impl.events;
  4402. +
  4403. +import org.l2jmobius.gameserver.model.events.EventType;
  4404. +import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
  4405. +
  4406. +/**
  4407. + * @author UnAfraid
  4408. + */
  4409. +public class OnTvTEventStart implements IBaseEvent
  4410. +{
  4411. +   @Override
  4412. +   public EventType getType()
  4413. +   {
  4414. +       return EventType.ON_TVT_EVENT_START;
  4415. +   }
  4416. +}
  4417. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java
  4418. new file mode 100644
  4419. index 0000000..637ed7c
  4420. --- /dev/null
  4421. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/holders/PlayerEventHolder.java
  4422. @@ -0,0 +1,98 @@
  4423. +/*
  4424. + * This file is part of the L2J Mobius project.
  4425. + *
  4426. + * This program is free software: you can redistribute it and/or modify
  4427. + * it under the terms of the GNU General Public License as published by
  4428. + * the Free Software Foundation, either version 3 of the License, or
  4429. + * (at your option) any later version.
  4430. + *
  4431. + * This program is distributed in the hope that it will be useful,
  4432. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4433. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4434. + * General Public License for more details.
  4435. + *
  4436. + * You should have received a copy of the GNU General Public License
  4437. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  4438. + */
  4439. +package org.l2jmobius.gameserver.model.holders;
  4440. +
  4441. +import java.util.Collection;
  4442. +import java.util.concurrent.ConcurrentHashMap;
  4443. +
  4444. +import org.l2jmobius.gameserver.data.sql.ClanTable;
  4445. +import org.l2jmobius.gameserver.model.Location;
  4446. +import org.l2jmobius.gameserver.model.actor.Player;
  4447. +
  4448. +/**
  4449. + * Player event holder, meant for restoring player after event has finished.<br>
  4450. + * Allows you to restore following information about player:
  4451. + * <ul>
  4452. + * <li>Name</li>
  4453. + * <li>Title</li>
  4454. + * <li>Clan</li>
  4455. + * <li>Location</li>
  4456. + * <li>PvP Kills</li>
  4457. + * <li>PK Kills</li>
  4458. + * <li>Karma</li>
  4459. + * </ul>
  4460. + * @author Nik, xban1x
  4461. + */
  4462. +public class PlayerEventHolder
  4463. +{
  4464. +   private final Player _player;
  4465. +   private final String _name;
  4466. +   private final String _title;
  4467. +   private final int _clanId;
  4468. +   private final Location _loc;
  4469. +   private final int _pvpKills;
  4470. +   private final int _pkKills;
  4471. +   private final int _karma;
  4472. +  
  4473. +   private final Collection<Player> _kills = ConcurrentHashMap.newKeySet();
  4474. +   private boolean _sitForced;
  4475. +  
  4476. +   public PlayerEventHolder(Player player)
  4477. +   {
  4478. +       this(player, false);
  4479. +   }
  4480. +  
  4481. +   public PlayerEventHolder(Player player, boolean sitForced)
  4482. +   {
  4483. +       _player = player;
  4484. +       _name = player.getName();
  4485. +       _title = player.getTitle();
  4486. +       _clanId = player.getClanId();
  4487. +       _loc = new Location(player);
  4488. +       _pvpKills = player.getPvpKills();
  4489. +       _pkKills = player.getPkKills();
  4490. +       _karma = player.getKarma();
  4491. +       _sitForced = sitForced;
  4492. +   }
  4493. +  
  4494. +   public void restorePlayerStats()
  4495. +   {
  4496. +       _player.setName(_name);
  4497. +       _player.setTitle(_title);
  4498. +       _player.setClan(ClanTable.getInstance().getClan(_clanId));
  4499. +       _player.teleToLocation(_loc, true);
  4500. +       _player.setPvpKills(_pvpKills);
  4501. +       _player.setPkKills(_pkKills);
  4502. +       _player.setKarma(_karma);
  4503. +      
  4504. +   }
  4505. +  
  4506. +   public void setSitForced(boolean sitForced)
  4507. +   {
  4508. +       _sitForced = sitForced;
  4509. +   }
  4510. +  
  4511. +   public boolean isSitForced()
  4512. +   {
  4513. +       return _sitForced;
  4514. +   }
  4515. +  
  4516. +   public Collection<Player> getKills()
  4517. +   {
  4518. +       return _kills;
  4519. +   }
  4520. +}
  4521. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
  4522. index 9d9191e..fa1cf40 100644
  4523. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
  4524. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/interfaces/IEventListener.java
  4525. @@ -39,4 +39,10 @@
  4526.     boolean canRevive();
  4527.    
  4528.     Player getPlayer();
  4529. +  
  4530. +   /**
  4531. +    * @return {@code true} if player is on event, {@code false} otherwise.
  4532. +    */
  4533. +   boolean isOnEvent();
  4534. +  
  4535.  }
  4536. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
  4537. index 4850fb5..b25fab5 100644
  4538. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
  4539. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/AbstractOlympiadGame.java
  4540. @@ -26,6 +26,7 @@
  4541.  import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
  4542.  import org.l2jmobius.gameserver.instancemanager.CastleManager;
  4543.  import org.l2jmobius.gameserver.instancemanager.FortManager;
  4544. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4545.  import org.l2jmobius.gameserver.model.Location;
  4546.  import org.l2jmobius.gameserver.model.Party;
  4547.  import org.l2jmobius.gameserver.model.actor.Creature;
  4548. @@ -123,7 +124,7 @@
  4549.         }
  4550.        
  4551.         // safety precautions
  4552. -       if (player.inObserverMode() || player.isRegisteredOnEvent())
  4553. +       if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()))
  4554.         {
  4555.             return new SystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
  4556.         }
  4557. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
  4558. index 0f8635c..5df2b1e 100644
  4559. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
  4560. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/olympiad/OlympiadManager.java
  4561. @@ -487,9 +487,9 @@
  4562.         }
  4563.        
  4564.         final int charId = noble.getObjectId();
  4565. -       if (noble.isRegisteredOnEvent())
  4566. +       if (noble.isOnEvent())
  4567.         {
  4568. -           player.sendMessage("You can't join olympiad while participating on an event.");
  4569. +           player.sendMessage("You can't join olympiad while participating on TvT Event.");
  4570.             return false;
  4571.         }
  4572.        
  4573. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
  4574. index 905b723..7884aac 100644
  4575. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
  4576. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/skill/Skill.java
  4577. @@ -39,6 +39,7 @@
  4578.  import org.l2jmobius.gameserver.geoengine.GeoEngine;
  4579.  import org.l2jmobius.gameserver.handler.ITargetTypeHandler;
  4580.  import org.l2jmobius.gameserver.handler.TargetHandler;
  4581. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4582.  import org.l2jmobius.gameserver.model.ExtractableProductItem;
  4583.  import org.l2jmobius.gameserver.model.ExtractableSkill;
  4584.  import org.l2jmobius.gameserver.model.StatSet;
  4585. @@ -1131,6 +1132,11 @@
  4586.                     return false;
  4587.                 }
  4588.                
  4589. +               if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
  4590. +               {
  4591. +                   return false;
  4592. +               }
  4593. +              
  4594.                 if (!sourceInArena && !(targetPlayer.isInsideZone(ZoneId.PVP) && !targetPlayer.isInsideZone(ZoneId.SIEGE)))
  4595.                 {
  4596.                     if ((player.getAllyId() != 0) && (player.getAllyId() == targetPlayer.getAllyId()))
  4597. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  4598. index 09c48ae..2b01d68 100644
  4599. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  4600. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/EnterWorld.java
  4601. @@ -48,6 +48,7 @@
  4602.  import org.l2jmobius.gameserver.instancemanager.ServerRestartManager;
  4603.  import org.l2jmobius.gameserver.instancemanager.SiegeManager;
  4604.  import org.l2jmobius.gameserver.instancemanager.TerritoryWarManager;
  4605. +import org.l2jmobius.gameserver.instancemanager.events.TvTEvent;
  4606.  import org.l2jmobius.gameserver.model.Couple;
  4607.  import org.l2jmobius.gameserver.model.World;
  4608.  import org.l2jmobius.gameserver.model.WorldObject;
  4609. @@ -618,6 +619,8 @@
  4610.             player.sendPacket(ExNoticePostArrived.valueOf(false));
  4611.         }
  4612.        
  4613. +       TvTEvent.onLogin(player);
  4614. +      
  4615.         if (Config.WELCOME_MESSAGE_ENABLED)
  4616.         {
  4617.             player.sendPacket(new ExShowScreenMessage(Config.WELCOME_MESSAGE_TEXT, Config.WELCOME_MESSAGE_TIME));
  4618. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
  4619. index e48286b..c7552f5 100644
  4620. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
  4621. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/util/DocumentBase.java
  4622. @@ -98,6 +98,7 @@
  4623.  import org.l2jmobius.gameserver.model.conditions.ConditionPlayerState;
  4624.  import org.l2jmobius.gameserver.model.conditions.ConditionPlayerSubclass;
  4625.  import org.l2jmobius.gameserver.model.conditions.ConditionPlayerTransformationId;
  4626. +import org.l2jmobius.gameserver.model.conditions.ConditionPlayerTvTEvent;
  4627.  import org.l2jmobius.gameserver.model.conditions.ConditionPlayerVehicleMounted;
  4628.  import org.l2jmobius.gameserver.model.conditions.ConditionPlayerWeight;
  4629.  import org.l2jmobius.gameserver.model.conditions.ConditionSiegeZone;
  4630. @@ -656,6 +657,12 @@
  4631.                     cond = joinAnd(cond, new ConditionPlayerPledgeClass(pledgeClass));
  4632.                     break;
  4633.                 }
  4634. +               case "ontvtevent":
  4635. +               {
  4636. +                   final boolean val = Boolean.parseBoolean(a.getNodeValue());
  4637. +                   cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
  4638. +                   break;
  4639. +               }
  4640.                 case "clanhall":
  4641.                 {
  4642.                     final StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
  4643. \ No newline at end of file
  4644.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement