Advertisement
l2jkamui

TeamVsTeam

Apr 22nd, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.84 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 4)
  6. +++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
  7. @@ -1,9 +1,11 @@
  8. package net.sf.l2j.gameserver.model.actor.appearance;
  9.  
  10. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  11. import net.sf.l2j.gameserver.model.base.Sex;
  12.  
  13. public final class PcAppearance
  14. {
  15. + private Player _owner;
  16. private byte _face;
  17. private byte _hairColor;
  18. private byte _hairStyle;
  19. @@ -11,6 +13,7 @@
  20. private boolean _invisible = false;
  21. private int _nameColor = 0xFFFFFF;
  22. private int _titleColor = 0xFFFF77;
  23. + private String _visibleTitle;
  24.  
  25. public PcAppearance(byte face, byte hColor, byte hStyle, Sex sex)
  26. {
  27. @@ -104,4 +107,27 @@
  28. {
  29. _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
  30. }
  31. +
  32. + public final void setVisibleTitle(String visibleTitle)
  33. + {
  34. + _visibleTitle = visibleTitle;
  35. + }
  36. +
  37. + public final String getVisibleTitle()
  38. + {
  39. + if (_visibleTitle == null)
  40. + _visibleTitle = getOwner().getTitle();
  41. +
  42. + return _visibleTitle;
  43. + }
  44. +
  45. + public void setOwner(Player owner)
  46. + {
  47. + _owner = owner;
  48. + }
  49. +
  50. + public Player getOwner()
  51. + {
  52. + return _owner;
  53. + }
  54. }
  55. \ No newline at end of file
  56. Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  57. ===================================================================
  58. --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 4)
  59. +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
  60. @@ -1,6 +1,7 @@
  61. package net.sf.l2j.gameserver.network.serverpackets;
  62.  
  63. import net.sf.l2j.gameserver.data.manager.CastleManager;
  64. +import net.sf.l2j.gameserver.engine.impl.EventCommons;
  65. import net.sf.l2j.gameserver.model.actor.Attackable;
  66. import net.sf.l2j.gameserver.model.actor.Creature;
  67. import net.sf.l2j.gameserver.model.actor.instance.Player;
  68. @@ -43,7 +44,10 @@
  69.  
  70. writeC(0x06);
  71. writeD(_charObjId);
  72. - writeD(0x01); // to nearest village
  73. + if (_activeChar instanceof Player && EventCommons.getInstance().showDiePacket((Player)_activeChar))
  74. + writeD(0x01); // to nearest village
  75. + else
  76. + writeD(0x00);
  77.  
  78. if (_clan != null)
  79. {
  80. Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  81. ===================================================================
  82. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 4)
  83. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
  84. @@ -242,7 +242,13 @@
  85. player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
  86. return false;
  87. }
  88. -
  89. +
  90. + if (player.isInFunEvent())
  91. + {
  92. + player.sendMessage("You cannot register in olympiad while registered at TvT.");
  93. + return false;
  94. + }
  95. +
  96. if (player.isSubClassActive())
  97. {
  98. player.sendPacket(SystemMessageId.YOU_CANT_JOIN_THE_OLYMPIAD_WITH_A_SUB_JOB_CHARACTER);
  99. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  100. ===================================================================
  101. --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 4)
  102. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
  103. @@ -25,9 +25,11 @@
  104. {
  105. final Creature target = (Creature) cha;
  106. if (activeChar instanceof Player)
  107. - {
  108. + {
  109. if (cha instanceof Player)
  110. ((Player) cha).reviveRequest((Player) activeChar, skill, false);
  111. + else if (cha instanceof Player)
  112. + ((Player) cha).isInFunEvent();
  113. else if (cha instanceof Pet)
  114. {
  115. if (((Pet) cha).getOwner() == activeChar)
  116. Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
  117. ===================================================================
  118. --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 4)
  119. +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
  120. @@ -46,7 +46,13 @@
  121. player.sendMessage("You or your target cannot trade during Olympiad.");
  122. return;
  123. }
  124. -
  125. +
  126. + if (player.isInFunEvent() || target.isInFunEvent())
  127. + {
  128. + player.sendMessage("You or your target cannot trade during event.");
  129. + return;
  130. + }
  131. +
  132. // Alt game - Karma punishment
  133. if (!Config.KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || target.getKarma() > 0))
  134. {
  135. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  136. ===================================================================
  137. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 4)
  138. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  139. @@ -170,6 +170,12 @@
  140. player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
  141. return;
  142. }
  143. +
  144. + if (player.isInFunEvent())
  145. + {
  146. + player.sendMessage("You can not observe games while registered for event.");
  147. + return;
  148. + }
  149.  
  150. final int arenaId = Integer.parseInt(_command.substring(12).trim());
  151. player.enterOlympiadObserverMode(arenaId);
  152. Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
  153. ===================================================================
  154. --- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (revision 4)
  155. +++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (working copy)
  156. @@ -10,6 +10,7 @@
  157. import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
  158. import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
  159. import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
  160. +import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
  161. import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
  162. import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
  163. import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
  164. @@ -30,6 +31,7 @@
  165. registerHandler(new ClanWarsList());
  166. registerHandler(new DisMount());
  167. registerHandler(new Escape());
  168. + registerHandler(new EventCommands());
  169. registerHandler(new Loc());
  170. registerHandler(new Mount());
  171. registerHandler(new OlympiadStat());
  172. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java
  173. ===================================================================
  174. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (revision 4)
  175. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (working copy)
  176. @@ -25,8 +25,14 @@
  177. if (activeChar == null)
  178. return;
  179.  
  180. + // check participants can not change their title
  181. + if (activeChar.isInFunEvent())
  182. + {
  183. + activeChar.sendMessage("You cannot change title while participating in an event.");
  184. + return;
  185. + }
  186. // Noblesse can bestow a title to themselves
  187. - if (activeChar.isNoble() && _target.matches(activeChar.getName()))
  188. + else if (activeChar.isNoble() && _target.matches(activeChar.getName()))
  189. {
  190. activeChar.setTitle(_title);
  191. activeChar.sendPacket(SystemMessageId.TITLE_CHANGED);
  192. Index: java/net/sf/l2j/gameserver/engine/impl/EventCommons.java
  193. ===================================================================
  194. --- java/net/sf/l2j/gameserver/engine/impl/EventCommons.java (revision 0)
  195. +++ java/net/sf/l2j/gameserver/engine/impl/EventCommons.java (working copy)
  196. @@ -0,0 +1,240 @@
  197. +package net.sf.l2j.gameserver.engine.impl;
  198. +
  199. +import java.util.ArrayList;
  200. +import java.util.HashMap;
  201. +import net.sf.l2j.commons.concurrent.ThreadPool;
  202. +
  203. +import net.sf.l2j.Config;
  204. +import net.sf.l2j.gameserver.engine.TvTEvent;
  205. +import net.sf.l2j.gameserver.model.actor.Creature;
  206. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  207. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  208. +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  209. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  210. +
  211. +/**
  212. + * @author Anarchy
  213. + *
  214. + */
  215. +public class EventCommons
  216. +{
  217. + private HashMap<Player, IEvent> _players;
  218. + private HashMap<Player, Class<?>> _registeredPlayers;
  219. +
  220. + public static EventCommons getInstance()
  221. + {
  222. + return SingletonHolder._instance;
  223. + }
  224. +
  225. + protected EventCommons()
  226. + {
  227. + _players = new HashMap<>();
  228. + _registeredPlayers = new HashMap<>();
  229. + }
  230. +
  231. + public void registerPlayer(Player player, Class<?> c)
  232. + {
  233. + if (_registeredPlayers.containsKey(player))
  234. + {
  235. + player.sendMessage("You have already registered for the event.");
  236. + return;
  237. + }
  238. + _registeredPlayers.put(player, c);
  239. + }
  240. +
  241. + public void unregisterPlayer(Player player, Class<?> c)
  242. + {
  243. + if (!_registeredPlayers.containsKey(player))
  244. + {
  245. + player.sendMessage("You have not registered for the event.");
  246. + return;
  247. + }
  248. +
  249. + _registeredPlayers.remove(player);
  250. + }
  251. +
  252. + public boolean showDiePacket(Player player)
  253. + {
  254. + if (_players.containsKey(player))
  255. + {
  256. + if (_players.get(player) instanceof TvTEvent)
  257. + return false;
  258. + }
  259. +
  260. + return true;
  261. + }
  262. +
  263. + public void doDie(Creature killer, Player victim)
  264. + {
  265. + if (_players.containsKey(victim))
  266. + {
  267. + if (killer != null && killer instanceof Player)
  268. + {
  269. + Player kl = (Player)killer;
  270. +
  271. + if (_players.containsKey(kl))
  272. + {
  273. + if (_players.get(victim) == _players.get(kl))
  274. + {
  275. + // TvT event kills.
  276. + if (_players.get(victim) instanceof TvTEvent)
  277. + {
  278. + if (kl.getEventTeam() != victim.getEventTeam())
  279. + {
  280. + final PlaySound ps = new PlaySound(0, "ItemSound.quest_itemget");
  281. + sysMsgToAllParticipants(killer.getName() + " I have killed " + victim.getName()+ " !");
  282. + kl.getEventTeam().addPoints(1);
  283. + kl.increaseScore();
  284. + kl.setTitle("Kills: " + kl.getScore());
  285. + kl.getAppearance().setVisibleTitle("Kills: " + kl.getScore());
  286. + kl.broadcastTitleInfo();
  287. + kl.sendPacket(ps);
  288. + }
  289. + victim.sendMessage("You will be revived in " + Config.TVT_RES_SECONDS + " second(s)");
  290. + ThreadPool.schedule(new ResTask(victim.getEventTeam().getRespawnX(), victim.getEventTeam().getRespawnY(), victim.getEventTeam().getRespawnZ(), victim, true),Config.TVT_RES_SECONDS * 1000);
  291. + }
  292. + }
  293. + }
  294. + }
  295. + }
  296. + }
  297. +
  298. + public void sysMsgToAllParticipants(String message)
  299. + {
  300. + for (Player player : _registeredPlayers.keySet())
  301. + {
  302. + if (player != null)
  303. + player.sendMessage(message);
  304. + }
  305. + }
  306. +
  307. + public boolean canTarget(Player player, Player target)
  308. + {
  309. + if ((!_players.containsKey(player) && _players.containsKey(target)) || (_players.containsKey(player) && !_players.containsKey(target)))
  310. + {
  311. + player.setTarget(null);
  312. + player.sendPacket(ActionFailed.STATIC_PACKET);
  313. + return false;
  314. + }
  315. +
  316. + if (_players.get(player) != _players.get(target))
  317. + {
  318. + player.setTarget(null);
  319. + player.sendPacket(ActionFailed.STATIC_PACKET);
  320. + return false;
  321. + }
  322. +
  323. + if ((target.getEventTeam() != null && player.getEventTeam() == null))
  324. + {
  325. + player.setTarget(null);
  326. + player.sendPacket(ActionFailed.STATIC_PACKET);
  327. + return false;
  328. + }
  329. +
  330. + if (target.getEventTeam() == null && player.getEventTeam() != null)
  331. + {
  332. + player.setTarget(null);
  333. + player.sendPacket(ActionFailed.STATIC_PACKET);
  334. + return false;
  335. + }
  336. +
  337. + return true;
  338. + }
  339. +
  340. + public void addPlayer(Player player, IEvent event)
  341. + {
  342. + if (!_players.containsKey(player))
  343. + _players.put(player, event);
  344. + }
  345. +
  346. + public void removePlayer(Player player)
  347. + {
  348. + if (_players.containsKey(player))
  349. + _players.remove(player);
  350. +
  351. + player.setTitle(player.getOriginalTitle());
  352. + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
  353. + player.broadcastTitleInfo();
  354. + player.clearPoints();
  355. + player.broadcastPacket(new SocialAction(player, 7));
  356. + }
  357. +
  358. + public int getRegisteredPlayersSize(Class<?> c)
  359. + {
  360. + int i = 0;
  361. + for (Player p : _registeredPlayers.keySet())
  362. + {
  363. + if (_registeredPlayers.get(p) == c)
  364. + i++;
  365. + }
  366. +
  367. + return i;
  368. + }
  369. +
  370. + public void removeRegisteredPlayers(Class<?> c)
  371. + {
  372. + ArrayList<Player> temp = new ArrayList<>();
  373. +
  374. + for (Player p : _registeredPlayers.keySet())
  375. + {
  376. + if (_registeredPlayers.get(p) == c)
  377. + temp.add(p);
  378. + }
  379. +
  380. + for (Player p : temp)
  381. + {
  382. + _registeredPlayers.remove(p);
  383. + }
  384. + }
  385. +
  386. + public HashMap<Player, Class<?>> getRegisteredPlayers()
  387. + {
  388. + return _registeredPlayers;
  389. + }
  390. +
  391. + public ArrayList<Player> getRegisteredPlayers(Class<?> c)
  392. + {
  393. + ArrayList<Player> temp = new ArrayList<>();
  394. +
  395. + for (Player p : _registeredPlayers.keySet())
  396. + {
  397. + if (_registeredPlayers.get(p) == c)
  398. + temp.add(p);
  399. + }
  400. +
  401. + return temp;
  402. + }
  403. +
  404. + public class ResTask implements Runnable
  405. + {
  406. + private final int _x, _y, _z;
  407. + private final Player _player;
  408. + private final boolean _heal;
  409. +
  410. + public ResTask(int x, int y, int z, Player player, boolean heal)
  411. + {
  412. + _x = x;
  413. + _y = y;
  414. + _z = z;
  415. + _player = player;
  416. + _heal = heal;
  417. + }
  418. +
  419. + @Override
  420. + public void run()
  421. + {
  422. + _player.doRevive();
  423. + _player.teleToLocation(_x, _y, _z, 0);
  424. + if (_heal)
  425. + {
  426. + _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
  427. + _player.setCurrentCp(_player.getMaxCp());
  428. + }
  429. + }
  430. + }
  431. +
  432. + private static class SingletonHolder
  433. + {
  434. + protected static final EventCommons _instance = new EventCommons();
  435. + }
  436. +}
  437. \ No newline at end of file
  438. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  439. ===================================================================
  440. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 4)
  441. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
  442. @@ -17,7 +17,7 @@
  443. @Override
  444. public boolean useUserCommand(int id, Player activeChar)
  445. {
  446. - if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
  447. + if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS) || activeChar.isInFunEvent())
  448. {
  449. activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
  450. return false;
  451. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java
  452. ===================================================================
  453. --- java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (revision 4)
  454. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (working copy)
  455. @@ -35,6 +35,13 @@
  456. return;
  457. }
  458.  
  459. + // players can not use in events
  460. + if (activeChar.isInFunEvent())
  461. + {
  462. + activeChar.sendMessage("You can't use in event.");
  463. + return;
  464. + }
  465. +
  466. final IntIntHolder[] skills = item.getEtcItem().getSkills();
  467. if (skills == null)
  468. {
  469. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  470. ===================================================================
  471. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 4)
  472. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
  473. @@ -40,7 +40,12 @@
  474. requestor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_HAS_ADDED_YOU_TO_IGNORE_LIST).addCharName(target));
  475. return;
  476. }
  477. -
  478. +
  479. + if (target.isInFunEvent() || requestor.isInFunEvent())
  480. + {
  481. + requestor.sendMessage("The player you tried to invite is currently in an event.");
  482. + return;
  483. + }
  484. if (target.equals(requestor) || target.isCursedWeaponEquipped() || requestor.isCursedWeaponEquipped() || target.getAppearance().getInvisible())
  485. {
  486. requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
  487. Index: java/net/sf/l2j/gameserver/engine/TvTEvent.java
  488. ===================================================================
  489. --- java/net/sf/l2j/gameserver/engine/TvTEvent.java (revision 0)
  490. +++ java/net/sf/l2j/gameserver/engine/TvTEvent.java (working copy)
  491. @@ -0,0 +1,251 @@
  492. +package net.sf.l2j.gameserver.engine;
  493. +
  494. +import java.util.ArrayList;
  495. +import java.util.LinkedList;
  496. +
  497. +import net.sf.l2j.commons.concurrent.ThreadPool;
  498. +
  499. +import net.sf.l2j.Config;
  500. +import net.sf.l2j.gameserver.data.ItemTable;
  501. +import net.sf.l2j.gameserver.data.xml.DoorData;
  502. +import net.sf.l2j.gameserver.engine.impl.EventCommons;
  503. +import net.sf.l2j.gameserver.engine.impl.EventState;
  504. +import net.sf.l2j.gameserver.engine.impl.EventTeam;
  505. +import net.sf.l2j.gameserver.engine.impl.IEvent;
  506. +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
  507. +import net.sf.l2j.gameserver.model.actor.instance.Door;
  508. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  509. +import net.sf.l2j.gameserver.util.Broadcast;
  510. +
  511. +/**
  512. + * @author Anarchy
  513. + *
  514. + */
  515. +public class TvTEvent implements IEvent
  516. +{
  517. + public ArrayList<Player> _players;
  518. + private EventState _state = EventState.INACTIVE;
  519. + private final ArrayList<EventTeam> _teams;
  520. + private final ArrayList<Door> _doors;
  521. +
  522. + public TvTEvent()
  523. + {
  524. + _players = new ArrayList<>();
  525. + _teams = new ArrayList<>();
  526. + _doors = new ArrayList<>();
  527. + }
  528. +
  529. + @Override
  530. + public void runEvent()
  531. + {
  532. + if (EventManager.getInstance().getCurrentEvent() != null)
  533. + return;
  534. +
  535. + EventManager.getInstance().setCurrentEvent(this);
  536. +
  537. + if (Config.ALLOW_TVT_EVENT)
  538. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s). Type /join or /leave", true);
  539. + else
  540. + Broadcast.announceToOnlinePlayers("TVT: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true);
  541. + for (int reward : Config.TVT_EVENT_REWARDS.keySet())
  542. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Reward: " + reward + " " + ItemTable.getInstance().getTemplate(reward).getName(), true);
  543. +
  544. + _state = EventState.REGISTERING;
  545. +
  546. + sleep(120);
  547. +
  548. + // sleep(Config.TVT_EVENT_PARTICIPATION_TIME * 60 * 1000); // in config given as minutes
  549. +
  550. + if (!check())
  551. + {
  552. + EventManager.getInstance().setCurrentEvent(null);
  553. + return;
  554. + }
  555. +
  556. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registrations for the TvT Event are closed.", true);
  557. + EventCommons.getInstance().sysMsgToAllParticipants(" Teleporting participants to an arena in " + 10 + " second(s).");
  558. +
  559. + _state = EventState.RUNNING;
  560. +
  561. + sleep(10);
  562. +
  563. + split();
  564. +
  565. + for (EventTeam et : _teams)
  566. + {
  567. + et.teleportTeam(Config.TVT_TEAMS_DATA.get(et.getName())[0], Config.TVT_TEAMS_DATA.get(et.getName())[1], Config.TVT_TEAMS_DATA.get(et.getName())[2], true);
  568. +
  569. + et.paralize(true);
  570. + }
  571. + closeDoors();
  572. +
  573. + sleep(5);
  574. +
  575. + for (EventTeam et : _teams)
  576. + {
  577. + et.paralize(false);
  578. + }
  579. +
  580. + Broadcast.announceToOnlinePlayers("TeamVsTeam: The event will last for " + Config.TVT_EVENT_RUNNING_TIME + " minute(s).", true);
  581. + sleep(300); // tvt time in min
  582. +
  583. + ThreadPool.schedule(new Runnable()
  584. + {
  585. + @Override
  586. + public void run()
  587. + {
  588. + rewardAndClear();
  589. + }
  590. + }, 1000 * 13);
  591. +
  592. +
  593. + openDoors();
  594. + _state = EventState.INACTIVE;
  595. +
  596. + EventManager.getInstance().setCurrentEvent(null);
  597. + System.out.append("TeamVsTeam: Initialized, started in " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s) and ends in " + Config.TVT_EVENT_RUNNING_TIME +" minute(s).");
  598. + }
  599. +
  600. + private void openDoors()
  601. + {
  602. + if (_doors.isEmpty())
  603. + {
  604. + for (int i : Config.TVT_DOORS)
  605. + {
  606. + Door door = DoorData.getInstance().getDoor(i);
  607. + door.openMe();
  608. + }
  609. + }
  610. + else
  611. + {
  612. + for (Door door : _doors)
  613. + {
  614. + door.deleteMe();
  615. + }
  616. + }
  617. + }
  618. +
  619. + private static void closeDoors()
  620. + {
  621. + for (int i : Config.TVT_DOORS)
  622. + {
  623. + Door door = DoorData.getInstance().getDoor(i);
  624. + door.closeMe();
  625. + }
  626. + }
  627. +
  628. + public void rewardAndClear()
  629. + {
  630. + int i = 0;
  631. + EventTeam winner = null;
  632. +
  633. + for (EventTeam et : _teams)
  634. + {
  635. + et.teleportTeam(82698, 148638, -3473, true);
  636. +
  637. + for (Player player : et.getPlayers())
  638. + {
  639. + EventCommons.getInstance().removePlayer(player);
  640. + }
  641. +
  642. + if (et.getPoints() > i)
  643. + {
  644. + i = et.getPoints();
  645. + winner = et;
  646. + }
  647. + }
  648. +
  649. + if (winner != null)
  650. + {
  651. + for (int ii : Config.TVT_EVENT_REWARDS.keySet())
  652. + {
  653. + winner.rewardTeam(ii, Config.TVT_EVENT_REWARDS.get(ii));
  654. + }
  655. +
  656. + Broadcast.announceToOnlinePlayers("TeamVsTeam: "+ winner.getName() + " team has won the event with " + winner.getPoints() + ".", true);
  657. + System.out.append("TeamVsTeam: "+ winner.getName() + " team has won the event with " + winner.getPoints() + ".");
  658. + }
  659. + else
  660. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Ended with no winner.", true);
  661. + System.out.append("TeamVsTeam: Ended with no winner.");
  662. + return;
  663. + }
  664. +
  665. + public boolean check()
  666. + {
  667. + if (EventCommons.getInstance().getRegisteredPlayersSize(TvTEvent.class) < Config.TVT_TEAMS_DATA.size() * 1)
  668. + {
  669. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Has been canceled due to lack of participants.", true);
  670. + EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
  671. + _state = EventState.INACTIVE;
  672. + System.out.append("TeamVsTeam: Has been canceled due to lack of participants.");
  673. + return false;
  674. + }
  675. +
  676. + return true;
  677. + }
  678. +
  679. + public void split()
  680. + {
  681. + int i = Config.TVT_TEAMS_DATA.size() - 1;
  682. + LinkedList<LinkedList<Player>> temp = new LinkedList<>();
  683. +
  684. + for (int ii = Config.TVT_TEAMS_DATA.size(); ii > 0; ii--)
  685. + {
  686. + LinkedList<Player> t = new LinkedList<>();
  687. + temp.add(t);
  688. + }
  689. +
  690. + for (Player p : EventCommons.getInstance().getRegisteredPlayers(TvTEvent.class))
  691. + {
  692. + temp.get(i).add(p);
  693. + i--;
  694. +
  695. + if (i == -1)
  696. + i = Config.TVT_TEAMS_DATA.size();
  697. +
  698. + EventCommons.getInstance().addPlayer(p, this);
  699. + }
  700. +
  701. + for (String s : Config.TVT_TEAMS_DATA.keySet())
  702. + {
  703. + EventTeam et = new EventTeam(temp.getLast(), s, 0, new int[]
  704. + {
  705. + Config.TVT_TEAMS_DATA.get(s)[0], Config.TVT_TEAMS_DATA.get(s)[1], Config.TVT_TEAMS_DATA.get(s)[2]
  706. + });
  707. + temp.remove(temp.getLast());
  708. +
  709. + _teams.add(et);
  710. + }
  711. + }
  712. +
  713. + private static void sleep(int seconds)
  714. + {
  715. + try
  716. + {
  717. + Thread.sleep(seconds * 1000);
  718. + }
  719. + catch (InterruptedException e)
  720. + {
  721. + e.printStackTrace();
  722. + }
  723. + }
  724. +
  725. + @Override
  726. + public EventState getState()
  727. + {
  728. + return _state;
  729. + }
  730. +
  731. + @Override
  732. + public String getTimes()
  733. + {
  734. + return Config.TVT_EVENT_TIMES;
  735. + }
  736. +
  737. + @Override
  738. + public int getId()
  739. + {
  740. + return 1;
  741. + }
  742. +}
  743. \ No newline at end of file
  744. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  745. ===================================================================
  746. --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 4)
  747. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
  748. @@ -41,6 +41,9 @@
  749. activeChar.sendPacket(SystemMessageId.CANT_MOVE_SITTING);
  750. return;
  751. }
  752. +
  753. + if (activeChar.isInFunEvent())
  754. + return;
  755.  
  756. if (activeChar.isInObserverMode())
  757. return;
  758. Index: java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  759. ===================================================================
  760. --- java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (revision 4)
  761. +++ java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (working copy)
  762. @@ -122,7 +122,7 @@
  763. }
  764.  
  765. // Simple checks to avoid exploits
  766. - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  767. + if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  768. {
  769. player.sendMessage("Due to the current partner's status, the teleportation failed.");
  770. return;
  771. Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
  772. ===================================================================
  773. --- java/net/sf/l2j/gameserver/model/actor/Creature.java (revision 4)
  774. +++ java/net/sf/l2j/gameserver/model/actor/Creature.java (working copy)
  775. @@ -131,6 +131,7 @@
  776. private CreatureTemplate _template; // The link on the L2CharTemplate object containing generic and static properties
  777.  
  778. protected String _title;
  779. + protected String _originalTitle;
  780. private double _hpUpdateIncCheck = .0;
  781. private double _hpUpdateDecCheck = .0;
  782. private double _hpUpdateInterval = .0;
  783. @@ -1888,8 +1889,16 @@
  784. {
  785. return _title;
  786. }
  787. -
  788. +
  789. /**
  790. + * @return the Title of the Creature.
  791. + */
  792. + public final String getOriginalTitle()
  793. + {
  794. + return _originalTitle;
  795. + }
  796. +
  797. + /**
  798. * Set the Title of the Creature. Concatens it if length > 16.
  799. * @param value The String to test.
  800. */
  801. Index: java/net/sf/l2j/gameserver/engine/impl/IEvent.java
  802. ===================================================================
  803. --- java/net/sf/l2j/gameserver/engine/impl/IEvent.java (revision 0)
  804. +++ java/net/sf/l2j/gameserver/engine/impl/IEvent.java (working copy)
  805. @@ -0,0 +1,13 @@
  806. +package net.sf.l2j.gameserver.engine.impl;
  807. +
  808. +/**
  809. + * @author Anarchy
  810. + *
  811. + */
  812. +public interface IEvent
  813. +{
  814. + public void runEvent();
  815. + public EventState getState();
  816. + public String getTimes();
  817. + public int getId();
  818. +}
  819. Index: java/net/sf/l2j/gameserver/engine/impl/EventState.java
  820. ===================================================================
  821. --- java/net/sf/l2j/gameserver/engine/impl/EventState.java (revision 0)
  822. +++ java/net/sf/l2j/gameserver/engine/impl/EventState.java (working copy)
  823. @@ -0,0 +1,12 @@
  824. +package net.sf.l2j.gameserver.engine.impl;
  825. +
  826. +/**
  827. + * @author Anarchy
  828. + *
  829. + */
  830. +public enum EventState
  831. +{
  832. + INACTIVE,
  833. + REGISTERING,
  834. + RUNNING
  835. +}
  836. Index: java/net/sf/l2j/gameserver/engine/impl/EventTeam.java
  837. ===================================================================
  838. --- java/net/sf/l2j/gameserver/engine/impl/EventTeam.java (revision 0)
  839. +++ java/net/sf/l2j/gameserver/engine/impl/EventTeam.java (working copy)
  840. @@ -0,0 +1,207 @@
  841. +package net.sf.l2j.gameserver.engine.impl;
  842. +
  843. +import java.util.List;
  844. +
  845. +import net.sf.l2j.Config;
  846. +import net.sf.l2j.gameserver.data.SkillTable;
  847. +import net.sf.l2j.gameserver.model.actor.Summon;
  848. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  849. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  850. +import net.sf.l2j.gameserver.model.group.Party;
  851. +import net.sf.l2j.gameserver.model.group.Party.MessageType;
  852. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  853. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  854. +import net.sf.l2j.gameserver.network.serverpackets.Ride;
  855. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  856. +import net.sf.l2j.gameserver.skills.AbnormalEffect;
  857. +
  858. +/**
  859. + * @author williams
  860. + *
  861. + */
  862. +public class EventTeam
  863. +{
  864. + private final List<Player> _players;
  865. + private final String _name;
  866. + private int _points;
  867. + private final int[] _respawnLoc;
  868. +
  869. + public EventTeam(List<Player> players, String name, int points, int[] respawnLoc)
  870. + {
  871. + _players = players;
  872. + _name = name;
  873. + _points = points;
  874. + _respawnLoc = respawnLoc;
  875. +
  876. + for (Player p : _players)
  877. + {
  878. + p.setEventTeam(this);
  879. + }
  880. + }
  881. +
  882. + /**
  883. + * The method to teleport the player<br>
  884. + * 1. Unsummon pet if there is one
  885. + * 2. Remove all effects
  886. + * 3. Revive and full heal the player
  887. + * 4. Teleport the player
  888. + * 5. Broadcast status and user info
  889. + * 6. Remove party
  890. + * 7. Remove players mounted
  891. + * @param x
  892. + * @param y
  893. + * @param z
  894. + * @param teleport
  895. + */
  896. + public void teleportTeam(int x, int y, int z, boolean teleport)
  897. + {
  898. + for (Player player : _players)
  899. + {
  900. + if (player == null)
  901. + return;
  902. +
  903. + // Count Kills at the title
  904. + player.setTitle("Kills: " + player.getScore());
  905. + player.getAppearance().setVisibleTitle("Kills: " + player.getScore());
  906. + player.broadcastTitleInfo();
  907. +
  908. + // Aura duel for team
  909. + if (teleport)
  910. + player.setTeam(1 + 1);
  911. + else
  912. + player.setTeam(0);
  913. +
  914. + // Remove players Mounted
  915. + if (player.isMounted())
  916. + {
  917. + if (player.dismount())
  918. + {
  919. + if (player.isFlying())
  920. + player.removeSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill().getId(), false);
  921. +
  922. + final Ride dismount = new Ride(player.getObjectId(), Ride.ACTION_DISMOUNT, 0);
  923. + player.broadcastPacket(dismount);
  924. + player.setMountObjectId(0);
  925. + }
  926. + }
  927. +
  928. + // Remove Buffs
  929. + if (Config.TvT_EVENT_REMOVE_BUFFS)
  930. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  931. +
  932. + // Heal/Revive Player fully
  933. + player.setCurrentCp(player.getMaxCp());
  934. + player.setCurrentHp(player.getMaxHp());
  935. + player.setCurrentMp(player.getMaxMp());
  936. + player.doRevive();
  937. +
  938. + // Remove Summon's Buffs
  939. + final Summon summon = player.getPet();
  940. + if (Config.TvT_EVENT_REMOVE_BUFFS && summon != null)
  941. + {
  942. + summon.stopAllEffectsExceptThoseThatLastThroughDeath();
  943. + summon.abortAttack();
  944. + summon.abortCast();
  945. +
  946. + if (summon instanceof Pet)
  947. + summon.unSummon(player);
  948. + }
  949. +
  950. + player.broadcastStatusUpdate();
  951. + player.broadcastUserInfo();
  952. +
  953. + // stop any cubic that has been given by other player.
  954. + player.stopCubicsByOthers();
  955. +
  956. + // Remove player from his party
  957. + if (teleport)
  958. + {
  959. + final Party party = player.getParty();
  960. + if (party != null)
  961. + party.removePartyMember(player, MessageType.EXPELLED);
  962. + }
  963. +
  964. + player.teleToLocation(x, y, z, 0);
  965. + if (teleport)
  966. + player.sendMessage("You have been teleported.");
  967. + }
  968. + }
  969. +
  970. + public void paralize(boolean val)
  971. + {
  972. + if (val)
  973. + {
  974. + for (Player player : _players)
  975. + {
  976. + player.sendPacket(new ExShowScreenMessage("Fight starts in seconds!", 5000, 0x02, true));
  977. + player.startAbnormalEffect(AbnormalEffect.ROOT);
  978. + player.setIsParalyzed(true);
  979. + }
  980. + }
  981. + else
  982. + {
  983. + for (Player player : _players)
  984. + {
  985. + player.broadcastPacket(new SocialAction(player, 4));
  986. + player.sendPacket(new ExShowScreenMessage("Fight started!", 5000, 0x02, true));
  987. + player.stopAbnormalEffect(AbnormalEffect.ROOT);
  988. + player.setIsParalyzed(false);
  989. + }
  990. + }
  991. + }
  992. +
  993. + public void rewardTeam(int itemId, int count)
  994. + {
  995. + for (Player player : _players)
  996. + {
  997. + // Fireworks for rewarded player
  998. + player.broadcastPacket(new MagicSkillUse(player, player, 2025, 1, 1, 1));
  999. + player.addItem("Event Reward", itemId, count, null, true);
  1000. + }
  1001. + }
  1002. +
  1003. + public void addPoints(int val)
  1004. + {
  1005. + _points += val;
  1006. + }
  1007. +
  1008. + public void removePoints(int val)
  1009. + {
  1010. + _points -= val;
  1011. + }
  1012. +
  1013. + public int getPoints()
  1014. + {
  1015. + return _points;
  1016. + }
  1017. +
  1018. + public int getRespawnX()
  1019. + {
  1020. + return _respawnLoc[0];
  1021. + }
  1022. +
  1023. + public int getRespawnY()
  1024. + {
  1025. + return _respawnLoc[1];
  1026. + }
  1027. +
  1028. + public int getRespawnZ()
  1029. + {
  1030. + return _respawnLoc[2];
  1031. + }
  1032. +
  1033. + public String getName()
  1034. + {
  1035. + return _name;
  1036. + }
  1037. +
  1038. + public List<Player> getPlayers()
  1039. + {
  1040. + return _players;
  1041. + }
  1042. +
  1043. + public boolean containsPlayer(Player p)
  1044. + {
  1045. + return _players.contains(p);
  1046. + }
  1047. +}
  1048. \ No newline at end of file
  1049. Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
  1050. ===================================================================
  1051. --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java (revision 4)
  1052. +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java (working copy)
  1053. @@ -48,6 +48,9 @@
  1054. import net.sf.l2j.gameserver.data.xml.NpcData;
  1055. import net.sf.l2j.gameserver.data.xml.PlayerData;
  1056. import net.sf.l2j.gameserver.data.xml.RecipeData;
  1057. +import net.sf.l2j.gameserver.engine.TvTEvent;
  1058. +import net.sf.l2j.gameserver.engine.impl.EventCommons;
  1059. +import net.sf.l2j.gameserver.engine.impl.EventTeam;
  1060. import net.sf.l2j.gameserver.geoengine.GeoEngine;
  1061. import net.sf.l2j.gameserver.handler.IItemHandler;
  1062. import net.sf.l2j.gameserver.handler.ItemHandler;
  1063. @@ -578,6 +581,10 @@
  1064.  
  1065. private Door _requestedGate;
  1066.  
  1067. + private EventTeam _eventTeam = null;
  1068. +
  1069. + private short _points = 0;
  1070. +
  1071. /**
  1072. * Constructor of Player (use Creature constructor).
  1073. * <ul>
  1074. @@ -2897,6 +2904,9 @@
  1075. @Override
  1076. public void onAction(Player player)
  1077. {
  1078. + if (!EventCommons.getInstance().canTarget(player, this))
  1079. + return;
  1080. +
  1081. // Set the target of the player
  1082. if (player.getTarget() != this)
  1083. player.setTarget(this);
  1084. @@ -2942,6 +2952,9 @@
  1085. if (player.isGM())
  1086. AdminEditChar.showCharacterInfo(player, this);
  1087.  
  1088. + if (!EventCommons.getInstance().canTarget(player, this))
  1089. + return;
  1090. +
  1091. super.onActionShift(player);
  1092. }
  1093.  
  1094. @@ -3654,6 +3667,8 @@
  1095. if (isFakeDeath())
  1096. stopFakeDeath(true);
  1097. }
  1098. +
  1099. + EventCommons.getInstance().doDie(killer, this);
  1100.  
  1101. if (killer != null)
  1102. {
  1103. @@ -3870,6 +3885,9 @@
  1104. // PK Points are increased only if you kill a player.
  1105. if (target instanceof Player)
  1106. setPkKills(getPkKills() + 1);
  1107. +
  1108. + if (isInFunEvent() == false)
  1109. + return;
  1110.  
  1111. // Calculate new karma.
  1112. setKarma(getKarma() + Formulas.calculateKarmaGain(getPkKills(), target instanceof Summon));
  1113. @@ -3895,6 +3913,9 @@
  1114. final Player player = target.getActingPlayer();
  1115. if (player == null)
  1116. return;
  1117. +
  1118. + if (isInFunEvent() == false)
  1119. + return;
  1120.  
  1121. if (isInDuel() && player.getDuelId() == getDuelId())
  1122. return;
  1123. @@ -9278,6 +9299,9 @@
  1124.  
  1125. if (OlympiadManager.getInstance().isRegisteredInComp(this))
  1126. OlympiadManager.getInstance().removeDisconnectedCompetitor(this);
  1127. +
  1128. + // Handle removal from TeamVsTeam
  1129. + EventCommons.getInstance().removeRegisteredPlayers(TvTEvent.class);
  1130.  
  1131. // Open a Html message to inform the player
  1132. final NpcHtmlMessage html = new NpcHtmlMessage(0);
  1133. @@ -9425,7 +9449,7 @@
  1134. if (_deathPenaltyBuffLevel >= 15) // maximum level reached
  1135. return;
  1136.  
  1137. - if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
  1138. + if ((getKarma() > 0 || Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE) && !(killer instanceof Player) && !isGM() && !(getCharmOfLuck() && (killer == null || killer.isRaid())) && !isPhoenixBlessed() && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)) && isInFunEvent())
  1139. {
  1140. if (_deathPenaltyBuffLevel != 0)
  1141. removeSkill(5076, false);
  1142. @@ -9808,7 +9832,7 @@
  1143. if (summonerChar == null)
  1144. return false;
  1145.  
  1146. - if (summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
  1147. + if (summonerChar.isInFunEvent() || summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
  1148. return false;
  1149.  
  1150. return true;
  1151. @@ -9851,7 +9875,7 @@
  1152. return false;
  1153. }
  1154.  
  1155. - if (targetChar.isInObserverMode() || targetChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND))
  1156. + if (targetChar.isInObserverMode() || targetChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || targetChar.isInFunEvent())
  1157. {
  1158. summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_IN_SUMMON_BLOCKING_AREA).addCharName(targetChar));
  1159. return false;
  1160. @@ -10174,6 +10198,36 @@
  1161. {
  1162. _requestedGate = door;
  1163. }
  1164. +
  1165. + public boolean isInFunEvent()
  1166. + {
  1167. + return ((EventCommons.getInstance().getRegisteredPlayers().containsKey(this)));
  1168. + }
  1169. +
  1170. + public EventTeam getEventTeam()
  1171. + {
  1172. + return _eventTeam;
  1173. + }
  1174. +
  1175. + public void setEventTeam(EventTeam val)
  1176. + {
  1177. + _eventTeam = val;
  1178. + }
  1179. +
  1180. + public short getScore()
  1181. + {
  1182. + return _points;
  1183. + }
  1184. +
  1185. + public void clearPoints()
  1186. + {
  1187. + _points = 0;
  1188. + }
  1189. +
  1190. + public void increaseScore()
  1191. + {
  1192. + _points++;
  1193. + }
  1194.  
  1195. @Override
  1196. public boolean polymorph(PolyType type, int npcId)
  1197. Index: config/events.properties
  1198. ===================================================================
  1199. --- config/events.properties (revision 4)
  1200. +++ config/events.properties (working copy)
  1201. @@ -235,4 +235,29 @@
  1202. AltFishChampionshipReward2 = 500000
  1203. AltFishChampionshipReward3 = 300000
  1204. AltFishChampionshipReward4 = 200000
  1205. -AltFishChampionshipReward5 = 100000
  1206. \ No newline at end of file
  1207. +AltFishChampionshipReward5 = 100000
  1208. +
  1209. +#=============================================================
  1210. +# TvT Event
  1211. +#=============================================================
  1212. +# Enable or disable the TvT Event.
  1213. +AllowTvtEvent = True
  1214. +# Times of day that the event will take place.
  1215. +TvtEventTimes = 12:00,14:00,16:00
  1216. +# Registration timer from start of event (in minutes).
  1217. +TvTEventParticipationTime = 5
  1218. +# Event running time (in minutes).
  1219. +TvTEventRunningTime = 5
  1220. +# Rewards.
  1221. +TvtEventRewards = 57,1000;
  1222. +# Team data. Should be like this: teamname_x,y,z;teamname_x,y,z.
  1223. +# Note: You can add as many teams as you like.
  1224. +TvtTeamsData = Angels_148404,46718,-3414;Demons_150545,46718,-3414
  1225. +# Time to res after death.
  1226. +TvtResSeconds = 5
  1227. +# Doors to close when event starts.
  1228. +# Default doors: Coliseum
  1229. +TvtDoors = 24190001,24190002,24190003,24190004
  1230. +# Participant's effects
  1231. +# 1. Unsummon pet if there is one , 2. Remove all effects , 3. Remove party, 4. Remove players mounted
  1232. +TvTEventRemoveBuffs True
  1233. \ No newline at end of file
  1234. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  1235. ===================================================================
  1236. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 4)
  1237. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
  1238. @@ -36,7 +36,14 @@
  1239. sendPacket(RestartResponse.valueOf(false));
  1240. return;
  1241. }
  1242. -
  1243. +
  1244. + if (player.isInFunEvent())
  1245. + {
  1246. + player.sendMessage("You can not restart the event.");
  1247. + sendPacket(RestartResponse.valueOf(false));
  1248. + return;
  1249. + }
  1250. +
  1251. if (AttackStanceTaskManager.getInstance().isInAttackStance(player))
  1252. {
  1253. player.sendPacket(SystemMessageId.CANT_RESTART_WHILE_FIGHTING);
  1254. Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  1255. ===================================================================
  1256. --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 4)
  1257. +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
  1258. @@ -38,7 +38,7 @@
  1259. if (activeChar instanceof Player)
  1260. {
  1261. // Check invalid states.
  1262. - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  1263. + if (((Player) activeChar).isInFunEvent() || activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  1264. return;
  1265. }
  1266.  
  1267. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java
  1268. ===================================================================
  1269. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (revision 0)
  1270. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (working copy)
  1271. @@ -0,0 +1,52 @@
  1272. +package net.sf.l2j.gameserver.handler.usercommandhandlers;
  1273. +
  1274. +import net.sf.l2j.gameserver.engine.TvTEvent;
  1275. +import net.sf.l2j.gameserver.engine.impl.EventCommons;
  1276. +import net.sf.l2j.gameserver.engine.impl.EventState;
  1277. +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
  1278. +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  1279. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  1280. +
  1281. +/**
  1282. + * @author williams
  1283. + *
  1284. + */
  1285. +public class EventCommands implements IUserCommandHandler
  1286. +{
  1287. + private static final int[] COMMAND_IDS =
  1288. + {
  1289. + 114, 115
  1290. + };
  1291. +
  1292. + @Override
  1293. + public boolean useUserCommand(int id, Player activeChar)
  1294. + {
  1295. + if (activeChar.isInOlympiadMode())
  1296. + return false;
  1297. +
  1298. + if (id == 114)
  1299. + {
  1300. + if (EventManager.getInstance().getCurrentEvent() == null || EventManager.getInstance().getCurrentEvent().getState() != EventState.REGISTERING)
  1301. + return false;
  1302. +
  1303. + EventCommons.getInstance().registerPlayer(activeChar, TvTEvent.class);
  1304. + activeChar.sendMessage("You have registered successfully.");
  1305. +
  1306. + }
  1307. + else if (id == 115)
  1308. + {
  1309. + if (EventCommons.getInstance().getRegisteredPlayers().containsKey(activeChar))
  1310. + EventCommons.getInstance().unregisterPlayer(activeChar,EventCommons.getInstance().getRegisteredPlayers().get(activeChar));
  1311. +
  1312. + activeChar.sendMessage("You have canceled your registration.");
  1313. + }
  1314. +
  1315. + return true;
  1316. + }
  1317. +
  1318. + @Override
  1319. + public int[] getUserCommandList()
  1320. + {
  1321. + return COMMAND_IDS;
  1322. + }
  1323. +}
  1324. Index: java/net/sf/l2j/gameserver/GameServer.java
  1325. ===================================================================
  1326. --- java/net/sf/l2j/gameserver/GameServer.java (revision 4)
  1327. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  1328. @@ -59,6 +59,7 @@
  1329. import net.sf.l2j.gameserver.data.xml.SummonItemData;
  1330. import net.sf.l2j.gameserver.data.xml.TeleportLocationData;
  1331. import net.sf.l2j.gameserver.data.xml.WalkerRouteData;
  1332. +import net.sf.l2j.gameserver.engine.impl.manager.EventManager;
  1333. import net.sf.l2j.gameserver.geoengine.GeoEngine;
  1334. import net.sf.l2j.gameserver.handler.AdminCommandHandler;
  1335. import net.sf.l2j.gameserver.handler.ChatHandler;
  1336. @@ -278,6 +279,9 @@
  1337. LOGGER.info("Loaded {} skill handlers.", SkillHandler.getInstance().size());
  1338. LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
  1339.  
  1340. + StringUtil.printSection("Event Manager");
  1341. + EventManager.getInstance();
  1342. +
  1343. StringUtil.printSection("System");
  1344. Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  1345. ForumsBBSManager.getInstance();
  1346. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
  1347. ===================================================================
  1348. --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 4)
  1349. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
  1350. @@ -38,6 +38,12 @@
  1351. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  1352. return;
  1353. }
  1354. +
  1355. + if (activeChar.isInFunEvent())
  1356. + {
  1357. + activeChar.sendMessage("You can't use resurrection in event.");
  1358. + return;
  1359. + }
  1360.  
  1361. // Pet scrolls to ress a player.
  1362. if (item.getItemId() == 6387 && target instanceof Player)
  1363. Index: java/net/sf/l2j/Config.java
  1364. ===================================================================
  1365. --- java/net/sf/l2j/Config.java (revision 4)
  1366. +++ java/net/sf/l2j/Config.java (working copy)
  1367. @@ -168,7 +168,7 @@
  1368. public static int FS_TIME_WARMUP;
  1369. public static int FS_PARTY_MEMBER_COUNT;
  1370.  
  1371. - /** dimensional rift */
  1372. + /** Dimensional rift */
  1373. public static int RIFT_MIN_PARTY_SIZE;
  1374. public static int RIFT_SPAWN_DELAY;
  1375. public static int RIFT_MAX_JUMPS;
  1376. @@ -205,6 +205,17 @@
  1377. public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
  1378. public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
  1379.  
  1380. + /** TvT Event */
  1381. + public static boolean ALLOW_TVT_EVENT;
  1382. + public static boolean TvT_EVENT_REMOVE_BUFFS;
  1383. + public static int TVT_EVENT_PARTICIPATION_TIME;
  1384. + public static int TVT_EVENT_RUNNING_TIME;
  1385. + public static int TVT_RES_SECONDS;
  1386. + public static String TVT_EVENT_TIMES;
  1387. + public static HashMap<Integer, Integer> TVT_EVENT_REWARDS = new HashMap<>();
  1388. + public static HashMap<String, int[]> TVT_TEAMS_DATA = new HashMap<>();
  1389. + public static ArrayList<Integer> TVT_DOORS = new ArrayList<>();
  1390. +
  1391. // --------------------------------------------------
  1392. // GeoEngine
  1393. // --------------------------------------------------
  1394. @@ -871,6 +882,41 @@
  1395. ALT_FISH_CHAMPIONSHIP_REWARD_3 = events.getProperty("AltFishChampionshipReward3", 300000);
  1396. ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
  1397. ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
  1398. +
  1399. + ALLOW_TVT_EVENT = events.getProperty("AllowTvtEvent", false);
  1400. + TvT_EVENT_REMOVE_BUFFS = events.getProperty("TvTEventRemoveBuffs", false);
  1401. + TVT_EVENT_TIMES = events.getProperty("TvtEventTimes", "12:00,14:00,16:00");
  1402. + TVT_EVENT_PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 3600);
  1403. + TVT_EVENT_RUNNING_TIME = events.getProperty("TvTEventRunningTime", 1800);
  1404. + String TVT_EVENT_REWARDS_VALUE = events.getProperty("TvtEventRewards", "57,1;");
  1405. + String[] tvt_event_rewards_splitted_1 = TVT_EVENT_REWARDS_VALUE.split(";");
  1406. + for (String i : tvt_event_rewards_splitted_1)
  1407. + {
  1408. + String[] tvt_event_rewards_splitted_2 = i.split(",");
  1409. + TVT_EVENT_REWARDS.put(Integer.parseInt(tvt_event_rewards_splitted_2[0]),
  1410. + Integer.parseInt(tvt_event_rewards_splitted_2[1]));
  1411. + }
  1412. + String tvt_teams_data = events.getProperty("TvtTeamsData", "Good_0,0,0;Evil_0,0,0");
  1413. + String[] ttd_splitted = tvt_teams_data.split(";");
  1414. + for (String s : ttd_splitted)
  1415. + {
  1416. + String[] ss = s.split("_");
  1417. + String name = ss[0];
  1418. + String[] sss = ss[1].split(",");
  1419. + int x = Integer.parseInt(sss[0]);
  1420. + int y = Integer.parseInt(sss[1]);
  1421. + int z = Integer.parseInt(sss[2]);
  1422. +
  1423. + TVT_TEAMS_DATA.put(name, new int[] { x, y, z });
  1424. + }
  1425. + TVT_RES_SECONDS = events.getProperty("TvtResSeconds", 10);
  1426. + String tvt_doors = events.getProperty("TvtDoors", "24190001,24190002,24190003,24190004");
  1427. + String[] tvt_doors_split = tvt_doors.split(",");
  1428. + for (String s : tvt_doors_split)
  1429. + {
  1430. + int i = Integer.parseInt(s);
  1431. + TVT_DOORS.add(i);
  1432. + }
  1433. }
  1434.  
  1435. /**
  1436. Index: java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java
  1437. ===================================================================
  1438. --- java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java (revision 0)
  1439. +++ java/net/sf/l2j/gameserver/engine/impl/manager/EventManager.java (working copy)
  1440. @@ -0,0 +1,132 @@
  1441. +package net.sf.l2j.gameserver.engine.impl.manager;
  1442. +
  1443. +import java.util.Calendar;
  1444. +import java.util.HashMap;
  1445. +import java.util.logging.Logger;
  1446. +
  1447. +import net.sf.l2j.commons.concurrent.ThreadPool;
  1448. +
  1449. +import net.sf.l2j.Config;
  1450. +import net.sf.l2j.gameserver.engine.TvTEvent;
  1451. +import net.sf.l2j.gameserver.engine.impl.IEvent;
  1452. +
  1453. +/**
  1454. + * @author Anarchy
  1455. + *
  1456. + */
  1457. +public final class EventManager
  1458. +{
  1459. + private static final Logger _log = Logger.getLogger(EventManager.class.getName());
  1460. +
  1461. + public static int TVT = 1;
  1462. +
  1463. + private int _events = 0;
  1464. + public HashMap<IEvent, Integer> _eventsTasks;
  1465. + private IEvent _currentEvent = null;
  1466. +
  1467. + public static EventManager getInstance()
  1468. + {
  1469. + return SingletonHolder._instance;
  1470. + }
  1471. +
  1472. + protected EventManager()
  1473. + {
  1474. + _eventsTasks = new HashMap<>();
  1475. +
  1476. + if (Config.ALLOW_TVT_EVENT)
  1477. + registerEvent(Config.TVT_EVENT_TIMES, TvTEvent.class);
  1478. +
  1479. + _log.info("Loaded " + _events + " events.");
  1480. + }
  1481. +
  1482. + public void registerEvent(final String times, final Class<?> type)
  1483. + {
  1484. + _events++;
  1485. +
  1486. + int i = 0;
  1487. +
  1488. + for (String time : times.split(","))
  1489. + {
  1490. + final IEvent event;
  1491. +
  1492. + try
  1493. + {
  1494. + event = (IEvent)type.newInstance();
  1495. + }
  1496. + catch (InstantiationException | IllegalAccessException ea)
  1497. + {
  1498. + ea.printStackTrace();
  1499. + return;
  1500. + }
  1501. +
  1502. + String[] timeArray = time.split(":");
  1503. + int hours = Integer.parseInt(timeArray[0]);
  1504. + int minutes = Integer.parseInt(timeArray[1]);
  1505. +
  1506. + Calendar cld = Calendar.getInstance();
  1507. +
  1508. + cld.set(Calendar.HOUR_OF_DAY, hours);
  1509. + cld.set(Calendar.MINUTE, minutes);
  1510. + cld.set(Calendar.SECOND, 0);
  1511. +
  1512. + if (cld.getTimeInMillis() - System.currentTimeMillis() < 0)
  1513. + {
  1514. + cld.set(Calendar.DAY_OF_MONTH, cld.get(Calendar.DAY_OF_MONTH) + 1);
  1515. + cld.set(Calendar.HOUR_OF_DAY, hours);
  1516. + cld.set(Calendar.MINUTE, minutes);
  1517. + cld.set(Calendar.SECOND, 0);
  1518. + }
  1519. +
  1520. + if (cld.getTimeInMillis() - System.currentTimeMillis() > 0)
  1521. + {
  1522. + i++;
  1523. +
  1524. + if (_eventsTasks.containsKey(event))
  1525. + {
  1526. + _eventsTasks.remove(event);
  1527. + _eventsTasks.put(event, i);
  1528. + }
  1529. + else
  1530. + {
  1531. + _eventsTasks.put(event, i);
  1532. + }
  1533. +
  1534. + ThreadPool.schedule(new Runnable()
  1535. + {
  1536. + @Override
  1537. + public void run()
  1538. + {
  1539. + if (_eventsTasks.get(event) == 1)
  1540. + {
  1541. + _eventsTasks.remove(event);
  1542. + registerEvent(times, type);
  1543. + }
  1544. + else
  1545. + {
  1546. + int t = _eventsTasks.get(event);
  1547. + _eventsTasks.remove(event);
  1548. + _eventsTasks.put(event, t--);
  1549. + }
  1550. +
  1551. + event.runEvent();
  1552. + }
  1553. + }, cld.getTimeInMillis() - System.currentTimeMillis());
  1554. + }
  1555. + }
  1556. + }
  1557. +
  1558. + public IEvent getCurrentEvent()
  1559. + {
  1560. + return _currentEvent;
  1561. + }
  1562. +
  1563. + public void setCurrentEvent(IEvent event)
  1564. + {
  1565. + _currentEvent = event;
  1566. + }
  1567. +
  1568. + private static class SingletonHolder
  1569. + {
  1570. + protected static final EventManager _instance = new EventManager();
  1571. + }
  1572. +}
  1573. \ No newline at end of file
  1574. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java
  1575. ===================================================================
  1576. --- java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (revision 4)
  1577. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/GetPlayer.java (working copy)
  1578. @@ -28,6 +28,9 @@
  1579. final Player victim = target.getActingPlayer();
  1580. if (victim == null || victim.isAlikeDead())
  1581. continue;
  1582. +
  1583. + if (!victim.isInFunEvent())
  1584. + continue;
  1585.  
  1586. victim.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 0);
  1587. }
  1588. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  1589. ===================================================================
  1590. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 4)
  1591. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
  1592. @@ -39,6 +39,9 @@
  1593. player.stopFakeDeath(true);
  1594. return;
  1595. }
  1596. +
  1597. + if (player.isInFunEvent())
  1598. + return;
  1599.  
  1600. if (!player.isDead())
  1601. return;
  1602. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  1603. ===================================================================
  1604. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 4)
  1605. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
  1606. @@ -26,6 +26,13 @@
  1607. player.sendPacket(ActionFailed.STATIC_PACKET);
  1608. return;
  1609. }
  1610. +
  1611. + if (player.isInFunEvent())
  1612. + {
  1613. + player.sendMessage("You can not exit the event.");
  1614. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1615. + return;
  1616. + }
  1617.  
  1618. if (player.isInsideZone(ZoneId.NO_RESTART))
  1619. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement