Advertisement
ChristianSDM

Clan war 90%

Mar 25th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.14 KB | None | 0 0
  1. Index: head-src/com/l2jfrozen/gameserver/InitialClanWar.java
  2.  
  3. +package com.l2jfrozen.gameserver;
  4. +
  5. +import java.text.SimpleDateFormat;
  6. +import java.util.Calendar;
  7. +import java.util.logging.Logger;
  8. +
  9. +import com.l2jfrozen.Config;
  10. +import com.l2jfrozen.gameserver.model.entity.event.ClanWar;
  11. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  12. +
  13. +
  14. + public class InitialClanWar
  15. + {
  16. + //Variaveis globais
  17. + private static InitialClanWar _instance = null;
  18. + protected static final Logger _log = Logger.getLogger(InitialClanWar.class.getName());
  19. + private Calendar NextRestart;
  20. + private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
  21. +
  22. + //Singleton
  23. + public static InitialClanWar getInstance()
  24. + {
  25. + if(_instance == null)
  26. + _instance = new InitialClanWar();
  27. + return _instance;
  28. + }
  29. +
  30. + public String getRestartNextTime()
  31. + {
  32. + if(NextRestart.getTime() != null)
  33. + return format.format(NextRestart.getTime());
  34. + return "Erro";
  35. + }
  36. +
  37. + //Connstrutor
  38. + private InitialClanWar()
  39. + {
  40. + //:D
  41. + }
  42. +
  43. + public void StartCalculationOfNextClanWarTime()
  44. + {
  45. + _log.info("#####################################");
  46. + _log.info("#[ClanWar System]: System actived...#");
  47. + _log.info("#####################################");
  48. + try
  49. + {
  50. + Calendar currentTime = Calendar.getInstance();
  51. + Calendar testStartTime = null;
  52. + long flush2 = 0,timeL = 0;
  53. + int count = 0;
  54. +
  55. + for (String timeOfDay : Config.CLANWAR_INTERVAL_BY_TIME_OF_DAY)
  56. + {
  57. + testStartTime = Calendar.getInstance();
  58. + testStartTime.setLenient(true);
  59. + String[] splitTimeOfDay = timeOfDay.split(":");
  60. + testStartTime.set(Calendar.HOUR_OF_DAY, Integer.parseInt(splitTimeOfDay[0]));
  61. + testStartTime.set(Calendar.MINUTE, Integer.parseInt(splitTimeOfDay[1]));
  62. + testStartTime.set(Calendar.SECOND, 00);
  63. + //Verifica a validade to tempo
  64. + if (testStartTime.getTimeInMillis() < currentTime.getTimeInMillis())
  65. + {
  66. + testStartTime.add(Calendar.DAY_OF_MONTH, 1);
  67. + }
  68. +
  69. + //TimeL Recebe o quanto falta de milisegundos para o restart
  70. + timeL = testStartTime.getTimeInMillis() - currentTime.getTimeInMillis();
  71. +
  72. + //Verifica qual horario sera o proximo restart
  73. + if(count == 0){
  74. + flush2 = timeL;
  75. + NextRestart = testStartTime;
  76. + }
  77. +
  78. + if(timeL < flush2){
  79. + flush2 = timeL;
  80. + NextRestart = testStartTime;
  81. + }
  82. +
  83. + count ++;
  84. + }
  85. + _log.info("[AutoEvent]: Next Restart Time: " + NextRestart.getTime().toString());
  86. + ThreadPoolManager.getInstance().scheduleGeneral(new StartRestartTask(), flush2);
  87. + }
  88. + catch (Exception e)
  89. + {
  90. + System.out.println("[ClanWar]: The ClanWar automated server presented error in load restarts period config !");
  91. + }
  92. + }
  93. +
  94. + class StartRestartTask implements Runnable
  95. + {
  96. + @Override
  97. + public void run()
  98. + {
  99. + ClanWar.eventowar();
  100. + InitialClanWar.getInstance().StartCalculationOfNextClanWarTime();
  101. + return;
  102. + }
  103. + }
  104. +}
  105.  
  106. Index: head-src/com/l2jfrozen/gameserver/handler/voicedcommandhandlers/ClanWarvoice.java
  107.  
  108. +package com.l2jfrozen.gameserver.handler.voicedcommandhandlers;
  109. +
  110. +import com.l2jfrozen.gameserver.handler.IVoicedCommandHandler;
  111. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  112. +import com.l2jfrozen.gameserver.model.entity.event.ClanWar;
  113. +
  114. +public class ClanWarvoice implements IVoicedCommandHandler
  115. +{
  116. + private static final String[] _voicedCommands = { "joincw", "leavecw" };
  117. +
  118. + @Override
  119. + public boolean useVoicedCommand(String command, L2PcInstance activeChar,String target)
  120. + {
  121. + if (command.equals("joincw"))
  122. + ClanWar.registerClanWar(activeChar);
  123. + if (command.equals("leavecw"))
  124. + ClanWar.unregisterClanWar(activeChar);
  125. + return true;
  126. + }
  127. +
  128. + @Override
  129. + public String[] getVoicedCommandList()
  130. + {
  131. + return _voicedCommands;
  132. + }
  133. +}
  134.  
  135. Index: head-src/com/l2jfrozen/gameserver/model/entity/event/ClanWar.java
  136.  
  137. +package com.l2jfrozen.gameserver.model.entity.event;
  138. +
  139. +import com.l2jfrozen.Config;
  140. +import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  141. +import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
  142. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  143. +import com.l2jfrozen.gameserver.model.entity.Announcements;
  144. +import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  145. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  146. +import com.l2jfrozen.util.random.Rnd;
  147. +
  148. +import javolution.util.FastList;
  149. +
  150. +public class ClanWar implements Runnable
  151. +{
  152. + public static FastList<L2PcInstance> _warplayers = new FastList<L2PcInstance>();
  153. + public static L2Spawn _npcSpawn;
  154. + public static boolean ativowar = false;
  155. + public static boolean registrowar = false;
  156. +
  157. + @Override
  158. + public void run()
  159. + {
  160. + if (ativowar == true)
  161. + {
  162. + return;
  163. + }
  164. + eventowar();
  165. +
  166. + }
  167. +
  168. + public static void eventowar()
  169. + {
  170. + NpcSpawnClanWarMan();
  171. + ativowar = true;
  172. + registrowar = true;
  173. + Announcements.getInstance().gameAnnouncetoClanWar("ClanWar Started");
  174. + Announcements.getInstance().gameAnnouncetoClanWar("5 minute(s) till registration close");
  175. + Announcements.getInstance().gameAnnouncetoClanWar("Use to .joincw or .leavecw or go to giran");
  176. + wait(1);
  177. + Announcements.getInstance().gameAnnouncetoClanWar("4 minute(s) till registration close");
  178. + wait(1);
  179. + Announcements.getInstance().gameAnnouncetoClanWar("3 minute(s) till registration close");
  180. + wait(1);
  181. + Announcements.getInstance().gameAnnouncetoClanWar("2 minute(s) till registration close");
  182. + wait(1);
  183. + Announcements.getInstance().gameAnnouncetoClanWar("1 minute(s) till registration close");
  184. + wait(1);
  185. + unspawnNpcClanWarMan();
  186. + if (_warplayers.size() < 3)
  187. + {
  188. + for (L2PcInstance pp : _warplayers)
  189. + {
  190. + pp.inWARCLANZONE = false;
  191. + }
  192. + Announcements.getInstance().gameAnnouncetoClanWar("Minimum 3 participants for the event to happen");
  193. + clearClanWar();
  194. + return;
  195. + }
  196. + registrowar = false;
  197. + teleportClanWar(false);
  198. + setUserData();
  199. + prepare();
  200. + Announcements.getInstance().gameAnnouncetoClanWar("You have 45 seconds to get prepared");
  201. + waitSecs(45);
  202. + start();
  203. + Announcements.getInstance().gameAnnouncetoClanWar("8 minute(s) till event ClanWar finish!");
  204. + wait(3);
  205. + Announcements.getInstance().gameAnnouncetoClanWar("5 minute(s) till event ClanWar finish!");
  206. + wait(1);
  207. + Announcements.getInstance().gameAnnouncetoClanWar("4 minute(s) till event ClanWar finish!");
  208. + wait(1);
  209. + Announcements.getInstance().gameAnnouncetoClanWar("3 minute(s) till event ClanWar finish!");
  210. + wait(1);
  211. + Announcements.getInstance().gameAnnouncetoClanWar("2 minute(s) till event ClanWar finish!");
  212. + wait(1);
  213. + Announcements.getInstance().gameAnnouncetoClanWar("1 minute(s) till event ClanWar finish!");
  214. + wait(1);
  215. + ativowar = false;
  216. + Announcements.getInstance().gameAnnouncetoClanWar("The event ClanWar ended congratulations!");
  217. + waitSecs(1);
  218. + teleportClanWar(true);
  219. + clearClanWar();
  220. + }
  221. +
  222. + public static boolean is_startedwar()
  223. + {
  224. + return ativowar;
  225. + }
  226. +
  227. + public static void teleportClanWar(boolean back)
  228. + {
  229. + if (!back)
  230. + {
  231. + for (L2PcInstance p : _warplayers)
  232. + {
  233. + p.restoreCP();
  234. + p.restoreHPMP();
  235. + p.teleToLocation(45527 + Rnd.get(3001) - 700, 49562 + Rnd.get(1501) - 500, -3071);
  236. + p.sendMessage("You have been moved to coliseum");
  237. + }
  238. + }
  239. + else
  240. + {
  241. + for (L2PcInstance p : _warplayers)
  242. + {
  243. + p.getAppearance().setNameColor(p._originalcolorclanwar);
  244. + p.setTitle(p._originaltitleclanwar);
  245. + p.inWARCLANZONE = false;
  246. + _warplayers.remove(p);
  247. + p.teleToLocation(82813, 148344, -3471);
  248. + p.sendMessage("You have been moved to giran");
  249. + }
  250. + }
  251. + }
  252. +
  253. + public static void registerClanWar(L2PcInstance p)
  254. + {
  255. +
  256. + if (_warplayers.contains(p))
  257. + {
  258. + p.sendMessage("You have already register");
  259. + return;
  260. + }
  261. + if (p.getClan() == null)
  262. + {
  263. + p.sendMessage("You don't have clan");
  264. + return;
  265. + }
  266. + if (registrowar == false)
  267. + {
  268. + p.sendMessage("Can't register now");
  269. + return;
  270. + }
  271. + if (p.isInOlympiadMode())
  272. + {
  273. + p.sendMessage("You can't register while you have register for olympiad match");
  274. + return;
  275. + }
  276. + if (p.isInFunEvent())
  277. + {
  278. + p.sendMessage("You can't register while you have register for other Event");
  279. + return;
  280. + }
  281. + if (p.isInArenaEvent())
  282. + {
  283. + p.sendMessage("You can't register while you have register for other Event");
  284. + return;
  285. + }
  286. + if (p.inLASTMAN == true)
  287. + {
  288. + p.sendMessage("You can't register while you have register for other Event");
  289. + return;
  290. + }
  291. + if (EvtArenaManager.getInstance().isRegistered(p))
  292. + {
  293. + p.sendMessage("You can't register while you have register for other Event");
  294. + return;
  295. + }
  296. + if (p.getKarma() > 0)
  297. + {
  298. + p.sendMessage("You can not register pk");
  299. + return;
  300. + }
  301. + _warplayers.add(p);
  302. + p.sendMessage("You successfully registered for the event");
  303. + p.inWARCLANZONE = true;
  304. + }
  305. +
  306. + public static void unregisterClanWar(L2PcInstance p)
  307. + {
  308. + if (!_warplayers.contains(p))
  309. + {
  310. + p.sendMessage("You have already unregister");
  311. + return;
  312. + }
  313. +
  314. + if (registrowar == false)
  315. + {
  316. + p.sendMessage("You can't unregister while match is about to begin");
  317. + return;
  318. + }
  319. +
  320. + _warplayers.remove(p);
  321. + p.sendMessage("Succesfully unregistered");
  322. + p.inWARCLANZONE = false;
  323. + }
  324. +
  325. + public static void prepare()
  326. + {
  327. + for (L2PcInstance p : _warplayers)
  328. + {
  329. + p.setIsInvul(true);
  330. + p.setIsRooted(true);
  331. + p.sendMessage("You have 45 seconds to get prepared");
  332. + }
  333. + }
  334. +
  335. + public static void start()
  336. + {
  337. +
  338. + for (L2PcInstance p : _warplayers)
  339. + {
  340. + p.stopRooting(null);
  341. + p.setIsInvul(false);
  342. + p.sendMessage("Go go go,start fighting");
  343. + }
  344. + }
  345. +
  346. + private static void NpcSpawnClanWarMan()
  347. + {
  348. + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(Config.LASTMAN_ID_NPC);// ID do mob
  349. + try
  350. + {
  351. + _npcSpawn = new L2Spawn(tmpl);
  352. +
  353. + _npcSpawn.setLocx(82640); // loc x
  354. + _npcSpawn.setLocy(148519); // loc y
  355. + _npcSpawn.setLocz(-3472); // loc z
  356. + _npcSpawn.setAmount(1);
  357. + _npcSpawn.setHeading(0);
  358. + _npcSpawn.setRespawnDelay(1);
  359. +
  360. + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  361. +
  362. + _npcSpawn.init();
  363. + _npcSpawn.getLastSpawn().setTitle("ClanWar");
  364. + _npcSpawn.getLastSpawn().isAggressive();
  365. + _npcSpawn.getLastSpawn().decayMe();
  366. + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  367. + }
  368. + catch (Exception e)
  369. + {
  370. + System.out.println("Erro no evento");
  371. + }
  372. + }
  373. +
  374. + private static void unspawnNpcClanWarMan()
  375. + {
  376. + if (_npcSpawn == null || _npcSpawn.getLastSpawn() == null)
  377. + return;
  378. +
  379. + _npcSpawn.getLastSpawn().deleteMe();
  380. + _npcSpawn.stopRespawn();
  381. + SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
  382. + }
  383. +
  384. + public static void clearClanWar()
  385. + {
  386. + for (L2PcInstance p : _warplayers)
  387. + {
  388. + p.inWARCLANZONE = false;
  389. + }
  390. + _warplayers.clear();
  391. + ativowar = false;
  392. + registrowar = false;
  393. + }
  394. +
  395. + public static void waitSecs(int i)
  396. + {
  397. + try
  398. + {
  399. + Thread.sleep(i * 1000);
  400. + }
  401. + catch (InterruptedException ie)
  402. + {
  403. + ie.printStackTrace();
  404. + }
  405. + }
  406. +
  407. + public static void wait(int i)
  408. + {
  409. + try
  410. + {
  411. + Thread.sleep(i * 60000);
  412. + }
  413. + catch (InterruptedException ie)
  414. + {
  415. + ie.printStackTrace();
  416. + }
  417. + }
  418. +
  419. + public static void setUserData()
  420. + {
  421. + final FastList<L2PcInstance> players = getPlayers();
  422. +
  423. + for (final L2PcInstance player : players)
  424. + {
  425. + player._originalcolorclanwar = player.getAppearance().getNameColor();
  426. + player._originaltitleclanwar = player.getTitle();
  427. + player.getAppearance().setNameColor(Config.CLANWARANEMCOLOR);
  428. + player.setTitle("ClanWar Event");
  429. + player.setKarma(0);
  430. + player.broadcastUserInfo();
  431. + }
  432. + }
  433. +
  434. + protected synchronized static FastList<L2PcInstance> getPlayers()
  435. + {
  436. + return _warplayers;
  437. + }
  438. +
  439. +}
  440.  
  441. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2EngineEventInstance.java
  442.  
  443. +/* This program is free software; you can redistribute it and/or modify
  444. + * it under the terms of the GNU General Public License as published by
  445. + * the Free Software Foundation; either version 2, or (at your option)
  446. + * any later version.
  447. + *
  448. + * This program is distributed in the hope that it will be useful,
  449. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  450. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  451. + * GNU General Public License for more details.
  452. + *
  453. + * You should have received a copy of the GNU General Public License
  454. + * along with this program; if not, write to the Free Software
  455. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  456. + * 02111-1307, USA.
  457. + *
  458. + * http://www.gnu.org/copyleft/gpl.html
  459. + */
  460. +package com.l2jfrozen.gameserver.model.actor.instance;
  461. +
  462. +import com.l2jfrozen.Config;
  463. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  464. +import com.l2jfrozen.gameserver.model.entity.event.ClanWar;
  465. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  466. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  467. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  468. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  469. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  470. +
  471. +public class L2EngineEventInstance extends L2FolkInstance
  472. + {
  473. + public L2EngineEventInstance(int objectId, L2NpcTemplate template)
  474. + {
  475. + super(objectId, template);
  476. + }
  477. +
  478. + @Override
  479. + public void onAction(L2PcInstance player)
  480. + {
  481. + if (!canTarget(player))
  482. + return;
  483. +
  484. + player.setLastFolkNPC(this);
  485. +
  486. + // Check if the L2PcInstance already target the L2NpcInstance
  487. + if (this != player.getTarget())
  488. + {
  489. + // Set the target of the L2PcInstance player
  490. + player.setTarget(this);
  491. +
  492. + // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  493. + MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  494. + player.sendPacket(my);
  495. + my = null;
  496. +
  497. + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  498. + player.sendPacket(new ValidateLocation(this));
  499. + }
  500. + else
  501. + {
  502. + // Calculate the distance between the L2PcInstance and the L2NpcInstance
  503. + if (!canInteract(player))
  504. + {
  505. + // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  506. + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  507. + }
  508. + else
  509. + {
  510. + if(ClanWar.ativowar == true)
  511. + {
  512. + showMessageWindowClanWar(player);
  513. + }
  514. + if(LastMan.ativo == true)
  515. + {
  516. + showMessageWindow(player);
  517. + }
  518. + }
  519. + }
  520. + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  521. + player.sendPacket(ActionFailed.STATIC_PACKET);
  522. + }
  523. +
  524. + private void showMessageWindow(L2PcInstance player)
  525. + {
  526. + String filename = "data/html/mods/LastMan/start.htm";
  527. +
  528. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  529. + html.setFile(filename);
  530. + html.replace("%objectId%", String.valueOf(getObjectId()));
  531. + html.replace("%servername%", Config.ALT_Server_Name);
  532. + player.sendPacket(html);
  533. + filename = null;
  534. + html = null;
  535. + }
  536. +
  537. + private void showMessageWindowClanWar(L2PcInstance player)
  538. + {
  539. + String filename = "data/html/mods/ClanWar/start.htm";
  540. +
  541. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  542. + html.setFile(filename);
  543. + html.replace("%objectId%", String.valueOf(getObjectId()));
  544. + html.replace("%servername%", Config.ALT_Server_Name);
  545. + player.sendPacket(html);
  546. + filename = null;
  547. + html = null;
  548. + }
  549. +
  550. +
  551. +
  552. +
  553. + @Override
  554. + public void onBypassFeedback(L2PcInstance player, String command)
  555. + {
  556. +
  557. + if (command.startsWith("registro"))
  558. + {
  559. +LastMan.register(player);
  560. + }
  561. + else if (command.startsWith("remove"))
  562. + {
  563. + LastMan.unregister(player);
  564. + }
  565. + else if (command.startsWith("retirarclan"))
  566. + {
  567. + ClanWar.unregisterClanWar(player);
  568. + }
  569. + else if (command.startsWith("registrarclan"))
  570. + {
  571. + ClanWar.registerClanWar(player);
  572. + }
  573. + }
  574. +
  575. +
  576. +}
  577.  
  578.  
  579. Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminClanWar.java
  580.  
  581. +package com.l2jfrozen.gameserver.handler.admincommandhandlers;
  582. +
  583. +import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  584. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  585. +import com.l2jfrozen.gameserver.model.entity.event.ClanWar;
  586. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  587. +
  588. +public class AdminClanWar implements IAdminCommandHandler
  589. +{
  590. +
  591. + public AdminClanWar()
  592. + {
  593. + }
  594. +
  595. + @Override
  596. +public boolean useAdminCommand(String command, L2PcInstance activeChar)
  597. + {
  598. + if (command.startsWith("admin_clanwar"))
  599. + {
  600. + try
  601. + {
  602. + ThreadPoolManager.getInstance().scheduleGeneral(new ClanWar(), 1);
  603. +
  604. + }
  605. + catch (Exception e)
  606. + {
  607. + activeChar.sendMessage("Usage: //clanwar");
  608. + }
  609. + }
  610. + return true;
  611. + }
  612. +
  613. + @Override
  614. +public String[] getAdminCommandList()
  615. + {
  616. + return ADMIN_COMMANDS;
  617. + }
  618. +
  619. + private static final String ADMIN_COMMANDS[] =
  620. + {
  621. + "admin_clanwar"
  622. + };
  623. +
  624. +}
  625.  
  626.  
  627. Index: head-src/com/l2jfrozen/gameserver/model/zone/type/L2ClanWarZone.java
  628.  
  629. +/*
  630. + * This program is free software: you can redistribute it and/or modify it under
  631. + * the terms of the GNU General Public License as published by the Free Software
  632. + * Foundation, either version 3 of the License, or (at your option) any later
  633. + * version.
  634. + *
  635. + * This program is distributed in the hope that it will be useful, but WITHOUT
  636. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  637. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  638. + * details.
  639. + *
  640. + * You should have received a copy of the GNU General Public License along with
  641. + * this program. If not, see <http://www.gnu.org/licenses/>.
  642. + */
  643. +package com.l2jfrozen.gameserver.model.zone.type;
  644. +
  645. +import com.l2jfrozen.gameserver.model.L2Character;
  646. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  647. +import com.l2jfrozen.gameserver.model.entity.event.ClanWar;
  648. +import com.l2jfrozen.gameserver.model.zone.L2ZoneType;
  649. +import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  650. +
  651. +public class L2ClanWarZone extends L2ZoneType
  652. +{
  653. +
  654. + public L2ClanWarZone(int id)
  655. + {
  656. + super(id);
  657. + }
  658. +
  659. + @Override
  660. + protected void onEnter(L2Character character)
  661. + {
  662. + if (ClanWar.ativowar == true)
  663. + {
  664. + if (character instanceof L2PcInstance)
  665. + {
  666. + if (((L2PcInstance) character).getClan() != null && ((L2PcInstance) character).inWARCLANZONE == true)
  667. + {
  668. + ((L2PcInstance) character).setIsInsideClanwarZone(true);
  669. + ((L2PcInstance) character).sendMessage("You have entered a Clan War Zone. Prepare for fight.");
  670. + }
  671. + else
  672. + {
  673. + ((L2PcInstance) character).sendMessage("This is strict area for clan members ONLY. or not at the time of the event");
  674. + ((L2PcInstance) character).teleToLocation(83302, 148125, -3408);
  675. + }
  676. + }
  677. + }
  678. + }
  679. +
  680. + @Override
  681. + protected void onExit(L2Character character)
  682. + {
  683. + if(((L2PcInstance) character).isInClanWarEvent())
  684. + {
  685. + if(!((L2PcInstance) character).isDead())
  686. + {
  687. + ThreadPoolManager.getInstance().scheduleGeneral(new BackToZone(character), 2000);
  688. + }
  689. + ((L2PcInstance) character).sendMessage("You can't cheat your way out of here. You must wait ClanWar time is over.");
  690. + }
  691. + if (character instanceof L2PcInstance)
  692. + {
  693. + ((L2PcInstance) character).setIsInsideClanwarZone(false);
  694. + }
  695. + }
  696. +
  697. + @Override
  698. + public void onDieInside(L2Character character)
  699. + {
  700. +
  701. + }
  702. +
  703. + @Override
  704. + public void onReviveInside(L2Character character)
  705. + {
  706. + onEnter(character);
  707. + }
  708. +
  709. + static class BackToZone implements Runnable
  710. + {
  711. + private L2PcInstance _activeChar;
  712. +
  713. + BackToZone(L2Character character)
  714. + {
  715. + _activeChar = (L2PcInstance) character;
  716. + }
  717. +
  718. + @Override
  719. + public void run()
  720. + {
  721. + _activeChar.teleToLocation(45819, 49359, -3066); // Elven Village
  722. + }
  723. +}
  724. +}
  725.  
  726.  
  727. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
  728.  
  729.  
  730. private boolean _isTradeOff = false;
  731. + public boolean inWARCLANZONE = false;
  732.  
  733.  
  734.  
  735. public int _originalNameColorOffline = 0xFFFFFF;
  736. + public int _originalcolorclanwar;
  737. + public String _originaltitleclanwar;
  738.  
  739.  
  740.  
  741.  
  742.  
  743. }, Config.TVT_REVIVE_DELAY);
  744. }
  745. }
  746. + else if (inWARCLANZONE)
  747. + {
  748. + if (ClanWar.ativowar || inWARCLANZONE == true)
  749. + {
  750. + sendMessage("You will be revived and teleported in 10 seconds!");
  751. + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  752. + {
  753. + @Override
  754. + public void run()
  755. + {
  756. + teleToLocation(45527 + Rnd.get(3001) - 700, 49562 + Rnd.get(1501) - 500, -3071);
  757. + doRevive();
  758. + }
  759. + }, 10000);
  760. + }
  761. + }
  762. else if (_inEventTvT)
  763. {
  764. if (TvT.is_teleport() || TvT.is_started())
  765.  
  766.  
  767.  
  768. public void increasePkKillsAndKarma(int targLVL)
  769. {
  770. - if ((TvT.is_started() && _inEventTvT) || (DM.is_started() && _inEventDM) || (CTF.is_started() && _inEventCTF) || (VIP._started && _inEventVIP))
  771. + if ((TvT.is_started() && _inEventTvT) || (DM.is_started() && _inEventDM) || (CTF.is_started() && _inEventCTF) || (VIP._started && _inEventVIP) || ClanWar.ativowar == true)
  772. return;
  773.  
  774. // Add karma to attacker and increase its PK counter
  775. setPvpKills(getPvpKills() + 1);
  776.  
  777.  
  778.  
  779.  
  780. if (Config.ANTI_FARM_SUMMON)
  781. {
  782. if (target instanceof L2SummonInstance)
  783. return;
  784. }
  785.  
  786. + if (isInsideClanwarZone() && targetPlayer.isInsideClanwarZone() && (getClan() != null) && (targetPlayer.getClan() != null) && (getClanId() != targetPlayer.getClanId()))
  787. + {
  788. + getInventory().addItem("Event", Config.CLANWAR_ITEM_ID, Config.CLANWAR_ITEM_QUANTIA, null, null);
  789. + sendMessage("You killed someone from an enemy clan.");
  790. + getClan().setReputationScore(getClan().getReputationScore() + Config.REPUTATION_QUANTITY_CLANWAR, true);
  791. + setKarma(0);
  792. + }
  793.  
  794.  
  795.  
  796. public L2HennaInstance getHennas(final int slot)
  797. {
  798. if (slot < 1 || slot > 3)
  799. return null;
  800.  
  801. return _henna[slot - 1];
  802. }
  803.  
  804. + public boolean isInClanWarEvent()
  805. + {
  806. + return inWARCLANZONE;
  807. + }
  808.  
  809. Index: head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  810.  
  811. +registerAdminCommandHandler(new AdminClanWar());
  812. registerAdminCommandHandler(new AdminAdmin());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement