Guest User

Triple TvT Event

a guest
Apr 12th, 2010
1,853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.50 KB | None | 0 0
  1. Index: L2_GameServer_It/java/net/sf/l2j/gameserver/model/entity/TvTEvent.java
  2. ===================================================================
  3. --- L2_GameServer_It/java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (revision 1433)
  4. +++ L2_GameServer_It/java/net/sf/l2j/gameserver/model/entity/TvTEvent.java (working copy)
  5. @@ -57,7 +57,7 @@
  6. }
  7.  
  8. /** The teams of the TvTEvent<br> */
  9. - private static TvTEventTeam[] _teams = new TvTEventTeam[2]; // event only allow max 2 teams
  10. + private static TvTEventTeam[] _teams = new TvTEventTeam[3]; // event only allow max 2 teams
  11. /** The state of the TvTEvent<br> */
  12. private static EventState _state = EventState.INACTIVE;
  13. /** The spawn of the participation npc<br> */
  14. @@ -78,6 +78,7 @@
  15. {
  16. _teams[0] = new TvTEventTeam(Config.TVT_EVENT_TEAM_1_NAME, Config.TVT_EVENT_TEAM_1_COORDINATES);
  17. _teams[1] = new TvTEventTeam(Config.TVT_EVENT_TEAM_2_NAME, Config.TVT_EVENT_TEAM_2_COORDINATES);
  18. + _teams[2] = new TvTEventTeam(Config.TVT_EVENT_TEAM_3_NAME, Config.TVT_EVENT_TEAM_3_COORDINATES);
  19. }
  20.  
  21. /**
  22. @@ -143,11 +144,12 @@
  23. setState(EventState.STARTING);
  24.  
  25. // not enought participants
  26. - if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
  27. + if (_teams[0].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[1].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS || _teams[2].getParticipatedPlayerCount() < Config.TVT_EVENT_MIN_PLAYERS_IN_TEAMS)
  28. {
  29. setState(EventState.INACTIVE);
  30. _teams[0].cleanMe();
  31. _teams[1].cleanMe();
  32. + _teams[2].cleanMe();
  33. unSpawnNpc();
  34. return false;
  35. }
  36. @@ -185,16 +187,16 @@
  37. */
  38. public static String calculateRewards()
  39. {
  40. - if (_teams[0].getPoints() == _teams[1].getPoints())
  41. + if (_teams[0].getPoints() == _teams[1].getPoints() || (_teams[0].getPoints() == _teams[2].getPoints() || _teams[1].getPoints() == _teams[2].getPoints()))
  42. {
  43. - if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0)
  44. + if (_teams[0].getParticipatedPlayerCount() == 0 || _teams[1].getParticipatedPlayerCount() == 0 || _teams[2].getParticipatedPlayerCount() == 0)
  45. {
  46. // the fight cannot be completed
  47. setState(EventState.REWARDING);
  48. return "TvT Event: Event finish. No team won, cause of inactivity!";
  49. }
  50.  
  51. - sysMsgToAllParticipants("TvT Event: Both teams are at a tie, next team to get a kill wins!");
  52. + sysMsgToAllParticipants("TvT Event: Teams are at a tie, next team to get a kill wins!");
  53. }
  54.  
  55. while (_teams[0].getPoints() == _teams[1].getPoints())
  56. @@ -209,7 +211,7 @@
  57.  
  58. setState(EventState.REWARDING); // after state REWARDING is set, nobody can point anymore
  59.  
  60. - byte teamId = (byte)(_teams[0].getPoints() > _teams[1].getPoints() ? 0 : 1); // which team wins?
  61. + byte teamId = (byte)(_teams[0].getPoints() > _teams[1].getPoints() || (_teams[0].getPoints() > _teams[2].getPoints()) || (_teams[1].getPoints() > _teams[2].getPoints()) ? 0 : 1); // which team wins?
  62. TvTEventTeam team = _teams[teamId];
  63.  
  64. for (String playerName : team.getParticipatedPlayerNames())
  65. @@ -292,6 +294,7 @@
  66.  
  67. _teams[0].cleanMe();
  68. _teams[1].cleanMe();
  69. + _teams[2].cleanMe();
  70. setState(EventState.INACTIVE);
  71. }
  72.  
  73. @@ -310,10 +313,12 @@
  74.  
  75. byte teamId = 0;
  76.  
  77. - if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount())
  78. - teamId = (byte)(Rnd.get(2));
  79. + if (_teams[0].getParticipatedPlayerCount() == _teams[1].getParticipatedPlayerCount() || (_teams[0].getParticipatedPlayerCount() == _teams[2].getParticipatedPlayerCount() || (_teams[1].getParticipatedPlayerCount() == _teams[2].getParticipatedPlayerCount())))
  80. + teamId = (byte)(Rnd.get(3));
  81. else
  82. teamId = (byte)(_teams[0].getParticipatedPlayerCount() > _teams[1].getParticipatedPlayerCount() ? 1 : 0);
  83. + teamId = (byte)(_teams[0].getParticipatedPlayerCount() > _teams[2].getParticipatedPlayerCount() ? 1 : 0);
  84. + teamId = (byte)(_teams[1].getParticipatedPlayerCount() > _teams[2].getParticipatedPlayerCount() ? 1 : 0);
  85.  
  86. return _teams[teamId].addPlayer(playerInstance);
  87. }
  88. @@ -357,6 +362,12 @@
  89. if (playerInstance != null)
  90. playerInstance.sendMessage(message);
  91. }
  92. +
  93. + for (L2PcInstance playerInstance : _teams[2].getParticipatedPlayers().values())
  94. + {
  95. + if (playerInstance != null)
  96. + playerInstance.sendMessage(message);
  97. + }
  98. }
  99.  
  100. /**
  101. @@ -451,11 +462,11 @@
  102. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Cursed weapon owners are not allowed to participate.</body></html>");
  103. else if (playerInstance.getKarma() > 0)
  104. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Chaotic players are not allowed to participate.</body></html>");
  105. - else if (_teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  106. + else if (_teams[0].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[1].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS && _teams[2].getParticipatedPlayerCount() >= Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS)
  107. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Sorry the event is full!</body></html>");
  108. else if (playerLevel < Config.TVT_EVENT_MIN_LVL || playerLevel > Config.TVT_EVENT_MAX_LVL)
  109. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>Only players from level " + Config.TVT_EVENT_MIN_LVL + " to level " + Config.TVT_EVENT_MAX_LVL + " are allowed tro participate.</body></html>");
  110. - else if (_teams[0].getParticipatedPlayerCount() > 19 && _teams[1].getParticipatedPlayerCount() > 19)
  111. + else if (_teams[0].getParticipatedPlayerCount() > 19 && _teams[1].getParticipatedPlayerCount() > 19 && _teams[2].getParticipatedPlayerCount() > 19)
  112. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>The event is full! Maximum of " + Config.TVT_EVENT_MAX_PLAYERS_IN_TEAMS + " player are allowed in one team.</body></html>");
  113. else if (addParticipant(playerInstance))
  114. npcHtmlMessage.setHtml("<html><head><title>TvT Event</title></head><body>You are on the registration list now.</body></html>");
  115. @@ -723,7 +734,7 @@
  116. */
  117. public static byte getParticipantTeamId(String playerName)
  118. {
  119. - return (byte)(_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : -1));
  120. + return (byte)(_teams[0].containsPlayer(playerName) ? 0 : (_teams[1].containsPlayer(playerName) ? 1 : (_teams[2].containsPlayer(playerName) ? 2 : -1)));
  121. }
  122.  
  123. /**
  124. @@ -734,7 +745,7 @@
  125. */
  126. public static int[] getParticipantTeamCoordinates(String playerName)
  127. {
  128. - return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : null);
  129. + return _teams[0].containsPlayer(playerName) ? _teams[0].getCoordinates() : (_teams[1].containsPlayer(playerName) ? _teams[1].getCoordinates() : (_teams[2].containsPlayer(playerName) ? _teams[2].getCoordinates() : null));
  130. }
  131.  
  132.  
  133. @@ -746,7 +757,7 @@
  134. */
  135. public static boolean isPlayerParticipant(String playerName)
  136. {
  137. - return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName);
  138. + return _teams[0].containsPlayer(playerName) || _teams[1].containsPlayer(playerName) || _teams[2].containsPlayer(playerName);
  139. }
  140.  
  141. /**
  142. @@ -756,7 +767,7 @@
  143. */
  144. public static int getParticipatedPlayersCount()
  145. {
  146. - return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount();
  147. + return _teams[0].getParticipatedPlayerCount() + _teams[1].getParticipatedPlayerCount() + _teams[2].getParticipatedPlayerCount();
  148. }
  149.  
  150. /**
  151. @@ -766,7 +777,7 @@
  152. */
  153. public static String[] getTeamNames()
  154. {
  155. - return new String[]{_teams[0].getName(), _teams[1].getName()};
  156. + return new String[]{_teams[0].getName(), _teams[1].getName(), _teams[2].getName()};
  157. }
  158.  
  159. /**
  160. @@ -776,7 +787,7 @@
  161. */
  162. public static int[] getTeamsPlayerCounts()
  163. {
  164. - return new int[]{_teams[0].getParticipatedPlayerCount(), _teams[1].getParticipatedPlayerCount()};
  165. + return new int[]{_teams[0].getParticipatedPlayerCount(), _teams[1].getParticipatedPlayerCount(), _teams[2].getParticipatedPlayerCount()};
  166. }
  167.  
  168. /**
  169. @@ -786,6 +797,6 @@
  170. */
  171. public static int[] getTeamsPoints()
  172. {
  173. - return new int[]{_teams[0].getPoints(), _teams[1].getPoints()};
  174. + return new int[]{_teams[0].getPoints(), _teams[1].getPoints(), _teams[2].getPoints()};
  175. }
  176. }
  177. Index: L2_GameServer_It/java/net/sf/l2j/Config.java
  178. ===================================================================
  179. --- L2_GameServer_It/java/net/sf/l2j/Config.java (revision 1433)
  180. +++ L2_GameServer_It/java/net/sf/l2j/Config.java (working copy)
  181. @@ -863,6 +863,8 @@
  182. public static int[] TVT_EVENT_TEAM_1_COORDINATES = new int[3];
  183. public static String TVT_EVENT_TEAM_2_NAME;
  184. public static int[] TVT_EVENT_TEAM_2_COORDINATES = new int[3];
  185. + public static String TVT_EVENT_TEAM_3_NAME;
  186. + public static int[] TVT_EVENT_TEAM_3_COORDINATES = new int[3];
  187. public static List<int[]> TVT_EVENT_REWARDS = new FastList<int[]>();
  188. public static boolean TVT_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
  189. public static boolean TVT_EVENT_POTIONS_ALLOWED;
  190. @@ -1887,7 +1889,9 @@
  191. TVT_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(L2JModSettings.getProperty("TvTEventStartLeaveTeleportDelay", "20"));
  192.  
  193. TVT_EVENT_TEAM_1_NAME = L2JModSettings.getProperty("TvTEventTeam1Name", "Team1");
  194. + TVT_EVENT_TEAM_2_NAME = L2JModSettings.getProperty("TvTEventTeam2Name", "Team2");
  195. propertySplit = L2JModSettings.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
  196. + propertySplit = L2JModSettings.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
  197.  
  198. if (propertySplit.length < 3)
  199. {
  200. @@ -1899,9 +1903,13 @@
  201. TVT_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  202. TVT_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  203. TVT_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  204. +
  205. + TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  206. + TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  207. + TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  208.  
  209. - TVT_EVENT_TEAM_2_NAME = L2JModSettings.getProperty("TvTEventTeam2Name", "Team2");
  210. - propertySplit = L2JModSettings.getProperty("TvTEventTeam2Coordinates", "0,0,0").split(",");
  211. + TVT_EVENT_TEAM_3_NAME = L2JModSettings.getProperty("TvTEventTeam3Name", "Team2");
  212. + propertySplit = L2JModSettings.getProperty("TvTEventTeam3Coordinates", "0,0,0").split(",");
  213.  
  214. if (propertySplit.length < 3)
  215. {
  216. @@ -1910,9 +1918,9 @@
  217. }
  218. else
  219. {
  220. - TVT_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  221. - TVT_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  222. - TVT_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  223. + TVT_EVENT_TEAM_3_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  224. + TVT_EVENT_TEAM_3_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  225. + TVT_EVENT_TEAM_3_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  226. propertySplit = L2JModSettings.getProperty("TvTEventReward", "57,100000").split(";");
  227.  
  228. for (String reward : propertySplit)
  229. Index: L2_GameServer_It/java/config/l2jmods.properties
  230. ===================================================================
  231. --- L2_GameServer_It/java/config/l2jmods.properties (revision 1433)
  232. +++ L2_GameServer_It/java/config/l2jmods.properties (working copy)
  233. @@ -96,38 +96,54 @@
  234. #---------------------------------------------------------------
  235. # enable TvTEvent
  236. TvTEventEnabled = false
  237. +
  238. # Time Between TvT events (in minutes, 300 = 5 hours)
  239. TvTEventInterval = 300
  240. +
  241. # Registration timer (in minutes) from start of event.
  242. TvTEventParticipationTime = 60
  243. +
  244. # Event running time, in minutes
  245. TvTEventRunningTime = 20
  246. +
  247. # TvT Event NPC Details (create a custom npc of type L2TvTEventNpc)
  248. TvTEventParticipationNpcId = 70010
  249. TvTEventParticipationNpcCoordinates = 83425,148585,-3406
  250. +
  251. # Minimum amount of players allowed in each team
  252. TvTEventMinPlayersInTeams = 1
  253. TvTEventMaxPlayersInTeams = 20
  254. +
  255. # Level rules
  256. TvTEventMinPlayerLevel = 1
  257. TvTEventMaxPlayerLevel = 80
  258. +
  259. # Teleport delay Timers (in seconds)
  260. TvTEventRespawnTeleportDelay = 10
  261. TvTEventStartLeaveTeleportDelay = 10
  262. +
  263. # First Team Details (name, start and death x,y,z tp point)
  264. TvTEventTeam1Name = Team1
  265. TvTEventTeam1Coordinates = 148695,46725,-3414
  266. +
  267. # Second Team Details (name, start and death x,y,z tp point)
  268. TvTEventTeam2Name = Team2
  269. TvTEventTeam2Coordinates = 149999,46728,-3414
  270. +
  271. +# Third Team Details (name, start and death x,y,z tp point)
  272. +TvTEventTeam3Name = Team3
  273. +TvTEventTeam3Coordinates = 149999,46730,-3414
  274. +
  275. # Reward for winning team
  276. # itemId,amount;itemId,amount;itemId,amount;...
  277. # no ";" at the start or end
  278. TvTEventReward = 57,100000;5575,1000
  279. +
  280. # TvTEvent Rules
  281. TvTEventTargetTeamMembersAllowed = true
  282. TvTEventPotionsAllowed = false
  283. TvTEventSummonByItemAllowed = false
  284. +
  285. # Door id's to close/open on start/end
  286. # ex.: 1;2;3;4;5;6
  287. # no ";" at the start or end
  288.  
  289. Index: L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java
  290. ===================================================================
  291. --- L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (revision 1433)
  292. +++ L2_GameServer_It/java/net/sf/l2j/gameserver/model/actor/instance/L2TvTEventNpcInstance.java (working copy)
  293. @@ -68,6 +68,8 @@
  294. npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  295. npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  296. npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  297. + npcHtmlMessage.replace("%team3name%", Config.TVT_EVENT_TEAM_3_NAME);
  298. + npcHtmlMessage.replace("%team3playercount%", String.valueOf(teamsPlayerCounts[2]));
  299. playerInstance.sendPacket(npcHtmlMessage);
  300. }
  301. }
  302. @@ -89,7 +91,10 @@
  303. npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  304. npcHtmlMessage.replace("%team2name%", Config.TVT_EVENT_TEAM_2_NAME);
  305. npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  306. - npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  307. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1]));
  308. + npcHtmlMessage.replace("%team3name%", Config.TVT_EVENT_TEAM_3_NAME);
  309. + npcHtmlMessage.replace("%team3playercount%", String.valueOf(teamsPlayerCounts[2]));
  310. + npcHtmlMessage.replace("%team3points%", String.valueOf(teamsPointsCounts[2]));
  311. playerInstance.sendPacket(npcHtmlMessage);
  312. }
  313. }
  314.  
  315. Index: Data/data/html/mods/TvTEventParticipation.htm
  316. ===================================================================
  317. --- Data/data/html/mods/TvTEventParticipation.htm (revision 680)
  318. +++ Data/data/html/mods/TvTEventParticipation.htm (working copy)
  319. @@ -1,7 +1,8 @@
  320. <html><title>TvT Event</title><body>
  321. Registration for TvT Event:<br><br><center>
  322. %team1name%&nbsp;&nbsp;&nbsp;&nbsp;(%team1playercount% players in)<br1>
  323. -%team2name%&nbsp;&nbsp;&nbsp;&nbsp;(%team2playercount% players in)<br>
  324. +%team2name%&nbsp;&nbsp;&nbsp;&nbsp;(%team2playercount% players in)<br1>
  325. +%team3name%&nbsp;&nbsp;&nbsp;&nbsp;(%team3playercount% players in)<br>
  326. <button value="Participate" action="bypass -h npc_%objectId%_tvt_event_participation" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
  327. <button value="Close" action="bypass -h npc_%objectId%_Close" width=50 height=15 back="sek.cbui94" fore="sek.cbui92">
  328. </center></body></html>
  329. Index: Data/data/html/mods/TvTEventStatus.htm
  330. ===================================================================
  331. --- Data/data/html/mods/TvTEventStatus.htm (revision 680)
  332. +++ Data/data/html/mods/TvTEventStatus.htm (working copy)
  333. @@ -1,5 +1,6 @@
  334. <html><title>TvT Event</title><body>
  335. Status:<br><br><center>
  336. %team1name% with %team1playercount% players and %team1points% points.<br1>
  337. -%team2name% with %team2playercount% players and %team2points% points.<br>
  338. +%team2name% with %team2playercount% players and %team2points% points.<br1>
  339. +%team3name% with %team3playercount% players and %team3points% points.<br>
  340. </center></body></html>
Advertisement
Add Comment
Please, Sign In to add comment