Guest User

TvT aCis 382

a guest
Jul 14th, 2019
747
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/actor/Player.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/actor/Player.java (revision 1)
  6. +++ java/net/sf/l2j/gameserver/model/actor/Player.java (working copy)
  7. @@ -124,6 +124,7 @@
  8. import net.sf.l2j.gameserver.model.craft.ManufactureList;
  9. import net.sf.l2j.gameserver.model.entity.Castle;
  10. import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  11. +import net.sf.l2j.gameserver.model.entity.events.impl.Event;
  12. import net.sf.l2j.gameserver.model.entity.Siege;
  13. import net.sf.l2j.gameserver.model.group.CommandChannel;
  14. import net.sf.l2j.gameserver.model.group.Party;
  15. @@ -356,6 +357,7 @@
  16. private boolean _isSitting;
  17.  
  18. private final Location _savedLocation = new Location(0, 0, 0);
  19. + private Location _originalCoordinates;
  20.  
  21. private int _recomHave;
  22. private int _recomLeft;
  23. @@ -457,6 +459,7 @@
  24. private final BlockList _blockList = new BlockList(this);
  25.  
  26. private TeamType _team = TeamType.NONE;
  27. + private Event _event;
  28.  
  29. private int _alliedVarkaKetra; // lvl of alliance with ketra orcs or varka silenos, used in quests and aggro checks [-5,-1] varka, 0 neutral, [1,5] ketra
  30.  
  31. @@ -3505,39 +3508,54 @@
  32. {
  33. Player pk = killer.getActingPlayer();
  34.  
  35. - // Clear resurrect xp calculation
  36. - setExpBeforeDeath(0);
  37. + if (pk != null)
  38. + {
  39. + // Player is in event and killed
  40. + Event event = pk.getEvent();
  41. + if (event != null && event.isStarted())
  42. + event.onKill(pk, this);
  43. + }
  44.  
  45. - if (isCursedWeaponEquipped())
  46. - CursedWeaponManager.getInstance().drop(_cursedWeaponEquippedId, killer);
  47. + // Player is in event and died
  48. + Event event = getEvent();
  49. + if (event != null && event.isStarted())
  50. + event.onDie(this);
  51. else
  52. {
  53. - if (pk == null || !pk.isCursedWeaponEquipped())
  54. + // Clear resurrect xp calculation
  55. + setExpBeforeDeath(0);
  56. +
  57. + if (isCursedWeaponEquipped())
  58. + CursedWeaponManager.getInstance().drop(_cursedWeaponEquippedId, killer);
  59. + else
  60. {
  61. - onDieDropItem(killer); // Check if any item should be dropped
  62. -
  63. - // if the area isn't an arena
  64. - if (!isInArena())
  65. + if (pk == null || !pk.isCursedWeaponEquipped())
  66. {
  67. - // if both victim and attacker got clans & aren't academicians
  68. - if (pk != null && pk.getClan() != null && getClan() != null && !isAcademyMember() && !pk.isAcademyMember())
  69. + onDieDropItem(killer); // Check if any item should be dropped
  70. +
  71. + // if the area isn't an arena
  72. + if (!isInArena())
  73. {
  74. - // if clans got mutual war, then use the reputation calcul
  75. - if (_clan.isAtWarWith(pk.getClanId()) && pk.getClan().isAtWarWith(_clan.getClanId()))
  76. + // if both victim and attacker got clans & aren't academicians
  77. + if (pk != null && pk.getClan() != null && getClan() != null && !isAcademyMember() && !pk.isAcademyMember())
  78. {
  79. - // when your reputation score is 0 or below, the other clan cannot acquire any reputation points
  80. - if (getClan().getReputationScore() > 0)
  81. - pk.getClan().addReputationScore(1);
  82. - // when the opposing sides reputation score is 0 or below, your clans reputation score doesn't decrease
  83. - if (pk.getClan().getReputationScore() > 0)
  84. - _clan.takeReputationScore(1);
  85. + // if clans got mutual war, then use the reputation calcul
  86. + if (_clan.isAtWarWith(pk.getClanId()) && pk.getClan().isAtWarWith(_clan.getClanId()))
  87. + {
  88. + // when your reputation score is 0 or below, the other clan cannot acquire any reputation points
  89. + if (getClan().getReputationScore() > 0)
  90. + pk.getClan().addReputationScore(1);
  91. + // when the opposing sides reputation score is 0 or below, your clans reputation score doesn't decrease
  92. + if (pk.getClan().getReputationScore() > 0)
  93. + _clan.takeReputationScore(1);
  94. + }
  95. }
  96. }
  97. +
  98. + // Reduce player's xp and karma.
  99. + if (Config.ALT_GAME_DELEVEL && (!hasSkill(L2Skill.SKILL_LUCKY) || getStat().getLevel() > 9))
  100. + deathPenalty(pk != null && getClan() != null && pk.getClan() != null && (getClan().isAtWarWith(pk.getClanId()) || pk.getClan().isAtWarWith(getClanId())), pk != null, killer instanceof SiegeGuard);
  101. }
  102. -
  103. - // Reduce player's xp and karma.
  104. - if (Config.ALT_GAME_DELEVEL && (!hasSkill(L2Skill.SKILL_LUCKY) || getStat().getLevel() > 9))
  105. - deathPenalty(pk != null && getClan() != null && pk.getClan() != null && (getClan().isAtWarWith(pk.getClanId()) || pk.getClan().isAtWarWith(getClanId())), pk != null, killer instanceof SiegeGuard);
  106. }
  107. }
  108. }
  109. @@ -4597,6 +4615,12 @@
  110. return false;
  111. }
  112.  
  113. + if (getEvent() != null)
  114. + {
  115. + sendMessage("Cannot mount while in event.");
  116. + return false;
  117. + }
  118. +
  119. if (!MathUtil.checkIfInRange(200, this, summon, true))
  120. {
  121. sendPacket(SystemMessageId.TOO_FAR_AWAY_FROM_STRIDER_TO_MOUNT);
  122. @@ -7136,6 +7172,16 @@
  123. return !_isInOlympiadMode && !_savedLocation.equals(Location.DUMMY_LOC);
  124. }
  125.  
  126. + public Location getOriginalCoordinates()
  127. + {
  128. + return _originalCoordinates;
  129. + }
  130. +
  131. + public void setOriginalCoordinates(Location originalCoordinates)
  132. + {
  133. + _originalCoordinates = originalCoordinates;
  134. + }
  135. +
  136. public int getTeleMode()
  137. {
  138. return _teleMode;
  139. @@ -7387,6 +7433,17 @@
  140. return _lvlJoinedAcademy > 0;
  141. }
  142.  
  143. + @Override
  144. + public Event getEvent()
  145. + {
  146. + return _event;
  147. + }
  148. +
  149. + public void setEvent(Event event)
  150. + {
  151. + _event = event;
  152. + }
  153. +
  154. public void setTeam(TeamType team)
  155. {
  156. _team = team;
  157. @@ -8137,11 +8200,16 @@
  158. GameTimeTaskManager.getInstance().remove(this);
  159. ShadowItemTaskManager.getInstance().remove(this);
  160.  
  161. + // Player is in event
  162. + Event event = getEvent();
  163. + if (event != null)
  164. + event.removePlayer(this);
  165. +
  166. // Cancel the cast of eventual fusion skill users on this target.
  167. for (Creature character : getKnownType(Creature.class))
  168. if (character.getFusionSkill() != null && character.getFusionSkill().getTarget() == this)
  169. character.abortCast();
  170. -
  171. +
  172. // Stop signets & toggles effects.
  173. for (L2Effect effect : getAllEffects())
  174. {
  175. Index: java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java
  176. ===================================================================
  177. --- java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java (revision 1)
  178. +++ java/net/sf/l2j/gameserver/model/actor/instance/SchemeBuffer.java (working copy)
  179. @@ -31,7 +31,13 @@
  180. {
  181. StringTokenizer st = new StringTokenizer(command, " ");
  182. String currentCommand = st.nextToken();
  183. -
  184. +
  185. + if (player.getEvent() != null)
  186. + {
  187. + player.sendMessage("Cheater wait for the event to buff you.");
  188. + return;
  189. + }
  190. +
  191. if (currentCommand.startsWith("menu"))
  192. {
  193. final NpcHtmlMessage html = new NpcHtmlMessage(0);
  194. Index: java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  195. ===================================================================
  196. --- java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (revision 1)
  197. +++ java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (working copy)
  198. @@ -13,6 +13,7 @@
  199. import net.sf.l2j.gameserver.model.actor.Npc;
  200. import net.sf.l2j.gameserver.model.actor.Player;
  201. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  202. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  203. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  204. import net.sf.l2j.gameserver.network.serverpackets.ConfirmDlg;
  205. import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  206. @@ -120,7 +121,8 @@
  207. }
  208.  
  209. // Simple checks to avoid exploits
  210. - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  211. + Event event = partner.getEvent();
  212. + if (event != null && event.isStarted() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  213. {
  214. player.sendMessage("Due to the current partner's status, the teleportation failed.");
  215. return;
  216. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  217. ===================================================================
  218. --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 1)
  219. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
  220. @@ -14,6 +14,7 @@
  221. import net.sf.l2j.gameserver.model.actor.instance.ChristmasTree;
  222. import net.sf.l2j.gameserver.model.actor.instance.Pet;
  223. import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  224. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  225. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  226. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  227. import net.sf.l2j.gameserver.model.spawn.L2Spawn;
  228. @@ -45,6 +46,13 @@
  229. if (player.isAllSkillsDisabled() || player.isCastingNow())
  230. return;
  231.  
  232. + Event event = player.getEvent();
  233. + if (event != null && event.isStarted())
  234. + {
  235. + player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  236. + return;
  237. + }
  238. +
  239. final IntIntHolder sitem = SummonItemData.getInstance().getSummonItem(item.getItemId());
  240.  
  241. if ((player.getSummon() != null || player.isMounted()) && sitem.getValue() > 0)
  242. Index: java/net/sf/l2j/gameserver/model/entity/event/TvTEvent.java
  243. ===================================================================
  244. --- java/net/sf/l2j/gameserver/model/entity/event/TvTEvent.java (revision 0)
  245. +++ java/net/sf/l2j/gameserver/model/entity/event/TvTEvent.java (working copy)
  246. @@ -0,0 +1,657 @@
  247. +package net.sf.l2j.gameserver.model.entity.event;
  248. +
  249. +import java.util.List;
  250. +import java.util.concurrent.CopyOnWriteArrayList;
  251. +import java.util.concurrent.ScheduledFuture;
  252. +import java.util.logging.Logger;
  253. +
  254. +import net.sf.l2j.commons.concurrent.ThreadPool;
  255. +import net.sf.l2j.commons.random.Rnd;
  256. +
  257. +import net.sf.l2j.Config;
  258. +import net.sf.l2j.gameserver.data.sql.SpawnTable;
  259. +import net.sf.l2j.gameserver.data.xml.DoorData;
  260. +import net.sf.l2j.gameserver.data.xml.MapRegionData;
  261. +import net.sf.l2j.gameserver.data.xml.NpcData;
  262. +import net.sf.l2j.gameserver.enums.EventState;
  263. +import net.sf.l2j.gameserver.enums.MessageType;
  264. +import net.sf.l2j.gameserver.enums.TeamType;
  265. +import net.sf.l2j.gameserver.model.World;
  266. +import net.sf.l2j.gameserver.model.actor.Creature;
  267. +import net.sf.l2j.gameserver.model.actor.Npc;
  268. +import net.sf.l2j.gameserver.model.actor.Player;
  269. +import net.sf.l2j.gameserver.model.actor.Summon;
  270. +import net.sf.l2j.gameserver.model.actor.instance.Door;
  271. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  272. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  273. +import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  274. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  275. +import net.sf.l2j.gameserver.model.group.Party;
  276. +import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  277. +import net.sf.l2j.gameserver.model.location.Location;
  278. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  279. +import net.sf.l2j.gameserver.model.spawn.L2Spawn;
  280. +import net.sf.l2j.gameserver.network.serverpackets.ChangeWaitType;
  281. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  282. +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  283. +
  284. +/**
  285. + * @author DnR
  286. + */
  287. +public class TvTEvent extends Event
  288. +{
  289. + protected static Logger _log = Logger.getLogger(TvTEvent.class.getName());
  290. +
  291. + // TvT related lists
  292. + private List<Player> _registered = new CopyOnWriteArrayList<>();
  293. + private List<Player> _blueTeam = new CopyOnWriteArrayList<>();
  294. + private List<Player> _redTeam = new CopyOnWriteArrayList<>();
  295. +
  296. + private Npc _npcManager;
  297. +
  298. + public ScheduledFuture<?> _registrationTask = null;
  299. +
  300. + /**
  301. + * Loads all configuration settings and started event if needed.
  302. + */
  303. + private TvTEvent()
  304. + {
  305. + // Event has already started, so do not reload anything
  306. + if (_state == EventState.STARTED)
  307. + return;
  308. +
  309. + // Clean up
  310. + _registered.clear();
  311. + _redTeam.clear();
  312. + _blueTeam.clear();
  313. +
  314. + if (Config.TVT_ENABLE)
  315. + {
  316. + _log.info("TvT Event: Initialized Event");
  317. +
  318. + if (_state == EventState.INITIAL || _state == EventState.SCHEDULED_NEXT)
  319. + {
  320. + _state = EventState.INITIAL;
  321. + scheduleRegistration();
  322. + }
  323. + }
  324. + }
  325. +
  326. + /**
  327. + * Schedules event registration.
  328. + */
  329. + private void scheduleRegistration()
  330. + {
  331. + // If registration task is currently running, cancel it now
  332. + if (_registrationTask != null)
  333. + {
  334. + _registrationTask.cancel(false);
  335. + _registrationTask = null;
  336. + }
  337. +
  338. + // Delete registration NPC if spawned
  339. + if (_npcManager != null)
  340. + {
  341. + if (_npcManager.isVisible())
  342. + _npcManager.deleteMe();
  343. + }
  344. +
  345. + // Start task
  346. + if (Config.TVT_ENABLE)
  347. + {
  348. + if (_state != EventState.SCHEDULED_NEXT)
  349. + {
  350. + // Set state
  351. + _state = EventState.SCHEDULED_NEXT;
  352. +
  353. + World.announceToOnlinePlayers("TvT Event: Next event in " + (Config.EVENT_DELAY / 60) + " minute(s)", true);
  354. + _log.info("TvT Event: Next event in " + (Config.EVENT_DELAY / 60) + " minute(s)");
  355. + _registrationTask = ThreadPool.schedule(new RegistrationTask(), Config.EVENT_DELAY * 1000L);
  356. + }
  357. + }
  358. + }
  359. +
  360. + /**
  361. + * Starts event cycle.
  362. + */
  363. + protected void scheduleEvent()
  364. + {
  365. + // Set state
  366. + _state = EventState.REGISTER;
  367. +
  368. + // Spawn TvT manager NPC
  369. + try
  370. + {
  371. + final NpcTemplate template = NpcData.getInstance().getTemplate(Config.TVT_NPC_ID);
  372. + final L2Spawn spawn = new L2Spawn(template);
  373. + spawn.setLoc(Config.TVT_NPC_LOCATION.getX(), Config.TVT_NPC_LOCATION.getY(), Config.TVT_NPC_LOCATION.getZ(), 0);
  374. + spawn.setRespawnDelay(60000);
  375. + spawn.setRespawnState(false);
  376. +
  377. + SpawnTable.getInstance().addSpawn(spawn, false);
  378. +
  379. + _npcManager = spawn.doSpawn(false);
  380. + _npcManager.broadcastPacket(new MagicSkillUse(_npcManager, _npcManager, 1034, 1, 1, 1));
  381. + }
  382. + catch (Exception e)
  383. + {
  384. + return;
  385. + }
  386. +
  387. + World.announceToOnlinePlayers("TvT Event: Registration opened for " + (Config.PARTICIPATION_TIME / 60) + " minute(s).", true);
  388. + World.announceToOnlinePlayers("TvT Event: Recruiting levels: " + Config.MIN_LEVEL + " to " + Config.MAX_LEVEL + ".", true);
  389. + World.announceToOnlinePlayers("TvT Event: Max players in team: "+ Config.MAX_PARTICIOANTS +".", true);
  390. + World.announceToOnlinePlayers("TvT Event: Commands /register /unregister.", true);
  391. +
  392. + for (IntIntHolder reward: Config.TVT_REWARDS)
  393. + World.announceToOnlinePlayers("TvT Event: Reward "+reward.getId() +","+reward.getValue(), true);
  394. +
  395. + // Start timer
  396. + eventTimer(Config.PARTICIPATION_TIME);
  397. +
  398. + if ((_registered.size() >= Config.MIN_PARTICIOANTS) && (_state != EventState.INITIAL))
  399. + {
  400. + // Close doors
  401. + toggleArenaDoors(false);
  402. +
  403. + // Port players and start event
  404. + World.announceToOnlinePlayers("TvT Event: Event has started!", true);
  405. + portTeamsToArena();
  406. + eventTimer(Config.EVENT_DURATION);
  407. +
  408. + if (_state == EventState.INITIAL)
  409. + World.announceToOnlinePlayers("TvT Event: Event was cancelled.", true);
  410. + else
  411. + World.announceToOnlinePlayers("TvT Event: Blue Team kills: " + _blueTeamKills + " , Red Team kills: " + _redTeamKills + ".", true);
  412. +
  413. + // Shutting down event
  414. + eventRemovals();
  415. + }
  416. + else
  417. + {
  418. + if (_state == EventState.INITIAL)
  419. + World.announceToOnlinePlayers("TvT Event: Event was cancelled.", true);
  420. + else
  421. + World.announceToOnlinePlayers("TvT Event: Event was cancelled due to lack of participation.", true);
  422. +
  423. + _registered.clear();
  424. + }
  425. +
  426. + // Open doors
  427. + toggleArenaDoors(true);
  428. +
  429. + _state = EventState.INITIAL;
  430. +
  431. + // Schedule next registration
  432. + scheduleRegistration();
  433. + }
  434. +
  435. + /**
  436. + * Handles arena doors open state.
  437. + * @param open
  438. + */
  439. + private static void toggleArenaDoors(boolean open)
  440. + {
  441. + for (int doorId : Config.TVT_DOOR_IDS)
  442. + {
  443. + final Door door = DoorData.getInstance().getDoor(doorId);
  444. + if (door != null)
  445. + {
  446. + if (open)
  447. + door.openMe();
  448. + else
  449. + door.closeMe();
  450. + }
  451. + }
  452. + }
  453. +
  454. + /**
  455. + * Cleans up and finishes event.
  456. + */
  457. + private void eventRemovals()
  458. + {
  459. + // Blue team
  460. + for (Player blue : _blueTeam)
  461. + {
  462. + if (blue == null)
  463. + continue;
  464. +
  465. + // Give rewards
  466. + if (_state != EventState.INITIAL && (_blueTeamKills > _redTeamKills || _blueTeamKills == _redTeamKills && Config.REWARD_DIE))
  467. + {
  468. + for (IntIntHolder reward : Config.TVT_REWARDS)
  469. + {
  470. + if (reward == null)
  471. + continue;
  472. +
  473. + blue.addItem("TvTReward", reward.getId(), reward.getValue(), null, true);
  474. + }
  475. + }
  476. +
  477. + if (blue.isDead())
  478. + blue.doRevive();
  479. +
  480. + removePlayer(blue);
  481. + blue.teleToLocation(blue.getOriginalCoordinates());
  482. + }
  483. +
  484. + // Red team
  485. + for (Player red : _redTeam)
  486. + {
  487. + if (red == null)
  488. + continue;
  489. +
  490. + // Give rewards
  491. + if (_state != EventState.INITIAL && (_blueTeamKills < _redTeamKills || _blueTeamKills == _redTeamKills && Config.REWARD_DIE))
  492. + {
  493. + for (IntIntHolder reward : Config.TVT_REWARDS)
  494. + {
  495. + if (reward == null)
  496. + continue;
  497. +
  498. + red.addItem("TvTReward", reward.getId(), reward.getValue(), null, true);
  499. + }
  500. + }
  501. +
  502. + if (red.isDead())
  503. + red.doRevive();
  504. +
  505. + removePlayer(red);
  506. + red.teleToLocation(red.getOriginalCoordinates());
  507. + }
  508. +
  509. + // Event ended in a tie and no rewards will be given
  510. + if (_blueTeamKills == _redTeamKills && !Config.REWARD_DIE)
  511. + World.announceToOnlinePlayers("TvT Event: Event ended in a Tie. No rewards will be given!", true);
  512. +
  513. + _blueTeam.clear();
  514. + _redTeam.clear();
  515. + _blueTeamKills = 0;
  516. + _redTeamKills = 0;
  517. + }
  518. +
  519. + /**
  520. + * Event timer.
  521. + *
  522. + * @param time
  523. + */
  524. + private void eventTimer(int time)
  525. + {
  526. + for (int seconds = time; (seconds > 0 && _state != EventState.INITIAL); seconds--)
  527. + {
  528. + switch (seconds)
  529. + {
  530. + case 3600:
  531. + if (_state == EventState.STARTED)
  532. + World.announceToOnlinePlayers("TvT Event: " + (seconds / 60) + " hour(s) until event is finished!", true);
  533. + else
  534. + World.announceToOnlinePlayers("TvT Event: " + (seconds / 60) + " hour(s) until registration is closed!", true);
  535. + break;
  536. +
  537. + case 1800: // 30 minutes left
  538. + case 900: // 15 minutes left
  539. + case 600: // 10 minutes left
  540. + case 300: // 5 minutes left
  541. + case 240: // 4 minutes left
  542. + case 180: // 3 minutes left
  543. + case 120: // 2 minutes left
  544. + case 60: // 1 minute left
  545. + if (_state == EventState.STARTED)
  546. + World.announceToOnlinePlayers("TvT Event: " + (seconds / 60) + " minute(s) until event is finished!", true);
  547. + else
  548. + World.announceToOnlinePlayers("TvT Event: " + (seconds / 60) + " minute(s) until registration is closed!", true);
  549. + break;
  550. + case 30: // 30 seconds left
  551. + case 15: // 15 seconds left
  552. + case 5:// 5 seconds left
  553. + if (_state == EventState.STARTED)
  554. + World.announceToOnlinePlayers("TvT Event: " + seconds + " second(s) until event is finished!", true);
  555. + else
  556. + World.announceToOnlinePlayers("TvT Event: " + seconds + " second(s) until registration is closed!", true);
  557. + break;
  558. + }
  559. +
  560. + long oneSecWaitStart = System.currentTimeMillis();
  561. + while ((oneSecWaitStart + 1000L) > System.currentTimeMillis())
  562. + {
  563. + try
  564. + {
  565. + Thread.sleep(1);
  566. + }
  567. + catch (InterruptedException ie)
  568. + {
  569. + }
  570. + }
  571. + }
  572. + }
  573. +
  574. + /**
  575. + * Ports teams to arena.
  576. + */
  577. + private void portTeamsToArena()
  578. + {
  579. + while (_registered.size() > 0)
  580. + {
  581. + Player player = _registered.get(Rnd.get(_registered.size()));
  582. +
  583. + // First create 2 event teams
  584. + if (_blueTeam.size() > _redTeam.size())
  585. + {
  586. + _redTeam.add(player);
  587. + player.setTeam(TeamType.RED);
  588. + }
  589. + else
  590. + {
  591. + _blueTeam.add(player);
  592. + player.setTeam(TeamType.BLUE);
  593. + }
  594. +
  595. + // Abort casting if player casting
  596. + if (player.isCastingNow())
  597. + player.abortCast();
  598. +
  599. + player.getAppearance().setVisible();
  600. +
  601. + if (player.isDead())
  602. + player.doRevive();
  603. + else
  604. + {
  605. + player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
  606. + player.setCurrentCp(player.getMaxCp());
  607. + }
  608. +
  609. + // Remove Buffs
  610. + player.stopAllEffectsExceptThoseThatLastThroughDeath();
  611. +
  612. + // stop any cubic that has been given by other player.
  613. + player.stopCubicsByOthers();
  614. +
  615. + // Dismount player, if mounted.
  616. + if (player.isMounted())
  617. + player.dismount();
  618. + // Test summon existence, if any.
  619. + else
  620. + {
  621. + final Summon summon = player.getSummon();
  622. +
  623. + // Unsummon pets directly.
  624. + if (summon instanceof Pet)
  625. + summon.unSummon(player);
  626. + // Remove servitor buffs and cancel animations.
  627. + else if (summon != null)
  628. + {
  629. + summon.stopAllEffectsExceptThoseThatLastThroughDeath();
  630. + summon.abortAttack();
  631. + summon.abortCast();
  632. + }
  633. + }
  634. +
  635. + // Remove player from his party
  636. + if (player.getParty() != null)
  637. + {
  638. + Party party = player.getParty();
  639. + party.removePartyMember(player, MessageType.EXPELLED);
  640. + }
  641. +
  642. + // Remove Duel State
  643. + if (player.isInDuel())
  644. + player.setDuelState(DuelState.INTERRUPTED);
  645. +
  646. + Location playerCoordinates = new Location(player.getPosition());
  647. + player.setOriginalCoordinates(playerCoordinates);
  648. + player.sendMessage("You have been teleported.");
  649. +
  650. + _registered.remove(player);
  651. + }
  652. +
  653. + _state = EventState.STARTED;
  654. +
  655. + // Port teams
  656. + for (Player blue : _blueTeam)
  657. + {
  658. + if (blue == null)
  659. + continue;
  660. +
  661. + blue.teleToLocation(Config.TVT_BLUE_SPAWN_LOCATION);
  662. + }
  663. +
  664. + for (Player red : _redTeam)
  665. + {
  666. + if (red == null)
  667. + continue;
  668. +
  669. + red.teleToLocation(Config.TVT_RED_SPAWN_LOCATION);
  670. + }
  671. + }
  672. +
  673. + /**
  674. + * Registers player to event.
  675. + *
  676. + * @param player
  677. + */
  678. + @Override
  679. + public void registerPlayer(Player player)
  680. + {
  681. + if (_state != EventState.REGISTER)
  682. + {
  683. + player.sendMessage("TvT Registration is not in progress.");
  684. + return;
  685. + }
  686. +
  687. + if (player.isFestivalParticipant())
  688. + {
  689. + player.sendMessage("Festival participants cannot register to the event.");
  690. + return;
  691. + }
  692. +
  693. + if (player.isInJail())
  694. + {
  695. + player.sendMessage("Jailed players cannot register to the event.");
  696. + return;
  697. + }
  698. +
  699. + if (player.isDead())
  700. + {
  701. + player.sendMessage("Dead players cannot register to the event.");
  702. + return;
  703. + }
  704. +
  705. + if (OlympiadManager.getInstance().isRegisteredInComp(player))
  706. + {
  707. + player.sendMessage("Grand Olympiad participants cannot register to the event.");
  708. + return;
  709. + }
  710. +
  711. + if ((player.getLevel() < Config.MIN_LEVEL) || (player.getLevel() > Config.MAX_LEVEL))
  712. + {
  713. + player.sendMessage("You have not reached the appropriate level to join the event.");
  714. + return;
  715. + }
  716. +
  717. + if (_registered.size() == Config.MAX_PARTICIOANTS)
  718. + {
  719. + player.sendMessage("There is no more room for you to register to the event.");
  720. + return;
  721. + }
  722. +
  723. + for (Player registered : _registered)
  724. + {
  725. + if (registered == null)
  726. + continue;
  727. +
  728. + if (registered.getObjectId() == player.getObjectId())
  729. + {
  730. + player.sendMessage("You are already registered in the TvT event.");
  731. + return;
  732. + }
  733. +
  734. + // Check if dual boxing is not allowed
  735. + if (!Config.DUAL_BOX)
  736. + {
  737. + if ((registered.getClient() == null) || (player.getClient() == null))
  738. + continue;
  739. +
  740. + String ip1 = player.getClient().getConnection().getInetAddress().getHostAddress();
  741. + String ip2 = registered.getClient().getConnection().getInetAddress().getHostAddress();
  742. + if ((ip1 != null) && (ip2 != null) && ip1.equals(ip2))
  743. + {
  744. + player.sendMessage("Your IP is already registered in the TvT event.");
  745. + return;
  746. + }
  747. + }
  748. + }
  749. +
  750. + _registered.add(player);
  751. +
  752. + player.sendMessage("You have registered to participate in the TvT Event.");
  753. +
  754. + super.registerPlayer(player);
  755. + }
  756. +
  757. + /**
  758. + * Removes player from event.
  759. + *
  760. + * @param player
  761. + */
  762. + @Override
  763. + public void removePlayer(Player player)
  764. + {
  765. + if (_registered.contains(player))
  766. + {
  767. + _registered.remove(player);
  768. + player.sendMessage("You have been removed from the TvT Event registration list.");
  769. + }
  770. + else if (player.getTeam() == TeamType.BLUE)
  771. + _blueTeam.remove(player);
  772. + else if (player.getTeam() == TeamType.RED)
  773. + _redTeam.remove(player);
  774. +
  775. + // If no participants left, abort event
  776. + if ((player.getTeam().getId() > 0) && (_blueTeam.size() == 0) && (_redTeam.size() == 0))
  777. + _state = EventState.INITIAL;
  778. +
  779. + // Now, remove team status
  780. + player.setTeam(TeamType.NONE);
  781. +
  782. + super.removePlayer(player);
  783. + }
  784. +
  785. + @Override
  786. + public boolean isRegistered(Player player)
  787. + {
  788. + return _registered.contains(player);
  789. + }
  790. +
  791. + public List<Player> getBlueTeam()
  792. + {
  793. + return _blueTeam;
  794. + }
  795. +
  796. + public List<Player> getRedTeam()
  797. + {
  798. + return _redTeam;
  799. + }
  800. +
  801. + public List<Player> getRegistered()
  802. + {
  803. + return _registered;
  804. + }
  805. +
  806. + class RegistrationTask implements Runnable
  807. + {
  808. + public RegistrationTask()
  809. + {
  810. + }
  811. +
  812. + @Override
  813. + public void run()
  814. + {
  815. + if (Config.TVT_ENABLE)
  816. + scheduleEvent();
  817. + else
  818. + _state = EventState.INITIAL; // Default state
  819. + }
  820. + }
  821. +
  822. + @Override
  823. + public void onDie(Creature creature)
  824. + {
  825. + if (creature == null)
  826. + return;
  827. +
  828. + if (creature instanceof Player)
  829. + {
  830. + final Player player = ((Player) creature);
  831. +
  832. + player.broadcastPacket(new ChangeWaitType(player, ChangeWaitType.WT_START_FAKEDEATH));
  833. +
  834. + player.sendMessage("You will be respawned in " + Config.PLAYER_RESPAWN_DELAY + " seconds.");
  835. + ThreadPool.schedule(new Runnable()
  836. + {
  837. + @Override
  838. + public void run()
  839. + {
  840. + if (!player.isDead())
  841. + return;
  842. +
  843. + player.doRevive();
  844. +
  845. + if (player.getTeam() == TeamType.BLUE)
  846. + player.teleToLocation(Config.TVT_BLUE_SPAWN_LOCATION);
  847. + else if (player.getTeam() == TeamType.RED)
  848. + player.teleToLocation(Config.TVT_RED_SPAWN_LOCATION);
  849. + // Player has probably left event for some reason
  850. + else
  851. + player.teleportTo(MapRegionData.TeleportType.TOWN);
  852. + }
  853. + }, Config.PLAYER_RESPAWN_DELAY * 1000L);
  854. + }
  855. + }
  856. +
  857. + @Override
  858. + public void onKill(Player player, Player target)
  859. + {
  860. + if (player == null || target == null)
  861. + return;
  862. +
  863. + // Increase kills only if victim belonged to enemy team
  864. + if (player.getTeam() == TeamType.BLUE && target.getTeam() == TeamType.RED)
  865. + _blueTeamKills++;
  866. + else if (player.getTeam() == TeamType.RED && target.getTeam() == TeamType.BLUE)
  867. + _redTeamKills++;
  868. +
  869. + player.sendPacket(new PlaySound(0, "ItemSound.quest_itemget"));
  870. + player.broadcastTitleInfo();
  871. + player.broadcastUserInfo();
  872. + }
  873. +
  874. + @Override
  875. + public void onRevive(Creature creature)
  876. + {
  877. + if (creature == null)
  878. + return;
  879. +
  880. + // Heal Player fully
  881. + creature.setCurrentHpMp(creature.getMaxHp(), creature.getMaxMp());
  882. + creature.setCurrentCp(creature.getMaxCp());
  883. +
  884. + ChangeWaitType revive = new ChangeWaitType(creature, ChangeWaitType.WT_STOP_FAKEDEATH);
  885. + creature.broadcastPacket(revive);
  886. + }
  887. +
  888. + @Override
  889. + public boolean canTarget(Player player, Player target)
  890. + {
  891. + return true;
  892. + }
  893. +
  894. + public static final TvTEvent getInstance()
  895. + {
  896. + return SingletonHolder.INSTANCE;
  897. + }
  898. +
  899. + private static class SingletonHolder
  900. + {
  901. + protected static final TvTEvent INSTANCE = new TvTEvent();
  902. + }
  903. +}
  904. \ No newline at end of file
  905. Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
  906. ===================================================================
  907. --- java/net/sf/l2j/gameserver/model/actor/Creature.java (revision 1)
  908. +++ java/net/sf/l2j/gameserver/model/actor/Creature.java (working copy)
  909. @@ -50,6 +50,7 @@
  910. import net.sf.l2j.gameserver.model.actor.stat.CreatureStat;
  911. import net.sf.l2j.gameserver.model.actor.status.CreatureStatus;
  912. import net.sf.l2j.gameserver.model.actor.template.CreatureTemplate;
  913. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  914. import net.sf.l2j.gameserver.model.group.Party;
  915. import net.sf.l2j.gameserver.model.holder.SkillUseHolder;
  916. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  917. @@ -372,6 +373,12 @@
  918. {
  919. // default implementation
  920. }
  921. +
  922. + public Event getEvent()
  923. + {
  924. + // Overridden in Player
  925. + return null;
  926. + }
  927.  
  928. /**
  929. * Instantly teleport this {@link Creature} to defined coordinates X/Y/Z.<br>
  930. @@ -1469,6 +1476,10 @@
  931.  
  932. setIsDead(true);
  933. }
  934. +
  935. + Event event = getEvent();
  936. + if (event != null && event.isStarted())
  937. + event.onDie(this);
  938.  
  939. // Set target to null and cancel Attack or Cast
  940. setTarget(null);
  941. @@ -1488,7 +1499,7 @@
  942. // Notify Creature AI
  943. if (hasAI())
  944. getAI().notifyEvent(AiEventType.DEAD, null);
  945. -
  946. +
  947. return true;
  948. }
  949.  
  950. @@ -1519,6 +1530,10 @@
  951.  
  952. // Start broadcast status
  953. broadcastPacket(new Revive(this));
  954. +
  955. + Event event = getEvent();
  956. + if (event != null && event.isStarted())
  957. + event.onRevive(this);
  958. }
  959.  
  960. /**
  961. Index: java/net/sf/l2j/gameserver/data/manager/DimensionalRiftManager.java
  962. ===================================================================
  963. --- java/net/sf/l2j/gameserver/data/manager/DimensionalRiftManager.java (revision 1)
  964. +++ java/net/sf/l2j/gameserver/data/manager/DimensionalRiftManager.java (working copy)
  965. @@ -175,7 +175,13 @@
  966. showHtmlFile(player, "data/html/seven_signs/rift/NoParty.htm", npc);
  967. return;
  968. }
  969. -
  970. +
  971. + if (player.getEvent() != null)
  972. + {
  973. + player.sendMessage("Somebody among the party members has registered to participate in an event.");
  974. + return;
  975. + }
  976. +
  977. // Player isn't the party leader.
  978. if (!party.isLeader(player))
  979. {
  980. Index: java/net/sf/l2j/gameserver/model/actor/Playable.java
  981. ===================================================================
  982. --- java/net/sf/l2j/gameserver/model/actor/Playable.java (revision 1)
  983. +++ java/net/sf/l2j/gameserver/model/actor/Playable.java (working copy)
  984. @@ -13,6 +13,7 @@
  985. import net.sf.l2j.gameserver.model.actor.stat.PlayableStat;
  986. import net.sf.l2j.gameserver.model.actor.status.PlayableStatus;
  987. import net.sf.l2j.gameserver.model.actor.template.CreatureTemplate;
  988. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  989. import net.sf.l2j.gameserver.network.SystemMessageId;
  990. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  991. import net.sf.l2j.gameserver.network.serverpackets.Revive;
  992. @@ -132,6 +133,10 @@
  993.  
  994. // Notify Creature AI
  995. getAI().notifyEvent(AiEventType.DEAD);
  996. +
  997. + Event event = getEvent();
  998. + if (event != null && event.isStarted())
  999. + event.onDie(this);
  1000.  
  1001. // Notify Quest of L2Playable's death
  1002. final Player actingPlayer = getActingPlayer();
  1003. @@ -141,7 +146,7 @@
  1004. if (killer != null)
  1005. {
  1006. final Player player = killer.getActingPlayer();
  1007. - if (player != null)
  1008. + if (player != null && (player.getEvent() == null || !player.getEvent().isStarted()))
  1009. player.onKillUpdatePvPKarma(this);
  1010. }
  1011.  
  1012. @@ -168,6 +173,10 @@
  1013.  
  1014. // Start broadcast status
  1015. broadcastPacket(new Revive(this));
  1016. +
  1017. + Event event = getEvent();
  1018. + if (event != null && event.isStarted())
  1019. + event.onRevive(this);
  1020. }
  1021.  
  1022. public boolean checkIfPvP(Playable target)
  1023. Index: java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java
  1024. ===================================================================
  1025. --- java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java (revision 1)
  1026. +++ java/net/sf/l2j/gameserver/network/serverpackets/UserInfo.java (working copy)
  1027. @@ -7,6 +7,7 @@
  1028. import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
  1029. import net.sf.l2j.gameserver.model.actor.Player;
  1030. import net.sf.l2j.gameserver.model.actor.Summon;
  1031. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1032. import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
  1033.  
  1034. public class UserInfo extends L2GameServerPacket
  1035. @@ -171,8 +172,13 @@
  1036. writeD(_player.getAppearance().getFace());
  1037. writeD((_player.isGM()) ? 1 : 0);
  1038.  
  1039. - writeS((_player.getPolyType() != PolyType.DEFAULT) ? "Morphed" : _player.getTitle());
  1040. + String name = ((_player.getPolyType() != PolyType.DEFAULT) ? "Morphed" : _player.getTitle());
  1041. +
  1042. + Event event = _player.getEvent();
  1043. + if (event != null && event.isStarted())
  1044. + name = ((_player.getTeam() == TeamType.BLUE) ? "Kills: " + _player.getEvent().getBlueTeamKills() : (_player.getTeam() == TeamType.RED) ? "Kills: " + _player.getEvent().getRedTeamKills() : _player.getTitle());
  1045.  
  1046. + writeS(name);
  1047. writeD(_player.getClanId());
  1048. writeD(_player.getClanCrestId());
  1049. writeD(_player.getAllyId());
  1050. @@ -207,11 +213,21 @@
  1051. writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
  1052. writeC((_player.isFishing()) ? 1 : 0);
  1053. writeLoc(_player.getFishingStance().getLoc());
  1054. - writeD(_player.getAppearance().getNameColor());
  1055. +
  1056. + int Namecolor = (_player.getAppearance().getNameColor());
  1057. + if (event != null && event.isStarted())
  1058. + Namecolor = (_player.getTeam() == TeamType.BLUE ? Integer.decode("0xDF0101") : _player.getTeam() == TeamType.RED ? Integer.decode("0x0000FF") : _player.getAppearance().getNameColor());
  1059. +
  1060. + writeD(Namecolor);
  1061. writeC((_player.isRunning()) ? 0x01 : 0x00);
  1062. writeD(_player.getPledgeClass());
  1063. writeD(_player.getPledgeType());
  1064. - writeD(_player.getAppearance().getTitleColor());
  1065. +
  1066. + int Titlecolor = (_player.getAppearance().getTitleColor());
  1067. + if (event != null && event.isStarted())
  1068. + Titlecolor = (_player.getTeam() == TeamType.BLUE ? Integer.decode("0xDF0101") : _player.getTeam() == TeamType.RED ? Integer.decode("0x0000FF") : _player.getAppearance().getTitleColor());
  1069. +
  1070. + writeD(Titlecolor);
  1071. writeD(CursedWeaponManager.getInstance().getCurrentStage(_player.getCursedWeaponEquippedId()));
  1072. }
  1073. }
  1074. \ No newline at end of file
  1075. Index: java/net/sf/l2j/gameserver/enums/EventState.java
  1076. ===================================================================
  1077. --- java/net/sf/l2j/gameserver/enums/EventState.java (revision 0)
  1078. +++ java/net/sf/l2j/gameserver/enums/EventState.java (working copy)
  1079. @@ -0,0 +1,13 @@
  1080. +package net.sf.l2j.gameserver.enums;
  1081. +
  1082. +/**
  1083. + * @author Williams
  1084. + *
  1085. + */
  1086. +public enum EventState
  1087. +{
  1088. + INITIAL,
  1089. + REGISTER,
  1090. + SCHEDULED_NEXT,
  1091. + STARTED
  1092. +}
  1093. \ No newline at end of file
  1094. Index: config/events.properties
  1095. ===================================================================
  1096. --- config/events.properties (revision 1)
  1097. +++ config/events.properties (working copy)
  1098. @@ -1,4 +1,64 @@
  1099. #=============================================================
  1100. +# TvT Event
  1101. +#=============================================================
  1102. +# Enable TvT Event
  1103. +TvTEventEnable = True
  1104. +
  1105. +# TvT Event maximum participants
  1106. +TvTMaxParticipants = 40
  1107. +
  1108. +# TvT Event minimum participants
  1109. +TvTMinParticipants = 2
  1110. +
  1111. +# TvT Event minimum level
  1112. +TvTEventMinLevel = 60
  1113. +
  1114. +# TvT Event maximum level
  1115. +TvTEventMaxLevel = 80
  1116. +
  1117. +# Delay between TvT Events (in seconds)
  1118. +# Default: 1 hours
  1119. +TvTEventDelay = 120
  1120. +
  1121. +# TvT event registration NPC ID
  1122. +# It can be anything since core changes npc type to L2TvTManager
  1123. +TvTNpcManager = 50002
  1124. +
  1125. +# TvT registration NPC coords
  1126. +TvTRegisterLocation = 83358,148879,-3405
  1127. +
  1128. +# TvT doors settings
  1129. +TvTArenaDoors = 24190002;24190003
  1130. +
  1131. +# Time that TvT registration is open (in seconds)
  1132. +# Default: 5 minutes
  1133. +TvTEventParticipationTime = 120
  1134. +
  1135. +# Time that TvT event lasts (in seconds)
  1136. +# Default: 5 minutes
  1137. +TvTEventDuration = 120
  1138. +
  1139. +# TvT event blue team spawn coords
  1140. +TvTBlueTeamLocation = 148476,46061,-3411
  1141. +
  1142. +# TvT event red team spawn coords
  1143. +TvTRedTeamLocation = 150480,47444,-3411
  1144. +
  1145. +# TvT player respawn delay upon death (in seconds)
  1146. +# Default: 10 seconds
  1147. +TvTPlayerRespawnDelay = 10
  1148. +
  1149. +# TvT dual box protection
  1150. +TvTAllowDualBoxing = True
  1151. +
  1152. +# TvT Event reward list
  1153. +# Format: itemId1-itemNum1;itemId2-itemNum2...
  1154. +TvTEventRewardList = 57-1000000;6393-50;5592-20
  1155. +
  1156. +# Give rewards to both teams on tie
  1157. +TvTGiveRewardsOnTie = False
  1158. +
  1159. +#=============================================================
  1160. # Olympiad
  1161. #=============================================================
  1162. # Olympiad start time hour, default 18 (6PM).
  1163. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  1164. ===================================================================
  1165. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 1)
  1166. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
  1167. @@ -3,6 +3,7 @@
  1168. import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
  1169. import net.sf.l2j.gameserver.enums.ZoneId;
  1170. import net.sf.l2j.gameserver.model.actor.Player;
  1171. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1172. import net.sf.l2j.gameserver.network.GameClient;
  1173. import net.sf.l2j.gameserver.network.GameClient.GameClientState;
  1174. import net.sf.l2j.gameserver.network.SystemMessageId;
  1175. @@ -23,7 +24,15 @@
  1176. final Player player = getClient().getPlayer();
  1177. if (player == null)
  1178. return;
  1179. -
  1180. +
  1181. + Event event = player.getEvent();
  1182. + if (event != null && event.isStarted())
  1183. + {
  1184. + player.sendMessage("You cannot restart while in event.");
  1185. + sendPacket(RestartResponse.valueOf(false));
  1186. + return;
  1187. + }
  1188. +
  1189. if (player.getActiveEnchantItem() != null || player.isLocked() || player.isInStoreMode())
  1190. {
  1191. sendPacket(RestartResponse.valueOf(false));
  1192. Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  1193. ===================================================================
  1194. --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 1)
  1195. +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
  1196. @@ -6,6 +6,7 @@
  1197. import net.sf.l2j.gameserver.model.actor.Player;
  1198. import net.sf.l2j.gameserver.model.actor.instance.Monster;
  1199. import net.sf.l2j.gameserver.model.entity.Siege;
  1200. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1201. import net.sf.l2j.gameserver.model.pledge.Clan;
  1202.  
  1203. public class Die extends L2GameServerPacket
  1204. @@ -13,7 +14,7 @@
  1205. private final Creature _activeChar;
  1206. private final int _charObjId;
  1207. private final boolean _fake;
  1208. -
  1209. + private boolean _inEvent;
  1210. private boolean _sweepable;
  1211. private boolean _allowFixedRes;
  1212. private Clan _clan;
  1213. @@ -29,7 +30,8 @@
  1214. Player player = (Player) cha;
  1215. _allowFixedRes = player.getAccessLevel().allowFixedRes();
  1216. _clan = player.getClan();
  1217. -
  1218. + Event event = player.getEvent();
  1219. + _inEvent = event != null && event.isStarted();
  1220. }
  1221. else if (cha instanceof Monster)
  1222. _sweepable = ((Monster) cha).isSpoiled();
  1223. @@ -38,7 +40,7 @@
  1224. @Override
  1225. protected final void writeImpl()
  1226. {
  1227. - if (_fake)
  1228. + if (_fake || _inEvent)
  1229. return;
  1230.  
  1231. writeC(0x06);
  1232. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  1233. ===================================================================
  1234. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 1)
  1235. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  1236. @@ -18,6 +18,7 @@
  1237. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEditNpc;
  1238. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEffects;
  1239. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEnchant;
  1240. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEventEngine;
  1241. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminExpSp;
  1242. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGeoEngine;
  1243. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGm;
  1244. @@ -68,6 +69,7 @@
  1245. registerHandler(new AdminEditNpc());
  1246. registerHandler(new AdminEffects());
  1247. registerHandler(new AdminEnchant());
  1248. + registerHandler(new AdminEventEngine());
  1249. registerHandler(new AdminExpSp());
  1250. registerHandler(new AdminGeoEngine());
  1251. registerHandler(new AdminGm());
  1252. Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  1253. ===================================================================
  1254. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 1)
  1255. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
  1256. @@ -11,6 +11,7 @@
  1257. import net.sf.l2j.Config;
  1258. import net.sf.l2j.gameserver.enums.OlympiadType;
  1259. import net.sf.l2j.gameserver.model.actor.Player;
  1260. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1261. import net.sf.l2j.gameserver.network.SystemMessageId;
  1262. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1263. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  1264. @@ -130,7 +131,14 @@
  1265. player.sendPacket(SystemMessageId.GAME_REQUEST_CANNOT_BE_MADE);
  1266. return false;
  1267. }
  1268. -
  1269. +
  1270. + Event event = player.getEvent();
  1271. + if (event != null && event.isStarted())
  1272. + {
  1273. + player.sendMessage("Event Participants cannot register to the Grand Olympiad Games.");
  1274. + return false;
  1275. + }
  1276. +
  1277. switch (type)
  1278. {
  1279. case CLASSED:
  1280. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java
  1281. ===================================================================
  1282. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (revision 0)
  1283. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/EventCommands.java (working copy)
  1284. @@ -0,0 +1,39 @@
  1285. +package net.sf.l2j.gameserver.handler.usercommandhandlers;
  1286. +
  1287. +import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  1288. +import net.sf.l2j.gameserver.model.actor.Player;
  1289. +import net.sf.l2j.gameserver.model.entity.event.TvTEvent;
  1290. +
  1291. +/**
  1292. + * @author Williams
  1293. + *
  1294. + */
  1295. +public class EventCommands implements IUserCommandHandler
  1296. +{
  1297. + private static final int[] COMMAND_IDS =
  1298. + {
  1299. + 114, 115
  1300. + };
  1301. +
  1302. + @Override
  1303. + public boolean useUserCommand(int id, Player activeChar)
  1304. + {
  1305. + if (id == 114)
  1306. + TvTEvent.getInstance().registerPlayer(activeChar);
  1307. + else if (id == 115)
  1308. + {
  1309. + if (TvTEvent.getInstance().isRegistered(activeChar))
  1310. + TvTEvent.getInstance().removePlayer(activeChar);
  1311. + else
  1312. + activeChar.sendMessage("You are not registered for the TvT Event.");
  1313. + }
  1314. +
  1315. + return true;
  1316. + }
  1317. +
  1318. + @Override
  1319. + public int[] getUserCommandList()
  1320. + {
  1321. + return COMMAND_IDS;
  1322. + }
  1323. +}
  1324. \ No newline at end of file
  1325. Index: java/net/sf/l2j/Config.java
  1326. ===================================================================
  1327. --- java/net/sf/l2j/Config.java (revision 1)
  1328. +++ java/net/sf/l2j/Config.java (working copy)
  1329. @@ -17,6 +17,7 @@
  1330. import net.sf.l2j.commons.math.MathUtil;
  1331.  
  1332. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  1333. +import net.sf.l2j.gameserver.model.location.Location;
  1334.  
  1335. /**
  1336. * This class contains global server configuration.<br>
  1337. @@ -117,6 +118,26 @@
  1338. // Events settings
  1339. // --------------------------------------------------
  1340.  
  1341. + /** TvTEvent */
  1342. + public static boolean TVT_ENABLE;
  1343. + public static int MIN_PARTICIOANTS;
  1344. + public static int MAX_PARTICIOANTS;
  1345. + public static byte MIN_LEVEL;
  1346. + public static byte MAX_LEVEL;
  1347. + public static int EVENT_DELAY;
  1348. + public static int PARTICIPATION_TIME;
  1349. + public static int EVENT_DURATION;
  1350. + public static int PLAYER_RESPAWN_DELAY;
  1351. + public static boolean DUAL_BOX;
  1352. + public static boolean REWARD_DIE;
  1353. + public static Location TVT_BLUE_SPAWN_LOCATION;
  1354. + public static Location TVT_RED_SPAWN_LOCATION;
  1355. + public static Location TVT_NPC_LOCATION;
  1356. + public static IntIntHolder[] TVT_REWARDS;
  1357. + public static String TVT_DOOR_LIST;
  1358. + public static int[] TVT_DOOR_IDS;
  1359. + public static int TVT_NPC_ID;
  1360. +
  1361. /** Olympiad */
  1362. public static int ALT_OLY_START_TIME;
  1363. public static int ALT_OLY_MIN;
  1364. @@ -738,6 +773,34 @@
  1365. private static final void loadEvents()
  1366. {
  1367. final ExProperties events = initProperties(EVENTS_FILE);
  1368. + TVT_ENABLE = events.getProperty("TvTEventEnable", false);
  1369. + MIN_PARTICIOANTS = events.getProperty("TvTMinParticipants", 6);
  1370. + MAX_PARTICIOANTS = events.getProperty("TvTMaxParticipants", 40);
  1371. + MIN_LEVEL = (byte) events.getProperty("TvTEventMinLevel", 60);
  1372. + MAX_LEVEL = (byte) events.getProperty("TvTEventMaxLevel", 78);
  1373. + EVENT_DELAY = events.getProperty("TvTEventDelay", 18000);
  1374. + PARTICIPATION_TIME = events.getProperty("TvTEventParticipationTime", 1200);
  1375. + EVENT_DURATION = events.getProperty("TvTEventDuration", 1800);
  1376. + PLAYER_RESPAWN_DELAY = events.getProperty("TvTPlayerRespawnDelay", 20);
  1377. + DUAL_BOX = events.getProperty("TvTAllowDualBoxing", false);
  1378. + REWARD_DIE = events.getProperty("TvTGiveRewardsOnTie", false);
  1379. + TVT_BLUE_SPAWN_LOCATION = events.parseLocation("TvTBlueTeamLocation", "48476,46061,-3411");
  1380. + TVT_RED_SPAWN_LOCATION = events.parseLocation("TvTRedTeamLocation", "150480,47444,-3411");
  1381. + TVT_NPC_LOCATION = events.parseLocation("TvTRegisterLocation", "151808,46864,-3408");
  1382. + TVT_REWARDS = events.parseIntIntList("TvTEventRewardList", "1-268");
  1383. + TVT_NPC_ID = events.getProperty("TvTNpcManager", 18);
  1384. + TVT_DOOR_LIST = events.getProperty("TvTArenaDoors", "24190002;24190003");
  1385. +
  1386. + String[] array = TVT_DOOR_LIST.split(";");
  1387. +
  1388. + TVT_DOOR_IDS = new int[array.length];
  1389. +
  1390. + for (int i = 0; i < array.length; i++)
  1391. + TVT_DOOR_IDS[i] = Integer.parseInt(array[i]);
  1392. +
  1393. + // sorting so binarySearch can be used later
  1394. + Arrays.sort(TVT_DOOR_IDS);
  1395. +
  1396. ALT_OLY_START_TIME = events.getProperty("AltOlyStartTime", 18);
  1397. ALT_OLY_MIN = events.getProperty("AltOlyMin", 0);
  1398. ALT_OLY_CPERIOD = events.getProperty("AltOlyCPeriod", 21600000);
  1399. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  1400. ===================================================================
  1401. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 1)
  1402. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  1403. @@ -14,6 +14,7 @@
  1404. import net.sf.l2j.gameserver.model.actor.Npc;
  1405. import net.sf.l2j.gameserver.model.actor.Player;
  1406. import net.sf.l2j.gameserver.model.actor.instance.OlympiadManagerNpc;
  1407. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1408. import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  1409. import net.sf.l2j.gameserver.network.FloodProtectors;
  1410. import net.sf.l2j.gameserver.network.FloodProtectors.Action;
  1411. @@ -181,7 +182,14 @@
  1412. player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
  1413. return;
  1414. }
  1415. -
  1416. +
  1417. + Event event = player.getEvent();
  1418. + if (event != null && event.isStarted())
  1419. + {
  1420. + player.sendMessage("You can not observe games while registered for an event!");
  1421. + return;
  1422. + }
  1423. +
  1424. final int arenaId = Integer.parseInt(_command.substring(12).trim());
  1425. player.enterOlympiadObserverMode(arenaId);
  1426. }
  1427. Index: java/net/sf/l2j/gameserver/model/actor/player/Punishment.java
  1428. ===================================================================
  1429. --- java/net/sf/l2j/gameserver/model/actor/player/Punishment.java (revision 1)
  1430. +++ java/net/sf/l2j/gameserver/model/actor/player/Punishment.java (working copy)
  1431. @@ -8,6 +8,7 @@
  1432. import net.sf.l2j.gameserver.enums.PunishmentType;
  1433. import net.sf.l2j.gameserver.enums.ZoneId;
  1434. import net.sf.l2j.gameserver.model.actor.Player;
  1435. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1436. import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  1437. import net.sf.l2j.gameserver.network.serverpackets.EtcStatusUpdate;
  1438. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1439. @@ -129,7 +130,12 @@
  1440.  
  1441. if (OlympiadManager.getInstance().isRegisteredInComp(_owner))
  1442. OlympiadManager.getInstance().removeDisconnectedCompetitor(_owner);
  1443. -
  1444. +
  1445. + // Remove participant of event
  1446. + Event event = _owner.getEvent();
  1447. + if (event != null)
  1448. + event.removePlayer(_owner);
  1449. +
  1450. // Open a Html message to inform the player
  1451. final NpcHtmlMessage html = new NpcHtmlMessage(0);
  1452. html.setFile("data/html/jail_in.htm");
  1453. Index: java/net/sf/l2j/gameserver/GameServer.java
  1454. ===================================================================
  1455. --- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
  1456. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  1457. @@ -84,6 +84,7 @@
  1458. import net.sf.l2j.gameserver.model.boat.BoatInnadrilTour;
  1459. import net.sf.l2j.gameserver.model.boat.BoatRunePrimeval;
  1460. import net.sf.l2j.gameserver.model.boat.BoatTalkingGludin;
  1461. +import net.sf.l2j.gameserver.model.entity.event.TvTEvent;
  1462. import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  1463. import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
  1464. import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
  1465. @@ -260,6 +261,7 @@
  1466. }
  1467.  
  1468. StringUtil.printSection("Events");
  1469. + TvTEvent.getInstance();
  1470. DerbyTrackManager.getInstance();
  1471. LotteryManager.getInstance();
  1472.  
  1473. Index: java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java
  1474. ===================================================================
  1475. --- java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java (revision 1)
  1476. +++ java/net/sf/l2j/gameserver/network/serverpackets/CharInfo.java (working copy)
  1477. @@ -6,6 +6,7 @@
  1478. import net.sf.l2j.gameserver.enums.skills.AbnormalEffect;
  1479. import net.sf.l2j.gameserver.model.actor.Player;
  1480. import net.sf.l2j.gameserver.model.actor.Summon;
  1481. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1482. import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
  1483.  
  1484. public class CharInfo extends L2GameServerPacket
  1485. @@ -117,8 +118,13 @@
  1486. writeD(_player.getAppearance().getHairColor());
  1487. writeD(_player.getAppearance().getFace());
  1488.  
  1489. - writeS((canSeeInvis) ? "Invisible" : _player.getTitle());
  1490. + String name = (canSeeInvis) ? "Invisible" : _player.getTitle();
  1491. +
  1492. + Event event = _player.getEvent();
  1493. + if (event != null && event.isStarted())
  1494. + name = ((_player.getTeam() == TeamType.BLUE) ? "Kills: " + _player.getEvent().getBlueTeamKills() : (_player.getTeam() == TeamType.RED) ? "Kills: " + _player.getEvent().getRedTeamKills() : _player.getTitle());
  1495.  
  1496. + writeS(name);
  1497. writeD(_player.getClanId());
  1498. writeD(_player.getClanCrestId());
  1499. writeD(_player.getAllyId());
  1500. @@ -153,11 +159,19 @@
  1501. writeC((_player.isHero() || (_player.isGM() && Config.GM_HERO_AURA)) ? 1 : 0);
  1502. writeC((_player.isFishing()) ? 1 : 0);
  1503. writeLoc(_player.getFishingStance().getLoc());
  1504. - writeD(_player.getAppearance().getNameColor());
  1505. + int Namecolor = (_player.getAppearance().getNameColor());
  1506. + if (event != null && event.isStarted())
  1507. + Namecolor = (_player.getTeam() == TeamType.BLUE ? Integer.decode("0xDF0101") : _player.getTeam() == TeamType.RED ? Integer.decode("0x0000FF") : _player.getAppearance().getNameColor());
  1508. +
  1509. + writeD(Namecolor);
  1510. writeD(_player.getHeading());
  1511. writeD(_player.getPledgeClass());
  1512. writeD(_player.getPledgeType());
  1513. - writeD(_player.getAppearance().getTitleColor());
  1514. + int Titlecolor = (_player.getAppearance().getTitleColor());
  1515. + if (event != null && event.isStarted())
  1516. + Titlecolor = (_player.getTeam() == TeamType.BLUE ? Integer.decode("0xDF0101") : _player.getTeam() == TeamType.RED ? Integer.decode("0x0000FF") : _player.getAppearance().getTitleColor());
  1517. +
  1518. + writeD(Titlecolor);
  1519. writeD(CursedWeaponManager.getInstance().getCurrentStage(_player.getCursedWeaponEquippedId()));
  1520. }
  1521. }
  1522. \ No newline at end of file
  1523. Index: java/net/sf/l2j/gameserver/handler/UserCommandHandler.java
  1524. ===================================================================
  1525. --- java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (revision 1)
  1526. +++ java/net/sf/l2j/gameserver/handler/UserCommandHandler.java (working copy)
  1527. @@ -10,6 +10,7 @@
  1528. import net.sf.l2j.gameserver.handler.usercommandhandlers.ClanWarsList;
  1529. import net.sf.l2j.gameserver.handler.usercommandhandlers.DisMount;
  1530. import net.sf.l2j.gameserver.handler.usercommandhandlers.Escape;
  1531. +import net.sf.l2j.gameserver.handler.usercommandhandlers.EventCommands;
  1532. import net.sf.l2j.gameserver.handler.usercommandhandlers.Loc;
  1533. import net.sf.l2j.gameserver.handler.usercommandhandlers.Mount;
  1534. import net.sf.l2j.gameserver.handler.usercommandhandlers.OlympiadStat;
  1535. @@ -30,6 +31,7 @@
  1536. registerHandler(new ClanWarsList());
  1537. registerHandler(new DisMount());
  1538. registerHandler(new Escape());
  1539. + registerHandler(new EventCommands());
  1540. registerHandler(new Loc());
  1541. registerHandler(new Mount());
  1542. registerHandler(new OlympiadStat());
  1543. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  1544. ===================================================================
  1545. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 1)
  1546. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
  1547. @@ -3,6 +3,7 @@
  1548. import net.sf.l2j.gameserver.data.manager.FestivalOfDarknessManager;
  1549. import net.sf.l2j.gameserver.enums.ZoneId;
  1550. import net.sf.l2j.gameserver.model.actor.Player;
  1551. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1552. import net.sf.l2j.gameserver.network.SystemMessageId;
  1553. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1554. import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
  1555. @@ -20,7 +21,15 @@
  1556. final Player player = getClient().getPlayer();
  1557. if (player == null)
  1558. return;
  1559. -
  1560. +
  1561. + Event event = player.getEvent();
  1562. + if (event != null && event.isStarted())
  1563. + {
  1564. + player.sendMessage("You cannot logout while in event.");
  1565. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1566. + return;
  1567. + }
  1568. +
  1569. if (player.getActiveEnchantItem() != null || player.isLocked())
  1570. {
  1571. player.sendPacket(ActionFailed.STATIC_PACKET);
  1572. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java
  1573. ===================================================================
  1574. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (revision 1)
  1575. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (working copy)
  1576. @@ -3,6 +3,7 @@
  1577. import net.sf.l2j.commons.lang.StringUtil;
  1578.  
  1579. import net.sf.l2j.gameserver.model.actor.Player;
  1580. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1581. import net.sf.l2j.gameserver.model.pledge.Clan;
  1582. import net.sf.l2j.gameserver.model.pledge.ClanMember;
  1583. import net.sf.l2j.gameserver.network.SystemMessageId;
  1584. @@ -27,6 +28,13 @@
  1585. if (activeChar == null)
  1586. return;
  1587.  
  1588. + Event event = activeChar.getEvent();
  1589. + if (event != null && event.isStarted())
  1590. + {
  1591. + activeChar.sendMessage("You cannot change title while in event.");
  1592. + return;
  1593. + }
  1594. +
  1595. if (!StringUtil.isValidString(_title, "^[a-zA-Z0-9 !@#$&()\\-`.+,/\"]*{0,16}$"))
  1596. {
  1597. activeChar.sendPacket(SystemMessageId.NOT_WORKING_PLEASE_TRY_AGAIN_LATER);
  1598. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  1599. ===================================================================
  1600. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 1)
  1601. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
  1602. @@ -4,6 +4,7 @@
  1603. import net.sf.l2j.gameserver.enums.ZoneId;
  1604. import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  1605. import net.sf.l2j.gameserver.model.actor.Player;
  1606. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1607. import net.sf.l2j.gameserver.network.SystemMessageId;
  1608. import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  1609.  
  1610. @@ -22,7 +23,14 @@
  1611. activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
  1612. return false;
  1613. }
  1614. -
  1615. +
  1616. + Event event = activeChar.getEvent();
  1617. + if (event != null && event.isStarted())
  1618. + {
  1619. + activeChar.sendMessage("You may not use an escape in events.");
  1620. + return false;
  1621. + }
  1622. +
  1623. activeChar.stopMove(null);
  1624.  
  1625. // Official timer 5 minutes, for GM 1 second
  1626. Index: java/net/sf/l2j/gameserver/model/entity/event/imp/Event.java
  1627. ===================================================================
  1628. --- java/net/sf/l2j/gameserver/model/entity/event/imp/Event.java (revision 0)
  1629. +++ java/net/sf/l2j/gameserver/model/entity/event/imp/Event.java (working copy)
  1630. @@ -0,0 +1,64 @@
  1631. +package net.sf.l2j.gameserver.model.entity.event.imp;
  1632. +
  1633. +import net.sf.l2j.gameserver.enums.EventState;
  1634. +import net.sf.l2j.gameserver.model.actor.Creature;
  1635. +import net.sf.l2j.gameserver.model.actor.Player;
  1636. +
  1637. +/**
  1638. + * @author DnR
  1639. + *
  1640. + */
  1641. +public abstract class Event
  1642. +{
  1643. + // Event Kills
  1644. + public int _blueTeamKills = 0;
  1645. + public int _redTeamKills = 0;
  1646. +
  1647. + // Event default state
  1648. + public EventState _state = EventState.INITIAL;
  1649. +
  1650. + public boolean isStarted()
  1651. + {
  1652. + return _state == EventState.STARTED;
  1653. + }
  1654. +
  1655. + public EventState getEventState()
  1656. + {
  1657. + return _state;
  1658. + }
  1659. +
  1660. + public void setEventState(EventState state)
  1661. + {
  1662. + _state = state;
  1663. + }
  1664. +
  1665. + public int getBlueTeamKills()
  1666. + {
  1667. + return _blueTeamKills;
  1668. + }
  1669. +
  1670. + public int getRedTeamKills()
  1671. + {
  1672. + return _redTeamKills;
  1673. + }
  1674. +
  1675. + public abstract boolean isRegistered(Player player);
  1676. +
  1677. + public abstract void onDie(Creature player);
  1678. +
  1679. + public abstract void onKill(Player player, Player target);
  1680. +
  1681. + public abstract void onRevive(Creature player);
  1682. +
  1683. + public abstract boolean canTarget(Player player, Player target);
  1684. +
  1685. + public void registerPlayer(Player player)
  1686. + {
  1687. + player.setEvent(this);
  1688. + }
  1689. +
  1690. + public void removePlayer(Player player)
  1691. + {
  1692. + player.setEvent(null);
  1693. + }
  1694. +}
  1695. \ No newline at end of file
  1696. Index: java/net/sf/l2j/gameserver/model/actor/instance/TvTManager.java
  1697. ===================================================================
  1698. --- java/net/sf/l2j/gameserver/model/actor/instance/TvTManager.java (revision 0)
  1699. +++ java/net/sf/l2j/gameserver/model/actor/instance/TvTManager.java (working copy)
  1700. @@ -0,0 +1,85 @@
  1701. +package net.sf.l2j.gameserver.model.actor.instance;
  1702. +
  1703. +import net.sf.l2j.Config;
  1704. +import net.sf.l2j.gameserver.data.cache.HtmCache;
  1705. +import net.sf.l2j.gameserver.enums.EventState;
  1706. +import net.sf.l2j.gameserver.model.actor.Player;
  1707. +import net.sf.l2j.gameserver.model.actor.instance.Folk;
  1708. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  1709. +import net.sf.l2j.gameserver.model.entity.event.TvTEvent;
  1710. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1711. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1712. +
  1713. +/**
  1714. + * @author DnR
  1715. + *
  1716. + */
  1717. +public class TvTManager extends Folk
  1718. +{
  1719. + public TvTManager(int objectId, NpcTemplate template)
  1720. + {
  1721. + super(objectId, template);
  1722. + }
  1723. +
  1724. + @Override
  1725. + public void onBypassFeedback(Player player, String command)
  1726. + {
  1727. + if (command.equals("tvt_event_participation"))
  1728. + TvTEvent.getInstance().registerPlayer(player);
  1729. + else if (command.equals("tvt_event_remove_participation"))
  1730. + TvTEvent.getInstance().removePlayer(player);
  1731. + }
  1732. +
  1733. + @Override
  1734. + public void showChatWindow(Player player, int val)
  1735. + {
  1736. + if (player == null)
  1737. + return;
  1738. +
  1739. + if (TvTEvent.getInstance().getEventState() == EventState.REGISTER)
  1740. + {
  1741. + String htmFile = "data/html/event/";
  1742. +
  1743. + if (!TvTEvent.getInstance().isRegistered(player))
  1744. + htmFile += "TvTEventParticipation";
  1745. + else
  1746. + htmFile += "TvTEventRemoveParticipation";
  1747. +
  1748. + htmFile += ".htm";
  1749. +
  1750. + String htmContent = HtmCache.getInstance().getHtm(htmFile);
  1751. + if (htmContent != null)
  1752. + {
  1753. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1754. +
  1755. + npcHtmlMessage.setHtml(htmContent);
  1756. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1757. + npcHtmlMessage.replace("%registeredcount%", String.valueOf(TvTEvent.getInstance().getRegistered().size()));
  1758. + npcHtmlMessage.replace("%minimumplayers%", String.valueOf(Config.MIN_PARTICIOANTS));
  1759. + npcHtmlMessage.replace("%maximumplayers%", String.valueOf(Config.MAX_PARTICIOANTS));
  1760. + npcHtmlMessage.replace("%minimumlevel%", String.valueOf(Config.MIN_LEVEL));
  1761. + npcHtmlMessage.replace("%maximumlevel%", String.valueOf(Config.MAX_LEVEL));
  1762. + player.sendPacket(npcHtmlMessage);
  1763. + }
  1764. + }
  1765. + else
  1766. + {
  1767. + String htmContent = HtmCache.getInstance().getHtm("data/html/event/TvTEventStatus.htm");
  1768. +
  1769. + if (htmContent != null)
  1770. + {
  1771. +
  1772. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1773. +
  1774. + npcHtmlMessage.setHtml(htmContent);
  1775. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(TvTEvent.getInstance().getBlueTeam().size()));
  1776. + npcHtmlMessage.replace("%team1points%", String.valueOf(TvTEvent.getInstance().getBlueTeamKills()));
  1777. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(TvTEvent.getInstance().getRedTeam().size()));
  1778. + npcHtmlMessage.replace("%team2points%", String.valueOf(TvTEvent.getInstance().getRedTeamKills()));
  1779. + player.sendPacket(npcHtmlMessage);
  1780. + }
  1781. + }
  1782. +
  1783. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1784. + }
  1785. +}
  1786. \ No newline at end of file
  1787. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java
  1788. ===================================================================
  1789. --- java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (revision 1)
  1790. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (working copy)
  1791. @@ -8,6 +8,7 @@
  1792. import net.sf.l2j.gameserver.model.actor.Player;
  1793. import net.sf.l2j.gameserver.model.actor.instance.Pet;
  1794. import net.sf.l2j.gameserver.model.actor.instance.Servitor;
  1795. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1796. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  1797. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  1798. import net.sf.l2j.gameserver.network.SystemMessageId;
  1799. @@ -27,6 +28,13 @@
  1800.  
  1801. final boolean isPet = playable instanceof Pet;
  1802. final Player activeChar = playable.getActingPlayer();
  1803. +
  1804. + Event event = activeChar.getEvent();
  1805. + if (event != null && event.isStarted())
  1806. + {
  1807. + activeChar.sendMessage("You cannot use this item in events.");
  1808. + return;
  1809. + }
  1810.  
  1811. // Pets can only use tradable items.
  1812. if (isPet && !item.isTradable())
  1813. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  1814. ===================================================================
  1815. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 1)
  1816. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
  1817. @@ -1,9 +1,11 @@
  1818. package net.sf.l2j.gameserver.network.clientpackets;
  1819.  
  1820. import net.sf.l2j.gameserver.enums.LootRule;
  1821. +import net.sf.l2j.gameserver.enums.TeamType;
  1822. import net.sf.l2j.gameserver.model.World;
  1823. import net.sf.l2j.gameserver.model.actor.Player;
  1824. import net.sf.l2j.gameserver.model.actor.player.BlockList;
  1825. +import net.sf.l2j.gameserver.model.entity.event.imp.Event;
  1826. import net.sf.l2j.gameserver.model.group.Party;
  1827. import net.sf.l2j.gameserver.network.SystemMessageId;
  1828. import net.sf.l2j.gameserver.network.serverpackets.AskJoinParty;
  1829. @@ -34,6 +36,18 @@
  1830. requestor.sendPacket(SystemMessageId.FIRST_SELECT_USER_TO_INVITE_TO_PARTY);
  1831. return;
  1832. }
  1833. +
  1834. + Event targetEvent = target.getEvent();
  1835. + Event requestorEvent = requestor.getEvent();
  1836. +
  1837. + if (targetEvent != null && targetEvent.isStarted() && target.getTeam() == TeamType.NONE || target.getTeam().getId() > 0 && target.getTeam() != requestor.getTeam())
  1838. + return;
  1839. +
  1840. + if (requestorEvent != null && requestorEvent.isStarted() && requestor.getTeam() == TeamType.NONE || requestor.getTeam().getId() > 0 && requestor.getTeam() != target.getTeam())
  1841. + {
  1842. + requestor.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  1843. + return;
  1844. + }
  1845.  
  1846. if (BlockList.isBlocked(target, requestor))
  1847. {
  1848. ### Eclipse Workspace Patch 1.0
  1849. #P aCis_gameserver
  1850. Index: java/net/sf/l2j/commons/config/ExProperties.java
  1851. ===================================================================
  1852. --- java/net/sf/l2j/commons/config/ExProperties.java (revision 1)
  1853. +++ java/net/sf/l2j/commons/config/ExProperties.java (working copy)
  1854. @@ -9,6 +9,7 @@
  1855. import net.sf.l2j.commons.logging.CLogger;
  1856.  
  1857. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  1858. +import net.sf.l2j.gameserver.model.location.Location;
  1859.  
  1860. public class ExProperties extends Properties
  1861. {
  1862. @@ -215,4 +216,44 @@
  1863. }
  1864. return result;
  1865. }
  1866. +
  1867. + /**
  1868. + * x,y,z
  1869. + * @param line
  1870. + * @param defaultValue
  1871. + * @return an array consisting of parsed items.
  1872. + */
  1873. + public final Location parseLocation(String line, String defaultValue)
  1874. + {
  1875. + final String[] propertySplit = getProperty(line, defaultValue).split(",");
  1876. + if (propertySplit.length < 3)
  1877. + return null;
  1878. +
  1879. + int i = 0;
  1880. + final int[] result = new int[propertySplit.length];
  1881. + for (String value : propertySplit)
  1882. + {
  1883. + try
  1884. + {
  1885. + result[i] = Integer.parseInt(value);
  1886. + }
  1887. + catch (NumberFormatException e)
  1888. + {
  1889. + LOGGER.warn("Config: Error parsing coordinate -> \"" + value + "\"");
  1890. + return null;
  1891. + }
  1892. +
  1893. + i++;
  1894. + }
  1895. +
  1896. + if (result.length < 3)
  1897. + {
  1898. + LOGGER.warn("Config: Error parsing location -> size: \"" + result.length + "\"");
  1899. + return null;
  1900. + }
  1901. +
  1902. + final Location loc = new Location(result[0], result[1], result[2]);
  1903. +
  1904. + return loc;
  1905. + }
  1906. }
  1907. \ No newline at end of file
  1908. #P aCis_datapack
  1909. Index: data/xml/adminCommands.xml
  1910. ===================================================================
  1911. --- data/xml/adminCommands.xml (revision 1)
  1912. +++ data/xml/adminCommands.xml (working copy)
  1913. @@ -334,4 +334,7 @@
  1914. <!-- ZONE -->
  1915. <aCar name="admin_zone_check" accessLevel="7"/>
  1916. <aCar name="admin_zone_visual" accessLevel="7"/>
  1917. +
  1918. + <!-- TVT -->
  1919. + <aCar name="admin_tvt_abort" accessLevel="7"/>
  1920. </list>
  1921. \ No newline at end of file
  1922. Index: data/html/event/TvTEventRemoveParticipation.htm
  1923. ===================================================================
  1924. --- data/html/event/TvTEventRemoveParticipation.htm (revision 0)
  1925. +++ data/html/event/TvTEventRemoveParticipation.htm (working copy)
  1926. @@ -0,0 +1,11 @@
  1927. +<html><title>TvT Event</title><br><body>
  1928. +Cancel Registration yourself for TvT Event:<br1><br>
  1929. +<center>Registered:(%registeredcount% players in)<br1>
  1930. +Minimum players required:%minimumplayers%<br1>
  1931. +Maximum players allowed:%maximumplayers%<br>
  1932. +Minimum level:%minimumlevel%<br1>
  1933. +Maximum level:%maximumlevel%</center><br><br>
  1934. +You are already registered for this event. Do you wish to cancel your participation in this Event?<br><br><center>
  1935. +<button value="Yes" action="bypass -h npc_%objectId%_tvt_event_remove_participation" width=40 height=15 back="sek.cbui94" fore="sek.cbui92">
  1936. +<button value="No" action="bypass -h npc_%objectId%_Close" width=40 height=15 back="sek.cbui94" fore="sek.cbui92">
  1937. +</center></body></html>
  1938. Index: data/html/event/TvTEventStatus.htm
  1939. ===================================================================
  1940. --- data/html/event/TvTEventStatus.htm (revision 0)
  1941. +++ data/html/event/TvTEventStatus.htm (working copy)
  1942. @@ -0,0 +1,7 @@
  1943. +<html><title>TvT Event</title><br>
  1944. +<body>Status:<br>
  1945. +<br>
  1946. +<center>Blue Team with %team1playercount% players and %team1points% points.<br1>
  1947. +Red Team with %team2playercount% players and %team2points% points.<br>
  1948. +</center>
  1949. +</body></html>
  1950. \ No newline at end of file
  1951. Index: data/html/event/TvTEventParticipation.htm
  1952. ===================================================================
  1953. --- data/html/event/TvTEventParticipation.htm (revision 0)
  1954. +++ data/html/event/TvTEventParticipation.htm (working copy)
  1955. @@ -0,0 +1,10 @@
  1956. +<html><title>TvT Event</title><br><body>
  1957. +Registration for TvT Event:<br><br><center>
  1958. +Registered: %registeredcount%, players in)<br1>
  1959. +Minimum players required;%minimumplayers%<br1>
  1960. +Maximum players allowed:%maximumplayers%<br>
  1961. +Minimum level:%minimumlevel%<br1>
  1962. +Maximum level:%maximumlevel%<br>
  1963. +<button value="Participate" action="bypass -h npc_%objectId%_tvt_event_participation" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
  1964. +<button value="Close" action="bypass -h npc_%objectId%_Close" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
  1965. +</center></body></html>
  1966. Index: data/xml/npcs/50000-50999.xml
  1967. ===================================================================
  1968. --- data/xml/npcs/50000-50999.xml (revision 1)
  1969. +++ data/xml/npcs/50000-50999.xml (working copy)
  1970. @@ -1,5 +1,79 @@
  1971. <?xml version="1.0" encoding="utf-8"?>
  1972. <list>
  1973. +<npc id="50002" idTemplate="35322" name="Event" title="TvT Manager">
  1974. + <set name="usingServerSideName" val="true" />
  1975. + <set name="usingServerSideTitle" val="true" />
  1976. + <set name="level" val="20"/>
  1977. + <set name="radius" val="34"/>
  1978. + <set name="height" val="65"/>
  1979. + <set name="rHand" val="0"/>
  1980. + <set name="lHand" val="0"/>
  1981. + <set name="type" val="TvTManager"/>
  1982. + <set name="exp" val="0"/>
  1983. + <set name="sp" val="10"/>
  1984. + <set name="hp" val="342.5127"/>
  1985. + <set name="mp" val="192"/>
  1986. + <set name="hpRegen" val="2.5"/>
  1987. + <set name="mpRegen" val="1.2"/>
  1988. + <set name="pAtk" val="44.32863"/>
  1989. + <set name="pDef" val="86.87049"/>
  1990. + <set name="mAtk" val="30.2707"/>
  1991. + <set name="mDef" val="63.56806"/>
  1992. + <set name="crit" val="4"/>
  1993. + <set name="atkSpd" val="253"/>
  1994. + <set name="str" val="40"/>
  1995. + <set name="int" val="21"/>
  1996. + <set name="dex" val="30"/>
  1997. + <set name="wit" val="20"/>
  1998. + <set name="con" val="43"/>
  1999. + <set name="men" val="20"/>
  2000. + <set name="corpseTime" val="7"/>
  2001. + <set name="walkSpd" val="50"/>
  2002. + <set name="runSpd" val="120"/>
  2003. + <set name="dropHerbGroup" val="0"/>
  2004. + <ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="false" seedable="false"/>
  2005. + <skills>
  2006. + <skill id="4045" level="1"/>
  2007. + <skill id="4416" level="19"/>
  2008. + </skills>
  2009. + </npc>
  2010. <npc id="50006" idTemplate="31228" name="Roy the Cat" title="Class Manager">
  2011. <set name="usingServerSideName" val="true"/>
  2012. <set name="usingServerSideTitle" val="true"/>
RAW Paste Data