Advertisement
l2jkamui

TeamVsTeam

Apr 20th, 2018
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 101.08 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_datapack
  3. Index: data/xml/npcs/50000-50999.xml
  4. ===================================================================
  5. --- data/xml/npcs/50000-50999.xml (revision 2)
  6. +++ data/xml/npcs/50000-50999.xml (working copy)
  7. @@ -111,4 +111,41 @@
  8. <skill id="4416" level="18"/>
  9. </skills>
  10. </npc>
  11. + <npc id="50009" idTemplate="35322" name="Hestui" title="Event Manager">
  12. + <set name="usingServerSideName" val="true" />
  13. + <set name="usingServerSideTitle" val="true" />
  14. + <set name="level" val="20"/>
  15. + <set name="radius" val="34"/>
  16. + <set name="height" val="65"/>
  17. + <set name="rHand" val="0"/>
  18. + <set name="lHand" val="0"/>
  19. + <set name="type" val="EventsManager"/>
  20. + <set name="exp" val="0"/>
  21. + <set name="sp" val="10"/>
  22. + <set name="hp" val="342.5127"/>
  23. + <set name="mp" val="192"/>
  24. + <set name="hpRegen" val="2.5"/>
  25. + <set name="mpRegen" val="1.2"/>
  26. + <set name="pAtk" val="44.32863"/>
  27. + <set name="pDef" val="86.87049"/>
  28. + <set name="mAtk" val="30.2707"/>
  29. + <set name="mDef" val="63.56806"/>
  30. + <set name="crit" val="4"/>
  31. + <set name="atkSpd" val="253"/>
  32. + <set name="str" val="40"/>
  33. + <set name="int" val="21"/>
  34. + <set name="dex" val="30"/>
  35. + <set name="wit" val="20"/>
  36. + <set name="con" val="43"/>
  37. + <set name="men" val="20"/>
  38. + <set name="corpseTime" val="7"/>
  39. + <set name="walkSpd" val="50"/>
  40. + <set name="runSpd" val="120"/>
  41. + <set name="dropHerbGroup" val="0"/>
  42. + <ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="false" seedable="false"/>
  43. + <skills>
  44. + <skill id="4045" level="1"/>
  45. + <skill id="4416" level="19"/>
  46. + </skills>
  47. + </npc>
  48. </list>
  49. \ No newline at end of file
  50. Index: data/html/mods/TeamVsTeam/RemoveParticipation.htm
  51. ===================================================================
  52. --- data/html/mods/TeamVsTeam/RemoveParticipation.htm (revision 0)
  53. +++ data/html/mods/TeamVsTeam/RemoveParticipation.htm (working copy)
  54. @@ -0,0 +1,6 @@
  55. +<html><title>Event Manager</title><body>
  56. +Cancel Registration yourself for the Event:<br1>
  57. +You are already registered for this event. Do you wish to cancel your participation in this Event?<br><center>
  58. +<button value="Yes" action="bypass -h npc_%objectId%_events_remove_participation" width=40 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  59. +<button value="No" action="bypass -h npc_%objectId%_Close" width=40 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  60. +</center></body></html>
  61. \ No newline at end of file
  62. Index: data/html/mods/TeamVsTeam/Participation.htm
  63. ===================================================================
  64. --- data/html/mods/TeamVsTeam/Participation.htm (revision 0)
  65. +++ data/html/mods/TeamVsTeam/Participation.htm (working copy)
  66. @@ -0,0 +1,7 @@
  67. +<html><title>Event Manager</title><body>
  68. +Registration for the Event:<br><br><center>
  69. +%playercount% players in<br>
  70. +Participation Fee: %fee%<br>
  71. +<button value="Participate" action="bypass -h npc_%objectId%_events_participation" width=50 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  72. +<button value="Close" action="bypass -h npc_%objectId%_Close" width=50 height=15 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  73. +</center></body></html>
  74. \ No newline at end of file
  75. Index: data/html/mods/TeamVsTeam/Status.htm
  76. ===================================================================
  77. --- data/html/mods/TeamVsTeam/Status.htm (revision 0)
  78. +++ data/html/mods/TeamVsTeam/Status.htm (working copy)
  79. @@ -0,0 +1,5 @@
  80. +<html><title>TvT Event</title><body>
  81. +Status:<br><br><center>
  82. +%team1name% with %team1playercount% players and %team1points% points.<br1>
  83. +%team2name% with %team2playercount% players and %team2points% points.<br>
  84. +</center></body></html>
  85. \ No newline at end of file
  86. #P aCis_gameserver
  87. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java
  88. ===================================================================
  89. --- java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (revision 2)
  90. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/Resurrect.java (working copy)
  91. @@ -28,6 +28,8 @@
  92. {
  93. if (cha instanceof Player)
  94. ((Player) cha).reviveRequest((Player) activeChar, skill, false);
  95. + else if (cha instanceof Player)
  96. + ((Player) cha).isInFunEvent();
  97. else if (cha instanceof Pet)
  98. {
  99. if (((Pet) cha).getOwner() == activeChar)
  100. Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
  101. ===================================================================
  102. --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 2)
  103. +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
  104. @@ -8,6 +8,7 @@
  105. import net.sf.l2j.gameserver.model.actor.Npc;
  106. import net.sf.l2j.gameserver.model.actor.instance.Player;
  107. import net.sf.l2j.gameserver.network.SystemMessageId;
  108. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  109. import net.sf.l2j.gameserver.network.serverpackets.SendTradeRequest;
  110. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  111.  
  112. @@ -40,6 +41,12 @@
  113. player.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  114. return;
  115. }
  116. +
  117. + if (player.isInFunEvent() || target.isInFunEvent())
  118. + {
  119. + player.sendPacket(new ExShowScreenMessage("You can't Trade when is in events.", 8000, 0x02, true));
  120. + return;
  121. + }
  122.  
  123. if (target.isInOlympiadMode() || player.isInOlympiadMode())
  124. {
  125. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java
  126. ===================================================================
  127. --- java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (revision 2)
  128. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ItemSkills.java (working copy)
  129. @@ -11,6 +11,7 @@
  130. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  131. import net.sf.l2j.gameserver.model.item.type.EtcItemType;
  132. import net.sf.l2j.gameserver.network.SystemMessageId;
  133. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  134. import net.sf.l2j.gameserver.network.serverpackets.ExUseSharedGroupItem;
  135. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  136.  
  137. @@ -35,6 +36,13 @@
  138. return;
  139. }
  140.  
  141. + // players can not use in events
  142. + if (activeChar.isInFunEvent())
  143. + {
  144. + activeChar.sendPacket(new ExShowScreenMessage("You can't use Potion in event.", 8000, 0x02, true));
  145. + return;
  146. + }
  147. +
  148. final IntIntHolder[] skills = item.getEtcItem().getSkills();
  149. if (skills == null)
  150. {
  151. Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java
  152. ===================================================================
  153. --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java (revision 0)
  154. +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeleport.java (working copy)
  155. @@ -0,0 +1,131 @@
  156. +package net.sf.l2j.gameserver.model.entity.engine.impl;
  157. +
  158. +import net.sf.l2j.commons.concurrent.ThreadPool;
  159. +import net.sf.l2j.commons.random.Rnd;
  160. +
  161. +import net.sf.l2j.Config;
  162. +import net.sf.l2j.gameserver.data.SkillTable;
  163. +import net.sf.l2j.gameserver.model.actor.Summon;
  164. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  165. +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
  166. +import net.sf.l2j.gameserver.model.entity.Duel.DuelState;
  167. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  168. +import net.sf.l2j.gameserver.model.group.Party.MessageType;
  169. +import net.sf.l2j.gameserver.network.serverpackets.Ride;
  170. +
  171. +/**
  172. + * @author williams
  173. + *
  174. + */
  175. +public class EventTeleport implements Runnable
  176. +{
  177. + /** The instance of the player to teleport */
  178. + public Player _player;
  179. + /** Coordinates of the spot to teleport to */
  180. + public int[] _coordinates = new int[3];
  181. + /** Admin removed this player from event */
  182. + private boolean _adminRemove;
  183. +
  184. + /**
  185. + * Initialize the teleport and start the delayed task
  186. + * @param playerInstance
  187. + * @param coordinates
  188. + * @param fastSchedule
  189. + * @param adminRemove
  190. + */
  191. + public EventTeleport(Player playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  192. + {
  193. + _player = playerInstance;
  194. + _coordinates = coordinates;
  195. + _adminRemove = adminRemove;
  196. +
  197. + // in config as seconds
  198. + long delay = (TeamVsTeam.isStarted() ? 10 : 10) * 1000;
  199. +
  200. + if (fastSchedule)
  201. + delay = 0;
  202. +
  203. + ThreadPool.schedule(this, delay);
  204. + }
  205. +
  206. + /**
  207. + * The task method to teleport the player<br>
  208. + * 1. Unsummon pet if there is one
  209. + * 2. Remove all effects
  210. + * 3. Revive and full heal the player
  211. + * 4. Teleport the player
  212. + * 5. Broadcast status and user info
  213. + * 6. Remove party
  214. + * 7. Restricted for skill
  215. + * 8. Remove players mounted
  216. + */
  217. + @Override
  218. + public void run()
  219. + {
  220. + if (_player == null)
  221. + return;
  222. +
  223. + if (_player.getPet() != null)
  224. + {
  225. + Summon summon = _player.getPet();
  226. + summon.stopAllEffects();
  227. +
  228. + if (summon instanceof Servitor)
  229. + summon.unSummon(_player);
  230. + }
  231. +
  232. + if (Config.EVENTS_EFFECTS_REMOVAL == 0 || (Config.EVENTS_EFFECTS_REMOVAL == 1 && (_player.getTeam() == 0 || (_player.isInDuel() && _player.getDuelState() != DuelState.INTERRUPTED))))
  233. + _player.stopAllEffectsExceptThoseThatLastThroughDeath();
  234. +
  235. + if (_player.getParty() != null)
  236. + _player.getParty().removePartyMember(_player, MessageType.EXPELLED);
  237. +
  238. + if (_player.isMounted())
  239. + {
  240. + if (_player.dismount())
  241. + {
  242. + if (_player.isFlying())
  243. + _player.removeSkill(SkillTable.FrequentSkill.WYVERN_BREATH.getSkill().getId(), false);
  244. +
  245. + final Ride dismount = new Ride(_player.getObjectId(), Ride.ACTION_DISMOUNT, 0);
  246. + _player.broadcastPacket(dismount);
  247. + _player.setMountObjectId(0);
  248. + }
  249. + }
  250. +
  251. + if (_player.isMageClass())
  252. + {
  253. + for (int[] mageBuffs : Config.EVENTS_MAGE_BUFFS)
  254. + {
  255. + if (mageBuffs == null)
  256. + continue;
  257. +
  258. + SkillTable.getInstance().getInfo(mageBuffs[0], mageBuffs[1]).getEffects(_player, _player);
  259. + }
  260. + }
  261. + else
  262. + {
  263. + for (int[] fighterBuffs : Config.EVENTS_FIGHTER_BUFFS)
  264. + {
  265. + if (fighterBuffs == null)
  266. + continue;
  267. +
  268. + SkillTable.getInstance().getInfo(fighterBuffs[0], fighterBuffs[1]).getEffects(_player, _player);
  269. + }
  270. + }
  271. +
  272. + if (TeamVsTeam.isStarted() && !_adminRemove)
  273. + _player.setTeam(TeamVsTeam.getParticipantTeamId(_player.getName()) + 1);
  274. + else
  275. + _player.setTeam(0);
  276. +
  277. + _player.doRevive();
  278. + _player.setCurrentHp(_player.getMaxHp());
  279. + _player.setCurrentCp(_player.getMaxCp());
  280. + _player.setCurrentMp(_player.getMaxMp());
  281. + _player.teleToLocation(_coordinates[0] + Rnd.get(101) - 50, _coordinates[1] + Rnd.get(101) - 50, _coordinates[2], 0);
  282. +
  283. + _player.broadcastStatusUpdate();
  284. + _player.broadcastUserInfo();
  285. + }
  286. +}
  287. \ No newline at end of file
  288. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  289. ===================================================================
  290. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 2)
  291. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
  292. @@ -46,6 +46,12 @@
  293. requestor.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
  294. return;
  295. }
  296. +
  297. + if (target.isInFunEvent() || requestor.isInFunEvent())
  298. + {
  299. + requestor.sendMessage("The player you tried to invite is currently in an event.");
  300. + return;
  301. + }
  302.  
  303. if (target.isInParty())
  304. {
  305. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java
  306. ===================================================================
  307. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (revision 2)
  308. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestart.java (working copy)
  309. @@ -7,6 +7,7 @@
  310. import net.sf.l2j.gameserver.network.L2GameClient.GameClientState;
  311. import net.sf.l2j.gameserver.network.SystemMessageId;
  312. import net.sf.l2j.gameserver.network.serverpackets.CharSelectInfo;
  313. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  314. import net.sf.l2j.gameserver.network.serverpackets.RestartResponse;
  315. import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
  316.  
  317. @@ -43,7 +44,12 @@
  318. sendPacket(RestartResponse.valueOf(false));
  319. return;
  320. }
  321. -
  322. + if (player.isInFunEvent())
  323. + {
  324. + player.sendPacket(new ExShowScreenMessage("You can not Restart the event.", 3000, 0x02, true));
  325. + sendPacket(RestartResponse.valueOf(false));
  326. + return;
  327. + }
  328. if (player.isFestivalParticipant() && SevenSignsFestival.getInstance().isFestivalInitialized())
  329. {
  330. player.sendPacket(SystemMessageId.NO_RESTART_HERE);
  331. Index: java/net/sf/l2j/gameserver/GameServer.java
  332. ===================================================================
  333. --- java/net/sf/l2j/gameserver/GameServer.java (revision 2)
  334. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  335. @@ -65,6 +65,7 @@
  336. import net.sf.l2j.gameserver.handler.ItemHandler;
  337. import net.sf.l2j.gameserver.handler.SkillHandler;
  338. import net.sf.l2j.gameserver.handler.UserCommandHandler;
  339. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  340. import net.sf.l2j.gameserver.idfactory.IdFactory;
  341. import net.sf.l2j.gameserver.instancemanager.AuctionManager;
  342. import net.sf.l2j.gameserver.instancemanager.AutoSpawnManager;
  343. @@ -84,6 +85,7 @@
  344. import net.sf.l2j.gameserver.model.boat.BoatRunePrimeval;
  345. import net.sf.l2j.gameserver.model.boat.BoatTalkingGludin;
  346. import net.sf.l2j.gameserver.model.entity.Hero;
  347. +import net.sf.l2j.gameserver.model.entity.engine.impl.manager.EngineManager;
  348. import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  349. import net.sf.l2j.gameserver.model.olympiad.OlympiadGameManager;
  350. import net.sf.l2j.gameserver.model.partymatching.PartyMatchRoomList;
  351. @@ -270,6 +272,9 @@
  352. if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
  353. FishingChampionshipManager.getInstance();
  354.  
  355. + StringUtil.printSection("Events jDevs");
  356. + EngineManager.getInstance();
  357. +
  358. StringUtil.printSection("Handlers");
  359. LOGGER.info("AutoSpawnHandler: Loaded {} handlers.", AutoSpawnManager.getInstance().size());
  360. LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
  361. @@ -277,6 +282,7 @@
  362. LOGGER.info("Loaded {} item handlers.", ItemHandler.getInstance().size());
  363. LOGGER.info("Loaded {} skill handlers.", SkillHandler.getInstance().size());
  364. LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
  365. + LOGGER.info("Loaded {} voiced command handlers." , VoicedCommandHandler.getInstance().size());
  366.  
  367. StringUtil.printSection("System");
  368. Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
  369. Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java
  370. ===================================================================
  371. --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java (revision 0)
  372. +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventTeam.java (working copy)
  373. @@ -0,0 +1,189 @@
  374. +package net.sf.l2j.gameserver.model.entity.engine.impl;
  375. +
  376. +import java.util.HashMap;
  377. +import java.util.Map;
  378. +import java.util.Vector;
  379. +
  380. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  381. +
  382. +/**
  383. + * @author williams
  384. + *
  385. + */
  386. +public class EventTeam
  387. +{
  388. + /** The name of the team */
  389. + private String _name;
  390. +
  391. + /** The team spot coordinated */
  392. + private int[] _coordinates = new int[3];
  393. +
  394. + /** The points of the team */
  395. + private short _points;
  396. +
  397. + /** Name and instance of all participated players in HashMap */
  398. + private Map<String, Player> _participatedPlayers = new HashMap<>();
  399. +
  400. + /** Name of all participated players in Vector */
  401. + private Vector<String> _participatedPlayerNames = new Vector<>();
  402. +
  403. + /**
  404. + * C'tor initialize the team
  405. + * @param name
  406. + * @param coordinates
  407. + */
  408. + public EventTeam(String name, int[] coordinates)
  409. + {
  410. + _name = name;
  411. + _coordinates = coordinates;
  412. + _points = 0;
  413. + }
  414. +
  415. + /**
  416. + * Adds a player to the team
  417. + * @param player
  418. + * @return boolean
  419. + */
  420. + public boolean addPlayer(Player player)
  421. + {
  422. + if (player == null)
  423. + return false;
  424. +
  425. + synchronized (_participatedPlayers)
  426. + {
  427. + String playerName = player.getName();
  428. +
  429. + _participatedPlayers.put(playerName, player);
  430. +
  431. + if (!_participatedPlayerNames.contains(playerName))
  432. + _participatedPlayerNames.add(playerName);
  433. + }
  434. +
  435. + return true;
  436. + }
  437. +
  438. + /**
  439. + * Removes a player from the team
  440. + * @param playerName
  441. + */
  442. + public void removePlayer(String playerName)
  443. + {
  444. + synchronized (_participatedPlayers)
  445. + {
  446. + _participatedPlayers.remove(playerName);
  447. + _participatedPlayerNames.remove(playerName);
  448. + }
  449. + }
  450. +
  451. + /**
  452. + * Increases the points of the team
  453. + */
  454. + public void increasePoints()
  455. + {
  456. + _points++;
  457. + }
  458. +
  459. + /**
  460. + * Cleanup the team and make it ready for adding players again
  461. + */
  462. + public void cleanMe()
  463. + {
  464. + _participatedPlayers.clear();
  465. + _participatedPlayerNames.clear();
  466. + _participatedPlayers = new HashMap<>();
  467. + _participatedPlayerNames = new Vector<>();
  468. + _points = 0;
  469. + }
  470. +
  471. + /**
  472. + * Is given player in this team?
  473. + * @param playerName
  474. + * @return boolean
  475. + */
  476. + public boolean containsPlayer(String playerName)
  477. + {
  478. + boolean containsPlayer;
  479. +
  480. + synchronized (_participatedPlayers)
  481. + {
  482. + containsPlayer = _participatedPlayerNames.contains(playerName);
  483. + }
  484. +
  485. + return containsPlayer;
  486. + }
  487. +
  488. + /**
  489. + * Returns the name of the team
  490. + * @return String
  491. + */
  492. + public String getName()
  493. + {
  494. + return _name;
  495. + }
  496. +
  497. + /**
  498. + * Returns the coordinates of the team spot
  499. + * @return int[]
  500. + */
  501. + public int[] getCoordinates()
  502. + {
  503. + return _coordinates;
  504. + }
  505. +
  506. + /**
  507. + * Returns the points of the team
  508. + * @return short
  509. + */
  510. + public short getPoints()
  511. + {
  512. + return _points;
  513. + }
  514. +
  515. + /**
  516. + * Returns name and instance of all participated players in HashMap
  517. + * @return Map<String, Player>
  518. + */
  519. + public Map<String, Player> getParticipatedPlayers()
  520. + {
  521. + Map<String, Player> participatedPlayers = null;
  522. +
  523. + synchronized (_participatedPlayers)
  524. + {
  525. + participatedPlayers = _participatedPlayers;
  526. + }
  527. +
  528. + return participatedPlayers;
  529. + }
  530. +
  531. + /**
  532. + * Returns name of all participated players in Vector
  533. + * @return Vector<String>
  534. + */
  535. + public Vector<String> getParticipatedPlayerNames()
  536. + {
  537. + Vector<String> participatedPlayerNames = null;
  538. +
  539. + synchronized (_participatedPlayers)
  540. + {
  541. + participatedPlayerNames = _participatedPlayerNames;
  542. + }
  543. +
  544. + return participatedPlayerNames;
  545. + }
  546. +
  547. + /**
  548. + * Returns player count of this team
  549. + * @return int
  550. + */
  551. + public int getParticipatedPlayerCount()
  552. + {
  553. + int participatedPlayerCount;
  554. +
  555. + synchronized (_participatedPlayers)
  556. + {
  557. + participatedPlayerCount = _participatedPlayers.size();
  558. + }
  559. +
  560. + return participatedPlayerCount;
  561. + }
  562. +}
  563. \ No newline at end of file
  564. Index: java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java
  565. ===================================================================
  566. --- java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java (revision 0)
  567. +++ java/net/sf/l2j/gameserver/model/entity/engine/TeamVsTeam.java (working copy)
  568. @@ -0,0 +1,744 @@
  569. +package net.sf.l2j.gameserver.model.entity.engine;
  570. +
  571. +import net.sf.l2j.commons.concurrent.ThreadPool;
  572. +import net.sf.l2j.commons.random.Rnd;
  573. +
  574. +import net.sf.l2j.Config;
  575. +import net.sf.l2j.gameserver.data.ItemTable;
  576. +import net.sf.l2j.gameserver.data.SpawnTable;
  577. +import net.sf.l2j.gameserver.data.xml.DoorData;
  578. +import net.sf.l2j.gameserver.data.xml.NpcData;
  579. +import net.sf.l2j.gameserver.model.L2Spawn;
  580. +import net.sf.l2j.gameserver.model.World;
  581. +import net.sf.l2j.gameserver.model.actor.Creature;
  582. +import net.sf.l2j.gameserver.model.actor.Npc;
  583. +import net.sf.l2j.gameserver.model.actor.Summon;
  584. +import net.sf.l2j.gameserver.model.actor.instance.Door;
  585. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  586. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  587. +import net.sf.l2j.gameserver.model.actor.instance.Servitor;
  588. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  589. +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeam;
  590. +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeleport;
  591. +import net.sf.l2j.gameserver.model.entity.engine.impl.EventsState;
  592. +import net.sf.l2j.gameserver.model.location.Location;
  593. +import net.sf.l2j.gameserver.network.SystemMessageId;
  594. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  595. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  596. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  597. +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  598. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  599. +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  600. +import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  601. +import net.sf.l2j.gameserver.util.Broadcast;
  602. +
  603. +/**
  604. + * @author williams
  605. + *
  606. + */
  607. +public class TeamVsTeam
  608. +{
  609. + /** The teams of the TeamVsTeam */
  610. + public static EventTeam[] _teams = new EventTeam[2]; // event only allow max 2 teams
  611. + /** The state of the TeamVsTeam */
  612. + public static EventsState _state = EventsState.INACTIVE;
  613. +
  614. + /**
  615. + * Teams initializing<br>
  616. + */
  617. + public static void init()
  618. + {
  619. + _teams[0] = new EventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
  620. + _teams[1] = new EventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
  621. + }
  622. +
  623. + /**
  624. + * Starts the participation of the TeamVsTeam<br>
  625. + * 1. Try to spawn a new npc of it<br>
  626. + * <br>
  627. + * @return boolean<br>
  628. + */
  629. + public static boolean startParticipation()
  630. + {
  631. + try
  632. + {
  633. + final NpcTemplate template = NpcData.getInstance().getTemplate(Config.EVENTS_PARTICIPATION_NPC_ID);
  634. + final L2Spawn spawn = new L2Spawn(template);
  635. + spawn.setLoc(Config.EVENTS_PARTICIPATION_NPC_COORDINATES[0], Config.EVENTS_PARTICIPATION_NPC_COORDINATES[1], Config.EVENTS_PARTICIPATION_NPC_COORDINATES[2], 0);
  636. +
  637. + SpawnTable.getInstance().addNewSpawn(spawn, false);
  638. + final Npc npc = spawn.doSpawn(true);
  639. + npc.scheduleDespawn(Config.TVT_EVENT_RUNNING_TIME * 1000 * 60);
  640. + npc.broadcastPacket(new MagicSkillUse(npc, npc, 1034, 1, 1, 1));
  641. + }
  642. + catch (Exception e)
  643. + {
  644. + System.out.println("TeamVsTeam: exception: " + e);
  645. + return false;
  646. + }
  647. + setState(EventsState.PARTICIPATING);
  648. + return true;
  649. + }
  650. +
  651. + /**
  652. + * Starts the TeamVsTeam fight<br>
  653. + * 1. Set state EventsState.STARTING<br>
  654. + * 2. Close doors specified in configs<br>
  655. + * 3. Abort if not enought participants(return false)<br>
  656. + * 4. Set state EventsState.STARTED<br>
  657. + * 5. Teleport all participants to team spot<br>
  658. + * <br>
  659. + * @return boolean<br>
  660. + */
  661. + public static boolean startFight()
  662. + {
  663. + setState(EventsState.STARTING);
  664. +
  665. + // not enought participants
  666. + if (_teams[0].getParticipatedPlayerCount() < Config.EVENTS_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.EVENTS_MIN_PLAYERS_IN_TEAMS)
  667. + {
  668. + setState(EventsState.INACTIVE);
  669. + _teams[0].cleanMe();
  670. + _teams[1].cleanMe();
  671. + return false;
  672. + }
  673. +
  674. + closeDoors();
  675. + setState(EventsState.STARTED); // set state to STARTED here, so TeamVsTeamTeleporter know to teleport to team spot
  676. +
  677. + // teleport all participants to there team spot
  678. + for (EventTeam team : _teams)
  679. + {
  680. + for (String playerName : team.getParticipatedPlayerNames())
  681. + {
  682. + Player player = team.getParticipatedPlayers().get(playerName);
  683. +
  684. + if (player == null)
  685. + continue;
  686. +
  687. + if (isStarted())
  688. + player.setTeam(getParticipantTeamId(player.getName()) + 1);
  689. + else
  690. + player.setTeam(0);
  691. +
  692. + ThreadPool.schedule(new Runnable()
  693. + {
  694. + @Override
  695. + public void run()
  696. + {
  697. + player.sendPacket(new ExShowScreenMessage("Fight starts in 5 seconds!", 5000, 0x02, true));
  698. + }
  699. + }, 1000 * 13);
  700. +
  701. + ThreadPool.schedule(new Runnable()
  702. + {
  703. + @Override
  704. + public void run()
  705. + {
  706. + player.broadcastPacket(new SocialAction(player, 4));
  707. + player.sendPacket(new ExShowScreenMessage("Fight started!", 5000, 0x02, true));
  708. + }
  709. + }, 1000 * 20);
  710. +
  711. + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
  712. + {
  713. + player.setTitle("Kills: " + player.getScore());
  714. + player.getAppearance().setVisibleTitle("Kills: " + player.getScore());
  715. + player.broadcastTitleInfo();
  716. + }
  717. +
  718. + player.getSavedLocation().set(player.getPosition());
  719. + // implements Runnable and starts itself in constructor
  720. + new EventTeleport(player, team.getCoordinates(), false, false);
  721. + }
  722. + }
  723. + return true;
  724. + }
  725. +
  726. + /**
  727. + * Calculates the TeamVsTeam reward<br>
  728. + * 1. If both teams are at a tie(points equals), send it as system message to all participants, if one of the teams have 0 participants left online abort rewarding<br>
  729. + * 2. Wait till teams are not at a tie anymore<br>
  730. + * 3. Set state EvcentState.REWARDING<br>
  731. + * 4. Reward team with more points<br>
  732. + * 5. Show win html to wining team participants<br>
  733. + * <br>
  734. + * @return String<br>
  735. + */
  736. + public static String calculateRewards()
  737. + {
  738. + if (_teams[0].getPoints() == _teams[1].getPoints())
  739. + {
  740. + if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
  741. + {
  742. + // the fight cannot be completed
  743. + setState(EventsState.REWARDING);
  744. + return "TeamVsTeam: Event finish. No team won, cause of inactivity!";
  745. + }
  746. + sysMsgToAllParticipants("TeamVsTeam: Both teams are at a tie, next team to get a kill wins!");
  747. + }
  748. +
  749. + while (_teams[0].getPoints() == _teams[1].getPoints())
  750. + {
  751. + waiter(1);
  752. + }
  753. +
  754. + setState(EventsState.REWARDING); // after state REWARDING is set, nobody can point anymore
  755. +
  756. + byte teamId = (byte) (_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
  757. + EventTeam team = _teams[teamId];
  758. +
  759. + for (Player player : team.getParticipatedPlayers().values())
  760. + {
  761. + if (player == null)
  762. + continue;
  763. +
  764. + for (int[] reward : Config.TVT_EVENT_REWARDS)
  765. + {
  766. + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
  767. + player.getInventory().addItem("TeamVsTeam", reward[0], reward[1], player, player);
  768. + else
  769. + {
  770. + for (int i = 0; i < reward[1]; i++)
  771. + player.getInventory().addItem("TeamVsTeam", reward[0], 1, player, player);
  772. + }
  773. +
  774. + if (reward[1] > 1)
  775. + {
  776. + SystemMessage systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  777. + systemMessage.addItemName(reward[0]);
  778. + systemMessage.addNumber(reward[1]);
  779. + }
  780. + else
  781. + {
  782. + SystemMessage systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  783. + systemMessage.addItemName(reward[0]);
  784. + player.sendPacket(systemMessage);
  785. + }
  786. + }
  787. +
  788. + StatusUpdate statusUpdate = new StatusUpdate(player);
  789. + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
  790. + player.sendPacket(statusUpdate);
  791. +
  792. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  793. + npcHtmlMessage.setHtml("<html><head><title>Team Vs Team</title></head><body><font color=\"LEVEL\">Your team won the event!</font><br>Look in your inventory, there should be your reward.</body></html>");
  794. + player.sendPacket(npcHtmlMessage);
  795. +
  796. + }
  797. + return "TeamVsTeam: Event finish. Team " + team.getName() + " won with " + team.getPoints() + " kills.";
  798. + }
  799. +
  800. + /**
  801. + * Stops the TeamVsTeam fight<br>
  802. + * 1. Set state EventsState.INACTIVATING<br>
  803. + * 2. Remove TeamVsTeam npc from world<br>
  804. + * 3. Open doors specified in configs<br>
  805. + * 4. Teleport all participants back to participation npc location<br>
  806. + * 5. Teams cleaning<br>
  807. + * 6. Set state EventsState.INACTIVE<br>
  808. + */
  809. + public static void stopFight()
  810. + {
  811. + setState(EventsState.INACTIVATING);
  812. + openDoors();
  813. +
  814. + for (EventTeam team : _teams)
  815. + {
  816. + for (final Player player : team.getParticipatedPlayers().values())
  817. + {
  818. + if (player == null)
  819. + continue;
  820. +
  821. + final Location loc = player.getSavedLocation();
  822. + if (loc.equals(Location.DUMMY_LOC))
  823. + return;
  824. +
  825. + player.teleToLocation(loc, 0);
  826. + player.getSavedLocation().clean();
  827. +
  828. + if (isInactive())
  829. + player.setTeam(getParticipantTeamId(player.getName()) + 1);
  830. + else
  831. + player.setTeam(0);
  832. +
  833. + player.broadcastPacket(new SocialAction(player, 7));
  834. +
  835. + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
  836. + {
  837. + ThreadPool.schedule(new Runnable()
  838. + {
  839. + @Override
  840. + public void run()
  841. + {
  842. + player.setTitle(player.getOriginalTitle());
  843. + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
  844. + player.broadcastTitleInfo();
  845. + player.clearPoints();
  846. + }
  847. + }, 10 * 1000);
  848. + }
  849. + }
  850. + }
  851. +
  852. + _teams[0].cleanMe();
  853. + _teams[1].cleanMe();
  854. + setState(EventsState.INACTIVE);
  855. + }
  856. +
  857. + /**
  858. + * Adds a player to a TeamVsTeam team<br>
  859. + * 1. Calculate the id of the team in which the player should be added<br>
  860. + * 2. Add the player to the calculated team
  861. + * @param player
  862. + * @return boolean
  863. + */
  864. + public static synchronized boolean addParticipant(Player player)
  865. + {
  866. + if (player == null)
  867. + return false;
  868. +
  869. + byte teamId = 0;
  870. +
  871. + if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
  872. + teamId = (byte) (Rnd.get(2));
  873. + else
  874. + teamId = (byte) (_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
  875. +
  876. + return _teams[teamId].addPlayer(player);
  877. + }
  878. +
  879. + /**
  880. + * Removes a TeamVsTeam player from it's team<br>
  881. + * 1. Get team id of the player<br>
  882. + * 2. Remove player from it's team
  883. + * @param playerName
  884. + * @return boolean
  885. + */
  886. + public static boolean removeParticipant(String playerName)
  887. + {
  888. + byte teamId = getParticipantTeamId(playerName);
  889. +
  890. + if (teamId == -1)
  891. + return false;
  892. +
  893. + for (final Player player : _teams[teamId].getParticipatedPlayers().values())
  894. + {
  895. + if (player != null)
  896. + {
  897. + if (isInactive())
  898. + player.setTeam(getParticipantTeamId(player.getName()) + 1);
  899. + else
  900. + player.setTeam(0);
  901. +
  902. + final Location loc = player.getSavedLocation();
  903. + if (loc.equals(Location.DUMMY_LOC))
  904. + return true;
  905. +
  906. + player.teleToLocation(loc, 0);
  907. + player.getSavedLocation().clean();
  908. + }
  909. + }
  910. +
  911. + _teams[teamId].removePlayer(playerName);
  912. + return true;
  913. + }
  914. +
  915. + /**
  916. + * Send a SystemMessage to all participated players<br>
  917. + * 1. Send the message to all players of team number one<br>
  918. + * 2. Send the message to all players of team number two
  919. + * @param message
  920. + */
  921. + public static void sysMsgToAllParticipants(String message)
  922. + {
  923. + for (Player player : _teams[0].getParticipatedPlayers().values())
  924. + {
  925. + if (player != null)
  926. + player.sendMessage(message);
  927. + }
  928. +
  929. + for (Player player : _teams[1].getParticipatedPlayers().values())
  930. + {
  931. + if (player != null)
  932. + player.sendMessage(message);
  933. + }
  934. + }
  935. +
  936. + /**
  937. + * Close doors specified in configs
  938. + */
  939. + public static void closeDoors()
  940. + {
  941. + for (int doorId : Config.EVENTS_DOORS_IDS_TO_CLOSE)
  942. + {
  943. + Door door = DoorData.getInstance().getDoor(doorId);
  944. +
  945. + if (door != null)
  946. + door.closeMe();
  947. + }
  948. + }
  949. +
  950. + /**
  951. + * Open doors specified in configs
  952. + */
  953. + public static void openDoors()
  954. + {
  955. + for (int doorId : Config.EVENTS_DOORS_IDS_TO_OPEN)
  956. + {
  957. + Door door = DoorData.getInstance().getDoor(doorId);
  958. +
  959. + if (door != null)
  960. + door.openMe();
  961. + }
  962. + }
  963. +
  964. + public static void waiter(int seconds)
  965. + {
  966. + try
  967. + {
  968. + Thread.sleep(seconds * 1000);
  969. + }
  970. + catch (InterruptedException e)
  971. + {
  972. + e.printStackTrace();
  973. + }
  974. + }
  975. +
  976. + /**
  977. + * Called when a player logs in
  978. + * @param player
  979. + */
  980. + public static void onLogin(Player player)
  981. + {
  982. + if (player == null || (!isStarting() && !isStarted()))
  983. + return;
  984. +
  985. + byte teamId = getParticipantTeamId(player.getName());
  986. +
  987. + if (teamId == -1)
  988. + return;
  989. +
  990. + _teams[teamId].addPlayer(player);
  991. + new EventTeleport(player, _teams[teamId].getCoordinates(), true, false);
  992. + }
  993. +
  994. + /**
  995. + * Called when a player logs out
  996. + * @param player
  997. + */
  998. + public static void onLogout(Player player)
  999. + {
  1000. + if (player == null || (!isStarting() && !isStarted()))
  1001. + return;
  1002. +
  1003. + if (isInactive())
  1004. + player.setTeam(getParticipantTeamId(player.getName()) + 1);
  1005. + else
  1006. + player.setTeam(0);
  1007. +
  1008. + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
  1009. + {
  1010. + player.setTitle(player.getOriginalTitle());
  1011. + player.getAppearance().setVisibleTitle(player.getOriginalTitle());
  1012. + player.broadcastTitleInfo();
  1013. + }
  1014. + removeParticipant(player.getName());
  1015. + }
  1016. +
  1017. + /**
  1018. + * Called on every onAction in L2PcIstance
  1019. + * @param playerName
  1020. + * @param targetPlayerName
  1021. + * @return boolean
  1022. + */
  1023. + public static boolean onAction(String playerName, String targetPlayerName)
  1024. + {
  1025. + if (!isStarted())
  1026. + return true;
  1027. +
  1028. + Player player = World.getInstance().getPlayer(playerName);
  1029. +
  1030. + if (player == null)
  1031. + return false;
  1032. +
  1033. + if (player.isGM())
  1034. + return true;
  1035. +
  1036. + byte playerTeamId = getParticipantTeamId(playerName);
  1037. + byte targetPlayerTeamId = getParticipantTeamId(targetPlayerName);
  1038. +
  1039. + if ((playerTeamId != -1 && targetPlayerTeamId == -1) || (playerTeamId == -1 && targetPlayerTeamId != -1))
  1040. + return false;
  1041. +
  1042. + if (playerTeamId != -1 && targetPlayerTeamId != -1 && playerTeamId == targetPlayerTeamId)
  1043. + return false;
  1044. +
  1045. + return true;
  1046. + }
  1047. +
  1048. + /**
  1049. + * Is called when a player is killed
  1050. + * @param killerCharacter
  1051. + * @param killerPlayer
  1052. + */
  1053. + public static void onKill(Creature killerCharacter, Player killerPlayer)
  1054. + {
  1055. + if (killerPlayer == null || !isStarted())
  1056. + return;
  1057. +
  1058. + byte killedTeamId = getParticipantTeamId(killerPlayer.getName());
  1059. +
  1060. + if (killedTeamId == -1)
  1061. + return;
  1062. +
  1063. + new EventTeleport(killerPlayer, _teams[killedTeamId].getCoordinates(), false, false);
  1064. +
  1065. + if (killerCharacter == null)
  1066. + return;
  1067. +
  1068. + if (killerCharacter instanceof Pet || killerCharacter instanceof Servitor)
  1069. + {
  1070. + killerPlayer = ((Summon) killerCharacter).getOwner();
  1071. +
  1072. + if (killerPlayer == null)
  1073. + return;
  1074. + }
  1075. + else if (killerCharacter instanceof Player)
  1076. + killerPlayer = (Player) killerCharacter;
  1077. + else
  1078. + return;
  1079. +
  1080. + for (int[] rewardKills : Config.TVT_EVENT_REWARDS_KILL)
  1081. + {
  1082. + killerPlayer.increaseKills();
  1083. + switch (killerPlayer.getEventKills())
  1084. + {
  1085. + case 5: // Reward after 5 kills without die
  1086. + case 8: // Reward after 8 kills without die
  1087. + case 12: // Reward after 12 kills without die
  1088. + case 15: // Reward after 15 kills without die
  1089. + case 20: // Reward after 20 kills without die
  1090. +
  1091. + SystemMessage systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  1092. + systemMessage.addItemName(rewardKills[0]);
  1093. + systemMessage.addNumber(rewardKills[1]);
  1094. + killerPlayer.sendPacket(systemMessage);
  1095. +
  1096. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Player " + killerPlayer.getName() + " has " + killerPlayer.getEventKills() + " kills without die.", true);
  1097. + killerPlayer.getInventory().addItem("TeamVsTeam", rewardKills[0], rewardKills[1], killerPlayer, killerPlayer);
  1098. + break;
  1099. + }
  1100. + }
  1101. +
  1102. + byte killerTeamId = getParticipantTeamId(killerPlayer.getName());
  1103. +
  1104. + if (killerTeamId != -1 && killedTeamId != -1 && killerTeamId != killedTeamId)
  1105. + {
  1106. + EventTeam killerTeam = _teams[killerTeamId];
  1107. +
  1108. + killerTeam.increasePoints();
  1109. +
  1110. + if (Config.TVT_EVENT_ON_KILL.equalsIgnoreCase("pmtitle"))
  1111. + {
  1112. + sysMsgToAllParticipants(killerPlayer.getName() + " I have killed " + killerPlayer.getName()+ " !");
  1113. + final PlaySound ps = new PlaySound(0, "ItemSound.quest_itemget");
  1114. + _teams[killerTeamId].getParticipatedPlayers().values();
  1115. + killerPlayer.increaseScore();
  1116. + killerPlayer.setTitle("Kills: " + killerPlayer.getScore());
  1117. + killerPlayer.getAppearance().setVisibleTitle("Kills: " + killerPlayer.getScore());
  1118. + killerPlayer.broadcastTitleInfo();
  1119. + killerPlayer.sendPacket(ps);
  1120. + }
  1121. + }
  1122. + }
  1123. +
  1124. + /**
  1125. + * Sets the TeamVsTeam state
  1126. + * @param state
  1127. + */
  1128. + private static void setState(EventsState state)
  1129. + {
  1130. + synchronized (_state)
  1131. + {
  1132. + _state = state;
  1133. + }
  1134. + }
  1135. +
  1136. + /**
  1137. + * Is TeamVsTeam inactive?
  1138. + * @return boolean
  1139. + */
  1140. + public static boolean isInactive()
  1141. + {
  1142. + boolean isInactive;
  1143. +
  1144. + synchronized (_state)
  1145. + {
  1146. + isInactive = _state == EventsState.INACTIVE;
  1147. + }
  1148. +
  1149. + return isInactive;
  1150. + }
  1151. +
  1152. + /**
  1153. + * Is TeamVsTeam in inactivating?
  1154. + * @return boolean
  1155. + */
  1156. + public static boolean isInactivating()
  1157. + {
  1158. + boolean isInactivating;
  1159. +
  1160. + synchronized (_state)
  1161. + {
  1162. + isInactivating = _state == EventsState.INACTIVATING;
  1163. + }
  1164. +
  1165. + return isInactivating;
  1166. + }
  1167. +
  1168. + /**
  1169. + * Is TeamVsTeam in participation?
  1170. + * @return boolean
  1171. + */
  1172. + public static boolean isParticipating()
  1173. + {
  1174. + boolean isParticipating;
  1175. +
  1176. + synchronized (_state)
  1177. + {
  1178. + isParticipating = _state == EventsState.PARTICIPATING;
  1179. + }
  1180. +
  1181. + return isParticipating;
  1182. + }
  1183. +
  1184. + /**
  1185. + * Is TeamVsTeam starting?
  1186. + * @return boolean
  1187. + */
  1188. + public static boolean isStarting()
  1189. + {
  1190. + boolean isStarting;
  1191. +
  1192. + synchronized (_state)
  1193. + {
  1194. + isStarting = _state == EventsState.STARTING;
  1195. + }
  1196. +
  1197. + return isStarting;
  1198. + }
  1199. +
  1200. + /**
  1201. + * Is TeamVsTeam started?
  1202. + * @return boolean
  1203. + */
  1204. + public static boolean isStarted()
  1205. + {
  1206. + boolean isStarted;
  1207. +
  1208. + synchronized (_state)
  1209. + {
  1210. + isStarted = _state == EventsState.STARTED;
  1211. + }
  1212. +
  1213. + return isStarted;
  1214. + }
  1215. +
  1216. + /**
  1217. + * Is TeamVsTeam rewarding?
  1218. + * @return boolean
  1219. + */
  1220. + public static boolean isRewarding()
  1221. + {
  1222. + boolean isRewarding;
  1223. +
  1224. + synchronized (_state)
  1225. + {
  1226. + isRewarding = _state == EventsState.REWARDING;
  1227. + }
  1228. +
  1229. + return isRewarding;
  1230. + }
  1231. +
  1232. + /**
  1233. + * Returns the team id of a player, if player is not participant it returns -1
  1234. + * @param playerName
  1235. + * @return byte
  1236. + */
  1237. + public static byte getParticipantTeamId(String playerName)
  1238. + {
  1239. + return (byte) (_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
  1240. + }
  1241. +
  1242. + /**
  1243. + * Returns the team coordinates in which the player is in, if player is not in a team return null
  1244. + * @param playerName
  1245. + * @return int[]
  1246. + */
  1247. + public static int[] getParticipantTeamCoordinates(String playerName)
  1248. + {
  1249. + return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
  1250. + }
  1251. +
  1252. + /**
  1253. + * Is given player participant of the event?
  1254. + * @param playerName
  1255. + * @return boolean
  1256. + */
  1257. + public static boolean isPlayerParticipant(String playerName)
  1258. + {
  1259. + return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
  1260. + }
  1261. +
  1262. + /**
  1263. + * Returns participated player count<br>
  1264. + * <br>
  1265. + * @return int<br>
  1266. + */
  1267. + public static int getParticipatedPlayersCount()
  1268. + {
  1269. + return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
  1270. + }
  1271. +
  1272. + /**
  1273. + * Returns teams names<br>
  1274. + * <br>
  1275. + * @return String[]<br>
  1276. + */
  1277. + public static String[] getTeamNames()
  1278. + {
  1279. + return new String[]
  1280. + {
  1281. + _teams[0].getName(),
  1282. + _teams[1].getName()
  1283. + };
  1284. + }
  1285. +
  1286. + /**
  1287. + * Returns player count of both teams<br>
  1288. + * <br>
  1289. + * @return int[]<br>
  1290. + */
  1291. + public static int[] getTeamsPlayerCounts()
  1292. + {
  1293. + return new int[]
  1294. + {
  1295. + _teams[0].getParticipatedPlayerCount(),
  1296. + _teams[1].getParticipatedPlayerCount()
  1297. + };
  1298. + }
  1299. +
  1300. + /**
  1301. + * Returns points count of both teams
  1302. + * @return int[]
  1303. + */
  1304. + public static int[] getTeamsPoints()
  1305. + {
  1306. + return new int[]
  1307. + {
  1308. + _teams[0].getPoints(),
  1309. + _teams[1].getPoints()
  1310. + };
  1311. + }
  1312. +}
  1313. \ No newline at end of file
  1314. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  1315. ===================================================================
  1316. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 2)
  1317. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
  1318. @@ -5,6 +5,7 @@
  1319. import net.sf.l2j.gameserver.model.zone.ZoneId;
  1320. import net.sf.l2j.gameserver.network.SystemMessageId;
  1321. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1322. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  1323. import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
  1324.  
  1325. public final class Logout extends L2GameClientPacket
  1326. @@ -27,6 +28,13 @@
  1327. return;
  1328. }
  1329.  
  1330. + if (player.isInFunEvent())
  1331. + {
  1332. + player.sendPacket(new ExShowScreenMessage("You can not Exit the event.", 3000, 0x02, true));
  1333. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1334. + return;
  1335. + }
  1336. +
  1337. if (player.isInsideZone(ZoneId.NO_RESTART))
  1338. {
  1339. player.sendPacket(SystemMessageId.NO_LOGOUT_HERE);
  1340. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java
  1341. ===================================================================
  1342. --- java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (revision 2)
  1343. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/ScrollOfResurrection.java (working copy)
  1344. @@ -11,6 +11,7 @@
  1345. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  1346. import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  1347. import net.sf.l2j.gameserver.network.SystemMessageId;
  1348. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  1349.  
  1350. public class ScrollOfResurrection implements IItemHandler
  1351. {
  1352. @@ -39,6 +40,12 @@
  1353. return;
  1354. }
  1355.  
  1356. + if (activeChar.isInFunEvent())
  1357. + {
  1358. + activeChar.sendPacket(new ExShowScreenMessage("You can't use Scroll Of Resurrection in event." , 8000, 0x02, true));
  1359. + return;
  1360. + }
  1361. +
  1362. // Pet scrolls to ress a player.
  1363. if (item.getItemId() == 6387 && target instanceof Player)
  1364. {
  1365. Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java
  1366. ===================================================================
  1367. --- java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java (revision 0)
  1368. +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/EventsState.java (working copy)
  1369. @@ -0,0 +1,15 @@
  1370. +package net.sf.l2j.gameserver.model.entity.engine.impl;
  1371. +
  1372. +/**
  1373. + * @author williams
  1374. + *
  1375. + */
  1376. +public enum EventsState
  1377. +{
  1378. + INACTIVE,
  1379. + INACTIVATING,
  1380. + PARTICIPATING,
  1381. + STARTING,
  1382. + STARTED,
  1383. + REWARDING
  1384. +}
  1385. Index: java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java
  1386. ===================================================================
  1387. --- java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (revision 2)
  1388. +++ java/net/sf/l2j/gameserver/model/actor/instance/WeddingManagerNpc.java (working copy)
  1389. @@ -122,7 +122,7 @@
  1390. }
  1391.  
  1392. // Simple checks to avoid exploits
  1393. - if (partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  1394. + if (partner.isInFunEvent() || partner.isInJail() || partner.isInOlympiadMode() || partner.isInDuel() || partner.isFestivalParticipant() || (partner.isInParty() && partner.getParty().isInDimensionalRift()) || partner.isInObserverMode())
  1395. {
  1396. player.sendMessage("Due to the current partner's status, the teleportation failed.");
  1397. return;
  1398. Index: java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java
  1399. ===================================================================
  1400. --- java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (revision 2)
  1401. +++ java/net/sf/l2j/gameserver/handler/itemhandlers/SummonItems.java (working copy)
  1402. @@ -42,6 +42,9 @@
  1403. return;
  1404. }
  1405.  
  1406. + if (activeChar.isInFunEvent())
  1407. + return;
  1408. +
  1409. if (activeChar.isInObserverMode())
  1410. return;
  1411.  
  1412. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
  1413. ===================================================================
  1414. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (revision 2)
  1415. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java (working copy)
  1416. @@ -19,6 +19,7 @@
  1417. import net.sf.l2j.gameserver.network.FloodProtectors.Action;
  1418. import net.sf.l2j.gameserver.network.SystemMessageId;
  1419. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1420. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  1421. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1422.  
  1423. public final class RequestBypassToServer extends L2GameClientPacket
  1424. @@ -165,6 +166,12 @@
  1425. return;
  1426. }
  1427.  
  1428. + if (player.isInFunEvent())
  1429. + {
  1430. + player.sendPacket(new ExShowScreenMessage("You can not observe games while registered for events", 5000, 0x02, true));
  1431. + return;
  1432. + }
  1433. +
  1434. if (OlympiadManager.getInstance().isRegisteredInComp(player))
  1435. {
  1436. player.sendPacket(SystemMessageId.WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
  1437. Index: java/net/sf/l2j/gameserver/model/actor/instance/Player.java
  1438. ===================================================================
  1439. --- java/net/sf/l2j/gameserver/model/actor/instance/Player.java (revision 2)
  1440. +++ java/net/sf/l2j/gameserver/model/actor/instance/Player.java (working copy)
  1441. @@ -105,6 +105,7 @@
  1442. import net.sf.l2j.gameserver.model.entity.Hero;
  1443. import net.sf.l2j.gameserver.model.entity.Siege;
  1444. import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
  1445. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  1446. import net.sf.l2j.gameserver.model.group.CommandChannel;
  1447. import net.sf.l2j.gameserver.model.group.Party;
  1448. import net.sf.l2j.gameserver.model.group.Party.LootRule;
  1449. @@ -578,6 +579,9 @@
  1450.  
  1451. private Door _requestedGate;
  1452.  
  1453. + private int _eventkills;
  1454. + private short _points = 0;
  1455. +
  1456. /**
  1457. * Constructor of Player (use Creature constructor).
  1458. * <ul>
  1459. @@ -2897,6 +2901,13 @@
  1460. @Override
  1461. public void onAction(Player player)
  1462. {
  1463. + // Check if this Player is in an event
  1464. + if (!TeamVsTeam.onAction(player.getName(), getName()))
  1465. + {
  1466. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1467. + return;
  1468. + }
  1469. +
  1470. // Set the target of the player
  1471. if (player.getTarget() != this)
  1472. player.setTarget(this);
  1473. @@ -2908,7 +2919,7 @@
  1474. player.getAI().setIntention(CtrlIntention.INTERACT, this);
  1475. return;
  1476. }
  1477. -
  1478. +
  1479. // Check if this Player is autoAttackable
  1480. if (isAutoAttackable(player))
  1481. {
  1482. @@ -2941,6 +2952,13 @@
  1483. {
  1484. if (player.isGM())
  1485. AdminEditChar.showCharacterInfo(player, this);
  1486. +
  1487. + // Check if this Player is in an event
  1488. + if (!TeamVsTeam.onAction(player.getName(), getName()))
  1489. + {
  1490. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1491. + return;
  1492. + }
  1493.  
  1494. super.onActionShift(player);
  1495. }
  1496. @@ -3649,16 +3667,21 @@
  1497. if (isMounted())
  1498. stopFeed();
  1499.  
  1500. + // kill the player in event
  1501. + getEventKills();
  1502. +
  1503. synchronized (this)
  1504. {
  1505. if (isFakeDeath())
  1506. stopFakeDeath(true);
  1507. }
  1508.  
  1509. + TeamVsTeam.onKill(killer, this);
  1510. +
  1511. if (killer != null)
  1512. {
  1513. Player pk = killer.getActingPlayer();
  1514. -
  1515. +
  1516. // Clear resurrect xp calculation
  1517. setExpBeforeDeath(0);
  1518.  
  1519. @@ -3896,6 +3919,9 @@
  1520. if (player == null)
  1521. return;
  1522.  
  1523. + if (isInFunEvent() == false)
  1524. + return;
  1525. +
  1526. if (isInDuel() && player.getDuelId() == getDuelId())
  1527. return;
  1528.  
  1529. @@ -6296,6 +6322,10 @@
  1530. if (attacker instanceof Monster)
  1531. return true;
  1532.  
  1533. + // Check if the attacker is in events started
  1534. + if (isInFunEvent())
  1535. + return true;
  1536. +
  1537. // Check if the attacker is not in the same party
  1538. if (_party != null && _party.containsPlayer(attacker))
  1539. return false;
  1540. @@ -9278,6 +9308,9 @@
  1541.  
  1542. if (OlympiadManager.getInstance().isRegisteredInComp(this))
  1543. OlympiadManager.getInstance().removeDisconnectedCompetitor(this);
  1544. +
  1545. + if (isInFunEvent())
  1546. + TeamVsTeam.removeParticipant(getName());
  1547.  
  1548. // Open a Html message to inform the player
  1549. final NpcHtmlMessage html = new NpcHtmlMessage(0);
  1550. @@ -9425,7 +9458,7 @@
  1551. if (_deathPenaltyBuffLevel >= 15) // maximum level reached
  1552. return;
  1553.  
  1554. - 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)))
  1555. + 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())
  1556. {
  1557. if (_deathPenaltyBuffLevel != 0)
  1558. removeSkill(5076, false);
  1559. @@ -9808,7 +9841,7 @@
  1560. if (summonerChar == null)
  1561. return false;
  1562.  
  1563. - if (summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
  1564. + if (summonerChar.isInFunEvent() || summonerChar.isInOlympiadMode() || summonerChar.isInObserverMode() || summonerChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) || summonerChar.isMounted())
  1565. return false;
  1566.  
  1567. return true;
  1568. @@ -9845,7 +9878,7 @@
  1569. return false;
  1570. }
  1571.  
  1572. - if (targetChar.isFestivalParticipant() || targetChar.isMounted())
  1573. + if (targetChar.isFestivalParticipant() || targetChar.isMounted() || targetChar.isInFunEvent())
  1574. {
  1575. summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  1576. return false;
  1577. @@ -10237,4 +10270,34 @@
  1578. }
  1579. }
  1580. }
  1581. +
  1582. + public int getEventKills()
  1583. + {
  1584. + return _eventkills;
  1585. + }
  1586. +
  1587. + public void increaseKills()
  1588. + {
  1589. + _eventkills++;
  1590. + }
  1591. +
  1592. + public short getScore()
  1593. + {
  1594. + return _points;
  1595. + }
  1596. +
  1597. + public void clearPoints()
  1598. + {
  1599. + _points = 0;
  1600. + }
  1601. +
  1602. + public void increaseScore()
  1603. + {
  1604. + _points++;
  1605. + }
  1606. +
  1607. + public boolean isInFunEvent()
  1608. + {
  1609. + return ((TeamVsTeam.isStarted() && TeamVsTeam.isPlayerParticipant(getName())) && !isGM());
  1610. + }
  1611. }
  1612. \ No newline at end of file
  1613. Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
  1614. ===================================================================
  1615. --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
  1616. +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (working copy)
  1617. @@ -0,0 +1,14 @@
  1618. +package net.sf.l2j.gameserver.handler;
  1619. +
  1620. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  1621. +
  1622. +/**
  1623. + * @author Williams
  1624. + *
  1625. + */
  1626. +public interface IVoicedCommandHandler
  1627. +{
  1628. + public boolean useVoicedCommand(String command, Player activeChar, String params);
  1629. +
  1630. + public String[] getVoicedCommandList();
  1631. +}
  1632. \ No newline at end of file
  1633. Index: java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java
  1634. ===================================================================
  1635. --- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 2)
  1636. +++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
  1637. @@ -1,9 +1,11 @@
  1638. package net.sf.l2j.gameserver.model.actor.appearance;
  1639.  
  1640. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  1641. import net.sf.l2j.gameserver.model.base.Sex;
  1642.  
  1643. public final class PcAppearance
  1644. {
  1645. + private Player _owner;
  1646. private byte _face;
  1647. private byte _hairColor;
  1648. private byte _hairStyle;
  1649. @@ -11,6 +13,8 @@
  1650. private boolean _invisible = false;
  1651. private int _nameColor = 0xFFFFFF;
  1652. private int _titleColor = 0xFFFF77;
  1653. + private String _visibleName;
  1654. + private String _visibleTitle;
  1655.  
  1656. public PcAppearance(byte face, byte hColor, byte hStyle, Sex sex)
  1657. {
  1658. @@ -104,4 +108,40 @@
  1659. {
  1660. _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
  1661. }
  1662. +
  1663. + public final void setVisibleName(String visibleName)
  1664. + {
  1665. + _visibleName = visibleName;
  1666. + }
  1667. +
  1668. + public final String getVisibleName()
  1669. + {
  1670. + if (_visibleName == null)
  1671. + _visibleName = getOwner().getName();
  1672. +
  1673. + return _visibleName;
  1674. + }
  1675. +
  1676. + public final void setVisibleTitle(String visibleTitle)
  1677. + {
  1678. + _visibleTitle = visibleTitle;
  1679. + }
  1680. +
  1681. + public final String getVisibleTitle()
  1682. + {
  1683. + if (_visibleTitle == null)
  1684. + _visibleTitle = getOwner().getTitle();
  1685. +
  1686. + return _visibleTitle;
  1687. + }
  1688. +
  1689. + public void setOwner(Player owner)
  1690. + {
  1691. + _owner = owner;
  1692. + }
  1693. +
  1694. + public Player getOwner()
  1695. + {
  1696. + return _owner;
  1697. + }
  1698. }
  1699. \ No newline at end of file
  1700. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java
  1701. ===================================================================
  1702. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (revision 2)
  1703. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestGiveNickName.java (working copy)
  1704. @@ -24,6 +24,13 @@
  1705. final Player activeChar = getClient().getActiveChar();
  1706. if (activeChar == null)
  1707. return;
  1708. +
  1709. + // check participants can not change their title
  1710. + if (activeChar.isInFunEvent())
  1711. + {
  1712. + activeChar.sendMessage("You cannot change title while participating in an event.");
  1713. + return;
  1714. + }
  1715.  
  1716. // Noblesse can bestow a title to themselves
  1717. if (activeChar.isNoble() && _target.matches(activeChar.getName()))
  1718. Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
  1719. ===================================================================
  1720. --- java/net/sf/l2j/gameserver/model/actor/Creature.java (revision 2)
  1721. +++ java/net/sf/l2j/gameserver/model/actor/Creature.java (working copy)
  1722. @@ -131,6 +131,8 @@
  1723. private CreatureTemplate _template; // The link on the L2CharTemplate object containing generic and static properties
  1724.  
  1725. protected String _title;
  1726. + protected String _originalTitle;
  1727. +
  1728. private double _hpUpdateIncCheck = .0;
  1729. private double _hpUpdateDecCheck = .0;
  1730. private double _hpUpdateInterval = .0;
  1731. @@ -1888,6 +1890,14 @@
  1732. {
  1733. return _title;
  1734. }
  1735. +
  1736. + /**
  1737. + * @return the Title of the Creature.
  1738. + */
  1739. + public final String getOriginalTitle()
  1740. + {
  1741. + return _originalTitle;
  1742. + }
  1743.  
  1744. /**
  1745. * Set the Title of the Creature. Concatens it if length > 16.
  1746. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  1747. ===================================================================
  1748. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 2)
  1749. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  1750. @@ -17,6 +17,7 @@
  1751. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEditNpc;
  1752. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEffects;
  1753. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEnchant;
  1754. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminEvents;
  1755. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminExpSp;
  1756. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGeoEngine;
  1757. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminGm;
  1758. @@ -63,6 +64,7 @@
  1759. registerHandler(new AdminCursedWeapons());
  1760. registerHandler(new AdminDelete());
  1761. registerHandler(new AdminDoorControl());
  1762. + registerHandler(new AdminEvents());
  1763. registerHandler(new AdminEditChar());
  1764. registerHandler(new AdminEditNpc());
  1765. registerHandler(new AdminEffects());
  1766. Index: java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java
  1767. ===================================================================
  1768. --- java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java (revision 0)
  1769. +++ java/net/sf/l2j/gameserver/model/actor/instance/EventsManager.java (working copy)
  1770. @@ -0,0 +1,172 @@
  1771. +package net.sf.l2j.gameserver.model.actor.instance;
  1772. +
  1773. +import net.sf.l2j.Config;
  1774. +import net.sf.l2j.gameserver.data.ItemTable;
  1775. +import net.sf.l2j.gameserver.data.cache.HtmCache;
  1776. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  1777. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  1778. +import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
  1779. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  1780. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1781. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  1782. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1783. +
  1784. +/**
  1785. + * @author williams
  1786. + *
  1787. + */
  1788. +public class EventsManager extends Folk
  1789. +{
  1790. + public EventsManager(int objectId, NpcTemplate template)
  1791. + {
  1792. + super(objectId, template);
  1793. + }
  1794. +
  1795. + @Override
  1796. + public void onBypassFeedback(Player player, String command)
  1797. + {
  1798. + if (player == null || !TeamVsTeam.isParticipating())
  1799. + return;
  1800. +
  1801. + /**if (player.isAio())
  1802. + {
  1803. + player.sendPacket(new ExShowScreenMessage("Aio player can not register.", 3000, 0x02, true));
  1804. + return;
  1805. + }
  1806. + */
  1807. + if (command.equals("events_participation"))
  1808. + {
  1809. + /**if (DeathMatch.isPlayerParticipant(player.getName()) || CaptureTheFlag.isPlayerParticipant(player.getName()) || TeamVsTeamRound.isPlayerParticipant(player.getName()))
  1810. + player.sendPacket(new ExShowScreenMessage("You can not participate when registered to another event.", 3000, 0x02, true));
  1811. + else*/ if (player.isInDuel())
  1812. + player.sendPacket(new ExShowScreenMessage("You must complete the duel before register.", 3000, 0x02, true));
  1813. + else if (player.isMounted())
  1814. + player.sendPacket(new ExShowScreenMessage("Revoke your pet before register.", 3000, 0x02, true));
  1815. + else if (player.isInJail())
  1816. + player.sendPacket(new ExShowScreenMessage("You can't register from the jail.", 3000, 0x02, true));
  1817. + else if (player.isDead())
  1818. + player.sendPacket(new ExShowScreenMessage("You can't register while you are dead.", 3000, 0x02, true));
  1819. + else if (player.isCursedWeaponEquipped())
  1820. + player.sendPacket(new ExShowScreenMessage("Cursed weapon owners are not allowed to participate.", 3000, 0x02, true));
  1821. + else if (OlympiadManager.getInstance().isRegistered(player))
  1822. + player.sendPacket(new ExShowScreenMessage("You can not participate when registered for Olympiad.", 3000, 0x02, true));
  1823. + else if (Config.LIST_RESTRICTED_CLASSES_IN_EVENTS.contains(player.getTemplate().getClassId().getId()))
  1824. + player.sendPacket(new ExShowScreenMessage("Your class isn't allowed in this event.", 3000, 0x02, true));
  1825. + //else if (player.isAio())
  1826. + //player.sendPacket(new ExShowScreenMessage("Aio charactes are not allowed to participate in events.", 3000, 0x02, true));
  1827. + else if (player.getKarma() > 0)
  1828. + player.sendPacket(new ExShowScreenMessage("Chaotic players are not allowed to participate.", 3000, 0x02, true));
  1829. + else if (player.getLevel() < Config.EVENTS_MIN_LVL || player.getLevel() > Config.EVENTS_MAX_LVL)
  1830. + player.sendPacket(new ExShowScreenMessage("Only players from level "+ Config.EVENTS_MIN_LVL +" to level "+ Config.EVENTS_MAX_LVL + " are allowed tro participate.", 3000, 0x02, true));
  1831. + else if (TeamVsTeam._teams[0].getParticipatedPlayerCount() == Config.EVENTS_MAX_PLAYERS_IN_TEAMS && TeamVsTeam._teams[1].getParticipatedPlayerCount() == Config.EVENTS_MAX_PLAYERS_IN_TEAMS)
  1832. + player.sendPacket(new ExShowScreenMessage("The event is full! Only "+ Config.EVENTS_MAX_PLAYERS_IN_TEAMS +" players are allowed per team.", 3000, 0x02, true));
  1833. + // else if (Config.EVENTS_MAX_PARTICIPANTS_PER_IP > 0 && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.TVT_ID, player, Config.EVENTS_MAX_PARTICIPANTS_PER_IP))
  1834. + // player.sendPacket(new ExShowScreenMessage("Maximum "+ AntiFeedManager.getInstance().getLimit(player, Config.EVENTS_MAX_PARTICIPANTS_PER_IP) +" participant(s) per IP address is allowed.", 3000, 0x02, true));
  1835. + else if (needParticipationFee() && !hasParticipationFee(player))
  1836. + player.sendPacket(new ExShowScreenMessage("You need "+ getParticipationFee() +" for participation.", 3000, 0x02, true));
  1837. + else if (TeamVsTeam.addParticipant(player))
  1838. + {
  1839. + player.sendPacket(new ExShowScreenMessage("You are on the registration list now.", 3000, 0x02, true));
  1840. + payParticipationFee(player);
  1841. + }
  1842. + else
  1843. + return;
  1844. + }
  1845. + else if (command.equals("events_remove_participation"))
  1846. + {
  1847. + player.sendPacket(new ExShowScreenMessage("You are not longer on the registration list.", 3000, 0x02, true));
  1848. + if (refundParticipationFee(player) != null)
  1849. + TeamVsTeam.removeParticipant(player.getName());
  1850. +
  1851. + //if (Config.EVENTS_MAX_PARTICIPANTS_PER_IP > 0)
  1852. + //AntiFeedManager.getInstance().removePlayer(AntiFeedManager.TVT_ID, player);
  1853. + }
  1854. + }
  1855. +
  1856. + @Override
  1857. + public void showChatWindow(Player player, int val)
  1858. + {
  1859. + if (player == null)
  1860. + return;
  1861. +
  1862. + if (TeamVsTeam.isParticipating())
  1863. + {
  1864. + boolean isParticipant = TeamVsTeam.isPlayerParticipant(player.getName());
  1865. + String htmContent;
  1866. + if (!isParticipant)
  1867. + htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/Participation.htm");
  1868. + else
  1869. + htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/RemoveParticipation.htm");
  1870. +
  1871. + if (htmContent != null)
  1872. + {
  1873. + int[] teamsPlayerCounts = TeamVsTeam.getTeamsPlayerCounts();
  1874. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1875. +
  1876. + npcHtmlMessage.setHtml(htmContent);
  1877. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1878. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  1879. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1880. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  1881. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1882. + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
  1883. +
  1884. + if (!isParticipant)
  1885. + npcHtmlMessage.replace("%fee%", getParticipationFee());
  1886. +
  1887. + player.sendPacket(npcHtmlMessage);
  1888. + }
  1889. + }
  1890. + else if ((TeamVsTeam.isStarting()) || (TeamVsTeam.isStarted()))
  1891. + {
  1892. + String htmContent = HtmCache.getInstance().getHtm("data/html/mods/TeamVsTeam/Status.htm");
  1893. + if (htmContent != null)
  1894. + {
  1895. + int[] teamsPlayerCounts = TeamVsTeam.getTeamsPlayerCounts();
  1896. + int[] teamsPointsCounts = TeamVsTeam.getTeamsPoints();
  1897. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1898. +
  1899. + npcHtmlMessage.setHtml(htmContent);
  1900. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  1901. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1902. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  1903. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  1904. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1905. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1]));
  1906. + player.sendPacket(npcHtmlMessage);
  1907. + }
  1908. + }
  1909. + player.sendPacket(ActionFailed.STATIC_PACKET);
  1910. + }
  1911. +
  1912. + public static boolean needParticipationFee()
  1913. + {
  1914. + return Config.EVENTS_PARTICIPATION_FEE[0] != 0 && Config.EVENTS_PARTICIPATION_FEE[1] != 0;
  1915. + }
  1916. +
  1917. + public static boolean hasParticipationFee(Player player)
  1918. + {
  1919. + return player.getInventory().getInventoryItemCount(Config.EVENTS_PARTICIPATION_FEE[0], -1) >= Config.EVENTS_PARTICIPATION_FEE[1];
  1920. + }
  1921. +
  1922. + public static boolean payParticipationFee(Player player)
  1923. + {
  1924. + return player.destroyItemByItemId("Participation Fee", Config.EVENTS_PARTICIPATION_FEE[0], Config.EVENTS_PARTICIPATION_FEE[1], null, true);
  1925. + }
  1926. +
  1927. + public static ItemInstance refundParticipationFee(Player player)
  1928. + {
  1929. + return player.addItem("Participation Fee", Config.EVENTS_PARTICIPATION_FEE[0], Config.EVENTS_PARTICIPATION_FEE[1], null, true);
  1930. + }
  1931. +
  1932. + public static String getParticipationFee()
  1933. + {
  1934. + int itemId = Config.EVENTS_PARTICIPATION_FEE[0];
  1935. + int itemNum = Config.EVENTS_PARTICIPATION_FEE[1];
  1936. +
  1937. + if (itemId == 0 || itemNum == 0)
  1938. + return "-";
  1939. +
  1940. + return String.valueOf(itemNum) + " " + ItemTable.getInstance().getTemplate(itemId).getName();
  1941. + }
  1942. +}
  1943. \ No newline at end of file
  1944. Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  1945. ===================================================================
  1946. --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
  1947. +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
  1948. @@ -0,0 +1,53 @@
  1949. +package net.sf.l2j.gameserver.handler;
  1950. +
  1951. +import java.util.HashMap;
  1952. +import java.util.Map;
  1953. +
  1954. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.RegisterEvents;
  1955. +
  1956. +/**
  1957. + * @author williams
  1958. + *
  1959. + */
  1960. +public class VoicedCommandHandler
  1961. +{
  1962. + private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
  1963. +
  1964. + public static VoicedCommandHandler getInstance()
  1965. + {
  1966. + return SingletonHolder._instance;
  1967. + }
  1968. +
  1969. + protected VoicedCommandHandler()
  1970. + {
  1971. + registerHandler(new RegisterEvents());
  1972. + }
  1973. +
  1974. + public void registerHandler(IVoicedCommandHandler handler)
  1975. + {
  1976. + String[] ids = handler.getVoicedCommandList();
  1977. +
  1978. + for (int i = 0; i < ids.length; i++)
  1979. + _datatable.put(ids[i].hashCode(), handler);
  1980. + }
  1981. +
  1982. + public IVoicedCommandHandler getHandler(String voicedCommand)
  1983. + {
  1984. + String command = voicedCommand;
  1985. +
  1986. + if (voicedCommand.indexOf(" ") != -1)
  1987. + command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
  1988. +
  1989. + return _datatable.get(command.hashCode());
  1990. + }
  1991. +
  1992. + public int size()
  1993. + {
  1994. + return _datatable.size();
  1995. + }
  1996. +
  1997. + private static class SingletonHolder
  1998. + {
  1999. + protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
  2000. + }
  2001. +}
  2002. \ No newline at end of file
  2003. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEvents.java
  2004. ===================================================================
  2005. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEvents.java (revision 0)
  2006. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminEvents.java (working copy)
  2007. @@ -0,0 +1,91 @@
  2008. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  2009. +
  2010. +import java.util.logging.Logger;
  2011. +
  2012. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  2013. +import net.sf.l2j.gameserver.model.WorldObject;
  2014. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  2015. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  2016. +import net.sf.l2j.gameserver.model.entity.engine.impl.EventTeleport;
  2017. +
  2018. +/**
  2019. + * @author williams
  2020. + *
  2021. + */
  2022. +public class AdminEvents implements IAdminCommandHandler
  2023. +{
  2024. + private static final Logger GMAUDIT_LOG = Logger.getLogger("gmaudit");
  2025. +
  2026. + private static final String[] ADMIN_COMMANDS =
  2027. + {
  2028. + "admin_tvt_add",
  2029. + "admin_tvt_remove"
  2030. + };
  2031. +
  2032. + @Override
  2033. + public boolean useAdminCommand(String command, Player adminInstance)
  2034. + {
  2035. + GMAUDIT_LOG.info(adminInstance.getName() + " [" + adminInstance.getObjectId() + "] used '" + command + "' command on: " + ((adminInstance.getTarget() != null) ? adminInstance.getTarget().getName() : "none"));
  2036. +
  2037. + if (command.equals("admin_tvt_add"))
  2038. + {
  2039. + WorldObject target = adminInstance.getTarget();
  2040. +
  2041. + if (target == null || !(target instanceof Player))
  2042. + {
  2043. + adminInstance.sendMessage("You should select a player!");
  2044. + return true;
  2045. + }
  2046. +
  2047. + add(adminInstance, (Player) target);
  2048. + }
  2049. + else if (command.equals("admin_tvt_remove"))
  2050. + {
  2051. + WorldObject target = adminInstance.getTarget();
  2052. +
  2053. + if (target == null || !(target instanceof Player))
  2054. + {
  2055. + adminInstance.sendMessage("You should select a player!");
  2056. + return true;
  2057. + }
  2058. +
  2059. + remove(adminInstance, (Player) target);
  2060. + }
  2061. +
  2062. + return true;
  2063. + }
  2064. +
  2065. + @Override
  2066. + public String[] getAdminCommandList()
  2067. + {
  2068. + return ADMIN_COMMANDS;
  2069. + }
  2070. +
  2071. + private static void add(Player adminInstance, Player playerInstance)
  2072. + {
  2073. + if (TeamVsTeam.isPlayerParticipant(playerInstance.getName()))
  2074. + {
  2075. + adminInstance.sendMessage("Player already participated in the event!");
  2076. + return;
  2077. + }
  2078. +
  2079. + if (!TeamVsTeam.addParticipant(playerInstance))
  2080. + {
  2081. + adminInstance.sendMessage("Player instance could not be added, it seems to be null!");
  2082. + return;
  2083. + }
  2084. +
  2085. + if (TeamVsTeam.isStarted())
  2086. + // we don't need to check return value of TvTEvent.getParticipantTeamCoordinates() for null, TvTEvent.addParticipant() returned true so target is in event
  2087. + new EventTeleport(playerInstance, TeamVsTeam.getParticipantTeamCoordinates(playerInstance.getName()), true, false);
  2088. + }
  2089. +
  2090. + private static void remove(Player adminInstance, Player playerInstance)
  2091. + {
  2092. + if (!TeamVsTeam.removeParticipant(playerInstance.getName()))
  2093. + {
  2094. + adminInstance.sendMessage("Player is not part of the event!");
  2095. + return;
  2096. + }
  2097. + }
  2098. +}
  2099. \ No newline at end of file
  2100. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  2101. ===================================================================
  2102. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 2)
  2103. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
  2104. @@ -17,7 +17,7 @@
  2105. @Override
  2106. public boolean useUserCommand(int id, Player activeChar)
  2107. {
  2108. - if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
  2109. + if (activeChar.isInFunEvent() || activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.isInObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || activeChar.isInsideZone(ZoneId.BOSS))
  2110. {
  2111. activeChar.sendPacket(SystemMessageId.NO_UNSTUCK_PLEASE_SEND_PETITION);
  2112. return false;
  2113. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  2114. ===================================================================
  2115. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 2)
  2116. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
  2117. @@ -40,6 +40,9 @@
  2118. return;
  2119. }
  2120.  
  2121. + if (player.isInFunEvent())
  2122. + return;
  2123. +
  2124. if (!player.isDead())
  2125. return;
  2126.  
  2127. Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java
  2128. ===================================================================
  2129. --- java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (revision 2)
  2130. +++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadManager.java (working copy)
  2131. @@ -242,6 +242,12 @@
  2132. player.sendPacket(SystemMessageId.ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
  2133. return false;
  2134. }
  2135. +
  2136. + if (player.isInFunEvent())
  2137. + {
  2138. + player.sendMessage("You cannot register in olympiad while registered at TvT.");
  2139. + return false;
  2140. + }
  2141.  
  2142. if (player.isSubClassActive())
  2143. {
  2144. Index: java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java
  2145. ===================================================================
  2146. --- java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java (revision 0)
  2147. +++ java/net/sf/l2j/gameserver/model/entity/engine/impl/manager/EngineManager.java (working copy)
  2148. @@ -0,0 +1,239 @@
  2149. +/*
  2150. + * This program is free software: you can redistribute it and/or modify it under
  2151. + * the terms of the GNU General Public License as published by the Free Software
  2152. + * Foundation, either version 3 of the License, or (at your option) any later
  2153. + * version.
  2154. + *
  2155. + * This program is distributed in the hope that it will be useful, but WITHOUT
  2156. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2157. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2158. + * details.
  2159. + *
  2160. + * You should have received a copy of the GNU General Public License along with
  2161. + * this program. If not, see <http://www.gnu.org/licenses/>.
  2162. + */
  2163. +package net.sf.l2j.gameserver.model.entity.engine.impl.manager;
  2164. +
  2165. +import java.util.Calendar;
  2166. +import java.util.concurrent.ScheduledFuture;
  2167. +import java.util.logging.Logger;
  2168. +
  2169. +import net.sf.l2j.Config;
  2170. +
  2171. +import net.sf.l2j.commons.concurrent.ThreadPool;
  2172. +
  2173. +import net.sf.l2j.gameserver.data.ItemTable;
  2174. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  2175. +import net.sf.l2j.gameserver.util.Broadcast;
  2176. +
  2177. +/**
  2178. + * @author FBIagent
  2179. + */
  2180. +public class EngineManager
  2181. +{
  2182. + protected static final Logger _log = Logger.getLogger(EngineManager.class.getName());
  2183. + private TVTStartTask _task;
  2184. +
  2185. + public EngineManager()
  2186. + {
  2187. + if (Config.TVT_ENABLED)
  2188. + {
  2189. + TeamVsTeam.init();
  2190. + scheduleEventStart();
  2191. + _log.info("TeamVsTeam: Started.");
  2192. + }
  2193. + else
  2194. + _log.info("TeamVsTeam: Disabled.");
  2195. + }
  2196. +
  2197. + public static EngineManager getInstance()
  2198. + {
  2199. + return SingletonHolder._instance;
  2200. + }
  2201. +
  2202. + public void scheduleEventStart()
  2203. + {
  2204. + try
  2205. + {
  2206. + Calendar currentTime = Calendar.getInstance();
  2207. + Calendar nextStartTime = null;
  2208. + Calendar testStartTime = null;
  2209. + for (String timeOfDay : Config.TVT_EVENT_INTERVAL)
  2210. + {
  2211. + // Creating a Calendar object from the specified interval value
  2212. + testStartTime = Calendar.getInstance();
  2213. + testStartTime.setLenient(true);
  2214. + String[] splitTimeOfDay = timeOfDay.split(":");
  2215. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  2216. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  2217. +
  2218. + // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  2219. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  2220. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  2221. +
  2222. + // Check for the test date to be the minimum (smallest in the specified list)
  2223. + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
  2224. + nextStartTime = testStartTime;
  2225. + }
  2226. + if (nextStartTime != null)
  2227. + {
  2228. + _task = new TVTStartTask(nextStartTime.getTimeInMillis());
  2229. + ThreadPool.execute(_task);
  2230. + }
  2231. + }
  2232. + catch (Exception e)
  2233. + {
  2234. + _log.warning("TeamVsTeam: Error figuring out a start time. Check TeamVsTeamInterval in config file.");
  2235. + }
  2236. + }
  2237. +
  2238. + public void startReg()
  2239. + {
  2240. + if (!TeamVsTeam.startParticipation())
  2241. + {
  2242. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Event was cancelled.", true);
  2243. + _log.warning("TeamVsTeam: Error spawning event npc for participation.");
  2244. + scheduleEventStart();
  2245. + }
  2246. + else
  2247. + {
  2248. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Registration opened for " + Config.TVT_EVENT_PARTICIPATION_TIME + " minute(s).", true);
  2249. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Joinable in " + Config.EVENTS_JOIN_LOCATION + ".", true);
  2250. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Recruiting levels: " + Config.EVENTS_MIN_LVL + " to " + Config.EVENTS_MAX_LVL + ".", true);
  2251. +
  2252. + for (int[] reward : Config.TVT_EVENT_REWARDS)
  2253. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Reward: " + reward[1] + " " + ItemTable.getInstance().getTemplate(reward[0]).getName(), true);
  2254. +
  2255. + if (Config.TVT_VOICED_COMMAND)
  2256. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Commands .tvtjoin .tvtleave .tvtinfo.",true);
  2257. +
  2258. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_PARTICIPATION_TIME);
  2259. + ThreadPool.execute(_task);
  2260. + }
  2261. + }
  2262. +
  2263. + public void startEvent()
  2264. + {
  2265. + if (!TeamVsTeam.startFight())
  2266. + {
  2267. + Broadcast.announceToOnlinePlayers("TeamVsTeam: Event cancelled due to lack of Participation.", true);
  2268. + _log.info("TeamVsTeam: Lack of registration, abort event.");
  2269. + scheduleEventStart();
  2270. + }
  2271. + else
  2272. + {
  2273. + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting participants to an arena in " + 10 + " second(s).");
  2274. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.TVT_EVENT_RUNNING_TIME);
  2275. + ThreadPool.execute(_task);
  2276. + }
  2277. + }
  2278. +
  2279. + public void endEvent()
  2280. + {
  2281. + Broadcast.announceToOnlinePlayers(TeamVsTeam.calculateRewards(), true);
  2282. + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: Teleporting back to the registration npc in " + 10 + " second(s).");
  2283. + TeamVsTeam.stopFight();
  2284. + scheduleEventStart();
  2285. + }
  2286. +
  2287. + public void skipDelay()
  2288. + {
  2289. + if (_task.nextRun.cancel(false))
  2290. + {
  2291. + _task.setStartTime(System.currentTimeMillis());
  2292. + ThreadPool.execute(_task);
  2293. + }
  2294. + }
  2295. +
  2296. + /**
  2297. + * Class for TVT cycles
  2298. + */
  2299. + class TVTStartTask implements Runnable
  2300. + {
  2301. + private long _startTime;
  2302. + public ScheduledFuture<?> nextRun;
  2303. +
  2304. + public TVTStartTask(long startTime)
  2305. + {
  2306. + _startTime = startTime;
  2307. + }
  2308. +
  2309. + public void setStartTime(long startTime)
  2310. + {
  2311. + _startTime = startTime;
  2312. + }
  2313. +
  2314. + /**
  2315. + * @see java.lang.Runnable#run()
  2316. + */
  2317. + @Override
  2318. + public void run()
  2319. + {
  2320. + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  2321. +
  2322. + if (delay > 0)
  2323. + announce(delay);
  2324. +
  2325. + int nextMsg = 0;
  2326. + if (delay > 3600)
  2327. + nextMsg = delay - 3600;
  2328. + else if (delay > 1800)
  2329. + nextMsg = delay - 1800;
  2330. + else if (delay > 900)
  2331. + nextMsg = delay - 900;
  2332. + else if (delay > 600)
  2333. + nextMsg = delay - 600;
  2334. + else if (delay > 300)
  2335. + nextMsg = delay - 300;
  2336. + else if (delay > 60)
  2337. + nextMsg = delay - 60;
  2338. + else if (delay > 5)
  2339. + nextMsg = delay - 5;
  2340. + else if (delay > 0)
  2341. + nextMsg = delay;
  2342. + else
  2343. + {
  2344. + // start
  2345. + if (TeamVsTeam.isInactive())
  2346. + startReg();
  2347. + else if (TeamVsTeam.isParticipating())
  2348. + startEvent();
  2349. + else
  2350. + endEvent();
  2351. + }
  2352. +
  2353. + if (delay > 0)
  2354. + nextRun = ThreadPool.schedule(this, nextMsg * 1000);
  2355. + }
  2356. +
  2357. + private void announce(long time)
  2358. + {
  2359. + if (time >= 3600 && time % 3600 == 0)
  2360. + {
  2361. + if (TeamVsTeam.isParticipating())
  2362. + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + (time / 60 / 60) + " hour(s) until registration is closed!", true);
  2363. + else if (TeamVsTeam.isStarted())
  2364. + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + (time / 60 / 60) + " hour(s) until event is finished!");
  2365. + }
  2366. + else if (time >= 60)
  2367. + {
  2368. + if (TeamVsTeam.isParticipating())
  2369. + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + (time / 60) + " minute(s) until registration is closed!", true);
  2370. + else if (TeamVsTeam.isStarted())
  2371. + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + (time / 60) + " minute(s) until the event is finished!");
  2372. + }
  2373. + else
  2374. + {
  2375. + if (TeamVsTeam.isParticipating())
  2376. + Broadcast.announceToOnlinePlayers("TeamVsTeam: " + time + " second(s) until registration is closed!", true);
  2377. + else if (TeamVsTeam.isStarted())
  2378. + TeamVsTeam.sysMsgToAllParticipants("TeamVsTeam: " + time + " second(s) until the event is finished!");
  2379. + }
  2380. + }
  2381. + }
  2382. +
  2383. + private static class SingletonHolder
  2384. + {
  2385. + protected static final EngineManager _instance = new EngineManager();
  2386. + }
  2387. +}
  2388. \ No newline at end of file
  2389. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
  2390. ===================================================================
  2391. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 2)
  2392. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
  2393. @@ -1,6 +1,10 @@
  2394. package net.sf.l2j.gameserver.handler.chathandlers;
  2395.  
  2396. +import java.util.StringTokenizer;
  2397. +
  2398. import net.sf.l2j.gameserver.handler.IChatHandler;
  2399. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  2400. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  2401. import net.sf.l2j.gameserver.model.BlockList;
  2402. import net.sf.l2j.gameserver.model.actor.instance.Player;
  2403. import net.sf.l2j.gameserver.network.FloodProtectors;
  2404. @@ -20,13 +24,43 @@
  2405. if (!FloodProtectors.performAction(activeChar.getClient(), Action.GLOBAL_CHAT))
  2406. return;
  2407.  
  2408. - final CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  2409. - for (Player player : activeChar.getKnownTypeInRadius(Player.class, 1250))
  2410. + boolean vcd_used = false;
  2411. + if (text.startsWith("."))
  2412. {
  2413. - if (!BlockList.isBlocked(player, activeChar))
  2414. - player.sendPacket(cs);
  2415. + StringTokenizer st = new StringTokenizer(text);
  2416. + IVoicedCommandHandler vch;
  2417. + String command = "";
  2418. +
  2419. + if (st.countTokens() > 1)
  2420. + {
  2421. + command = st.nextToken().substring(1);
  2422. + params = text.substring(command.length() + 2);
  2423. + vch = VoicedCommandHandler.getInstance().getHandler(command);
  2424. + }
  2425. + else
  2426. + {
  2427. + command = text.substring(1);
  2428. + vch = VoicedCommandHandler.getInstance().getHandler(command);
  2429. + }
  2430. +
  2431. + if (vch != null)
  2432. + {
  2433. + vch.useVoicedCommand(command, activeChar, params);
  2434. + vcd_used = true;
  2435. + }
  2436. }
  2437. - activeChar.sendPacket(cs);
  2438. + if (!vcd_used)
  2439. + {
  2440. + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  2441. +
  2442. + for (Player player : activeChar.getKnownTypeInRadius(Player.class, 1250))
  2443. + {
  2444. + if (!BlockList.isBlocked(player, activeChar))
  2445. + player.sendPacket(cs);
  2446. + }
  2447. +
  2448. + activeChar.sendPacket(cs);
  2449. + }
  2450. }
  2451.  
  2452. @Override
  2453. Index: java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java
  2454. ===================================================================
  2455. --- java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (revision 2)
  2456. +++ java/net/sf/l2j/gameserver/skills/l2skills/L2SkillTeleport.java (working copy)
  2457. @@ -38,7 +38,7 @@
  2458. if (activeChar instanceof Player)
  2459. {
  2460. // Check invalid states.
  2461. - if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  2462. + if (((Player) activeChar).isInFunEvent() || activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  2463. return;
  2464. }
  2465.  
  2466. Index: java/net/sf/l2j/Config.java
  2467. ===================================================================
  2468. --- java/net/sf/l2j/Config.java (revision 2)
  2469. +++ java/net/sf/l2j/Config.java (working copy)
  2470. @@ -30,6 +30,7 @@
  2471.  
  2472. public static final String CLANS_FILE = "./config/clans.properties";
  2473. public static final String EVENTS_FILE = "./config/events.properties";
  2474. + public static final String EVENTS_CUSTOM_FILE = "./config/TeamVsTeam.properties";
  2475. public static final String GEOENGINE_FILE = "./config/geoengine.properties";
  2476. public static final String HEXID_FILE = "./config/hexid.txt";
  2477. public static final String LOGIN_CONFIGURATION_FILE = "./config/loginserver.properties";
  2478. @@ -204,7 +205,43 @@
  2479. public static int ALT_FISH_CHAMPIONSHIP_REWARD_3;
  2480. public static int ALT_FISH_CHAMPIONSHIP_REWARD_4;
  2481. public static int ALT_FISH_CHAMPIONSHIP_REWARD_5;
  2482. +
  2483. + // --------------------------------------------------
  2484. + // Events jDevs settings
  2485. + // --------------------------------------------------
  2486.  
  2487. + /**Core Engine*/
  2488. + public static String EVENTS_JOIN_LOCATION;
  2489. + public static int EVENTS_PARTICIPATION_NPC_ID;
  2490. + public static int EVENTS_MIN_PLAYERS_IN_TEAMS;
  2491. + public static int EVENTS_MAX_PLAYERS_IN_TEAMS;
  2492. + public static int EVENTS_EFFECTS_REMOVAL;
  2493. + public static int EVENTS_MAX_PARTICIPANTS_PER_IP;
  2494. + public static int[] EVENTS_PARTICIPATION_NPC_COORDINATES = new int[3];
  2495. + public static int[] EVENTS_PARTICIPATION_FEE = new int[2];
  2496. + public static List<Integer> EVENTS_DOORS_IDS_TO_OPEN;
  2497. + public static List<Integer> EVENTS_DOORS_IDS_TO_CLOSE;
  2498. + public static byte EVENTS_MIN_LVL;
  2499. + public static byte EVENTS_MAX_LVL;
  2500. + public static int[][] EVENTS_FIGHTER_BUFFS;
  2501. + public static int[][] EVENTS_MAGE_BUFFS;
  2502. + public static List<Integer> LIST_RESTRICTED_CLASSES_IN_EVENTS;
  2503. + public static String EVENTS_RESTRICTED_CLASSES;
  2504. +
  2505. + /** Team vs. Team */
  2506. + public static boolean TVT_ENABLED;
  2507. + public static boolean TVT_VOICED_COMMAND;
  2508. + public static String[] TVT_EVENT_INTERVAL;
  2509. + public static String TVT_EVENT_ON_KILL;
  2510. + public static String TVT_EVENT_TEAM_1_NAME;
  2511. + public static String TVT_EVENT_TEAM_2_NAME;
  2512. + public static int TVT_EVENT_PARTICIPATION_TIME;
  2513. + public static int TVT_EVENT_RUNNING_TIME;
  2514. + public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  2515. + public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  2516. + public static List<int[]> TVT_EVENT_REWARDS = new ArrayList<>();
  2517. + public static List<int[]> TVT_EVENT_REWARDS_KILL = new ArrayList<>();
  2518. +
  2519. // --------------------------------------------------
  2520. // GeoEngine
  2521. // --------------------------------------------------
  2522. @@ -872,6 +909,114 @@
  2523. ALT_FISH_CHAMPIONSHIP_REWARD_4 = events.getProperty("AltFishChampionshipReward4", 200000);
  2524. ALT_FISH_CHAMPIONSHIP_REWARD_5 = events.getProperty("AltFishChampionshipReward5", 100000);
  2525. }
  2526. +
  2527. + /**
  2528. + * Loads event engine settings.<br>
  2529. + */
  2530. + private static final void loadEventsEngine()
  2531. + {
  2532. + final ExProperties jdevs = initProperties(EVENTS_CUSTOM_FILE);
  2533. + EVENTS_JOIN_LOCATION = jdevs.getProperty("NpcRegisterLocation", "Giran");
  2534. + EVENTS_PARTICIPATION_NPC_ID = jdevs.getProperty("EventsParticipationNpcId", 0);
  2535. + EVENTS_RESTRICTED_CLASSES = jdevs.getProperty("EventsRestrictedClasses", "0,0");
  2536. + EVENTS_MIN_PLAYERS_IN_TEAMS = jdevs.getProperty("EventsMinPlayersInTeams", 1);
  2537. + EVENTS_MAX_PLAYERS_IN_TEAMS = jdevs.getProperty("EventsMaxPlayersInTeams", 2);
  2538. + EVENTS_MIN_LVL = (byte) jdevs.getProperty("EventsMinPlayerLevel", 1);
  2539. + EVENTS_MAX_LVL = (byte) jdevs.getProperty("EventsMaxPlayerLevel", 80);
  2540. + EVENTS_EFFECTS_REMOVAL = jdevs.getProperty("EventsEffectsRemoval", 0);
  2541. + EVENTS_MAX_PARTICIPANTS_PER_IP = jdevs.getProperty("EventsMaxParticipantsPerIP", 0);
  2542. + EVENTS_FIGHTER_BUFFS = parseItemsList(jdevs.getProperty("EventsFighterBuffs", "123,456"));
  2543. + EVENTS_MAGE_BUFFS = parseItemsList(jdevs.getProperty("EventsMageBuffs", "789,1223"));
  2544. +
  2545. + LIST_RESTRICTED_CLASSES_IN_EVENTS = new ArrayList<>();
  2546. + for (String val : EVENTS_RESTRICTED_CLASSES.split(","))
  2547. + {
  2548. + int classId = Integer.parseInt(val);
  2549. + LIST_RESTRICTED_CLASSES_IN_EVENTS.add(classId);
  2550. + }
  2551. +
  2552. + String[] propertySplit = jdevs.getProperty("EventsParticipationNpcCoordinates", "0,0,0").split(",");
  2553. + if (propertySplit.length < 3)
  2554. + TVT_ENABLED = false;
  2555. + else
  2556. + {
  2557. + EVENTS_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  2558. + EVENTS_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  2559. + EVENTS_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  2560. + }
  2561. +
  2562. + propertySplit = jdevs.getProperty("EventsParticipationFee", "0,0").split(",");
  2563. + try
  2564. + {
  2565. + EVENTS_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
  2566. + EVENTS_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
  2567. + }
  2568. + catch (NumberFormatException nfe)
  2569. + {
  2570. + if (propertySplit.length > 0)
  2571. + _log.warning("EventEngine: invalid config property -> EventsParticipationFee");
  2572. + }
  2573. +
  2574. + propertySplit = jdevs.getProperty("EventsDoorsToOpen", "").split(";");
  2575. + EVENTS_DOORS_IDS_TO_OPEN = new ArrayList<>(propertySplit.length);
  2576. + for (String door : propertySplit)
  2577. + {
  2578. + EVENTS_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  2579. + }
  2580. +
  2581. + propertySplit = jdevs.getProperty("EventsDoorsToClose", "").split(";");
  2582. + EVENTS_DOORS_IDS_TO_CLOSE = new ArrayList<>(propertySplit.length);
  2583. + for (String door : propertySplit)
  2584. + {
  2585. + EVENTS_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  2586. + }
  2587. +
  2588. + /** Team Vs Team engine */
  2589. + TVT_ENABLED = jdevs.getProperty("TVTEnabled", false);
  2590. + TVT_EVENT_INTERVAL = jdevs.getProperty("TvTEventInterval", "20:00").split(",");
  2591. + TVT_EVENT_PARTICIPATION_TIME = jdevs.getProperty("TvTEventParticipationTime", 3600);
  2592. + TVT_EVENT_RUNNING_TIME = jdevs.getProperty("TvTEventRunningTime", 1800);
  2593. + TVT_VOICED_COMMAND = jdevs.getProperty("TvTVoicedCommand", false);
  2594. + TVT_EVENT_ON_KILL = jdevs.getProperty("TvTEventOnKill", "pmteam");
  2595. + TVT_EVENT_TEAM_1_NAME = jdevs.getProperty("TvTEventTeam1Name", "Team1");
  2596. + TVT_EVENT_TEAM_2_NAME = jdevs.getProperty("TvTEventTeam2Name", "Team2");
  2597. +
  2598. + propertySplit = jdevs.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
  2599. + if (propertySplit.length < 3)
  2600. + TVT_ENABLED = false;
  2601. + else
  2602. + {
  2603. + TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  2604. + TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  2605. + TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  2606. + }
  2607. +
  2608. + propertySplit = jdevs.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
  2609. + if (propertySplit.length < 3)
  2610. + TVT_ENABLED = false;
  2611. + else
  2612. + {
  2613. + TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  2614. + TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  2615. + TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  2616. + }
  2617. +
  2618. + propertySplit = jdevs.getProperty("TvTEventReward", "57,100000").split(";");
  2619. + for (String reward : propertySplit)
  2620. + {
  2621. + String[] rewardSplit = reward.split(",");
  2622. + if (rewardSplit.length == 2)
  2623. + TVT_EVENT_REWARDS.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  2624. + }
  2625. +
  2626. + propertySplit = jdevs.getProperty("TvTEventRewardKill", "57,2").split(";");
  2627. + for (String reward : propertySplit)
  2628. + {
  2629. + String[] rewardSplit = reward.split(",");
  2630. + if (rewardSplit.length == 2)
  2631. + TVT_EVENT_REWARDS_KILL.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  2632. + }
  2633. + }
  2634.  
  2635. /**
  2636. * Loads geoengine settings.
  2637. @@ -1351,6 +1496,9 @@
  2638. // events settings
  2639. loadEvents();
  2640.  
  2641. + // jdevs events settings
  2642. + loadEventsEngine();
  2643. +
  2644. // geoengine settings
  2645. loadGeoengine();
  2646. Index: config/game/TeamVsTeam.properties
  2647. ===================================================================
  2648. --- config/game/TeamVsTeam.properties (revision 0)
  2649. +++ config/game/TeamVsTeam.properties (working copy)
  2650. @@ -0,0 +1,99 @@
  2651. +# =================================================================
  2652. +# Engine jDevs (by Williams)
  2653. +# =================================================================
  2654. +# Events npc (create a custom npc of type EventManager).
  2655. +EventsParticipationNpcId = 50009
  2656. +
  2657. +# Location Npc Register
  2658. +NpcRegisterLocation = Giran
  2659. +
  2660. +# Events participation fee (itemId, number).
  2661. +# Example: 57,100000
  2662. +EventsParticipationFee = 57,1
  2663. +
  2664. +# Location for events npc to spawn in form x,y,z
  2665. +EventsParticipationNpcCoordinates = 82698,148638,-3468
  2666. +
  2667. +# Min/Max amount of players allowed in each team.
  2668. +EventsMinPlayersInTeams = 1
  2669. +EventsMaxPlayersInTeams = 20
  2670. +
  2671. +# Min/Max level of players that may join the events.
  2672. +EventsMinPlayerLevel = 20
  2673. +EventsMaxPlayerLevel = 81
  2674. +
  2675. +# Door ID's to open/close on start/end.
  2676. +# Example: EventsDoorsToOpen = id1;id2;...
  2677. +EventsDoorsToOpen = 24190001;24190002;24190003;24190004
  2678. +EventsDoorsToClose = 24190001;24190002;24190003;24190004
  2679. +
  2680. +# Participant's effects handling on teleport/death.
  2681. +# Effects lasting through death never removed.
  2682. +# 0 - always remove all effects.
  2683. +# 1 - remove all effects only during port to event (noblesse blessing can be used)
  2684. +# 2 - never remove any effect
  2685. +# Default: 0
  2686. +EventsEffectsRemoval = 2
  2687. +
  2688. +# Fighter-class participants will be buffed with those buffs each respawn
  2689. +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
  2690. +# Example: 1504,1;1501,1;1502,1;1499,1
  2691. +EventsFighterBuffs = 1036,1;1040,1;1045,3;1068,1;1077,1;1068,1;1204,1;1240,1;1242,1;1259,4;1035,1;\
  2692. ++264,1;267,1;268,1;269,1;304,1;271,1;274,1;275,1;
  2693. +
  2694. +# Mage-class participants will be buffed with those buffs each respawn
  2695. +# Format: skill1Id,skill1Level;skill2Id,skill2Level...
  2696. +# Example: 1504,1;1500,1;1501,1;1085,3
  2697. +EventsMageBuffs = 1036,1;1040,1;1045,3;1048,3;1059,1;1085,1;1204,1;1303,1;1062,1;1035,1;1259,4;1389,1;\
  2698. ++264,1;267,1;268,1;304,1;273,1;276,1;
  2699. +
  2700. +# Class Restriction for events.
  2701. +# Example: classId,classId, ...
  2702. +EventsRestrictedClasses = 0
  2703. +
  2704. +# Maximum number of allowed participants per IP address (dualbox check)
  2705. +# Default: 0 (no limits)
  2706. +EventsMaxParticipantsPerIP = 0
  2707. +
  2708. +# =================================================================
  2709. +# Team vs. Team (by FBIagent) / Dev Williams
  2710. +# =================================================================
  2711. +# Enable/Disable Event TvT.
  2712. +TVTEnabled = True
  2713. +
  2714. +# Times TvT will occur (24h format).
  2715. +# Example: 20:00,21,00,22:00
  2716. +TvTEventInterval = 8:00,10:00,12:00,14:00,16:00,18:00,20:00,22:00
  2717. +
  2718. +# Registration timer from start of event (in minutes).
  2719. +TvTEventParticipationTime = 5
  2720. +
  2721. +# Event running time (in minutes).
  2722. +TvTEventRunningTime = 5
  2723. +
  2724. +# First Blue - Name, Start/Death x,y,z location.
  2725. +TvTEventTeam1Name = Blue
  2726. +TvTEventTeam1Coordinates = 148232,46552,-3408
  2727. +
  2728. +# Second Red - Name, Start/Death x,y,z location.
  2729. +TvTEventTeam2Name = Red
  2730. +TvTEventTeam2Coordinates = 150712,46536,-3408
  2731. +
  2732. +# Reward for winning team.
  2733. +# Example: TvTEventReward = itemId,amount;
  2734. +TvTEventReward = 57,1
  2735. +
  2736. +# If true, gives reward for kills stage without die
  2737. +# Example: Get 5/8/12/15/20 kills without die, and you will be rewarded
  2738. +# Example: TvTEventRewardKill = itemId,amount;
  2739. +TvTEventRewardKill = 57,2
  2740. +
  2741. +# Method to show player's kill on the TvT.
  2742. +# Example: "Kills: number" (title will be restored at the event end).
  2743. +# Put "pmtitle" for both methods (pmteam and title).
  2744. +# Default: pmteam
  2745. +TvTEventOnKill = pmtitle
  2746. +
  2747. +# Voiced command (.tvton, .tvtoff, .tvtinfo) working during TvT Event to get information about event status
  2748. +# Default: True
  2749. +TvTVoicedCommand = True
  2750. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java
  2751. ===================================================================
  2752. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java (revision 0)
  2753. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/RegisterEvents.java (working copy)
  2754. @@ -0,0 +1,120 @@
  2755. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  2756. +
  2757. +import net.sf.l2j.Config;
  2758. +import net.sf.l2j.gameserver.data.cache.HtmCache;
  2759. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  2760. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  2761. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  2762. +import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
  2763. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  2764. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  2765. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  2766. +
  2767. +/**
  2768. + * @author williams
  2769. + *
  2770. + */
  2771. +public class RegisterEvents implements IVoicedCommandHandler
  2772. +{
  2773. + private static final String[] VOICED_COMMANDS =
  2774. + {
  2775. + "register",
  2776. + "unregister",
  2777. + "eventstatus"
  2778. + };
  2779. +
  2780. + @Override
  2781. + public boolean useVoicedCommand(final String command, final Player activeChar, final String target)
  2782. + {
  2783. + if (command.startsWith("register"))
  2784. + Join(target, activeChar);
  2785. + else if (command.startsWith("unregister"))
  2786. + Leave(activeChar);
  2787. + else if (command.startsWith("eventstatus"))
  2788. + Status(activeChar);
  2789. + return true;
  2790. + }
  2791. +
  2792. + public static boolean Join(final String command, Player activeChar)
  2793. + {
  2794. + if (!TeamVsTeam.isParticipating())
  2795. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  2796. + else if (TeamVsTeam.isPlayerParticipant(activeChar.getName()))
  2797. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You are already on the list."));
  2798. + else if (activeChar.isCursedWeaponEquipped())
  2799. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Cursed weapon owners are not allowed to participate."));
  2800. + else if (activeChar.isInJail())
  2801. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Nothing for you!."));
  2802. + //else if (activeChar.isAio())
  2803. + //activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "AIO player can not register!."));
  2804. + else if (OlympiadManager.getInstance().isRegisteredInComp(activeChar))
  2805. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Olympiad participants can't register."));
  2806. + else if (activeChar.getKarma() > 0)
  2807. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Chaotic players are not allowed to participate."));
  2808. + else if (TeamVsTeam._teams[0].getParticipatedPlayerCount() >= Config.EVENTS_MAX_PLAYERS_IN_TEAMS && TeamVsTeam._teams[1].getParticipatedPlayerCount() >= Config.EVENTS_MAX_PLAYERS_IN_TEAMS)
  2809. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Sorry the event is full!"));
  2810. + else if (activeChar.getLevel() < Config.EVENTS_MIN_LVL || activeChar.getLevel() > Config.EVENTS_MAX_LVL)
  2811. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "Only players from level " + Config.EVENTS_MIN_LVL + " until level " + Config.EVENTS_MAX_LVL + " are allowed to participate."));
  2812. + else if (TeamVsTeam._teams[0].getParticipatedPlayerCount() > 19 && TeamVsTeam._teams[1].getParticipatedPlayerCount() > 19)
  2813. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "The event is full! Maximum of " + Config.EVENTS_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team."));
  2814. + else
  2815. + {
  2816. + TeamVsTeam.addParticipant(activeChar);
  2817. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  2818. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  2819. + activeChar.sendPacket(npcHtmlMessage);
  2820. + }
  2821. + return false;
  2822. + }
  2823. +
  2824. + public boolean Leave(final Player activeChar)
  2825. + {
  2826. + if (!TeamVsTeam.isParticipating())
  2827. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "Hey " + activeChar.getName() + "", "There is no TvT Event in progress."));
  2828. + else if (!TeamVsTeam.isInactive() && !TeamVsTeam.isPlayerParticipant(activeChar.getName()))
  2829. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "You aren't registered in the TvT Event."));
  2830. + else
  2831. + {
  2832. + TeamVsTeam.removeParticipant(activeChar.getName());
  2833. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  2834. + npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are not longer on the registration list.</body></html>");
  2835. + activeChar.sendPacket(npcHtmlMessage);
  2836. + }
  2837. + return false;
  2838. + }
  2839. +
  2840. + public boolean Status(final Player activeChar)
  2841. + {
  2842. + if (!TeamVsTeam.isStarted())
  2843. + activeChar.sendPacket(new CreatureSay(0, Say2.HERO_VOICE, "TvT Event", "TvT Event is not in progress yet."));
  2844. + else
  2845. + {
  2846. + String htmFile = "data/html/mods/TeamVsTeamStatus.htm";
  2847. + String htmContent = HtmCache.getInstance().getHtm(htmFile);
  2848. +
  2849. + if (htmContent != null)
  2850. + {
  2851. + int[] teamsPlayerCounts = TeamVsTeam.getTeamsPlayerCounts();
  2852. + int[] teamsPointsCounts = TeamVsTeam.getTeamsPoints();
  2853. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(5);
  2854. +
  2855. + npcHtmlMessage.setHtml(htmContent);
  2856. + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  2857. + npcHtmlMessage.replace("%team1name%", Config.TVT_EVENT_TEAM_1_NAME);
  2858. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  2859. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  2860. + npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  2861. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  2862. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  2863. + activeChar.sendPacket(npcHtmlMessage);
  2864. + }
  2865. + }
  2866. + return false;
  2867. + }
  2868. +
  2869. + @Override
  2870. + public String[] getVoicedCommandList()
  2871. + {
  2872. + return VOICED_COMMANDS;
  2873. + }
  2874. +}
  2875. \ No newline at end of file
  2876. Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
  2877. ===================================================================
  2878. --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 2)
  2879. +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
  2880. @@ -16,6 +16,7 @@
  2881.  
  2882. private boolean _sweepable;
  2883. private boolean _allowFixedRes;
  2884. + private boolean _canTeleport;
  2885. private Clan _clan;
  2886.  
  2887. public Die(Creature cha)
  2888. @@ -29,7 +30,7 @@
  2889. Player player = (Player) cha;
  2890. _allowFixedRes = player.getAccessLevel().allowFixedRes();
  2891. _clan = player.getClan();
  2892. -
  2893. + _canTeleport = !player.isInFunEvent();
  2894. }
  2895. else if (cha instanceof Attackable)
  2896. _sweepable = ((Attackable) cha).isSpoiled();
  2897. @@ -43,9 +44,9 @@
  2898.  
  2899. writeC(0x06);
  2900. writeD(_charObjId);
  2901. - writeD(0x01); // to nearest village
  2902. + writeD(_canTeleport ? 0x01 : 0x00); // to nearest village
  2903.  
  2904. - if (_clan != null)
  2905. + if (_canTeleport && _clan != null)
  2906. {
  2907. SiegeSide side = null;
  2908. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  2909. ===================================================================
  2910. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 2)
  2911. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
  2912. @@ -28,6 +28,7 @@
  2913. import net.sf.l2j.gameserver.model.entity.ClanHall;
  2914. import net.sf.l2j.gameserver.model.entity.Siege;
  2915. import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
  2916. +import net.sf.l2j.gameserver.model.entity.engine.TeamVsTeam;
  2917. import net.sf.l2j.gameserver.model.holder.IntIntHolder;
  2918. import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  2919. import net.sf.l2j.gameserver.model.pledge.Clan;
  2920. @@ -305,6 +306,7 @@
  2921. PetitionManager.getInstance().checkPetitionMessages(player);
  2922.  
  2923. player.onPlayerEnter();
  2924. + TeamVsTeam.onLogin(player);
  2925.  
  2926. sendPacket(new SkillCoolTime(player));
  2927. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement