Advertisement
tedlol

last update

Sep 18th, 2012
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 303.36 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/entity/CTFManager.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/entity/CTFManager.java (revision 0)
  4. +++ java/com/l2jserver/gameserver/model/entity/CTFManager.java (working copy)
  5. @@ -0,0 +1,298 @@
  6. +/*
  7. + * This program is free software: you can redistribute it and/or modify it under
  8. + * the terms of the GNU General Public License as published by the Free Software
  9. + * Foundation, either version 3 of the License, or (at your option) any later
  10. + * version.
  11. + *
  12. + * This program is distributed in the hope that it will be useful, but WITHOUT
  13. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  14. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  15. + * details.
  16. + *
  17. + * You should have received a copy of the GNU General Public License along with
  18. + * this program. If not, see <http://www.gnu.org/licenses/>.
  19. + */
  20. +
  21. +package com.l2jserver.gameserver.model.entity;
  22. +
  23. +import java.util.Calendar;
  24. +import java.util.concurrent.ScheduledFuture;
  25. +import java.util.logging.Logger;
  26. +
  27. +import com.l2jserver.Config;
  28. +import com.l2jserver.gameserver.Announcements;
  29. +import com.l2jserver.gameserver.ThreadPoolManager;
  30. +
  31. +/**
  32. + * @author FBIagent, edited U3Games
  33. + */
  34. +
  35. +public class CTFManager
  36. +{
  37. + protected static final Logger _log = Logger.getLogger(CTFManager.class.getName());
  38. +
  39. + /** Task for event cycles<br> */
  40. + private CTFStartTask _task;
  41. +
  42. + /**
  43. + * New instance only by getInstance()<br>
  44. + */
  45. + private CTFManager()
  46. + {
  47. + if (Config.CTF_EVENT_ENABLED)
  48. + {
  49. + CTFEvent.init();
  50. +
  51. + this.scheduleEventStart();
  52. + _log.info("CTFEventEngine[CTFManager.CTFManager()]: Started.");
  53. + }
  54. + else
  55. + {
  56. + _log.info("CTFEventEngine[CTFManager.CTFManager()]: Engine is disabled.");
  57. + }
  58. + }
  59. +
  60. + /**
  61. + * Initialize new/Returns the one and only instance<br><br>
  62. + *
  63. + * @return CTFManager<br>
  64. + */
  65. + public static CTFManager getInstance()
  66. + {
  67. + return SingletonHolder._instance;
  68. + }
  69. +
  70. + /**
  71. + * Starts CTFStartTask
  72. + */
  73. + public void scheduleEventStart()
  74. + {
  75. + try
  76. + {
  77. + Calendar currentTime = Calendar.getInstance();
  78. + Calendar nextStartTime = null;
  79. + Calendar testStartTime = null;
  80. + for (String timeOfDay : Config.CTF_EVENT_INTERVAL)
  81. + {
  82. + // Creating a Calendar object from the specified interval value
  83. + testStartTime = Calendar.getInstance();
  84. + testStartTime.setLenient(true);
  85. + String[] splitTimeOfDay = timeOfDay.split(":");
  86. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  87. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  88. + // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  89. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  90. + {
  91. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  92. + }
  93. + // Check for the test date to be the minimum (smallest in the specified list)
  94. + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
  95. + {
  96. + nextStartTime = testStartTime;
  97. + }
  98. + }
  99. + _task = new CTFStartTask(nextStartTime.getTimeInMillis());
  100. + ThreadPoolManager.getInstance().executeTask(_task);
  101. + }
  102. + catch (Exception e)
  103. + {
  104. + _log.warning("CTFEventEngine[CTFManager.scheduleEventStart()]: Error figuring out a start time. Check CTFEventInterval in config file.");
  105. + }
  106. + }
  107. +
  108. + /**
  109. + * Method to start participation
  110. + */
  111. + public void startReg()
  112. + {
  113. + if (!CTFEvent.startParticipation())
  114. + {
  115. + Announcements.getInstance().announceToAll("CTF Event: Event was cancelled.");
  116. + _log.warning("CTFEventEngine[CTFManager.run()]: Error spawning event npc for participation.");
  117. +
  118. + this.scheduleEventStart();
  119. + }
  120. + else
  121. + {
  122. + Announcements.getInstance().announceToAll("CTF Event: Registration opened for " + Config.CTF_EVENT_PARTICIPATION_TIME
  123. + + " minute(s).");
  124. +
  125. + // schedule registration end
  126. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_PARTICIPATION_TIME);
  127. + ThreadPoolManager.getInstance().executeTask(_task);
  128. + }
  129. + }
  130. +
  131. + /**
  132. + * Method to start the fight
  133. + */
  134. + public void startEvent()
  135. + {
  136. + if (!CTFEvent.startFight())
  137. + {
  138. + Announcements.getInstance().announceToAll("CTF Event: Event cancelled due to lack of Participation.");
  139. + _log.info("CTFEventEngine[CTFManager.run()]: Lack of registration, abort event.");
  140. +
  141. + this.scheduleEventStart();
  142. + }
  143. + else
  144. + {
  145. + CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting participants to an arena in "
  146. + + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  147. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.CTF_EVENT_RUNNING_TIME);
  148. + ThreadPoolManager.getInstance().executeTask(_task);
  149. + }
  150. + }
  151. +
  152. + /**
  153. + * Method to end the event and reward
  154. + */
  155. + public void endEvent()
  156. + {
  157. + Announcements.getInstance().announceToAll(CTFEvent.calculateRewards());
  158. + CTFEvent.sysMsgToAllParticipants("CTF Event: Teleporting back to the registration npc in "
  159. + + Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  160. + CTFEvent.stopFight();
  161. +
  162. + this.scheduleEventStart();
  163. + }
  164. +
  165. + public void skipDelay()
  166. + {
  167. + if (_task.nextRun.cancel(false))
  168. + {
  169. + _task.setStartTime(System.currentTimeMillis());
  170. + ThreadPoolManager.getInstance().executeTask(_task);
  171. + }
  172. + }
  173. +
  174. + /**
  175. + * Class for CTF cycles
  176. + */
  177. + class CTFStartTask implements Runnable
  178. + {
  179. + private long _startTime;
  180. + public ScheduledFuture<?> nextRun;
  181. +
  182. + public CTFStartTask(long startTime)
  183. + {
  184. + _startTime = startTime;
  185. + }
  186. +
  187. + public void setStartTime(long startTime)
  188. + {
  189. + _startTime = startTime;
  190. + }
  191. +
  192. + /**
  193. + * @see java.lang.Runnable#run()
  194. + */
  195. + public void run()
  196. + {
  197. + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  198. +
  199. + if (delay > 0)
  200. + {
  201. + this.announce(delay);
  202. + }
  203. +
  204. + int nextMsg = 0;
  205. + if (delay > 3600)
  206. + {
  207. + nextMsg = delay - 3600;
  208. + }
  209. + else if (delay > 1800)
  210. + {
  211. + nextMsg = delay - 1800;
  212. + }
  213. + else if (delay > 900)
  214. + {
  215. + nextMsg = delay - 900;
  216. + }
  217. + else if (delay > 600)
  218. + {
  219. + nextMsg = delay - 600;
  220. + }
  221. + else if (delay > 300)
  222. + {
  223. + nextMsg = delay - 300;
  224. + }
  225. + else if (delay > 60)
  226. + {
  227. + nextMsg = delay - 60;
  228. + }
  229. + else if (delay > 5)
  230. + {
  231. + nextMsg = delay - 5;
  232. + }
  233. + else if (delay > 0)
  234. + {
  235. + nextMsg = delay;
  236. + }
  237. + else
  238. + {
  239. + // start
  240. + if (CTFEvent.isInactive())
  241. + {
  242. + CTFManager.this.startReg();
  243. + }
  244. + else if (CTFEvent.isParticipating())
  245. + {
  246. + CTFManager.this.startEvent();
  247. + }
  248. + else
  249. + {
  250. + CTFManager.this.endEvent();
  251. + }
  252. + }
  253. +
  254. + if (delay > 0)
  255. + {
  256. + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
  257. + }
  258. + }
  259. +
  260. + private void announce(long time)
  261. + {
  262. + if (time >= 3600 && time % 3600 == 0)
  263. + {
  264. + if (CTFEvent.isParticipating())
  265. + {
  266. + Announcements.getInstance().announceToAll("CTF Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
  267. + }
  268. + else if (CTFEvent.isStarted())
  269. + {
  270. + CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
  271. + }
  272. + }
  273. + else if (time >= 60)
  274. + {
  275. + if (CTFEvent.isParticipating())
  276. + {
  277. + Announcements.getInstance().announceToAll("CTF Event: " + (time / 60) + " minute(s) until registration is closed!");
  278. + }
  279. + else if (CTFEvent.isStarted())
  280. + {
  281. + CTFEvent.sysMsgToAllParticipants("CTF Event: " + (time / 60) + " minute(s) until the event is finished!");
  282. + }
  283. + }
  284. + else
  285. + {
  286. + if (CTFEvent.isParticipating())
  287. + {
  288. + Announcements.getInstance().announceToAll("CTF Event: " + time + " second(s) until registration is closed!");
  289. + }
  290. + else if (CTFEvent.isStarted())
  291. + {
  292. + CTFEvent.sysMsgToAllParticipants("CTF Event: " + time + " second(s) until the event is finished!");
  293. + }
  294. + }
  295. + }
  296. + }
  297. +
  298. + @SuppressWarnings("synthetic-access")
  299. + private static class SingletonHolder
  300. + {
  301. + protected static final CTFManager _instance = new CTFManager();
  302. + }
  303. +}
  304. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  305. ===================================================================
  306. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 65)
  307. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  308. @@ -162,7 +162,9 @@
  309. import com.l2jserver.gameserver.model.effects.EffectTemplate;
  310. import com.l2jserver.gameserver.model.effects.L2Effect;
  311. import com.l2jserver.gameserver.model.effects.L2EffectType;
  312. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  313. import com.l2jserver.gameserver.model.entity.Castle;
  314. +import com.l2jserver.gameserver.model.entity.DMEvent;
  315. import com.l2jserver.gameserver.model.entity.Duel;
  316. import com.l2jserver.gameserver.model.entity.Fort;
  317. import com.l2jserver.gameserver.model.entity.Hero;
  318. @@ -5981,6 +5983,8 @@
  319. {
  320. L2PcInstance pk = killer.getActingPlayer();
  321.  
  322. + CTFEvent.onKill(killer, this);
  323. + DMEvent.onKill(killer, this);
  324. TvTEvent.onKill(killer, this);
  325. TvTRoundEvent.onKill(killer, this);
  326.  
  327. @@ -9439,6 +9443,18 @@
  328. }
  329. }
  330.  
  331. + // Check if the attacker is in CTF and CTF is started
  332. + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(getObjectId()))
  333. + {
  334. + return true;
  335. + }
  336. +
  337. + // Check if the attacker is in DM and DM is started
  338. + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(getObjectId()))
  339. + {
  340. + return true;
  341. + }
  342. +
  343. // Check if the attacker is in TvT and TvT is started
  344. if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId()))
  345. {
  346. @@ -12243,6 +12259,8 @@
  347. pet.updateAndBroadcastStatus(0);
  348. }
  349.  
  350. + CTFEvent.onTeleported(this);
  351. + DMEvent.onTeleported(this);
  352. TvTEvent.onTeleported(this);
  353. TvTRoundEvent.onTeleported(this);
  354. }
  355. @@ -13008,6 +13026,26 @@
  356. _log.log(Level.SEVERE, "deleteMe()", e);
  357. }
  358.  
  359. + // CTF Event removal
  360. + try
  361. + {
  362. + CTFEvent.onLogout(this);
  363. + }
  364. + catch (Exception e)
  365. + {
  366. + _log.log(Level.SEVERE, "deleteMe()", e);
  367. + }
  368. +
  369. + // DM Event removal
  370. + try
  371. + {
  372. + DMEvent.onLogout(this);
  373. + }
  374. + catch (Exception e)
  375. + {
  376. + _log.log(Level.SEVERE, "deleteMe()", e);
  377. + }
  378. +
  379. // TvT Event removal
  380. try
  381. {
  382. @@ -13880,6 +13918,14 @@
  383. sendMessage("You are in jail for " + delayInMinutes + " minutes.");
  384. }
  385.  
  386. + if (!CTFEvent.isInactive() && CTFEvent.isPlayerParticipant(getObjectId()))
  387. + {
  388. + CTFEvent.removeParticipant(getObjectId());
  389. + }
  390. + if (!DMEvent.isInactive() && DMEvent.isPlayerParticipant(getObjectId()))
  391. + {
  392. + DMEvent.removeParticipant(getObjectId());
  393. + }
  394. if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(getObjectId()))
  395. {
  396. TvTEvent.removeParticipant(getObjectId());
  397. @@ -14315,7 +14361,7 @@
  398.  
  399. public void calculateDeathPenaltyBuffLevel(L2Character killer)
  400. {
  401. - if (((getKarma() > 0) || (Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE)) && !(killer instanceof L2PcInstance) && !(canOverrideCond(PcCondOverride.DEATH_PENALTY)) && !(getCharmOfLuck() && killer.isRaid()) && !isPhoenixBlessed() && !isLucky() && !(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId())) && !(TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(getObjectId())) && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
  402. + if (((getKarma() > 0) || (Rnd.get(1, 100) <= Config.DEATH_PENALTY_CHANCE)) && !(killer instanceof L2PcInstance) && !(canOverrideCond(PcCondOverride.DEATH_PENALTY)) && !(getCharmOfLuck() && killer.isRaid()) && !isPhoenixBlessed() && !isLucky() && !(CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(getObjectId())) && !(DMEvent.isStarted() && DMEvent.isPlayerParticipant(getObjectId())) && !(TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(getObjectId())) && !(TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(getObjectId())) && !(isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE)))
  403. {
  404. increaseDeathPenaltyBuffLevel();
  405. }
  406. @@ -14834,6 +14880,18 @@
  407. return false;
  408. }
  409.  
  410. + if (!CTFEvent.onEscapeUse(summonerChar.getObjectId()))
  411. + {
  412. + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
  413. + return false;
  414. + }
  415. +
  416. + if (!DMEvent.onEscapeUse(summonerChar.getObjectId()))
  417. + {
  418. + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
  419. + return false;
  420. + }
  421. +
  422. if (!TvTEvent.onEscapeUse(summonerChar.getObjectId()))
  423. {
  424. summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  425. @@ -14913,6 +14971,18 @@
  426. return false;
  427. }
  428.  
  429. + if (!CTFEvent.onEscapeUse(targetChar.getObjectId()))
  430. + {
  431. + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
  432. + return false;
  433. + }
  434. +
  435. + if (!DMEvent.onEscapeUse(targetChar.getObjectId()))
  436. + {
  437. + summonerChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING));
  438. + return false;
  439. + }
  440. +
  441. if (!TvTEvent.onEscapeUse(targetChar.getObjectId()))
  442. {
  443. summonerChar.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  444. Index: java/com/l2jserver/gameserver/engines/DocumentBase.java
  445. ===================================================================
  446. --- java/com/l2jserver/gameserver/engines/DocumentBase.java (revision 65)
  447. +++ java/com/l2jserver/gameserver/engines/DocumentBase.java (working copy)
  448. @@ -740,6 +740,16 @@
  449. boolean val = Boolean.parseBoolean(a.getNodeValue());
  450. cond = joinAnd(cond, new ConditionPlayerIsClanLeader(val));
  451. }
  452. + else if ("onCTFEvent".equalsIgnoreCase(a.getNodeName()))
  453. + {
  454. + boolean val = Boolean.valueOf(a.getNodeValue());
  455. + cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
  456. + }
  457. + else if ("onDMEvent".equalsIgnoreCase(a.getNodeName()))
  458. + {
  459. + boolean val = Boolean.valueOf(a.getNodeValue());
  460. + cond = joinAnd(cond, new ConditionPlayerTvTEvent(val));
  461. + }
  462. else if ("onTvTEvent".equalsIgnoreCase(a.getNodeName()))
  463. {
  464. boolean val = Boolean.parseBoolean(a.getNodeValue());
  465. Index: java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java
  466. ===================================================================
  467. --- java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java (revision 65)
  468. +++ java/com/l2jserver/gameserver/instancemanager/AntiFeedManager.java (working copy)
  469. @@ -33,6 +33,8 @@
  470. public static final int TVT_ID = 2;
  471. public static final int L2EVENT_ID = 3;
  472. public static final int TVT_ROUND_ID = 4;
  473. + public static final int CTF_ID = 5;
  474. + public static final int DM_ID = 6;
  475.  
  476. private final Map<Integer, Long> _lastDeathTimes = new L2FastMap<>(true);
  477. private final L2HashMap<Integer, Map<Integer, Connections>> _eventIPs = new L2HashMap<>();
  478. Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java
  479. ===================================================================
  480. --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (revision 65)
  481. +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillMount.java (working copy)
  482. @@ -18,6 +18,8 @@
  483. import com.l2jserver.gameserver.model.StatsSet;
  484. import com.l2jserver.gameserver.model.actor.L2Character;
  485. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  486. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  487. +import com.l2jserver.gameserver.model.entity.DMEvent;
  488. import com.l2jserver.gameserver.model.entity.TvTEvent;
  489. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  490. import com.l2jserver.gameserver.model.skills.L2Skill;
  491. @@ -43,11 +45,21 @@
  492. return;
  493. }
  494.  
  495. + if (!CTFEvent.onItemSummon(caster.getObjectId()))
  496. + {
  497. + return;
  498. + }
  499. +
  500. + if (!DMEvent.onItemSummon(caster.getObjectId()))
  501. + {
  502. + return;
  503. + }
  504. +
  505. if (!TvTEvent.onItemSummon(caster.getObjectId()))
  506. {
  507. return;
  508. }
  509. -
  510. +
  511. if (!TvTRoundEvent.onItemSummon(caster.getObjectId()))
  512. {
  513. return;
  514. Index: java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java
  515. ===================================================================
  516. --- java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java (revision 0)
  517. +++ java/com/l2jserver/gameserver/model/entity/DMEventPlayer.java (working copy)
  518. @@ -0,0 +1,207 @@
  519. +/*
  520. + * This program is free software: you can redistribute it and/or modify it under
  521. + * the terms of the GNU General Public License as published by the Free Software
  522. + * Foundation, either version 3 of the License, or (at your option) any later
  523. + * version.
  524. + *
  525. + * This program is distributed in the hope that it will be useful, but WITHOUT
  526. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  527. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  528. + * details.
  529. + *
  530. + * You should have received a copy of the GNU General Public License along with
  531. + * this program. If not, see <http://www.gnu.org/licenses/>.
  532. + */
  533. +
  534. +package com.l2jserver.gameserver.model.entity;
  535. +
  536. +import java.util.Map;
  537. +
  538. +import javolution.util.FastMap;
  539. +
  540. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  541. +
  542. +/**
  543. + * @author FBIagent, edited U3Games
  544. + */
  545. +
  546. +public class DMEventPlayer
  547. +{
  548. + /** The player of the player<br> */
  549. + private L2PcInstance _player;
  550. + /** The points of the player<br> */
  551. + private short _points;
  552. + /** The death of the player<br> */
  553. + private short _death;
  554. + private String _hexCode;
  555. + /** player and instance of all participated players in FastMap<br> */
  556. + private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<Integer, L2PcInstance>();
  557. +
  558. + /**
  559. + * C'tor initialize the team<br><br>
  560. + *
  561. + * @param player as String<br>
  562. + * @param coordinates as int[]<br>
  563. + */
  564. + public DMEventPlayer(L2PcInstance player, int[] coordinates, String hexCode)
  565. + {
  566. + _player = player;
  567. + _coordinates = coordinates;
  568. + _points = 0;
  569. + _death = 0;
  570. + _hexCode = hexCode;
  571. + }
  572. +
  573. + /**
  574. + * Adds a player to the team<br><br>
  575. + *
  576. + * @param playerInstance as L2PcInstance<br>
  577. + * @return boolean: true if success, otherwise false<br>
  578. + */
  579. + public boolean addPlayer(L2PcInstance playerInstance)
  580. + {
  581. + if (playerInstance == null)
  582. + {
  583. + return false;
  584. + }
  585. +
  586. + synchronized (_participatedPlayers)
  587. + {
  588. + _participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
  589. + }
  590. +
  591. + return true;
  592. + }
  593. +
  594. + /**
  595. + * Removes a player from the team
  596. + * @param playerObjectId
  597. + */
  598. + public void removePlayer(int playerObjectId)
  599. + {
  600. + synchronized (_participatedPlayers)
  601. + {
  602. + _participatedPlayers.remove(playerObjectId);
  603. + }
  604. + }
  605. +
  606. + /**
  607. + * Increases the points of the team<br>
  608. + */
  609. + public short getPoints()
  610. + {
  611. + return _points;
  612. + }
  613. +
  614. + /**
  615. + * Cleanup the team and make it ready for adding players again<br>
  616. + */
  617. + public void cleanMe()
  618. + {
  619. + _participatedPlayers.clear();
  620. + _participatedPlayers = new FastMap<Integer, L2PcInstance>();
  621. + _points = 0;
  622. + }
  623. +
  624. + /**
  625. + * Returns the player of the team<br><br>
  626. + *
  627. + * @return String: player of the team<br>
  628. + */
  629. + public L2PcInstance getPlayer()
  630. + {
  631. + return _player;
  632. + }
  633. +
  634. + /**
  635. + * Returns the coordinates of the team spot<br><br>
  636. + *
  637. + * @return int[]: team coordinates<br>
  638. + */
  639. + public int[] getCoordinates()
  640. + {
  641. + return _coordinates;
  642. + }
  643. +
  644. + /**
  645. + * @param points the _points to set
  646. + */
  647. + public void setPoints(short points)
  648. + {
  649. + _points = points;
  650. + }
  651. +
  652. + /**
  653. + * Increases the points of the player<br>
  654. + */
  655. + public void increasePoints()
  656. + {
  657. + ++_points;
  658. + }
  659. +
  660. + /**
  661. + * @return the _death
  662. + */
  663. + public short getDeath()
  664. + {
  665. + return _death;
  666. + }
  667. +
  668. + /**
  669. + * @param death the _death to set
  670. + */
  671. + public void setDeath(short death)
  672. + {
  673. + _death = death;
  674. + }
  675. +
  676. + /**
  677. + * Increases the death of the player<br>
  678. + */
  679. + public void increaseDeath()
  680. + {
  681. + ++_death;
  682. + }
  683. +
  684. + /**
  685. + * @return the _hexCode
  686. + */
  687. + public String getHexCode()
  688. + {
  689. + return _hexCode;
  690. + }
  691. +
  692. + /**
  693. + * Returns player and instance of all participated players in FastMap<br><br>
  694. + *
  695. + * @return Map<String, L2PcInstance>: map of players in this team<br>
  696. + */
  697. + public Map<Integer, L2PcInstance> getParticipatedPlayers()
  698. + {
  699. + Map<Integer, L2PcInstance> participatedPlayers = null;
  700. +
  701. + synchronized (_participatedPlayers)
  702. + {
  703. + participatedPlayers = _participatedPlayers;
  704. + }
  705. +
  706. + return participatedPlayers;
  707. + }
  708. +
  709. + /**
  710. + * Returns player count of this team<br><br>
  711. + *
  712. + * @return int: number of players in team<br>
  713. + */
  714. + public int getParticipatedPlayerCount()
  715. + {
  716. + int participatedPlayerCount;
  717. +
  718. + synchronized (_participatedPlayers)
  719. + {
  720. + participatedPlayerCount = _participatedPlayers.size();
  721. + }
  722. +
  723. + return participatedPlayerCount;
  724. + }
  725. +}
  726. Index: java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
  727. ===================================================================
  728. --- java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (revision 65)
  729. +++ java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java (working copy)
  730. @@ -51,8 +51,10 @@
  731. import com.l2jserver.gameserver.model.PcCondOverride;
  732. import com.l2jserver.gameserver.model.actor.instance.L2ClassMasterInstance;
  733. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  734. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  735. import com.l2jserver.gameserver.model.entity.Castle;
  736. import com.l2jserver.gameserver.model.entity.Couple;
  737. +import com.l2jserver.gameserver.model.entity.DMEvent;
  738. import com.l2jserver.gameserver.model.entity.Fort;
  739. import com.l2jserver.gameserver.model.entity.FortSiege;
  740. import com.l2jserver.gameserver.model.entity.Hitman;
  741. @@ -146,9 +148,9 @@
  742. {
  743. L2PcInstance activeChar = getClient().getActiveChar();
  744.  
  745. - PvPColorSystem pvpcolor = new PvPColorSystem();
  746. - pvpcolor.updateNameColor(activeChar);
  747. - pvpcolor.updateTitleColor(activeChar);
  748. + PvPColorSystem pvpcolor = new PvPColorSystem();
  749. + pvpcolor.updateNameColor(activeChar);
  750. + pvpcolor.updateTitleColor(activeChar);
  751.  
  752. if (activeChar == null)
  753. {
  754. @@ -188,14 +190,14 @@
  755. _log.warning("User already exists in Object ID map! User " + activeChar.getName() + " is a character clone.");
  756. }
  757. }
  758. -
  759. - if (activeChar.getPremiumService()==1)
  760. +
  761. + if (activeChar.getPremiumService() == 1)
  762. {
  763. activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(), 1));
  764. }
  765. else
  766. {
  767. - activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(),0));
  768. + activeChar.sendPacket(new ExBrPremiumState(activeChar.getObjectId(), 0));
  769. }
  770.  
  771. // Apply special GM properties to the GM when entering
  772. @@ -452,14 +454,18 @@
  773. }
  774.  
  775. activeChar.updateEffectIcons();
  776. -
  777. +
  778. if (Config.PC_BANG_ENABLED)
  779. + {
  780. + if (activeChar.getPcBangPoints() > 0)
  781. {
  782. - if (activeChar.getPcBangPoints() > 0)
  783. - activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcBangPoints(), 0, 1));
  784. - else
  785. - activeChar.sendPacket(new ExPCCafePointInfo());
  786. + activeChar.sendPacket(new ExPCCafePointInfo(activeChar.getPcBangPoints(), 0, 1));
  787. }
  788. + else
  789. + {
  790. + activeChar.sendPacket(new ExPCCafePointInfo());
  791. + }
  792. + }
  793.  
  794. activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  795.  
  796. @@ -484,8 +490,8 @@
  797. Announcements.getInstance().showAnnouncements(activeChar);
  798. activeChar.sendMessage("==================================");
  799. activeChar.sendMessage("Developer: Flash ");
  800. - activeChar.sendMessage("Welcome Back "+activeChar.getName()+" to our Server!");
  801. - activeChar.sendMessage("players online "+L2World.getInstance().getAllPlayers().size());
  802. + activeChar.sendMessage("Welcome Back " + activeChar.getName() + " to our Server!");
  803. + activeChar.sendMessage("players online " + L2World.getInstance().getAllPlayers().size());
  804. activeChar.sendMessage("==================================");
  805.  
  806. if (showClanNotice)
  807. @@ -505,19 +511,23 @@
  808. sendPacket(new NpcHtmlMessage(1, serverNews));
  809. }
  810. }
  811. -
  812. +
  813. // Bot manager punishment
  814. - if(Config.ENABLE_BOTREPORT)
  815. - BotManager.getInstance().onEnter(activeChar);
  816. + if (Config.ENABLE_BOTREPORT)
  817. + {
  818. + BotManager.getInstance().onEnter(activeChar);
  819. + }
  820.  
  821. // Clan Leader Color Name
  822. - if (!activeChar.isGM() && (activeChar.getClan() != null && activeChar.isClanLeader() && Config.CLAN_LEADER_COLOR_ENABLED && activeChar.getClan().getLevel() >= Config.CLAN_LEADER_COLOR_CLAN_LEVEL))
  823. - activeChar.getAppearance().setNameColor(Config.CLAN_LEADER_COLOR);
  824. + if (!activeChar.isGM() && ((activeChar.getClan() != null) && activeChar.isClanLeader() && Config.CLAN_LEADER_COLOR_ENABLED && (activeChar.getClan().getLevel() >= Config.CLAN_LEADER_COLOR_CLAN_LEVEL)))
  825. + {
  826. + activeChar.getAppearance().setNameColor(Config.CLAN_LEADER_COLOR);
  827. + }
  828.  
  829. if (Config.ANNOUNCE_CASTLE_LORDS)
  830. {
  831. notifyCastleOwner(activeChar);
  832. - }
  833. + }
  834.  
  835. if (Config.PETITIONING_ALLOWED)
  836. {
  837. @@ -538,7 +548,7 @@
  838. sendPacket(new ExNevitAdventTimeChange(activeChar.getAdventTime(), false));
  839. sendPacket(new ExShowContactList(activeChar));
  840.  
  841. - boolean reloadRune = false;
  842. + boolean reloadRune = false;
  843. for (L2ItemInstance i : activeChar.getInventory().getItems())
  844. {
  845. if (i.isTimeLimitedItem())
  846. @@ -548,12 +558,16 @@
  847. if (i.isShadowItem() && i.isEquipped())
  848. {
  849. i.decreaseMana(false);
  850. - if(i.isRune())
  851. - reloadRune = true;
  852. + if (i.isRune())
  853. + {
  854. + reloadRune = true;
  855. + }
  856. }
  857. }
  858. - if (reloadRune)
  859. + if (reloadRune)
  860. + {
  861. activeChar.reloadRune();
  862. + }
  863. for (L2ItemInstance i : activeChar.getWarehouse().getItems())
  864. {
  865. if (i.isTimeLimitedItem())
  866. @@ -561,16 +575,16 @@
  867. i.scheduleLifeTimeTask();
  868. }
  869. }
  870. - for (L2ItemInstance items : activeChar.getInventory().getItems())
  871. - {
  872. - if (!activeChar.isGM() && items.isEquipable() && items.getEnchantLevel() > Config.MAX_ENCHANT_LEVEL)
  873. - {
  874. - activeChar.getInventory().destroyItem(null, items, activeChar, null);
  875. - Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " has Overenchanted item! Kicked! ", Config.DEFAULT_PUNISH);
  876. - _log.info(items+" item has been removed from "+activeChar);
  877. - }
  878. - }
  879. -
  880. + for (L2ItemInstance items : activeChar.getInventory().getItems())
  881. + {
  882. + if (!activeChar.isGM() && items.isEquipable() && (items.getEnchantLevel() > Config.MAX_ENCHANT_LEVEL))
  883. + {
  884. + activeChar.getInventory().destroyItem(null, items, activeChar, null);
  885. + Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " has Overenchanted item! Kicked! ", Config.DEFAULT_PUNISH);
  886. + _log.info(items + " item has been removed from " + activeChar);
  887. + }
  888. + }
  889. +
  890. if (DimensionalRiftManager.getInstance().checkIfInRiftZone(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false))
  891. {
  892. DimensionalRiftManager.getInstance().teleportToWaitingRoom(activeChar);
  893. @@ -616,6 +630,8 @@
  894. RegionBBSManager.getInstance().changeCommunityBoard();
  895. CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_STATUS));
  896.  
  897. + CTFEvent.onLogin(activeChar);
  898. + DMEvent.onLogin(activeChar);
  899. TvTEvent.onLogin(activeChar);
  900. TvTRoundEvent.onLogin(activeChar);
  901.  
  902. @@ -625,9 +641,11 @@
  903. }
  904.  
  905. L2ClassMasterInstance.showQuestionMark(activeChar);
  906. - if(Config.ALLOW_HITMAN_GDE)
  907. - Hitman.getInstance().onEnterWorld(activeChar);
  908. -
  909. + if (Config.ALLOW_HITMAN_GDE)
  910. + {
  911. + Hitman.getInstance().onEnterWorld(activeChar);
  912. + }
  913. +
  914. int birthday = activeChar.checkBirthDay();
  915. if (birthday == 0)
  916. {
  917. @@ -783,19 +801,19 @@
  918. {
  919. qs.getQuest().notifyEvent("UC", null, player);
  920. }
  921. -
  922. +
  923. }
  924. +
  925. // Premium Service Icon
  926. private void PremiumServiceIcon(L2PcInstance activeChar)
  927. {
  928. - if(activeChar.getPremiumService()==1)
  929. + if (activeChar.getPremiumService() == 1)
  930. {
  931. activeChar.sendPacket(new PremiumState(activeChar.getObjectId(), 1));
  932. activeChar.sendMessage("Premium account: now active");
  933. }
  934. }
  935.  
  936. -
  937. @Override
  938. public String getType()
  939. {
  940. @@ -829,6 +847,7 @@
  941. {
  942. listeners.remove(listener);
  943. }
  944. +
  945. private void notifyCastleOwner(L2PcInstance activeChar)
  946. {
  947. L2Clan clan = activeChar.getClan();
  948. @@ -839,7 +858,9 @@
  949. {
  950. Castle castle = CastleManager.getInstance().getCastleById(clan.getCastleId());
  951. if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
  952. + {
  953. Announcements.getInstance().announceToAll("Lord " + activeChar.getName() + " Ruler Of " + castle.getName() + " Castle is Now Online!");
  954. + }
  955. }
  956. }
  957. }
  958. Index: java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java
  959. ===================================================================
  960. --- java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java (revision 0)
  961. +++ java/com/l2jserver/gameserver/model/actor/instance/L2CTFEventNpcInstance.java (working copy)
  962. @@ -0,0 +1,108 @@
  963. +/*
  964. + * This program is free software: you can redistribute it and/or modify it under
  965. + * the terms of the GNU General Public License as published by the Free Software
  966. + * Foundation, either version 3 of the License, or (at your option) any later
  967. + * version.
  968. + *
  969. + * This program is distributed in the hope that it will be useful, but WITHOUT
  970. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  971. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  972. + * details.
  973. + *
  974. + * You should have received a copy of the GNU General Public License along with
  975. + * this program. If not, see <http://www.gnu.org/licenses/>.
  976. + */
  977. +
  978. +package com.l2jserver.gameserver.model.actor.instance;
  979. +
  980. +import com.l2jserver.Config;
  981. +import com.l2jserver.gameserver.cache.HtmCache;
  982. +import com.l2jserver.gameserver.model.actor.L2Npc;
  983. +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  984. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  985. +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  986. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  987. +
  988. +public class L2CTFEventNpcInstance extends L2Npc
  989. +{
  990. + private static final String htmlPath = "data/html/mods/CTFEvent/";
  991. +
  992. + public L2CTFEventNpcInstance(int objectId, L2NpcTemplate template)
  993. + {
  994. + super(objectId, template);
  995. + setInstanceType(InstanceType.L2CTFEventNpcInstance);
  996. + }
  997. +
  998. + @Override
  999. + public void onBypassFeedback(L2PcInstance playerInstance, String command)
  1000. + {
  1001. + CTFEvent.onBypass(command, playerInstance);
  1002. + }
  1003. +
  1004. + @Override
  1005. + public void showChatWindow(L2PcInstance playerInstance, int val)
  1006. + {
  1007. + if (playerInstance == null)
  1008. + {
  1009. + return;
  1010. + }
  1011. +
  1012. + if (CTFEvent.isParticipating())
  1013. + {
  1014. + final boolean isParticipant = CTFEvent.isPlayerParticipant(playerInstance.getObjectId());
  1015. + final String htmContent;
  1016. +
  1017. + if (!isParticipant)
  1018. + {
  1019. + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Participation.htm");
  1020. + }
  1021. + else
  1022. + {
  1023. + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "RemoveParticipation.htm");
  1024. + }
  1025. +
  1026. + if (htmContent != null)
  1027. + {
  1028. + int[] teamsPlayerCounts = CTFEvent.getTeamsPlayerCounts();
  1029. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1030. +
  1031. + npcHtmlMessage.setHtml(htmContent);
  1032. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1033. + npcHtmlMessage.replace("%team1name%", Config.CTF_EVENT_TEAM_1_NAME);
  1034. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1035. + npcHtmlMessage.replace("%team2name%", Config.CTF_EVENT_TEAM_2_NAME);
  1036. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1037. + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0] + teamsPlayerCounts[1]));
  1038. + if (!isParticipant)
  1039. + {
  1040. + npcHtmlMessage.replace("%fee%", CTFEvent.getParticipationFee());
  1041. + }
  1042. +
  1043. + playerInstance.sendPacket(npcHtmlMessage);
  1044. + }
  1045. + }
  1046. + else if (CTFEvent.isStarting() || CTFEvent.isStarted())
  1047. + {
  1048. + final String htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Status.htm");
  1049. +
  1050. + if (htmContent != null)
  1051. + {
  1052. + int[] teamsPlayerCounts = CTFEvent.getTeamsPlayerCounts();
  1053. + int[] teamsPointsCounts = CTFEvent.getTeamsPoints();
  1054. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  1055. +
  1056. + npcHtmlMessage.setHtml(htmContent);
  1057. + // npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  1058. + npcHtmlMessage.replace("%team1name%", Config.CTF_EVENT_TEAM_1_NAME);
  1059. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  1060. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  1061. + npcHtmlMessage.replace("%team2name%", Config.CTF_EVENT_TEAM_2_NAME);
  1062. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  1063. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  1064. + playerInstance.sendPacket(npcHtmlMessage);
  1065. + }
  1066. + }
  1067. +
  1068. + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
  1069. + }
  1070. +}
  1071. Index: java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java
  1072. ===================================================================
  1073. --- java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java (revision 65)
  1074. +++ java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java (working copy)
  1075. @@ -32,6 +32,8 @@
  1076. import com.l2jserver.gameserver.model.actor.L2Summon;
  1077. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  1078. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  1079. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  1080. +import com.l2jserver.gameserver.model.entity.DMEvent;
  1081. import com.l2jserver.gameserver.model.entity.TvTEvent;
  1082. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  1083. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  1084. @@ -140,7 +142,7 @@
  1085. }
  1086.  
  1087. // safety precautions
  1088. - if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()))
  1089. + if (player.inObserverMode() || TvTEvent.isPlayerParticipant(player.getObjectId()) || CTFEvent.isPlayerParticipant(player.getObjectId()) || DMEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()))
  1090. {
  1091. return SystemMessage.getSystemMessage(SystemMessageId.THE_GAME_HAS_BEEN_CANCELLED_BECAUSE_THE_OTHER_PARTY_DOES_NOT_MEET_THE_REQUIREMENTS_FOR_JOINING_THE_GAME);
  1092. }
  1093. Index: java/com/l2jserver/gameserver/model/entity/DMEvent.java
  1094. ===================================================================
  1095. --- java/com/l2jserver/gameserver/model/entity/DMEvent.java (revision 0)
  1096. +++ java/com/l2jserver/gameserver/model/entity/DMEvent.java (working copy)
  1097. @@ -0,0 +1,1215 @@
  1098. +/*
  1099. + * This program is free software: you can redistribute it and/or modify it under
  1100. + * the terms of the GNU General Public License as published by the Free Software
  1101. + * Foundation, either version 3 of the License, or (at your option) any later
  1102. + * version.
  1103. + *
  1104. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1105. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1106. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1107. + * details.
  1108. + *
  1109. + * You should have received a copy of the GNU General Public License along with
  1110. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1111. + */
  1112. +
  1113. +package com.l2jserver.gameserver.model.entity;
  1114. +
  1115. +import java.math.BigInteger;
  1116. +import java.util.Collection;
  1117. +import java.util.Comparator;
  1118. +import java.util.List;
  1119. +import java.util.Map;
  1120. +import java.util.TreeSet;
  1121. +import java.util.logging.Level;
  1122. +import java.util.logging.Logger;
  1123. +
  1124. +import javolution.util.FastMap;
  1125. +
  1126. +import com.l2jserver.Config;
  1127. +import com.l2jserver.gameserver.cache.HtmCache;
  1128. +import com.l2jserver.gameserver.datatables.DoorTable;
  1129. +import com.l2jserver.gameserver.datatables.ItemTable;
  1130. +import com.l2jserver.gameserver.datatables.NpcTable;
  1131. +import com.l2jserver.gameserver.datatables.SkillTable;
  1132. +import com.l2jserver.gameserver.datatables.SpawnTable;
  1133. +import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
  1134. +import com.l2jserver.gameserver.instancemanager.InstanceManager;
  1135. +import com.l2jserver.gameserver.model.L2Party;
  1136. +import com.l2jserver.gameserver.model.L2Spawn;
  1137. +import com.l2jserver.gameserver.model.L2World;
  1138. +import com.l2jserver.gameserver.model.actor.L2Character;
  1139. +import com.l2jserver.gameserver.model.actor.L2Npc;
  1140. +import com.l2jserver.gameserver.model.actor.L2Summon;
  1141. +import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  1142. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  1143. +import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  1144. +import com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance;
  1145. +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  1146. +import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  1147. +import com.l2jserver.gameserver.model.skills.L2Skill;
  1148. +import com.l2jserver.gameserver.network.SystemMessageId;
  1149. +import com.l2jserver.gameserver.network.clientpackets.Say2;
  1150. +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  1151. +import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  1152. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  1153. +import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
  1154. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  1155. +import com.l2jserver.util.Rnd;
  1156. +import com.l2jserver.util.StringUtil;
  1157. +
  1158. +/**
  1159. + * @author FBIagent, edited U3Games and DreamStage
  1160. + */
  1161. +
  1162. +public class DMEvent
  1163. +{
  1164. + enum EventState
  1165. + {
  1166. + INACTIVE,
  1167. + INACTIVATING,
  1168. + PARTICIPATING,
  1169. + STARTING,
  1170. + STARTED,
  1171. + REWARDING
  1172. + }
  1173. +
  1174. + protected static final Logger _log = Logger.getLogger(DMEvent.class.getName());
  1175. + /** html path **/
  1176. + private static final String htmlPath = "data/html/mods/DMEvent/";
  1177. + /** The state of the DMEvent<br> */
  1178. + private static EventState _state = EventState.INACTIVE;
  1179. + /** The spawn of the participation npc<br> */
  1180. + private static L2Spawn _npcSpawn = null;
  1181. + /** The teams of the TvTEvent<br> */
  1182. + public static TvTEventTeam[] _teams = new TvTEventTeam[1];
  1183. + /** the npc instance of the participation npc<br> */
  1184. + private static L2Npc _lastNpcSpawn = null;
  1185. + /** Instance id<br> */
  1186. + private static int _DMEventInstance = 0;
  1187. +
  1188. + // private static List<DMEventPlayer> _DMEventPlayer = new ArrayList<DMEventPlayer>();
  1189. +
  1190. + private static Map<Integer, DMEventPlayer> _DMEventPlayer = new FastMap<Integer, DMEventPlayer>();
  1191. +
  1192. + public DMEvent()
  1193. + {
  1194. + }
  1195. +
  1196. + /**
  1197. + * DM initializing<br>
  1198. + */
  1199. + public static void init()
  1200. + {
  1201. + }
  1202. +
  1203. + /**
  1204. + * Sets the DMEvent state<br>
  1205. + * <br>
  1206. + * @param state as EventState<br>
  1207. + */
  1208. + private static void setState(EventState state)
  1209. + {
  1210. + synchronized (_state)
  1211. + {
  1212. + _state = state;
  1213. + }
  1214. + }
  1215. +
  1216. + /**
  1217. + * Is DMEvent inactive?<br>
  1218. + * <br>
  1219. + * @return boolean: true if event is inactive(waiting for next event cycle), otherwise false<br>
  1220. + */
  1221. + public static boolean isInactive()
  1222. + {
  1223. + boolean isInactive;
  1224. +
  1225. + synchronized (_state)
  1226. + {
  1227. + isInactive = _state == EventState.INACTIVE;
  1228. + }
  1229. +
  1230. + return isInactive;
  1231. + }
  1232. +
  1233. + /**
  1234. + * Is DMEvent in inactivating?<br>
  1235. + * <br>
  1236. + * @return boolean: true if event is in inactivating progress, otherwise false<br>
  1237. + */
  1238. + public static boolean isInactivating()
  1239. + {
  1240. + boolean isInactivating;
  1241. +
  1242. + synchronized (_state)
  1243. + {
  1244. + isInactivating = _state == EventState.INACTIVATING;
  1245. + }
  1246. +
  1247. + return isInactivating;
  1248. + }
  1249. +
  1250. + /**
  1251. + * Is DMEvent in participation?<br>
  1252. + * <br>
  1253. + * @return boolean: true if event is in participation progress, otherwise false<br>
  1254. + */
  1255. + public static boolean isParticipating()
  1256. + {
  1257. + boolean isParticipating;
  1258. +
  1259. + synchronized (_state)
  1260. + {
  1261. + isParticipating = _state == EventState.PARTICIPATING;
  1262. + }
  1263. +
  1264. + return isParticipating;
  1265. + }
  1266. +
  1267. + /**
  1268. + * Is DMEvent starting?<br>
  1269. + * <br>
  1270. + * @return boolean: true if event is starting up(setting up fighting spot, teleport players etc.), otherwise false<br>
  1271. + */
  1272. + public static boolean isStarting()
  1273. + {
  1274. + boolean isStarting;
  1275. +
  1276. + synchronized (_state)
  1277. + {
  1278. + isStarting = _state == EventState.STARTING;
  1279. + }
  1280. +
  1281. + return isStarting;
  1282. + }
  1283. +
  1284. + /**
  1285. + * Is DMEvent started?<br>
  1286. + * <br>
  1287. + * @return boolean: true if event is started, otherwise false<br>
  1288. + */
  1289. + public static boolean isStarted()
  1290. + {
  1291. + boolean isStarted;
  1292. +
  1293. + synchronized (_state)
  1294. + {
  1295. + isStarted = _state == EventState.STARTED;
  1296. + }
  1297. +
  1298. + return isStarted;
  1299. + }
  1300. +
  1301. + /**
  1302. + * Is DMEvent rewadrding?<br>
  1303. + * <br>
  1304. + * @return boolean: true if event is currently rewarding, otherwise false<br>
  1305. + */
  1306. + public static boolean isRewarding()
  1307. + {
  1308. + boolean isRewarding;
  1309. +
  1310. + synchronized (_state)
  1311. + {
  1312. + isRewarding = _state == EventState.REWARDING;
  1313. + }
  1314. +
  1315. + return isRewarding;
  1316. + }
  1317. +
  1318. + /**
  1319. + * Close doors specified in configs
  1320. + */
  1321. + private static void closeDoors(List<Integer> doors)
  1322. + {
  1323. + for (int doorId : doors)
  1324. + {
  1325. + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
  1326. +
  1327. + if (doorInstance != null)
  1328. + {
  1329. + doorInstance.closeMe();
  1330. + }
  1331. + }
  1332. + }
  1333. +
  1334. + /**
  1335. + * Open doors specified in configs
  1336. + */
  1337. + private static void openDoors(List<Integer> doors)
  1338. + {
  1339. + for (int doorId : doors)
  1340. + {
  1341. + L2DoorInstance doorInstance = DoorTable.getInstance().getDoor(doorId);
  1342. +
  1343. + if (doorInstance != null)
  1344. + {
  1345. + doorInstance.openMe();
  1346. + }
  1347. + }
  1348. + }
  1349. +
  1350. + /**
  1351. + * UnSpawns the DMEvent npc
  1352. + */
  1353. + private static void unSpawnNpc()
  1354. + {
  1355. + // Delete the npc
  1356. + _lastNpcSpawn.deleteMe();
  1357. + SpawnTable.getInstance().deleteSpawn(_lastNpcSpawn.getSpawn(), false);
  1358. + // Stop respawning of the npc
  1359. + _npcSpawn.stopRespawn();
  1360. + _npcSpawn = null;
  1361. + _lastNpcSpawn = null;
  1362. + }
  1363. +
  1364. + /**
  1365. + * Starts the participation of the DMEvent<br>
  1366. + * 1. Get L2NpcTemplate by Config.DM_EVENT_PARTICIPATION_NPC_ID<br>
  1367. + * 2. Try to spawn a new npc of it<br>
  1368. + * <br>
  1369. + * @return boolean: true if success, otherwise false<br>
  1370. + */
  1371. + public static boolean startParticipation()
  1372. + {
  1373. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.DM_EVENT_PARTICIPATION_NPC_ID);
  1374. +
  1375. + if (tmpl == null)
  1376. + {
  1377. + _log.warning("DMEventEngine[DMEvent.startParticipation()]: L2NpcTemplate is a NullPointer -> Invalid npc id in configs?");
  1378. + return false;
  1379. + }
  1380. +
  1381. + try
  1382. + {
  1383. + _npcSpawn = new L2Spawn(tmpl);
  1384. +
  1385. + _npcSpawn.setLocx(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[0]);
  1386. + _npcSpawn.setLocy(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[1]);
  1387. + _npcSpawn.setLocz(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
  1388. + _npcSpawn.setAmount(1);
  1389. + _npcSpawn.setHeading(Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[3]);
  1390. + _npcSpawn.setRespawnDelay(1);
  1391. + // later no need to delete spawn from db, we don't store it (false)
  1392. + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  1393. + _npcSpawn.init();
  1394. + _lastNpcSpawn = _npcSpawn.getLastSpawn();
  1395. + _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
  1396. + _lastNpcSpawn.setTitle("DM Event Participation");
  1397. + _lastNpcSpawn.isAggressive();
  1398. + _lastNpcSpawn.decayMe();
  1399. + _lastNpcSpawn.spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  1400. + _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1));
  1401. + }
  1402. + catch (Exception e)
  1403. + {
  1404. + _log.log(Level.WARNING, "DMEventEngine[DMEvent.startParticipation()]: exception: " + e.getMessage(), e);
  1405. + return false;
  1406. + }
  1407. +
  1408. + setState(EventState.PARTICIPATING);
  1409. + return true;
  1410. + }
  1411. +
  1412. + /**
  1413. + * Starts the DMEvent fight<br>
  1414. + * 1. Set state EventState.STARTING<br>
  1415. + * 2. Close doors specified in configs<br>
  1416. + * 3. Abort if not enought participants(return false)<br>
  1417. + * 4. Set state EventState.STARTED<br>
  1418. + * 5. Teleport all participants to team spot<br>
  1419. + * <br>
  1420. + * @return boolean: true if success, otherwise false<br>
  1421. + */
  1422. + public static boolean startFight()
  1423. + {
  1424. + // Set state to STARTING
  1425. + setState(EventState.STARTING);
  1426. +
  1427. + // Check the number of participants
  1428. + if (_DMEventPlayer.size() < Config.DM_EVENT_MIN_PLAYERS)
  1429. + {
  1430. + // Set state INACTIVE
  1431. + setState(EventState.INACTIVE);
  1432. +
  1433. + // Cleanup of participants
  1434. + _DMEventPlayer.clear();
  1435. +
  1436. + // Unspawn the event NPC
  1437. + unSpawnNpc();
  1438. + return false;
  1439. + }
  1440. +
  1441. + if (Config.DM_EVENT_IN_INSTANCE)
  1442. + {
  1443. + try
  1444. + {
  1445. + _DMEventInstance = InstanceManager.getInstance().createDynamicInstance(Config.DM_EVENT_INSTANCE_FILE);
  1446. + InstanceManager.getInstance().getInstance(_DMEventInstance).setAllowSummon(false);
  1447. + InstanceManager.getInstance().getInstance(_DMEventInstance).setPvPInstance(true);
  1448. + InstanceManager.getInstance().getInstance(_DMEventInstance).setEmptyDestroyTime((Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY * 1000) + 60000L);
  1449. + }
  1450. + catch (Exception e)
  1451. + {
  1452. + _DMEventInstance = 0;
  1453. + _log.log(Level.WARNING, "DMEventEngine[DMEvent.createDynamicInstance]: exception: " + e.getMessage(), e);
  1454. + }
  1455. + }
  1456. +
  1457. + // Opens all doors specified in configs for dm
  1458. + openDoors(Config.DM_DOORS_IDS_TO_OPEN);
  1459. + // Closes all doors specified in configs for dm
  1460. + closeDoors(Config.DM_DOORS_IDS_TO_CLOSE);
  1461. + // Set state STARTED
  1462. + setState(EventState.STARTED);
  1463. +
  1464. + for (DMEventPlayer player : _DMEventPlayer.values())
  1465. + {
  1466. + if (player != null)
  1467. + {
  1468. + // Teleporter implements Runnable and starts itself
  1469. + new DMEventTeleporter(player.getPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
  1470. + }
  1471. +
  1472. + }
  1473. +
  1474. + return true;
  1475. + }
  1476. +
  1477. + public static TreeSet<DMEventPlayer> orderPosition(Collection<DMEventPlayer> listPlayer)
  1478. + {
  1479. + TreeSet<DMEventPlayer> players = new TreeSet<DMEventPlayer>(new Comparator<DMEventPlayer>()
  1480. + {
  1481. + @Override
  1482. + public int compare(DMEventPlayer p1, DMEventPlayer p2)
  1483. + {
  1484. + Integer c1 = Integer.valueOf(p2.getPoints() - p1.getPoints());
  1485. + Integer c2 = Integer.valueOf(p1.getDeath() - p2.getDeath());
  1486. + Integer c3 = p1.getHexCode().compareTo(p2.getHexCode());
  1487. +
  1488. + if (c1 == 0)
  1489. + {
  1490. + if (c2 == 0)
  1491. + {
  1492. + return c3;
  1493. + }
  1494. + return c2;
  1495. + }
  1496. + return c1;
  1497. + }
  1498. + });
  1499. + players.addAll(listPlayer);
  1500. + return players;
  1501. + }
  1502. +
  1503. + /**
  1504. + * Calculates the DMEvent reward<br>
  1505. + * 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>
  1506. + * 2. Wait till teams are not at a tie anymore<br>
  1507. + * 3. Set state EvcentState.REWARDING<br>
  1508. + * 4. Reward team with more points<br>
  1509. + * 5. Show win html to wining team participants<br>
  1510. + * <br>
  1511. + * @return String: winning team name<br>
  1512. + */
  1513. + public static String calculateRewards()
  1514. + {
  1515. + TreeSet<DMEventPlayer> players = orderPosition(_DMEventPlayer.values());
  1516. +
  1517. + for (int j = 0; j < Config.DM_REWARD_FIRST_PLAYERS; j++)
  1518. + {
  1519. + if (players.isEmpty())
  1520. + {
  1521. + break;
  1522. + }
  1523. +
  1524. + DMEventPlayer player = players.first();
  1525. +
  1526. + if (player.getPoints() == 0)
  1527. + {
  1528. + break;
  1529. + }
  1530. + rewardPlayer(player, j + 1);
  1531. + players.remove(player);
  1532. + int playerPointPrev = player.getPoints();
  1533. +
  1534. + if (!Config.DM_REWARD_TEAM_TIE)
  1535. + {
  1536. + continue;
  1537. + }
  1538. +
  1539. + while (!players.isEmpty())
  1540. + {
  1541. + player = players.first();
  1542. + if (player.getPoints() != playerPointPrev)
  1543. + {
  1544. + break;
  1545. + }
  1546. + rewardPlayer(player, j + 1);
  1547. + players.remove(player);
  1548. + }
  1549. + }
  1550. +
  1551. + // Set state REWARDING so nobody can point anymore
  1552. + setState(EventState.REWARDING);
  1553. +
  1554. + return "DM Event ended, thanks to everyone who participated!";
  1555. + }
  1556. +
  1557. + private static void rewardPlayer(DMEventPlayer p, int pos)
  1558. + {
  1559. + L2PcInstance activeChar = p.getPlayer();
  1560. +
  1561. + // Check for nullpointer
  1562. + if (activeChar == null)
  1563. + {
  1564. + return;
  1565. + }
  1566. +
  1567. + SystemMessage systemMessage = null;
  1568. +
  1569. + List<int[]> rewards = Config.DM_EVENT_REWARDS;
  1570. +
  1571. + for (int[] reward : rewards)
  1572. + {
  1573. + PcInventory inv = activeChar.getInventory();
  1574. +
  1575. + // Check for stackable item, non stackabe items need to be added one by one
  1576. + if (ItemTable.getInstance().createDummyItem(reward[0]).isStackable())
  1577. + {
  1578. + inv.addItem("DM Event", reward[0], reward[1], activeChar, activeChar);
  1579. +
  1580. + if (reward[1] > 1)
  1581. + {
  1582. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
  1583. + systemMessage.addItemName(reward[0]);
  1584. + systemMessage.addItemNumber(reward[1]);
  1585. + }
  1586. + else
  1587. + {
  1588. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  1589. + systemMessage.addItemName(reward[0]);
  1590. + }
  1591. +
  1592. + activeChar.sendPacket(systemMessage);
  1593. + }
  1594. + else
  1595. + {
  1596. + for (int i = 0; i < reward[1]; ++i)
  1597. + {
  1598. + inv.addItem("DM Event", reward[0], 1, activeChar, activeChar);
  1599. + systemMessage = SystemMessage.getSystemMessage(SystemMessageId.EARNED_ITEM_S1);
  1600. + systemMessage.addItemName(reward[0]);
  1601. + activeChar.sendPacket(systemMessage);
  1602. + }
  1603. + }
  1604. + }
  1605. +
  1606. + StatusUpdate statusUpdate = new StatusUpdate(activeChar);
  1607. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1608. +
  1609. + statusUpdate.addAttribute(StatusUpdate.CUR_LOAD, activeChar.getCurrentLoad());
  1610. + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Reward.htm"));
  1611. + activeChar.sendPacket(statusUpdate);
  1612. + activeChar.sendPacket(npcHtmlMessage);
  1613. + }
  1614. +
  1615. + /**
  1616. + * Stops the DMEvent fight<br>
  1617. + * 1. Set state EventState.INACTIVATING<br>
  1618. + * 2. Remove DM npc from world<br>
  1619. + * 3. Open doors specified in configs<br>
  1620. + * 4. Send Top Rank<br>
  1621. + * 5. Teleport all participants back to participation npc location<br>
  1622. + * 6. List players cleaning<br>
  1623. + * 7. Set state EventState.INACTIVE<br>
  1624. + */
  1625. + public static void stopFight()
  1626. + {
  1627. + // Set state INACTIVATING
  1628. + setState(EventState.INACTIVATING);
  1629. + // Unspawn event npc
  1630. + unSpawnNpc();
  1631. + // Opens all doors specified in configs for DM
  1632. + openDoors(Config.DM_DOORS_IDS_TO_CLOSE);
  1633. + // Closes all doors specified in Configs for DM
  1634. + closeDoors(Config.DM_DOORS_IDS_TO_OPEN);
  1635. +
  1636. + String[] topPositions;
  1637. + String htmltext = "";
  1638. + if (Config.DM_EVENT_SHOW_TOP_RANK)
  1639. + {
  1640. + topPositions = getFirstPosition(Config.DM_EVENT_TOP_RANK);
  1641. + Boolean c = true;
  1642. + String c1 = "D9CC46";
  1643. + String c2 = "FFFFFF";
  1644. + if (topPositions != null)
  1645. + {
  1646. + for (int i = 0; i < topPositions.length; i++)
  1647. + {
  1648. + String color = (c ? c1 : c2);
  1649. + String[] row = topPositions[i].split("\\,");
  1650. + htmltext += "<tr>";
  1651. + htmltext += "<td width=\"35\" align=\"center\"><font color=\"" + color + "\">" + String.valueOf(i + 1) + "</font></td>";
  1652. + htmltext += "<td width=\"100\" align=\"left\"><font color=\"" + color + "\">" + row[0] + "</font></td>";
  1653. + htmltext += "<td width=\"125\" align=\"right\"><font color=\"" + color + "\">" + row[1] + "</font></td>";
  1654. + htmltext += "</tr>";
  1655. + c = !c;
  1656. + }
  1657. + }
  1658. + }
  1659. +
  1660. + for (DMEventPlayer player : _DMEventPlayer.values())
  1661. + {
  1662. + if (player != null)
  1663. + {
  1664. + // Top Rank
  1665. + if (Config.DM_EVENT_SHOW_TOP_RANK)
  1666. + {
  1667. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1668. + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(player.getPlayer().getHtmlPrefix(), htmlPath + "TopRank.htm"));
  1669. + npcHtmlMessage.replace("%toprank%", htmltext);
  1670. + player.getPlayer().sendPacket(npcHtmlMessage);
  1671. + }
  1672. + new DMEventTeleporter(player.getPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
  1673. + }
  1674. + }
  1675. +
  1676. + // Cleanup list
  1677. + _DMEventPlayer = new FastMap<Integer, DMEventPlayer>();
  1678. + // Set state INACTIVE
  1679. + setState(EventState.INACTIVE);
  1680. + }
  1681. +
  1682. + /**
  1683. + * Adds a player to a DMEvent<br>
  1684. + * @param activeChar as L2PcInstance<br>
  1685. + * @return boolean: true if success, otherwise false<br>
  1686. + */
  1687. + public static synchronized boolean addParticipant(L2PcInstance activeChar)
  1688. + {
  1689. + // Check for nullpoitner
  1690. + if (activeChar == null)
  1691. + {
  1692. + return false;
  1693. + }
  1694. +
  1695. + if (isPlayerParticipant(activeChar))
  1696. + {
  1697. + return false;
  1698. + }
  1699. +
  1700. + String hexCode = hexToString(generateHex(16));
  1701. + _DMEventPlayer.put(activeChar.getObjectId(), new DMEventPlayer(activeChar, hexCode));
  1702. + return true;
  1703. + }
  1704. +
  1705. + public static boolean isPlayerParticipant(L2PcInstance activeChar)
  1706. + {
  1707. + if (activeChar == null)
  1708. + {
  1709. + return false;
  1710. + }
  1711. + try
  1712. + {
  1713. + if (_DMEventPlayer.containsKey(activeChar.getObjectId()))
  1714. + {
  1715. + return true;
  1716. + }
  1717. + }
  1718. + catch (Exception e)
  1719. + {
  1720. + return false;
  1721. + }
  1722. + return false;
  1723. + }
  1724. +
  1725. + public static boolean isPlayerParticipant(int objectId)
  1726. + {
  1727. + L2PcInstance activeChar = L2World.getInstance().getPlayer(objectId);
  1728. + if (activeChar == null)
  1729. + {
  1730. + return false;
  1731. + }
  1732. + return isPlayerParticipant(activeChar);
  1733. + }
  1734. +
  1735. + /**
  1736. + * Removes a DMEvent player<br>
  1737. + * @param activeChar as L2PcInstance<br>
  1738. + * @return boolean: true if success, otherwise false<br>
  1739. + */
  1740. + public static boolean removeParticipant(L2PcInstance activeChar)
  1741. + {
  1742. + if (activeChar == null)
  1743. + {
  1744. + return false;
  1745. + }
  1746. +
  1747. + if (!isPlayerParticipant(activeChar))
  1748. + {
  1749. + return false;
  1750. + }
  1751. +
  1752. + try
  1753. + {
  1754. + _DMEventPlayer.remove(activeChar.getObjectId());
  1755. + }
  1756. + catch (Exception e)
  1757. + {
  1758. + return false;
  1759. + }
  1760. +
  1761. + return true;
  1762. + }
  1763. +
  1764. + public static boolean payParticipationFee(L2PcInstance activeChar)
  1765. + {
  1766. + int itemId = Config.DM_EVENT_PARTICIPATION_FEE[0];
  1767. + int itemNum = Config.DM_EVENT_PARTICIPATION_FEE[1];
  1768. + if ((itemId == 0) || (itemNum == 0))
  1769. + {
  1770. + return true;
  1771. + }
  1772. +
  1773. + if (activeChar.getInventory().getInventoryItemCount(itemId, -1) < itemNum)
  1774. + {
  1775. + return false;
  1776. + }
  1777. +
  1778. + return activeChar.destroyItemByItemId("DM Participation Fee", itemId, itemNum, _lastNpcSpawn, true);
  1779. + }
  1780. +
  1781. + public static String getParticipationFee()
  1782. + {
  1783. + int itemId = Config.DM_EVENT_PARTICIPATION_FEE[0];
  1784. + int itemNum = Config.DM_EVENT_PARTICIPATION_FEE[1];
  1785. +
  1786. + if ((itemId == 0) || (itemNum == 0))
  1787. + {
  1788. + return "-";
  1789. + }
  1790. +
  1791. + return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName());
  1792. + }
  1793. +
  1794. + /**
  1795. + * Send a SystemMessage to all participated players<br>
  1796. + * @param message as String<br>
  1797. + */
  1798. + public static void sysMsgToAllParticipants(String message)
  1799. + {
  1800. + for (DMEventPlayer player : _DMEventPlayer.values())
  1801. + {
  1802. + if (player != null)
  1803. + {
  1804. + player.getPlayer().sendMessage(message);
  1805. + }
  1806. + }
  1807. + }
  1808. +
  1809. + /**
  1810. + * Called when a player logs in<br>
  1811. + * <br>
  1812. + * @param activeChar as L2PcInstance<br>
  1813. + */
  1814. + public static void onLogin(L2PcInstance activeChar)
  1815. + {
  1816. + if ((activeChar == null) || (!isStarting() && !isStarted()))
  1817. + {
  1818. + return;
  1819. + }
  1820. +
  1821. + if (!isPlayerParticipant(activeChar))
  1822. + {
  1823. + return;
  1824. + }
  1825. +
  1826. + new DMEventTeleporter(activeChar.getActingPlayer(), Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
  1827. + }
  1828. +
  1829. + /**
  1830. + * Called when a player logs out<br>
  1831. + * <br>
  1832. + * @param activeChar as L2PcInstance<br>
  1833. + */
  1834. + public static void onLogout(L2PcInstance activeChar)
  1835. + {
  1836. + if ((activeChar != null) && (isStarting() || isStarted() || isParticipating()))
  1837. + {
  1838. + if (removeParticipant(activeChar))
  1839. + {
  1840. + activeChar.setXYZInvisible((Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[0] + Rnd.get(101)) - 50, (Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[1] + Rnd.get(101)) - 50, Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
  1841. + }
  1842. + }
  1843. + }
  1844. +
  1845. + /**
  1846. + * Called on every bypass by npc of type L2DMEventNpc<br>
  1847. + * Needs synchronization cause of the max player check<br>
  1848. + * <br>
  1849. + * @param command as String<br>
  1850. + * @param activeChar as L2PcInstance<br>
  1851. + */
  1852. + public static synchronized void onBypass(String command, L2PcInstance activeChar)
  1853. + {
  1854. + if ((activeChar == null) || !isParticipating())
  1855. + {
  1856. + return;
  1857. + }
  1858. +
  1859. + final String htmContent;
  1860. +
  1861. + if (command.equals("dm_event_participation"))
  1862. + {
  1863. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1864. + int playerLevel = activeChar.getLevel();
  1865. +
  1866. + if (activeChar.isCursedWeaponEquipped())
  1867. + {
  1868. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "CursedWeaponEquipped.htm");
  1869. + if (htmContent != null)
  1870. + {
  1871. + npcHtmlMessage.setHtml(htmContent);
  1872. + }
  1873. + }
  1874. + else if (activeChar.isInOlympiadMode())
  1875. + {
  1876. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Olympiad.htm");
  1877. + if (htmContent != null)
  1878. + {
  1879. + npcHtmlMessage.setHtml(htmContent);
  1880. + }
  1881. + }
  1882. + else if (activeChar.getKarma() > 0)
  1883. + {
  1884. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Karma.htm");
  1885. + if (htmContent != null)
  1886. + {
  1887. + npcHtmlMessage.setHtml(htmContent);
  1888. + }
  1889. + }
  1890. + else if ((playerLevel < Config.DM_EVENT_MIN_LVL) || (playerLevel > Config.DM_EVENT_MAX_LVL))
  1891. + {
  1892. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Level.htm");
  1893. + if (htmContent != null)
  1894. + {
  1895. + npcHtmlMessage.setHtml(htmContent);
  1896. + npcHtmlMessage.replace("%min%", String.valueOf(Config.DM_EVENT_MIN_LVL));
  1897. + npcHtmlMessage.replace("%max%", String.valueOf(Config.DM_EVENT_MAX_LVL));
  1898. + }
  1899. + }
  1900. + else if (_DMEventPlayer.size() == Config.DM_EVENT_MAX_PLAYERS)
  1901. + {
  1902. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Full.htm");
  1903. + if (htmContent != null)
  1904. + {
  1905. + npcHtmlMessage.setHtml(htmContent);
  1906. + npcHtmlMessage.replace("%max%", String.valueOf(Config.DM_EVENT_MAX_PLAYERS));
  1907. + }
  1908. + }
  1909. + else if ((Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.DM_ID, activeChar, Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP))
  1910. + {
  1911. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "IPRestriction.htm");
  1912. + if (htmContent != null)
  1913. + {
  1914. + npcHtmlMessage.setHtml(htmContent);
  1915. + npcHtmlMessage.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(activeChar, Config.DM_EVENT_MAX_PARTICIPANTS_PER_IP)));
  1916. + }
  1917. + }
  1918. + else if (!payParticipationFee(activeChar))
  1919. + {
  1920. + htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "ParticipationFee.htm");
  1921. + if (htmContent != null)
  1922. + {
  1923. + npcHtmlMessage.setHtml(htmContent);
  1924. + npcHtmlMessage.replace("%fee%", getParticipationFee());
  1925. + }
  1926. + }
  1927. + else if (isPlayerParticipant(activeChar))
  1928. + {
  1929. + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Registered.htm"));
  1930. + }
  1931. + else if (addParticipant(activeChar))
  1932. + {
  1933. + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Registered.htm"));
  1934. + }
  1935. + else
  1936. + {
  1937. + return;
  1938. + }
  1939. +
  1940. + activeChar.sendPacket(npcHtmlMessage);
  1941. + }
  1942. + else if (command.equals("dm_event_remove_participation"))
  1943. + {
  1944. + removeParticipant(activeChar);
  1945. + if (Config.TVT_EVENT_MAX_PARTICIPANTS_PER_IP > 0)
  1946. + {
  1947. + AntiFeedManager.getInstance().removePlayer(AntiFeedManager.DM_ID, activeChar);
  1948. + }
  1949. +
  1950. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(0);
  1951. +
  1952. + npcHtmlMessage.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPath + "Unregistered.htm"));
  1953. + activeChar.sendPacket(npcHtmlMessage);
  1954. + }
  1955. + }
  1956. +
  1957. + /**
  1958. + * Called on every onAction in L2PcIstance<br>
  1959. + * <br>
  1960. + * @param activeChar as L2PcInstance<br>
  1961. + * @param targetPlayerName as Integer<br>
  1962. + * @return boolean: true if player is allowed to target, otherwise false<br>
  1963. + */
  1964. + public static boolean onAction(L2PcInstance activeChar, int targetedPlayerObjectId)
  1965. + {
  1966. + if ((activeChar == null) || !isStarted())
  1967. + {
  1968. + return true;
  1969. + }
  1970. + if (activeChar.isGM())
  1971. + {
  1972. + return true;
  1973. + }
  1974. + if (!isPlayerParticipant(activeChar) && isPlayerParticipant(targetedPlayerObjectId))
  1975. + {
  1976. + return false;
  1977. + }
  1978. + if (isPlayerParticipant(activeChar) && !isPlayerParticipant(targetedPlayerObjectId))
  1979. + {
  1980. + return false;
  1981. + }
  1982. +
  1983. + return true;
  1984. + }
  1985. +
  1986. + /**
  1987. + * Called on every scroll use<br>
  1988. + * <br>
  1989. + * @param objectId as Integer<br>
  1990. + * @return boolean: true if player is allowed to use scroll, otherwise false<br>
  1991. + */
  1992. + public static boolean onScrollUse(int objectId)
  1993. + {
  1994. + if (!isStarted())
  1995. + {
  1996. + return true;
  1997. + }
  1998. +
  1999. + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_SCROLL_ALLOWED)
  2000. + {
  2001. + return false;
  2002. + }
  2003. +
  2004. + return true;
  2005. + }
  2006. +
  2007. + /**
  2008. + * Called on every potion use<br>
  2009. + * <br>
  2010. + * @param objectId as Integer<br>
  2011. + * @return boolean: true if player is allowed to use potions, otherwise false<br>
  2012. + */
  2013. + public static boolean onPotionUse(int objectId)
  2014. + {
  2015. + if (!isStarted())
  2016. + {
  2017. + return true;
  2018. + }
  2019. +
  2020. + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_POTIONS_ALLOWED)
  2021. + {
  2022. + return false;
  2023. + }
  2024. +
  2025. + return true;
  2026. + }
  2027. +
  2028. + /**
  2029. + * Called on every escape use<br>
  2030. + * <br>
  2031. + * @param objectId as Integer<br>
  2032. + * @return boolean: true if player is not in DM Event, otherwise false<br>
  2033. + */
  2034. + public static boolean onEscapeUse(int objectId)
  2035. + {
  2036. + if (!isStarted())
  2037. + {
  2038. + return true;
  2039. + }
  2040. +
  2041. + if (isPlayerParticipant(objectId))
  2042. + {
  2043. + return false;
  2044. + }
  2045. +
  2046. + return true;
  2047. + }
  2048. +
  2049. + /**
  2050. + * Called on every summon item use<br>
  2051. + * <br>
  2052. + * @param objectId as Integer<br>
  2053. + * @return boolean: true if player is allowed to summon by item, otherwise false<br>
  2054. + */
  2055. + public static boolean onItemSummon(int objectId)
  2056. + {
  2057. + if (!isStarted())
  2058. + {
  2059. + return true;
  2060. + }
  2061. +
  2062. + if (isPlayerParticipant(objectId) && !Config.DM_EVENT_SUMMON_BY_ITEM_ALLOWED)
  2063. + {
  2064. + return false;
  2065. + }
  2066. +
  2067. + return true;
  2068. + }
  2069. +
  2070. + /**
  2071. + * Is called when a player is killed<br>
  2072. + * <br>
  2073. + * @param killerCharacter as L2Character<br>
  2074. + * @param killedPlayerInstance as L2PcInstance<br>
  2075. + */
  2076. + public static void onKill(L2Character killerCharacter, L2PcInstance killedPlayerInstance)
  2077. + {
  2078. + if ((killedPlayerInstance == null) || !isStarted())
  2079. + {
  2080. + return;
  2081. + }
  2082. +
  2083. + if (!isPlayerParticipant(killedPlayerInstance.getObjectId()))
  2084. + {
  2085. + return;
  2086. + }
  2087. +
  2088. + new DMEventTeleporter(killedPlayerInstance, Config.DM_EVENT_PARTICIPATION_NPC_COORDINATES, false, false);
  2089. +
  2090. + if (killerCharacter == null)
  2091. + {
  2092. + return;
  2093. + }
  2094. +
  2095. + L2PcInstance killerPlayerInstance = null;
  2096. +
  2097. + if ((killerCharacter instanceof L2PetInstance) || (killerCharacter instanceof L2ServitorInstance))
  2098. + {
  2099. + killerPlayerInstance = ((L2Summon) killerCharacter).getOwner();
  2100. + if (killerPlayerInstance == null)
  2101. + {
  2102. + return;
  2103. + }
  2104. + }
  2105. + else if (killerCharacter instanceof L2PcInstance)
  2106. + {
  2107. + killerPlayerInstance = (L2PcInstance) killerCharacter;
  2108. + }
  2109. + else
  2110. + {
  2111. + return;
  2112. + }
  2113. +
  2114. + if (isPlayerParticipant(killerPlayerInstance))
  2115. + {
  2116. + _DMEventPlayer.get(killerPlayerInstance.getObjectId()).increasePoints();
  2117. + killerPlayerInstance.sendPacket(new CreatureSay(killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I have killed " + killedPlayerInstance.getName() + "!"));
  2118. +
  2119. + _DMEventPlayer.get(killedPlayerInstance.getObjectId()).increaseDeath();
  2120. + killedPlayerInstance.sendPacket(new CreatureSay(killerPlayerInstance.getObjectId(), Say2.TELL, killerPlayerInstance.getName(), "I killed you!"));
  2121. + }
  2122. + }
  2123. +
  2124. + /**
  2125. + * Called on Appearing packet received (player finished teleporting)<br>
  2126. + * <br>
  2127. + * @param L2PcInstance activeChar
  2128. + */
  2129. + public static void onTeleported(L2PcInstance activeChar)
  2130. + {
  2131. + if (!isStarted() || (activeChar == null) || !isPlayerParticipant(activeChar.getObjectId()))
  2132. + {
  2133. + return;
  2134. + }
  2135. +
  2136. + if (activeChar.isMageClass())
  2137. + {
  2138. + if ((Config.DM_EVENT_MAGE_BUFFS != null) && !Config.DM_EVENT_MAGE_BUFFS.isEmpty())
  2139. + {
  2140. + for (int i : Config.DM_EVENT_MAGE_BUFFS.keys())
  2141. + {
  2142. + L2Skill skill = SkillTable.getInstance().getInfo(i, Config.DM_EVENT_MAGE_BUFFS.get(i));
  2143. + if (skill != null)
  2144. + {
  2145. + skill.getEffects(activeChar, activeChar);
  2146. + }
  2147. + }
  2148. + }
  2149. + }
  2150. + else
  2151. + {
  2152. + if ((Config.DM_EVENT_FIGHTER_BUFFS != null) && !Config.DM_EVENT_FIGHTER_BUFFS.isEmpty())
  2153. + {
  2154. + for (int i : Config.DM_EVENT_FIGHTER_BUFFS.keys())
  2155. + {
  2156. + L2Skill skill = SkillTable.getInstance().getInfo(i, Config.DM_EVENT_FIGHTER_BUFFS.get(i));
  2157. + if (skill != null)
  2158. + {
  2159. + skill.getEffects(activeChar, activeChar);
  2160. + }
  2161. + }
  2162. + }
  2163. + }
  2164. +
  2165. + removeParty(activeChar);
  2166. + }
  2167. +
  2168. + /*
  2169. + * Return true if player valid for skill
  2170. + */
  2171. + public static final boolean checkForDMSkill(L2PcInstance source, L2PcInstance target, L2Skill skill)
  2172. + {
  2173. + if (!isStarted())
  2174. + {
  2175. + return true;
  2176. + }
  2177. +
  2178. + // DM is started
  2179. + final boolean isSourceParticipant = isPlayerParticipant(source);
  2180. + final boolean isTargetParticipant = isPlayerParticipant(target);
  2181. +
  2182. + // both players not participating
  2183. + if (!isSourceParticipant && !isTargetParticipant)
  2184. + {
  2185. + return true;
  2186. + }
  2187. + // one player not participating
  2188. + if (!(isSourceParticipant && isTargetParticipant))
  2189. + {
  2190. + return false;
  2191. + }
  2192. +
  2193. + return true;
  2194. + }
  2195. +
  2196. + public static int getPlayerCounts()
  2197. + {
  2198. + return _DMEventPlayer.size();
  2199. + }
  2200. +
  2201. + public static String[] getFirstPosition(int countPos)
  2202. + {
  2203. + TreeSet<DMEventPlayer> players = orderPosition(_DMEventPlayer.values());
  2204. + String text = "";
  2205. + for (int j = 0; j < countPos; j++)
  2206. + {
  2207. + if (players.isEmpty())
  2208. + {
  2209. + break;
  2210. + }
  2211. +
  2212. + DMEventPlayer player = players.first();
  2213. +
  2214. + if (player.getPoints() == 0)
  2215. + {
  2216. + break;
  2217. + }
  2218. +
  2219. + text += player.getPlayer().getName() + "," + String.valueOf(player.getPoints()) + ";";
  2220. + players.remove(player);
  2221. +
  2222. + int playerPointPrev = player.getPoints();
  2223. +
  2224. + if (!Config.DM_REWARD_TEAM_TIE)
  2225. + {
  2226. + continue;
  2227. + }
  2228. +
  2229. + while (!players.isEmpty())
  2230. + {
  2231. + player = players.first();
  2232. + if (player.getPoints() != playerPointPrev)
  2233. + {
  2234. + break;
  2235. + }
  2236. + text += player.getPlayer().getName() + "," + String.valueOf(player.getPoints()) + ";";
  2237. + players.remove(player);
  2238. + }
  2239. + }
  2240. +
  2241. + if (text != "")
  2242. + {
  2243. + return text.split("\\;");
  2244. + }
  2245. +
  2246. + return null;
  2247. + }
  2248. +
  2249. + /**
  2250. + * Returns the team id of a player, if player is not participant it returns -1<br>
  2251. + * <br>
  2252. + * @param playerName as String<br>
  2253. + * @return byte: team name of the given playerName, if not in event -1<br>
  2254. + */
  2255. + public static byte getParticipantTeamId(int playerObjectId)
  2256. + {
  2257. + return (byte) (_teams[0].containsPlayer(playerObjectId) ? 0 : -1);
  2258. + }
  2259. +
  2260. + public static void removeParty(L2PcInstance activeChar)
  2261. + {
  2262. + if (activeChar.getParty() != null)
  2263. + {
  2264. + L2Party party = activeChar.getParty();
  2265. + party.removePartyMember(activeChar);
  2266. + }
  2267. + }
  2268. +
  2269. + public static byte[] generateHex(int size)
  2270. + {
  2271. + byte[] array = new byte[size];
  2272. + Rnd.nextBytes(array);
  2273. + return array;
  2274. + }
  2275. +
  2276. + public static String hexToString(byte[] hex)
  2277. + {
  2278. + return new BigInteger(hex).toString(16);
  2279. + }
  2280. +
  2281. + public static int getDMEventInstance()
  2282. + {
  2283. + return _DMEventInstance;
  2284. + }
  2285. +
  2286. + /**
  2287. + * @return
  2288. + */
  2289. + public static int[] getTeamsPlayerCounts()
  2290. + {
  2291. + // TODO Auto-generated method stub
  2292. + return null;
  2293. + }
  2294. +
  2295. + /**
  2296. + * @return
  2297. + */
  2298. + public static int[] getTeamsPoints()
  2299. + {
  2300. + // TODO Auto-generated method stub
  2301. + return null;
  2302. + }
  2303. +
  2304. + /**
  2305. + * @param objectId
  2306. + */
  2307. + public static void removeParticipant(int objectId)
  2308. + {
  2309. + // TODO Auto-generated method stub
  2310. +
  2311. + }
  2312. +}
  2313. Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java
  2314. ===================================================================
  2315. --- java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (revision 65)
  2316. +++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
  2317. @@ -25,8 +25,10 @@
  2318. import com.l2jserver.gameserver.model.Location;
  2319. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  2320. import com.l2jserver.gameserver.model.actor.instance.L2SiegeFlagInstance;
  2321. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  2322. import com.l2jserver.gameserver.model.entity.Castle;
  2323. import com.l2jserver.gameserver.model.entity.ClanHall;
  2324. +import com.l2jserver.gameserver.model.entity.DMEvent;
  2325. import com.l2jserver.gameserver.model.entity.Fort;
  2326. import com.l2jserver.gameserver.model.entity.TvTEvent;
  2327. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  2328. @@ -75,6 +77,16 @@
  2329. return;
  2330. }
  2331.  
  2332. + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(activeChar.getObjectId()))
  2333. + {
  2334. + return;
  2335. + }
  2336. +
  2337. + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(activeChar.getObjectId()))
  2338. + {
  2339. + return;
  2340. + }
  2341. +
  2342. if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()))
  2343. {
  2344. return;
  2345. @@ -82,7 +94,7 @@
  2346.  
  2347. if (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(activeChar.getObjectId()))
  2348. {
  2349. - return;
  2350. + return;
  2351. }
  2352.  
  2353. if (activeChar.isFakeDeath())
  2354. @@ -142,9 +154,13 @@
  2355. return;
  2356. }
  2357. if (activeChar.isInTownWarEvent())
  2358. - loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.Town);
  2359. + {
  2360. + loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.Town);
  2361. + }
  2362. else
  2363. - loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
  2364. + {
  2365. + loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, MapRegionManager.TeleportWhereType.ClanHall);
  2366. + }
  2367.  
  2368. if ((ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()) != null) && (ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP) != null))
  2369. {
  2370. Index: java/com/l2jserver/gameserver/GameServer.java
  2371. ===================================================================
  2372. --- java/com/l2jserver/gameserver/GameServer.java (revision 65)
  2373. +++ java/com/l2jserver/gameserver/GameServer.java (working copy)
  2374. @@ -124,6 +124,8 @@
  2375. import com.l2jserver.gameserver.model.L2World;
  2376. import com.l2jserver.gameserver.model.PartyMatchRoomList;
  2377. import com.l2jserver.gameserver.model.PartyMatchWaitingList;
  2378. +import com.l2jserver.gameserver.model.entity.CTFManager;
  2379. +import com.l2jserver.gameserver.model.entity.DMManager;
  2380. import com.l2jserver.gameserver.model.entity.Hero;
  2381. import com.l2jserver.gameserver.model.entity.Hitman;
  2382. import com.l2jserver.gameserver.model.entity.TownWarManager;
  2383. @@ -143,7 +145,6 @@
  2384. import com.l2jserver.util.DeadLockDetector;
  2385. import com.l2jserver.util.IPv4Filter;
  2386.  
  2387. -
  2388. public class GameServer
  2389. {
  2390. private static final Logger _log = Logger.getLogger(GameServer.class.getName());
  2391. @@ -254,7 +255,7 @@
  2392. PetDataTable.getInstance();
  2393. CharSummonTable.getInstance().init();
  2394.  
  2395. - printSection("Clans");
  2396. + printSection("Clans");
  2397. ClanTable.getInstance();
  2398. CHSiegeManager.getInstance();
  2399. ClanHallManager.getInstance();
  2400. @@ -282,9 +283,11 @@
  2401. SpawnTable.getInstance();
  2402. ColosseumFencesTable.getInstance();
  2403. HellboundManager.getInstance();
  2404. -
  2405. +
  2406. if (Config.ENABLE_BONUS_MANAGER)
  2407. + {
  2408. BonusExpManager.getInstance();
  2409. + }
  2410.  
  2411. RaidBossSpawnManager.getInstance();
  2412. DayNightSpawnManager.getInstance().trim().notifyChangeMode();
  2413. @@ -347,7 +350,7 @@
  2414. if (Config.SAVE_DROPPED_ITEM)
  2415. {
  2416. ItemsOnGroundManager.getInstance();
  2417. -
  2418. +
  2419. }
  2420.  
  2421. if ((Config.AUTODESTROY_ITEM_AFTER > 0) || (Config.HERB_AUTO_DESTROY_TIME > 0))
  2422. @@ -372,21 +375,29 @@
  2423. {
  2424. CoupleManager.getInstance();
  2425. }
  2426. -
  2427. +
  2428. if (Config.RANK_ARENA_ENABLED)
  2429. + {
  2430. ArenaLeaderboard.getInstance();
  2431. + }
  2432.  
  2433. if (Config.RANK_FISHERMAN_ENABLED)
  2434. + {
  2435. FishermanLeaderboard.getInstance();
  2436. + }
  2437.  
  2438. if (Config.RANK_CRAFT_ENABLED)
  2439. + {
  2440. CraftLeaderboard.getInstance();
  2441. + }
  2442.  
  2443. if (Config.RANK_TVT_ENABLED)
  2444. + {
  2445. TvTLeaderboard.getInstance();
  2446. + }
  2447.  
  2448. TaskManager.getInstance();
  2449. -
  2450. +
  2451. AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID);
  2452. MerchantPriceConfigTable.getInstance().updateReferences();
  2453. CastleManager.getInstance().activateInstances();
  2454. @@ -406,6 +417,8 @@
  2455.  
  2456. _log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
  2457.  
  2458. + CTFManager.getInstance();
  2459. + DMManager.getInstance();
  2460. TvTManager.getInstance();
  2461. TvTRoundManager.getInstance();
  2462. TownWarManager.getInstance();
  2463. Index: java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java
  2464. ===================================================================
  2465. --- java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java (revision 0)
  2466. +++ java/com/l2jserver/gameserver/model/entity/CTFEventTeam.java (working copy)
  2467. @@ -0,0 +1,183 @@
  2468. +/*
  2469. + * This program is free software: you can redistribute it and/or modify it under
  2470. + * the terms of the GNU General Public License as published by the Free Software
  2471. + * Foundation, either version 3 of the License, or (at your option) any later
  2472. + * version.
  2473. + *
  2474. + * This program is distributed in the hope that it will be useful, but WITHOUT
  2475. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2476. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2477. + * details.
  2478. + *
  2479. + * You should have received a copy of the GNU General Public License along with
  2480. + * this program. If not, see <http://www.gnu.org/licenses/>.
  2481. + */
  2482. +
  2483. +package com.l2jserver.gameserver.model.entity;
  2484. +
  2485. +import java.util.Map;
  2486. +
  2487. +import javolution.util.FastMap;
  2488. +
  2489. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  2490. +
  2491. +/**
  2492. + * @author FBIagent, edited U3Games
  2493. + */
  2494. +
  2495. +public class CTFEventTeam
  2496. +{
  2497. + /** The name of the team<br> */
  2498. + private String _name;
  2499. + /** The team spot coordinated<br> */
  2500. + private int[] _coordinates = new int[3];
  2501. + /** The points of the team<br> */
  2502. + private short _points;
  2503. + /** Name and instance of all participated players in FastMap<br> */
  2504. + private Map<Integer, L2PcInstance> _participatedPlayers = new FastMap<Integer, L2PcInstance>();
  2505. +
  2506. + /**
  2507. + * C'tor initialize the team<br><br>
  2508. + *
  2509. + * @param name as String<br>
  2510. + * @param coordinates as int[]<br>
  2511. + */
  2512. + public CTFEventTeam(String name, int[] coordinates)
  2513. + {
  2514. + _name = name;
  2515. + _coordinates = coordinates;
  2516. + _points = 0;
  2517. + }
  2518. +
  2519. + /**
  2520. + * Adds a player to the team<br><br>
  2521. + *
  2522. + * @param playerInstance as L2PcInstance<br>
  2523. + * @return boolean: true if success, otherwise false<br>
  2524. + */
  2525. + public boolean addPlayer(L2PcInstance playerInstance)
  2526. + {
  2527. + if (playerInstance == null)
  2528. + {
  2529. + return false;
  2530. + }
  2531. +
  2532. + synchronized (_participatedPlayers)
  2533. + {
  2534. + _participatedPlayers.put(playerInstance.getObjectId(), playerInstance);
  2535. + }
  2536. +
  2537. + return true;
  2538. + }
  2539. +
  2540. + /**
  2541. + * Removes a player from the team
  2542. + * @param playerObjectId
  2543. + */
  2544. + public void removePlayer(int playerObjectId)
  2545. + {
  2546. + synchronized (_participatedPlayers)
  2547. + {
  2548. + _participatedPlayers.remove(playerObjectId);
  2549. + }
  2550. + }
  2551. +
  2552. + /**
  2553. + * Increases the points of the team<br>
  2554. + */
  2555. + public void increasePoints()
  2556. + {
  2557. + ++_points;
  2558. + }
  2559. +
  2560. + /**
  2561. + * Cleanup the team and make it ready for adding players again<br>
  2562. + */
  2563. + public void cleanMe()
  2564. + {
  2565. + _participatedPlayers.clear();
  2566. + _participatedPlayers = new FastMap<Integer, L2PcInstance>();
  2567. + _points = 0;
  2568. + }
  2569. +
  2570. + /**
  2571. + * Is given player in this team?
  2572. + * @param playerObjectId
  2573. + * @return boolean: true if player is in this team, otherwise false
  2574. + */
  2575. + public boolean containsPlayer(int playerObjectId)
  2576. + {
  2577. + boolean containsPlayer;
  2578. +
  2579. + synchronized (_participatedPlayers)
  2580. + {
  2581. + containsPlayer = _participatedPlayers.containsKey(playerObjectId);
  2582. + }
  2583. +
  2584. + return containsPlayer;
  2585. + }
  2586. +
  2587. + /**
  2588. + * Returns the name of the team<br><br>
  2589. + *
  2590. + * @return String: name of the team<br>
  2591. + */
  2592. + public String getName()
  2593. + {
  2594. + return _name;
  2595. + }
  2596. +
  2597. + /**
  2598. + * Returns the coordinates of the team spot<br><br>
  2599. + *
  2600. + * @return int[]: team coordinates<br>
  2601. + */
  2602. + public int[] getCoordinates()
  2603. + {
  2604. + return _coordinates;
  2605. + }
  2606. +
  2607. + /**
  2608. + * Returns the points of the team<br><br>
  2609. + *
  2610. + * @return short: team points<br>
  2611. + */
  2612. + public short getPoints()
  2613. + {
  2614. + return _points;
  2615. + }
  2616. +
  2617. + /**
  2618. + * Returns name and instance of all participated players in FastMap<br><br>
  2619. + *
  2620. + * @return Map<String, L2PcInstance>: map of players in this team<br>
  2621. + */
  2622. + public Map<Integer, L2PcInstance> getParticipatedPlayers()
  2623. + {
  2624. + Map<Integer, L2PcInstance> participatedPlayers = null;
  2625. +
  2626. + synchronized (_participatedPlayers)
  2627. + {
  2628. + participatedPlayers = _participatedPlayers;
  2629. + }
  2630. +
  2631. + return participatedPlayers;
  2632. + }
  2633. +
  2634. + /**
  2635. + * Returns player count of this team<br><br>
  2636. + *
  2637. + * @return int: number of players in team<br>
  2638. + */
  2639. + public int getParticipatedPlayerCount()
  2640. + {
  2641. + int participatedPlayerCount;
  2642. +
  2643. + synchronized (_participatedPlayers)
  2644. + {
  2645. + participatedPlayerCount = _participatedPlayers.size();
  2646. + }
  2647. +
  2648. + return participatedPlayerCount;
  2649. + }
  2650. +}
  2651. Index: java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java
  2652. ===================================================================
  2653. --- java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java (revision 65)
  2654. +++ java/com/l2jserver/gameserver/model/actor/instance/L2CastleMagicianInstance.java (working copy)
  2655. @@ -27,6 +27,8 @@
  2656. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  2657. import com.l2jserver.gameserver.model.base.AcquireSkillType;
  2658. import com.l2jserver.gameserver.model.effects.L2EffectType;
  2659. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  2660. +import com.l2jserver.gameserver.model.entity.DMEvent;
  2661. import com.l2jserver.gameserver.model.entity.TvTEvent;
  2662. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  2663. import com.l2jserver.gameserver.model.zone.ZoneId;
  2664. @@ -500,6 +502,31 @@
  2665. }
  2666. }
  2667.  
  2668. + if (!CTFEvent.onEscapeUse(player.getObjectId()))
  2669. + {
  2670. + player.sendMessage("You on CTF Event, teleporting disabled.");
  2671. + return false;
  2672. + }
  2673. +
  2674. + if (!CTFEvent.onEscapeUse(clanLeader.getObjectId()))
  2675. + {
  2676. + // Need retail message if there's one.
  2677. + player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
  2678. + return false;
  2679. + }
  2680. +
  2681. + if (!DMEvent.onEscapeUse(player.getObjectId()))
  2682. + {
  2683. + player.sendMessage("You on DM Event, teleporting disabled.");
  2684. + return false;
  2685. + }
  2686. +
  2687. + if (!DMEvent.onEscapeUse(clanLeader.getObjectId()))
  2688. + {
  2689. + // Need retail message if there's one.
  2690. + player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
  2691. + return false;
  2692. + }
  2693. if (!TvTEvent.onEscapeUse(player.getObjectId()))
  2694. {
  2695. player.sendMessage("You on TvT Event, teleporting disabled.");
  2696. @@ -512,7 +539,7 @@
  2697. player.sendMessage("Couldn't teleport to clan leader. The requirements was not meet.");
  2698. return false;
  2699. }
  2700. -
  2701. +
  2702. if (!TvTRoundEvent.onEscapeUse(player.getObjectId()))
  2703. {
  2704. player.sendMessage("You on TvT Round Event, teleporting disabled.");
  2705. Index: java/com/l2jserver/gameserver/network/L2GameClient.java
  2706. ===================================================================
  2707. --- java/com/l2jserver/gameserver/network/L2GameClient.java (revision 65)
  2708. +++ java/com/l2jserver/gameserver/network/L2GameClient.java (working copy)
  2709. @@ -45,8 +45,9 @@
  2710. import com.l2jserver.gameserver.model.L2Clan;
  2711. import com.l2jserver.gameserver.model.L2World;
  2712. import com.l2jserver.gameserver.model.PcCondOverride;
  2713. -import com.l2jserver.gameserver.model.actor.L2Character;
  2714. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  2715. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  2716. +import com.l2jserver.gameserver.model.entity.DMEvent;
  2717. import com.l2jserver.gameserver.model.entity.L2Event;
  2718. import com.l2jserver.gameserver.model.entity.TvTEvent;
  2719. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  2720. @@ -798,7 +799,7 @@
  2721. protected boolean offlineMode(L2PcInstance player)
  2722. {
  2723. boolean canSetShop = false;
  2724. - if (player.isInOlympiadMode() || player.isFestivalParticipant() || TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInJail() || (player.getVehicle() != null))
  2725. + if (player.isInOlympiadMode() || player.isFestivalParticipant() || TvTEvent.isPlayerParticipant(player.getObjectId()) || CTFEvent.isPlayerParticipant(player.getObjectId()) || DMEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInJail() || (player.getVehicle() != null))
  2726. {
  2727. return false;
  2728. }
  2729. Index: java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java
  2730. ===================================================================
  2731. --- java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (revision 65)
  2732. +++ java/com/l2jserver/gameserver/model/skills/l2skills/L2SkillTeleport.java (working copy)
  2733. @@ -25,6 +25,8 @@
  2734. import com.l2jserver.gameserver.model.StatsSet;
  2735. import com.l2jserver.gameserver.model.actor.L2Character;
  2736. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  2737. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  2738. +import com.l2jserver.gameserver.model.entity.DMEvent;
  2739. import com.l2jserver.gameserver.model.entity.TvTEvent;
  2740. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  2741. import com.l2jserver.gameserver.model.skills.L2Skill;
  2742. @@ -56,7 +58,7 @@
  2743.  
  2744. @Override
  2745. public void useSkill(L2Character activeChar, L2Object[] targets)
  2746. - {
  2747. + {
  2748. boolean bss = isMagic() && activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOTS);
  2749.  
  2750. if (activeChar.isPlayer())
  2751. @@ -67,7 +69,19 @@
  2752. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  2753. return;
  2754. }
  2755. -
  2756. +
  2757. + if (!CTFEvent.onEscapeUse(activeChar.getActingPlayer().getObjectId()))
  2758. + {
  2759. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  2760. + return;
  2761. + }
  2762. +
  2763. + if (!DMEvent.onEscapeUse(activeChar.getActingPlayer().getObjectId()))
  2764. + {
  2765. + activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  2766. + return;
  2767. + }
  2768. +
  2769. if (!TvTRoundEvent.onEscapeUse(((L2PcInstance) activeChar).getObjectId()))
  2770. {
  2771. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  2772. @@ -134,12 +148,22 @@
  2773. {
  2774. continue;
  2775. }
  2776. -
  2777. - if (!TvTRoundEvent.onEscapeUse(targetChar.getObjectId()))
  2778. +
  2779. + if (!CTFEvent.onEscapeUse(targetChar.getObjectId()))
  2780. {
  2781. continue;
  2782. }
  2783. -
  2784. +
  2785. + if (!DMEvent.onEscapeUse(targetChar.getObjectId()))
  2786. + {
  2787. + continue;
  2788. + }
  2789. +
  2790. + if (!TvTRoundEvent.onEscapeUse(targetChar.getObjectId()))
  2791. + {
  2792. + continue;
  2793. + }
  2794. +
  2795. if (targetChar.isInOlympiadMode())
  2796. {
  2797. continue;
  2798. Index: java/com/l2jserver/Config.java
  2799. ===================================================================
  2800. --- java/com/l2jserver/Config.java (revision 65)
  2801. +++ java/com/l2jserver/Config.java (working copy)
  2802. @@ -15,7 +15,6 @@
  2803. package com.l2jserver;
  2804.  
  2805. import info.tak11.subnet.Subnet;
  2806. -import gnu.trove.map.hash.TIntFloatHashMap;
  2807.  
  2808. import java.io.BufferedReader;
  2809. import java.io.File;
  2810. @@ -58,6 +57,9 @@
  2811. import com.l2jserver.util.L2Properties;
  2812. import com.l2jserver.util.StringUtil;
  2813.  
  2814. +import gnu.trove.map.hash.TIntFloatHashMap;
  2815. +import gnu.trove.map.hash.TIntIntHashMap;
  2816. +
  2817. /**
  2818. * This class loads all the game server related configurations from files.<br>
  2819. * The files are usually located in config folder in server root folder.<br>
  2820. @@ -117,8 +119,8 @@
  2821. public static String PKS_COLORS;
  2822. public static FastMap<Integer, Integer> PKS_COLORS_LIST;
  2823. public static boolean ANNOUNCE_CASTLE_LORDS;
  2824. - //balance
  2825. - public static float DAGGER_VS_HEAVY;
  2826. + // balance
  2827. + public static float DAGGER_VS_HEAVY;
  2828. public static float DAGGER_VS_LIGHT;
  2829. public static float DAGGER_VS_ROBE;
  2830. public static float ARCHER_VS_HEAVY;
  2831. @@ -139,9 +141,9 @@
  2832. public static float POLE_VS_HEAVY;
  2833. public static float POLE_VS_LIGHT;
  2834. public static float POLE_VS_ROBE;
  2835. - //--------------------------------------------------
  2836. + // --------------------------------------------------
  2837. // PC bang points
  2838. - //--------------------------------------------------
  2839. + // --------------------------------------------------
  2840. public static boolean PC_BANG_ENABLED;
  2841. public static int MAX_PC_BANG_POINTS;
  2842. public static boolean ENABLE_DOUBLE_PC_BANG_POINTS;
  2843. @@ -150,30 +152,30 @@
  2844. public static boolean RANDOM_PC_BANG_POINT;
  2845. public static boolean ENABLE_BONUS_MANAGER;
  2846. public static boolean Boost_EXP_COMMAND;
  2847. - //--------------------------------------------------
  2848. + // --------------------------------------------------
  2849. // Premium Settings
  2850. - //--------------------------------------------------
  2851. - public static boolean USE_PREMIUMSERVICE;
  2852. - public static boolean PREMIUM_INFO;
  2853. - public static float PREMIUM_RATE_XP;
  2854. - public static float PREMIUM_RATE_SP;
  2855. - public static float PREMIUM_RATE_DROP_ITEMS;
  2856. - public static float PREMIUM_RATE_DROP_ITEMS_BY_RAID;
  2857. - public static float PREMIUM_RATE_DROP_SPOIL;
  2858. - public static TIntFloatHashMap PREMIUM_RATE_DROP_ITEMS_ID;
  2859. + // --------------------------------------------------
  2860. + public static boolean USE_PREMIUMSERVICE;
  2861. + public static boolean PREMIUM_INFO;
  2862. + public static float PREMIUM_RATE_XP;
  2863. + public static float PREMIUM_RATE_SP;
  2864. + public static float PREMIUM_RATE_DROP_ITEMS;
  2865. + public static float PREMIUM_RATE_DROP_ITEMS_BY_RAID;
  2866. + public static float PREMIUM_RATE_DROP_SPOIL;
  2867. + public static TIntFloatHashMap PREMIUM_RATE_DROP_ITEMS_ID;
  2868. public static boolean ENABLE_BOTREPORT;
  2869. - public static boolean ALT_ALLOW_REFINE_PVP_ITEM;
  2870. + public static boolean ALT_ALLOW_REFINE_PVP_ITEM;
  2871. public static boolean HB_NEEDS_QUEST;
  2872. public static boolean PVP_MANAPOTION;
  2873. public static boolean ENABLE_UNSTUCK_PVP;
  2874. public static boolean USE_CR_ITEM;
  2875. - public static int CR_ITEM_MIN_CLAN_LVL;
  2876. - public static int CR_ITEM_REPS_TO_BE_AWARDED;
  2877. - public static int CR_ITEM_REPS_ITEM_ID;
  2878. - public static boolean NOBLE_CUSTOM_ITEMS;
  2879. - public static int NOOBLE_CUSTOM_ITEM_ID;
  2880. + public static int CR_ITEM_MIN_CLAN_LVL;
  2881. + public static int CR_ITEM_REPS_TO_BE_AWARDED;
  2882. + public static int CR_ITEM_REPS_ITEM_ID;
  2883. + public static boolean NOBLE_CUSTOM_ITEMS;
  2884. + public static int NOOBLE_CUSTOM_ITEM_ID;
  2885. public static int GAME_POINT_ITEM_ID;
  2886. - //Npc Buffer
  2887. + // Npc Buffer
  2888. public static boolean NpcBuffer_Reload;
  2889. public static boolean NpcBuffer_SmartWindow;
  2890. public static boolean NpcBuffer_VIP;
  2891. @@ -213,10 +215,10 @@
  2892. public static int TOPID;
  2893. public static boolean TOPDEBUG;
  2894. public static boolean CHAR_TITLE;
  2895. - public static String ADD_CHAR_TITLE;
  2896. + public static String ADD_CHAR_TITLE;
  2897. // ---------------------------------------------------
  2898. // Event Custom Config
  2899. - //----------------------------------------------------
  2900. + // ----------------------------------------------------
  2901. public static int TW_TOWN_ID;
  2902. public static String TW_TOWN_NAME;
  2903. public static boolean TW_ALL_TOWNS;
  2904. @@ -232,7 +234,7 @@
  2905. public static boolean TW_RESS_ON_DEATH;
  2906. public static boolean TW_RANDOM_SPAWN;
  2907. public static boolean TW_LOSE_BUFFS_ON_DEATH;
  2908. - //Tvt Round
  2909. + // Tvt Round
  2910. public static boolean TVT_ROUND_EVENT_ENABLED;
  2911. public static boolean TVT_ROUND_EVENT_IN_INSTANCE;
  2912. public static String TVT_ROUND_EVENT_INSTANCE_FILE;
  2913. @@ -276,17 +278,17 @@
  2914. public static boolean TVT_ROUND_ALLOW_VOICED_COMMAND;
  2915. public static boolean ALLOW_HITMAN_GDE;
  2916. public static boolean HITMAN_GDE_TAKE_KARMA;
  2917. - //Hide and Seek
  2918. - public static boolean ALT_HAS_ENABLE;
  2919. - public static int ALT_HAS_TIME_REG;
  2920. - public static int ALT_HAS_TIME_EVENT;
  2921. - public static int ALT_HAS_NPC;
  2922. - public static boolean ALT_HAS_PKJOIN;
  2923. - public static boolean ALT_HAS_SECUENTIAL;
  2924. - public static int ALT_HAS_MINLEVEL;
  2925. - public static int ALT_HAS_MAXLEVEL;
  2926. - public static int ALT_HAS_MINPLAYERS;
  2927. - public static int ALT_HAS_MAXPLAYERS;
  2928. + // Hide and Seek
  2929. + public static boolean ALT_HAS_ENABLE;
  2930. + public static int ALT_HAS_TIME_REG;
  2931. + public static int ALT_HAS_TIME_EVENT;
  2932. + public static int ALT_HAS_NPC;
  2933. + public static boolean ALT_HAS_PKJOIN;
  2934. + public static boolean ALT_HAS_SECUENTIAL;
  2935. + public static int ALT_HAS_MINLEVEL;
  2936. + public static int ALT_HAS_MAXLEVEL;
  2937. + public static int ALT_HAS_MINPLAYERS;
  2938. + public static int ALT_HAS_MAXPLAYERS;
  2939. public static boolean RANK_ARENA_ACCEPT_SAME_IP;
  2940. public static boolean RANK_ARENA_ENABLED;
  2941. public static int RANK_ARENA_INTERVAL;
  2942. @@ -304,6 +306,67 @@
  2943. public static int RANK_TVT_INTERVAL;
  2944. public static int RANK_TVT_REWARD_ID;
  2945. public static int RANK_TVT_REWARD_COUNT;
  2946. + public static boolean CTF_EVENT_ENABLED;
  2947. + public static boolean CTF_EVENT_IN_INSTANCE;
  2948. + public static String CTF_EVENT_INSTANCE_FILE;
  2949. + public static String[] CTF_EVENT_INTERVAL;
  2950. + public static int CTF_EVENT_PARTICIPATION_TIME;
  2951. + public static int CTF_EVENT_RUNNING_TIME;
  2952. + public static int CTF_EVENT_PARTICIPATION_NPC_ID;
  2953. + public static int[] CTF_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  2954. + public static int[] CTF_EVENT_PARTICIPATION_FEE = new int[2];
  2955. + public static int CTF_EVENT_MIN_PLAYERS_IN_TEAMS;
  2956. + public static int CTF_EVENT_MAX_PLAYERS_IN_TEAMS;
  2957. + public static int CTF_EVENT_RESPAWN_TELEPORT_DELAY;
  2958. + public static int CTF_EVENT_START_LEAVE_TELEPORT_DELAY;
  2959. + public static String CTF_EVENT_TEAM_1_NAME;
  2960. + public static int[] CTF_EVENT_TEAM_1_COORDINATES = new int[3];
  2961. + public static String CTF_EVENT_TEAM_2_NAME;
  2962. + public static int[] CTF_EVENT_TEAM_2_COORDINATES = new int[3];
  2963. + public static List<int[]> CTF_EVENT_REWARDS;
  2964. + public static boolean CTF_EVENT_TARGET_TEAM_MEMBERS_ALLOWED;
  2965. + public static boolean CTF_EVENT_SCROLL_ALLOWED;
  2966. + public static boolean CTF_EVENT_POTIONS_ALLOWED;
  2967. + public static boolean CTF_EVENT_SUMMON_BY_ITEM_ALLOWED;
  2968. + public static List<Integer> CTF_DOORS_IDS_TO_OPEN;
  2969. + public static List<Integer> CTF_DOORS_IDS_TO_CLOSE;
  2970. + public static boolean CTF_REWARD_TEAM_TIE;
  2971. + public static byte CTF_EVENT_MIN_LVL;
  2972. + public static byte CTF_EVENT_MAX_LVL;
  2973. + public static int CTF_EVENT_EFFECTS_REMOVAL;
  2974. + public static TIntIntHashMap CTF_EVENT_FIGHTER_BUFFS;
  2975. + public static TIntIntHashMap CTF_EVENT_MAGE_BUFFS;
  2976. + public static int CTF_EVENT_MAX_PARTICIPANTS_PER_IP;
  2977. + public static boolean CTF_ALLOW_VOICED_COMMAND;
  2978. + public static boolean DM_EVENT_ENABLED;
  2979. + public static boolean DM_EVENT_IN_INSTANCE;
  2980. + public static String DM_EVENT_INSTANCE_FILE;
  2981. + public static String[] DM_EVENT_INTERVAL;
  2982. + public static int DM_EVENT_PARTICIPATION_TIME;
  2983. + public static int DM_EVENT_RUNNING_TIME;
  2984. + public static int DM_EVENT_PARTICIPATION_NPC_ID;
  2985. + public static boolean DM_EVENT_SHOW_TOP_RANK;
  2986. + public static int DM_EVENT_TOP_RANK;
  2987. + public static int[] DM_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  2988. + public static int[] DM_EVENT_PARTICIPATION_FEE = new int[2];
  2989. + public static int DM_EVENT_MIN_PLAYERS;
  2990. + public static int DM_EVENT_MAX_PLAYERS;
  2991. + public static int DM_EVENT_RESPAWN_TELEPORT_DELAY;
  2992. + public static int DM_EVENT_START_LEAVE_TELEPORT_DELAY;
  2993. + public static List<int[]> DM_EVENT_REWARDS;
  2994. + public static boolean DM_EVENT_SCROLL_ALLOWED;
  2995. + public static boolean DM_EVENT_POTIONS_ALLOWED;
  2996. + public static boolean DM_EVENT_SUMMON_BY_ITEM_ALLOWED;
  2997. + public static List<Integer> DM_DOORS_IDS_TO_OPEN;
  2998. + public static List<Integer> DM_DOORS_IDS_TO_CLOSE;
  2999. + public static boolean DM_REWARD_TEAM_TIE;
  3000. + public static byte DM_EVENT_MIN_LVL;
  3001. + public static byte DM_EVENT_MAX_LVL;
  3002. + public static int DM_EVENT_EFFECTS_REMOVAL;
  3003. + public static TIntIntHashMap DM_EVENT_FIGHTER_BUFFS;
  3004. + public static TIntIntHashMap DM_EVENT_MAGE_BUFFS;
  3005. + public static int DM_EVENT_MAX_PARTICIPANTS_PER_IP;
  3006. + public static boolean DM_ALLOW_VOICED_COMMAND;
  3007. // --------------------------------------------------
  3008. // L2J Variable Definitions
  3009. // --------------------------------------------------
  3010. @@ -884,8 +947,8 @@
  3011. public static int L2JMOD_CHAMP_MAX_LVL;
  3012. public static int L2JMOD_CHAMPION_HP;
  3013. public static int L2JMOD_CHAMPION_REWARDS;
  3014. - public static int L2JMOD_CHAMPION_REWARDS_XP;
  3015. - public static int L2JMOD_CHAMPION_REWARDS_SP;
  3016. + public static int L2JMOD_CHAMPION_REWARDS_XP;
  3017. + public static int L2JMOD_CHAMPION_REWARDS_SP;
  3018. public static float L2JMOD_CHAMPION_ADENAS_REWARDS;
  3019. public static float L2JMOD_CHAMPION_HP_REGEN;
  3020. public static float L2JMOD_CHAMPION_ATK;
  3021. @@ -1272,11 +1335,11 @@
  3022. public static int ZAKEN_MAXMEMBERS_NIGHTTIME;
  3023. public static int FRINTEZZA_MAXPLAYERS;
  3024. public static int MIN_FREYA_PLAYERS;
  3025. - public static int MAX_FREYA_PLAYERS;
  3026. - public static int MIN_LEVEL_PLAYERS;
  3027. - public static int MIN_FREYA_HC_PLAYERS;
  3028. - public static int MAX_FREYA_HC_PLAYERS;
  3029. - public static int MIN_LEVEL_HC_PLAYERS;
  3030. + public static int MAX_FREYA_PLAYERS;
  3031. + public static int MIN_LEVEL_PLAYERS;
  3032. + public static int MIN_FREYA_HC_PLAYERS;
  3033. + public static int MAX_FREYA_HC_PLAYERS;
  3034. + public static int MIN_LEVEL_HC_PLAYERS;
  3035.  
  3036. // Gracia Seeds Settings
  3037.  
  3038. @@ -1652,428 +1715,681 @@
  3039. try (InputStream is = new FileInputStream(Avenger))
  3040. {
  3041. Avengers.load(is);
  3042. -
  3043. -
  3044. - BODY_ZA_MINUTU = Integer.parseInt(Avengers.getProperty("BodyZaMinutu", "20"));
  3045. - GUARD_ID = Integer.parseInt(Avengers.getProperty("GuardId", "36602"));
  3046. - CLAN_LEADER_COLOR_ENABLED = Boolean.parseBoolean(Avengers.getProperty("ClanLeaderNameColorEnabled", "False"));
  3047. - CLAN_LEADER_COLOR = Integer.decode((new StringBuilder()).append("0x").append(Avengers.getProperty("ClanLeaderColor", "00FFFF")).toString()).intValue();
  3048. - CLAN_LEADER_COLOR_CLAN_LEVEL = Integer.parseInt(Avengers.getProperty("ClanLeaderColorAtClanLevel", "1"));
  3049. - ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(Avengers.getProperty("AnnounceCastleLords", "false"));
  3050. - DAGGER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DaggerVsHeavy", "1.00"));
  3051. - DAGGER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DaggerVsLight", "1.00"));
  3052. - DAGGER_VS_ROBE = Float.parseFloat(Avengers.getProperty("DaggerVsRobe", "1.00"));
  3053. - ARCHER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("ArcherVsHeavy", "1.00"));
  3054. - ARCHER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("ArcherVsLight", "1.00"));
  3055. - ARCHER_VS_ROBE = Float.parseFloat(Avengers.getProperty("ArcherVsRobe", "1.00"));
  3056. - BLUNT_VS_HEAVY = Float.parseFloat(Avengers.getProperty("BluntVsHeavy", "1.00"));
  3057. - BLUNT_VS_LIGHT = Float.parseFloat(Avengers.getProperty("BluntVsLight", "1.00"));
  3058. - BLUNT_VS_ROBE = Float.parseFloat(Avengers.getProperty("BluntVsRobe", "1.00"));
  3059. - FIST_VS_HEAVY = Float.parseFloat(Avengers.getProperty("FistVsHeavy", "1.00"));
  3060. - FIST_VS_LIGHT = Float.parseFloat(Avengers.getProperty("FistVsLight", "1.00"));
  3061. - FIST_VS_ROBE = Float.parseFloat(Avengers.getProperty("FistVsRobe", "1.00"));
  3062. - DUAL_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DualVsHeavy", "1.00"));
  3063. - DUAL_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DualVsLight", "1.00"));
  3064. - DUAL_VS_ROBE = Float.parseFloat(Avengers.getProperty("DualVsRobe", "1.00"));
  3065. - SWORD_VS_HEAVY = Float.parseFloat(Avengers.getProperty("SwordVsHeavy", "1.00"));
  3066. - SWORD_VS_LIGHT = Float.parseFloat(Avengers.getProperty("SwordVsLight", "1.00"));
  3067. - SWORD_VS_ROBE = Float.parseFloat(Avengers.getProperty("SwordVsRobe", "1.00"));
  3068. - POLE_VS_HEAVY = Float.parseFloat(Avengers.getProperty("PoleVsHeavy", "1.00"));
  3069. - POLE_VS_LIGHT = Float.parseFloat(Avengers.getProperty("PoleVsLight", "1.00"));
  3070. - POLE_VS_ROBE = Float.parseFloat(Avengers.getProperty("PoleVsRobe", "1.00"));
  3071. - PC_BANG_ENABLED = Boolean.parseBoolean(Avengers.getProperty("Enabled", "false"));
  3072. - ENABLE_BOTREPORT = Boolean.valueOf(Avengers.getProperty("EnableBotReport", "false"));
  3073. - ALT_ALLOW_REFINE_PVP_ITEM = Boolean.parseBoolean(Avengers.getProperty("AltAllowRefinePVPItem", "False"));
  3074. - HB_NEEDS_QUEST = Boolean.parseBoolean(Avengers.getProperty("HBNeedsQuest", "True"));
  3075. - PVP_MANAPOTION = Boolean.parseBoolean(Avengers.getProperty("PvPManaPotion", "True"));
  3076. - ENABLE_UNSTUCK_PVP = Boolean.parseBoolean(Avengers.getProperty("EnableUnstuckPvP", "True"));
  3077. - USE_CR_ITEM = Boolean.parseBoolean(Avengers.getProperty("EnableTheClanRepPointsItem", "False"));
  3078. - CR_ITEM_MIN_CLAN_LVL = Integer.parseInt(Avengers.getProperty("MinClanLevelNeededForCR", "7"));
  3079. - CR_ITEM_REPS_TO_BE_AWARDED = Integer.parseInt(Avengers.getProperty("HowManyClanRepsToGive", "500"));
  3080. - CR_ITEM_REPS_ITEM_ID = Integer.parseInt(Avengers.getProperty("CRItemID", "6673"));
  3081. - NOBLE_CUSTOM_ITEMS = Boolean.parseBoolean(Avengers.getProperty("EnableNobleCustomItem", "true"));
  3082. - NOOBLE_CUSTOM_ITEM_ID = Integer.parseInt(Avengers.getProperty("NoobleCustomItemId", "6673"));
  3083. - GAME_POINT_ITEM_ID = Integer.parseInt(Avengers.getProperty("GamePointItemId", "-300"));
  3084. - NpcBuffer_Reload = Boolean.parseBoolean(Avengers.getProperty("EnableReloadScript", "False"));
  3085. - NpcBuffer_SmartWindow = Boolean.parseBoolean(Avengers.getProperty("EnableSmartWindow", "True"));
  3086. - NpcBuffer_VIP = Boolean.parseBoolean(Avengers.getProperty("EnableVIP", "False"));
  3087. - NpcBuffer_VIP_ALV= Integer.parseInt(Avengers.getProperty("VipAccesLevel", "1"));
  3088. - NpcBuffer_EnableBuff = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSection", "True"));
  3089. - NpcBuffer_EnableScheme = Boolean.parseBoolean(Avengers.getProperty("EnableScheme", "True"));
  3090. - NpcBuffer_EnableHeal = Boolean.parseBoolean(Avengers.getProperty("EnableHeal", "True"));
  3091. - NpcBuffer_EnableBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableBuffs", "True"));
  3092. - NpcBuffer_EnableResist = Boolean.parseBoolean(Avengers.getProperty("EnableResist", "True"));
  3093. - NpcBuffer_EnableSong = Boolean.parseBoolean(Avengers.getProperty("EnableSongs", "True"));
  3094. - NpcBuffer_EnableDance = Boolean.parseBoolean(Avengers.getProperty("EnableDances", "True"));
  3095. - NpcBuffer_EnableChant = Boolean.parseBoolean(Avengers.getProperty("EnableChants", "True"));
  3096. - NpcBuffer_EnableOther = Boolean.parseBoolean(Avengers.getProperty("EnableOther", "True"));
  3097. - NpcBuffer_EnableSpecial = Boolean.parseBoolean(Avengers.getProperty("EnableSpecial", "True"));
  3098. - NpcBuffer_EnableCubic = Boolean.parseBoolean(Avengers.getProperty("EnableCubic", "True"));
  3099. - NpcBuffer_EnableCancel = Boolean.parseBoolean(Avengers.getProperty("EnableRemoveBuffs", "True"));
  3100. - NpcBuffer_EnableBuffSet = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSet", "True"));
  3101. - NpcBuffer_EnableBuffPK = Boolean.parseBoolean(Avengers.getProperty("EnableBuffForPK", "False"));
  3102. - NpcBuffer_EnableFreeBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableFreeBuffs", "True"));
  3103. - NpcBuffer_EnableTimeOut = Boolean.parseBoolean(Avengers.getProperty("EnableTimeOut", "True"));
  3104. - NpcBuffer_TimeOutTime = Integer.parseInt(Avengers.getProperty("TimeoutTime", "10"));
  3105. - NpcBuffer_MinLevel = Integer.parseInt(Avengers.getProperty("MinimumLevel", "20"));
  3106. - NpcBuffer_PriceCancel = Integer.parseInt(Avengers.getProperty("RemoveBuffsPrice", "100000"));
  3107. - NpcBuffer_PriceHeal = Integer.parseInt(Avengers.getProperty("HealPrice", "100000"));
  3108. - NpcBuffer_PriceBuffs = Integer.parseInt(Avengers.getProperty("BuffsPrice", "100000"));
  3109. - NpcBuffer_PriceResist = Integer.parseInt(Avengers.getProperty("ResistPrice", "100000"));
  3110. - NpcBuffer_PriceSong = Integer.parseInt(Avengers.getProperty("SongPrice", "100000"));
  3111. - NpcBuffer_PriceDance = Integer.parseInt(Avengers.getProperty("DancePrice", "100000"));
  3112. - NpcBuffer_PriceChant = Integer.parseInt(Avengers.getProperty("ChantsPrice", "100000"));
  3113. - NpcBuffer_PriceOther = Integer.parseInt(Avengers.getProperty("OtherPrice", "100000"));
  3114. - NpcBuffer_PriceSpecial = Integer.parseInt(Avengers.getProperty("SpecialPrice", "100000"));
  3115. - NpcBuffer_PriceCubic = Integer.parseInt(Avengers.getProperty("CubicPrice", "100000"));
  3116. - NpcBuffer_PriceSet = Integer.parseInt(Avengers.getProperty("SetPrice", "10000000"));
  3117. - NpcBuffer_PriceScheme = Integer.parseInt(Avengers.getProperty("SchemePrice", "10000000"));
  3118. - NpcBuffer_MaxScheme = Integer.parseInt(Avengers.getProperty("MaxScheme", "4"));
  3119. - NpcBuffer_consumableID = Integer.parseInt(Avengers.getProperty("ConsumableID", "57"));
  3120. - TOPDEBUG = Boolean.parseBoolean(Avengers.getProperty("TopNpcDebug", "false"));
  3121. - CHAR_TITLE = Boolean.parseBoolean(Avengers.getProperty("CharTitle", "true"));
  3122. - ADD_CHAR_TITLE = Avengers.getProperty("CharAddTitle", "Flash");
  3123. - TOPID = Integer.parseInt(Avengers.getProperty("TopNpcID", "36602"));
  3124. - MAX_PC_BANG_POINTS = Integer.parseInt(Avengers.getProperty("MaxPcBangPoints", "200000"));
  3125. - if(MAX_PC_BANG_POINTS<0)
  3126. - MAX_PC_BANG_POINTS=0;
  3127. - ENABLE_DOUBLE_PC_BANG_POINTS = Boolean.parseBoolean(Avengers.getProperty("DoublingAcquisitionPoints", "false"));
  3128. - DOUBLE_PC_BANG_POINTS_CHANCE = Integer.parseInt(Avengers.getProperty("DoublingAcquisitionPointsChance", "1"));
  3129. - if(DOUBLE_PC_BANG_POINTS_CHANCE<0 || DOUBLE_PC_BANG_POINTS_CHANCE>100)
  3130. - DOUBLE_PC_BANG_POINTS_CHANCE=1;
  3131. - PC_BANG_POINT_RATE = Double.parseDouble(Avengers.getProperty("AcquisitionPointsRate", "1.0"));
  3132. - if(PC_BANG_POINT_RATE<0)
  3133. - PC_BANG_POINT_RATE=1;
  3134. - RANDOM_PC_BANG_POINT = Boolean.parseBoolean(Avengers.getProperty("AcquisitionPointsRandom", "false"));
  3135. - Boost_EXP_COMMAND = Boolean.parseBoolean(Avengers.getProperty("SpExpCommand", "False"));
  3136. - ENABLE_BONUS_MANAGER = Boolean.parseBoolean(Avengers.getProperty("EnableBonusManager", "False"));
  3137. - USE_PREMIUMSERVICE = Boolean.parseBoolean(Avengers.getProperty("EnablePremium", "false"));
  3138. - PREMIUM_INFO = Boolean.parseBoolean(Avengers.getProperty("PremiumInfo", "False"));
  3139. - PREMIUM_RATE_XP = Float.parseFloat(Avengers.getProperty("PremiumRateXp", "2."));
  3140. - PREMIUM_RATE_SP = Float.parseFloat(Avengers.getProperty("PremiumRateSp", "2."));
  3141. - PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(Avengers.getProperty("PremiumRateDropItems", "2."));
  3142. - PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(Avengers.getProperty("PremiumRateRaidDropItems", "2."));
  3143. - PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(Avengers.getProperty("PremiumRateDropSpoil", "2."));
  3144. -
  3145. - PVPS_COLORS = Avengers.getProperty("PvpsColors", "");
  3146. - PVPS_COLORS_LIST = new FastMap<Integer, Integer>();
  3147. -
  3148. - String[] splitted_pvps_colors = PVPS_COLORS.split(";");
  3149. -
  3150. - for(String iii:splitted_pvps_colors)
  3151. - {
  3152. - String[] pvps_colors = iii.split(",");
  3153. - if(pvps_colors.length != 2)
  3154. - {
  3155. - System.out.println("Invalid properties.");
  3156. - }
  3157. - else
  3158. - {
  3159. - PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
  3160. - }
  3161. - }
  3162. - PKS_COLORS = Avengers.getProperty("PksColors", "");
  3163. - PKS_COLORS_LIST = new FastMap<Integer, Integer>();
  3164. - String[] splitted_pks_colors = PKS_COLORS.split(";");
  3165. -
  3166. - for(String iii:splitted_pks_colors)
  3167. - {
  3168. - String[] pks_colors = iii.split(",");
  3169. - if(pks_colors.length != 2)
  3170. - {
  3171. - System.out.println("Invalid properties.");
  3172. - }
  3173. - else
  3174. - {
  3175. - PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
  3176. - }
  3177. - }
  3178.  
  3179. - String[] propertySplit = Avengers.getProperty("PremiumRateDropItemsById", "").split(";");
  3180. - PREMIUM_RATE_DROP_ITEMS_ID = new TIntFloatHashMap(propertySplit.length);
  3181. - if (!propertySplit[0].isEmpty())
  3182. - {
  3183. - for (String item : propertySplit)
  3184. - {
  3185. - String[] itemSplit = item.split(",");
  3186. - if (itemSplit.length != 2)
  3187. - _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
  3188. - else
  3189. - {
  3190. - try
  3191. - {
  3192. - PREMIUM_RATE_DROP_ITEMS_ID.put(Integer.parseInt(itemSplit[0]), Float.parseFloat(itemSplit[1]));
  3193. - }
  3194. - catch (NumberFormatException nfe)
  3195. - {
  3196. - if (!item.isEmpty())
  3197. - _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
  3198. - }
  3199. - }
  3200. - }
  3201. - }
  3202. - if (PREMIUM_RATE_DROP_ITEMS_ID.get(PcInventory.ADENA_ID) == 0f)
  3203. - {
  3204. - PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, PREMIUM_RATE_DROP_ITEMS); //for Adena rate if not defined
  3205. - }
  3206. - }
  3207. -
  3208. - catch (Exception e)
  3209. - {
  3210. - _log.log(Level.SEVERE, "Error while loading Avengers settings!", e);
  3211. - }
  3212. + BODY_ZA_MINUTU = Integer.parseInt(Avengers.getProperty("BodyZaMinutu", "20"));
  3213. + GUARD_ID = Integer.parseInt(Avengers.getProperty("GuardId", "36602"));
  3214. + CLAN_LEADER_COLOR_ENABLED = Boolean.parseBoolean(Avengers.getProperty("ClanLeaderNameColorEnabled", "False"));
  3215. + CLAN_LEADER_COLOR = Integer.decode((new StringBuilder()).append("0x").append(Avengers.getProperty("ClanLeaderColor", "00FFFF")).toString()).intValue();
  3216. + CLAN_LEADER_COLOR_CLAN_LEVEL = Integer.parseInt(Avengers.getProperty("ClanLeaderColorAtClanLevel", "1"));
  3217. + ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(Avengers.getProperty("AnnounceCastleLords", "false"));
  3218. + DAGGER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DaggerVsHeavy", "1.00"));
  3219. + DAGGER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DaggerVsLight", "1.00"));
  3220. + DAGGER_VS_ROBE = Float.parseFloat(Avengers.getProperty("DaggerVsRobe", "1.00"));
  3221. + ARCHER_VS_HEAVY = Float.parseFloat(Avengers.getProperty("ArcherVsHeavy", "1.00"));
  3222. + ARCHER_VS_LIGHT = Float.parseFloat(Avengers.getProperty("ArcherVsLight", "1.00"));
  3223. + ARCHER_VS_ROBE = Float.parseFloat(Avengers.getProperty("ArcherVsRobe", "1.00"));
  3224. + BLUNT_VS_HEAVY = Float.parseFloat(Avengers.getProperty("BluntVsHeavy", "1.00"));
  3225. + BLUNT_VS_LIGHT = Float.parseFloat(Avengers.getProperty("BluntVsLight", "1.00"));
  3226. + BLUNT_VS_ROBE = Float.parseFloat(Avengers.getProperty("BluntVsRobe", "1.00"));
  3227. + FIST_VS_HEAVY = Float.parseFloat(Avengers.getProperty("FistVsHeavy", "1.00"));
  3228. + FIST_VS_LIGHT = Float.parseFloat(Avengers.getProperty("FistVsLight", "1.00"));
  3229. + FIST_VS_ROBE = Float.parseFloat(Avengers.getProperty("FistVsRobe", "1.00"));
  3230. + DUAL_VS_HEAVY = Float.parseFloat(Avengers.getProperty("DualVsHeavy", "1.00"));
  3231. + DUAL_VS_LIGHT = Float.parseFloat(Avengers.getProperty("DualVsLight", "1.00"));
  3232. + DUAL_VS_ROBE = Float.parseFloat(Avengers.getProperty("DualVsRobe", "1.00"));
  3233. + SWORD_VS_HEAVY = Float.parseFloat(Avengers.getProperty("SwordVsHeavy", "1.00"));
  3234. + SWORD_VS_LIGHT = Float.parseFloat(Avengers.getProperty("SwordVsLight", "1.00"));
  3235. + SWORD_VS_ROBE = Float.parseFloat(Avengers.getProperty("SwordVsRobe", "1.00"));
  3236. + POLE_VS_HEAVY = Float.parseFloat(Avengers.getProperty("PoleVsHeavy", "1.00"));
  3237. + POLE_VS_LIGHT = Float.parseFloat(Avengers.getProperty("PoleVsLight", "1.00"));
  3238. + POLE_VS_ROBE = Float.parseFloat(Avengers.getProperty("PoleVsRobe", "1.00"));
  3239. + PC_BANG_ENABLED = Boolean.parseBoolean(Avengers.getProperty("Enabled", "false"));
  3240. + ENABLE_BOTREPORT = Boolean.valueOf(Avengers.getProperty("EnableBotReport", "false"));
  3241. + ALT_ALLOW_REFINE_PVP_ITEM = Boolean.parseBoolean(Avengers.getProperty("AltAllowRefinePVPItem", "False"));
  3242. + HB_NEEDS_QUEST = Boolean.parseBoolean(Avengers.getProperty("HBNeedsQuest", "True"));
  3243. + PVP_MANAPOTION = Boolean.parseBoolean(Avengers.getProperty("PvPManaPotion", "True"));
  3244. + ENABLE_UNSTUCK_PVP = Boolean.parseBoolean(Avengers.getProperty("EnableUnstuckPvP", "True"));
  3245. + USE_CR_ITEM = Boolean.parseBoolean(Avengers.getProperty("EnableTheClanRepPointsItem", "False"));
  3246. + CR_ITEM_MIN_CLAN_LVL = Integer.parseInt(Avengers.getProperty("MinClanLevelNeededForCR", "7"));
  3247. + CR_ITEM_REPS_TO_BE_AWARDED = Integer.parseInt(Avengers.getProperty("HowManyClanRepsToGive", "500"));
  3248. + CR_ITEM_REPS_ITEM_ID = Integer.parseInt(Avengers.getProperty("CRItemID", "6673"));
  3249. + NOBLE_CUSTOM_ITEMS = Boolean.parseBoolean(Avengers.getProperty("EnableNobleCustomItem", "true"));
  3250. + NOOBLE_CUSTOM_ITEM_ID = Integer.parseInt(Avengers.getProperty("NoobleCustomItemId", "6673"));
  3251. + GAME_POINT_ITEM_ID = Integer.parseInt(Avengers.getProperty("GamePointItemId", "-300"));
  3252. + NpcBuffer_Reload = Boolean.parseBoolean(Avengers.getProperty("EnableReloadScript", "False"));
  3253. + NpcBuffer_SmartWindow = Boolean.parseBoolean(Avengers.getProperty("EnableSmartWindow", "True"));
  3254. + NpcBuffer_VIP = Boolean.parseBoolean(Avengers.getProperty("EnableVIP", "False"));
  3255. + NpcBuffer_VIP_ALV = Integer.parseInt(Avengers.getProperty("VipAccesLevel", "1"));
  3256. + NpcBuffer_EnableBuff = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSection", "True"));
  3257. + NpcBuffer_EnableScheme = Boolean.parseBoolean(Avengers.getProperty("EnableScheme", "True"));
  3258. + NpcBuffer_EnableHeal = Boolean.parseBoolean(Avengers.getProperty("EnableHeal", "True"));
  3259. + NpcBuffer_EnableBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableBuffs", "True"));
  3260. + NpcBuffer_EnableResist = Boolean.parseBoolean(Avengers.getProperty("EnableResist", "True"));
  3261. + NpcBuffer_EnableSong = Boolean.parseBoolean(Avengers.getProperty("EnableSongs", "True"));
  3262. + NpcBuffer_EnableDance = Boolean.parseBoolean(Avengers.getProperty("EnableDances", "True"));
  3263. + NpcBuffer_EnableChant = Boolean.parseBoolean(Avengers.getProperty("EnableChants", "True"));
  3264. + NpcBuffer_EnableOther = Boolean.parseBoolean(Avengers.getProperty("EnableOther", "True"));
  3265. + NpcBuffer_EnableSpecial = Boolean.parseBoolean(Avengers.getProperty("EnableSpecial", "True"));
  3266. + NpcBuffer_EnableCubic = Boolean.parseBoolean(Avengers.getProperty("EnableCubic", "True"));
  3267. + NpcBuffer_EnableCancel = Boolean.parseBoolean(Avengers.getProperty("EnableRemoveBuffs", "True"));
  3268. + NpcBuffer_EnableBuffSet = Boolean.parseBoolean(Avengers.getProperty("EnableBuffSet", "True"));
  3269. + NpcBuffer_EnableBuffPK = Boolean.parseBoolean(Avengers.getProperty("EnableBuffForPK", "False"));
  3270. + NpcBuffer_EnableFreeBuffs = Boolean.parseBoolean(Avengers.getProperty("EnableFreeBuffs", "True"));
  3271. + NpcBuffer_EnableTimeOut = Boolean.parseBoolean(Avengers.getProperty("EnableTimeOut", "True"));
  3272. + NpcBuffer_TimeOutTime = Integer.parseInt(Avengers.getProperty("TimeoutTime", "10"));
  3273. + NpcBuffer_MinLevel = Integer.parseInt(Avengers.getProperty("MinimumLevel", "20"));
  3274. + NpcBuffer_PriceCancel = Integer.parseInt(Avengers.getProperty("RemoveBuffsPrice", "100000"));
  3275. + NpcBuffer_PriceHeal = Integer.parseInt(Avengers.getProperty("HealPrice", "100000"));
  3276. + NpcBuffer_PriceBuffs = Integer.parseInt(Avengers.getProperty("BuffsPrice", "100000"));
  3277. + NpcBuffer_PriceResist = Integer.parseInt(Avengers.getProperty("ResistPrice", "100000"));
  3278. + NpcBuffer_PriceSong = Integer.parseInt(Avengers.getProperty("SongPrice", "100000"));
  3279. + NpcBuffer_PriceDance = Integer.parseInt(Avengers.getProperty("DancePrice", "100000"));
  3280. + NpcBuffer_PriceChant = Integer.parseInt(Avengers.getProperty("ChantsPrice", "100000"));
  3281. + NpcBuffer_PriceOther = Integer.parseInt(Avengers.getProperty("OtherPrice", "100000"));
  3282. + NpcBuffer_PriceSpecial = Integer.parseInt(Avengers.getProperty("SpecialPrice", "100000"));
  3283. + NpcBuffer_PriceCubic = Integer.parseInt(Avengers.getProperty("CubicPrice", "100000"));
  3284. + NpcBuffer_PriceSet = Integer.parseInt(Avengers.getProperty("SetPrice", "10000000"));
  3285. + NpcBuffer_PriceScheme = Integer.parseInt(Avengers.getProperty("SchemePrice", "10000000"));
  3286. + NpcBuffer_MaxScheme = Integer.parseInt(Avengers.getProperty("MaxScheme", "4"));
  3287. + NpcBuffer_consumableID = Integer.parseInt(Avengers.getProperty("ConsumableID", "57"));
  3288. + TOPDEBUG = Boolean.parseBoolean(Avengers.getProperty("TopNpcDebug", "false"));
  3289. + CHAR_TITLE = Boolean.parseBoolean(Avengers.getProperty("CharTitle", "true"));
  3290. + ADD_CHAR_TITLE = Avengers.getProperty("CharAddTitle", "Flash");
  3291. + TOPID = Integer.parseInt(Avengers.getProperty("TopNpcID", "36602"));
  3292. + MAX_PC_BANG_POINTS = Integer.parseInt(Avengers.getProperty("MaxPcBangPoints", "200000"));
  3293. + if (MAX_PC_BANG_POINTS < 0)
  3294. + {
  3295. + MAX_PC_BANG_POINTS = 0;
  3296. + }
  3297. + ENABLE_DOUBLE_PC_BANG_POINTS = Boolean.parseBoolean(Avengers.getProperty("DoublingAcquisitionPoints", "false"));
  3298. + DOUBLE_PC_BANG_POINTS_CHANCE = Integer.parseInt(Avengers.getProperty("DoublingAcquisitionPointsChance", "1"));
  3299. + if ((DOUBLE_PC_BANG_POINTS_CHANCE < 0) || (DOUBLE_PC_BANG_POINTS_CHANCE > 100))
  3300. + {
  3301. + DOUBLE_PC_BANG_POINTS_CHANCE = 1;
  3302. + }
  3303. + PC_BANG_POINT_RATE = Double.parseDouble(Avengers.getProperty("AcquisitionPointsRate", "1.0"));
  3304. + if (PC_BANG_POINT_RATE < 0)
  3305. + {
  3306. + PC_BANG_POINT_RATE = 1;
  3307. + }
  3308. + RANDOM_PC_BANG_POINT = Boolean.parseBoolean(Avengers.getProperty("AcquisitionPointsRandom", "false"));
  3309. + Boost_EXP_COMMAND = Boolean.parseBoolean(Avengers.getProperty("SpExpCommand", "False"));
  3310. + ENABLE_BONUS_MANAGER = Boolean.parseBoolean(Avengers.getProperty("EnableBonusManager", "False"));
  3311. + USE_PREMIUMSERVICE = Boolean.parseBoolean(Avengers.getProperty("EnablePremium", "false"));
  3312. + PREMIUM_INFO = Boolean.parseBoolean(Avengers.getProperty("PremiumInfo", "False"));
  3313. + PREMIUM_RATE_XP = Float.parseFloat(Avengers.getProperty("PremiumRateXp", "2."));
  3314. + PREMIUM_RATE_SP = Float.parseFloat(Avengers.getProperty("PremiumRateSp", "2."));
  3315. + PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(Avengers.getProperty("PremiumRateDropItems", "2."));
  3316. + PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(Avengers.getProperty("PremiumRateRaidDropItems", "2."));
  3317. + PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(Avengers.getProperty("PremiumRateDropSpoil", "2."));
  3318.  
  3319. + PVPS_COLORS = Avengers.getProperty("PvpsColors", "");
  3320. + PVPS_COLORS_LIST = new FastMap<Integer, Integer>();
  3321.  
  3322. + String[] splitted_pvps_colors = PVPS_COLORS.split(";");
  3323. +
  3324. + for (String iii : splitted_pvps_colors)
  3325. + {
  3326. + String[] pvps_colors = iii.split(",");
  3327. + if (pvps_colors.length != 2)
  3328. + {
  3329. + System.out.println("Invalid properties.");
  3330. + }
  3331. + else
  3332. + {
  3333. + PVPS_COLORS_LIST.put(Integer.parseInt(pvps_colors[0]), Integer.decode("0x" + pvps_colors[1]));
  3334. + }
  3335. + }
  3336. + PKS_COLORS = Avengers.getProperty("PksColors", "");
  3337. + PKS_COLORS_LIST = new FastMap<Integer, Integer>();
  3338. + String[] splitted_pks_colors = PKS_COLORS.split(";");
  3339. +
  3340. + for (String iii : splitted_pks_colors)
  3341. + {
  3342. + String[] pks_colors = iii.split(",");
  3343. + if (pks_colors.length != 2)
  3344. + {
  3345. + System.out.println("Invalid properties.");
  3346. + }
  3347. + else
  3348. + {
  3349. + PKS_COLORS_LIST.put(Integer.parseInt(pks_colors[0]), Integer.decode("0x" + pks_colors[1]));
  3350. + }
  3351. + }
  3352. +
  3353. + String[] propertySplit = Avengers.getProperty("PremiumRateDropItemsById", "").split(";");
  3354. + PREMIUM_RATE_DROP_ITEMS_ID = new TIntFloatHashMap(propertySplit.length);
  3355. + if (!propertySplit[0].isEmpty())
  3356. + {
  3357. + for (String item : propertySplit)
  3358. + {
  3359. + String[] itemSplit = item.split(",");
  3360. + if (itemSplit.length != 2)
  3361. + {
  3362. + _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
  3363. + }
  3364. + else
  3365. + {
  3366. + try
  3367. + {
  3368. + PREMIUM_RATE_DROP_ITEMS_ID.put(Integer.parseInt(itemSplit[0]), Float.parseFloat(itemSplit[1]));
  3369. + }
  3370. + catch (NumberFormatException nfe)
  3371. + {
  3372. + if (!item.isEmpty())
  3373. + {
  3374. + _log.warning(StringUtil.concat("Config.load(): invalid config property -> PremiumRateDropItemsById \"", item, "\""));
  3375. + }
  3376. + }
  3377. + }
  3378. + }
  3379. + }
  3380. + if (PREMIUM_RATE_DROP_ITEMS_ID.get(PcInventory.ADENA_ID) == 0f)
  3381. + {
  3382. + PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, PREMIUM_RATE_DROP_ITEMS); // for Adena rate if not defined
  3383. + }
  3384. + }
  3385. +
  3386. + catch (Exception e)
  3387. + {
  3388. + _log.log(Level.SEVERE, "Error while loading Avengers settings!", e);
  3389. + }
  3390. +
  3391. // Event Custom Config
  3392. L2Properties Event = new L2Properties();
  3393. final File Events = new File(EVENT_FILE);
  3394. try (InputStream is = new FileInputStream(Events))
  3395. {
  3396. Event.load(is);
  3397. -
  3398. - TW_TOWN_ID = Integer.parseInt(Event.getProperty("TownWarTownId", "9"));
  3399. - TW_TOWN_NAME = Event.getProperty("TownWarTownName", "Giran Town");
  3400. - TW_ALL_TOWNS = Boolean.parseBoolean(Event.getProperty("TownWarAllTowns", "False"));
  3401. - TW_AUTO_EVENT = Boolean.parseBoolean(Event.getProperty("TownWarAutoEvent", "False"));
  3402. - TW_INTERVAL = Event.getProperty("TownWarInterval", "20:00").split(",");
  3403. - TW_TIME_BEFORE_START = Integer.parseInt(Event.getProperty("TownWarTimeBeforeStart", "5"));
  3404. - TW_RUNNING_TIME = Integer.parseInt(Event.getProperty("TownWarRunningTime", "10"));
  3405. - TW_ITEM_ID = Integer.parseInt(Event.getProperty("TownWarItemId", "57"));
  3406. - TW_ITEM_AMOUNT = Integer.parseInt(Event.getProperty("TownWarItemAmount", "5000"));
  3407. - TW_GIVE_PVP_AND_PK_POINTS = Boolean.parseBoolean(Event.getProperty("TownWarGivePvPAndPkPoints", "False"));
  3408. - TW_ALLOW_KARMA = Boolean.parseBoolean(Event.getProperty("TownWarAllowKarma", "False"));
  3409. - TW_DISABLE_GK = Boolean.parseBoolean(Event.getProperty("TownWarDisableGK", "False"));
  3410. - TW_RESS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarRessOnDeath", "True"));
  3411. - TW_RANDOM_SPAWN = Boolean.parseBoolean(Event.getProperty("TownWarRandomSpawn", "True"));
  3412. - TW_LOSE_BUFFS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarLoseBuffsOnDeath", "False"));
  3413. - ALLOW_HITMAN_GDE = Boolean.valueOf(Event.getProperty("AllowHitmanGDE", "true"));
  3414. - HITMAN_GDE_TAKE_KARMA = Boolean.valueOf(Event.getProperty("HitmansTakekarma", "false"));
  3415. - ALT_HAS_ENABLE = Boolean.parseBoolean(Event.getProperty("HaSEventEnabled", "false"));
  3416. - ALT_HAS_TIME_REG = Integer.parseInt(Event.getProperty("HaSEventParticipationTime", "5"));
  3417. - ALT_HAS_TIME_EVENT = Integer.parseInt(Event.getProperty("HaSEventRunningTime", "10"));
  3418. - ALT_HAS_NPC = Integer.parseInt(Event.getProperty("HaSEventParticipationNpcId", "90000"));
  3419. - ALT_HAS_PKJOIN = Boolean.parseBoolean(Event.getProperty("HaSEventCanPkJoin", "false"));
  3420. - ALT_HAS_SECUENTIAL = Boolean.parseBoolean(Event.getProperty("HaSEventSecuential", "false"));
  3421. - ALT_HAS_MINLEVEL = Integer.parseInt(Event.getProperty("HaSEventMinimumLevel", "1"));
  3422. - ALT_HAS_MAXLEVEL = Integer.parseInt(Event.getProperty("HaSEventMaximumLevel", "85"));
  3423. - ALT_HAS_MINPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMinimumPlayers", "2"));
  3424. - ALT_HAS_MAXPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMaximumPlayers", "20"));
  3425. - RANK_ARENA_ACCEPT_SAME_IP = Boolean.parseBoolean(Event.getProperty("ArenaAcceptSameIP", "true"));
  3426. - RANK_ARENA_ENABLED = Boolean.parseBoolean(Event.getProperty("RankArenaEnabled", "false"));
  3427. - RANK_ARENA_INTERVAL = Integer.parseInt(Event.getProperty("RankArenaInterval", "120"));
  3428. - RANK_ARENA_REWARD_ID = Integer.parseInt(Event.getProperty("RankArenaRewardId", "57"));
  3429. - RANK_ARENA_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankArenaRewardCount", "1000"));
  3430. - RANK_FISHERMAN_ENABLED = Boolean.parseBoolean(Event.getProperty("RankFishermanEnabled", "false"));
  3431. - RANK_FISHERMAN_INTERVAL = Integer.parseInt(Event.getProperty("RankFishermanInterval", "120"));
  3432. - RANK_FISHERMAN_REWARD_ID = Integer.parseInt(Event.getProperty("RankFishermanRewardId", "57"));
  3433. - RANK_FISHERMAN_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankFishermanRewardCount", "1000"));
  3434. - RANK_CRAFT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankCraftEnabled", "false"));
  3435. - RANK_CRAFT_INTERVAL = Integer.parseInt(Event.getProperty("RankCraftInterval", "120"));
  3436. - RANK_CRAFT_REWARD_ID = Integer.parseInt(Event.getProperty("RankCraftRewardId", "57"));
  3437. - RANK_CRAFT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankCraftRewardCount", "1000"));
  3438. - RANK_TVT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankTvTEnabled", "false"));
  3439. - RANK_TVT_INTERVAL = Integer.parseInt(Event.getProperty("RankTvTInterval", "120"));
  3440. - RANK_TVT_REWARD_ID = Integer.parseInt(Event.getProperty("RankTvTRewardId", "57"));
  3441. - RANK_TVT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankTvTRewardCount", "1000"));
  3442. - TVT_ROUND_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventEnabled", "false"));
  3443. - TVT_ROUND_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventInInstance", "false"));
  3444. - TVT_ROUND_EVENT_INSTANCE_FILE = Event.getProperty("TvTRoundEventInstanceFile", "coliseum.xml");
  3445. - TVT_ROUND_EVENT_INTERVAL = Event.getProperty("TvTRoundEventInterval", "20:00").split(",");
  3446. - TVT_ROUND_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationTime", "3600"));
  3447. - TVT_ROUND_EVENT_FIRST_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventFirstFightRunningTime", "1800"));
  3448. - TVT_ROUND_EVENT_SECOND_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventSecondFightRunningTime", "1800"));
  3449. - TVT_ROUND_EVENT_THIRD_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventThirdFightRunningTime", "1800"));
  3450. - TVT_ROUND_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationNpcId", "0"));
  3451. - TVT_ROUND_EVENT_ON_DIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventOnDie", "true"));
  3452. -
  3453. +
  3454. + TW_TOWN_ID = Integer.parseInt(Event.getProperty("TownWarTownId", "9"));
  3455. + TW_TOWN_NAME = Event.getProperty("TownWarTownName", "Giran Town");
  3456. + TW_ALL_TOWNS = Boolean.parseBoolean(Event.getProperty("TownWarAllTowns", "False"));
  3457. + TW_AUTO_EVENT = Boolean.parseBoolean(Event.getProperty("TownWarAutoEvent", "False"));
  3458. + TW_INTERVAL = Event.getProperty("TownWarInterval", "20:00").split(",");
  3459. + TW_TIME_BEFORE_START = Integer.parseInt(Event.getProperty("TownWarTimeBeforeStart", "5"));
  3460. + TW_RUNNING_TIME = Integer.parseInt(Event.getProperty("TownWarRunningTime", "10"));
  3461. + TW_ITEM_ID = Integer.parseInt(Event.getProperty("TownWarItemId", "57"));
  3462. + TW_ITEM_AMOUNT = Integer.parseInt(Event.getProperty("TownWarItemAmount", "5000"));
  3463. + TW_GIVE_PVP_AND_PK_POINTS = Boolean.parseBoolean(Event.getProperty("TownWarGivePvPAndPkPoints", "False"));
  3464. + TW_ALLOW_KARMA = Boolean.parseBoolean(Event.getProperty("TownWarAllowKarma", "False"));
  3465. + TW_DISABLE_GK = Boolean.parseBoolean(Event.getProperty("TownWarDisableGK", "False"));
  3466. + TW_RESS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarRessOnDeath", "True"));
  3467. + TW_RANDOM_SPAWN = Boolean.parseBoolean(Event.getProperty("TownWarRandomSpawn", "True"));
  3468. + TW_LOSE_BUFFS_ON_DEATH = Boolean.parseBoolean(Event.getProperty("TownWarLoseBuffsOnDeath", "False"));
  3469. + ALLOW_HITMAN_GDE = Boolean.valueOf(Event.getProperty("AllowHitmanGDE", "true"));
  3470. + HITMAN_GDE_TAKE_KARMA = Boolean.valueOf(Event.getProperty("HitmansTakekarma", "false"));
  3471. + ALT_HAS_ENABLE = Boolean.parseBoolean(Event.getProperty("HaSEventEnabled", "false"));
  3472. + ALT_HAS_TIME_REG = Integer.parseInt(Event.getProperty("HaSEventParticipationTime", "5"));
  3473. + ALT_HAS_TIME_EVENT = Integer.parseInt(Event.getProperty("HaSEventRunningTime", "10"));
  3474. + ALT_HAS_NPC = Integer.parseInt(Event.getProperty("HaSEventParticipationNpcId", "90000"));
  3475. + ALT_HAS_PKJOIN = Boolean.parseBoolean(Event.getProperty("HaSEventCanPkJoin", "false"));
  3476. + ALT_HAS_SECUENTIAL = Boolean.parseBoolean(Event.getProperty("HaSEventSecuential", "false"));
  3477. + ALT_HAS_MINLEVEL = Integer.parseInt(Event.getProperty("HaSEventMinimumLevel", "1"));
  3478. + ALT_HAS_MAXLEVEL = Integer.parseInt(Event.getProperty("HaSEventMaximumLevel", "85"));
  3479. + ALT_HAS_MINPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMinimumPlayers", "2"));
  3480. + ALT_HAS_MAXPLAYERS = Integer.parseInt(Event.getProperty("HaSEventMaximumPlayers", "20"));
  3481. + RANK_ARENA_ACCEPT_SAME_IP = Boolean.parseBoolean(Event.getProperty("ArenaAcceptSameIP", "true"));
  3482. + RANK_ARENA_ENABLED = Boolean.parseBoolean(Event.getProperty("RankArenaEnabled", "false"));
  3483. + RANK_ARENA_INTERVAL = Integer.parseInt(Event.getProperty("RankArenaInterval", "120"));
  3484. + RANK_ARENA_REWARD_ID = Integer.parseInt(Event.getProperty("RankArenaRewardId", "57"));
  3485. + RANK_ARENA_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankArenaRewardCount", "1000"));
  3486. + RANK_FISHERMAN_ENABLED = Boolean.parseBoolean(Event.getProperty("RankFishermanEnabled", "false"));
  3487. + RANK_FISHERMAN_INTERVAL = Integer.parseInt(Event.getProperty("RankFishermanInterval", "120"));
  3488. + RANK_FISHERMAN_REWARD_ID = Integer.parseInt(Event.getProperty("RankFishermanRewardId", "57"));
  3489. + RANK_FISHERMAN_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankFishermanRewardCount", "1000"));
  3490. + RANK_CRAFT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankCraftEnabled", "false"));
  3491. + RANK_CRAFT_INTERVAL = Integer.parseInt(Event.getProperty("RankCraftInterval", "120"));
  3492. + RANK_CRAFT_REWARD_ID = Integer.parseInt(Event.getProperty("RankCraftRewardId", "57"));
  3493. + RANK_CRAFT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankCraftRewardCount", "1000"));
  3494. + RANK_TVT_ENABLED = Boolean.parseBoolean(Event.getProperty("RankTvTEnabled", "false"));
  3495. + RANK_TVT_INTERVAL = Integer.parseInt(Event.getProperty("RankTvTInterval", "120"));
  3496. + RANK_TVT_REWARD_ID = Integer.parseInt(Event.getProperty("RankTvTRewardId", "57"));
  3497. + RANK_TVT_REWARD_COUNT = Integer.parseInt(Event.getProperty("RankTvTRewardCount", "1000"));
  3498. + CTF_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("CTFEventEnabled", "false"));
  3499. + CTF_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("CTFEventInInstance", "false"));
  3500. + CTF_EVENT_INSTANCE_FILE = Event.getProperty("CTFEventInstanceFile", "coliseum.xml");
  3501. + CTF_EVENT_INTERVAL = Event.getProperty("CTFEventInterval", "22:00").split(",");
  3502. + CTF_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("CTFEventParticipationTime", "3600"));
  3503. + CTF_EVENT_RUNNING_TIME = Integer.parseInt(Event.getProperty("CTFEventRunningTime", "1800"));
  3504. + CTF_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("CTFEventParticipationNpcId", "0"));
  3505. +
  3506. + DM_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("DMEventEnabled", "false"));
  3507. + DM_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("DMEventInInstance", "false"));
  3508. + DM_EVENT_INSTANCE_FILE = Event.getProperty("DMEventInstanceFile", "coliseum.xml");
  3509. + DM_EVENT_INTERVAL = Event.getProperty("DMEventInterval", "21:00").split(",");
  3510. + DM_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("DMEventParticipationTime", "3600"));
  3511. + DM_EVENT_RUNNING_TIME = Integer.parseInt(Event.getProperty("DMEventRunningTime", "1800"));
  3512. + DM_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("DMEventParticipationNpcId", "0"));
  3513. + DM_EVENT_SHOW_TOP_RANK = Boolean.parseBoolean(Event.getProperty("DMEventShowTopRank", "False"));
  3514. + DM_EVENT_TOP_RANK = Integer.parseInt(Event.getProperty("DMEventTopRank", "10"));
  3515. +
  3516. + TVT_ROUND_EVENT_ENABLED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventEnabled", "false"));
  3517. + TVT_ROUND_EVENT_IN_INSTANCE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventInInstance", "false"));
  3518. + TVT_ROUND_EVENT_INSTANCE_FILE = Event.getProperty("TvTRoundEventInstanceFile", "coliseum.xml");
  3519. + TVT_ROUND_EVENT_INTERVAL = Event.getProperty("TvTRoundEventInterval", "20:00").split(",");
  3520. + TVT_ROUND_EVENT_PARTICIPATION_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationTime", "3600"));
  3521. + TVT_ROUND_EVENT_FIRST_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventFirstFightRunningTime", "1800"));
  3522. + TVT_ROUND_EVENT_SECOND_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventSecondFightRunningTime", "1800"));
  3523. + TVT_ROUND_EVENT_THIRD_FIGHT_RUNNING_TIME = Integer.parseInt(Event.getProperty("TvTRoundEventThirdFightRunningTime", "1800"));
  3524. + TVT_ROUND_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(Event.getProperty("TvTRoundEventParticipationNpcId", "0"));
  3525. + TVT_ROUND_EVENT_ON_DIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventOnDie", "true"));
  3526. +
  3527. if (TVT_ROUND_EVENT_PARTICIPATION_NPC_ID == 0)
  3528. + {
  3529. + TVT_ROUND_EVENT_ENABLED = false;
  3530. + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcId");
  3531. + }
  3532. + else
  3533. + {
  3534. + String[] propertySplit = Event.getProperty("TvTRoundEventParticipationNpcCoordinates", "0,0,0").split(",");
  3535. + if (propertySplit.length < 3)
  3536. {
  3537. TVT_ROUND_EVENT_ENABLED = false;
  3538. - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcId");
  3539. + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcCoordinates");
  3540. }
  3541. else
  3542. {
  3543. - String[] propertySplit = Event.getProperty("TvTRoundEventParticipationNpcCoordinates", "0,0,0").split(",");
  3544. + TVT_ROUND_EVENT_REWARDS = new ArrayList<int[]>();
  3545. + TVT_ROUND_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
  3546. + TVT_ROUND_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
  3547. + TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE = new ArrayList<Integer>();
  3548. + TVT_ROUND_EVENT_WAIT_OPEN_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitOpenAnteroomDoors", "30"));
  3549. + TVT_ROUND_EVENT_WAIT_CLOSE_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitCloseAnteroomDoors", "15"));
  3550. + TVT_ROUND_EVENT_STOP_ON_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventStopOnTie", "false"));
  3551. + TVT_ROUND_EVENT_MINIMUM_TIE = Integer.parseInt(Event.getProperty("TvTRoundEventMinimumTie", "1"));
  3552. + if ((TVT_ROUND_EVENT_MINIMUM_TIE != 1) && (TVT_ROUND_EVENT_MINIMUM_TIE != 2) && (TVT_ROUND_EVENT_MINIMUM_TIE != 3))
  3553. + {
  3554. + TVT_ROUND_EVENT_MINIMUM_TIE = 1;
  3555. + }
  3556. + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  3557. + TVT_ROUND_EVENT_TEAM_1_COORDINATES = new int[3];
  3558. + TVT_ROUND_EVENT_TEAM_2_COORDINATES = new int[3];
  3559. + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3560. + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3561. + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3562. + if (propertySplit.length == 4)
  3563. + {
  3564. + TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
  3565. + }
  3566. + TVT_ROUND_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayersInTeams", "1"));
  3567. + TVT_ROUND_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayersInTeams", "20"));
  3568. + TVT_ROUND_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayerLevel", "1"));
  3569. + TVT_ROUND_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayerLevel", "80"));
  3570. + TVT_ROUND_EVENT_START_RESPAWN_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("TvTRoundEventStartRespawnLeaveTeleportDelay", "10"));
  3571. + TVT_ROUND_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("TvTRoundEventEffectsRemoval", "0"));
  3572. + TVT_ROUND_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("TvTRoundEventMaxParticipantsPerIP", "0"));
  3573. + TVT_ROUND_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("TvTRoundAllowVoicedInfoCommand", "false"));
  3574. + TVT_ROUND_EVENT_TEAM_1_NAME = Event.getProperty("TvTRoundEventTeam1Name", "Team1");
  3575. + propertySplit = Event.getProperty("TvTRoundEventTeam1Coordinates", "0,0,0").split(",");
  3576. if (propertySplit.length < 3)
  3577. {
  3578. TVT_ROUND_EVENT_ENABLED = false;
  3579. - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationNpcCoordinates");
  3580. + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam1Coordinates");
  3581. }
  3582. else
  3583. {
  3584. - TVT_ROUND_EVENT_REWARDS = new ArrayList<int[]>();
  3585. - TVT_ROUND_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
  3586. - TVT_ROUND_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
  3587. - TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE = new ArrayList<Integer>();
  3588. - TVT_ROUND_EVENT_WAIT_OPEN_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitOpenAnteroomDoors", "30"));
  3589. - TVT_ROUND_EVENT_WAIT_CLOSE_ANTEROOM_DOORS = Integer.parseInt(Event.getProperty("TvTRoundEventWaitCloseAnteroomDoors", "15"));
  3590. - TVT_ROUND_EVENT_STOP_ON_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundEventStopOnTie", "false"));
  3591. - TVT_ROUND_EVENT_MINIMUM_TIE = Integer.parseInt(Event.getProperty("TvTRoundEventMinimumTie", "1"));
  3592. - if (TVT_ROUND_EVENT_MINIMUM_TIE != 1 && TVT_ROUND_EVENT_MINIMUM_TIE != 2 && TVT_ROUND_EVENT_MINIMUM_TIE != 3) TVT_ROUND_EVENT_MINIMUM_TIE = 1;
  3593. - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  3594. - TVT_ROUND_EVENT_TEAM_1_COORDINATES = new int[3];
  3595. - TVT_ROUND_EVENT_TEAM_2_COORDINATES = new int[3];
  3596. - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3597. - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3598. - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3599. - if (propertySplit.length == 4)
  3600. - TVT_ROUND_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
  3601. - TVT_ROUND_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayersInTeams", "1"));
  3602. - TVT_ROUND_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayersInTeams", "20"));
  3603. - TVT_ROUND_EVENT_MIN_LVL = (byte)Integer.parseInt(Event.getProperty("TvTRoundEventMinPlayerLevel", "1"));
  3604. - TVT_ROUND_EVENT_MAX_LVL = (byte)Integer.parseInt(Event.getProperty("TvTRoundEventMaxPlayerLevel", "80"));
  3605. - TVT_ROUND_EVENT_START_RESPAWN_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("TvTRoundEventStartRespawnLeaveTeleportDelay", "10"));
  3606. - TVT_ROUND_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("TvTRoundEventEffectsRemoval", "0"));
  3607. - TVT_ROUND_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("TvTRoundEventMaxParticipantsPerIP", "0"));
  3608. - TVT_ROUND_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("TvTRoundAllowVoicedInfoCommand", "false"));
  3609. - TVT_ROUND_EVENT_TEAM_1_NAME = Event.getProperty("TvTRoundEventTeam1Name", "Team1");
  3610. - propertySplit = Event.getProperty("TvTRoundEventTeam1Coordinates", "0,0,0").split(",");
  3611. + TVT_ROUND_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3612. + TVT_ROUND_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3613. + TVT_ROUND_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3614. + TVT_ROUND_EVENT_TEAM_2_NAME = Event.getProperty("TvTRoundEventTeam2Name", "Team2");
  3615. + propertySplit = Event.getProperty("TvTRoundEventTeam2Coordinates", "0,0,0").split(",");
  3616. if (propertySplit.length < 3)
  3617. {
  3618. TVT_ROUND_EVENT_ENABLED = false;
  3619. - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam1Coordinates");
  3620. + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam2Coordinates");
  3621. }
  3622. else
  3623. {
  3624. - TVT_ROUND_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3625. - TVT_ROUND_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3626. - TVT_ROUND_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3627. - TVT_ROUND_EVENT_TEAM_2_NAME = Event.getProperty("TvTRoundEventTeam2Name", "Team2");
  3628. - propertySplit = Event.getProperty("TvTRoundEventTeam2Coordinates", "0,0,0").split(",");
  3629. - if (propertySplit.length < 3)
  3630. + TVT_ROUND_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3631. + TVT_ROUND_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3632. + TVT_ROUND_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3633. + propertySplit = Event.getProperty("TvTRoundEventParticipationFee", "0,0").split(",");
  3634. + try
  3635. {
  3636. - TVT_ROUND_EVENT_ENABLED= false;
  3637. - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventTeam2Coordinates");
  3638. + TVT_ROUND_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
  3639. + TVT_ROUND_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
  3640. }
  3641. - else
  3642. + catch (NumberFormatException nfe)
  3643. {
  3644. - TVT_ROUND_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3645. - TVT_ROUND_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3646. - TVT_ROUND_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3647. - propertySplit = Event.getProperty("TvTRoundEventParticipationFee", "0,0").split(",");
  3648. + if (propertySplit.length > 0)
  3649. + {
  3650. + _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationFee");
  3651. + }
  3652. + }
  3653. + propertySplit = Event.getProperty("TvTRoundEventReward", "57,100000").split(";");
  3654. + for (String reward : propertySplit)
  3655. + {
  3656. + String[] rewardSplit = reward.split(",");
  3657. + if (rewardSplit.length != 2)
  3658. + {
  3659. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
  3660. + }
  3661. + else
  3662. + {
  3663. + try
  3664. + {
  3665. + TVT_ROUND_EVENT_REWARDS.add(new int[]
  3666. + {
  3667. + Integer.parseInt(rewardSplit[0]),
  3668. + Integer.parseInt(rewardSplit[1])
  3669. + });
  3670. + }
  3671. + catch (NumberFormatException nfe)
  3672. + {
  3673. + if (!reward.isEmpty())
  3674. + {
  3675. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
  3676. + }
  3677. + }
  3678. + }
  3679. + }
  3680. +
  3681. + TVT_ROUND_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventTargetTeamMembersAllowed", "true"));
  3682. + TVT_ROUND_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventScrollsAllowed", "false"));
  3683. + TVT_ROUND_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventPotionsAllowed", "false"));
  3684. + TVT_ROUND_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventSummonByItemAllowed", "false"));
  3685. + TVT_ROUND_GIVE_POINT_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundGivePointTeamTie", "false"));
  3686. + TVT_ROUND_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundRewardTeamTie", "false"));
  3687. + TVT_ROUND_EVENT_REWARD_ON_SECOND_FIGHT_END = Boolean.parseBoolean(Event.getProperty("TvTRoundEventRewardOnSecondFightEnd", "false"));
  3688. + propertySplit = Event.getProperty("TvTRoundDoorsToOpen", "").split(";");
  3689. + for (String door : propertySplit)
  3690. + {
  3691. try
  3692. {
  3693. - TVT_ROUND_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
  3694. - TVT_ROUND_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
  3695. + TVT_ROUND_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  3696. }
  3697. catch (NumberFormatException nfe)
  3698. {
  3699. - if (propertySplit.length > 0)
  3700. - _log.warning("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventParticipationFee");
  3701. + if (!door.isEmpty())
  3702. + {
  3703. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToOpen \"", door, "\""));
  3704. + }
  3705. }
  3706. - propertySplit = Event.getProperty("TvTRoundEventReward", "57,100000").split(";");
  3707. - for (String reward : propertySplit)
  3708. + }
  3709. +
  3710. + propertySplit = Event.getProperty("TvTRoundDoorsToClose", "").split(";");
  3711. + for (String door : propertySplit)
  3712. + {
  3713. + try
  3714. {
  3715. - String[] rewardSplit = reward.split(",");
  3716. - if (rewardSplit.length != 2)
  3717. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
  3718. + TVT_ROUND_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  3719. + }
  3720. + catch (NumberFormatException nfe)
  3721. + {
  3722. + if (!door.isEmpty())
  3723. + {
  3724. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToClose \"", door, "\""));
  3725. + }
  3726. + }
  3727. + }
  3728. +
  3729. + propertySplit = Event.getProperty("TvTRoundAnteroomDoorsToOpenClose", "").split(";");
  3730. + for (String door : propertySplit)
  3731. + {
  3732. + try
  3733. + {
  3734. + TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE.add(Integer.parseInt(door));
  3735. + }
  3736. + catch (NumberFormatException nfe)
  3737. + {
  3738. + if (!door.isEmpty())
  3739. + {
  3740. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundAnteroomDoorsToOpenClose \"", door, "\""));
  3741. + }
  3742. + }
  3743. + }
  3744. +
  3745. + propertySplit = Event.getProperty("TvTRoundEventFighterBuffs", "").split(";");
  3746. + if (!propertySplit[0].isEmpty())
  3747. + {
  3748. + TVT_ROUND_EVENT_FIGHTER_BUFFS = new HashMap<>(propertySplit.length);
  3749. + for (String skill : propertySplit)
  3750. + {
  3751. + String[] skillSplit = skill.split(",");
  3752. + if (skillSplit.length != 2)
  3753. + {
  3754. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
  3755. + }
  3756. else
  3757. {
  3758. try
  3759. {
  3760. - TVT_ROUND_EVENT_REWARDS.add(new int[]{Integer.parseInt(rewardSplit[0]), Integer.parseInt(rewardSplit[1])});
  3761. + TVT_ROUND_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  3762. }
  3763. catch (NumberFormatException nfe)
  3764. {
  3765. - if (!reward.isEmpty())
  3766. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventReward \"", reward, "\""));
  3767. + if (!skill.isEmpty())
  3768. + {
  3769. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
  3770. + }
  3771. }
  3772. }
  3773. }
  3774. -
  3775. - TVT_ROUND_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventTargetTeamMembersAllowed", "true"));
  3776. - TVT_ROUND_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventScrollsAllowed", "false"));
  3777. - TVT_ROUND_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventPotionsAllowed", "false"));
  3778. - TVT_ROUND_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("TvTRoundEventSummonByItemAllowed", "false"));
  3779. - TVT_ROUND_GIVE_POINT_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundGivePointTeamTie", "false"));
  3780. - TVT_ROUND_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("TvTRoundRewardTeamTie", "false"));
  3781. - TVT_ROUND_EVENT_REWARD_ON_SECOND_FIGHT_END = Boolean.parseBoolean(Event.getProperty("TvTRoundEventRewardOnSecondFightEnd", "false"));
  3782. - propertySplit = Event.getProperty("TvTRoundDoorsToOpen", "").split(";");
  3783. - for (String door : propertySplit)
  3784. + }
  3785. +
  3786. + propertySplit = Event.getProperty("TvTRoundEventMageBuffs", "").split(";");
  3787. + if (!propertySplit[0].isEmpty())
  3788. + {
  3789. + TVT_ROUND_EVENT_MAGE_BUFFS = new HashMap<>(propertySplit.length);
  3790. + for (String skill : propertySplit)
  3791. {
  3792. - try
  3793. + String[] skillSplit = skill.split(",");
  3794. + if (skillSplit.length != 2)
  3795. {
  3796. - TVT_ROUND_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  3797. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
  3798. }
  3799. - catch (NumberFormatException nfe)
  3800. + else
  3801. {
  3802. - if (!door.isEmpty())
  3803. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToOpen \"", door, "\""));
  3804. + try
  3805. + {
  3806. + TVT_ROUND_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  3807. + }
  3808. + catch (NumberFormatException nfe)
  3809. + {
  3810. + if (!skill.isEmpty())
  3811. + {
  3812. + _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
  3813. + }
  3814. + }
  3815. }
  3816. }
  3817. -
  3818. - propertySplit = Event.getProperty("TvTRoundDoorsToClose", "").split(";");
  3819. - for (String door : propertySplit)
  3820. + }
  3821. + }
  3822. + }
  3823. + }
  3824. + }
  3825. +
  3826. + if (CTF_EVENT_PARTICIPATION_NPC_ID == 0)
  3827. + {
  3828. + CTF_EVENT_ENABLED = false;
  3829. + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationNpcId");
  3830. + }
  3831. + else
  3832. + {
  3833. + String[] propertySplit = Event.getProperty("CTFEventParticipationNpcCoordinates", "0,0,0").split(",");
  3834. + if (propertySplit.length < 3)
  3835. + {
  3836. + CTF_EVENT_ENABLED = false;
  3837. + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationNpcCoordinates");
  3838. + }
  3839. + else
  3840. + {
  3841. + CTF_EVENT_REWARDS = new ArrayList<int[]>();
  3842. + CTF_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
  3843. + CTF_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
  3844. + CTF_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  3845. + CTF_EVENT_TEAM_1_COORDINATES = new int[3];
  3846. + CTF_EVENT_TEAM_2_COORDINATES = new int[3];
  3847. + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3848. + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3849. + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3850. + if (propertySplit.length == 4)
  3851. + {
  3852. + CTF_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
  3853. + }
  3854. + CTF_EVENT_MIN_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("CTFEventMinPlayersInTeams", "1"));
  3855. + CTF_EVENT_MAX_PLAYERS_IN_TEAMS = Integer.parseInt(Event.getProperty("CTFEventMaxPlayersInTeams", "20"));
  3856. + CTF_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("CTFEventMinPlayerLevel", "1"));
  3857. + CTF_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("CTFEventMaxPlayerLevel", "80"));
  3858. + CTF_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("CTFEventRespawnTeleportDelay", "20"));
  3859. + CTF_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("CTFEventStartLeaveTeleportDelay", "20"));
  3860. + CTF_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("CTFEventEffectsRemoval", "0"));
  3861. + CTF_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("CTFEventMaxParticipantsPerIP", "0"));
  3862. + CTF_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("CTFAllowVoicedInfoCommand", "false"));
  3863. + CTF_EVENT_TEAM_1_NAME = Event.getProperty("CTFEventTeam1Name", "Team1");
  3864. + propertySplit = Event.getProperty("CTFEventTeam1Coordinates", "0,0,0").split(",");
  3865. + if (propertySplit.length < 3)
  3866. + {
  3867. + CTF_EVENT_ENABLED = false;
  3868. + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventTeam1Coordinates");
  3869. + }
  3870. + else
  3871. + {
  3872. + CTF_EVENT_TEAM_1_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3873. + CTF_EVENT_TEAM_1_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3874. + CTF_EVENT_TEAM_1_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3875. + CTF_EVENT_TEAM_2_NAME = Event.getProperty("CTFEventTeam2Name", "Team2");
  3876. + propertySplit = Event.getProperty("CTFEventTeam2Coordinates", "0,0,0").split(",");
  3877. + if (propertySplit.length < 3)
  3878. + {
  3879. + CTF_EVENT_ENABLED = false;
  3880. + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventTeam2Coordinates");
  3881. + }
  3882. + else
  3883. + {
  3884. + CTF_EVENT_TEAM_2_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  3885. + CTF_EVENT_TEAM_2_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  3886. + CTF_EVENT_TEAM_2_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  3887. + propertySplit = Event.getProperty("CTFEventParticipationFee", "0,0").split(",");
  3888. + try
  3889. + {
  3890. + CTF_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
  3891. + CTF_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
  3892. + }
  3893. + catch (NumberFormatException nfe)
  3894. + {
  3895. + if (propertySplit.length > 0)
  3896. {
  3897. + _log.warning("CTFEventEngine[Config.load()]: invalid config property -> CTFEventParticipationFee");
  3898. + }
  3899. + }
  3900. + propertySplit = Event.getProperty("CTFEventReward", "57,100000").split(";");
  3901. + for (String reward : propertySplit)
  3902. + {
  3903. + String[] rewardSplit = reward.split(",");
  3904. + if (rewardSplit.length != 2)
  3905. + {
  3906. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventReward \"", reward, "\""));
  3907. + }
  3908. + else
  3909. + {
  3910. try
  3911. {
  3912. - TVT_ROUND_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  3913. + CTF_EVENT_REWARDS.add(new int[]
  3914. + {
  3915. + Integer.parseInt(rewardSplit[0]),
  3916. + Integer.parseInt(rewardSplit[1])
  3917. + });
  3918. }
  3919. catch (NumberFormatException nfe)
  3920. {
  3921. - if (!door.isEmpty())
  3922. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundDoorsToClose \"", door, "\""));
  3923. + if (!reward.isEmpty())
  3924. + {
  3925. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventReward \"", reward, "\""));
  3926. + }
  3927. }
  3928. }
  3929. -
  3930. - propertySplit = Event.getProperty("TvTRoundAnteroomDoorsToOpenClose", "").split(";");
  3931. - for (String door : propertySplit)
  3932. + }
  3933. +
  3934. + CTF_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventTargetTeamMembersAllowed", "true"));
  3935. + CTF_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventScrollsAllowed", "false"));
  3936. + CTF_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventPotionsAllowed", "false"));
  3937. + CTF_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("CTFEventSummonByItemAllowed", "false"));
  3938. + CTF_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("CTFRewardTeamTie", "false"));
  3939. + propertySplit = Event.getProperty("CTFDoorsToOpen", "").split(";");
  3940. + for (String door : propertySplit)
  3941. + {
  3942. + try
  3943. {
  3944. - try
  3945. + CTF_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  3946. + }
  3947. + catch (NumberFormatException nfe)
  3948. + {
  3949. + if (!door.isEmpty())
  3950. {
  3951. - TVT_ROUND_ANTEROOM_DOORS_IDS_TO_OPEN_CLOSE.add(Integer.parseInt(door));
  3952. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFDoorsToOpen \"", door, "\""));
  3953. }
  3954. - catch (NumberFormatException nfe)
  3955. + }
  3956. + }
  3957. +
  3958. + propertySplit = Event.getProperty("CTFDoorsToClose", "").split(";");
  3959. + for (String door : propertySplit)
  3960. + {
  3961. + try
  3962. + {
  3963. + CTF_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  3964. + }
  3965. + catch (NumberFormatException nfe)
  3966. + {
  3967. + if (!door.isEmpty())
  3968. {
  3969. - if (!door.isEmpty())
  3970. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundAnteroomDoorsToOpenClose \"", door, "\""));
  3971. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFDoorsToClose \"", door, "\""));
  3972. }
  3973. }
  3974. -
  3975. - propertySplit = Event.getProperty("TvTRoundEventFighterBuffs", "").split(";");
  3976. - if (!propertySplit[0].isEmpty())
  3977. + }
  3978. +
  3979. + propertySplit = Event.getProperty("CTFEventFighterBuffs", "").split(";");
  3980. + if (!propertySplit[0].isEmpty())
  3981. + {
  3982. + CTF_EVENT_FIGHTER_BUFFS = new TIntIntHashMap(propertySplit.length);
  3983. + for (String skill : propertySplit)
  3984. {
  3985. - TVT_ROUND_EVENT_FIGHTER_BUFFS = new HashMap<>(propertySplit.length);
  3986. - for (String skill : propertySplit)
  3987. + String[] skillSplit = skill.split(",");
  3988. + if (skillSplit.length != 2)
  3989. {
  3990. - String[] skillSplit = skill.split(",");
  3991. - if (skillSplit.length != 2)
  3992. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
  3993. - else
  3994. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventFighterBuffs \"", skill, "\""));
  3995. + }
  3996. + else
  3997. + {
  3998. + try
  3999. {
  4000. - try
  4001. + CTF_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4002. + }
  4003. + catch (NumberFormatException nfe)
  4004. + {
  4005. + if (!skill.isEmpty())
  4006. {
  4007. - TVT_ROUND_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4008. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventFighterBuffs \"", skill, "\""));
  4009. }
  4010. - catch (NumberFormatException nfe)
  4011. - {
  4012. - if (!skill.isEmpty())
  4013. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventFighterBuffs \"", skill, "\""));
  4014. - }
  4015. }
  4016. }
  4017. }
  4018. -
  4019. - propertySplit = Event.getProperty("TvTRoundEventMageBuffs", "").split(";");
  4020. - if (!propertySplit[0].isEmpty())
  4021. + }
  4022. +
  4023. + propertySplit = Event.getProperty("CTFEventMageBuffs", "").split(";");
  4024. + if (!propertySplit[0].isEmpty())
  4025. + {
  4026. + CTF_EVENT_MAGE_BUFFS = new TIntIntHashMap(propertySplit.length);
  4027. + for (String skill : propertySplit)
  4028. {
  4029. - TVT_ROUND_EVENT_MAGE_BUFFS = new HashMap<>(propertySplit.length);
  4030. - for (String skill : propertySplit)
  4031. + String[] skillSplit = skill.split(",");
  4032. + if (skillSplit.length != 2)
  4033. {
  4034. - String[] skillSplit = skill.split(",");
  4035. - if (skillSplit.length != 2)
  4036. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
  4037. - else
  4038. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventMageBuffs \"", skill, "\""));
  4039. + }
  4040. + else
  4041. + {
  4042. + try
  4043. {
  4044. - try
  4045. + CTF_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4046. + }
  4047. + catch (NumberFormatException nfe)
  4048. + {
  4049. + if (!skill.isEmpty())
  4050. {
  4051. - TVT_ROUND_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4052. + _log.warning(StringUtil.concat("CTFEventEngine[Config.load()]: invalid config property -> CTFEventMageBuffs \"", skill, "\""));
  4053. }
  4054. - catch (NumberFormatException nfe)
  4055. - {
  4056. - if (!skill.isEmpty())
  4057. - _log.warning(StringUtil.concat("TvTRoundEventEngine[Config.load()]: invalid config property -> TvTRoundEventMageBuffs \"", skill, "\""));
  4058. - }
  4059. }
  4060. }
  4061. }
  4062. @@ -2081,12 +2397,193 @@
  4063. }
  4064. }
  4065. }
  4066. -
  4067. - }
  4068. - catch (Exception e)
  4069. - {
  4070. - _log.log(Level.SEVERE, "Error while loading Event settings!", e);
  4071. - }
  4072. + }
  4073. +
  4074. + if (DM_EVENT_PARTICIPATION_NPC_ID == 0)
  4075. + {
  4076. + DM_EVENT_ENABLED = false;
  4077. + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationNpcId");
  4078. + }
  4079. + else
  4080. + {
  4081. + String[] propertySplit = Event.getProperty("DMEventParticipationNpcCoordinates", "0,0,0").split(",");
  4082. + if (propertySplit.length < 3)
  4083. + {
  4084. + DM_EVENT_ENABLED = false;
  4085. + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationNpcCoordinates");
  4086. + }
  4087. + else
  4088. + {
  4089. + DM_EVENT_REWARDS = new ArrayList<int[]>();
  4090. + DM_DOORS_IDS_TO_OPEN = new ArrayList<Integer>();
  4091. + DM_DOORS_IDS_TO_CLOSE = new ArrayList<Integer>();
  4092. + DM_EVENT_PARTICIPATION_NPC_COORDINATES = new int[4];
  4093. + DM_EVENT_TEAM_1_COORDINATES = new int[3];
  4094. + DM_EVENT_TEAM_2_COORDINATES = new int[3];
  4095. + DM_EVENT_PARTICIPATION_NPC_COORDINATES[0] = Integer.parseInt(propertySplit[0]);
  4096. + DM_EVENT_PARTICIPATION_NPC_COORDINATES[1] = Integer.parseInt(propertySplit[1]);
  4097. + DM_EVENT_PARTICIPATION_NPC_COORDINATES[2] = Integer.parseInt(propertySplit[2]);
  4098. + if (propertySplit.length == 4)
  4099. + {
  4100. + DM_EVENT_PARTICIPATION_NPC_COORDINATES[3] = Integer.parseInt(propertySplit[3]);
  4101. + }
  4102. + DM_EVENT_MIN_PLAYERS = Integer.parseInt(Event.getProperty("DMEventMinPlayers", "1"));
  4103. + DM_EVENT_MAX_PLAYERS = Integer.parseInt(Event.getProperty("DMEventMaxPlayers", "20"));
  4104. + DM_EVENT_MIN_LVL = (byte) Integer.parseInt(Event.getProperty("DMEventMinPlayerLevel", "1"));
  4105. + DM_EVENT_MAX_LVL = (byte) Integer.parseInt(Event.getProperty("DMEventMaxPlayerLevel", "80"));
  4106. + DM_EVENT_RESPAWN_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("DMEventRespawnTeleportDelay", "20"));
  4107. + DM_EVENT_START_LEAVE_TELEPORT_DELAY = Integer.parseInt(Event.getProperty("DMEventStartLeaveTeleportDelay", "20"));
  4108. + DM_EVENT_EFFECTS_REMOVAL = Integer.parseInt(Event.getProperty("DMEventEffectsRemoval", "0"));
  4109. + DM_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(Event.getProperty("DMEventMaxParticipantsPerIP", "0"));
  4110. + DM_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(Event.getProperty("DMAllowVoicedInfoCommand", "false"));
  4111. + if (propertySplit.length < 3)
  4112. + {
  4113. + DM_EVENT_ENABLED = false;
  4114. + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventCoordinates");
  4115. + }
  4116. + else
  4117. + {
  4118. + propertySplit = Event.getProperty("DMEventParticipationFee", "0,0").split(",");
  4119. + try
  4120. + {
  4121. + DM_EVENT_PARTICIPATION_FEE[0] = Integer.parseInt(propertySplit[0]);
  4122. + DM_EVENT_PARTICIPATION_FEE[1] = Integer.parseInt(propertySplit[1]);
  4123. + }
  4124. + catch (NumberFormatException nfe)
  4125. + {
  4126. + if (propertySplit.length > 0)
  4127. + {
  4128. + _log.warning("DMEventEngine[Config.load()]: invalid config property -> DMEventParticipationFee");
  4129. + }
  4130. + }
  4131. + propertySplit = Event.getProperty("DMEventReward", "57,100000").split(";");
  4132. + for (String reward : propertySplit)
  4133. + {
  4134. + String[] rewardSplit = reward.split(",");
  4135. + if (rewardSplit.length != 2)
  4136. + {
  4137. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventReward \"", reward, "\""));
  4138. + }
  4139. + else
  4140. + {
  4141. + try
  4142. + {
  4143. + DM_EVENT_REWARDS.add(new int[]
  4144. + {
  4145. + Integer.parseInt(rewardSplit[0]),
  4146. + Integer.parseInt(rewardSplit[1])
  4147. + });
  4148. + }
  4149. + catch (NumberFormatException nfe)
  4150. + {
  4151. + if (!reward.isEmpty())
  4152. + {
  4153. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventReward \"", reward, "\""));
  4154. + }
  4155. + }
  4156. + }
  4157. + }
  4158. +
  4159. + DM_EVENT_TARGET_TEAM_MEMBERS_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventTargetTeamMembersAllowed", "true"));
  4160. + DM_EVENT_SCROLL_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventScrollsAllowed", "false"));
  4161. + DM_EVENT_POTIONS_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventPotionsAllowed", "false"));
  4162. + DM_EVENT_SUMMON_BY_ITEM_ALLOWED = Boolean.parseBoolean(Event.getProperty("DMEventSummonByItemAllowed", "false"));
  4163. + DM_REWARD_TEAM_TIE = Boolean.parseBoolean(Event.getProperty("DMRewardTeamTie", "false"));
  4164. + propertySplit = Event.getProperty("DMDoorsToOpen", "").split(";");
  4165. + for (String door : propertySplit)
  4166. + {
  4167. + try
  4168. + {
  4169. + DM_DOORS_IDS_TO_OPEN.add(Integer.parseInt(door));
  4170. + }
  4171. + catch (NumberFormatException nfe)
  4172. + {
  4173. + if (!door.isEmpty())
  4174. + {
  4175. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMDoorsToOpen \"", door, "\""));
  4176. + }
  4177. + }
  4178. + }
  4179. +
  4180. + propertySplit = Event.getProperty("DMDoorsToClose", "").split(";");
  4181. + for (String door : propertySplit)
  4182. + {
  4183. + try
  4184. + {
  4185. + DM_DOORS_IDS_TO_CLOSE.add(Integer.parseInt(door));
  4186. + }
  4187. + catch (NumberFormatException nfe)
  4188. + {
  4189. + if (!door.isEmpty())
  4190. + {
  4191. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMDoorsToClose \"", door, "\""));
  4192. + }
  4193. + }
  4194. + }
  4195. +
  4196. + propertySplit = Event.getProperty("DMEventFighterBuffs", "").split(";");
  4197. + if (!propertySplit[0].isEmpty())
  4198. + {
  4199. + DM_EVENT_FIGHTER_BUFFS = new TIntIntHashMap(propertySplit.length);
  4200. + for (String skill : propertySplit)
  4201. + {
  4202. + String[] skillSplit = skill.split(",");
  4203. + if (skillSplit.length != 2)
  4204. + {
  4205. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventFighterBuffs \"", skill, "\""));
  4206. + }
  4207. + else
  4208. + {
  4209. + try
  4210. + {
  4211. + DM_EVENT_FIGHTER_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4212. + }
  4213. + catch (NumberFormatException nfe)
  4214. + {
  4215. + if (!skill.isEmpty())
  4216. + {
  4217. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventFighterBuffs \"", skill, "\""));
  4218. + }
  4219. + }
  4220. + }
  4221. + }
  4222. + }
  4223. +
  4224. + propertySplit = Event.getProperty("DMEventMageBuffs", "").split(";");
  4225. + if (!propertySplit[0].isEmpty())
  4226. + {
  4227. + DM_EVENT_MAGE_BUFFS = new TIntIntHashMap(propertySplit.length);
  4228. + for (String skill : propertySplit)
  4229. + {
  4230. + String[] skillSplit = skill.split(",");
  4231. + if (skillSplit.length != 2)
  4232. + {
  4233. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventMageBuffs \"", skill, "\""));
  4234. + }
  4235. + else
  4236. + {
  4237. + try
  4238. + {
  4239. + DM_EVENT_MAGE_BUFFS.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
  4240. + }
  4241. + catch (NumberFormatException nfe)
  4242. + {
  4243. + if (!skill.isEmpty())
  4244. + {
  4245. + _log.warning(StringUtil.concat("DMEventEngine[Config.load()]: invalid config property -> DMEventMageBuffs \"", skill, "\""));
  4246. + }
  4247. + }
  4248. + }
  4249. + }
  4250. + }
  4251. + }
  4252. + }
  4253. + }
  4254. + }
  4255. + catch (Exception e)
  4256. + {
  4257. + _log.log(Level.SEVERE, "Error while loading Event settings!", e);
  4258. + }
  4259. // Load Character L2Properties file (if exists)
  4260. L2Properties Character = new L2Properties();
  4261. final File chars = new File(CHARACTER_CONFIG_FILE);
  4262. @@ -3002,8 +3499,8 @@
  4263. L2JMOD_CHAMPION_HP = Integer.parseInt(L2JModSettings.getProperty("ChampionHp", "7"));
  4264. L2JMOD_CHAMPION_HP_REGEN = Float.parseFloat(L2JModSettings.getProperty("ChampionHpRegen", "1."));
  4265. L2JMOD_CHAMPION_REWARDS = Integer.parseInt(L2JModSettings.getProperty("ChampionRewards", "8"));
  4266. - L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(L2JModSettings.getProperty("ChampionXPRewards", "8"));
  4267. - L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(L2JModSettings.getProperty("ChampionSPRewards", "8"));
  4268. + L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(L2JModSettings.getProperty("ChampionXPRewards", "8"));
  4269. + L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(L2JModSettings.getProperty("ChampionSPRewards", "8"));
  4270. L2JMOD_CHAMPION_ADENAS_REWARDS = Float.parseFloat(L2JModSettings.getProperty("ChampionAdenasRewards", "1"));
  4271. L2JMOD_CHAMPION_ATK = Float.parseFloat(L2JModSettings.getProperty("ChampionAtk", "1."));
  4272. L2JMOD_CHAMPION_SPD_ATK = Float.parseFloat(L2JModSettings.getProperty("ChampionSpdAtk", "1."));
  4273. @@ -3072,7 +3569,7 @@
  4274. TVT_EVENT_EFFECTS_REMOVAL = Integer.parseInt(L2JModSettings.getProperty("TvTEventEffectsRemoval", "0"));
  4275. TVT_EVENT_MAX_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("TvTEventMaxParticipantsPerIP", "0"));
  4276. TVT_ALLOW_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowVoicedInfoCommand", "false"));
  4277. - TVT_ALLOW_REGISTER_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowRegisterVoicedCommand", "false"));
  4278. + TVT_ALLOW_REGISTER_VOICED_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("TvTAllowRegisterVoicedCommand", "false"));
  4279. TVT_EVENT_TEAM_1_NAME = L2JModSettings.getProperty("TvTEventTeam1Name", "Team1");
  4280. tvtNpcCoords = L2JModSettings.getProperty("TvTEventTeam1Coordinates", "0,0,0").split(",");
  4281. if (tvtNpcCoords.length < 3)
  4282. @@ -3594,35 +4091,38 @@
  4283.  
  4284. BELETH_MIN_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("BelethMinPlayers", "36"));
  4285.  
  4286. - Interval_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("IntervalOfSailrenSpawn", "12"));
  4287. - if (Interval_Of_Sailren_Spawn < 1 || Interval_Of_Sailren_Spawn > 192)
  4288. - Interval_Of_Sailren_Spawn = 12;
  4289. - Interval_Of_Sailren_Spawn = Interval_Of_Sailren_Spawn * 3600000;
  4290. -
  4291. - Random_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("RandomOfSailrenSpawn", "24"));
  4292. - if (Random_Of_Sailren_Spawn < 1 || Random_Of_Sailren_Spawn > 192)
  4293. - Random_Of_Sailren_Spawn = 24;
  4294. - Random_Of_Sailren_Spawn = Random_Of_Sailren_Spawn * 3600000;
  4295. -
  4296. - ZAKEN_MINLEVEL_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime", "55"));
  4297. - ZAKEN_MINLEVEL_DAYTIME83 = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime83", "78"));
  4298. - FRINTEZZA_MINLEVEL = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinLevel", "80"));
  4299. -
  4300. - FRINTEZZA_MINPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinPlayers", "36"));
  4301. - ZAKEN_MINMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersDaytime", "9"));
  4302. - ZAKEN_MINMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersNighttime", "72"));
  4303. -
  4304. - ZAKEN_MAXMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersDaytime", "27"));
  4305. - ZAKEN_MAXMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersNighttime", "450"));
  4306. - FRINTEZZA_MAXPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMaxPlayers", "45"));
  4307. - MIN_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaPlayers", "18"));
  4308. - MAX_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaPlayers", "27"));
  4309. - MIN_LEVEL_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelPlayers", "82"));
  4310. - MIN_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaHcPlayers", "36"));
  4311. - MAX_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaHcPlayers", "45"));
  4312. - MIN_LEVEL_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelHcPlayers", "82"));
  4313. -
  4314. -
  4315. + Interval_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("IntervalOfSailrenSpawn", "12"));
  4316. + if ((Interval_Of_Sailren_Spawn < 1) || (Interval_Of_Sailren_Spawn > 192))
  4317. + {
  4318. + Interval_Of_Sailren_Spawn = 12;
  4319. + }
  4320. + Interval_Of_Sailren_Spawn = Interval_Of_Sailren_Spawn * 3600000;
  4321. +
  4322. + Random_Of_Sailren_Spawn = Integer.parseInt(GrandBossSettings.getProperty("RandomOfSailrenSpawn", "24"));
  4323. + if ((Random_Of_Sailren_Spawn < 1) || (Random_Of_Sailren_Spawn > 192))
  4324. + {
  4325. + Random_Of_Sailren_Spawn = 24;
  4326. + }
  4327. + Random_Of_Sailren_Spawn = Random_Of_Sailren_Spawn * 3600000;
  4328. +
  4329. + ZAKEN_MINLEVEL_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime", "55"));
  4330. + ZAKEN_MINLEVEL_DAYTIME83 = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinLevelDaytime83", "78"));
  4331. + FRINTEZZA_MINLEVEL = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinLevel", "80"));
  4332. +
  4333. + FRINTEZZA_MINPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMinPlayers", "36"));
  4334. + ZAKEN_MINMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersDaytime", "9"));
  4335. + ZAKEN_MINMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMinMembersNighttime", "72"));
  4336. +
  4337. + ZAKEN_MAXMEMBERS_DAYTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersDaytime", "27"));
  4338. + ZAKEN_MAXMEMBERS_NIGHTTIME = Integer.parseInt(GrandBossSettings.getProperty("ZakenMaxMembersNighttime", "450"));
  4339. + FRINTEZZA_MAXPLAYERS = Integer.parseInt(GrandBossSettings.getProperty("FrintezzaMaxPlayers", "45"));
  4340. + MIN_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaPlayers", "18"));
  4341. + MAX_FREYA_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaPlayers", "27"));
  4342. + MIN_LEVEL_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelPlayers", "82"));
  4343. + MIN_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinFreyaHcPlayers", "36"));
  4344. + MAX_FREYA_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MaxFreyaHcPlayers", "45"));
  4345. + MIN_LEVEL_HC_PLAYERS = Integer.parseInt(GrandBossSettings.getProperty("MinLevelHcPlayers", "82"));
  4346. +
  4347. // Gracia Seeds
  4348. L2Properties GraciaSeedsSettings = new L2Properties();
  4349. final File graciaseeds = new File(GRACIASEEDS_CONFIG_FILE);
  4350. @@ -3832,31 +4332,61 @@
  4351. {
  4352. switch (pName.trim().toLowerCase())
  4353. {
  4354. - case "EnableBotReport":
  4355. - ENABLE_BOTREPORT = Boolean.parseBoolean(pValue);
  4356. - break;
  4357. - case"PremiumRateXp":
  4358. - PREMIUM_RATE_XP = Float.parseFloat(pValue);
  4359. - break;
  4360. - case"PremiumRateSp":
  4361. - PREMIUM_RATE_SP = Float.parseFloat(pValue);
  4362. - break;
  4363. - case"PremiumRateDropItems":
  4364. - PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(pValue);
  4365. - break;
  4366. - case"PremiumRateRaidDropItems":
  4367. - PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(pValue);
  4368. - break;
  4369. - case"PremiumRateDropSpoil":
  4370. - PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(pValue);
  4371. - break;
  4372. - case"PremiumRateDropAdena":
  4373. - PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, Float.parseFloat(pValue));
  4374. - break;
  4375. + case "CTFEventEnabled":
  4376. + TVT_EVENT_ENABLED = Boolean.parseBoolean(pValue);
  4377. + break;
  4378. + case "CTFEventInterval":
  4379. + TVT_EVENT_INTERVAL = pValue.split(",");
  4380. + break;
  4381. + case "CTFEventParticipationTime":
  4382. + TVT_EVENT_PARTICIPATION_TIME = Integer.parseInt(pValue);
  4383. + break;
  4384. + case "CTFEventRunningTime":
  4385. + TVT_EVENT_RUNNING_TIME = Integer.parseInt(pValue);
  4386. + break;
  4387. + case "CTFEventParticipationNpcId":
  4388. + TVT_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(pValue);
  4389. + break;
  4390. + case "DMEventEnabled":
  4391. + TVT_EVENT_ENABLED = Boolean.parseBoolean(pValue);
  4392. + break;
  4393. + case "DMEventInterval":
  4394. + TVT_EVENT_INTERVAL = pValue.split(",");
  4395. + break;
  4396. + case "DMEventParticipationTime":
  4397. + TVT_EVENT_PARTICIPATION_TIME = Integer.parseInt(pValue);
  4398. + break;
  4399. + case "DMEventRunningTime":
  4400. + TVT_EVENT_RUNNING_TIME = Integer.parseInt(pValue);
  4401. + break;
  4402. + case "DMEventParticipationNpcId":
  4403. + TVT_EVENT_PARTICIPATION_NPC_ID = Integer.parseInt(pValue);
  4404. + case "EnableBotReport":
  4405. + break;
  4406. + ENABLE_BOTREPORT = Boolean.parseBoolean(pValue);
  4407. + break;
  4408. + case "PremiumRateXp":
  4409. + PREMIUM_RATE_XP = Float.parseFloat(pValue);
  4410. + break;
  4411. + case "PremiumRateSp":
  4412. + PREMIUM_RATE_SP = Float.parseFloat(pValue);
  4413. + break;
  4414. + case "PremiumRateDropItems":
  4415. + PREMIUM_RATE_DROP_ITEMS = Float.parseFloat(pValue);
  4416. + break;
  4417. + case "PremiumRateRaidDropItems":
  4418. + PREMIUM_RATE_DROP_ITEMS_BY_RAID = Float.parseFloat(pValue);
  4419. + break;
  4420. + case "PremiumRateDropSpoil":
  4421. + PREMIUM_RATE_DROP_SPOIL = Float.parseFloat(pValue);
  4422. + break;
  4423. + case "PremiumRateDropAdena":
  4424. + PREMIUM_RATE_DROP_ITEMS_ID.put(PcInventory.ADENA_ID, Float.parseFloat(pValue));
  4425. + break;
  4426. case "RateXp":
  4427. RATE_XP = Float.parseFloat(pValue);
  4428. break;
  4429. - // rates.properties
  4430. + // rates.properties
  4431. case "ratexp":
  4432. RATE_XP = Float.parseFloat(pValue);
  4433. break;
  4434. @@ -4544,12 +5074,12 @@
  4435. case "championrewards":
  4436. L2JMOD_CHAMPION_REWARDS = Integer.parseInt(pValue);
  4437. break;
  4438. - case "ChampionXPRewards":
  4439. - L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(pValue);
  4440. - break;
  4441. - case "ChampionSPRewards":
  4442. - L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(pValue);
  4443. - break;
  4444. + case "ChampionXPRewards":
  4445. + L2JMOD_CHAMPION_REWARDS_XP = Integer.parseInt(pValue);
  4446. + break;
  4447. + case "ChampionSPRewards":
  4448. + L2JMOD_CHAMPION_REWARDS_SP = Integer.parseInt(pValue);
  4449. + break;
  4450. case "championadenasrewards":
  4451. L2JMOD_CHAMPION_ADENAS_REWARDS = Float.parseFloat(pValue);
  4452. break;
  4453. Index: java/com/l2jserver/gameserver/network/serverpackets/Die.java
  4454. ===================================================================
  4455. --- java/com/l2jserver/gameserver/network/serverpackets/Die.java (revision 65)
  4456. +++ java/com/l2jserver/gameserver/network/serverpackets/Die.java (working copy)
  4457. @@ -25,7 +25,9 @@
  4458. import com.l2jserver.gameserver.model.actor.L2Attackable;
  4459. import com.l2jserver.gameserver.model.actor.L2Character;
  4460. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  4461. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  4462. import com.l2jserver.gameserver.model.entity.Castle;
  4463. +import com.l2jserver.gameserver.model.entity.DMEvent;
  4464. import com.l2jserver.gameserver.model.entity.Fort;
  4465. import com.l2jserver.gameserver.model.entity.TvTEvent;
  4466. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  4467. @@ -56,7 +58,7 @@
  4468.  
  4469. }
  4470. _charObjId = cha.getObjectId();
  4471. - _canTeleport = !((cha.isPlayer() && ((TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_charObjId)) || (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_charObjId)))) ||cha.isPendingRevive());
  4472. + _canTeleport = !(((cha.isPlayer() && ((TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_charObjId)) || ((CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(_charObjId)) || (DMEvent.isStarted() && DMEvent.isPlayerParticipant(_charObjId)) || (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_charObjId))))) || cha.isPendingRevive()));
  4473. if (cha.isL2Attackable())
  4474. {
  4475. _sweepable = ((L2Attackable) cha).isSweepActive();
  4476. Index: java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java
  4477. ===================================================================
  4478. --- java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java (revision 65)
  4479. +++ java/com/l2jserver/gameserver/model/actor/instance/L2CubicInstance.java (working copy)
  4480. @@ -34,6 +34,9 @@
  4481. import com.l2jserver.gameserver.model.actor.L2Character;
  4482. import com.l2jserver.gameserver.model.actor.L2Playable;
  4483. import com.l2jserver.gameserver.model.effects.L2Effect;
  4484. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  4485. +import com.l2jserver.gameserver.model.entity.CTFEventTeam;
  4486. +import com.l2jserver.gameserver.model.entity.DMEvent;
  4487. import com.l2jserver.gameserver.model.entity.TvTEvent;
  4488. import com.l2jserver.gameserver.model.entity.TvTEventTeam;
  4489. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  4490. @@ -306,6 +309,36 @@
  4491. {
  4492. return;
  4493. }
  4494. + // CTF event targeting
  4495. + if (CTFEvent.isStarted() && CTFEvent.isPlayerParticipant(_owner.getObjectId()))
  4496. + {
  4497. + CTFEventTeam enemyTeam = CTFEvent.getParticipantEnemyTeam(_owner.getObjectId());
  4498. +
  4499. + if (ownerTarget.getActingPlayer() != null)
  4500. + {
  4501. + L2PcInstance target = ownerTarget.getActingPlayer();
  4502. + if (enemyTeam.containsPlayer(target.getObjectId()) && !(target.isDead()))
  4503. + {
  4504. + _target = (L2Character) ownerTarget;
  4505. + }
  4506. + }
  4507. + return;
  4508. + }
  4509. + // DM event targeting
  4510. + if (DMEvent.isStarted() && DMEvent.isPlayerParticipant(_owner.getObjectId()))
  4511. + {
  4512. + DMEventTeam enemyTeam = DMEvent.getParticipantEnemyTeam(_owner.getObjectId());
  4513. +
  4514. + if (ownerTarget.getActingPlayer() != null)
  4515. + {
  4516. + L2PcInstance target = ownerTarget.getActingPlayer();
  4517. + if (enemyTeam.containsPlayer(target.getObjectId()) && !(target.isDead()))
  4518. + {
  4519. + _target = (L2Character) ownerTarget;
  4520. + }
  4521. + }
  4522. + return;
  4523. + }
  4524. // TvT event targeting
  4525. if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(_owner.getObjectId()))
  4526. {
  4527. @@ -321,7 +354,7 @@
  4528. }
  4529. return;
  4530. }
  4531. -
  4532. +
  4533. // TvT Round event targeting
  4534. if (TvTRoundEvent.isStarted() && TvTRoundEvent.isPlayerParticipant(_owner.getObjectId()))
  4535. {
  4536. Index: java/com/l2jserver/gameserver/model/entity/CTFEvent.java
  4537. ===================================================================
  4538. --- java/com/l2jserver/gameserver/model/entity/CTFEvent.java (revision 0)
  4539. +++ java/com/l2jserver/gameserver/model/entity/CTFEvent.java (working copy)
  4540. @@ -0,0 +1,3243 @@
  4541. +/*
  4542. + * This program is free software: you can redistribute it and/or modify it under
  4543. + * the terms of the GNU General Public License as published by the Free Software
  4544. + * Foundation, either version 3 of the License, or (at your option) any later
  4545. + * version.
  4546. + *
  4547. + * This program is distributed in the hope that it will be useful, but WITHOUT
  4548. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  4549. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  4550. + * details.
  4551. + *
  4552. + * You should have received a copy of the GNU General Public License along with
  4553. + * this program. If not, see <http://www.gnu.org/licenses/>.
  4554. + */
  4555. +package com.l2jserver.gameserver.model.entity;
  4556. +
  4557. +import java.sql.Connection;
  4558. +import java.sql.PreparedStatement;
  4559. +import java.sql.ResultSet;
  4560. +import java.sql.SQLException;
  4561. +import java.util.Calendar;
  4562. +import java.util.Map;
  4563. +import java.util.Vector;
  4564. +import java.util.concurrent.ScheduledFuture;
  4565. +import java.util.logging.Logger;
  4566. +
  4567. +import javolution.text.TextBuilder;
  4568. +import javolution.util.FastMap;
  4569. +
  4570. +import com.l2jserver.Config;
  4571. +import com.l2jserver.L2DatabaseFactory;
  4572. +import com.l2jserver.gameserver.Announcements;
  4573. +import com.l2jserver.gameserver.ThreadPoolManager;
  4574. +import com.l2jserver.gameserver.datatables.ItemTable;
  4575. +import com.l2jserver.gameserver.datatables.NpcTable;
  4576. +import com.l2jserver.gameserver.datatables.SpawnTable;
  4577. +import com.l2jserver.gameserver.model.L2Party;
  4578. +import com.l2jserver.gameserver.model.L2Radar;
  4579. +import com.l2jserver.gameserver.model.L2Spawn;
  4580. +import com.l2jserver.gameserver.model.actor.L2Character;
  4581. +import com.l2jserver.gameserver.model.actor.L2Summon;
  4582. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  4583. +import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  4584. +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  4585. +import com.l2jserver.gameserver.model.effects.L2Effect;
  4586. +import com.l2jserver.gameserver.model.effects.L2EffectType;
  4587. +import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  4588. +import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  4589. +import com.l2jserver.gameserver.model.skills.L2Skill;
  4590. +import com.l2jserver.gameserver.network.SystemMessageId;
  4591. +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  4592. +import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
  4593. +import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
  4594. +import com.l2jserver.gameserver.network.serverpackets.ItemList;
  4595. +import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  4596. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  4597. +import com.l2jserver.gameserver.network.serverpackets.PlaySound;
  4598. +import com.l2jserver.gameserver.network.serverpackets.RadarControl;
  4599. +import com.l2jserver.gameserver.network.serverpackets.SocialAction;
  4600. +import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  4601. +import com.l2jserver.util.Rnd;
  4602. +
  4603. +public class CTFEvent
  4604. +{
  4605. + /** Task for event cycles<br> */
  4606. + private CTFStartTask _task1;
  4607. +
  4608. + private CTFEvent()
  4609. + {
  4610. + if (Config.CTF_EVENT_ENABLED)
  4611. + {
  4612. + loadData();
  4613. + this.scheduleCTFEventStart();
  4614. + _log.warning("CTFEventEngine[CTF.CTF()]: Started.");
  4615. + }
  4616. + else
  4617. + {
  4618. + _log.warning("CTFEventEngine[CTF.CTF()]: Engine is disabled.");
  4619. + }
  4620. + }
  4621. +
  4622. + /**
  4623. + * Initialize new/Returns the one and only instance<br>
  4624. + * <br>
  4625. + * @return CTF<br>
  4626. + */
  4627. + public static CTFEvent getInstance()
  4628. + {
  4629. + return SingletonHolder._instance;
  4630. + }
  4631. +
  4632. + /**
  4633. + * Starts CTFStartTask
  4634. + */
  4635. + public void scheduleCTFEventStart()
  4636. + {
  4637. + try
  4638. + {
  4639. + Calendar currentTime = Calendar.getInstance();
  4640. + Calendar nextStartTime = null;
  4641. + Calendar testStartTime = null;
  4642. + for (String timeOfDay : Config.CTF_EVENT_INTERVAL)
  4643. + {
  4644. + // Creating a Calendar object from the specified interval value
  4645. + testStartTime = Calendar.getInstance();
  4646. + testStartTime.setLenient(true);
  4647. + String[] splitTimeOfDay = timeOfDay.split(":");
  4648. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  4649. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  4650. + // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  4651. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  4652. + {
  4653. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  4654. + }
  4655. + // Check for the test date to be the minimum (smallest in the specified list)
  4656. + if ((nextStartTime == null) || (testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis()))
  4657. + {
  4658. + nextStartTime = testStartTime;
  4659. + }
  4660. + }
  4661. + _task1 = new CTFStartTask(nextStartTime.getTimeInMillis());
  4662. + ThreadPoolManager.getInstance().executeTask(_task1);
  4663. + }
  4664. + catch (Exception e)
  4665. + {
  4666. + _log.warning("CTFEventEngine: Error figuring out a start time. Check CTFEventInterval in config file.");
  4667. + }
  4668. + }
  4669. +
  4670. + public void skipDelay()
  4671. + {
  4672. + if (_task1.nextRun.cancel(false))
  4673. + {
  4674. + _task1.setStartTime(System.currentTimeMillis());
  4675. + ThreadPoolManager.getInstance().executeTask(_task1);
  4676. + }
  4677. + }
  4678. +
  4679. + /**
  4680. + * Class forCTFT cycles
  4681. + */
  4682. + class CTFStartTask implements Runnable
  4683. + {
  4684. + private long _startTime;
  4685. + public ScheduledFuture<?> nextRun;
  4686. +
  4687. + public CTFStartTask(long startTime)
  4688. + {
  4689. + _startTime = startTime;
  4690. + }
  4691. +
  4692. + public void setStartTime(long startTime)
  4693. + {
  4694. + _startTime = startTime;
  4695. + }
  4696. +
  4697. + /**
  4698. + * @see java.lang.Runnable#run()
  4699. + */
  4700. + @Override
  4701. + public void run()
  4702. + {
  4703. + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  4704. +
  4705. + int nextMsg = 0;
  4706. + if (delay > 3600)
  4707. + {
  4708. + nextMsg = delay - 3600;
  4709. + }
  4710. + else if (delay > 1800)
  4711. + {
  4712. + nextMsg = delay - 1800;
  4713. + }
  4714. + else if (delay > 900)
  4715. + {
  4716. + nextMsg = delay - 900;
  4717. + }
  4718. + else if (delay > 600)
  4719. + {
  4720. + nextMsg = delay - 600;
  4721. + }
  4722. + else if (delay > 300)
  4723. + {
  4724. + nextMsg = delay - 300;
  4725. + }
  4726. + else if (delay > 60)
  4727. + {
  4728. + nextMsg = delay - 60;
  4729. + }
  4730. + else if (delay > 5)
  4731. + {
  4732. + nextMsg = delay - 5;
  4733. + }
  4734. + else if (delay > 0)
  4735. + {
  4736. + nextMsg = delay;
  4737. + }
  4738. + else
  4739. + {
  4740. + // start
  4741. +
  4742. + autoEvent();
  4743. + _task1.setStartTime(System.currentTimeMillis() + (60000L * 225));
  4744. + ThreadPoolManager.getInstance().executeTask(_task1);
  4745. + }
  4746. +
  4747. + if (delay > 0)
  4748. + {
  4749. + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
  4750. + }
  4751. + }
  4752. + }
  4753. +
  4754. + private final static Logger _log = Logger.getLogger(CTFEvent.class.getName());
  4755. + private static int _FlagNPC = 35062, _FLAG_IN_HAND_ITEM_ID = 6718;
  4756. + public static String _eventName = new String(), _eventDesc = new String(), _topTeam = new String(), _joiningLocationName = new String();
  4757. + public static Vector<String> _teams = new Vector<String>(), _savePlayers = new Vector<String>(), _savePlayerTeams = new Vector<String>();
  4758. + public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>(), _playersShuffle = new Vector<L2PcInstance>();
  4759. + public static Vector<Integer> _teamPlayersCount = new Vector<Integer>(), _teamColors = new Vector<Integer>(), _teamsX = new Vector<Integer>(), _teamsY = new Vector<Integer>(), _teamsZ = new Vector<Integer>(), _teamsBaseX = new Vector<Integer>(), _teamsBaseY = new Vector<Integer>(),
  4760. + _teamsBaseZ = new Vector<Integer>();
  4761. + public static boolean _joining = false, _teleport = false, _started = false, _sitForced = false;
  4762. + public static L2Spawn _npcSpawn;
  4763. + public static int _npcId = 0, _npcX = 0, _npcY = 0, _npcZ = 0, _npcHeading = 0, _rewardId = 0, _rewardAmount = 0, _minlvl = 0, _maxlvl = 0, _joinTime = 0, _eventTime = 0, _minPlayers = 0, _maxPlayers = 0;
  4764. + public static long _flagHoldTime = 0;
  4765. + public static Vector<Integer> _teamPointsCount = new Vector<Integer>();
  4766. + public static Vector<Integer> _flagIds = new Vector<Integer>(), _flagsX = new Vector<Integer>(), _flagsY = new Vector<Integer>(), _flagsZ = new Vector<Integer>();
  4767. + public static Vector<L2Spawn> _flagSpawns = new Vector<L2Spawn>(), _throneSpawns = new Vector<L2Spawn>();
  4768. + public static Vector<Boolean> _flagsTaken = new Vector<Boolean>(), _flagsNotRemoved = new Vector<Boolean>();
  4769. + public static int _topScore = 0, eventCenterX = 0, eventCenterY = 0, eventCenterZ = 0, eventOffset = 0;
  4770. + public static Map<String, Integer> _playerScores = new FastMap<String, Integer>();
  4771. +
  4772. + public static void showFlagHtml(L2PcInstance eventPlayer, String objectId, String teamName)
  4773. + {
  4774. + if (eventPlayer == null)
  4775. + {
  4776. + return;
  4777. + }
  4778. +
  4779. + try
  4780. + {
  4781. + NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
  4782. +
  4783. + TextBuilder replyMSG = new TextBuilder();
  4784. +
  4785. + replyMSG.append("<html><body><center>");
  4786. + replyMSG.append("CTF Flag<br><br>");
  4787. + replyMSG.append("<font color=\"00FF00\">" + teamName + "'s Flag</font><br>");
  4788. + if ((eventPlayer._teamNameCTF != null) && eventPlayer._teamNameCTF.equals(teamName))
  4789. + {
  4790. + replyMSG.append("<font color=\"LEVEL\">This is your Flag</font><br>");
  4791. + }
  4792. + else
  4793. + {
  4794. + replyMSG.append("<font color=\"LEVEL\">Enemy Flag!</font><br>");
  4795. + }
  4796. + if (_started)
  4797. + {
  4798. + processInFlagRange(eventPlayer);
  4799. + }
  4800. + else
  4801. + {
  4802. + replyMSG.append("CTF match is not in progress yet.<br>Wait for a GM to start the event<br>");
  4803. + }
  4804. + replyMSG.append("</center></body></html>");
  4805. + adminReply.setHtml(replyMSG.toString());
  4806. + eventPlayer.sendPacket(adminReply);
  4807. + }
  4808. + catch (Exception e)
  4809. + {
  4810. + _log.warning("" + "CTF Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception: " + e.getStackTrace());
  4811. + }
  4812. + }
  4813. +
  4814. + public static void CheckRestoreFlags()
  4815. + {
  4816. + Vector<Integer> teamsTakenFlag = new Vector<Integer>();
  4817. + try
  4818. + {
  4819. + for (L2PcInstance player : _players)
  4820. + { // if there's a player with a flag
  4821. + // add the index of the team who's FLAG WAS TAKEN to the list
  4822. + if (player != null)
  4823. + {
  4824. + if (!player.isOnline() && player._haveFlagCTF)// logged off with a flag in his hands
  4825. + {
  4826. + AnnounceToPlayers(false, "CTF Event: " + player.getName() + " logged off with a CTF flag!");
  4827. + player._haveFlagCTF = false;
  4828. + if (_teams.indexOf(player._teamNameHaveFlagCTF) >= 0)
  4829. + {
  4830. + if (_flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
  4831. + {
  4832. + _flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
  4833. + spawnFlag(player._teamNameHaveFlagCTF);
  4834. + AnnounceToPlayers(false, "CTF Event: " + player._teamNameHaveFlagCTF + " flag now returned to place.");
  4835. + }
  4836. + }
  4837. + removeFlagFromPlayer(player);
  4838. + player._teamNameHaveFlagCTF = null;
  4839. + return;
  4840. + }
  4841. + else if (player._haveFlagCTF)
  4842. + {
  4843. + teamsTakenFlag.add(_teams.indexOf(player._teamNameHaveFlagCTF));
  4844. + }
  4845. + }
  4846. + }
  4847. + // Go over the list of ALL teams
  4848. + for (String team : _teams)
  4849. + {
  4850. + if (team == null)
  4851. + {
  4852. + continue;
  4853. + }
  4854. + int index = _teams.indexOf(team);
  4855. + if (!teamsTakenFlag.contains(index))
  4856. + {
  4857. + if (_flagsTaken.get(index))
  4858. + {
  4859. + _flagsTaken.set(index, false);
  4860. + spawnFlag(team);
  4861. + AnnounceToPlayers(false, "CTF Event: " + team + " flag returned due to player error.");
  4862. + }
  4863. + }
  4864. + }
  4865. + // Check if a player ran away from the event holding a flag:
  4866. + for (L2PcInstance player : _players)
  4867. + {
  4868. + if ((player != null) && player._haveFlagCTF)
  4869. + {
  4870. + if (isOutsideCTFArea(player))
  4871. + {
  4872. + AnnounceToPlayers(false, "CTF Event: " + player.getName() + " escaped from the event holding a flag!");
  4873. + player._haveFlagCTF = false;
  4874. + if (_teams.indexOf(player._teamNameHaveFlagCTF) >= 0)
  4875. + {
  4876. + if (_flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
  4877. + {
  4878. + _flagsTaken.set(_teams.indexOf(player._teamNameHaveFlagCTF), false);
  4879. + spawnFlag(player._teamNameHaveFlagCTF);
  4880. + AnnounceToPlayers(false, "CTF Event: " + player._teamNameHaveFlagCTF + " flag now returned to place.");
  4881. + }
  4882. + }
  4883. + removeFlagFromPlayer(player);
  4884. + player._teamNameHaveFlagCTF = null;
  4885. + if (Config.CTF_BASE_TELEPORT_FIRST)
  4886. + {
  4887. + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
  4888. +
  4889. + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(player, false), 10000);
  4890. +
  4891. + player.sendMessage("You have been returned to your base. You will be sent into battle in 10 seconds.");
  4892. + }
  4893. + else
  4894. + {
  4895. + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
  4896. + player.sendMessage("You have been returned to your team spawn.");
  4897. + }
  4898. + return;
  4899. + }
  4900. + }
  4901. + }
  4902. + }
  4903. + catch (Exception e)
  4904. + {
  4905. + _log.warning("CTF.restoreFlags() Error:" + e.toString());
  4906. + }
  4907. + }
  4908. +
  4909. + public static void kickPlayerFromCTf(L2PcInstance playerToKick)
  4910. + {
  4911. + if (playerToKick == null)
  4912. + {
  4913. + return;
  4914. + }
  4915. +
  4916. + if (_joining)
  4917. + {
  4918. + _playersShuffle.remove(playerToKick);
  4919. + _players.remove(playerToKick);
  4920. + playerToKick._inEventCTF = false;
  4921. + playerToKick._teamNameCTF = new String();
  4922. + }
  4923. + if (_started || _teleport)
  4924. + {
  4925. + _playersShuffle.remove(playerToKick);
  4926. + playerToKick._inEventCTF = false;
  4927. + removePlayer(playerToKick);
  4928. + if (playerToKick.isOnline())
  4929. + {
  4930. + playerToKick.getAppearance().setNameColor(playerToKick._originalNameColorCTF);
  4931. + playerToKick.setKarma(playerToKick._originalKarmaCTF);
  4932. + playerToKick.setTitle(playerToKick._originalTitleCTF);
  4933. + playerToKick.broadcastUserInfo();
  4934. + playerToKick.sendMessage("You have been kicked from the CTF.");
  4935. + playerToKick.teleToLocation(_npcX, _npcY, _npcZ, false);
  4936. + }
  4937. + }
  4938. + }
  4939. +
  4940. + public static void AnnounceToPlayers(Boolean toall, String announce)
  4941. + {
  4942. + if (toall)
  4943. + {
  4944. + Announcements.getInstance().announceToAll(announce);
  4945. + }
  4946. + else
  4947. + {
  4948. + CreatureSay cs = new CreatureSay(0, 2, "", "Announcements : " + announce);
  4949. + if ((_players != null) && !_players.isEmpty())
  4950. + {
  4951. + for (L2PcInstance player : _players)
  4952. + {
  4953. + if ((player != null) && player.isOnline())
  4954. + {
  4955. + player.sendPacket(cs);
  4956. + }
  4957. + }
  4958. + }
  4959. + }
  4960. + }
  4961. +
  4962. + public static void Started(L2PcInstance player)
  4963. + {
  4964. + player._teamNameHaveFlagCTF = null;
  4965. + player._haveFlagCTF = false;
  4966. + }
  4967. +
  4968. + public static void StartEvent()
  4969. + {
  4970. + for (L2PcInstance player : _players)
  4971. + {
  4972. + if (player != null)
  4973. + {
  4974. + player._teamNameHaveFlagCTF = null;
  4975. + player._haveFlagCTF = false;
  4976. + }
  4977. + }
  4978. + }
  4979. +
  4980. + public static void addFlagToPlayer(L2PcInstance _player)
  4981. + {
  4982. + // remove items from the player hands (right, left, both)
  4983. + // This is NOT a BUG, I don't want them to see the icon they have 8D
  4984. + L2ItemInstance wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  4985. + if (wpn == null)
  4986. + {
  4987. + wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  4988. + if (wpn != null)
  4989. + {
  4990. + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
  4991. + }
  4992. + }
  4993. + else
  4994. + {
  4995. + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_RHAND);
  4996. + wpn = _player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
  4997. + if (wpn != null)
  4998. + {
  4999. + _player.getInventory().unEquipItemInBodySlotAndRecord(Inventory.PAPERDOLL_LHAND);
  5000. + }
  5001. + }
  5002. + // add the flag in his hands
  5003. + _player.getInventory().equipItem(ItemTable.getInstance().createItem("", CTF._FLAG_IN_HAND_ITEM_ID, 1, _player, null));
  5004. + _player.broadcastPacket(new SocialAction(_player, 16)); // amazing glow
  5005. + _player._haveFlagCTF = true;
  5006. + _player.broadcastUserInfo();
  5007. + CreatureSay cs = new CreatureSay(_player.getObjectId(), 15, ":", "You got it! Run back! ::"); // 8D
  5008. + _player.sendPacket(cs);
  5009. +
  5010. + // Start the flag holding timer
  5011. + _flagsNotRemoved.set(_teams.indexOf(_player._teamNameCTF), true);
  5012. + flagHoldTimer(_player, _flagHoldTime);
  5013. +
  5014. + // If player is invisible, make them visible
  5015. + if (_player.getAppearance().getInvisible())
  5016. + {
  5017. + @SuppressWarnings("unused")
  5018. + L2Effect eInvisible = _player.getFirstEffect(L2EffectType.HIDE);
  5019. + }
  5020. + }
  5021. +
  5022. + public static void removeFlagFromPlayer(L2PcInstance player)
  5023. + {
  5024. + L2ItemInstance wpn = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  5025. + player._haveFlagCTF = false;
  5026. +
  5027. + // Reset boolean of whether the holder's flag has not been removed yet to false and kill the flagHoldTimer thread
  5028. + _flagsNotRemoved.set(_teams.indexOf(player._teamNameCTF), false);
  5029. +
  5030. + if (wpn != null)
  5031. + {
  5032. + L2ItemInstance[] unequiped = player.getInventory().unEquipItemInBodySlotAndRecord(wpn.getItem().getBodyPart());
  5033. + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
  5034. + InventoryUpdate iu = new InventoryUpdate();
  5035. + for (L2ItemInstance element : unequiped)
  5036. + {
  5037. + iu.addModifiedItem(element);
  5038. + }
  5039. + player.sendPacket(iu);
  5040. + player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
  5041. + player.abortAttack();
  5042. + player.broadcastUserInfo();
  5043. + }
  5044. + else
  5045. + {
  5046. + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
  5047. + player.sendPacket(new ItemList(player, true)); // get your weapon back now ...
  5048. + player.abortAttack();
  5049. + player.broadcastUserInfo();
  5050. + }
  5051. + }
  5052. +
  5053. + public static void setTeamFlag(String teamName, L2PcInstance activeChar)
  5054. + {
  5055. + int index = _teams.indexOf(teamName);
  5056. +
  5057. + if (index == -1)
  5058. + {
  5059. + return;
  5060. + }
  5061. + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, activeChar.getX(), activeChar.getY(), activeChar.getZ());
  5062. + }
  5063. +
  5064. + public static void setTeamFlag(String teamName, int x, int y, int z)
  5065. + {
  5066. + int index = _teams.indexOf(teamName);
  5067. +
  5068. + if (index == -1)
  5069. + {
  5070. + return;
  5071. + }
  5072. + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, x, y, z);
  5073. + }
  5074. +
  5075. + public static void spawnAllFlags()
  5076. + {
  5077. + while (_flagSpawns.size() < _teams.size())
  5078. + {
  5079. + _flagSpawns.add(null);
  5080. + }
  5081. + while (_throneSpawns.size() < _teams.size())
  5082. + {
  5083. + _throneSpawns.add(null);
  5084. + }
  5085. + for (String team : _teams)
  5086. + {
  5087. + int index = _teams.indexOf(team);
  5088. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_flagIds.get(index));
  5089. + L2NpcTemplate throne = NpcTable.getInstance().getTemplate(32027);
  5090. + try
  5091. + {
  5092. + // spawn throne
  5093. + _throneSpawns.set(index, new L2Spawn(throne));
  5094. + _throneSpawns.get(index).setLocx(_flagsX.get(index));
  5095. + _throneSpawns.get(index).setLocy(_flagsY.get(index));
  5096. + _throneSpawns.get(index).setLocz(_flagsZ.get(index) - 10);
  5097. + _throneSpawns.get(index).setAmount(1);
  5098. + _throneSpawns.get(index).setHeading(0);
  5099. + _throneSpawns.get(index).setRespawnDelay(1);
  5100. + SpawnTable.getInstance().addNewSpawn(_throneSpawns.get(index), false);
  5101. + _throneSpawns.get(index).init();
  5102. + _throneSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
  5103. + _throneSpawns.get(index).getLastSpawn().decayMe();
  5104. + _throneSpawns.get(index).getLastSpawn().spawnMe(_throneSpawns.get(index).getLastSpawn().getX(), _throneSpawns.get(index).getLastSpawn().getY(), _throneSpawns.get(index).getLastSpawn().getZ());
  5105. + _throneSpawns.get(index).getLastSpawn().setTitle(team + " Throne");
  5106. + _throneSpawns.get(index).getLastSpawn().broadcastPacket(new MagicSkillUse(_throneSpawns.get(index).getLastSpawn(), _throneSpawns.get(index).getLastSpawn(), 1036, 1, 5500, 1));
  5107. + _throneSpawns.get(index).getLastSpawn()._isCTF_throneSpawn = true;
  5108. +
  5109. + // spawn flag
  5110. + _flagSpawns.set(index, new L2Spawn(tmpl));
  5111. + _flagSpawns.get(index).setLocx(_flagsX.get(index));
  5112. + _flagSpawns.get(index).setLocy(_flagsY.get(index));
  5113. + _flagSpawns.get(index).setLocz(_flagsZ.get(index));
  5114. + _flagSpawns.get(index).setAmount(1);
  5115. + _flagSpawns.get(index).setHeading(0);
  5116. + _flagSpawns.get(index).setRespawnDelay(1);
  5117. + SpawnTable.getInstance().addNewSpawn(_flagSpawns.get(index), false);
  5118. + _flagSpawns.get(index).init();
  5119. + _flagSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
  5120. + _flagSpawns.get(index).getLastSpawn().setTitle(team + "'s Flag");
  5121. + _flagSpawns.get(index).getLastSpawn()._CTF_FlagTeamName = team;
  5122. + _flagSpawns.get(index).getLastSpawn().decayMe();
  5123. + _flagSpawns.get(index).getLastSpawn().spawnMe(_flagSpawns.get(index).getLastSpawn().getX(), _flagSpawns.get(index).getLastSpawn().getY(), _flagSpawns.get(index).getLastSpawn().getZ());
  5124. + _flagSpawns.get(index).getLastSpawn()._isCTF_Flag = true;
  5125. + if (index == (_teams.size() - 1))
  5126. + {
  5127. + calculateOutSideOfCTF(); // sets event boundaries so players don't run with the flag.
  5128. + }
  5129. + }
  5130. + catch (Exception e)
  5131. + {
  5132. + _log.warning("CTF Engine[spawnAllFlags()]: exception: " + e.getStackTrace());
  5133. + }
  5134. + }
  5135. + }
  5136. +
  5137. + public static void processTopTeam()
  5138. + {
  5139. +
  5140. + _topTeam = null;
  5141. + for (String team : _teams)
  5142. + {
  5143. + if ((teamPointsCount(team) == _topScore) && (_topScore > 0))
  5144. + {
  5145. + _topTeam = null;
  5146. + }
  5147. + if (teamPointsCount(team) > _topScore)
  5148. + {
  5149. + _topTeam = team;
  5150. + _topScore = teamPointsCount(team);
  5151. + }
  5152. + }
  5153. + if (_topScore <= 0)
  5154. + {
  5155. + AnnounceToPlayers(true, "CTF Event: No flags taken.");
  5156. + }
  5157. + else
  5158. + {
  5159. + if (_topTeam == null)
  5160. + {
  5161. + AnnounceToPlayers(true, "CTF Event: Maximum flags taken : " + _topScore + " flags! No one won.");
  5162. + }
  5163. + else
  5164. + {
  5165. + AnnounceToPlayers(true, "CTF Event: Team " + _topTeam + " wins the match, with " + _topScore + " flags taken!");
  5166. + rewardTeam(_topTeam);
  5167. + }
  5168. + }
  5169. + }
  5170. +
  5171. + public static void unspawnAllFlags()
  5172. + {
  5173. + try
  5174. + {
  5175. + if ((_throneSpawns == null) || (_flagSpawns == null) || (_teams == null))
  5176. + {
  5177. + return;
  5178. + }
  5179. + for (String team : _teams)
  5180. + {
  5181. + int index = _teams.indexOf(team);
  5182. + if (_throneSpawns.get(index) != null)
  5183. + {
  5184. + _throneSpawns.get(index).getLastSpawn().deleteMe();
  5185. + _throneSpawns.get(index).stopRespawn();
  5186. + SpawnTable.getInstance().deleteSpawn(_throneSpawns.get(index), true);
  5187. + }
  5188. + if (_flagSpawns.get(index) != null)
  5189. + {
  5190. + _flagSpawns.get(index).getLastSpawn().deleteMe();
  5191. + _flagSpawns.get(index).stopRespawn();
  5192. + SpawnTable.getInstance().deleteSpawn(_flagSpawns.get(index), true);
  5193. + }
  5194. + }
  5195. + _throneSpawns.removeAllElements();
  5196. + }
  5197. + catch (Throwable t)
  5198. + {
  5199. + _log.warning("CTF Engine[unspawnAllFlags()]: exception: " + t.getStackTrace());
  5200. + }
  5201. + }
  5202. +
  5203. + private static void unspawnFlag(String teamName)
  5204. + {
  5205. + int index = _teams.indexOf(teamName);
  5206. +
  5207. + _flagSpawns.get(index).getLastSpawn().deleteMe();
  5208. + _flagSpawns.get(index).stopRespawn();
  5209. + SpawnTable.getInstance().deleteSpawn(_flagSpawns.get(index), true);
  5210. + }
  5211. +
  5212. + public static void spawnFlag(String teamName)
  5213. + {
  5214. + int index = _teams.indexOf(teamName);
  5215. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_flagIds.get(index));
  5216. +
  5217. + try
  5218. + {
  5219. + _flagSpawns.set(index, new L2Spawn(tmpl));
  5220. +
  5221. + _flagSpawns.get(index).setLocx(_flagsX.get(index));
  5222. + _flagSpawns.get(index).setLocy(_flagsY.get(index));
  5223. + _flagSpawns.get(index).setLocz(_flagsZ.get(index));
  5224. + _flagSpawns.get(index).setAmount(1);
  5225. + _flagSpawns.get(index).setHeading(0);
  5226. + _flagSpawns.get(index).setRespawnDelay(1);
  5227. +
  5228. + SpawnTable.getInstance().addNewSpawn(_flagSpawns.get(index), false);
  5229. +
  5230. + _flagSpawns.get(index).init();
  5231. + _flagSpawns.get(index).getLastSpawn().getStatus().setCurrentHp(999999999);
  5232. + _flagSpawns.get(index).getLastSpawn().setTitle(teamName + "'s Flag");
  5233. + _flagSpawns.get(index).getLastSpawn()._CTF_FlagTeamName = teamName;
  5234. + _flagSpawns.get(index).getLastSpawn()._isCTF_Flag = true;
  5235. + _flagSpawns.get(index).getLastSpawn().decayMe();
  5236. + _flagSpawns.get(index).getLastSpawn().spawnMe(_flagSpawns.get(index).getLastSpawn().getX(), _flagSpawns.get(index).getLastSpawn().getY(), _flagSpawns.get(index).getLastSpawn().getZ());
  5237. + }
  5238. + catch (Exception e)
  5239. + {
  5240. + _log.warning("CTF Engine[spawnFlag(" + teamName + ")]: exception: " + e.getStackTrace());
  5241. + }
  5242. + }
  5243. +
  5244. + public static boolean InRangeOfFlag(L2PcInstance _player, int flagIndex, int offset)
  5245. + {
  5246. + if ((_player.getX() > (CTF._flagsX.get(flagIndex) - offset)) && (_player.getX() < (CTF._flagsX.get(flagIndex) + offset)) && (_player.getY() > (CTF._flagsY.get(flagIndex) - offset)) && (_player.getY() < (CTF._flagsY.get(flagIndex) + offset)) && (_player.getZ() > (CTF._flagsZ.get(flagIndex) - offset)) && (_player.getZ() < (CTF._flagsZ.get(flagIndex) + offset)))
  5247. + {
  5248. + return true;
  5249. + }
  5250. + return false;
  5251. + }
  5252. +
  5253. + public static void processInFlagRange(L2PcInstance _player)
  5254. + {
  5255. + try
  5256. + {
  5257. + CheckRestoreFlags();
  5258. + for (String team : _teams)
  5259. + {
  5260. + if (team.equals(_player._teamNameCTF))
  5261. + {
  5262. + int indexOwn = _teams.indexOf(_player._teamNameCTF);
  5263. +
  5264. + // if player is near his team flag holding the enemy flag
  5265. + if (InRangeOfFlag(_player, indexOwn, 100) && !_flagsTaken.get(indexOwn) && _player._haveFlagCTF)
  5266. + {
  5267. + int indexEnemy = _teams.indexOf(_player._teamNameHaveFlagCTF);
  5268. + // return enemy flag to place
  5269. + _flagsTaken.set(indexEnemy, false);
  5270. + spawnFlag(_player._teamNameHaveFlagCTF);
  5271. + // remove the flag from this player
  5272. + _player.broadcastPacket(new SocialAction(_player, 16)); // amazing glow
  5273. + _player.broadcastUserInfo();
  5274. + _player.broadcastPacket(new SocialAction(_player, 3)); // Victory
  5275. + _player.broadcastUserInfo();
  5276. + removeFlagFromPlayer(_player);
  5277. + _teamPointsCount.set(indexOwn, teamPointsCount(team) + 1);
  5278. + _player.broadcastPacket(new PlaySound(0, "ItemSound.quest_finish", 1, _player.getObjectId(), _player.getX(), _player.getY(), _player.getZ()));
  5279. + _player.broadcastUserInfo();
  5280. + _playerScores.put(_player.getName(), playerScoresCount(_player.getName()) + 1);
  5281. + AnnounceToPlayers(false, "CTF Event: " + _player.getName() + " scores for " + _player._teamNameCTF + " team.");
  5282. + AnnounceToPlayers(false, "CTF Event: Scores - " + _teams.get(0) + ": " + teamPointsCount(_teams.get(0)) + " " + _teams.get(1) + ": " + teamPointsCount(_teams.get(1)));
  5283. + }
  5284. + }
  5285. + else
  5286. + {
  5287. + int indexEnemy = _teams.indexOf(team);
  5288. + // if the player is near a enemy flag
  5289. + if (InRangeOfFlag(_player, indexEnemy, 100) && !_flagsTaken.get(indexEnemy) && !_player._haveFlagCTF && !_player.isDead())
  5290. + {
  5291. + if (_player.isRidingStrider() || _player.isFlying())
  5292. + {
  5293. + _player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_A_PET_OR_A_SERVITOR_IS_SUMMONED));
  5294. + break;
  5295. + }
  5296. +
  5297. + _flagsTaken.set(indexEnemy, true);
  5298. + unspawnFlag(team);
  5299. + _player._teamNameHaveFlagCTF = team;
  5300. + addFlagToPlayer(_player);
  5301. + _player.broadcastUserInfo();
  5302. + _player._haveFlagCTF = true;
  5303. + AnnounceToPlayers(false, "CTF Event: " + team + " flag taken by " + _player.getName() + "...");
  5304. + pointTeamTo(_player, team);
  5305. + break;
  5306. + }
  5307. + }
  5308. + }
  5309. + }
  5310. + catch (Exception e)
  5311. + {
  5312. + e.printStackTrace();
  5313. + }
  5314. + }
  5315. +
  5316. + public static void pointTeamTo(L2PcInstance hasFlag, String ourFlag)
  5317. + {
  5318. + try
  5319. + {
  5320. + for (L2PcInstance player : _players)
  5321. + {
  5322. + if ((player != null) && player.isOnline())
  5323. + {
  5324. + if (player._teamNameCTF.equals(ourFlag))
  5325. + {
  5326. + player.sendMessage(hasFlag.getName() + " took your flag!");
  5327. + if (player._haveFlagCTF)
  5328. + {
  5329. + player.sendMessage("You can not return the flag to headquarters, until your flag is returned to it's place.");
  5330. + player.sendPacket(new RadarControl(1, 1, player.getX(), player.getY(), player.getZ()));
  5331. + }
  5332. + else
  5333. + {
  5334. + player.sendPacket(new RadarControl(0, 1, hasFlag.getX(), hasFlag.getY(), hasFlag.getZ()));
  5335. + L2Radar rdr = new L2Radar(player);
  5336. + L2Radar.RadarOnPlayer radar = rdr.new RadarOnPlayer(hasFlag, player);
  5337. + ThreadPoolManager.getInstance().scheduleGeneral(radar, 10000 + Rnd.get(30000));
  5338. + }
  5339. + }
  5340. + }
  5341. + }
  5342. + }
  5343. + catch (Throwable t)
  5344. + {
  5345. + }
  5346. + }
  5347. +
  5348. + private static int playerScoresCount(String player)
  5349. + {
  5350. + if (_playerScores.containsKey(player))
  5351. + {
  5352. + return _playerScores.get(player);
  5353. + }
  5354. + else if (player != null)
  5355. + {
  5356. + _playerScores.put(player, 0);
  5357. + return _playerScores.get(player);
  5358. + }
  5359. + else
  5360. + {
  5361. + return 0;
  5362. + }
  5363. + }
  5364. +
  5365. + public static int teamPointsCount(String teamName)
  5366. + {
  5367. + int index = _teams.indexOf(teamName);
  5368. +
  5369. + if (index == -1)
  5370. + {
  5371. + return -1;
  5372. + }
  5373. +
  5374. + return _teamPointsCount.get(index);
  5375. + }
  5376. +
  5377. + public static void setTeamPointsCount(String teamName, int teamPointCount)
  5378. + {
  5379. + int index = _teams.indexOf(teamName);
  5380. +
  5381. + if (index == -1)
  5382. + {
  5383. + return;
  5384. + }
  5385. +
  5386. + _teamPointsCount.set(index, teamPointCount);
  5387. + }
  5388. +
  5389. + public static int teamPlayersCount(String teamName)
  5390. + {
  5391. + int index = _teams.indexOf(teamName);
  5392. +
  5393. + if (index == -1)
  5394. + {
  5395. + return -1;
  5396. + }
  5397. +
  5398. + return _teamPlayersCount.get(index);
  5399. + }
  5400. +
  5401. + public static void setTeamPlayersCount(String teamName, int teamPlayersCount)
  5402. + {
  5403. + int index = _teams.indexOf(teamName);
  5404. +
  5405. + if (index == -1)
  5406. + {
  5407. + return;
  5408. + }
  5409. +
  5410. + _teamPlayersCount.set(index, teamPlayersCount);
  5411. + }
  5412. +
  5413. + public static void setNpcPos(L2PcInstance activeChar)
  5414. + {
  5415. + _npcX = activeChar.getX();
  5416. + _npcY = activeChar.getY();
  5417. + _npcZ = activeChar.getZ();
  5418. + _npcHeading = activeChar.getHeading();
  5419. + }
  5420. +
  5421. + public static void setNpcPos(int x, int y, int z)
  5422. + {
  5423. + _npcX = x;
  5424. + _npcY = y;
  5425. + _npcZ = z;
  5426. + }
  5427. +
  5428. + public static void addTeam(String teamName)
  5429. + {
  5430. + if (!checkTeamOk())
  5431. + {
  5432. + if (Config.DEBUG)
  5433. + {
  5434. + _log.fine("CTF Engine[addTeam(" + teamName + ")]: checkTeamOk() = false");
  5435. + }
  5436. + return;
  5437. + }
  5438. +
  5439. + if (teamName.equals(" "))
  5440. + {
  5441. + return;
  5442. + }
  5443. +
  5444. + _teams.add(teamName);
  5445. + _teamPlayersCount.add(0);
  5446. + _teamColors.add(0);
  5447. + _teamsX.add(0);
  5448. + _teamsY.add(0);
  5449. + _teamsZ.add(0);
  5450. + _teamsBaseX.add(0);
  5451. + _teamsBaseY.add(0);
  5452. + _teamsBaseZ.add(0);
  5453. + _teamPointsCount.add(0);
  5454. + addOrSet(_teams.indexOf(teamName), null, false, _FlagNPC, 0, 0, 0);
  5455. + }
  5456. +
  5457. + private static void addOrSet(int listSize, L2Spawn flagSpawn, boolean flagsTaken, int flagId, int flagX, int flagY, int flagZ)
  5458. + {
  5459. + while (_flagsX.size() <= listSize)
  5460. + {
  5461. + _flagSpawns.add(null);
  5462. + _flagsTaken.add(false);
  5463. + _flagIds.add(_FlagNPC);
  5464. + _flagsX.add(0);
  5465. + _flagsY.add(0);
  5466. + _flagsZ.add(0);
  5467. + }
  5468. + _flagSpawns.set(listSize, flagSpawn);
  5469. + _flagsTaken.set(listSize, flagsTaken);
  5470. + _flagIds.set(listSize, flagId);
  5471. + _flagsX.set(listSize, flagX);
  5472. + _flagsY.set(listSize, flagY);
  5473. + _flagsZ.set(listSize, flagZ);
  5474. + }
  5475. +
  5476. + public static boolean checkMaxLevel(int maxlvl)
  5477. + {
  5478. + if (_minlvl >= maxlvl)
  5479. + {
  5480. + return false;
  5481. + }
  5482. +
  5483. + return true;
  5484. + }
  5485. +
  5486. + public static boolean checkMinLevel(int minlvl)
  5487. + {
  5488. + if (_maxlvl <= minlvl)
  5489. + {
  5490. + return false;
  5491. + }
  5492. +
  5493. + return true;
  5494. + }
  5495. +
  5496. + /** returns true if participated players is higher or equal then minimum needed players */
  5497. + public static boolean checkMinPlayers(int players)
  5498. + {
  5499. + if (_minPlayers <= players)
  5500. + {
  5501. + return true;
  5502. + }
  5503. +
  5504. + return false;
  5505. + }
  5506. +
  5507. + /** returns true if max players is higher or equal then participated players */
  5508. + public static boolean checkMaxPlayers(int players)
  5509. + {
  5510. + if (_maxPlayers > players)
  5511. + {
  5512. + return true;
  5513. + }
  5514. +
  5515. + return false;
  5516. + }
  5517. +
  5518. + public static void removeTeam(String teamName)
  5519. + {
  5520. + if (!checkTeamOk() || _teams.isEmpty())
  5521. + {
  5522. + if (Config.DEBUG)
  5523. + {
  5524. + _log.fine("CTF Engine[removeTeam(" + teamName + ")]: checkTeamOk() = false");
  5525. + }
  5526. + return;
  5527. + }
  5528. +
  5529. + if (teamPlayersCount(teamName) > 0)
  5530. + {
  5531. + if (Config.DEBUG)
  5532. + {
  5533. + _log.fine("CTF Engine[removeTeam(" + teamName + ")]: teamPlayersCount(teamName) > 0");
  5534. + }
  5535. + return;
  5536. + }
  5537. +
  5538. + int index = _teams.indexOf(teamName);
  5539. +
  5540. + if (index == -1)
  5541. + {
  5542. + return;
  5543. + }
  5544. +
  5545. + _teamsZ.remove(index);
  5546. + _teamsY.remove(index);
  5547. + _teamsX.remove(index);
  5548. + _teamsBaseZ.remove(index);
  5549. + _teamsBaseY.remove(index);
  5550. + _teamsBaseX.remove(index);
  5551. + _teamColors.remove(index);
  5552. + _teamPointsCount.remove(index);
  5553. + _teamPlayersCount.remove(index);
  5554. + _teams.remove(index);
  5555. + _flagSpawns.remove(index);
  5556. + _flagsTaken.remove(index);
  5557. + _flagIds.remove(index);
  5558. + _flagsX.remove(index);
  5559. + _flagsY.remove(index);
  5560. + _flagsZ.remove(index);
  5561. + }
  5562. +
  5563. + public static void setTeamPos(String teamName, L2PcInstance activeChar)
  5564. + {
  5565. + int index = _teams.indexOf(teamName);
  5566. +
  5567. + if (index == -1)
  5568. + {
  5569. + return;
  5570. + }
  5571. +
  5572. + _teamsX.set(index, activeChar.getX());
  5573. + _teamsY.set(index, activeChar.getY());
  5574. + _teamsZ.set(index, activeChar.getZ());
  5575. + }
  5576. +
  5577. + public static void setTeamPos(String teamName, int x, int y, int z)
  5578. + {
  5579. + int index = _teams.indexOf(teamName);
  5580. +
  5581. + if (index == -1)
  5582. + {
  5583. + return;
  5584. + }
  5585. +
  5586. + _teamsX.set(index, x);
  5587. + _teamsY.set(index, y);
  5588. + _teamsZ.set(index, z);
  5589. + }
  5590. +
  5591. + public static void setTeamBasePos(String teamName, L2PcInstance activeChar)
  5592. + {
  5593. + int index = _teams.indexOf(teamName);
  5594. +
  5595. + if (index == -1)
  5596. + {
  5597. + return;
  5598. + }
  5599. +
  5600. + _teamsBaseX.set(index, activeChar.getX());
  5601. + _teamsBaseY.set(index, activeChar.getY());
  5602. + _teamsBaseZ.set(index, activeChar.getZ());
  5603. + }
  5604. +
  5605. + public static void setTeamBasePos(String teamName, int x, int y, int z)
  5606. + {
  5607. + int index = _teams.indexOf(teamName);
  5608. +
  5609. + if (index == -1)
  5610. + {
  5611. + return;
  5612. + }
  5613. +
  5614. + _teamsBaseX.set(index, x);
  5615. + _teamsBaseY.set(index, y);
  5616. + _teamsBaseZ.set(index, z);
  5617. + }
  5618. +
  5619. + public static void setTeamColor(String teamName, int color)
  5620. + {
  5621. + if (!checkTeamOk())
  5622. + {
  5623. + return;
  5624. + }
  5625. +
  5626. + int index = _teams.indexOf(teamName);
  5627. +
  5628. + if (index == -1)
  5629. + {
  5630. + return;
  5631. + }
  5632. +
  5633. + _teamColors.set(index, color);
  5634. + }
  5635. +
  5636. + public static boolean checkTeamOk()
  5637. + {
  5638. + if (_started || _teleport || _joining)
  5639. + {
  5640. + return false;
  5641. + }
  5642. +
  5643. + return true;
  5644. + }
  5645. +
  5646. + public static void startJoin(L2PcInstance activeChar)
  5647. + {
  5648. + if (!startJoinOk())
  5649. + {
  5650. + activeChar.sendMessage("Event not setted propertly.");
  5651. + if (Config.DEBUG)
  5652. + {
  5653. + _log.fine("CTF Engine[startJoin(" + activeChar.getName() + ")]: startJoinOk() = false");
  5654. + }
  5655. + return;
  5656. + }
  5657. +
  5658. + _joining = true;
  5659. + spawnEventNpc(activeChar);
  5660. + AnnounceToPlayers(true, "CTF Event: Registration opened for 15 minute(s)! Use .joinctf command to register.");
  5661. + }
  5662. +
  5663. + public static void startJoin()
  5664. + {
  5665. + if (!startJoinOk())
  5666. + {
  5667. + _log.warning("Event not setted propertly.");
  5668. + if (Config.DEBUG)
  5669. + {
  5670. + _log.fine("CTF Engine[startJoin(startJoinOk() = false");
  5671. + }
  5672. + return;
  5673. + }
  5674. +
  5675. + _joining = true;
  5676. + spawnEventNpc();
  5677. + }
  5678. +
  5679. + public static boolean startAutoJoin()
  5680. + {
  5681. + if (!startJoinOk())
  5682. + {
  5683. + if (Config.DEBUG)
  5684. + {
  5685. + _log.fine("CTF Engine[startJoin]: startJoinOk() = false");
  5686. + }
  5687. + return false;
  5688. + }
  5689. +
  5690. + _joining = true;
  5691. + spawnEventNpc();
  5692. + AnnounceToPlayers(true, "CTF Event: Registration opened for 15 minute(s)! Use .joinctf command to register.");
  5693. + return true;
  5694. + }
  5695. +
  5696. + public static boolean startJoinOk()
  5697. + {
  5698. + if (Config.CTF_BASE_TELEPORT_FIRST && (_teamsBaseX.contains(0) || _teamsBaseY.contains(0) || _teamsBaseZ.contains(0)))
  5699. + {
  5700. + return false;
  5701. + }
  5702. + else if (_started || _teleport || _joining || (_teams.size() < 2) || _eventName.equals("") || _joiningLocationName.equals("") || _eventDesc.equals("") || (_npcId == 0) || (_npcX == 0) || (_npcY == 0) || (_npcZ == 0) || (_rewardId == 0) || (_rewardAmount == 0) || _teamsX.contains(0) || _teamsY.contains(0) || _teamsZ.contains(0) || (_flagHoldTime == 0))
  5703. + {
  5704. + return false;
  5705. + }
  5706. + try
  5707. + {
  5708. + if (_flagsX.contains(0) || _flagsY.contains(0) || _flagsZ.contains(0) || _flagIds.contains(0))
  5709. + {
  5710. + return false;
  5711. + }
  5712. + if ((_flagsX.size() < _teams.size()) || (_flagsY.size() < _teams.size()) || (_flagsZ.size() < _teams.size()) || (_flagIds.size() < _teams.size()))
  5713. + {
  5714. + return false;
  5715. + }
  5716. + }
  5717. + catch (ArrayIndexOutOfBoundsException e)
  5718. + {
  5719. + return false;
  5720. + }
  5721. + return true;
  5722. + }
  5723. +
  5724. + private static void spawnEventNpc(L2PcInstance activeChar)
  5725. + {
  5726. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
  5727. +
  5728. + try
  5729. + {
  5730. + _npcSpawn = new L2Spawn(tmpl);
  5731. +
  5732. + _npcSpawn.setLocx(_npcX);
  5733. + _npcSpawn.setLocy(_npcY);
  5734. + _npcSpawn.setLocz(_npcZ);
  5735. + _npcSpawn.setAmount(1);
  5736. + _npcSpawn.setHeading(_npcHeading);
  5737. + _npcSpawn.setRespawnDelay(1);
  5738. +
  5739. + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  5740. +
  5741. + _npcSpawn.init();
  5742. + _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
  5743. + _npcSpawn.getLastSpawn().setTitle(_eventName);
  5744. + _npcSpawn.getLastSpawn()._isEventMobCTF = true;
  5745. + _npcSpawn.getLastSpawn().isAggressive();
  5746. + _npcSpawn.getLastSpawn().decayMe();
  5747. + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  5748. +
  5749. + _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUse(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
  5750. + }
  5751. + catch (Exception e)
  5752. + {
  5753. + _log.warning("CTF Engine[spawnEventNpc(" + activeChar.getName() + ")]: exception: " + e.getMessage());
  5754. + }
  5755. + }
  5756. +
  5757. + public static class BaseTeleportTask implements Runnable
  5758. + {
  5759. + L2PcInstance player;
  5760. + boolean onBegin;
  5761. +
  5762. + public BaseTeleportTask(L2PcInstance _player, boolean _onBegin)
  5763. + {
  5764. + player = _player;
  5765. + onBegin = _onBegin;
  5766. + }
  5767. +
  5768. + public BaseTeleportTask(boolean _onBegin)
  5769. + {
  5770. + onBegin = _onBegin;
  5771. + }
  5772. +
  5773. + @Override
  5774. + public void run()
  5775. + {
  5776. + if (CTF._teleport || CTF._started)
  5777. + {
  5778. + if (onBegin)
  5779. + {
  5780. + spawnAllFlags();
  5781. +
  5782. + for (L2PcInstance players : _players)
  5783. + {
  5784. + new BaseTeleportTask(players, false).run();
  5785. + }
  5786. + }
  5787. + else
  5788. + {
  5789. + if (player != null)
  5790. + {
  5791. + player.teleToLocation(CTF._teamsX.get(CTF._teams.indexOf(player._teamNameCTF)), CTF._teamsY.get(CTF._teams.indexOf(player._teamNameCTF)), CTF._teamsZ.get(CTF._teams.indexOf(player._teamNameCTF)), false);
  5792. + }
  5793. + }
  5794. + }
  5795. + }
  5796. + }
  5797. +
  5798. + private static void spawnEventNpc()
  5799. + {
  5800. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
  5801. +
  5802. + try
  5803. + {
  5804. + _npcSpawn = new L2Spawn(tmpl);
  5805. +
  5806. + _npcSpawn.setLocx(_npcX);
  5807. + _npcSpawn.setLocy(_npcY);
  5808. + _npcSpawn.setLocz(_npcZ);
  5809. + _npcSpawn.setAmount(1);
  5810. + _npcSpawn.setHeading(_npcHeading);
  5811. + _npcSpawn.setRespawnDelay(1);
  5812. +
  5813. + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  5814. +
  5815. + _npcSpawn.init();
  5816. + _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
  5817. + _npcSpawn.getLastSpawn().setTitle(_eventName);
  5818. + _npcSpawn.getLastSpawn()._isEventMobCTF = true;
  5819. + _npcSpawn.getLastSpawn().isAggressive();
  5820. + _npcSpawn.getLastSpawn().decayMe();
  5821. + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  5822. +
  5823. + _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUse(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
  5824. + }
  5825. + catch (Exception e)
  5826. + {
  5827. + _log.warning("CTF Engine[spawnEventNpc(exception: " + e.getMessage());
  5828. + }
  5829. + }
  5830. +
  5831. + public static void teleportStart()
  5832. + {
  5833. + if (!_joining || _started || _teleport)
  5834. + {
  5835. + return;
  5836. + }
  5837. +
  5838. + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size()))
  5839. + {
  5840. + removeOfflinePlayers();
  5841. + shuffleTeams();
  5842. + }
  5843. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
  5844. + {
  5845. + return;
  5846. + }
  5847. +
  5848. + _joining = false;
  5849. + setUserData();
  5850. +
  5851. + if (Config.CTF_BASE_TELEPORT_FIRST)
  5852. + {
  5853. + AnnounceToPlayers(true, "CTF Event: Teleporting to team base. The fight will being in 20 seconds!");
  5854. +
  5855. + for (L2PcInstance player : _players)
  5856. + {
  5857. + if (player != null)
  5858. + {
  5859. + if (Config.CTF_ON_START_UNSUMMON_PET)
  5860. + {
  5861. + // Remove Summon's buffs
  5862. + if (player.getPet() != null)
  5863. + {
  5864. + L2Summon summon = player.getPet();
  5865. + for (L2Effect e : summon.getAllEffects())
  5866. + {
  5867. + if (e != null)
  5868. + {
  5869. + e.exit();
  5870. + }
  5871. + }
  5872. +
  5873. + if (summon instanceof L2PetInstance)
  5874. + {
  5875. + summon.unSummon(player);
  5876. + }
  5877. + }
  5878. + }
  5879. +
  5880. + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
  5881. + {
  5882. + for (L2Effect e : player.getAllEffects())
  5883. + {
  5884. + if (e != null)
  5885. + {
  5886. + e.exit();
  5887. + }
  5888. + }
  5889. + }
  5890. +
  5891. + // Remove player from his party
  5892. + if (player.getParty() != null)
  5893. + {
  5894. + L2Party party = player.getParty();
  5895. + party.removePartyMember(player);
  5896. + }
  5897. +
  5898. + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
  5899. + }
  5900. + }
  5901. + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(true), 20000);
  5902. + }
  5903. + else
  5904. + {
  5905. + AnnounceToPlayers(true, "CTF Event: Teleporting to team spot in 15 seconds!");
  5906. +
  5907. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  5908. + {
  5909. + @Override
  5910. + public void run()
  5911. + {
  5912. + spawnAllFlags();
  5913. +
  5914. + for (L2PcInstance player : _players)
  5915. + {
  5916. + if (player != null)
  5917. + {
  5918. + if (Config.CTF_ON_START_UNSUMMON_PET)
  5919. + {
  5920. + // Remove Summon's buffs
  5921. + if (player.getPet() != null)
  5922. + {
  5923. + L2Summon summon = player.getPet();
  5924. + for (L2Effect e : summon.getAllEffects())
  5925. + {
  5926. + if (e != null)
  5927. + {
  5928. + e.exit();
  5929. + }
  5930. + }
  5931. +
  5932. + if (summon instanceof L2PetInstance)
  5933. + {
  5934. + summon.unSummon(player);
  5935. + }
  5936. + }
  5937. + }
  5938. +
  5939. + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
  5940. + {
  5941. + for (L2Effect e : player.getAllEffects())
  5942. + {
  5943. + if (e != null)
  5944. + {
  5945. + e.exit();
  5946. + }
  5947. + }
  5948. + }
  5949. +
  5950. + // Remove player from his party
  5951. + if (player.getParty() != null)
  5952. + {
  5953. + L2Party party = player.getParty();
  5954. + party.removePartyMember(player);
  5955. + }
  5956. +
  5957. + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
  5958. + }
  5959. + }
  5960. + }
  5961. + }, 15000);
  5962. + }
  5963. + _teleport = true;
  5964. + }
  5965. +
  5966. + public static boolean teleportAutoStart()
  5967. + {
  5968. + if (!_joining || _started || _teleport)
  5969. + {
  5970. + return false;
  5971. + }
  5972. +
  5973. + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && checkMinPlayers(_playersShuffle.size()))
  5974. + {
  5975. + removeOfflinePlayers();
  5976. + shuffleTeams();
  5977. + }
  5978. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMinPlayers(_playersShuffle.size()))
  5979. + {
  5980. + AnnounceToPlayers(true, "CTF Event: Not enough players registered.");
  5981. + return false;
  5982. + }
  5983. +
  5984. + _joining = false;
  5985. + setUserData();
  5986. +
  5987. + if (Config.CTF_BASE_TELEPORT_FIRST)
  5988. + {
  5989. + AnnounceToPlayers(true, "CTF Event: Teleporting to team base. The fight will being in 20 seconds!");
  5990. +
  5991. + for (L2PcInstance player : _players)
  5992. + {
  5993. + if (player != null)
  5994. + {
  5995. + if (Config.CTF_ON_START_UNSUMMON_PET)
  5996. + {
  5997. + // Remove Summon's buffs
  5998. + if (player.getPet() != null)
  5999. + {
  6000. + L2Summon summon = player.getPet();
  6001. + for (L2Effect e : summon.getAllEffects())
  6002. + {
  6003. + if (e != null)
  6004. + {
  6005. + e.exit();
  6006. + }
  6007. + }
  6008. +
  6009. + if (summon instanceof L2PetInstance)
  6010. + {
  6011. + summon.unSummon(player);
  6012. + }
  6013. + }
  6014. + }
  6015. +
  6016. + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
  6017. + {
  6018. + for (L2Effect e : player.getAllEffects())
  6019. + {
  6020. + if (e != null)
  6021. + {
  6022. + e.exit();
  6023. + }
  6024. + }
  6025. + }
  6026. +
  6027. + // Remove player from his party
  6028. + if (player.getParty() != null)
  6029. + {
  6030. + L2Party party = player.getParty();
  6031. + party.removePartyMember(player);
  6032. + }
  6033. +
  6034. + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
  6035. + }
  6036. + }
  6037. + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(true), 30000);
  6038. + }
  6039. + else
  6040. + {
  6041. + AnnounceToPlayers(false, "CTF Event: Teleporting to team spot in 15 seconds!");
  6042. +
  6043. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  6044. + {
  6045. + @Override
  6046. + public void run()
  6047. + {
  6048. + spawnAllFlags();
  6049. +
  6050. + for (L2PcInstance player : _players)
  6051. + {
  6052. + if (player != null)
  6053. + {
  6054. + if (Config.CTF_ON_START_UNSUMMON_PET)
  6055. + {
  6056. + // Remove Summon's buffs
  6057. + if (player.getPet() != null)
  6058. + {
  6059. + L2Summon summon = player.getPet();
  6060. + for (L2Effect e : summon.getAllEffects())
  6061. + {
  6062. + if (e != null)
  6063. + {
  6064. + e.exit();
  6065. + }
  6066. + }
  6067. +
  6068. + if (summon instanceof L2PetInstance)
  6069. + {
  6070. + summon.unSummon(player);
  6071. + }
  6072. + }
  6073. + }
  6074. +
  6075. + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
  6076. + {
  6077. + for (L2Effect e : player.getAllEffects())
  6078. + {
  6079. + if (e != null)
  6080. + {
  6081. + e.exit();
  6082. + }
  6083. + }
  6084. + }
  6085. +
  6086. + // Remove player from his party
  6087. + if (player.getParty() != null)
  6088. + {
  6089. + L2Party party = player.getParty();
  6090. + party.removePartyMember(player);
  6091. + }
  6092. +
  6093. + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
  6094. + }
  6095. + }
  6096. + }
  6097. + }, 15000);
  6098. + }
  6099. + _teleport = true;
  6100. + return true;
  6101. + }
  6102. +
  6103. + public static void startEvent(L2PcInstance activeChar)
  6104. + {
  6105. + if (!startEventOk())
  6106. + {
  6107. + if (Config.DEBUG)
  6108. + {
  6109. + _log.fine("CTF Engine[startEvent(" + activeChar.getName() + ")]: startEventOk() = false");
  6110. + }
  6111. + return;
  6112. + }
  6113. +
  6114. + _teleport = false;
  6115. +
  6116. + _started = true;
  6117. + StartEvent();
  6118. + }
  6119. +
  6120. + public static void setJoinTime(int time)
  6121. + {
  6122. + _joinTime = time;
  6123. + }
  6124. +
  6125. + public static void setEventTime(int time)
  6126. + {
  6127. + _eventTime = time;
  6128. + }
  6129. +
  6130. + public static boolean startAutoEvent()
  6131. + {
  6132. + if (!startEventOk())
  6133. + {
  6134. + if (Config.DEBUG)
  6135. + {
  6136. + _log.fine("CTF Engine[startEvent]: startEventOk() = false");
  6137. + }
  6138. + return false;
  6139. + }
  6140. +
  6141. + _teleport = false;
  6142. +
  6143. + _started = true;
  6144. + return true;
  6145. + }
  6146. +
  6147. + public static synchronized void autoEvent()
  6148. + {
  6149. + if (startAutoJoin())
  6150. + {
  6151. + if (_joinTime > 0)
  6152. + {
  6153. + waiter(_joinTime * 60 * 1000); // minutes for join event
  6154. + }
  6155. + else if (_joinTime <= 0)
  6156. + {
  6157. + abortEvent();
  6158. + return;
  6159. + }
  6160. + if (teleportAutoStart())
  6161. + {
  6162. + AnnounceToPlayers(false, "CTF Event: Started. Go Capture the Flags!");
  6163. + waiter(1 * 1 * 1000); // 1 seconds wait time until start fight after teleported
  6164. + if (startAutoEvent())
  6165. + {
  6166. + waiter(_eventTime * 60 * 1000); // minutes for event time
  6167. + finishEvent();
  6168. + }
  6169. + }
  6170. + else if (!teleportAutoStart())
  6171. + {
  6172. + abortEvent();
  6173. + }
  6174. + }
  6175. + }
  6176. +
  6177. + // a scheduled time to remove the flag after a user set time _flagHoldTime
  6178. + private static void flagHoldTimer(final L2PcInstance _player, final long interval)
  6179. + {
  6180. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  6181. + {
  6182. + @Override
  6183. + public void run()
  6184. + {
  6185. + if (_started)
  6186. + {
  6187. + try
  6188. + // just to be sure
  6189. + {
  6190. + long countDown = System.currentTimeMillis();
  6191. + int seconds = (int) interval;
  6192. +
  6193. + while (((countDown + (interval * 1000)) > System.currentTimeMillis()) && (_flagsNotRemoved.get(_teams.indexOf(_player._teamNameCTF)) != false))
  6194. + {
  6195. + seconds--;
  6196. +
  6197. + switch (seconds)
  6198. + {
  6199. + case 600: // 10 minutes left
  6200. + if ((_player != null) && _player._haveFlagCTF)
  6201. + {
  6202. + _player.sendMessage("You have 10 minutes to capture the flag or it will be returned.");
  6203. + }
  6204. + break;
  6205. + case 300: // 5 minutes left
  6206. + if ((_player != null) && _player._haveFlagCTF)
  6207. + {
  6208. + _player.sendMessage("You have 5 minutes to capture the flag or it will be returned.");
  6209. + }
  6210. + break;
  6211. + case 240: // 4 minutes left
  6212. + if ((_player != null) && _player._haveFlagCTF)
  6213. + {
  6214. + _player.sendMessage("You have 5 minutes to capture the flag or it will be returned.");
  6215. + }
  6216. + break;
  6217. + case 180: // 3 minutes left
  6218. + if ((_player != null) && _player._haveFlagCTF)
  6219. + {
  6220. + _player.sendMessage("You have 3 minutes to capture the flag or it will be returned.");
  6221. + }
  6222. + break;
  6223. + case 120: // 2 minutes left
  6224. + if ((_player != null) && _player._haveFlagCTF)
  6225. + {
  6226. + _player.sendMessage("You have 2 minutes to capture the flag or it will be returned.");
  6227. + }
  6228. + break;
  6229. + case 60: // 1 minute left
  6230. + if ((_player != null) && _player._haveFlagCTF)
  6231. + {
  6232. + _player.sendMessage("You have 1 minute to capture the flag or it will be returned.");
  6233. + }
  6234. + break;
  6235. + case 30: // 30 seconds left
  6236. + if ((_player != null) && _player._haveFlagCTF)
  6237. + {
  6238. + _player.sendMessage("You have 30 seconds to capture the flag or it will be returned.");
  6239. + }
  6240. + break;
  6241. + case 10: // 10 seconds left
  6242. + if ((_player != null) && _player._haveFlagCTF)
  6243. + {
  6244. + _player.sendMessage("You have 10 seconds to capture the flag or it will be returned.");
  6245. + }
  6246. + break;
  6247. + case 1: // 1 seconds left
  6248. + if ((_player != null) && _player._haveFlagCTF)
  6249. + {
  6250. + removeFlagFromPlayer(_player);
  6251. + _flagsTaken.set(_teams.indexOf(_player._teamNameHaveFlagCTF), false);
  6252. + spawnFlag(_player._teamNameHaveFlagCTF);
  6253. + _player.sendMessage("You've held the flag for too long. The enemy flag has been returned.");
  6254. + AnnounceToPlayers(false, "CTF Event: " + _player.getName() + " held the flag for too long. " + _player._teamNameCTF + " flag has been returned.");
  6255. + }
  6256. + break;
  6257. + }
  6258. + long startOneSecondWaiterStartTime = System.currentTimeMillis();
  6259. +
  6260. + // only the try catch with Thread.sleep(1000) give bad countdown on high wait times
  6261. + while ((startOneSecondWaiterStartTime + 1000) > System.currentTimeMillis())
  6262. + {
  6263. + try
  6264. + {
  6265. + Thread.sleep(1);
  6266. + }
  6267. + catch (InterruptedException ie)
  6268. + {
  6269. + }
  6270. + }
  6271. + }
  6272. + }
  6273. + catch (Exception e)
  6274. + {
  6275. + _log.warning("Exception: CTF.flagHoldTimer(): " + e.getMessage());
  6276. + }
  6277. + }
  6278. + }
  6279. + }, 1);
  6280. + }
  6281. +
  6282. + private static synchronized void waiter(long interval)
  6283. + {
  6284. + long startWaiterTime = System.currentTimeMillis();
  6285. + int seconds = (int) (interval / 1000);
  6286. +
  6287. + while ((startWaiterTime + interval) > System.currentTimeMillis())
  6288. + {
  6289. + seconds--; // here because we don't want to see two time announce at the same time
  6290. +
  6291. + if (_joining || _started || _teleport)
  6292. + {
  6293. + switch (seconds)
  6294. + {
  6295. + case 3600: // 1 hour left
  6296. + if (_joining)
  6297. + {
  6298. + AnnounceToPlayers(true, "CTF Event: " + (seconds / 60 / 60) + " hour(s) until registration ends! Use .joinctf command to register.");
  6299. + }
  6300. + else if (_started)
  6301. + {
  6302. + AnnounceToPlayers(false, "CTF Event: " + (seconds / 60 / 60) + " hour(s) until event ends!");
  6303. + }
  6304. +
  6305. + break;
  6306. + case 600: // 10 minutes left
  6307. + case 300: // 5 minutes left
  6308. + case 60: // 1 minute left
  6309. + if (_joining)
  6310. + {
  6311. + removeOfflinePlayers();
  6312. + AnnounceToPlayers(true, "CTF Event: " + (seconds / 60) + " minute(s) until registration ends! Use .joinctf command to register.");
  6313. + }
  6314. + else if (_started)
  6315. + {
  6316. + AnnounceToPlayers(false, "CTF Event: " + (seconds / 60) + " minute(s) until event ends!");
  6317. + }
  6318. +
  6319. + break;
  6320. +
  6321. + case 5: // 5 seconds left
  6322. +
  6323. + if (_joining)
  6324. + {
  6325. + AnnounceToPlayers(true, "CTF Event: " + seconds + " second(s) until registration ends! Use .joinctf command to register.");
  6326. + }
  6327. + else if (_teleport)
  6328. + {
  6329. + AnnounceToPlayers(false, "CTF Event: " + seconds + " seconds(s) until ends starts!");
  6330. + }
  6331. + else if (_started)
  6332. + {
  6333. + AnnounceToPlayers(false, "CTF Event: " + seconds + " second(s) until event ends!");
  6334. + }
  6335. +
  6336. + break;
  6337. + }
  6338. + }
  6339. +
  6340. + long startOneSecondWaiterStartTime = System.currentTimeMillis();
  6341. +
  6342. + // only the try catch with Thread.sleep(1000) give bad countdown on high wait times
  6343. + while ((startOneSecondWaiterStartTime + 1000) > System.currentTimeMillis())
  6344. + {
  6345. + try
  6346. + {
  6347. + Thread.sleep(1);
  6348. + }
  6349. + catch (InterruptedException ie)
  6350. + {
  6351. + }
  6352. + }
  6353. + }
  6354. + }
  6355. +
  6356. + private static boolean startEventOk()
  6357. + {
  6358. + if (_joining || !_teleport || _started)
  6359. + {
  6360. + return false;
  6361. + }
  6362. +
  6363. + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
  6364. + {
  6365. + if (_teamPlayersCount.contains(0))
  6366. + {
  6367. + return false;
  6368. + }
  6369. + }
  6370. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  6371. + {
  6372. + Vector<L2PcInstance> playersShuffleTemp = new Vector<L2PcInstance>();
  6373. + int loopCount = 0;
  6374. +
  6375. + loopCount = _playersShuffle.size();
  6376. +
  6377. + for (int i = 0; i < loopCount; i++)
  6378. + {
  6379. + if (_playersShuffle != null)
  6380. + {
  6381. + playersShuffleTemp.add(_playersShuffle.get(i));
  6382. + }
  6383. + }
  6384. +
  6385. + _playersShuffle = playersShuffleTemp;
  6386. + playersShuffleTemp.clear();
  6387. +
  6388. + // if (_playersShuffle.size() < (_teams.size()*2)){
  6389. + // return false;
  6390. + // }
  6391. + }
  6392. +
  6393. + return true;
  6394. + }
  6395. +
  6396. + public static void shuffleTeams()
  6397. + {
  6398. + int teamCount = 0, playersCount = 0;
  6399. +
  6400. + for (;;)
  6401. + {
  6402. + if (_playersShuffle.isEmpty())
  6403. + {
  6404. + break;
  6405. + }
  6406. +
  6407. + int playerToAddIndex = Rnd.nextInt(_playersShuffle.size());
  6408. + L2PcInstance player = null;
  6409. + player = _playersShuffle.get(playerToAddIndex);
  6410. + player._originalNameColorCTF = player.getAppearance().getNameColor();
  6411. + player._originalKarmaCTF = player.getKarma();
  6412. +
  6413. + _players.add(player);
  6414. + _players.get(playersCount)._teamNameCTF = _teams.get(teamCount);
  6415. + _savePlayers.add(_players.get(playersCount).getName());
  6416. + _savePlayerTeams.add(_teams.get(teamCount));
  6417. + playersCount++;
  6418. +
  6419. + if (teamCount == (_teams.size() - 1))
  6420. + {
  6421. + teamCount = 0;
  6422. + }
  6423. + else
  6424. + {
  6425. + teamCount++;
  6426. + }
  6427. +
  6428. + _playersShuffle.remove(playerToAddIndex);
  6429. + }
  6430. + }
  6431. +
  6432. + public static void setUserData()
  6433. + {
  6434. + for (L2PcInstance player : _players)
  6435. + {
  6436. + if (_teams.indexOf(player._teamNameCTF) == 0)
  6437. + {
  6438. + player.setTeam(2);
  6439. + player.setKarma(0);
  6440. + player.broadcastUserInfo();
  6441. + }
  6442. + else
  6443. + {
  6444. + player.setTeam(_teams.indexOf(player._teamNameCTF));
  6445. + }
  6446. + player.setKarma(0);
  6447. + player.broadcastUserInfo();
  6448. + }
  6449. + }
  6450. +
  6451. + public static void finishEvent()
  6452. + {
  6453. + if (!finishEventOk())
  6454. + {
  6455. + if (Config.DEBUG)
  6456. + {
  6457. + _log.fine("CTF Engine[finishEvent]: finishEventOk() = false");
  6458. + }
  6459. + return;
  6460. + }
  6461. +
  6462. + _started = false;
  6463. + unspawnEventNpc();
  6464. + unspawnAllFlags();
  6465. + processTopTeam();
  6466. +
  6467. + if (_topScore != 0)
  6468. + {
  6469. + playKneelAnimation(_topTeam);
  6470. + }
  6471. +
  6472. + if (Config.CTF_ANNOUNCE_TEAM_STATS)
  6473. + {
  6474. + AnnounceToPlayers(true, _eventName + " Team Statistics:");
  6475. + for (String team : _teams)
  6476. + {
  6477. + int _flags_ = teamFlagCount(team);
  6478. + AnnounceToPlayers(true, "Team: " + team + " - Flags taken: " + _flags_);
  6479. + }
  6480. + }
  6481. +
  6482. + teleportFinish();
  6483. + }
  6484. +
  6485. + // show loosers and winners animations
  6486. + public static void playKneelAnimation(String teamName)
  6487. + {
  6488. + for (L2PcInstance player : _players)
  6489. + {
  6490. + if ((player != null) && player.isOnline() && (player._inEventCTF == true))
  6491. + {
  6492. + if (!player._teamNameCTF.equals(teamName))
  6493. + {
  6494. + player.broadcastPacket(new SocialAction(player, 7));
  6495. + }
  6496. + else if (player._teamNameCTF.equals(teamName))
  6497. + {
  6498. + player.broadcastPacket(new SocialAction(player, 3));
  6499. + }
  6500. + }
  6501. + }
  6502. + }
  6503. +
  6504. + private static boolean finishEventOk()
  6505. + {
  6506. + if (!_started)
  6507. + {
  6508. + return false;
  6509. + }
  6510. +
  6511. + return true;
  6512. + }
  6513. +
  6514. + /*
  6515. + * Erro nas mensagens public static void rewardTeam(String teamName) { for (L2PcInstance player : _players) { if (player != null) { if (player._teamNameCTF.equals(teamName)) { player.addItem("CTF Event: " + _eventName, _rewardId, _rewardAmount, player, true); NpcHtmlMessage nhm = new
  6516. + * NpcHtmlMessage(0); TextBuilder replyMSG = new TextBuilder(); int count = 0; replyMSG.append("<html><body><center><font color=\"FF66OO\">PG-L][ Rare CTF Event</font><br>Your team won!<br></center>"); replyMSG.append("<center>-= <font color=\"99CC00\">Best Flag Runners</font> =-</center><br>");
  6517. + * replyMSG.append("<table width=\"200\" align=\"center\"><tr align=\"center\"><td>"); for (String team : _teams) { replyMSG.append("<font color=\"LEVEL\">" + team + "</font>"); for (L2PcInstance p : _players) { if (_playerScores.containsKey(p.getName())) { if (p._teamNameCTF.equals(team)) {
  6518. + * replyMSG.append("<br>" + ++count + ". " + p.getName() + " - " + _playerScores.get(p.getName())); } } } if (((_teams.indexOf(team) + 1) % 2) != 0) { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td><td>"); } else { if (team ==
  6519. + * _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td></tr><tr><td>"); } count = 0; } nhm.setHtml(replyMSG.toString()); player.sendPacket(nhm); // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait
  6520. + * another packet player.sendPacket(ActionFailed.STATIC_PACKET); } else { NpcHtmlMessage nhm = new NpcHtmlMessage(0); TextBuilder replyMSG = new TextBuilder(); int count = 0;
  6521. + * replyMSG.append("<html><body><center><font color=\"FF66OO\">PG-L][ Rare CTF Event</font><br>Better luck next time!<br></center>"); replyMSG.append("<center>-= <font color=\"99CC00\">Best Flag Runners</font> =-</center><br>");
  6522. + * replyMSG.append("<table width=\"200\" align=\"center\"><center><tr align=\"center\"><td>"); for (String team : _teams) { replyMSG.append("<font color=\"LEVEL\">" + team + "</font>"); for (L2PcInstance p : _players) { if (_playerScores.containsKey(p.getName())) { if
  6523. + * (p._teamNameCTF.equals(team)) { replyMSG.append("<br>" + ++count + ". " + p.getName() + " - " + _playerScores.get(p.getName())); } } } if (((_teams.indexOf(team) + 1) % 2) != 0) { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else
  6524. + * replyMSG.append("</td><td>"); } else { if (team == _teams.lastElement()) replyMSG.append("</td></tr></table></body></html>"); else replyMSG.append("</td></tr><tr><td>"); } count = 0; } nhm.setHtml(replyMSG.toString()); player.sendPacket(nhm); // Send a Server->Client ActionFailed to the
  6525. + * L2PcInstance in order to avoid that the client wait another packet player.sendPacket(ActionFailed.STATIC_PACKET); } } } }
  6526. + */
  6527. +
  6528. + public static void rewardTeam(String teamName)
  6529. + {
  6530. + for (L2PcInstance player : _players)
  6531. + {
  6532. + if (player != null)
  6533. + {
  6534. + if (player._teamNameCTF.equals(teamName))
  6535. + {
  6536. + player.addItem("CTF Event: " + _eventName, _rewardId, _rewardAmount, player, true);
  6537. +
  6538. + NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  6539. + TextBuilder replyMSG = new TextBuilder();
  6540. +
  6541. + replyMSG.append("<html><body>Your team wins the event. Look in your inventory for the reward.</body></html>");
  6542. +
  6543. + nhm.setHtml(replyMSG.toString());
  6544. + player.sendPacket(nhm);
  6545. +
  6546. + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  6547. + player.sendPacket(ActionFailed.STATIC_PACKET);
  6548. + }
  6549. + }
  6550. + }
  6551. + }
  6552. +
  6553. + public static void abortEvent()
  6554. + {
  6555. + if (!_joining && !_teleport && !_started)
  6556. + {
  6557. + GmListTable.broadcastMessageToGMs("Failed aborting CTF: No CTF instance has been started.");
  6558. + return;
  6559. + }
  6560. +
  6561. + if (_joining && !_teleport && !_started)
  6562. + {
  6563. + unspawnEventNpc();
  6564. + cleanCTF();
  6565. + _joining = false;
  6566. + AnnounceToPlayers(true, "CTF Event: Match aborted!");
  6567. + return;
  6568. + }
  6569. + _joining = false;
  6570. + _teleport = false;
  6571. + _started = false;
  6572. + unspawnEventNpc();
  6573. + unspawnAllFlags();
  6574. + teleportFinish();
  6575. + }
  6576. +
  6577. + public static void dumpData()
  6578. + {
  6579. + _log.warning("");
  6580. + _log.warning("");
  6581. +
  6582. + if (!_joining && !_teleport && !_started)
  6583. + {
  6584. + _log.warning("<<---------------------------------->>");
  6585. + _log.warning(">> CTF Engine infos dump (INACTIVE) <<");
  6586. + _log.warning("<<--^----^^-----^----^^------^^----->>");
  6587. + }
  6588. + else if (_joining && !_teleport && !_started)
  6589. + {
  6590. + _log.warning("<<--------------------------------->>");
  6591. + _log.warning(">> CTF Engine infos dump (JOINING) <<");
  6592. + _log.warning("<<--^----^^-----^----^^------^----->>");
  6593. + }
  6594. + else if (!_joining && _teleport && !_started)
  6595. + {
  6596. + _log.warning("<<---------------------------------->>");
  6597. + _log.warning(">> CTF Engine infos dump (TELEPORT) <<");
  6598. + _log.warning("<<--^----^^-----^----^^------^^----->>");
  6599. + }
  6600. + else if (!_joining && !_teleport && _started)
  6601. + {
  6602. + _log.warning("<<--------------------------------->>");
  6603. + _log.warning(">> CTF Engine infos dump (STARTED) <<");
  6604. + _log.warning("<<--^----^^-----^----^^------^----->>");
  6605. + }
  6606. +
  6607. + _log.warning("Name: " + _eventName);
  6608. + _log.warning("Desc: " + _eventDesc);
  6609. + _log.warning("Join location: " + _joiningLocationName);
  6610. + _log.warning("Min lvl: " + _minlvl);
  6611. + _log.warning("Max lvl: " + _maxlvl);
  6612. + _log.warning("");
  6613. + _log.warning("##########################");
  6614. + _log.warning("# _teams(Vector<String>) #");
  6615. + _log.warning("##########################");
  6616. +
  6617. + for (String team : _teams)
  6618. + {
  6619. + _log.warning(team + " Flags Taken :" + _teamPointsCount.get(_teams.indexOf(team)));
  6620. + }
  6621. +
  6622. + if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  6623. + {
  6624. + _log.warning("");
  6625. + _log.warning("#########################################");
  6626. + _log.warning("# _playersShuffle(Vector<L2PcInstance>) #");
  6627. + _log.warning("#########################################");
  6628. +
  6629. + for (L2PcInstance player : _playersShuffle)
  6630. + {
  6631. + if (player != null)
  6632. + {
  6633. + _log.warning("Name: " + player.getName());
  6634. + }
  6635. + }
  6636. + }
  6637. +
  6638. + _log.warning("");
  6639. + _log.warning("##################################");
  6640. + _log.warning("# _players(Vector<L2PcInstance>) #");
  6641. + _log.warning("##################################");
  6642. +
  6643. + for (L2PcInstance player : _players)
  6644. + {
  6645. + if (player != null)
  6646. + {
  6647. + _log.warning("Name: " + player.getName() + " Team: " + player._teamNameCTF + " Flags :" + player._countCTFflags);
  6648. + }
  6649. + }
  6650. +
  6651. + _log.warning("");
  6652. + _log.warning("#####################################################################");
  6653. + _log.warning("# _savePlayers(Vector<String>) and _savePlayerTeams(Vector<String>) #");
  6654. + _log.warning("#####################################################################");
  6655. +
  6656. + for (String player : _savePlayers)
  6657. + {
  6658. + _log.warning("Name: " + player + " Team: " + _savePlayerTeams.get(_savePlayers.indexOf(player)));
  6659. + }
  6660. +
  6661. + _log.warning("");
  6662. + _log.warning("");
  6663. + _log.warning("**********==CTF==************");
  6664. + _log.warning("CTF._teamPointsCount:" + _teamPointsCount.toString());
  6665. + _log.warning("CTF._flagIds:" + _flagIds.toString());
  6666. + _log.warning("CTF._flagSpawns:" + _flagSpawns.toString());
  6667. + _log.warning("CTF._throneSpawns:" + _throneSpawns.toString());
  6668. + _log.warning("CTF._flagsTaken:" + _flagsTaken.toString());
  6669. + _log.warning("CTF._flagsX:" + _flagsX.toString());
  6670. + _log.warning("CTF._flagsY:" + _flagsY.toString());
  6671. + _log.warning("CTF._flagsZ:" + _flagsZ.toString());
  6672. + _log.warning("************EOF**************");
  6673. + _log.warning("");
  6674. + }
  6675. +
  6676. + public static void loadData()
  6677. + {
  6678. + _eventName = new String();
  6679. + _eventDesc = new String();
  6680. + _topTeam = new String();
  6681. + _joiningLocationName = new String();
  6682. + _teams = new Vector<String>();
  6683. + _savePlayers = new Vector<String>();
  6684. + _savePlayerTeams = new Vector<String>();
  6685. + _players = new Vector<L2PcInstance>();
  6686. + _playersShuffle = new Vector<L2PcInstance>();
  6687. + _teamPlayersCount = new Vector<Integer>();
  6688. + _teamPointsCount = new Vector<Integer>();
  6689. + _teamColors = new Vector<Integer>();
  6690. + _teamsX = new Vector<Integer>();
  6691. + _teamsY = new Vector<Integer>();
  6692. + _teamsZ = new Vector<Integer>();
  6693. + _teamsBaseX = new Vector<Integer>();
  6694. + _teamsBaseY = new Vector<Integer>();
  6695. + _teamsBaseZ = new Vector<Integer>();
  6696. + _playerScores = new FastMap<String, Integer>();
  6697. +
  6698. + _throneSpawns = new Vector<L2Spawn>();
  6699. + _flagSpawns = new Vector<L2Spawn>();
  6700. + _flagsTaken = new Vector<Boolean>();
  6701. + _flagIds = new Vector<Integer>();
  6702. + _flagsX = new Vector<Integer>();
  6703. + _flagsY = new Vector<Integer>();
  6704. + _flagsZ = new Vector<Integer>();
  6705. + _flagsNotRemoved = new Vector<Boolean>();
  6706. +
  6707. + _joining = false;
  6708. + _teleport = false;
  6709. + _started = false;
  6710. + _sitForced = false;
  6711. + _npcId = 0;
  6712. + _npcX = 0;
  6713. + _npcY = 0;
  6714. + _npcZ = 0;
  6715. + _npcHeading = 0;
  6716. + _rewardId = 0;
  6717. + _rewardAmount = 0;
  6718. + _topScore = 0;
  6719. + _minlvl = 0;
  6720. + _maxlvl = 0;
  6721. + _joinTime = 0;
  6722. + _eventTime = 0;
  6723. + _minPlayers = 0;
  6724. + _maxPlayers = 0;
  6725. + _flagHoldTime = 0;
  6726. +
  6727. + Connection con = null;
  6728. + try
  6729. + {
  6730. + PreparedStatement statement;
  6731. + ResultSet rs;
  6732. +
  6733. + con = L2DatabaseFactory.getInstance().getConnection();
  6734. +
  6735. + statement = con.prepareStatement("Select * from ctf");
  6736. + rs = statement.executeQuery();
  6737. +
  6738. + int teams = 0;
  6739. +
  6740. + while (rs.next())
  6741. + {
  6742. + _eventName = rs.getString("eventName");
  6743. + _eventDesc = rs.getString("eventDesc");
  6744. + _joiningLocationName = rs.getString("joiningLocation");
  6745. + _minlvl = rs.getInt("minlvl");
  6746. + _maxlvl = rs.getInt("maxlvl");
  6747. + _npcId = rs.getInt("npcId");
  6748. + _npcX = rs.getInt("npcX");
  6749. + _npcY = rs.getInt("npcY");
  6750. + _npcZ = rs.getInt("npcZ");
  6751. + _npcHeading = rs.getInt("npcHeading");
  6752. + _rewardId = rs.getInt("rewardId");
  6753. + _rewardAmount = rs.getInt("rewardAmount");
  6754. + teams = rs.getInt("teamsCount");
  6755. + _joinTime = rs.getInt("joinTime");
  6756. + _eventTime = rs.getInt("eventTime");
  6757. + _minPlayers = rs.getInt("minPlayers");
  6758. + _maxPlayers = rs.getInt("maxPlayers");
  6759. + _flagHoldTime = rs.getInt("flagHoldTime");
  6760. + }
  6761. + statement.close();
  6762. +
  6763. + int index = -1;
  6764. + if (teams > 0)
  6765. + {
  6766. + index = 0;
  6767. + }
  6768. + while ((index < teams) && (index > -1))
  6769. + {
  6770. + statement = con.prepareStatement("Select * from ctf_teams where teamId = ?");
  6771. + statement.setInt(1, index);
  6772. + rs = statement.executeQuery();
  6773. + while (rs.next())
  6774. + {
  6775. + _teams.add(rs.getString("teamName"));
  6776. + _teamPlayersCount.add(0);
  6777. + _teamPointsCount.add(0);
  6778. + _teamColors.add(0);
  6779. + _teamsX.add(0);
  6780. + _teamsY.add(0);
  6781. + _teamsZ.add(0);
  6782. + _teamsX.set(index, rs.getInt("teamX"));
  6783. + _teamsY.set(index, rs.getInt("teamY"));
  6784. + _teamsZ.set(index, rs.getInt("teamZ"));
  6785. + _teamColors.set(index, rs.getInt("teamColor"));
  6786. + _flagsX.add(0);
  6787. + _flagsY.add(0);
  6788. + _flagsZ.add(0);
  6789. + _flagsX.set(index, rs.getInt("flagX"));
  6790. + _flagsY.set(index, rs.getInt("flagY"));
  6791. + _flagsZ.set(index, rs.getInt("flagZ"));
  6792. + if (Config.CTF_BASE_TELEPORT_FIRST)
  6793. + {
  6794. + _teamsBaseX.add(0);
  6795. + _teamsBaseY.add(0);
  6796. + _teamsBaseZ.add(0);
  6797. + _teamsBaseX.set(index, rs.getInt("teamBaseX"));
  6798. + _teamsBaseY.set(index, rs.getInt("teamBaseY"));
  6799. + _teamsBaseZ.set(index, rs.getInt("teamBaseZ"));
  6800. + }
  6801. + _flagSpawns.add(null);
  6802. + _flagIds.add(_FlagNPC);
  6803. + _flagsTaken.add(false);
  6804. + _flagsNotRemoved.add(false);
  6805. + }
  6806. + index++;
  6807. + statement.close();
  6808. + }
  6809. + }
  6810. + catch (Exception e)
  6811. + {
  6812. + _log.warning("Exception: CTF.loadData(): " + e.getMessage());
  6813. + }
  6814. + finally
  6815. + {
  6816. + try
  6817. + {
  6818. + if (con != null)
  6819. + {
  6820. + con.close();
  6821. + }
  6822. + }
  6823. + catch (SQLException e)
  6824. + {
  6825. + e.printStackTrace();
  6826. + }
  6827. + }
  6828. + }
  6829. +
  6830. + public static void saveData()
  6831. + {
  6832. + Connection con = null;
  6833. + try
  6834. + {
  6835. + con = L2DatabaseFactory.getInstance().getConnection();
  6836. + PreparedStatement statement;
  6837. +
  6838. + statement = con.prepareStatement("Delete from ctf");
  6839. + statement.execute();
  6840. + statement.close();
  6841. +
  6842. + statement = con.prepareStatement("INSERT INTO ctf (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers, flagHoldTime) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  6843. + statement.setString(1, _eventName);
  6844. + statement.setString(2, _eventDesc);
  6845. + statement.setString(3, _joiningLocationName);
  6846. + statement.setInt(4, _minlvl);
  6847. + statement.setInt(5, _maxlvl);
  6848. + statement.setInt(6, _npcId);
  6849. + statement.setInt(7, _npcX);
  6850. + statement.setInt(8, _npcY);
  6851. + statement.setInt(9, _npcZ);
  6852. + statement.setInt(10, _npcHeading);
  6853. + statement.setInt(11, _rewardId);
  6854. + statement.setInt(12, _rewardAmount);
  6855. + statement.setInt(13, _teams.size());
  6856. + statement.setInt(14, _joinTime);
  6857. + statement.setInt(15, _eventTime);
  6858. + statement.setInt(16, _minPlayers);
  6859. + statement.setInt(17, _maxPlayers);
  6860. + statement.setLong(18, _flagHoldTime);
  6861. + statement.execute();
  6862. + statement.close();
  6863. +
  6864. + statement = con.prepareStatement("Delete from ctf_teams");
  6865. + statement.execute();
  6866. + statement.close();
  6867. +
  6868. + for (String teamName : _teams)
  6869. + {
  6870. + int index = _teams.indexOf(teamName);
  6871. +
  6872. + if (index == -1)
  6873. + {
  6874. + return;
  6875. + }
  6876. + if (Config.CTF_BASE_TELEPORT_FIRST)
  6877. + {
  6878. + statement = con.prepareStatement("INSERT INTO ctf_teams (teamId ,teamName, teamX, teamY, teamZ, teamColor, flagX, flagY, flagZ, teamBaseX, teamBaseY, teamBaseZ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  6879. + statement.setInt(1, index);
  6880. + statement.setString(2, teamName);
  6881. + statement.setInt(3, _teamsX.get(index));
  6882. + statement.setInt(4, _teamsY.get(index));
  6883. + statement.setInt(5, _teamsZ.get(index));
  6884. + statement.setInt(6, _teamColors.get(index));
  6885. + statement.setInt(7, _flagsX.get(index));
  6886. + statement.setInt(8, _flagsY.get(index));
  6887. + statement.setInt(9, _flagsZ.get(index));
  6888. + statement.setInt(10, _teamsBaseX.get(index));
  6889. + statement.setInt(11, _teamsBaseY.get(index));
  6890. + statement.setInt(12, _teamsBaseZ.get(index));
  6891. + statement.execute();
  6892. + statement.close();
  6893. + }
  6894. + else
  6895. + {
  6896. + statement = con.prepareStatement("INSERT INTO ctf_teams (teamId ,teamName, teamX, teamY, teamZ, teamColor, flagX, flagY, flagZ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
  6897. + statement.setInt(1, index);
  6898. + statement.setString(2, teamName);
  6899. + statement.setInt(3, _teamsX.get(index));
  6900. + statement.setInt(4, _teamsY.get(index));
  6901. + statement.setInt(5, _teamsZ.get(index));
  6902. + statement.setInt(6, _teamColors.get(index));
  6903. + statement.setInt(7, _flagsX.get(index));
  6904. + statement.setInt(8, _flagsY.get(index));
  6905. + statement.setInt(9, _flagsZ.get(index));
  6906. + statement.execute();
  6907. + statement.close();
  6908. + }
  6909. + }
  6910. + }
  6911. + catch (Exception e)
  6912. + {
  6913. + _log.warning("Exception: CTF.saveData(): " + e.getMessage());
  6914. + }
  6915. + finally
  6916. + {
  6917. + try
  6918. + {
  6919. + if (con != null)
  6920. + {
  6921. + con.close();
  6922. + }
  6923. + }
  6924. + catch (SQLException e)
  6925. + {
  6926. + e.printStackTrace();
  6927. + }
  6928. + }
  6929. + }
  6930. +
  6931. + public static void showEventHtml(L2PcInstance eventPlayer, String objectId)
  6932. + {
  6933. + try
  6934. + {
  6935. + NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
  6936. + TextBuilder replyMSG = new TextBuilder();
  6937. +
  6938. + replyMSG.append("<html><body>");
  6939. + replyMSG.append("CTF Match<br><br><br>");
  6940. + replyMSG.append("Current event...<br>");
  6941. + replyMSG.append(" ... description:&nbsp;<font color=\"00FF00\">" + _eventDesc + "</font><br>");
  6942. + if (Config.CTF_ANNOUNCE_REWARD)
  6943. + {
  6944. + replyMSG.append(" ... reward: (" + _rewardAmount + ") " + ItemTable.getInstance().getTemplate(_rewardId).getName() + "<br>");
  6945. + }
  6946. +
  6947. + if (!_started && !_joining)
  6948. + {
  6949. + replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
  6950. + }
  6951. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && !checkMaxPlayers(_playersShuffle.size()))
  6952. + {
  6953. + if (!CTF._started)
  6954. + {
  6955. + replyMSG.append("<font color=\"FFFF00\">The event has reached its maximum capacity.</font><br>Keep checking, someone may crit and you can steal their spot.");
  6956. + }
  6957. + }
  6958. + else if (eventPlayer.isCursedWeaponEquipped() && !Config.CTF_JOIN_CURSED)
  6959. + {
  6960. + replyMSG.append("<font color=\"FFFF00\">You can't participate in this event with a cursed Weapon.</font><br>");
  6961. + }
  6962. + else if (!_started && _joining && (eventPlayer.getLevel() >= _minlvl) && (eventPlayer.getLevel() <= _maxlvl))
  6963. + {
  6964. + if (_players.contains(eventPlayer) || checkShufflePlayers(eventPlayer))
  6965. + {
  6966. + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
  6967. + {
  6968. + replyMSG.append("You are already participating in team <font color=\"LEVEL\">" + eventPlayer._teamNameCTF + "</font><br><br>");
  6969. + }
  6970. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  6971. + {
  6972. + replyMSG.append("You are already participating!<br><br>");
  6973. + }
  6974. +
  6975. + replyMSG.append("<table border=\"0\"><tr>");
  6976. + replyMSG.append("<td width=\"200\">Wait till event start or</td>");
  6977. + replyMSG.append("<td width=\"60\"><center><button value=\"remove\" action=\"bypass -h npc_" + objectId + "_ctf_player_leave\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></td>");
  6978. + replyMSG.append("<td width=\"100\">your participation!</td>");
  6979. + replyMSG.append("</tr></table>");
  6980. + }
  6981. + else
  6982. + {
  6983. + replyMSG.append("<td width=\"200\">Your level : <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font></td><br>");
  6984. + replyMSG.append("<td width=\"200\">Min level : <font color=\"00FF00\">" + _minlvl + "</font></td><br>");
  6985. + replyMSG.append("<td width=\"200\">Max level : <font color=\"00FF00\">" + _maxlvl + "</font></td><br><br>");
  6986. +
  6987. + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
  6988. + {
  6989. + replyMSG.append("<center><table border=\"0\">");
  6990. +
  6991. + for (String team : _teams)
  6992. + {
  6993. + replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font>&nbsp;(" + teamPlayersCount(team) + " joined)</td>");
  6994. + replyMSG.append("<td width=\"60\"><button value=\"Join\" action=\"bypass -h npc_" + objectId + "_ctf_player_join " + team + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
  6995. + }
  6996. +
  6997. + replyMSG.append("</table></center>");
  6998. + }
  6999. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  7000. + {
  7001. + replyMSG.append("<center><table border=\"0\">");
  7002. +
  7003. + for (String team : _teams)
  7004. + {
  7005. + replyMSG.append("<tr><td width=\"100\"><font color=\"LEVEL\">" + team + "</font></td>");
  7006. + }
  7007. +
  7008. + replyMSG.append("</table></center><br>");
  7009. +
  7010. + replyMSG.append("<button value=\"Join\" action=\"bypass -h npc_" + objectId + "_ctf_player_join eventShuffle\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  7011. + replyMSG.append("Teams will be randomly generated!");
  7012. + }
  7013. + }
  7014. + }
  7015. + else if (_started && !_joining)
  7016. + {
  7017. + replyMSG.append("<center>CTF match is in progress.</center>");
  7018. + }
  7019. + else if ((eventPlayer.getLevel() < _minlvl) || (eventPlayer.getLevel() > _maxlvl))
  7020. + {
  7021. + replyMSG.append("Your lvl : <font color=\"00FF00\">" + eventPlayer.getLevel() + "</font><br>");
  7022. + replyMSG.append("Min level : <font color=\"00FF00\">" + _minlvl + "</font><br>");
  7023. + replyMSG.append("Max level : <font color=\"00FF00\">" + _maxlvl + "</font><br><br>");
  7024. + replyMSG.append("<font color=\"FFFF00\">You can't participatein this event.</font><br>");
  7025. + }
  7026. + // Show how many players joined & how many are still needed to join
  7027. + replyMSG.append("<br>There are " + _playersShuffle.size() + " player(s) participating in this event.<br>");
  7028. + if (_joining)
  7029. + {
  7030. + if (_playersShuffle.size() < _minPlayers)
  7031. + {
  7032. + int playersNeeded = _minPlayers - _playersShuffle.size();
  7033. + replyMSG.append("The event will not start unless " + playersNeeded + " more player(s) joins!");
  7034. + }
  7035. + }
  7036. +
  7037. + replyMSG.append("</body></html>");
  7038. + adminReply.setHtml(replyMSG.toString());
  7039. + eventPlayer.sendPacket(adminReply);
  7040. +
  7041. + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  7042. + eventPlayer.sendPacket(ActionFailed.STATIC_PACKET);
  7043. + }
  7044. + catch (Exception e)
  7045. + {
  7046. + _log.warning("CTF Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
  7047. + }
  7048. + }
  7049. +
  7050. + public static void addPlayer(L2PcInstance player, String teamName)
  7051. + {
  7052. + if (!addPlayerOk(teamName, player))
  7053. + {
  7054. + return;
  7055. + }
  7056. +
  7057. + if (Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE"))
  7058. + {
  7059. + player._teamNameCTF = teamName;
  7060. + _players.add(player);
  7061. + setTeamPlayersCount(teamName, teamPlayersCount(teamName) + 1);
  7062. + }
  7063. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  7064. + {
  7065. + _playersShuffle.add(player);
  7066. + }
  7067. +
  7068. + player._inEventCTF = true;
  7069. + player._countCTFflags = 0;
  7070. + }
  7071. +
  7072. + public static synchronized void removeOfflinePlayers()
  7073. + {
  7074. + try
  7075. + {
  7076. + if (_playersShuffle == null)
  7077. + {
  7078. + return;
  7079. + }
  7080. + else if (_playersShuffle.isEmpty())
  7081. + {
  7082. + return;
  7083. + }
  7084. + else if (_playersShuffle.size() > 0)
  7085. + {
  7086. + for (L2PcInstance player : _playersShuffle)
  7087. + {
  7088. + if (player == null)
  7089. + {
  7090. + _playersShuffle.remove(player);
  7091. + }
  7092. + else if (!player.isOnline() || player.isInJail())
  7093. + {
  7094. + removePlayer(player);
  7095. + }
  7096. + if ((_playersShuffle.size() == 0) || _playersShuffle.isEmpty())
  7097. + {
  7098. + break;
  7099. + }
  7100. + }
  7101. + }
  7102. + }
  7103. + catch (Exception e)
  7104. + {
  7105. + _log.warning("CTF Engine exception: " + e.getMessage());
  7106. + return;
  7107. + }
  7108. + }
  7109. +
  7110. + public static boolean checkShufflePlayers(L2PcInstance eventPlayer)
  7111. + {
  7112. + try
  7113. + {
  7114. + for (L2PcInstance player : _playersShuffle)
  7115. + {
  7116. + if ((player == null) || !player.isOnline())
  7117. + {
  7118. + _playersShuffle.remove(player);
  7119. + eventPlayer._inEventCTF = false;
  7120. + continue;
  7121. + }
  7122. + else if (player.getObjectId() == eventPlayer.getObjectId())
  7123. + {
  7124. + eventPlayer._inEventCTF = true;
  7125. + eventPlayer._countCTFflags = 0;
  7126. + return true;
  7127. + }
  7128. + // this 1 is incase player got new objectid after DC or reconnect
  7129. + else if (player.getName().equals(eventPlayer.getName()))
  7130. + {
  7131. + _playersShuffle.remove(player);
  7132. + _playersShuffle.add(eventPlayer);
  7133. + eventPlayer._inEventCTF = true;
  7134. + eventPlayer._countCTFflags = 0;
  7135. + return true;
  7136. + }
  7137. + }
  7138. + }
  7139. + catch (Exception e)
  7140. + {
  7141. + }
  7142. + return false;
  7143. + }
  7144. +
  7145. + public static boolean addPlayerOk(String teamName, L2PcInstance eventPlayer)
  7146. + {
  7147. + try
  7148. + {
  7149. + if (checkShufflePlayers(eventPlayer) || eventPlayer._inEventCTF)
  7150. + {
  7151. + eventPlayer.sendMessage("You are already participating in the event!");
  7152. + return false;
  7153. + }
  7154. +
  7155. + for (L2PcInstance player : _players)
  7156. + {
  7157. + if (player.getObjectId() == eventPlayer.getObjectId())
  7158. + {
  7159. + eventPlayer.sendMessage("You are already participating in the event!");
  7160. + return false;
  7161. + }
  7162. + else if (player.getName() == eventPlayer.getName())
  7163. + {
  7164. + eventPlayer.sendMessage("You are already participating in the event!");
  7165. + return false;
  7166. + }
  7167. + }
  7168. + if (_players.contains(eventPlayer))
  7169. + {
  7170. + eventPlayer.sendMessage("You are already participating in the event!");
  7171. + return false;
  7172. + }
  7173. + }
  7174. + catch (Exception e)
  7175. + {
  7176. + _log.warning("CTF Siege Engine exception: " + e.getMessage());
  7177. + }
  7178. +
  7179. + if (Config.CTF_EVEN_TEAMS.equals("NO"))
  7180. + {
  7181. + return true;
  7182. + }
  7183. + else if (Config.CTF_EVEN_TEAMS.equals("BALANCE"))
  7184. + {
  7185. + boolean allTeamsEqual = true;
  7186. + int countBefore = -1;
  7187. +
  7188. + for (int playersCount : _teamPlayersCount)
  7189. + {
  7190. + if (countBefore == -1)
  7191. + {
  7192. + countBefore = playersCount;
  7193. + }
  7194. +
  7195. + if (countBefore != playersCount)
  7196. + {
  7197. + allTeamsEqual = false;
  7198. + break;
  7199. + }
  7200. +
  7201. + countBefore = playersCount;
  7202. + }
  7203. +
  7204. + if (allTeamsEqual)
  7205. + {
  7206. + return true;
  7207. + }
  7208. +
  7209. + countBefore = Integer.MAX_VALUE;
  7210. +
  7211. + for (int teamPlayerCount : _teamPlayersCount)
  7212. + {
  7213. + if (teamPlayerCount < countBefore)
  7214. + {
  7215. + countBefore = teamPlayerCount;
  7216. + }
  7217. + }
  7218. +
  7219. + Vector<String> joinableTeams = new Vector<String>();
  7220. +
  7221. + for (String team : _teams)
  7222. + {
  7223. + if (teamPlayersCount(team) == countBefore)
  7224. + {
  7225. + joinableTeams.add(team);
  7226. + }
  7227. + }
  7228. +
  7229. + if (joinableTeams.contains(teamName))
  7230. + {
  7231. + return true;
  7232. + }
  7233. + }
  7234. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE"))
  7235. + {
  7236. + return true;
  7237. + }
  7238. +
  7239. + eventPlayer.sendMessage("Too many players in team \"" + teamName + "\"");
  7240. + return false;
  7241. + }
  7242. +
  7243. + public static synchronized void addDisconnectedPlayer(L2PcInstance player)
  7244. + {
  7245. + /*
  7246. + * !!! CAUTION !!! Do NOT fix multiple object Ids on this event or you will ruin the flag reposition check!!! All Multiple object Ids will be collected by the Garbage Collector, after the event ends, memory sweep is made!!!
  7247. + */
  7248. +
  7249. + if ((Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && (_teleport || _started)) || (Config.CTF_EVEN_TEAMS.equals("NO") || (Config.CTF_EVEN_TEAMS.equals("BALANCE") && (_teleport || _started))))
  7250. + {
  7251. + if (Config.CTF_ON_START_REMOVE_ALL_EFFECTS)
  7252. + {
  7253. + for (L2Effect e : player.getAllEffects())
  7254. + {
  7255. + if (e != null)
  7256. + {
  7257. + e.exit();
  7258. + }
  7259. + }
  7260. + }
  7261. +
  7262. + player._teamNameCTF = _savePlayerTeams.get(_savePlayers.indexOf(player.getName()));
  7263. + for (L2PcInstance p : _players)
  7264. + {
  7265. + if (p == null)
  7266. + {
  7267. + continue;
  7268. + }
  7269. + // check by name incase player got new objectId
  7270. + else if (p.getName().equals(player.getName()))
  7271. + {
  7272. + player._originalNameColorCTF = player.getAppearance().getNameColor();
  7273. + player._originalKarmaCTF = player.getKarma();
  7274. + player._inEventCTF = true;
  7275. + player._countCTFflags = p._countCTFflags;
  7276. + _players.remove(p); // removing old object id from vector
  7277. + _players.add(player); // adding new objectId to vector
  7278. + break;
  7279. + }
  7280. + }
  7281. + player.setTeam(_teams.indexOf(player._teamNameCTF));
  7282. + player.setKarma(0);
  7283. + player.broadcastUserInfo();
  7284. + if (Config.CTF_BASE_TELEPORT_FIRST)
  7285. + {
  7286. + player.sendMessage("We missed you! You will be sent back into battle in 10 seconds!");
  7287. +
  7288. + player.teleToLocation(_teamsBaseX.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseY.get(_teams.indexOf(player._teamNameCTF)), _teamsBaseZ.get(_teams.indexOf(player._teamNameCTF)));
  7289. +
  7290. + ThreadPoolManager.getInstance().scheduleGeneral(new BaseTeleportTask(player, false), 10000);
  7291. + }
  7292. + else
  7293. + {
  7294. + player.teleToLocation(_teamsX.get(_teams.indexOf(player._teamNameCTF)), _teamsY.get(_teams.indexOf(player._teamNameCTF)), _teamsZ.get(_teams.indexOf(player._teamNameCTF)));
  7295. + }
  7296. + Started(player);
  7297. + CheckRestoreFlags();
  7298. + }
  7299. + }
  7300. +
  7301. + public static void removePlayer(L2PcInstance player)
  7302. + {
  7303. + if (player._inEventCTF)
  7304. + {
  7305. + if (!_joining)
  7306. + {
  7307. + player.getAppearance().setNameColor(player._originalNameColorCTF);
  7308. + player.setKarma(player._originalKarmaCTF);
  7309. + player.broadcastUserInfo();
  7310. + }
  7311. + player._teamNameCTF = new String();
  7312. + player._countCTFflags = 0;
  7313. + player._inEventCTF = false;
  7314. +
  7315. + if ((Config.CTF_EVEN_TEAMS.equals("NO") || Config.CTF_EVEN_TEAMS.equals("BALANCE")) && _players.contains(player))
  7316. + {
  7317. + setTeamPlayersCount(player._teamNameCTF, teamPlayersCount(player._teamNameCTF) - 1);
  7318. + _players.remove(player);
  7319. + }
  7320. + else if (Config.CTF_EVEN_TEAMS.equals("SHUFFLE") && (!_playersShuffle.isEmpty() && _playersShuffle.contains(player)))
  7321. + {
  7322. + _playersShuffle.remove(player);
  7323. + }
  7324. + }
  7325. + }
  7326. +
  7327. + public static void cleanCTFEvent()
  7328. + {
  7329. + _log.warning("CTF : Cleaning players.");
  7330. + for (L2PcInstance player : _players)
  7331. + {
  7332. + if (player != null)
  7333. + {
  7334. + if (player._haveFlagCTF)
  7335. + {
  7336. + removeFlagFromPlayer(player);
  7337. + }
  7338. + else
  7339. + {
  7340. + player.getInventory().destroyItemByItemId("", CTF._FLAG_IN_HAND_ITEM_ID, 1, player, null);
  7341. + }
  7342. + player._haveFlagCTF = false;
  7343. + removePlayer(player);
  7344. + if (_savePlayers.contains(player.getName()))
  7345. + {
  7346. + _savePlayers.remove(player.getName());
  7347. + }
  7348. + player._inEventCTF = false;
  7349. + }
  7350. + }
  7351. + if ((_playersShuffle != null) && !_playersShuffle.isEmpty())
  7352. + {
  7353. + for (L2PcInstance player : _playersShuffle)
  7354. + {
  7355. + if (player != null)
  7356. + {
  7357. + player._inEventCTF = false;
  7358. + }
  7359. + }
  7360. + }
  7361. + _log.warning("CTF : Cleaning teams and flags.");
  7362. + for (String team : _teams)
  7363. + {
  7364. + int index = _teams.indexOf(team);
  7365. + _teamPointsCount.set(index, 0);
  7366. + _flagSpawns.set(index, null);
  7367. + _flagsTaken.set(index, false);
  7368. + _teamPlayersCount.set(index, 0);
  7369. + _teamPointsCount.set(index, 0);
  7370. + _flagsNotRemoved.set(index, false);
  7371. + }
  7372. + _topScore = 0;
  7373. + _topTeam = new String();
  7374. + _players = new Vector<L2PcInstance>();
  7375. + _playersShuffle = new Vector<L2PcInstance>();
  7376. + _savePlayers = new Vector<String>();
  7377. + _savePlayerTeams = new Vector<String>();
  7378. + _teamPointsCount = new Vector<Integer>();
  7379. + _flagSpawns = new Vector<L2Spawn>();
  7380. + _flagsTaken = new Vector<Boolean>();
  7381. + _teamPlayersCount = new Vector<Integer>();
  7382. + _flagsNotRemoved = new Vector<Boolean>();
  7383. + _playerScores = new FastMap<String, Integer>();
  7384. + _log.warning("Cleaning CTF done.");
  7385. + _log.warning("Loading new data from MySql");
  7386. + loadData();
  7387. + }
  7388. +
  7389. + public static void unspawnEventNpc()
  7390. + {
  7391. + if (_npcSpawn == null)
  7392. + {
  7393. + return;
  7394. + }
  7395. +
  7396. + _npcSpawn.getLastSpawn().deleteMe();
  7397. + _npcSpawn.stopRespawn();
  7398. + SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
  7399. + }
  7400. +
  7401. + public static void teleportFinish()
  7402. + {
  7403. + AnnounceToPlayers(false, "CTF Event: Teleport back to participation NPC in 15 seconds!");
  7404. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  7405. + {
  7406. + @Override
  7407. + public void run()
  7408. + {
  7409. + for (L2PcInstance player : _players)
  7410. + {
  7411. + if (player != null)
  7412. + {
  7413. + if (player.isOnline())
  7414. + {
  7415. + player.setTeam(0);
  7416. + player.broadcastUserInfo();
  7417. + player.teleToLocation(_npcX, _npcY, _npcZ, false);
  7418. + }
  7419. +
  7420. + else
  7421. + {
  7422. + Connection con = null;
  7423. + try
  7424. + {
  7425. + con = L2DatabaseFactory.getInstance().getConnection();
  7426. +
  7427. + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
  7428. + statement.setInt(1, _npcX);
  7429. + statement.setInt(2, _npcY);
  7430. + statement.setInt(3, _npcZ);
  7431. + statement.setString(4, player.getName());
  7432. + statement.execute();
  7433. + statement.close();
  7434. + }
  7435. + catch (SQLException se)
  7436. + {
  7437. + _log.warning("CTF Engine exception: " + se.getMessage());
  7438. + }
  7439. + finally
  7440. + {
  7441. + try
  7442. + {
  7443. + if (con != null)
  7444. + {
  7445. + con.close();
  7446. + }
  7447. + }
  7448. + catch (SQLException e)
  7449. + {
  7450. + e.printStackTrace();
  7451. + }
  7452. + }
  7453. + }
  7454. + }
  7455. + }
  7456. + cleanCTFEvent();
  7457. + }
  7458. + }, 15000);
  7459. + }
  7460. +
  7461. + public static int teamFlagCount(String teamName)
  7462. + {
  7463. + int index = _teams.indexOf(teamName);
  7464. +
  7465. + if (index == -1)
  7466. + {
  7467. + return -1;
  7468. + }
  7469. +
  7470. + return _teamPointsCount.get(index);
  7471. + }
  7472. +
  7473. + public static void setTeamFlagCount(String teamName, int teamFlagCount)
  7474. + {
  7475. + int index = _teams.indexOf(teamName);
  7476. +
  7477. + if (index == -1)
  7478. + {
  7479. + return;
  7480. + }
  7481. +
  7482. + _teamPointsCount.set(index, teamFlagCount);
  7483. + }
  7484. +
  7485. + /**
  7486. + * Used to calculate the event CTF area, so that players don't run off with the flag. Essential, since a player may take the flag just so other teams can't score points. This function is Only called upon ONE time on BEGINING OF EACH EVENT right after we spawn the flags.
  7487. + */
  7488. + private static void calculateOutSideOfCTFEvent()
  7489. + {
  7490. + if ((_teams == null) || (_flagSpawns == null) || (_teamsX == null) || (_teamsY == null) || (_teamsZ == null))
  7491. + {
  7492. + return;
  7493. + }
  7494. +
  7495. + int division = _teams.size() * 2, pos = 0;
  7496. + int[] locX = new int[division], locY = new int[division], locZ = new int[division];
  7497. + // Get all coordinates inorder to create a polygon:
  7498. + for (L2Spawn flag : _flagSpawns)
  7499. + {
  7500. + locX[pos] = flag.getLocx();
  7501. + locY[pos] = flag.getLocy();
  7502. + locZ[pos] = flag.getLocz();
  7503. + pos++;
  7504. + if (pos > (division / 2))
  7505. + {
  7506. + break;
  7507. + }
  7508. + }
  7509. +
  7510. + for (int x = 0; x < _teams.size(); x++)
  7511. + {
  7512. + locX[pos] = _teamsX.get(x);
  7513. + locY[pos] = _teamsY.get(x);
  7514. + locZ[pos] = _teamsZ.get(x);
  7515. + pos++;
  7516. + if (pos > division)
  7517. + {
  7518. + break;
  7519. + }
  7520. + }
  7521. +
  7522. + // find the polygon center, note that it's not the mathematical center of the polygon,
  7523. + // rather than a point which centers all coordinates:
  7524. + int centerX = 0, centerY = 0, centerZ = 0;
  7525. + for (int x = 0; x < pos; x++)
  7526. + {
  7527. + centerX += (locX[x] / division);
  7528. + centerY += (locY[x] / division);
  7529. + centerZ += (locZ[x] / division);
  7530. + }
  7531. +
  7532. + // now let's find the furthest distance from the "center" to the egg shaped sphere
  7533. + // surrounding the polygon, size x1.5 (for maximum logical area to wander...):
  7534. + int maxX = 0, maxY = 0, maxZ = 0;
  7535. + for (int x = 0; x < pos; x++)
  7536. + {
  7537. + if (maxX < (2 * Math.abs(centerX - locX[x])))
  7538. + {
  7539. + maxX = (2 * Math.abs(centerX - locX[x]));
  7540. + }
  7541. + if (maxY < (2 * Math.abs(centerY - locY[x])))
  7542. + {
  7543. + maxY = (2 * Math.abs(centerY - locY[x]));
  7544. + }
  7545. + if (maxZ < (2 * Math.abs(centerZ - locZ[x])))
  7546. + {
  7547. + maxZ = (2 * Math.abs(centerZ - locZ[x]));
  7548. + }
  7549. + }
  7550. +
  7551. + // centerX,centerY,centerZ are the coordinates of the "event center".
  7552. + // so let's save those coordinates to check on the players:
  7553. + eventCenterX = centerX;
  7554. + eventCenterY = centerY;
  7555. + eventCenterZ = centerZ;
  7556. + eventOffset = maxX;
  7557. + if (eventOffset < maxY)
  7558. + {
  7559. + eventOffset = maxY;
  7560. + }
  7561. + if (eventOffset < maxZ)
  7562. + {
  7563. + eventOffset = maxZ;
  7564. + }
  7565. + }
  7566. +
  7567. + public static boolean isOutsideCTFArea(L2PcInstance _player)
  7568. + {
  7569. + if ((_player == null) || !_player.isOnline())
  7570. + {
  7571. + return true;
  7572. + }
  7573. + if (!((_player.getX() > (eventCenterX - eventOffset)) && (_player.getX() < (eventCenterX + eventOffset)) && (_player.getY() > (eventCenterY - eventOffset)) && (_player.getY() < (eventCenterY + eventOffset)) && (_player.getZ() > (eventCenterZ - eventOffset)) && (_player.getZ() < (eventCenterZ + eventOffset))))
  7574. + {
  7575. + return true;
  7576. + }
  7577. + return false;
  7578. + }
  7579. +
  7580. + @SuppressWarnings("synthetic-access")
  7581. + private static class SingletonHolder
  7582. + {
  7583. + protected static final CTFEvent _instance = new CTFEvent();
  7584. + }
  7585. +
  7586. + /**
  7587. + * @return
  7588. + */
  7589. + public static boolean isStarted()
  7590. + {
  7591. + // TODO Auto-generated method stub
  7592. + return false;
  7593. + }
  7594. +
  7595. + /**
  7596. + * @return
  7597. + */
  7598. + public static int getCTFEventInstance()
  7599. + {
  7600. + // TODO Auto-generated method stub
  7601. + return 0;
  7602. + }
  7603. +
  7604. + /**
  7605. + * @param objectId
  7606. + * @return
  7607. + */
  7608. + public static int getParticipantTeamId(int objectId)
  7609. + {
  7610. + // TODO Auto-generated method stub
  7611. + return 0;
  7612. + }
  7613. +
  7614. + /**
  7615. + *
  7616. + */
  7617. + public static void init()
  7618. + {
  7619. + // TODO Auto-generated method stub
  7620. +
  7621. + }
  7622. +
  7623. + /**
  7624. + * @return
  7625. + */
  7626. + public static boolean startParticipation()
  7627. + {
  7628. + // TODO Auto-generated method stub
  7629. + return false;
  7630. + }
  7631. +
  7632. + /**
  7633. + * @return
  7634. + */
  7635. + public static boolean startFight()
  7636. + {
  7637. + // TODO Auto-generated method stub
  7638. + return false;
  7639. + }
  7640. +
  7641. + /**
  7642. + * @param string
  7643. + */
  7644. + public static void sysMsgToAllParticipants(String string)
  7645. + {
  7646. + // TODO Auto-generated method stub
  7647. +
  7648. + }
  7649. +
  7650. + /**
  7651. + * @return
  7652. + */
  7653. + public static String calculateRewards()
  7654. + {
  7655. + // TODO Auto-generated method stub
  7656. + return null;
  7657. + }
  7658. +
  7659. + /**
  7660. + *
  7661. + */
  7662. + public static void stopFight()
  7663. + {
  7664. + // TODO Auto-generated method stub
  7665. +
  7666. + }
  7667. +
  7668. + /**
  7669. + * @return
  7670. + */
  7671. + public static boolean isInactive()
  7672. + {
  7673. + // TODO Auto-generated method stub
  7674. + return false;
  7675. + }
  7676. +
  7677. + /**
  7678. + * @return
  7679. + */
  7680. + public static boolean isParticipating()
  7681. + {
  7682. + // TODO Auto-generated method stub
  7683. + return false;
  7684. + }
  7685. +
  7686. + /**
  7687. + * @param objectId
  7688. + * @return
  7689. + */
  7690. + public static boolean isPlayerParticipant(int objectId)
  7691. + {
  7692. + // TODO Auto-generated method stub
  7693. + return false;
  7694. + }
  7695. +
  7696. + /**
  7697. + * @param player
  7698. + * @param targetPlayer
  7699. + * @param skill
  7700. + * @return
  7701. + */
  7702. + public static boolean checkForCTFSkill(L2PcInstance player, L2PcInstance targetPlayer, L2Skill skill)
  7703. + {
  7704. + // TODO Auto-generated method stub
  7705. + return false;
  7706. + }
  7707. +
  7708. + /**
  7709. + * @param objectId
  7710. + * @return
  7711. + */
  7712. + public static boolean onItemSummon(int objectId)
  7713. + {
  7714. + // TODO Auto-generated method stub
  7715. + return false;
  7716. + }
  7717. +
  7718. + /**
  7719. + * @param objectId
  7720. + * @return
  7721. + */
  7722. + public static boolean onEscapeUse(int objectId)
  7723. + {
  7724. + // TODO Auto-generated method stub
  7725. + return false;
  7726. + }
  7727. +
  7728. + /**
  7729. + * @param activeChar
  7730. + */
  7731. + public static void onLogin(L2PcInstance activeChar)
  7732. + {
  7733. + // TODO Auto-generated method stub
  7734. +
  7735. + }
  7736. +
  7737. + /**
  7738. + * @param objectId
  7739. + * @return
  7740. + */
  7741. + public static CTFEventTeam getParticipantEnemyTeam(int objectId)
  7742. + {
  7743. + // TODO Auto-generated method stub
  7744. + return null;
  7745. + }
  7746. +
  7747. + /**
  7748. + * @param killer
  7749. + * @param l2PcInstance
  7750. + */
  7751. + public static void onKill(L2Character killer, L2PcInstance l2PcInstance)
  7752. + {
  7753. + // TODO Auto-generated method stub
  7754. +
  7755. + }
  7756. +
  7757. + /**
  7758. + * @param l2PcInstance
  7759. + */
  7760. + public static void onTeleported(L2PcInstance l2PcInstance)
  7761. + {
  7762. + // TODO Auto-generated method stub
  7763. +
  7764. + }
  7765. +
  7766. + /**
  7767. + * @param l2PcInstance
  7768. + */
  7769. + public static void onLogout(L2PcInstance l2PcInstance)
  7770. + {
  7771. + // TODO Auto-generated method stub
  7772. +
  7773. + }
  7774. +
  7775. + /**
  7776. + * @param objectId
  7777. + */
  7778. + public static void removeParticipant(int objectId)
  7779. + {
  7780. + // TODO Auto-generated method stub
  7781. +
  7782. + }
  7783. +}
  7784. Index: java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java
  7785. ===================================================================
  7786. --- java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java (revision 0)
  7787. +++ java/com/l2jserver/gameserver/model/actor/instance/L2DMEventNpcInstance.java (working copy)
  7788. @@ -0,0 +1,100 @@
  7789. +/*
  7790. + * This program is free software: you can redistribute it and/or modify it under
  7791. + * the terms of the GNU General Public License as published by the Free Software
  7792. + * Foundation, either version 3 of the License, or (at your option) any later
  7793. + * version.
  7794. + *
  7795. + * This program is distributed in the hope that it will be useful, but WITHOUT
  7796. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7797. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  7798. + * details.
  7799. + *
  7800. + * You should have received a copy of the GNU General Public License along with
  7801. + * this program. If not, see <http://www.gnu.org/licenses/>.
  7802. + */
  7803. +
  7804. +package com.l2jserver.gameserver.model.actor.instance;
  7805. +
  7806. +import com.l2jserver.Config;
  7807. +import com.l2jserver.gameserver.cache.HtmCache;
  7808. +import com.l2jserver.gameserver.model.actor.L2Npc;
  7809. +import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  7810. +import com.l2jserver.gameserver.model.entity.DMEvent;
  7811. +import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  7812. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  7813. +
  7814. +public class L2DMEventNpcInstance extends L2Npc
  7815. +{
  7816. + private static final String htmlPath="data/html/mods/DMEvent/";
  7817. +
  7818. + public L2DMEventNpcInstance(int objectId, L2NpcTemplate template)
  7819. + {
  7820. + super(objectId, template);
  7821. + setInstanceType(InstanceType.L2DMEventNpcInstance);
  7822. + }
  7823. +
  7824. + @Override
  7825. + public void onBypassFeedback(L2PcInstance playerInstance, String command)
  7826. + {
  7827. + DMEvent.onBypass(command, playerInstance);
  7828. + }
  7829. +
  7830. + @Override
  7831. + public void showChatWindow(L2PcInstance playerInstance, int val)
  7832. + {
  7833. + if (playerInstance == null)
  7834. + return;
  7835. +
  7836. + if (DMEvent.isParticipating())
  7837. + {
  7838. + final boolean isParticipant = DMEvent.isPlayerParticipant(playerInstance.getObjectId());
  7839. + final String htmContent;
  7840. +
  7841. + if (!isParticipant)
  7842. + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Participation.htm");
  7843. + else
  7844. + htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "RemoveParticipation.htm");
  7845. +
  7846. + if (htmContent != null)
  7847. + {
  7848. + int[] teamsPlayerCounts = DMEvent.getTeamsPlayerCounts();
  7849. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  7850. +
  7851. + npcHtmlMessage.setHtml(htmContent);
  7852. + npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  7853. + npcHtmlMessage.replace("%team1name%", Config.DM_EVENT_TEAM_1_NAME);
  7854. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  7855. + npcHtmlMessage.replace("%team2name%", Config.DM_EVENT_TEAM_2_NAME);
  7856. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  7857. + npcHtmlMessage.replace("%playercount%", String.valueOf(teamsPlayerCounts[0]+teamsPlayerCounts[1]));
  7858. + if (!isParticipant)
  7859. + npcHtmlMessage.replace("%fee%", DMEvent.getParticipationFee());
  7860. +
  7861. + playerInstance.sendPacket(npcHtmlMessage);
  7862. + }
  7863. + }
  7864. + else if (DMEvent.isStarting() || DMEvent.isStarted())
  7865. + {
  7866. + final String htmContent = HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Status.htm");
  7867. +
  7868. + if (htmContent != null)
  7869. + {
  7870. + int[] teamsPlayerCounts = DMEvent.getTeamsPlayerCounts();
  7871. + int[] teamsPointsCounts = DMEvent.getTeamsPoints();
  7872. + NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());
  7873. +
  7874. + npcHtmlMessage.setHtml(htmContent);
  7875. + //npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));
  7876. + npcHtmlMessage.replace("%team1name%", Config.DM_EVENT_TEAM_1_NAME);
  7877. + npcHtmlMessage.replace("%team1playercount%", String.valueOf(teamsPlayerCounts[0]));
  7878. + npcHtmlMessage.replace("%team1points%", String.valueOf(teamsPointsCounts[0]));
  7879. + npcHtmlMessage.replace("%team2name%", Config.DM_EVENT_TEAM_2_NAME);
  7880. + npcHtmlMessage.replace("%team2playercount%", String.valueOf(teamsPlayerCounts[1]));
  7881. + npcHtmlMessage.replace("%team2points%", String.valueOf(teamsPointsCounts[1])); // <---- array index from 0 to 1 thx DaRkRaGe
  7882. + playerInstance.sendPacket(npcHtmlMessage);
  7883. + }
  7884. + }
  7885. +
  7886. + playerInstance.sendPacket(ActionFailed.STATIC_PACKET);
  7887. + }
  7888. +}
  7889. Index: java/com/l2jserver/gameserver/model/L2Object.java
  7890. ===================================================================
  7891. --- java/com/l2jserver/gameserver/model/L2Object.java (revision 65)
  7892. +++ java/com/l2jserver/gameserver/model/L2Object.java (working copy)
  7893. @@ -173,6 +173,8 @@
  7894. L2ClanHallDoormenInstance(L2DoormenInstance),
  7895. // Custom
  7896. L2ClassMasterInstance(L2NpcInstance),
  7897. + L2CTFEventNpcInstance(L2Npc),
  7898. + L2DMEventNpcInstance(L2Npc),
  7899. L2NpcBufferInstance(L2Npc),
  7900. L2TvTEventNpcInstance(L2Npc),
  7901. L2TvTRoundEventNpcInstance(L2Npc),
  7902. Index: java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java
  7903. ===================================================================
  7904. --- java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java (revision 0)
  7905. +++ java/com/l2jserver/gameserver/model/entity/DMEventTeleporter.java (working copy)
  7906. @@ -0,0 +1,115 @@
  7907. +/*
  7908. + * This program is free software: you can redistribute it and/or modify it under
  7909. + * the terms of the GNU General Public License as published by the Free Software
  7910. + * Foundation, either version 3 of the License, or (at your option) any later
  7911. + * version.
  7912. + *
  7913. + * This program is distributed in the hope that it will be useful, but WITHOUT
  7914. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  7915. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  7916. + * details.
  7917. + *
  7918. + * You should have received a copy of the GNU General Public License along with
  7919. + * this program. If not, see <http://www.gnu.org/licenses/>.
  7920. + */
  7921. +
  7922. +package com.l2jserver.gameserver.model.entity;
  7923. +
  7924. +import com.l2jserver.Config;
  7925. +import com.l2jserver.gameserver.ThreadPoolManager;
  7926. +import com.l2jserver.gameserver.model.actor.L2Summon;
  7927. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  7928. +import com.l2jserver.util.Rnd;
  7929. +
  7930. +/**
  7931. + * @author FBIagent, edited U3Games
  7932. + */
  7933. +
  7934. +public class DMEventTeleporter implements Runnable
  7935. +{
  7936. + /** The instance of the player to teleport */
  7937. + private L2PcInstance _activeChar = null;
  7938. + /** Coordinates of the spot to teleport to */
  7939. + private int[] _coordinates = new int[3];
  7940. + /** Admin removed this player from event */
  7941. + private boolean _adminRemove = false;
  7942. +
  7943. + /**
  7944. + * Initialize the teleporter and start the delayed task.
  7945. + * @param activeChar
  7946. + * @param coordinates
  7947. + * @param fastSchedule
  7948. + * @param adminRemove
  7949. + */
  7950. + public DMEventTeleporter(L2PcInstance activeChar, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  7951. + {
  7952. + _activeChar = activeChar;
  7953. + _coordinates = coordinates;
  7954. + _adminRemove = adminRemove;
  7955. +
  7956. + long delay = (DMEvent.isStarted() ? Config.DM_EVENT_RESPAWN_TELEPORT_DELAY : Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
  7957. +
  7958. + ThreadPoolManager.getInstance().scheduleGeneral(this, fastSchedule ? 0 : delay);
  7959. + }
  7960. +
  7961. + /**
  7962. + * The task method to teleport the player<br>
  7963. + * 1. Unsummon pet if there is one<br>
  7964. + * 2. Remove all effects<br>
  7965. + * 3. Revive and full heal the player<br>
  7966. + * 4. Teleport the player<br>
  7967. + * 5. Broadcast status and user info<br><br>
  7968. + *
  7969. + * @see java.lang.Runnable#run()
  7970. + */
  7971. + public void run()
  7972. + {
  7973. + if (_activeChar == null)
  7974. + return;
  7975. +
  7976. + L2Summon summon = _activeChar.getPet();
  7977. +
  7978. + if (summon != null)
  7979. + summon.unSummon(_activeChar);
  7980. +
  7981. + if (Config.DM_EVENT_EFFECTS_REMOVAL == 0
  7982. + || (Config.DM_EVENT_EFFECTS_REMOVAL == 1 && (_activeChar.getTeam() == 0 || (_activeChar.isInDuel() && _activeChar.getDuelState() != Duel.DUELSTATE_INTERRUPTED))))
  7983. + _activeChar.stopAllEffectsExceptThoseThatLastThroughDeath();
  7984. +
  7985. + if (_activeChar.isInDuel())
  7986. + _activeChar.setDuelState(Duel.DUELSTATE_INTERRUPTED);
  7987. +
  7988. + int DMInstance = DMEvent.getDMEventInstance();
  7989. + if (DMInstance != 0)
  7990. + {
  7991. + if (DMEvent.isStarted() && !_adminRemove)
  7992. + {
  7993. + _activeChar.setInstanceId(DMInstance);
  7994. + }
  7995. + else
  7996. + {
  7997. + _activeChar.setInstanceId(0);
  7998. + }
  7999. + }
  8000. + else
  8001. + {
  8002. + _activeChar.setInstanceId(0);
  8003. + }
  8004. +
  8005. + _activeChar.doRevive();
  8006. +
  8007. + _activeChar.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
  8008. +
  8009. + if (DMEvent.isStarted() && !_adminRemove)
  8010. + _activeChar.setTeam(DMEvent.getParticipantTeamId(_activeChar.getObjectId()) + 1);
  8011. + else
  8012. + _activeChar.setTeam(0);
  8013. +
  8014. + _activeChar.setCurrentCp(_activeChar.getMaxCp());
  8015. + _activeChar.setCurrentHp(_activeChar.getMaxHp());
  8016. + _activeChar.setCurrentMp(_activeChar.getMaxMp());
  8017. +
  8018. + _activeChar.broadcastStatusUpdate();
  8019. + _activeChar.broadcastUserInfo();
  8020. + }
  8021. +}
  8022. Index: java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java
  8023. ===================================================================
  8024. --- java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java (revision 65)
  8025. +++ java/com/l2jserver/gameserver/instancemanager/HandysBlockCheckerManager.java (working copy)
  8026. @@ -23,6 +23,8 @@
  8027. import com.l2jserver.gameserver.ThreadPoolManager;
  8028. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  8029. import com.l2jserver.gameserver.model.entity.BlockCheckerEngine;
  8030. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  8031. +import com.l2jserver.gameserver.model.entity.DMEvent;
  8032. import com.l2jserver.gameserver.model.entity.TvTEvent;
  8033. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  8034. import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
  8035. @@ -40,7 +42,7 @@
  8036. * as the clearance of the participants list or liberate the arena.
  8037. * @author BiggBoss
  8038. */
  8039. -public final class HandysBlockCheckerManager
  8040. +public final class HandysBlockCheckerManager
  8041. {
  8042. // All the participants and their team classified by arena
  8043. private static final ArenaParticipantsHolder[] _arenaPlayers = new ArenaParticipantsHolder[4];
  8044. @@ -100,7 +102,7 @@
  8045. {
  8046. _arenaVotes.put(arena, 0);
  8047. }
  8048. -
  8049. +
  8050. protected HandysBlockCheckerManager()
  8051. {
  8052. // Initialize arena status
  8053. @@ -119,7 +121,7 @@
  8054. {
  8055. return _arenaPlayers[arena];
  8056. }
  8057. -
  8058. +
  8059. /**
  8060. * Initializes the participants holder
  8061. */
  8062. @@ -135,7 +137,7 @@
  8063. * Add the player to the specified arena (through the specified arena manager) and send the needed server -> client packets
  8064. * @param player
  8065. * @param arenaId
  8066. - * @return
  8067. + * @return
  8068. */
  8069. public boolean addPlayerToArena(L2PcInstance player, int arenaId)
  8070. {
  8071. @@ -155,23 +157,35 @@
  8072. return false;
  8073. }
  8074. }
  8075. -
  8076. +
  8077. if (player.isCursedWeaponEquipped())
  8078. {
  8079. player.sendPacket(SystemMessageId.CANNOT_REGISTER_PROCESSING_CURSED_WEAPON);
  8080. return false;
  8081. }
  8082.  
  8083. + if (CTFEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
  8084. + {
  8085. + player.sendMessage("Couldnt register you due other event participation");
  8086. + return false;
  8087. + }
  8088. +
  8089. + if (DMEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
  8090. + {
  8091. + player.sendMessage("Couldnt register you due other event participation");
  8092. + return false;
  8093. + }
  8094. +
  8095. if (TvTEvent.isPlayerParticipant(player.getObjectId()) || TvTRoundEvent.isPlayerParticipant(player.getObjectId()) || player.isInOlympiadMode())
  8096. {
  8097. player.sendMessage("Couldnt register you due other event participation");
  8098. return false;
  8099. }
  8100. -
  8101. +
  8102. if (OlympiadManager.getInstance().isRegistered(player))
  8103. {
  8104. OlympiadManager.getInstance().unRegisterNoble(player);
  8105. - player.sendPacket(SystemMessageId.COLISEUM_OLYMPIAD_KRATEIS_APPLICANTS_CANNOT_PARTICIPATE);
  8106. + player.sendPacket(SystemMessageId.COLISEUM_OLYMPIAD_KRATEIS_APPLICANTS_CANNOT_PARTICIPATE);
  8107. }
  8108.  
  8109. // if(UnderGroundColiseum.getInstance().isRegisteredPlayer(player))
  8110. @@ -210,7 +224,7 @@
  8111. * Will remove the specified player from the specified team and arena and will send the needed packet to all his team mates / enemy team mates
  8112. * @param player
  8113. * @param arenaId
  8114. - * @param team
  8115. + * @param team
  8116. */
  8117. public void removePlayer(L2PcInstance player, int arenaId, int team)
  8118. {
  8119. @@ -295,7 +309,7 @@
  8120. public boolean arenaIsBeingUsed(int arenaId)
  8121. {
  8122. if ((arenaId < 0) || (arenaId > 3))
  8123. - {
  8124. + {
  8125. return false;
  8126. }
  8127. return _arenaStatus.get(arenaId);
  8128. @@ -507,6 +521,7 @@
  8129. private class PenaltyRemove implements Runnable
  8130. {
  8131. private final Integer objectId;
  8132. +
  8133. public PenaltyRemove(Integer id)
  8134. {
  8135. objectId = id;
  8136. Index: java/com/l2jserver/gameserver/model/entity/DMManager.java
  8137. ===================================================================
  8138. --- java/com/l2jserver/gameserver/model/entity/DMManager.java (revision 0)
  8139. +++ java/com/l2jserver/gameserver/model/entity/DMManager.java (working copy)
  8140. @@ -0,0 +1,298 @@
  8141. +/*
  8142. + * This program is free software: you can redistribute it and/or modify it under
  8143. + * the terms of the GNU General Public License as published by the Free Software
  8144. + * Foundation, either version 3 of the License, or (at your option) any later
  8145. + * version.
  8146. + *
  8147. + * This program is distributed in the hope that it will be useful, but WITHOUT
  8148. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8149. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  8150. + * details.
  8151. + *
  8152. + * You should have received a copy of the GNU General Public License along with
  8153. + * this program. If not, see <http://www.gnu.org/licenses/>.
  8154. + */
  8155. +package com.l2jserver.gameserver.model.entity;
  8156. +
  8157. +import java.util.Calendar;
  8158. +import java.util.concurrent.ScheduledFuture;
  8159. +import java.util.logging.Logger;
  8160. +
  8161. +import com.l2jserver.Config;
  8162. +import com.l2jserver.gameserver.Announcements;
  8163. +import com.l2jserver.gameserver.ThreadPoolManager;
  8164. +
  8165. +
  8166. +/**
  8167. + * @author FBIagent
  8168. + */
  8169. +
  8170. +public class DMManager
  8171. +{
  8172. + protected static final Logger _log = Logger.getLogger(DMManager.class.getName());
  8173. +
  8174. + /** Task for event cycles<br> */
  8175. + private DMStartTask _task;
  8176. +
  8177. + /**
  8178. + * New instance only by getInstance()<br>
  8179. + */
  8180. + private DMManager()
  8181. + {
  8182. + if (Config.DM_EVENT_ENABLED)
  8183. + {
  8184. + DMEvent.init();
  8185. +
  8186. + this.scheduleEventStart();
  8187. + _log.info("DMEventEngine[DMManager.DMManager()]: Started.");
  8188. + }
  8189. + else
  8190. + {
  8191. + _log.info("DMEventEngine[DMManager.DMManager()]: Engine is disabled.");
  8192. + }
  8193. + }
  8194. +
  8195. + /**
  8196. + * Initialize new/Returns the one and only instance<br><br>
  8197. + *
  8198. + * @return DMManager<br>
  8199. + */
  8200. + public static DMManager getInstance()
  8201. + {
  8202. + return SingletonHolder._instance;
  8203. + }
  8204. +
  8205. + /**
  8206. + * Starts DMStartTask
  8207. + */
  8208. + public void scheduleEventStart()
  8209. + {
  8210. + try
  8211. + {
  8212. + Calendar currentTime = Calendar.getInstance();
  8213. + Calendar nextStartTime = null;
  8214. + Calendar testStartTime = null;
  8215. + for (String timeOfDay : Config.DM_EVENT_INTERVAL)
  8216. + {
  8217. + // Creating a Calendar object from the specified interval value
  8218. + testStartTime = Calendar.getInstance();
  8219. + testStartTime.setLenient(true);
  8220. + String[] splitTimeOfDay = timeOfDay.split(":");
  8221. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  8222. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  8223. + // If the date is in the past, make it the next day (Example: Checking for "1:00", when the time is 23:57.)
  8224. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  8225. + {
  8226. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  8227. + }
  8228. + // Check for the test date to be the minimum (smallest in the specified list)
  8229. + if (nextStartTime == null || testStartTime.getTimeInMillis() < nextStartTime.getTimeInMillis())
  8230. + {
  8231. + nextStartTime = testStartTime;
  8232. + }
  8233. + }
  8234. + _task = new DMStartTask(nextStartTime.getTimeInMillis());
  8235. + ThreadPoolManager.getInstance().executeTask(_task);
  8236. + }
  8237. + catch (Exception e)
  8238. + {
  8239. + _log.warning("DMEventEngine[DMManager.scheduleEventStart()]: Error figuring out a start time. Check DMEventInterval in config file.");
  8240. + }
  8241. + }
  8242. +
  8243. + /**
  8244. + * Method to start participation
  8245. + */
  8246. + public void startReg()
  8247. + {
  8248. + if (!DMEvent.startParticipation())
  8249. + {
  8250. + Announcements.getInstance().announceToAll("DM Event: Event was cancelled.");
  8251. + _log.warning("DMEventEngine[DMManager.run()]: Error spawning event npc for participation.");
  8252. +
  8253. + this.scheduleEventStart();
  8254. + }
  8255. + else
  8256. + {
  8257. + Announcements.getInstance().announceToAll("DM Event: Registration opened for " + Config.DM_EVENT_PARTICIPATION_TIME
  8258. + + " minute(s).");
  8259. +
  8260. + // schedule registration end
  8261. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.DM_EVENT_PARTICIPATION_TIME);
  8262. + ThreadPoolManager.getInstance().executeTask(_task);
  8263. + }
  8264. + }
  8265. +
  8266. + /**
  8267. + * Method to start the fight
  8268. + */
  8269. + public void startEvent()
  8270. + {
  8271. + if (!DMEvent.startFight())
  8272. + {
  8273. + Announcements.getInstance().announceToAll("DM Event: Event cancelled due to lack of Participation.");
  8274. + _log.info("DMEventEngine[DMManager.run()]: Lack of registration, abort event.");
  8275. +
  8276. + this.scheduleEventStart();
  8277. + }
  8278. + else
  8279. + {
  8280. + DMEvent.sysMsgToAllParticipants("DM Event: Teleporting participants to an arena in "
  8281. + + Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  8282. + _task.setStartTime(System.currentTimeMillis() + 60000L * Config.DM_EVENT_RUNNING_TIME);
  8283. + ThreadPoolManager.getInstance().executeTask(_task);
  8284. + }
  8285. + }
  8286. +
  8287. + /**
  8288. + * Method to end the event and reward
  8289. + */
  8290. + public void endEvent()
  8291. + {
  8292. + Announcements.getInstance().announceToAll(DMEvent.calculateRewards());
  8293. + DMEvent.sysMsgToAllParticipants("DM Event: Teleporting back to the registration npc in "
  8294. + + Config.DM_EVENT_START_LEAVE_TELEPORT_DELAY + " second(s).");
  8295. + DMEvent.stopFight();
  8296. +
  8297. + this.scheduleEventStart();
  8298. + }
  8299. +
  8300. + public void skipDelay()
  8301. + {
  8302. + if (_task.nextRun.cancel(false))
  8303. + {
  8304. + _task.setStartTime(System.currentTimeMillis());
  8305. + ThreadPoolManager.getInstance().executeTask(_task);
  8306. + }
  8307. + }
  8308. +
  8309. + /**
  8310. + * Class for DM cycles
  8311. + */
  8312. + class DMStartTask implements Runnable
  8313. + {
  8314. + private long _startTime;
  8315. + public ScheduledFuture<?> nextRun;
  8316. +
  8317. + public DMStartTask(long startTime)
  8318. + {
  8319. + _startTime = startTime;
  8320. + }
  8321. +
  8322. + public void setStartTime(long startTime)
  8323. + {
  8324. + _startTime = startTime;
  8325. + }
  8326. +
  8327. + /**
  8328. + * @see java.lang.Runnable#run()
  8329. + */
  8330. + public void run()
  8331. + {
  8332. + int delay = (int) Math.round((_startTime - System.currentTimeMillis()) / 1000.0);
  8333. +
  8334. + if (delay > 0)
  8335. + {
  8336. + this.announce(delay);
  8337. + }
  8338. +
  8339. + int nextMsg = 0;
  8340. + if (delay > 3600)
  8341. + {
  8342. + nextMsg = delay - 3600;
  8343. + }
  8344. + else if (delay > 1800)
  8345. + {
  8346. + nextMsg = delay - 1800;
  8347. + }
  8348. + else if (delay > 900)
  8349. + {
  8350. + nextMsg = delay - 900;
  8351. + }
  8352. + else if (delay > 600)
  8353. + {
  8354. + nextMsg = delay - 600;
  8355. + }
  8356. + else if (delay > 300)
  8357. + {
  8358. + nextMsg = delay - 300;
  8359. + }
  8360. + else if (delay > 60)
  8361. + {
  8362. + nextMsg = delay - 60;
  8363. + }
  8364. + else if (delay > 5)
  8365. + {
  8366. + nextMsg = delay - 5;
  8367. + }
  8368. + else if (delay > 0)
  8369. + {
  8370. + nextMsg = delay;
  8371. + }
  8372. + else
  8373. + {
  8374. + // start
  8375. + if (DMEvent.isInactive())
  8376. + {
  8377. + DMManager.this.startReg();
  8378. + }
  8379. + else if (DMEvent.isParticipating())
  8380. + {
  8381. + DMManager.this.startEvent();
  8382. + }
  8383. + else
  8384. + {
  8385. + DMManager.this.endEvent();
  8386. + }
  8387. + }
  8388. +
  8389. + if (delay > 0)
  8390. + {
  8391. + nextRun = ThreadPoolManager.getInstance().scheduleGeneral(this, nextMsg * 1000);
  8392. + }
  8393. + }
  8394. +
  8395. + private void announce(long time)
  8396. + {
  8397. + if (time >= 3600 && time % 3600 == 0)
  8398. + {
  8399. + if (DMEvent.isParticipating())
  8400. + {
  8401. + Announcements.getInstance().announceToAll("DM Event: " + (time / 60 / 60) + " hour(s) until registration is closed!");
  8402. + }
  8403. + else if (DMEvent.isStarted())
  8404. + {
  8405. + DMEvent.sysMsgToAllParticipants("DM Event: " + (time / 60 / 60) + " hour(s) until event is finished!");
  8406. + }
  8407. + }
  8408. + else if (time >= 60)
  8409. + {
  8410. + if (DMEvent.isParticipating())
  8411. + {
  8412. + Announcements.getInstance().announceToAll("DM Event: " + (time / 60) + " minute(s) until registration is closed!");
  8413. + }
  8414. + else if (DMEvent.isStarted())
  8415. + {
  8416. + DMEvent.sysMsgToAllParticipants("DM Event: " + (time / 60) + " minute(s) until the event is finished!");
  8417. + }
  8418. + }
  8419. + else
  8420. + {
  8421. + if (DMEvent.isParticipating())
  8422. + {
  8423. + Announcements.getInstance().announceToAll("DM Event: " + time + " second(s) until registration is closed!");
  8424. + }
  8425. + else if (DMEvent.isStarted())
  8426. + {
  8427. + DMEvent.sysMsgToAllParticipants("DM Event: " + time + " second(s) until the event is finished!");
  8428. + }
  8429. + }
  8430. + }
  8431. + }
  8432. +
  8433. + @SuppressWarnings("synthetic-access")
  8434. + private static class SingletonHolder
  8435. + {
  8436. + protected static final DMManager _instance = new DMManager();
  8437. + }
  8438. +}
  8439. Index: java/com/l2jserver/gameserver/model/skills/L2Skill.java
  8440. ===================================================================
  8441. --- java/com/l2jserver/gameserver/model/skills/L2Skill.java (revision 65)
  8442. +++ java/com/l2jserver/gameserver/model/skills/L2Skill.java (working copy)
  8443. @@ -48,6 +48,8 @@
  8444. import com.l2jserver.gameserver.model.conditions.Condition;
  8445. import com.l2jserver.gameserver.model.effects.EffectTemplate;
  8446. import com.l2jserver.gameserver.model.effects.L2Effect;
  8447. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  8448. +import com.l2jserver.gameserver.model.entity.DMEvent;
  8449. import com.l2jserver.gameserver.model.entity.TvTEvent;
  8450. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  8451. import com.l2jserver.gameserver.model.holders.ItemHolder;
  8452. @@ -1556,6 +1558,16 @@
  8453. }
  8454. }
  8455.  
  8456. + if (!CTFEvent.checkForCTFSkill(player, targetPlayer, skill))
  8457. + {
  8458. + return false;
  8459. + }
  8460. +
  8461. + if (!DMEvent.checkForDMSkill(player, targetPlayer, skill))
  8462. + {
  8463. + return false;
  8464. + }
  8465. +
  8466. if (!TvTEvent.checkForTvTSkill(player, targetPlayer, skill))
  8467. {
  8468. return false;
  8469. Index: java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java
  8470. ===================================================================
  8471. --- java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (revision 65)
  8472. +++ java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java (working copy)
  8473. @@ -28,6 +28,8 @@
  8474. import com.l2jserver.gameserver.model.L2World;
  8475. import com.l2jserver.gameserver.model.StatsSet;
  8476. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  8477. +import com.l2jserver.gameserver.model.entity.CTFEvent;
  8478. +import com.l2jserver.gameserver.model.entity.DMEvent;
  8479. import com.l2jserver.gameserver.model.entity.TvTEvent;
  8480. import com.l2jserver.gameserver.model.entity.TvTRoundEvent;
  8481. import com.l2jserver.gameserver.network.SystemMessageId;
  8482. @@ -493,13 +495,25 @@
  8483. player.sendMessage("You can't join olympiad while participating on TvT Event.");
  8484. return false;
  8485. }
  8486. -
  8487. +
  8488. if (TvTRoundEvent.isPlayerParticipant(charId))
  8489. {
  8490. player.sendMessage("You can't join olympiad while participating on TvT Round Event.");
  8491. return false;
  8492. }
  8493. -
  8494. +
  8495. + if (CTFEvent.isPlayerParticipant(charId))
  8496. + {
  8497. + player.sendMessage("You can't join olympiad while participating on CTF Event.");
  8498. + return false;
  8499. + }
  8500. +
  8501. + if (DMEvent.isPlayerParticipant(charId))
  8502. + {
  8503. + player.sendMessage("You can't join olympiad while participating on DM Event.");
  8504. + return false;
  8505. + }
  8506. +
  8507. if (isRegistered(noble, player, true))
  8508. {
  8509. return false;
  8510. Index: java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java
  8511. ===================================================================
  8512. --- java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java (revision 0)
  8513. +++ java/com/l2jserver/gameserver/model/entity/CTFEventTeleporter.java (working copy)
  8514. @@ -0,0 +1,115 @@
  8515. +/*
  8516. + * This program is free software: you can redistribute it and/or modify it under
  8517. + * the terms of the GNU General Public License as published by the Free Software
  8518. + * Foundation, either version 3 of the License, or (at your option) any later
  8519. + * version.
  8520. + *
  8521. + * This program is distributed in the hope that it will be useful, but WITHOUT
  8522. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8523. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  8524. + * details.
  8525. + *
  8526. + * You should have received a copy of the GNU General Public License along with
  8527. + * this program. If not, see <http://www.gnu.org/licenses/>.
  8528. + */
  8529. +
  8530. +package com.l2jserver.gameserver.model.entity;
  8531. +
  8532. +import com.l2jserver.Config;
  8533. +import com.l2jserver.gameserver.ThreadPoolManager;
  8534. +import com.l2jserver.gameserver.model.actor.L2Summon;
  8535. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  8536. +import com.l2jserver.util.Rnd;
  8537. +
  8538. +/**
  8539. + * @author FBIagent, edited U3Games
  8540. + */
  8541. +
  8542. +public class CTFEventTeleporter implements Runnable
  8543. +{
  8544. + /** The instance of the player to teleport */
  8545. + private L2PcInstance _playerInstance = null;
  8546. + /** Coordinates of the spot to teleport to */
  8547. + private int[] _coordinates = new int[3];
  8548. + /** Admin removed this player from event */
  8549. + private boolean _adminRemove = false;
  8550. +
  8551. + /**
  8552. + * Initialize the teleporter and start the delayed task.
  8553. + * @param playerInstance
  8554. + * @param coordinates
  8555. + * @param fastSchedule
  8556. + * @param adminRemove
  8557. + */
  8558. + public CTFEventTeleporter(L2PcInstance playerInstance, int[] coordinates, boolean fastSchedule, boolean adminRemove)
  8559. + {
  8560. + _playerInstance = playerInstance;
  8561. + _coordinates = coordinates;
  8562. + _adminRemove = adminRemove;
  8563. +
  8564. + long delay = (CTFEvent.isStarted() ? Config.CTF_EVENT_RESPAWN_TELEPORT_DELAY : Config.CTF_EVENT_START_LEAVE_TELEPORT_DELAY) * 1000;
  8565. +
  8566. + ThreadPoolManager.getInstance().scheduleGeneral(this, fastSchedule ? 0 : delay);
  8567. + }
  8568. +
  8569. + /**
  8570. + * The task method to teleport the player<br>
  8571. + * 1. Unsummon pet if there is one<br>
  8572. + * 2. Remove all effects<br>
  8573. + * 3. Revive and full heal the player<br>
  8574. + * 4. Teleport the player<br>
  8575. + * 5. Broadcast status and user info<br><br>
  8576. + *
  8577. + * @see java.lang.Runnable#run()
  8578. + */
  8579. + public void run()
  8580. + {
  8581. + if (_playerInstance == null)
  8582. + return;
  8583. +
  8584. + L2Summon summon = _playerInstance.getPet();
  8585. +
  8586. + if (summon != null)
  8587. + summon.unSummon(_playerInstance);
  8588. +
  8589. + if (Config.CTF_EVENT_EFFECTS_REMOVAL == 0
  8590. + || (Config.CTF_EVENT_EFFECTS_REMOVAL == 1 && (_playerInstance.getTeam() == 0 || (_playerInstance.isInDuel() && _playerInstance.getDuelState() != Duel.DUELSTATE_INTERRUPTED))))
  8591. + _playerInstance.stopAllEffectsExceptThoseThatLastThroughDeath();
  8592. +
  8593. + if (_playerInstance.isInDuel())
  8594. + _playerInstance.setDuelState(Duel.DUELSTATE_INTERRUPTED);
  8595. +
  8596. + int CTFInstance = CTFEvent.getCTFEventInstance();
  8597. + if (CTFInstance != 0)
  8598. + {
  8599. + if (CTFEvent.isStarted() && !_adminRemove)
  8600. + {
  8601. + _playerInstance.setInstanceId(CTFInstance);
  8602. + }
  8603. + else
  8604. + {
  8605. + _playerInstance.setInstanceId(0);
  8606. + }
  8607. + }
  8608. + else
  8609. + {
  8610. + _playerInstance.setInstanceId(0);
  8611. + }
  8612. +
  8613. + _playerInstance.doRevive();
  8614. +
  8615. + _playerInstance.teleToLocation( _coordinates[ 0 ] + Rnd.get(101)-50, _coordinates[ 1 ] + Rnd.get(101)-50, _coordinates[ 2 ], false );
  8616. +
  8617. + if (CTFEvent.isStarted() && !_adminRemove)
  8618. + _playerInstance.setTeam(CTFEvent.getParticipantTeamId(_playerInstance.getObjectId()) + 1);
  8619. + else
  8620. + _playerInstance.setTeam(0);
  8621. +
  8622. + _playerInstance.setCurrentCp(_playerInstance.getMaxCp());
  8623. + _playerInstance.setCurrentHp(_playerInstance.getMaxHp());
  8624. + _playerInstance.setCurrentMp(_playerInstance.getMaxMp());
  8625. +
  8626. + _playerInstance.broadcastStatusUpdate();
  8627. + _playerInstance.broadcastUserInfo();
  8628. + }
  8629. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement