BossForever

[aCis] TvT Event 364

Jan 9th, 2017
1,597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 91.92 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java  (revision 88)
  6. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Heal.java  (working copy)
  7. @@ -14,6 +14,7 @@
  8.   */
  9.  package net.sf.l2j.gameserver.handler.skillhandlers;
  10.  
  11. +import net.sf.l2j.Config;
  12.  import net.sf.l2j.gameserver.handler.ISkillHandler;
  13.  import net.sf.l2j.gameserver.handler.SkillHandler;
  14.  import net.sf.l2j.gameserver.model.L2Object;
  15. @@ -113,6 +114,8 @@
  16.                     continue;
  17.                 else if (activeChar instanceof L2PcInstance && ((L2PcInstance) activeChar).isCursedWeaponEquipped())
  18.                     continue;
  19. +               else if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
  20. +                   continue;
  21.             }
  22.            
  23.             switch (skill.getSkillType())
  24. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java
  25. ===================================================================
  26. --- java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java   (revision 89)
  27. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2WeddingManagerInstance.java   (working copy)
  28. @@ -132,7 +132,7 @@
  29.             }
  30.            
  31.             // Simple checks to avoid exploits
  32. -           if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  33. +           if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  34.             {
  35.                 player.sendMessage("Due to the current partner's status, the teleportation failed.");
  36.                 return;
  37. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
  38. ===================================================================
  39. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java   (nonexistent)
  40. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java   (working copy)
  41. @@ -0,0 +1,137 @@
  42. +/*
  43. + * This program is free software: you can redistribute it and/or modify it under
  44. + * the terms of the GNU General Public License as published by the Free Software
  45. + * Foundation, either version 3 of the License, or (at your option) any later
  46. + * version.
  47. + *
  48. + * This program is distributed in the hope that it will be useful, but WITHOUT
  49. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  50. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  51. + * details.
  52. + *
  53. + * You should have received a copy of the GNU General Public License along with
  54. + * this program. If not, see <http://www.gnu.org/licenses/>.
  55. + */
  56. +
  57. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  58. +
  59. +import net.sf.l2j.Config;
  60. +import net.sf.l2j.gameserver.cache.HtmCache;
  61. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  62. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  63. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  64. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  65. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  66. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  67. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  68. +
  69. +/**
  70. + * @author Baggos
  71. + */
  72. +
  73. +public class TvTEventCommand implements IVoicedCommandHandler
  74. +{
  75. +   private static final String[] VOICED_COMMANDS =
  76. +   {
  77. +       "tvtjoin",
  78. +       "tvtleave",
  79. +       "tvtstatus"
  80. +   };
  81. +  
  82. +   @Override
  83. +   public boolean useVoicedCommand(final String command, final L2PcInstance activeChar, final String target)
  84. +   {
  85. +       if (command.startsWith("tvtjoin"))
  86. +           JoinTvT(target, activeChar);
  87. +      
  88. +       else if (command.startsWith("tvtleave"))
  89. +           LeaveTvT(activeChar);
  90. +      
  91. +       else if (command.startsWith("tvtstatus"))
  92. +           TvTStatus(activeChar);
  93. +      
  94. +       return true;
  95. +   }
  96. +  
  97. +   public static boolean JoinTvT(final String command, L2PcInstance activeChar)
  98. +   {
  99. +       int playerLevel = activeChar.getLevel();
  100. +       if (!TvTEvent.isParticipating())
  101. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  102. +       else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
  103. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You are already on the list."));
  104. +       else if (activeChar.isCursedWeaponEquipped())
  105. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
  106. +       else if (activeChar.isInJail())
  107. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Nothing for you!."));
  108. +       else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
  109. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
  110. +       else if (activeChar.getKarma() > 0)
  111. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Chaotic players are not allowed to participate."));
  112. +       else if (TvTEvent._teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && TvTEvent._teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  113. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
  114. +       else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  115. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Only players from level " + Config.TVT_EVENT_MIN_LVL + " until level " + Config.TVT_EVENT_MAX_LVL + " are allowed to participate."));
  116. +       else if (TvTEvent._teams[0].getParticipatedPlayerCount() > 19 && TvTEvent._teams[1].getParticipatedPlayerCount() > 19)
  117. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + "  player are allowed in one team."));
  118. +       else
  119. +       {
  120. +           TvTEvent.addParticipant(activeChar);
  121. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  122. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  123. +           activeChar.sendPacket(npcHtmlMessage);
  124. +       }
  125. +       return false;
  126. +   }
  127. +  
  128. +   public boolean LeaveTvT(final L2PcInstance activeChar)
  129. +   {
  130. +       if (!TvTEvent.isParticipating())
  131. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  132. +       else if (!TvTEvent.isInactive() && !TvTEvent.isPlayerParticipant(activeChar.getName()))
  133. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
  134. +       else
  135. +       {
  136. +           TvTEvent.removeParticipant(activeChar.getName());
  137. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  138. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  139. +           activeChar.sendPacket(npcHtmlMessage);
  140. +       }
  141. +       return false;
  142. +   }
  143. +  
  144. +   public boolean TvTStatus(final L2PcInstance activeChar)
  145. +   {
  146. +       if (!TvTEvent.isStarted())
  147. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
  148. +       else
  149. +       {
  150. +           String htmFile = "data/html/mods/TvTEventStatus.htm";
  151. +           String htmContent = HtmCache.getInstance().getHtm(htmFile);
  152. +          
  153. +           if (htmContent != null)
  154. +           {
  155. +               int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  156. +               int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  157. +               NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
  158. +              
  159. +               npcHtmlMessage.setHtml(htmContent);
  160. +               // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  161. +               npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  162. +               npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  163. +               npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  164. +               npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  165. +               npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  166. +               npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  167. +               activeChar.sendPacket(npcHtmlMessage);
  168. +           }
  169. +       }
  170. +       return false;
  171. +   }
  172. +  
  173. +   @Override
  174. +   public String[] getVoicedCommandList()
  175. +   {
  176. +       return VOICED_COMMANDS;
  177. +   }
  178. +}
  179. \ No newline at end of file
  180. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  181. ===================================================================
  182. --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java    (revision 89)
  183. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java    (working copy)
  184. @@ -36,6 +36,7 @@
  185.  import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  186.  import net.sf.l2j.gameserver.model.actor.instance.L2XmassTreeInstance;
  187.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  188. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  189.  import net.sf.l2j.gameserver.model.item.SummonItem;
  190.  import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  191.  import net.sf.l2j.gameserver.network.SystemMessageId;
  192. @@ -67,7 +68,10 @@
  193.        
  194.         if (activeChar.isAllSkillsDisabled() || activeChar.isCastingNow())
  195.             return;
  196. -      
  197. +      
  198. +       if (!TvTEvent.onItemSummon(playable.getName()))
  199. +           return;
  200. +
  201.         final SummonItem sitem = SummonItemsData.getInstance().getSummonItem(item.getItemId());
  202.        
  203.         if ((activeChar.getPet() != null || activeChar.isMounted()) && sitem.isPetSummon())
  204. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java
  205. ===================================================================
  206. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java  (nonexistent)
  207. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEvent.java  (working copy)
  208. @@ -0,0 +1,91 @@
  209. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  210. +
  211. +import net.sf.l2j.Config;
  212. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  213. +import net.sf.l2j.gameserver.model.L2Object;
  214. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  215. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  216. +import net.sf.l2j.gameserver.model.entity.TvTEventTeleport;
  217. +import net.sf.l2j.gameserver.util.GMAudit;
  218. +
  219. +/**
  220. + * @author FBIagent The class handles administrator commands for the TvT Engine which was first implemented by FBIagent
  221. + */
  222. +public class AdminTvTEvent implements IAdminCommandHandler
  223. +{
  224. +   private static final String[] ADMIN_COMMANDS =
  225. +   {
  226. +       "admin_tvt_add",
  227. +       "admin_tvt_remove"
  228. +   };
  229. +  
  230. +   @Override
  231. +   public boolean useAdminCommand(String command, L2PcInstance adminInstance)
  232. +   {
  233. +      
  234. +       GMAudit.auditGMAction(adminInstance.getName(), command, (adminInstance.getTarget() != null ? adminInstance.getTarget().getName() : "no-target"), "");
  235. +      
  236. +       if (command.equals("admin_tvt_add"))
  237. +       {
  238. +           L2Object target = adminInstance.getTarget();
  239. +          
  240. +           if (target == null || !(target instanceof L2PcInstance))
  241. +           {
  242. +               adminInstance.sendMessage("You should select a player!");
  243. +               return true;
  244. +           }
  245. +          
  246. +           add(adminInstance, (L2PcInstance) target);
  247. +       }
  248. +       else if (command.equals("admin_tvt_remove"))
  249. +       {
  250. +           L2Object target = adminInstance.getTarget();
  251. +          
  252. +           if (target == null || !(target instanceof L2PcInstance))
  253. +           {
  254. +               adminInstance.sendMessage("You should select a player!");
  255. +               return true;
  256. +           }
  257. +          
  258. +           remove(adminInstance, (L2PcInstance) target);
  259. +       }
  260. +      
  261. +       return true;
  262. +   }
  263. +  
  264. +   @Override
  265. +   public String[] getAdminCommandList()
  266. +   {
  267. +       return ADMIN_COMMANDS;
  268. +   }
  269. +  
  270. +   private static void add(L2PcInstance adminInstance, L2PcInstance playerInstance)
  271. +   {
  272. +       if (TvTEvent.isPlayerParticipant(playerInstance.getName()))
  273. +       {
  274. +           adminInstance.sendMessage("Player already participated in the event!");
  275. +           return;
  276. +       }
  277. +      
  278. +       if (!TvTEvent.addParticipant(playerInstance))
  279. +       {
  280. +           adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
  281. +           return;
  282. +       }
  283. +      
  284. +       if (TvTEvent.isStarted())
  285. +           // we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
  286. +           new TvTEventTeleport(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
  287. +   }
  288. +  
  289. +   private static void remove(L2PcInstance adminInstance, L2PcInstance playerInstance)
  290. +   {
  291. +       if (!TvTEvent.removeParticipant(playerInstance.getName()))
  292. +       {
  293. +           adminInstance.sendMessage("Player is not part of the event!");
  294. +           return;
  295. +       }
  296. +      
  297. +       new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, true, true);
  298. +   }
  299. +}
  300. \ No newline at end of file
  301. Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
  302. ===================================================================
  303. --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java   (nonexistent)
  304. +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java   (working copy)
  305. @@ -0,0 +1,10 @@
  306. +package net.sf.l2j.gameserver.handler;
  307. +
  308. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  309. +
  310. +public interface IVoicedCommandHandler
  311. +{
  312. +       public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
  313. +
  314. +       public String[] getVoicedCommandList();
  315. +}
  316. \ No newline at end of file
  317. Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java
  318. ===================================================================
  319. --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java   (nonexistent)
  320. +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeleport.java   (working copy)
  321. @@ -0,0 +1,89 @@
  322. +package net.sf.l2j.gameserver.model.entity;
  323. +
  324. +import net.sf.l2j.commons.concurrent.ThreadPool;
  325. +
  326. +import net.sf.l2j.Config;
  327. +import net.sf.l2j.gameserver.datatables.SkillTable;
  328. +import net.sf.l2j.gameserver.model.L2Effect;
  329. +import net.sf.l2j.gameserver.model.L2Skill;
  330. +import net.sf.l2j.gameserver.model.actor.L2Summon;
  331. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  332. +
  333. +public class TvTEventTeleport implements Runnable
  334. +{
  335. +   /** Gives Noblesse to players */
  336. +   static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
  337. +   /** The instance of the player to teleport */
  338. +   public L2PcInstance _playerInstance;
  339. +   /** Coordinates of the spot to teleport to */
  340. +   public int[] _coordinates = new int[3];
  341. +   /** Admin removed this player from event */
  342. +   private boolean _adminRemove;
  343. +  
  344. +   /**
  345. +    * Initialize the teleporter and start the delayed task
  346. +    * @param playerInstance
  347. +    * @param coordinates
  348. +    * @param fastSchedule
  349. +    * @param adminRemove
  350. +    */
  351. +   public TvTEventTeleport(L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  352. +   {
  353. +       _playerInstance = playerInstance;
  354. +       _coordinates = coordinates;
  355. +       _adminRemove = adminRemove;
  356. +      
  357. +       // in config as seconds
  358. +       long delay = (TvTEvent.isStarted() ? Config.TVT_EVENT_RESPAWN_TELEPORT_DELAY : Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
  359. +      
  360. +       if (fastSchedule)
  361. +           delay = 0;
  362. +      
  363. +       ThreadPool.schedule(this, delay);
  364. +   }
  365. +  
  366. +   /**
  367. +    * The task method to teleport the player<br>
  368. +    * 1. Unsummon pet if there is one 2. Remove all effects 3. Revive and full heal the player 4. Teleport the player 5. Broadcast status and user info
  369. +    * @see java.lang.Runnable#run()
  370. +    */
  371. +   @Override
  372. +   public void run()
  373. +   {
  374. +       if (_playerInstance == null)
  375. +           return;
  376. +      
  377. +       L2Summon summon = _playerInstance.getPet();
  378. +      
  379. +       if (summon != null)
  380. +           summon.unSummon(_playerInstance);
  381. +      
  382. +       for (L2Effect effect : _playerInstance.getAllEffects())
  383. +       {
  384. +           if (Config.TVT_EVENT_REMOVE_BUFFS && effect != null)
  385. +               effect.exit();
  386. +       }
  387. +      
  388. +       ThreadPool.schedule(new Runnable()
  389. +       {
  390. +           @Override
  391. +           public void run()
  392. +           {
  393. +               _playerInstance.doRevive();
  394. +               _playerInstance.setCurrentHp(_playerInstance.getMaxHp());
  395. +               _playerInstance.setCurrentCp(_playerInstance.getMaxCp());
  396. +               _playerInstance.setCurrentMp(_playerInstance.getMaxMp());
  397. +               noblesse.getEffects(_playerInstance, _playerInstance);
  398. +               _playerInstance.teleToLocation(_coordinates[0], _coordinates[1], _coordinates[2], 0);
  399. +           }
  400. +       }, 4000);
  401. +      
  402. +       if (TvTEvent.isStarted() && !_adminRemove)
  403. +           _playerInstance.setTeam(TvTEvent.getParticipantTeamId(_playerInstance.getName()) + 1);
  404. +       else
  405. +           _playerInstance.setTeam(0);
  406. +      
  407. +       _playerInstance.broadcastStatusUpdate();
  408. +       _playerInstance.broadcastUserInfo();
  409. +   }
  410. +}
  411. \ No newline at end of file
  412. Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  413. ===================================================================
  414. --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (nonexistent)
  415. +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (working copy)
  416. @@ -0,0 +1,50 @@
  417. +package net.sf.l2j.gameserver.handler;
  418. +
  419. +import java.util.HashMap;
  420. +import java.util.Map;
  421. +
  422. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvTEventCommand;
  423. +
  424. +public class VoicedCommandHandler
  425. +{
  426. +   private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
  427. +  
  428. +   public static VoicedCommandHandler getInstance()
  429. +   {
  430. +       return SingletonHolder._instance;
  431. +   }
  432. +  
  433. +   protected VoicedCommandHandler()
  434. +   {
  435. +       // coloque aqui os comandos
  436. +       registerHandler(new TvTEventCommand());
  437. +   }
  438. +  
  439. +   public void registerHandler(IVoicedCommandHandler handler)
  440. +   {
  441. +       String[] ids = handler.getVoicedCommandList();
  442. +      
  443. +       for (int i = 0; i < ids.length; i++)
  444. +           _datatable.put(ids[i].hashCode(), handler);
  445. +   }
  446. +  
  447. +   public IVoicedCommandHandler getHandler(String voicedCommand)
  448. +   {
  449. +       String command = voicedCommand;
  450. +      
  451. +       if (voicedCommand.indexOf(" ") != -1)
  452. +           command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
  453. +      
  454. +       return _datatable.get(command.hashCode());
  455. +   }
  456. +  
  457. +   public int size()
  458. +   {
  459. +       return _datatable.size();
  460. +   }
  461. +  
  462. +   private static class SingletonHolder
  463. +   {
  464. +       protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
  465. +   }
  466. +}
  467. \ No newline at end of file
  468. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java
  469. ===================================================================
  470. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java   (nonexistent)
  471. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TvTEventCommand.java   (working copy)
  472. @@ -0,0 +1,137 @@
  473. +/*
  474. + * This program is free software: you can redistribute it and/or modify it under
  475. + * the terms of the GNU General Public License as published by the Free Software
  476. + * Foundation, either version 3 of the License, or (at your option) any later
  477. + * version.
  478. + *
  479. + * This program is distributed in the hope that it will be useful, but WITHOUT
  480. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  481. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  482. + * details.
  483. + *
  484. + * You should have received a copy of the GNU General Public License along with
  485. + * this program. If not, see <http://www.gnu.org/licenses/>.
  486. + */
  487. +
  488. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  489. +
  490. +import net.sf.l2j.Config;
  491. +import net.sf.l2j.gameserver.cache.HtmCache;
  492. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  493. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  494. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  495. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  496. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  497. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  498. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  499. +
  500. +/**
  501. + * @author Baggos
  502. + */
  503. +
  504. +public class TvTEventCommand implements IVoicedCommandHandler
  505. +{
  506. +   private static final String[] VOICED_COMMANDS =
  507. +   {
  508. +       "tvtjoin",
  509. +       "tvtleave",
  510. +       "tvtstatus"
  511. +   };
  512. +  
  513. +   @Override
  514. +   public boolean useVoicedCommand(final String command, final L2PcInstance activeChar, final String target)
  515. +   {
  516. +       if (command.startsWith("tvtjoin"))
  517. +           JoinTvT(target, activeChar);
  518. +      
  519. +       else if (command.startsWith("tvtleave"))
  520. +           LeaveTvT(activeChar);
  521. +      
  522. +       else if (command.startsWith("tvtstatus"))
  523. +           TvTStatus(activeChar);
  524. +      
  525. +       return true;
  526. +   }
  527. +  
  528. +   public static boolean JoinTvT(final String command, L2PcInstance activeChar)
  529. +   {
  530. +       int playerLevel = activeChar.getLevel();
  531. +       if (!TvTEvent.isParticipating())
  532. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  533. +       else if (TvTEvent.isPlayerParticipant(activeChar.getName()))
  534. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You are already on the list."));
  535. +       else if (activeChar.isCursedWeaponEquipped())
  536. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
  537. +       else if (activeChar.isInJail())
  538. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Nothing for you!."));
  539. +       else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
  540. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
  541. +       else if (activeChar.getKarma() > 0)
  542. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Chaotic players are not allowed to participate."));
  543. +       else if (TvTEvent._teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && TvTEvent._teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  544. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
  545. +       else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  546. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Only players from level " + Config.TVT_EVENT_MIN_LVL + " until level " + Config.TVT_EVENT_MAX_LVL + " are allowed to participate."));
  547. +       else if (TvTEvent._teams[0].getParticipatedPlayerCount() > 19 && TvTEvent._teams[1].getParticipatedPlayerCount() > 19)
  548. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + "  player are allowed in one team."));
  549. +       else
  550. +       {
  551. +           TvTEvent.addParticipant(activeChar);
  552. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  553. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  554. +           activeChar.sendPacket(npcHtmlMessage);
  555. +       }
  556. +       return false;
  557. +   }
  558. +  
  559. +   public boolean LeaveTvT(final L2PcInstance activeChar)
  560. +   {
  561. +       if (!TvTEvent.isParticipating())
  562. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  563. +       else if (!TvTEvent.isInactive() && !TvTEvent.isPlayerParticipant(activeChar.getName()))
  564. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
  565. +       else
  566. +       {
  567. +           TvTEvent.removeParticipant(activeChar.getName());
  568. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  569. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  570. +           activeChar.sendPacket(npcHtmlMessage);
  571. +       }
  572. +       return false;
  573. +   }
  574. +  
  575. +   public boolean TvTStatus(final L2PcInstance activeChar)
  576. +   {
  577. +       if (!TvTEvent.isStarted())
  578. +           activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
  579. +       else
  580. +       {
  581. +           String htmFile = "data/html/mods/TvTEventStatus.htm";
  582. +           String htmContent = HtmCache.getInstance().getHtm(htmFile);
  583. +          
  584. +           if (htmContent != null)
  585. +           {
  586. +               int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  587. +               int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  588. +               NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
  589. +              
  590. +               npcHtmlMessage.setHtml(htmContent);
  591. +               // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  592. +               npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  593. +               npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  594. +               npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  595. +               npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  596. +               npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  597. +               npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  598. +               activeChar.sendPacket(npcHtmlMessage);
  599. +           }
  600. +       }
  601. +       return false;
  602. +   }
  603. +  
  604. +   @Override
  605. +   public String[] getVoicedCommandList()
  606. +   {
  607. +       return VOICED_COMMANDS;
  608. +   }
  609. +}
  610. \ No newline at end of file
  611. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
  612. ===================================================================
  613. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java    (revision 89)
  614. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java    (working copy)
  615. @@ -14,7 +14,11 @@
  616.   */
  617.  package net.sf.l2j.gameserver.handler.chathandlers;
  618.  
  619. +import java.util.StringTokenizer;
  620. +
  621.  import net.sf.l2j.gameserver.handler.IChatHandler;
  622. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  623. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  624.  import net.sf.l2j.gameserver.model.BlockList;
  625.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  626.  import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  627. @@ -34,13 +38,42 @@
  628.         if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
  629.             return;
  630.        
  631. -       final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  632. -       for (L2PcInstance player : activeChar.getKnownTypeInRadius(L2PcInstance.class, 1250))
  633. +       boolean vcd_used = false;
  634. +       if (text.startsWith("."))
  635.         {
  636. -           if (!BlockList.isBlocked(player, activeChar))
  637. -               player.sendPacket(cs);
  638. +           StringTokenizer st = new StringTokenizer(text);
  639. +           IVoicedCommandHandler vch;
  640. +           String command = "";
  641. +           if (st.countTokens() > 1)
  642. +           {
  643. +               command = st.nextToken().substring(1);
  644. +               params = text.substring(command.length() + 2);
  645. +               vch = VoicedCommandHandler.getInstance().getHandler(command);
  646. +           }
  647. +           else
  648. +           {
  649. +               command = text.substring(1);
  650. +               vch = VoicedCommandHandler.getInstance().getHandler(command);
  651. +           }
  652. +          
  653. +           if (vch != null)
  654. +           {
  655. +               vch.useVoicedCommand(command, activeChar, params);
  656. +               vcd_used = true;
  657. +           }
  658.         }
  659. -       activeChar.sendPacket(cs);
  660. +       if (!vcd_used)
  661. +       {
  662. +           CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  663. +          
  664. +           for (L2PcInstance player : activeChar.getKnownTypeInRadius(L2PcInstance.class, 1250))
  665. +           {
  666. +               if (!BlockList.isBlocked(player, activeChar))
  667. +                   player.sendPacket(cs);
  668. +           }
  669. +          
  670. +           activeChar.sendPacket(cs);
  671. +       }
  672.     }
  673.    
  674.     @Override
  675. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  676. ===================================================================
  677. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 89)
  678. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  679. @@ -44,6 +44,7 @@
  680.  import net.sf.l2j.gameserver.model.entity.Castle;
  681.  import net.sf.l2j.gameserver.model.entity.ClanHall;
  682.  import net.sf.l2j.gameserver.model.entity.Siege;
  683. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  684.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  685.  import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  686.  import net.sf.l2j.gameserver.model.zone.ZoneId;
  687. @@ -319,6 +320,7 @@
  688.         PetitionManager.getInstance().checkPetitionMessages(activeChar);
  689.        
  690.         activeChar.onPlayerEnter();
  691. +       TvTEvent.onLogin(activeChar, activeChar);
  692.        
  693.         sendPacket(new SkillCoolTime(activeChar));
  694.        
  695. Index: config/events.properties
  696. ===================================================================
  697. --- config/events.properties    (revision 89)
  698. +++ config/events.properties    (working copy)
  699. @@ -235,4 +235,58 @@
  700.  AltFishChampionshipReward2 = 500000
  701.  AltFishChampionshipReward3 = 300000
  702.  AltFishChampionshipReward4 = 200000
  703. -AltFishChampionshipReward5 = 100000
  704. \ No newline at end of file
  705. +AltFishChampionshipReward5 = 100000
  706. +
  707. +#---------------------------------------------------------------
  708. +# Team vs. Team Event Engine                     -
  709. +#---------------------------------------------------------------
  710. +# enable TvTEvent
  711. +TvTEventEnabled = true
  712. +# Time Between TvT events (in minutes, 300 = 5 hours)
  713. +TvTEventInterval = 1
  714. +#  Registration timer (in minutes) from start of event.
  715. +TvTEventParticipationTime = 1
  716. +#  Event running time, in minutes
  717. +TvTEventRunningTime = 5
  718. +# TvT Event NPC Details (create a custom npc of type L2TvTEventNpc)
  719. +TvTEventParticipationNpcId = 70010
  720. +TvTEventParticipationNpcCoordinates = 83358,148879,-3405
  721. +# Minimum amount of players allowed in each team
  722. +TvTEventMinPlayersInTeams = 1
  723. +TvTEventMaxPlayersInTeams = 20
  724. +# Level rules
  725. +TvTEventMinPlayerLevel = 70
  726. +TvTEventMaxPlayerLevel = 80
  727. +# Remove buffs effect
  728. +TvTEventRemoveBuffs = false
  729. +# If Enable Players cant be healed
  730. +TvTHealPlayersEnable = true
  731. +# If true, gives reward for kills stage without die
  732. +# Example: Get 3/7/10 kills without die, and you will be rewarded
  733. +# No more than 1 item!
  734. +TvTKillsRewardEnable = true
  735. +TvTKillsReward = 57,500000000
  736. +# Teleport delay Timers (in seconds)
  737. +TvTEventRespawnTeleportDelay = 5
  738. +TvTEventStartLeaveTeleportDelay = 10
  739. +# Back to Town
  740. +TvTEventBack = 83013,148595,-3469
  741. +# First Team Details (name, start and death x,y,z tp point)
  742. +TvTEventTeam1Name = Good
  743. +TvTEventTeam1Coordinates = 148695,46725,-3414
  744. +# Second Team Details (name, start and death x,y,z tp point)
  745. +TvTEventTeam2Name = Evil
  746. +TvTEventTeam2Coordinates = 149999,46728,-3414
  747. +# Reward for winning team
  748. +# itemId,amount;itemId,amount;itemId,amount;...
  749. +# no ";" at the start or end
  750. +TvTEventReward = 57,100000;5575,1000
  751. +# TvTEvent Rules
  752. +TvTEventTargetTeamMembersAllowed = true
  753. +TvTEventPotionsAllowed = false
  754. +TvTEventSummonByItemAllowed = false
  755. +# Door id's to close/open on start/end
  756. +# ex.: 1;2;3;4;5;6
  757. +# no ";" at the start or end
  758. +TvTEventDoorsCloseOpenOnStartEnd =
  759. +
  760. \ No newline at end of file
  761. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  762. ===================================================================
  763. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java    (revision 88)
  764. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java    (working copy)
  765. @@ -16,6 +16,7 @@
  766.  
  767.  import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
  768.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  769. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  770.  import net.sf.l2j.gameserver.model.zone.ZoneId;
  771.  import net.sf.l2j.gameserver.network.L2GameClient;
  772.  import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
  773. @@ -51,7 +52,14 @@
  774.             sendPacket(RestartResponse.valueOf(false));
  775.             return;
  776.         }
  777. -      
  778. +      
  779. +       if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  780. +       {
  781. +           player.sendMessage("You can not restart when you registering in TvTEvent.");
  782. +           sendPacket(RestartResponse.valueOf(false));
  783. +           return;
  784. +       }
  785. +  
  786.         if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
  787.         {
  788.             player.sendPacket(SystemMessageId.CANT_RESTART_WHILE_FIGHTING);
  789. Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  790. ===================================================================
  791. --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java   (revision 88)
  792. +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java   (working copy)
  793. @@ -26,7 +26,7 @@
  794.  {
  795.     private final int _charObjId;
  796.     private final boolean _fake;
  797. -  
  798. +   private boolean _funEvent;
  799.     private boolean _sweepable;
  800.     private boolean _allowFixedRes;
  801.     private L2Clan _clan;
  802. @@ -43,6 +43,7 @@
  803.             L2PcInstance player = (L2PcInstance) cha;
  804.             _allowFixedRes = player.getAccessLevel().allowFixedRes();
  805.             _clan = player.getClan();
  806. +           _funEvent = !player.isInFunEvent();
  807.            
  808.         }
  809.         else if (cha instanceof L2Attackable)
  810. @@ -57,9 +58,9 @@
  811.        
  812.         writeC(0x06);
  813.         writeD(_charObjId);
  814. -       writeD(0x01); // to nearest village
  815. +       writeD(_funEvent ? 0x01 : 0); // to nearest village
  816.        
  817. -       if (_clan != null)
  818. +       if (_funEvent && _clan != null)
  819.         {
  820.             L2SiegeClan siegeClan = null;
  821.             boolean isInDefense = false;
  822. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  823. ===================================================================
  824. --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 88)
  825. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
  826. @@ -21,6 +21,7 @@
  827.  import net.sf.l2j.gameserver.model.actor.L2Character;
  828.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  829.  import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  830. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  831.  import net.sf.l2j.gameserver.skills.Formulas;
  832.  import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
  833.  import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  834. @@ -35,6 +36,12 @@
  835.     @Override
  836.     public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  837.     {
  838. +       if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(activeChar.getName()))
  839. +       {
  840. +           activeChar.sendMessage("You can not use this action when it is participating in this event.");
  841. +           return;
  842. +       }
  843. +      
  844.         for (L2Object cha : targets)
  845.         {
  846.             final L2Character target = (L2Character) cha;
  847. Index: java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java
  848. ===================================================================
  849. --- java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java    (nonexistent)
  850. +++ java/net/sf/l2j/gameserver/model/entity/TvTEventManager.java    (working copy)
  851. @@ -0,0 +1,139 @@
  852. +package net.sf.l2j.gameserver.model.entity;
  853. +
  854. +import net.sf.l2j.commons.concurrent.ThreadPool;
  855. +
  856. +import net.sf.l2j.Config;
  857. +import net.sf.l2j.gameserver.util.Broadcast;
  858. +
  859. +/**
  860. + * @author FBIagent
  861. + */
  862. +public class TvTEventManager implements Runnable
  863. +{
  864. +   /**
  865. +    * The one and only instance of this class<br>
  866. +    */
  867. +   private static TvTEventManager _instance = null;
  868. +  
  869. +   /**
  870. +    * New instance only by getInstance()<br>
  871. +    */
  872. +   private TvTEventManager()
  873. +   {
  874. +       if (Config.TVT_EVENT_ENABLED)
  875. +       {
  876. +           ThreadPool.schedule(this, 0);
  877. +           System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Started.");
  878. +       }
  879. +       else
  880. +           System.out.println("TvTEventEngine[TvTManager.TvTManager()]: Engine is disabled.");
  881. +   }
  882. +  
  883. +   /**
  884. +    * Initialize new/Returns the one and only instance<br>
  885. +    * <br>
  886. +    * @return TvTManager<br>
  887. +    */
  888. +   public static TvTEventManager getInstance()
  889. +   {
  890. +       if (_instance == null)
  891. +           _instance = new TvTEventManager();
  892. +      
  893. +       return _instance;
  894. +   }
  895. +  
  896. +   /**
  897. +    * The task method to handle cycles of the event
  898. +    * @see java.lang.Runnable#run()
  899. +    */
  900. +   @Override
  901. +   public void run()
  902. +   {
  903. +       TvTEvent.init();
  904. +      
  905. +       for (;;)
  906. +       {
  907. +           waiter(Config.TVT_EVENT_INTERVAL * 60); // in config given as minutes
  908. +          
  909. +           if (!TvTEvent.startParticipation())
  910. +           {
  911. +               Broadcast.announceToOnlinePlayers("TvT: Event was canceled.", true);
  912. +               System.out.println("TvTEventEngine[TvTManager.run()]: Error spawning event npc for participation.");
  913. +               continue;
  914. +           }
  915. +           Broadcast.announceToOnlinePlayers("TvT: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type .tvtjoin or .tvtleave", true);
  916. +          
  917. +           waiter(Config.TVT_EVENT_PARTICIPATION_TIME * 60); // in config given as minutes
  918. +          
  919. +           if (!TvTEvent.startFight())
  920. +           {
  921. +               Broadcast.announceToOnlinePlayers("TvT: Event canceled due to lack of Participation.", true);
  922. +               System.out.println("TvTEventEngine[TvTManager.run()]: Lack of registration, abort event.");
  923. +               continue;
  924. +           }
  925. +           Broadcast.announceToOnlinePlayers("TvT: Registration closed!", true);
  926. +           TvTEvent.sysMsgToAllParticipants("TvT: Teleporting participants to an arena in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  927. +          
  928. +           waiter(Config.TVT_EVENT_RUNNING_TIME * 60); // in config given as minutes
  929. +           Broadcast.announceToOnlinePlayers(TvTEvent.calculateRewards(), true);
  930. +           TvTEvent.sysMsgToAllParticipants("TvT: Teleporting back to the registration npc in " + Config.TVT_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  931. +           TvTEvent.stopFight();
  932. +       }
  933. +   }
  934. +  
  935. +   /**
  936. +    * This method waits for a period time delay
  937. +    * @param seconds
  938. +    */
  939. +   void waiter(int seconds)
  940. +   {
  941. +       while (seconds > 1)
  942. +       {
  943. +           seconds--; // here because we don't want to see two time announce at the same time
  944. +          
  945. +           if (TvTEvent.isParticipating() || TvTEvent.isStarted())
  946. +           {
  947. +               switch (seconds)
  948. +               {
  949. +                   case 3600: // 1 hour left
  950. +                       if (TvTEvent.isParticipating())
  951. +                           Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 / 60 + " hour(s) umtil registration is closed!", true);
  952. +                       else if (TvTEvent.isStarted())
  953. +                           TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 / 60 + " hour(s) until event is finished!");
  954. +                      
  955. +                       break;
  956. +                   case 1800: // 30 minutes left
  957. +                   case 900: // 15 minutes left
  958. +                   case 600: // 10 minutes left
  959. +                   case 300: // 5 minutes left
  960. +                   case 240: // 4 minutes left
  961. +                   case 180: // 3 minutes left
  962. +                   case 120: // 2 minutes left
  963. +                   case 60: // 1 minute left
  964. +                       if (TvTEvent.isParticipating())
  965. +                           Broadcast.announceToOnlinePlayers("TvT: " + seconds / 60 + " minute(s) until registration is closed!", true);
  966. +                       else if (TvTEvent.isStarted())
  967. +                           TvTEvent.sysMsgToAllParticipants("TvT: " + seconds / 60 + " minute(s) until the event is finished!");
  968. +                      
  969. +                       break;
  970. +                   case 30: // 30 seconds left
  971. +                       /**
  972. +                        * case 15: // 15 seconds left case 10: // 10 seconds left
  973. +                        */
  974. +                   case 5: // 5 seconds left
  975. +                      
  976. +                       /**
  977. +                        * case 4: // 4 seconds left case 3: // 3 seconds left case 2: // 2 seconds left case 1: // 1 seconds left
  978. +                        */
  979. +                       if (TvTEvent.isParticipating())
  980. +                           Broadcast.announceToOnlinePlayers("TvT: " + seconds + " second(s) until registration is closed!", true);
  981. +                       else if (TvTEvent.isStarted())
  982. +                           TvTEvent.sysMsgToAllParticipants("TvT: " + seconds + " second(s) until the event is finished!");
  983. +                      
  984. +                       break;
  985. +               }
  986. +           }
  987. +           TvTEvent.waiter(1);
  988. +       }
  989. +   }
  990. +}
  991. \ No newline at end of file
  992. Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  993. ===================================================================
  994. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java  (revision 88)
  995. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java  (working copy)
  996. @@ -22,6 +22,7 @@
  997.  
  998.  import net.sf.l2j.Config;
  999.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1000. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  1001.  import net.sf.l2j.gameserver.network.SystemMessageId;
  1002.  import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1003.  import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  1004. @@ -256,7 +257,13 @@
  1005.             player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
  1006.             return false;
  1007.         }
  1008. -      
  1009. +      
  1010. +       if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  1011. +       {
  1012. +           player.sendMessage("You can not register in olympiad while registered at TvT.");
  1013. +           return false;
  1014. +       }
  1015. +  
  1016.         if (player.isSubClassActive())
  1017.         {
  1018.             player.sendPacket(SystemMessageId.YOU_CANT_JOIN_THE_OLYMPIAD_WITH_A_SUB_JOB_CHARACTER);
  1019. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
  1020. ===================================================================
  1021. --- java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java  (revision 89)
  1022. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java  (working copy)
  1023. @@ -19,6 +19,7 @@
  1024.  import net.sf.l2j.gameserver.model.L2Skill;
  1025.  import net.sf.l2j.gameserver.model.actor.L2Character;
  1026.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1027. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  1028.  import net.sf.l2j.gameserver.network.SystemMessageId;
  1029.  import net.sf.l2j.gameserver.network.serverpackets.ConfirmDlg;
  1030.  import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  1031. @@ -46,7 +47,14 @@
  1032.         // Check player status.
  1033.         if (!L2PcInstance.checkSummonerStatus(player))
  1034.             return;
  1035. -      
  1036. +      
  1037. +       // Players can't summon anyone on event
  1038. +       if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  1039. +       {
  1040. +           player.sendMessage("You can not use this action when it is participating in this event.");
  1041. +           return;
  1042. +       }
  1043. +  
  1044.         for (L2Object obj : targets)
  1045.         {
  1046.             // The target must be a player.
  1047. Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  1048. ===================================================================
  1049. --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 88)
  1050. +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
  1051. @@ -53,7 +53,7 @@
  1052.         if (activeChar instanceof L2PcInstance)
  1053.         {
  1054.             // Check invalid states.
  1055. -           if (activeChar.isAfraid() || ((L2PcInstance) activeChar).isInOlympiadMode() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null)
  1056. +           if (activeChar.isAfraid() || ((L2PcInstance) activeChar).isInOlympiadMode() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null  || ((L2PcInstance) activeChar).isInFunEvent())
  1057.                 return;
  1058.         }
  1059.        
  1060. Index: java/net/sf/l2j/Config.java
  1061. ===================================================================
  1062. --- java/net/sf/l2j/Config.java (revision 91)
  1063. +++ java/net/sf/l2j/Config.java (working copy)
  1064. @@ -218,6 +218,33 @@
  1065.     public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
  1066.     public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
  1067.    
  1068. +   /** TvT Event */
  1069. +   public static boolean TVT_EVENT_ENABLED;
  1070. +   public static int TVT_EVENT_INTERVAL;
  1071. +   public static int TVT_EVENT_PARTICIPATION_TIME;
  1072. +   public static int TVT_EVENT_RUNNING_TIME;
  1073. +   public static int TVT_EVENT_PARTICIPATION_NPC_ID;
  1074. +   public static int TVT_EVENT_MIN_PLAYERS_IN_TEAMS;
  1075. +   public static int TVT_EVENT_MAX_PLAYERS_IN_TEAMS;
  1076. +   public static int TVT_EVENT_RESPAWN_TELEPORT_DELAY;
  1077. +   public static int TVT_EVENT_START_LEAVE_TELEPORT_DELAY;
  1078. +   public static String TVT_EVENT_TEAM_1_NAME;
  1079. +   public static int[] TVT_EVENT_BACK_COORDINATES = new int[3];
  1080. +   public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  1081. +   public static String TVT_EVENT_TEAM_2_NAME;
  1082. +   public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  1083. +   public static List<int[]> TVT_EVENT_REWARDS = new ArrayList<>();
  1084. +   public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
  1085. +   public static boolean TVT_EVENT_POTIONS_ALLOWED;
  1086. +   public static boolean TVT_EVENT_SUMMON_BY_ITEM_ALLOWED;
  1087. +   public static List<Integer> TVT_EVENT_DOOR_IDS = new ArrayList<>();
  1088. +   public static byte TVT_EVENT_MIN_LVL;
  1089. +   public static byte TVT_EVENT_MAX_LVL;
  1090. +   public static boolean TVT_EVENT_REMOVE_BUFFS;
  1091. +   public static boolean TVT_EVENT_HEAL_PLAYERS;
  1092. +   public static boolean TVT_KILLS_REWARD_ENABLED;
  1093. +   public static List<int[]> TVT_KILLS_REWARD = new ArrayList<>();
  1094. +  
  1095.     // --------------------------------------------------
  1096.     // GeoEngine
  1097.     // --------------------------------------------------
  1098. @@ -899,6 +926,144 @@
  1099.         ALT_FISH_CHAMPIONSHIP_REWARD_3 = events.getProperty("AltFishChampionshipReward3", 300000);
  1100.         ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
  1101.         ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
  1102. +      
  1103. +       TVT_EVENT_ENABLED = events.getProperty("TvTEventEnabled", false);
  1104. +       TVT_EVENT_INTERVAL = events.getProperty("TvTEventInterval", 18000);
  1105. +       TVT_EVENT_PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 3600);
  1106. +       TVT_EVENT_RUNNING_TIME = events.getProperty("TvTEventRunningTime", 1800);
  1107. +       TVT_EVENT_PARTICIPATION_NPC_ID = events.getProperty("TvTEventParticipationNpcId", 0);
  1108. +       TVT_EVENT_REMOVE_BUFFS = events.getProperty("TvTEventRemoveBuffs", false);
  1109. +       TVT_KILLS_REWARD_ENABLED = events.getProperty("TvTKillsRewardEnable", false);
  1110. +       TVT_EVENT_HEAL_PLAYERS = events.getProperty("TvTHealPlayersEnable", false);
  1111. +      
  1112. +       if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
  1113. +       {
  1114. +           TVT_EVENT_ENABLED = false;
  1115. +           System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcId");
  1116. +       }
  1117. +       else
  1118. +       {
  1119. +           String[] propertySplit = events.getProperty("TvTEventParticipationNpcCoordinates", "0,0,0").split(",");
  1120. +          
  1121. +           if (propertySplit.length < 3)
  1122. +           {
  1123. +               TVT_EVENT_ENABLED = false;
  1124. +               System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventParticipationNpcCoordinates");
  1125. +           }
  1126. +           else
  1127. +           {
  1128. +               TVT_EVENT_BACK_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  1129. +               TVT_EVENT_BACK_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  1130. +               TVT_EVENT_BACK_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  1131. +              
  1132. +               TVT_EVENT_MIN_PLAYERS_IN_TEAMS = events.getProperty("TvTEventMinPlayersInTeams", 1);
  1133. +               TVT_EVENT_MAX_PLAYERS_IN_TEAMS = events.getProperty("TvTEventMaxPlayersInTeams", 20);
  1134. +               TVT_EVENT_MIN_LVL = (byte) events.getProperty("TvTEventMinPlayerLevel", 1);
  1135. +               TVT_EVENT_MAX_LVL = (byte) events.getProperty("TvTEventMaxPlayerLevel", 80);
  1136. +               TVT_EVENT_RESPAWN_TELEPORT_DELAY = events.getProperty("TvTEventRespawnTeleportDelay", 20);
  1137. +               TVT_EVENT_START_LEAVE_TELEPORT_DELAY = events.getProperty("TvTEventStartLeaveTeleportDelay", 20);
  1138. +              
  1139. +               TVT_EVENT_TEAM_1_NAME = events.getProperty("TvTEventTeam1Name", "Team1");
  1140. +               propertySplit = events.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
  1141. +              
  1142. +               if (propertySplit.length < 3)
  1143. +               {
  1144. +                   TVT_EVENT_ENABLED = false;
  1145. +                   System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam1Coordinates");
  1146. +               }
  1147. +               else
  1148. +               {
  1149. +                   TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  1150. +                   TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  1151. +                   TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  1152. +                  
  1153. +                   TVT_EVENT_TEAM_2_NAME = events.getProperty("TvTEventTeam2Name", "Team2");
  1154. +                   propertySplit = events.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
  1155. +                  
  1156. +                   if (propertySplit.length < 3)
  1157. +                   {
  1158. +                       TVT_EVENT_ENABLED = false;
  1159. +                       System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventTeam2Coordinates");
  1160. +                   }
  1161. +                   else
  1162. +                   {
  1163. +                       TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  1164. +                       TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  1165. +                       TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  1166. +                       propertySplit = events.getProperty("TvTEventReward", "57,100000").split(";");
  1167. +                      
  1168. +                       for (String reward : propertySplit)
  1169. +                       {
  1170. +                           String[] rewardSplit = reward.split(",");
  1171. +                          
  1172. +                           if (rewardSplit.length != 2)
  1173. +                               System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  1174. +                           else
  1175. +                           {
  1176. +                               try
  1177. +                               {
  1178. +                                   TVT_EVENT_REWARDS.add(new int[]
  1179. +                                   {
  1180. +                                       Integer.valueOf(rewardSplit[0]),
  1181. +                                       Integer.valueOf(rewardSplit[1])
  1182. +                                   });
  1183. +                               }
  1184. +                               catch (NumberFormatException nfe)
  1185. +                               {
  1186. +                                   if (!reward.equals(""))
  1187. +                                       System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + reward + "\"");
  1188. +                               }
  1189. +                           }
  1190. +                       }
  1191. +                      
  1192. +                       propertySplit = events.getProperty("TvTKillsReward", "57,100000").split(";");
  1193. +                      
  1194. +                       for (String rewardKills : propertySplit)
  1195. +                       {
  1196. +                           String[] rewardSplit = rewardKills.split(",");
  1197. +                          
  1198. +                           if (rewardSplit.length != 2)
  1199. +                               System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
  1200. +                           else
  1201. +                           {
  1202. +                               try
  1203. +                               {
  1204. +                                   TVT_KILLS_REWARD.add(new int[]
  1205. +                                   {
  1206. +                                       Integer.valueOf(rewardSplit[0]),
  1207. +                                       Integer.valueOf(rewardSplit[1])
  1208. +                                   });
  1209. +                               }
  1210. +                               catch (NumberFormatException nfe)
  1211. +                               {
  1212. +                                   if (!rewardKills.equals(""))
  1213. +                                       System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventReward \"" + rewardKills + "\"");
  1214. +                               }
  1215. +                           }
  1216. +                       }
  1217. +                      
  1218. +                       TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = events.getProperty("TvTEventTargetTeamMembersAllowed", true);
  1219. +                       TVT_EVENT_POTIONS_ALLOWED = events.getProperty("TvTEventPotionsAllowed", false);
  1220. +                       TVT_EVENT_SUMMON_BY_ITEM_ALLOWED = events.getProperty("TvTEventSummonByItemAllowed", false);
  1221. +                       propertySplit = events.getProperty("TvTEventDoorsCloseOpenOnStartEnd", "").split(";");
  1222. +                      
  1223. +                       for (String door : propertySplit)
  1224. +                       {
  1225. +                           try
  1226. +                           {
  1227. +                               TVT_EVENT_DOOR_IDS.add(Integer.valueOf(door));
  1228. +                           }
  1229. +                           catch (NumberFormatException nfe)
  1230. +                           {
  1231. +                               if (!door.equals(""))
  1232. +                                   System.out.println("TvTEventEngine[Config.load()]: invalid config property -> TvTEventDoorsCloseOpenOnStartEnd \"" + door + "\"");
  1233. +                           }
  1234. +                       }
  1235. +                   }
  1236. +               }
  1237. +           }
  1238. +       }
  1239. +      
  1240.     }
  1241.    
  1242.     /**
  1243. Index: java/net/sf/l2j/gameserver/GameServer.java
  1244. ===================================================================
  1245. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 89)
  1246. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  1247. @@ -72,6 +72,7 @@
  1248.  import net.sf.l2j.gameserver.handler.ItemHandler;
  1249.  import net.sf.l2j.gameserver.handler.SkillHandler;
  1250.  import net.sf.l2j.gameserver.handler.UserCommandHandler;
  1251. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  1252.  import net.sf.l2j.gameserver.idfactory.IdFactory;
  1253.  import net.sf.l2j.gameserver.instancemanager.AuctionManager;
  1254.  import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
  1255. @@ -96,6 +97,7 @@
  1256.  import net.sf.l2j.gameserver.instancemanager.games.MonsterRace;
  1257.  import net.sf.l2j.gameserver.model.World;
  1258.  import net.sf.l2j.gameserver.model.entity.Hero;
  1259. +import net.sf.l2j.gameserver.model.entity.TvTEventManager;
  1260.  import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  1261.  import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
  1262.  import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
  1263. @@ -283,7 +285,11 @@
  1264.         _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
  1265.         _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
  1266.         _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
  1267. -      
  1268. +       _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
  1269. +      
  1270. +        StringUtil.printSection("TvT Event");
  1271. +        TvTEventManager.getInstance();
  1272. +  
  1273.         StringUtil.printSection("System");
  1274.         Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  1275.         ForumsBBSManager.getInstance();
  1276. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java
  1277. ===================================================================
  1278. --- java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java   (revision 88)
  1279. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/HealPercent.java   (working copy)
  1280. @@ -14,6 +14,7 @@
  1281.   */
  1282.  package net.sf.l2j.gameserver.handler.skillhandlers;
  1283.  
  1284. +import net.sf.l2j.Config;
  1285.  import net.sf.l2j.gameserver.handler.ISkillHandler;
  1286.  import net.sf.l2j.gameserver.handler.SkillHandler;
  1287.  import net.sf.l2j.gameserver.model.L2Object;
  1288. @@ -75,7 +76,21 @@
  1289.             // Doors and flags can't be healed in any way
  1290.             if (target instanceof L2DoorInstance || target instanceof L2SiegeFlagInstance)
  1291.                 continue;
  1292. +          
  1293. +           // Mana potions can't be used on event
  1294. +           if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_POTIONS_ALLOWED)
  1295. +           {
  1296. +               if (skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT)
  1297. +                   continue;
  1298. +           }
  1299.            
  1300. +           // Players can't be healed on event
  1301. +           if (((L2PcInstance) activeChar).isInFunEvent() && !Config.TVT_EVENT_HEAL_PLAYERS)
  1302. +           {
  1303. +               if (skill.getSkillType() == L2SkillType.HEAL_PERCENT)
  1304. +                   continue;
  1305. +           }
  1306. +  
  1307.             targetPlayer = target instanceof L2PcInstance;
  1308.            
  1309.             // Cursed weapon owner can't heal or be healed
  1310. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java
  1311. ===================================================================
  1312. --- java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java  (nonexistent)
  1313. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java  (working copy)
  1314. @@ -0,0 +1,81 @@
  1315. +package net.sf.l2j.gameserver.model.actor.instance;
  1316. +
  1317. +import net.sf.l2j.Config;
  1318. +import net.sf.l2j.gameserver.cache.HtmCache;
  1319. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  1320. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  1321. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1322. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1323. +
  1324. +public class L2TvTEventNpcInstance extends L2NpcInstance
  1325. +{
  1326. +   public L2TvTEventNpcInstance(int objectId, NpcTemplate template)
  1327. +   {
  1328. +       super(objectId, template);
  1329. +   }
  1330. +  
  1331. +   @Override
  1332. +   public void onBypassFeedback(L2PcInstance playerInstance, String command)
  1333. +   {
  1334. +       TvTEvent.onBypass(command, playerInstance);
  1335. +   }
  1336. +  
  1337. +   @Override
  1338. +   public void showChatWindow(L2PcInstance playerInstance, int val)
  1339. +   {
  1340. +       if (playerInstance == null)
  1341. +           return;
  1342. +      
  1343. +       if (TvTEvent.isParticipating())
  1344. +       {
  1345. +           String htmFile = "data/html/mods/";
  1346. +          
  1347. +           if (!TvTEvent.isPlayerParticipant(playerInstance.getName()))
  1348. +               htmFile += "TvTEventParticipation";
  1349. +           else
  1350. +               htmFile += "TvTEventRemoveParticipation";
  1351. +          
  1352. +           htmFile += ".htm";
  1353. +          
  1354. +           String htmContent = HtmCache.getInstance().getHtm(htmFile);
  1355. +          
  1356. +           if (htmContent != null)
  1357. +           {
  1358. +               int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  1359. +               NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1360. +              
  1361. +               npcHtmlMessage.setHtml(htmContent);
  1362. +               npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1363. +               npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  1364. +               npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1365. +               npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  1366. +               npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1367. +               playerInstance.sendPacket(npcHtmlMessage);
  1368. +           }
  1369. +       }
  1370. +       else if (TvTEvent.isStarting() || TvTEvent.isStarted())
  1371. +       {
  1372. +           String htmFile = "data/html/mods/TvTEventStatus.htm";
  1373. +           String htmContent = HtmCache.getInstance().getHtm(htmFile);
  1374. +          
  1375. +           if (htmContent != null)
  1376. +           {
  1377. +               int[] teamsPlayerCounts = TvTEvent.getTeamsPlayerCounts();
  1378. +               int[] teamsPointsCounts = TvTEvent.getTeamsPoints();
  1379. +               NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1380. +              
  1381. +               npcHtmlMessage.setHtml(htmContent);
  1382. +               // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1383. +               npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  1384. +               npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1385. +               npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  1386. +               npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  1387. +               npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1388. +               npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  1389. +               playerInstance.sendPacket(npcHtmlMessage);
  1390. +           }
  1391. +       }
  1392. +      
  1393. +       playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
  1394. +   }
  1395. +}
  1396. \ No newline at end of file
  1397. Index: java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java
  1398. ===================================================================
  1399. --- java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java  (nonexistent)
  1400. +++ java/net/sf/l2j/gameserver/model/entity/TvTEventTeams.java  (working copy)
  1401. @@ -0,0 +1,209 @@
  1402. +/*
  1403. + * This program is free software: you can redistribute it and/or modify it under
  1404. + * the terms of the GNU General Public License as published by the Free Software
  1405. + * Foundation, either version 3 of the License, or (at your option) any later
  1406. + * version.
  1407. + *
  1408. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1409. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1410. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1411. + * details.
  1412. + *
  1413. + * You should have received a copy of the GNU General Public License along with
  1414. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1415. + */
  1416. +package net.sf.l2j.gameserver.model.entity;
  1417. +
  1418. +
  1419. +import java.util.HashMap;
  1420. +import java.util.Map;
  1421. +import java.util.Vector;
  1422. +
  1423. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1424. +
  1425. +/**
  1426. + * @author FBIagent
  1427. + */
  1428. +public class TvTEventTeams
  1429. +{
  1430. +   /**
  1431. +    * The name of the team<br>
  1432. +    */
  1433. +   private String _name;
  1434. +   /**
  1435. +    * The team spot coordinated<br>
  1436. +    */
  1437. +   private int[] _coordinates = new int[3];
  1438. +   /**
  1439. +    * The points of the team<br>
  1440. +    */
  1441. +   private short _points;
  1442. +   /**
  1443. +    * Name and instance of all participated players in FastMap<br>
  1444. +    */
  1445. +   private Map<String, L2PcInstance> _participatedPlayers = new HashMap<>();
  1446. +   /**
  1447. +    * Name of all participated players in Vector<br>
  1448. +    */
  1449. +   private Vector<String> _participatedPlayerNames = new Vector<>();
  1450. +  
  1451. +   /**
  1452. +    * C'tor initialize the team
  1453. +    * @param name
  1454. +    * @param coordinates
  1455. +    */
  1456. +   public TvTEventTeams(String name, int[] coordinates)
  1457. +   {
  1458. +       _name = name;
  1459. +       _coordinates = coordinates;
  1460. +       _points = 0;
  1461. +   }
  1462. +  
  1463. +   /**
  1464. +    * Adds a player to the team
  1465. +    * @param playerInstance
  1466. +    * @return boolean
  1467. +    */
  1468. +   public boolean addPlayer(L2PcInstance playerInstance)
  1469. +   {
  1470. +       if (playerInstance == null)
  1471. +           return false;
  1472. +      
  1473. +       synchronized (_participatedPlayers)
  1474. +       {
  1475. +           String playerName = playerInstance.getName();
  1476. +          
  1477. +           _participatedPlayers.put(playerName, playerInstance);
  1478. +          
  1479. +           if (!_participatedPlayerNames.contains(playerName))
  1480. +               _participatedPlayerNames.add(playerName);
  1481. +       }
  1482. +      
  1483. +       return true;
  1484. +   }
  1485. +  
  1486. +   /**
  1487. +    * Removes a player from the team
  1488. +    * @param playerName
  1489. +    */
  1490. +   public void removePlayer(String playerName)
  1491. +   {
  1492. +       synchronized (_participatedPlayers)
  1493. +       {
  1494. +           _participatedPlayers.remove(playerName);
  1495. +           _participatedPlayerNames.remove(playerName);
  1496. +       }
  1497. +   }
  1498. +  
  1499. +   /**
  1500. +    * Increases the points of the team<br>
  1501. +    */
  1502. +   public void increasePoints()
  1503. +   {
  1504. +       _points++;
  1505. +   }
  1506. +  
  1507. +   /**
  1508. +    * Cleanup the team and make it ready for adding players again<br>
  1509. +    */
  1510. +   public void cleanMe()
  1511. +   {
  1512. +       _participatedPlayers.clear();
  1513. +       _participatedPlayerNames.clear();
  1514. +       _participatedPlayers = new HashMap<>();
  1515. +       _participatedPlayerNames = new Vector<>();
  1516. +       _points = 0;
  1517. +   }
  1518. +  
  1519. +   /**
  1520. +    * Is given player in this team?
  1521. +    * @param playerName
  1522. +    * @return boolean
  1523. +    */
  1524. +   public boolean containsPlayer(String playerName)
  1525. +   {
  1526. +       boolean containsPlayer;
  1527. +      
  1528. +       synchronized (_participatedPlayers)
  1529. +       {
  1530. +           containsPlayer = _participatedPlayerNames.contains(playerName);
  1531. +       }
  1532. +      
  1533. +       return containsPlayer;
  1534. +   }
  1535. +  
  1536. +   /**
  1537. +    * Returns the name of the team
  1538. +    * @return String
  1539. +    */
  1540. +   public String getName()
  1541. +   {
  1542. +       return _name;
  1543. +   }
  1544. +  
  1545. +   /**
  1546. +    * Returns the coordinates of the team spot
  1547. +    * @return int[]
  1548. +    */
  1549. +   public int[] getCoordinates()
  1550. +   {
  1551. +       return _coordinates;
  1552. +   }
  1553. +  
  1554. +   /**
  1555. +    * Returns the points of the team
  1556. +    * @return short
  1557. +    */
  1558. +   public short getPoints()
  1559. +   {
  1560. +       return _points;
  1561. +   }
  1562. +  
  1563. +   /**
  1564. +    * Returns name and instance of all participated players in FastMap
  1565. +    * @return Map<String, L2PcInstance>
  1566. +    */
  1567. +   public Map<String, L2PcInstance> getParticipatedPlayers()
  1568. +   {
  1569. +       Map<String, L2PcInstance> participatedPlayers = null;
  1570. +      
  1571. +       synchronized (_participatedPlayers)
  1572. +       {
  1573. +           participatedPlayers = _participatedPlayers;
  1574. +       }
  1575. +      
  1576. +       return participatedPlayers;
  1577. +   }
  1578. +  
  1579. +   /**
  1580. +    * Returns name of all participated players in Vector
  1581. +    * @return Vector<String>
  1582. +    */
  1583. +   public Vector<String> getParticipatedPlayerNames()
  1584. +   {
  1585. +       Vector<String> participatedPlayerNames = null;
  1586. +      
  1587. +       synchronized (_participatedPlayers)
  1588. +       {
  1589. +           participatedPlayerNames = _participatedPlayerNames;
  1590. +       }
  1591. +      
  1592. +       return participatedPlayerNames;
  1593. +   }
  1594. +  
  1595. +   /**
  1596. +    * Returns player count of this team
  1597. +    * @return int
  1598. +    */
  1599. +   public int getParticipatedPlayerCount()
  1600. +   {
  1601. +       int participatedPlayerCount;
  1602. +      
  1603. +       synchronized (_participatedPlayers)
  1604. +       {
  1605. +           participatedPlayerCount = _participatedPlayers.size();
  1606. +       }
  1607. +      
  1608. +       return participatedPlayerCount;
  1609. +   }
  1610. +}
  1611. \ No newline at end of file
  1612. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  1613. ===================================================================
  1614. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java    (revision 88)
  1615. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java    (working copy)
  1616. @@ -16,6 +16,7 @@
  1617.  
  1618.  import net.sf.l2j.gameserver.instancemanager.SevenSignsFestival;
  1619.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1620. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  1621.  import net.sf.l2j.gameserver.model.zone.ZoneId;
  1622.  import net.sf.l2j.gameserver.network.SystemMessageId;
  1623.  import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1624. @@ -48,7 +49,13 @@
  1625.             player.sendPacket(ActionFailed.STATIC_PACKET);
  1626.             return;
  1627.         }
  1628. -      
  1629. +      
  1630. +       if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getName()))
  1631. +       {
  1632. +           player.sendMessage("You can not leave the game while attending an event.");
  1633. +           return;
  1634. +       }
  1635. +  
  1636.         if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
  1637.         {
  1638.             player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
  1639. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  1640. ===================================================================
  1641. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java  (revision 89)
  1642. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java  (working copy)
  1643. @@ -32,7 +32,7 @@
  1644.     @Override
  1645.     public boolean useUserCommand(int id, L2PcInstance activeChar)
  1646.     {
  1647. -       if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null)
  1648. +       if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || ZoneManager.getInstance().getZone(activeChar, L2BossZone.class) != null || activeChar.isInFunEvent())
  1649.         {
  1650.             activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
  1651.             return false;
  1652. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  1653. ===================================================================
  1654. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 89)
  1655. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  1656. @@ -126,6 +126,7 @@
  1657.  import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  1658.  import net.sf.l2j.gameserver.model.entity.Hero;
  1659.  import net.sf.l2j.gameserver.model.entity.Siege;
  1660. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  1661.  import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  1662.  import net.sf.l2j.gameserver.model.holder.SkillUseHolder;
  1663.  import net.sf.l2j.gameserver.model.item.Henna;
  1664. @@ -388,6 +389,7 @@
  1665.     private PcAppearance _appearance;
  1666.    
  1667.     private long _expBeforeDeath;
  1668. +   public int _tvtkills;
  1669.     private int _karma;
  1670.     private int _pvpKills;
  1671.     private int _pkKills;
  1672. @@ -398,6 +400,7 @@
  1673.     private int _lastCompassZone; // the last compass zone update send to the client
  1674.    
  1675.     private boolean _isIn7sDungeon;
  1676. +   public boolean atEvent = false;
  1677.    
  1678.     private PunishLevel _punishLevel = PunishLevel.NONE;
  1679.     private long _punishTimer;
  1680. @@ -3186,6 +3189,11 @@
  1681.     @Override
  1682.     public void onAction(L2PcInstance player)
  1683.     {
  1684. +       if (!TvTEvent.onAction(player.getName(), getName()))
  1685. +       {
  1686. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  1687. +           return;
  1688. +       }
  1689.         // Set the target of the player
  1690.         if (player.getTarget() != this)
  1691.             player.setTarget(this);
  1692. @@ -3943,6 +3951,8 @@
  1693.         if (isMounted())
  1694.             stopFeed();
  1695.        
  1696. +       _tvtkills = 0;
  1697. +      
  1698.         synchronized (this)
  1699.         {
  1700.             if (isFakeDeath())
  1701. @@ -3949,6 +3959,8 @@
  1702.                 stopFakeDeath(true);
  1703.         }
  1704.        
  1705. +       TvTEvent.onKill(killer, this);
  1706. +      
  1707.         if (killer != null)
  1708.         {
  1709.             L2PcInstance pk = killer.getActingPlayer();
  1710. @@ -10607,4 +10619,9 @@
  1711.             }
  1712.         }
  1713.     }
  1714. +  
  1715. +   public boolean isInFunEvent()
  1716. +   {
  1717. +       return (atEvent || (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getName())) && !isGM());
  1718. +   }
  1719.  }
  1720. \ No newline at end of file
  1721. Index: java/net/sf/l2j/gameserver/model/entity/TvTEvent.java
  1722. ===================================================================
  1723. --- java/net/sf/l2j/gameserver/model/entity/TvTEvent.java   (nonexistent)
  1724. +++ java/net/sf/l2j/gameserver/model/entity/TvTEvent.java   (working copy)
  1725. @@ -0,0 +1,757 @@
  1726. +/* This program is free software: you can redistribute it and/or modify it under
  1727. + * the terms of the GNU General Public License as published by the Free Software
  1728. + * Foundation, either version 3 of the License, or (at your option) any later
  1729. + * version.
  1730. + *
  1731. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1732. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1733. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1734. + * details.
  1735. + *
  1736. + * You should have received a copy of the GNU General Public License along with
  1737. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1738. + */
  1739. +package net.sf.l2j.gameserver.model.entity;
  1740. +
  1741. +import net.sf.l2j.commons.random.Rnd;
  1742. +
  1743. +import net.sf.l2j.Config;
  1744. +import net.sf.l2j.gameserver.datatables.DoorTable;
  1745. +import net.sf.l2j.gameserver.datatables.ItemTable;
  1746. +import net.sf.l2j.gameserver.datatables.NpcTable;
  1747. +import net.sf.l2j.gameserver.datatables.SkillTable;
  1748. +import net.sf.l2j.gameserver.datatables.SpawnTable;
  1749. +import net.sf.l2j.gameserver.model.L2Skill;
  1750. +import net.sf.l2j.gameserver.model.L2Spawn;
  1751. +import net.sf.l2j.gameserver.model.World;
  1752. +import net.sf.l2j.gameserver.model.actor.L2Character;
  1753. +import net.sf.l2j.gameserver.model.actor.L2Npc;
  1754. +import net.sf.l2j.gameserver.model.actor.L2Summon;
  1755. +import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;
  1756. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1757. +import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  1758. +import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
  1759. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  1760. +import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
  1761. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  1762. +import net.sf.l2j.gameserver.network.SystemMessageId;
  1763. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  1764. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  1765. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  1766. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1767. +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  1768. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  1769. +
  1770. +/**
  1771. + * @author Baggos
  1772. + */
  1773. +public class TvTEvent
  1774. +{
  1775. +   enum EventState
  1776. +   {
  1777. +       INACTIVE,
  1778. +       INACTIVATING,
  1779. +       PARTICIPATING,
  1780. +       STARTING,
  1781. +       STARTED,
  1782. +       REWARDING
  1783. +   }
  1784. +  
  1785. +   /** Gives Noblesse to players */
  1786. +   static L2Skill noblesse = SkillTable.getInstance().getInfo(1323, 1);
  1787. +   /**
  1788. +    * The teams of the TvTEvent<br>
  1789. +    */
  1790. +   public static TvTEventTeams[] _teams = new TvTEventTeams[2]; // event only allow max 2 teams
  1791. +   /**
  1792. +    * The state of the TvTEvent<br>
  1793. +    */
  1794. +   public static EventState _state = EventState.INACTIVE;
  1795. +  
  1796. +   /**
  1797. +    * No instance of this class!<br>
  1798. +    */
  1799. +   private TvTEvent()
  1800. +   {
  1801. +   }
  1802. +  
  1803. +   /**
  1804. +    * Teams initializing<br>
  1805. +    */
  1806. +   public static void init()
  1807. +   {
  1808. +       _teams[0] = new TvTEventTeams(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
  1809. +       _teams[1] = new TvTEventTeams(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
  1810. +   }
  1811. +  
  1812. +   /**
  1813. +    * Starts the participation of the TvTEvent<br>
  1814. +    * 1. Get NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
  1815. +    * 2. Try to spawn a new npc of it<br>
  1816. +    * <br>
  1817. +    * @return boolean<br>
  1818. +    */
  1819. +   public static boolean startParticipation()
  1820. +   {
  1821. +       final int npcc = Config.TVT_EVENT_PARTICIPATION_TIME * 1000 * 60;
  1822. +       try
  1823. +       {
  1824. +           final NpcTemplate template = NpcTable.getInstance().getTemplate(Config.TVT_EVENT_PARTICIPATION_NPC_ID);
  1825. +           final L2Spawn spawn = new L2Spawn(template);
  1826. +           spawn.setLoc(Config.TVT_EVENT_BACK_COORDINATES[0], Config.TVT_EVENT_BACK_COORDINATES[1], Config.TVT_EVENT_BACK_COORDINATES[2], 0);
  1827. +          
  1828. +           SpawnTable.getInstance().addNewSpawn(spawn, false);
  1829. +           final L2Npc npc = spawn.doSpawn(true);
  1830. +           npc.scheduleDespawn(npcc);
  1831. +           npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1));
  1832. +       }
  1833. +       catch (Exception e)
  1834. +       {
  1835. +           System.out.println("TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e);
  1836. +           return false;
  1837. +       }
  1838. +       setState(EventState.PARTICIPATING);
  1839. +       return true;
  1840. +   }
  1841. +   /**
  1842. +    * Starts the TvTEvent fight<br>
  1843. +    * 1. Set state EventState.STARTING<br>
  1844. +    * 2. Close doors specified in configs<br>
  1845. +    * 3. Abort if not enought participants(return false)<br>
  1846. +    * 4. Set state EventState.STARTED<br>
  1847. +    * 5. Teleport all participants to team spot<br>
  1848. +    * <br>
  1849. +    * @return boolean<br>
  1850. +    */
  1851. +   public static boolean startFight()
  1852. +   {
  1853. +       setState(EventState.STARTING);
  1854. +      
  1855. +       // not enought participants
  1856. +       if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
  1857. +       {
  1858. +           setState(EventState.INACTIVE);
  1859. +           _teams[0].cleanMe();
  1860. +           _teams[1].cleanMe();
  1861. +           return false;
  1862. +       }
  1863. +      
  1864. +       closeDoors();
  1865. +       setState(EventState.STARTED); // set state to STARTED here, so TvTEventTeleporter know to teleport to team spot
  1866. +      
  1867. +       // teleport all participants to there team spot
  1868. +       for (TvTEventTeams team : _teams)
  1869. +       {
  1870. +           for (String playerName : team.getParticipatedPlayerNames())
  1871. +           {
  1872. +               L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
  1873. +              
  1874. +               if (playerInstance == null)
  1875. +                   continue;
  1876. +              
  1877. +               // leave party
  1878. +               playerInstance.leaveParty();
  1879. +              
  1880. +               // Get Noblesse effect
  1881. +               noblesse.getEffects(playerInstance, playerInstance);
  1882. +              
  1883. +               // implements Runnable and starts itself in constructor
  1884. +               new TvTEventTeleport(playerInstance, team.getCoordinates(), false, false);
  1885. +           }
  1886. +       }
  1887. +      
  1888. +       return true;
  1889. +   }
  1890. +  
  1891. +   /**
  1892. +    * Calculates the TvTEvent reward<br>
  1893. +    * 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>
  1894. +    * 2. Wait till teams are not at a tie anymore<br>
  1895. +    * 3. Set state EvcentState.REWARDING<br>
  1896. +    * 4. Reward team with more points<br>
  1897. +    * 5. Show win html to wining team participants<br>
  1898. +    * <br>
  1899. +    * @return String<br>
  1900. +    */
  1901. +   public static String calculateRewards()
  1902. +   {
  1903. +       if (_teams[0].getPoints() == _teams[1].getPoints())
  1904. +       {
  1905. +           if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
  1906. +           {
  1907. +               // the fight cannot be completed
  1908. +               setState(EventState.REWARDING);
  1909. +               return "TvT Event: Event finish. No team won, cause of inactivity!";
  1910. +           }
  1911. +          
  1912. +           sysMsgToAllParticipants("TvT Event: Both teams are at a tie, next team to get a kill wins!");
  1913. +       }
  1914. +      
  1915. +       while (_teams[0].getPoints() == _teams[1].getPoints())
  1916. +       {
  1917. +           waiter(1);
  1918. +       }
  1919. +      
  1920. +       setState(EventState.REWARDING); // after state REWARDING is set, nobody can point anymore
  1921. +      
  1922. +       byte teamId = (byte) (_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
  1923. +       TvTEventTeams team = _teams[teamId];
  1924. +      
  1925. +       for (String playerName : team.getParticipatedPlayerNames())
  1926. +       {
  1927. +           for (int[] reward : Config.TVT_EVENT_REWARDS)
  1928. +           {
  1929. +               if (team.getParticipatedPlayers().get(playerName) == null)
  1930. +                   continue;
  1931. +              
  1932. +               PcInventory inv = team.getParticipatedPlayers().get(playerName).getInventory();
  1933. +              
  1934. +               if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
  1935. +                   inv.addItem("TvT Event", reward[0], reward[1], team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
  1936. +               else
  1937. +               {
  1938. +                   for (int i = 0; i < reward[1]; i++)
  1939. +                       inv.addItem("TvT Event", reward[0], 1, team.getParticipatedPlayers().get(playerName), team.getParticipatedPlayers().get(playerName));
  1940. +               }
  1941. +              
  1942. +               SystemMessage systemMessage = null;
  1943. +              
  1944. +               if (reward[1] > 1)
  1945. +               {
  1946. +                   systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  1947. +                   systemMessage.addItemName(reward[0]);
  1948. +                   systemMessage.addNumber(reward[1]);
  1949. +               }
  1950. +               else
  1951. +               {
  1952. +                   systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  1953. +                   systemMessage.addItemName(reward[0]);
  1954. +               }
  1955. +              
  1956. +               team.getParticipatedPlayers().get(playerName).sendPacket(systemMessage);
  1957. +           }
  1958. +          
  1959. +           StatusUpdate statusUpdate = new StatusUpdate(team.getParticipatedPlayers().get(playerName));
  1960. +          
  1961. +           statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, team.getParticipatedPlayers().get(playerName).getCurrentLoad());
  1962. +           team.getParticipatedPlayers().get(playerName).sendPacket(statusUpdate);
  1963. +          
  1964. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1965. +          
  1966. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Your team won the event. Look in your inventory, there should be your reward.</body></html>");
  1967. +           team.getParticipatedPlayers().get(playerName).sendPacket(npcHtmlMessage);
  1968. +       }
  1969. +      
  1970. +       return "TvT Event: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
  1971. +   }
  1972. +  
  1973. +   /**
  1974. +    * Stops the TvTEvent fight<br>
  1975. +    * 1. Set state EventState.INACTIVATING<br>
  1976. +    * 2. Remove tvt npc from world<br>
  1977. +    * 3. Open doors specified in configs<br>
  1978. +    * 4. Teleport all participants back to participation npc location<br>
  1979. +    * 5. Teams cleaning<br>
  1980. +    * 6. Set state EventState.INACTIVE<br>
  1981. +    */
  1982. +   public static void stopFight()
  1983. +   {
  1984. +       setState(EventState.INACTIVATING);
  1985. +       openDoors();
  1986. +      
  1987. +       for (TvTEventTeams team : _teams)
  1988. +       {
  1989. +           for (String playerName : team.getParticipatedPlayerNames())
  1990. +           {
  1991. +               L2PcInstance playerInstance = team.getParticipatedPlayers().get(playerName);
  1992. +              
  1993. +               if (playerInstance == null)
  1994. +                   continue;
  1995. +              
  1996. +               new TvTEventTeleport(playerInstance, Config.TVT_EVENT_BACK_COORDINATES, false, false);
  1997. +           }
  1998. +       }
  1999. +      
  2000. +       _teams[0].cleanMe();
  2001. +       _teams[1].cleanMe();
  2002. +      
  2003. +       setState(EventState.INACTIVE);
  2004. +      
  2005. +   }
  2006. +  
  2007. +   /**
  2008. +    * Adds a player to a TvTEvent team<br>
  2009. +    * 1. Calculate the id of the team in which the player should be added<br>
  2010. +    * 2. Add the player to the calculated team
  2011. +    * @param playerInstance
  2012. +    * @return boolean
  2013. +    */
  2014. +   public static synchronized boolean addParticipant(L2PcInstance playerInstance)
  2015. +   {
  2016. +       if (playerInstance == null)
  2017. +           return false;
  2018. +      
  2019. +       byte teamId = 0;
  2020. +      
  2021. +       if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
  2022. +           teamId = (byte) (Rnd.get(2));
  2023. +       else
  2024. +           teamId = (byte) (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
  2025. +      
  2026. +       return _teams[teamId].addPlayer(playerInstance);
  2027. +   }
  2028. +  
  2029. +   /**
  2030. +    * Removes a TvTEvent player from it's team<br>
  2031. +    * 1. Get team id of the player<br>
  2032. +    * 2. Remove player from it's team
  2033. +    * @param playerName
  2034. +    * @return boolean
  2035. +    */
  2036. +   public static boolean removeParticipant(String playerName)
  2037. +   {
  2038. +       byte teamId = getParticipantTeamId(playerName);
  2039. +      
  2040. +       if (teamId == -1)
  2041. +           return false;
  2042. +      
  2043. +       _teams[teamId].removePlayer(playerName);
  2044. +       return true;
  2045. +   }
  2046. +  
  2047. +   /**
  2048. +    * Send a SystemMessage to all participated players<br>
  2049. +    * 1. Send the message to all players of team number one<br>
  2050. +    * 2. Send the message to all players of team number two
  2051. +    * @param message
  2052. +    */
  2053. +   public static void sysMsgToAllParticipants(String message)
  2054. +   {
  2055. +       for (L2PcInstance playerInstance : _teams[0].getParticipatedPlayers().values())
  2056. +       {
  2057. +           if (playerInstance != null)
  2058. +               playerInstance.sendMessage(message);
  2059. +       }
  2060. +      
  2061. +       for (L2PcInstance playerInstance : _teams[1].getParticipatedPlayers().values())
  2062. +       {
  2063. +           if (playerInstance != null)
  2064. +               playerInstance.sendMessage(message);
  2065. +       }
  2066. +   }
  2067. +  
  2068. +   /**
  2069. +    * Close doors specified in configs
  2070. +    */
  2071. +   public static void closeDoors()
  2072. +   {
  2073. +       for (int doorId : Config.TVT_EVENT_DOOR_IDS)
  2074. +       {
  2075. +           L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
  2076. +          
  2077. +           if (doorInstance != null)
  2078. +               doorInstance.closeMe();
  2079. +       }
  2080. +   }
  2081. +  
  2082. +   /**
  2083. +    * Open doors specified in configs
  2084. +    */
  2085. +   public static void openDoors()
  2086. +   {
  2087. +       for (int doorId : Config.TVT_EVENT_DOOR_IDS)
  2088. +       {
  2089. +           L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
  2090. +          
  2091. +           if (doorInstance != null)
  2092. +               doorInstance.openMe();
  2093. +       }
  2094. +   }
  2095. +  
  2096. +   public static void waiter(int seconds)
  2097. +   {
  2098. +       try
  2099. +       {
  2100. +           Thread.sleep(seconds * 1000);
  2101. +       }
  2102. +       catch (InterruptedException e)
  2103. +       {
  2104. +       }
  2105. +   }
  2106. +  
  2107. +   /**
  2108. +    * Called when a player logs in
  2109. +    * @param playerInstance
  2110. +    * @param player
  2111. +    */
  2112. +   public static void onLogin(L2PcInstance playerInstance, L2PcInstance player)
  2113. +   {
  2114. +       if (playerInstance == null || (!isStarting() && !isStarted()))
  2115. +           return;
  2116. +      
  2117. +       byte teamId = getParticipantTeamId(playerInstance.getName());
  2118. +      
  2119. +       if (teamId == -1)
  2120. +           return;
  2121. +      
  2122. +       _teams[teamId].addPlayer(playerInstance);
  2123. +       new TvTEventTeleport(playerInstance, _teams[teamId].getCoordinates(), true, false);
  2124. +   }
  2125. +  
  2126. +   /**
  2127. +    * Called when a player logs out
  2128. +    * @param playerInstance
  2129. +    * @param player
  2130. +    */
  2131. +   public static void onLogout(L2PcInstance playerInstance, L2PcInstance player)
  2132. +   {
  2133. +       if (playerInstance == null || (!isStarting() && !isStarted()))
  2134. +           return;
  2135. +      
  2136. +       removeParticipant(playerInstance.getName());
  2137. +   }
  2138. +  
  2139. +   /**
  2140. +    * Called on every bypass by npc of type L2TvTEventNpc<br>
  2141. +    * Needs synchronization cause of the max player check
  2142. +    * @param command
  2143. +    * @param playerInstance
  2144. +    */
  2145. +   public static synchronized void onBypass(String command, L2PcInstance playerInstance)
  2146. +   {
  2147. +       if (playerInstance == null || !isParticipating())
  2148. +           return;
  2149. +      
  2150. +       if (command.equals("tvt_event_participation"))
  2151. +       {
  2152. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  2153. +           int playerLevel = playerInstance.getLevel();
  2154. +          
  2155. +           if (playerInstance.isCursedWeaponEquipped())
  2156. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
  2157. +           else if (OlympiadManager.getInstance().isRegisteredInComp(playerInstance))
  2158. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Olympiad participants can't register.</body></html>");
  2159. +           else if (playerInstance.getKarma() > 0)
  2160. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
  2161. +           else if (_teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  2162. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Sorry the event is full!</body></html>");
  2163. +           else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  2164. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
  2165. +           else if (_teams[0].getParticipatedPlayerCount() > 19 && _teams[1].getParticipatedPlayerCount() > 19)
  2166. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + "  player are allowed in one team.</body></html>");
  2167. +           else if (addParticipant(playerInstance))
  2168. +               npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  2169. +           else
  2170. +               // addParticipant returned false cause playerInstance == null
  2171. +               return;
  2172. +          
  2173. +           playerInstance.sendPacket(npcHtmlMessage);
  2174. +       }
  2175. +       else if (command.equals("tvt_event_remove_participation"))
  2176. +       {
  2177. +           removeParticipant(playerInstance.getName());
  2178. +          
  2179. +           NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  2180. +          
  2181. +           npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  2182. +           playerInstance.sendPacket(npcHtmlMessage);
  2183. +       }
  2184. +   }
  2185. +  
  2186. +   /**
  2187. +    * Called on every onAction in L2PcIstance
  2188. +    * @param playerName
  2189. +    * @param targetPlayerName
  2190. +    * @return boolean
  2191. +    */
  2192. +   public static boolean onAction(String playerName, String targetPlayerName)
  2193. +   {
  2194. +       if (!isStarted())
  2195. +           return true;
  2196. +      
  2197. +       L2PcInstance playerInstance = World.getInstance().getPlayer(playerName);
  2198. +      
  2199. +       if (playerInstance == null)
  2200. +           return false;
  2201. +      
  2202. +       if (playerInstance.isGM())
  2203. +           return true;
  2204. +      
  2205. +       byte playerTeamId = getParticipantTeamId(playerName);
  2206. +       byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
  2207. +      
  2208. +       if ((playerTeamId != -1 && targetPlayerTeamId == -1) || (playerTeamId == -1 && targetPlayerTeamId != -1))
  2209. +           return false;
  2210. +      
  2211. +       if (playerTeamId != -1 && targetPlayerTeamId != -1 && playerTeamId == targetPlayerTeamId && !Config.TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED)
  2212. +           return false;
  2213. +      
  2214. +       return true;
  2215. +   }
  2216. +  
  2217. +   /**
  2218. +    * Called on every summon item use
  2219. +    * @param playerName
  2220. +    * @return boolean
  2221. +    */
  2222. +   public static boolean onItemSummon(String playerName)
  2223. +   {
  2224. +       if (!isStarted())
  2225. +           return true;
  2226. +      
  2227. +       if (isPlayerParticipant(playerName) && !Config.TVT_EVENT_SUMMON_BY_ITEM_ALLOWED)
  2228. +           return false;
  2229. +      
  2230. +       return true;
  2231. +   }
  2232. +  
  2233. +   /**
  2234. +    * Is called when a player is killed
  2235. +    * @param killerCharacter
  2236. +    * @param killedPlayerInstance
  2237. +    */
  2238. +   public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
  2239. +   {
  2240. +       if (killerCharacter == null || killedPlayerInstance == null || (!(killerCharacter instanceof L2PcInstance) && !(killerCharacter instanceof L2PetInstance) && !(killerCharacter instanceof L2SummonInstance)) || !isStarted())
  2241. +           return;
  2242. +      
  2243. +       L2PcInstance killerPlayerInstance = null;
  2244. +      
  2245. +       if (killerCharacter instanceof L2PetInstance || killerCharacter instanceof L2SummonInstance)
  2246. +       {
  2247. +           killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
  2248. +          
  2249. +           if (killerPlayerInstance == null)
  2250. +               return;
  2251. +       }
  2252. +       else
  2253. +           killerPlayerInstance = (L2PcInstance) killerCharacter;
  2254. +      
  2255. +       if (Config.TVT_KILLS_REWARD_ENABLED)
  2256. +           for (int[] rewardKills : Config.TVT_KILLS_REWARD)
  2257. +           {
  2258. +               SystemMessage systemMessage = null;
  2259. +               // Count the kill
  2260. +               killerPlayerInstance._tvtkills++;
  2261. +               switch (killerPlayerInstance._tvtkills)
  2262. +               {
  2263. +                   case 5: // Reward after 5 kills without die
  2264. +                   case 8: // Reward after 8 kills without die
  2265. +                   case 12: // Reward after 12 kills without die
  2266. +                   case 15: // Reward after 15 kills without die
  2267. +                   case 20: // Reward after 20 kills without die
  2268. +                      
  2269. +                       systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  2270. +                       systemMessage.addItemName(rewardKills[0]);
  2271. +                       systemMessage.addNumber(rewardKills[1]);
  2272. +                      
  2273. +                       killerPlayerInstance.getInventory().addItem("TvT Event", rewardKills[0], rewardKills[1], killerPlayerInstance, killerPlayerInstance);
  2274. +                       killerPlayerInstance.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Amazing", +killerPlayerInstance._tvtkills + " kills without die. You has been rewarded!"));
  2275. +                       killerPlayerInstance.sendPacket(systemMessage);
  2276. +                       break;
  2277. +               }
  2278. +           }
  2279. +      
  2280. +       String playerName = killerPlayerInstance.getName();
  2281. +       byte killerTeamId = getParticipantTeamId(playerName);
  2282. +      
  2283. +       playerName = killedPlayerInstance.getName();
  2284. +      
  2285. +       byte killedTeamId = getParticipantTeamId(playerName);
  2286. +      
  2287. +       if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
  2288. +           _teams[killerTeamId].increasePoints();
  2289. +      
  2290. +       if (killedTeamId != -1)
  2291. +           new TvTEventTeleport(killedPlayerInstance, _teams[killedTeamId].getCoordinates(), false, false);
  2292. +   }
  2293. +  
  2294. +   /**
  2295. +    * Sets the TvTEvent state
  2296. +    * @param state
  2297. +    */
  2298. +   private static void setState(EventState state)
  2299. +   {
  2300. +       synchronized (_state)
  2301. +       {
  2302. +           _state = state;
  2303. +       }
  2304. +   }
  2305. +  
  2306. +   /**
  2307. +    * Is TvTEvent inactive?
  2308. +    * @return boolean
  2309. +    */
  2310. +   public static boolean isInactive()
  2311. +   {
  2312. +       boolean isInactive;
  2313. +      
  2314. +       synchronized (_state)
  2315. +       {
  2316. +           isInactive = _state == EventState.INACTIVE;
  2317. +       }
  2318. +      
  2319. +       return isInactive;
  2320. +   }
  2321. +  
  2322. +   /**
  2323. +    * Is TvTEvent in inactivating?
  2324. +    * @return boolean
  2325. +    */
  2326. +   public static boolean isInactivating()
  2327. +   {
  2328. +       boolean isInactivating;
  2329. +      
  2330. +       synchronized (_state)
  2331. +       {
  2332. +           isInactivating = _state == EventState.INACTIVATING;
  2333. +       }
  2334. +      
  2335. +       return isInactivating;
  2336. +   }
  2337. +  
  2338. +   /**
  2339. +    * Is TvTEvent in participation?
  2340. +    * @return boolean
  2341. +    */
  2342. +   public static boolean isParticipating()
  2343. +   {
  2344. +       boolean isParticipating;
  2345. +      
  2346. +       synchronized (_state)
  2347. +       {
  2348. +           isParticipating = _state == EventState.PARTICIPATING;
  2349. +       }
  2350. +      
  2351. +       return isParticipating;
  2352. +   }
  2353. +  
  2354. +   /**
  2355. +    * Is TvTEvent starting?
  2356. +    * @return boolean
  2357. +    */
  2358. +   public static boolean isStarting()
  2359. +   {
  2360. +       boolean isStarting;
  2361. +      
  2362. +       synchronized (_state)
  2363. +       {
  2364. +           isStarting = _state == EventState.STARTING;
  2365. +       }
  2366. +      
  2367. +       return isStarting;
  2368. +   }
  2369. +  
  2370. +   /**
  2371. +    * Is TvTEvent started?
  2372. +    * @return boolean
  2373. +    */
  2374. +   public static boolean isStarted()
  2375. +   {
  2376. +       boolean isStarted;
  2377. +      
  2378. +       synchronized (_state)
  2379. +       {
  2380. +           isStarted = _state == EventState.STARTED;
  2381. +       }
  2382. +      
  2383. +       return isStarted;
  2384. +   }
  2385. +  
  2386. +   /**
  2387. +    * Is TvTEvent rewarding?
  2388. +    * @return boolean
  2389. +    */
  2390. +   public static boolean isRewarding()
  2391. +   {
  2392. +       boolean isRewarding;
  2393. +      
  2394. +       synchronized (_state)
  2395. +       {
  2396. +           isRewarding = _state == EventState.REWARDING;
  2397. +       }
  2398. +      
  2399. +       return isRewarding;
  2400. +   }
  2401. +  
  2402. +   /**
  2403. +    * Returns the team id of a player, if player is not participant it returns -1
  2404. +    * @param playerName
  2405. +    * @return byte
  2406. +    */
  2407. +   public static byte getParticipantTeamId(String playerName)
  2408. +   {
  2409. +       return (byte) (_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
  2410. +   }
  2411. +  
  2412. +   /**
  2413. +    * Returns the team coordinates in which the player is in, if player is not in a team return null
  2414. +    * @param playerName
  2415. +    * @return int[]
  2416. +    */
  2417. +   public static int[] getParticipantTeamCoordinates(String playerName)
  2418. +   {
  2419. +       return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
  2420. +   }
  2421. +  
  2422. +   /**
  2423. +    * Is given player participant of the event?
  2424. +    * @param playerName
  2425. +    * @return boolean
  2426. +    */
  2427. +   public static boolean isPlayerParticipant(String playerName)
  2428. +   {
  2429. +       return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
  2430. +   }
  2431. +  
  2432. +   /**
  2433. +    * Returns participated player count<br>
  2434. +    * <br>
  2435. +    * @return int<br>
  2436. +    */
  2437. +   public static int getParticipatedPlayersCount()
  2438. +   {
  2439. +       return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
  2440. +   }
  2441. +  
  2442. +   /**
  2443. +    * Returns teams names<br>
  2444. +    * <br>
  2445. +    * @return String[]<br>
  2446. +    */
  2447. +   public static String[] getTeamNames()
  2448. +   {
  2449. +       return new String[]
  2450. +       {
  2451. +           _teams[0].getName(),
  2452. +           _teams[1].getName()
  2453. +       };
  2454. +   }
  2455. +  
  2456. +   /**
  2457. +    * Returns player count of both teams<br>
  2458. +    * <br>
  2459. +    * @return int[]<br>
  2460. +    */
  2461. +   public static int[] getTeamsPlayerCounts()
  2462. +   {
  2463. +       return new int[]
  2464. +       {
  2465. +           _teams[0].getParticipatedPlayerCount(),
  2466. +           _teams[1].getParticipatedPlayerCount()
  2467. +       };
  2468. +   }
  2469. +  
  2470. +   /**
  2471. +    * Returns points count of both teams
  2472. +    * @return int[]
  2473. +    */
  2474. +   public static int[] getTeamsPoints()
  2475. +   {
  2476. +       return new int[]
  2477. +       {
  2478. +           _teams[0].getPoints(),
  2479. +           _teams[1].getPoints()
  2480. +       };
  2481. +   }
  2482. +}
  2483. \ No newline at end of file
  2484. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java
  2485. ===================================================================
  2486. --- java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java  (revision 88)
  2487. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java  (working copy)
  2488. @@ -22,6 +22,7 @@
  2489.  import net.sf.l2j.gameserver.datatables.MultisellData;
  2490.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  2491.  import net.sf.l2j.gameserver.model.entity.Hero;
  2492. +import net.sf.l2j.gameserver.model.entity.TvTEvent;
  2493.  import net.sf.l2j.gameserver.model.olympiad.CompetitionType;
  2494.  import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  2495.  import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
  2496. @@ -191,6 +192,12 @@
  2497.         }
  2498.         else if (command.startsWith("Olympiad"))
  2499.         {
  2500. +           if (TvTEvent.isParticipating())
  2501. +           {
  2502. +               player.sendMessage("You can't do that while in a event");
  2503. +               return;
  2504. +           }
  2505. +          
  2506.             int val = Integer.parseInt(command.substring(9, 10));
  2507.            
  2508.             final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  2509. @@ -228,6 +235,12 @@
  2510.                 case 3: // Spectator overview
  2511.                     html.setFile(Olympiad.OLYMPIAD_HTML_PATH + "olympiad_observe_list.htm");
  2512.                    
  2513. +                   if (TvTEvent.isParticipating() || TvTEvent.isStarting() || TvTEvent.isStarted())
  2514. +                   {
  2515. +                       player.sendMessage("You can't do that while in a event");
  2516. +                       return;
  2517. +                   }      
  2518. +                              
  2519.                     int i = 0;
  2520.                    
  2521.                     final StringBuilder sb = new StringBuilder(2000);
  2522. #P aCis_datapack
  2523. Index: data/xml/npcs/70000-70099.xml
  2524. ===================================================================
  2525. --- data/xml/npcs/70000-70099.xml   (nonexistent)
  2526. +++ data/xml/npcs/70000-70099.xml   (working copy)
  2527. @@ -0,0 +1,39 @@
  2528. +<?xml version="1.0" encoding="utf-8"?>
  2529. +<list>
  2530. +<npc id="70010" idTemplate="31280" name="Sir Bastian" title="Event Manager">
  2531. +<set name="level" val="70"/>
  2532. +<set name="radius" val="8"/>
  2533. +<set name="height" val="23"/>
  2534. +<set name="rHand" val="0"/>
  2535. +<set name="lHand" val="0"/>
  2536. +<set name="type" val="L2TvTEventNpc"/>
  2537. +<set name="exp" val="0"/>
  2538. +<set name="sp" val="0"/>
  2539. +<set name="hp" val="2444.46819"/>
  2540. +<set name="mp" val="1345.8"/>
  2541. +<set name="hpRegen" val="7.5"/>
  2542. +<set name="mpRegen" val="2.7"/>
  2543. +<set name="pAtk" val="688.86373"/>
  2544. +<set name="pDef" val="295.91597"/>
  2545. +<set name="mAtk" val="470.40463"/>
  2546. +<set name="mDef" val="216.53847"/>
  2547. +<set name="crit" val="4"/>
  2548. +<set name="atkSpd" val="253"/>
  2549. +<set name="str" val="40"/>
  2550. +<set name="int" val="21"/>
  2551. +<set name="dex" val="30"/>
  2552. +<set name="wit" val="20"/>
  2553. +<set name="con" val="43"/>
  2554. +<set name="men" val="20"/>
  2555. +<set name="corpseTime" val="7"/>
  2556. +<set name="walkSpd" val="50"/>
  2557. +<set name="runSpd" val="120"/>
  2558. +<set name="dropHerbGroup" val="0"/>
  2559. +<set name="attackRange" val="40"/>
  2560. +<ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
  2561. +<skills>
  2562. +<skill id="4045" level="1"/>
  2563. +<skill id="4416" level="14"/>
  2564. +</skills>
  2565. +</npc>
  2566. +</list>
  2567. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment