Advertisement
horato

Subclass event patch

May 17th, 2011
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 17.23 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_DataPack
  3. Index: data/scripts/mods/eventmodSubclassTvT/31212-started.htm
  4. ===================================================================
  5. --- data/scripts/mods/eventmodSubclassTvT/31212-started.htm (revision 0)
  6. +++ data/scripts/mods/eventmodSubclassTvT/31212-started.htm (revision 0)
  7. @@ -0,0 +1,9 @@
  8. +<html>
  9. +<body>
  10. +<center>
  11. +<br>
  12. +<font color=ff3333>Subclass event</font><br>
  13. +Event has already been started.
  14. +</center>
  15. +</body>
  16. +</html>
  17. \ No newline at end of file
  18. Index: data/scripts/mods/eventmodSubclassTvT/31212-signed.htm
  19. ===================================================================
  20. --- data/scripts/mods/eventmodSubclassTvT/31212-signed.htm  (revision 0)
  21. +++ data/scripts/mods/eventmodSubclassTvT/31212-signed.htm  (revision 0)
  22. @@ -0,0 +1,10 @@
  23. +<html>
  24. +<body>
  25. +<center>
  26. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  27. +<br>
  28. +<font color=ff3333>Subclass event</font><br>
  29. +Thanks for signup. Wait for event start.<br>
  30. +</center>
  31. +</body>
  32. +</html>
  33. \ No newline at end of file
  34. Index: data/scripts/mods/eventmodSubclassTvT/31212-unsigned.htm
  35. ===================================================================
  36. --- data/scripts/mods/eventmodSubclassTvT/31212-unsigned.htm    (revision 0)
  37. +++ data/scripts/mods/eventmodSubclassTvT/31212-unsigned.htm    (revision 0)
  38. @@ -0,0 +1,10 @@
  39. +<html>
  40. +<body>
  41. +<center>
  42. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  43. +<br>
  44. +<font color=ff3333>Subclass event</font><br>
  45. +You are now unregistered from the event.
  46. +</center>
  47. +</body>
  48. +</html>
  49. \ No newline at end of file
  50. Index: data/instances/subclass.xml
  51. ===================================================================
  52. --- data/instances/subclass.xml (revision 0)
  53. +++ data/instances/subclass.xml (revision 0)
  54. @@ -0,0 +1,4 @@
  55. +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  56. +<instance name="SubclassEventZone">
  57. +  <allowSummon val="false"/>
  58. +</instance>
  59. \ No newline at end of file
  60. Index: data/scripts/mods/eventmodSubclassTvT/31212.htm
  61. ===================================================================
  62. --- data/scripts/mods/eventmodSubclassTvT/31212.htm (revision 0)
  63. +++ data/scripts/mods/eventmodSubclassTvT/31212.htm (revision 0)
  64. @@ -0,0 +1,13 @@
  65. +<html>
  66. +<body>
  67. +<center>
  68. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  69. +<br>
  70. +<font color=ff3333>Subclass event</font><br>
  71. +You can signup for event here<br>
  72. +<button value="Participate in Subclass event" action="bypass -h Quest eventmodSubclassTvT signup" width=180 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  73. +<button value="Remove participiation" action="bypass -h Quest eventmodSubclassTvT signdown" width=180 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  74. +
  75. +</center>
  76. +</body>
  77. +</html>
  78. \ No newline at end of file
  79. Index: data/scripts/mods/eventmodSubclassTvT/31212-fail.htm
  80. ===================================================================
  81. --- data/scripts/mods/eventmodSubclassTvT/31212-fail.htm    (revision 0)
  82. +++ data/scripts/mods/eventmodSubclassTvT/31212-fail.htm    (revision 0)
  83. @@ -0,0 +1,10 @@
  84. +<html>
  85. +<body>
  86. +<center>
  87. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  88. +<br>
  89. +<font color=ff3333>Subclass event</font><br>
  90. +You must have 40 lvl and be on subclass in order to register<br>
  91. +</center>
  92. +</body>
  93. +</html>
  94. \ No newline at end of file
  95. Index: data/scripts/mods/eventmodSubclassTvT/eventmodSubclassTvT.java
  96. ===================================================================
  97. --- data/scripts/mods/eventmodSubclassTvT/eventmodSubclassTvT.java  (revision 0)
  98. +++ data/scripts/mods/eventmodSubclassTvT/eventmodSubclassTvT.java  (revision 0)
  99. @@ -0,0 +1,446 @@
  100. +/*
  101. + * This program is free software: you can redistribute it and/or modify it under
  102. + * the terms of the GNU General Public License as published by the Free Software
  103. + * Foundation, either version 3 of the License, or (at your option) any later
  104. + * version.
  105. + *
  106. + * This program is distributed in the hope that it will be useful, but WITHOUT
  107. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  108. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  109. + * details.
  110. + *
  111. + * You should have received a copy of the GNU General Public License along with
  112. + * this program. If not, see <http://www.gnu.org/licenses/>.
  113. + */
  114. +
  115. +package mods.eventmodSubclassTvT;
  116. +
  117. +/**************************************************************************************************************
  118. + *                                                                                                           *
  119. + *                                         @author horato, Nik                                                   *
  120. + *                                      Made for L2world.org                                                 *
  121. + *                                                                                                           *
  122. + **************************************************************************************************************/
  123. +import java.util.List;
  124. +import java.util.concurrent.ScheduledFuture;
  125. +import java.util.concurrent.TimeUnit;
  126. +
  127. +import javolution.util.FastList;
  128. +
  129. +import com.l2jserver.gameserver.Announcements;
  130. +import com.l2jserver.gameserver.ThreadPoolManager;
  131. +import com.l2jserver.gameserver.datatables.SkillTable;
  132. +import com.l2jserver.gameserver.instancemanager.InstanceManager;
  133. +import com.l2jserver.gameserver.instancemanager.QuestManager;
  134. +import com.l2jserver.gameserver.model.L2Effect;
  135. +import com.l2jserver.gameserver.model.L2Skill;
  136. +import com.l2jserver.gameserver.model.actor.L2Character;
  137. +import com.l2jserver.gameserver.model.actor.L2Npc;
  138. +import com.l2jserver.gameserver.model.actor.L2Summon;
  139. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  140. +import com.l2jserver.gameserver.model.quest.Event;
  141. +import com.l2jserver.gameserver.model.quest.Quest;
  142. +import com.l2jserver.gameserver.model.quest.QuestState;
  143. +import com.l2jserver.gameserver.network.serverpackets.ExCubeGameChangePoints;
  144. +import com.l2jserver.gameserver.network.serverpackets.ExCubeGameEnd;
  145. +
  146. +public class eventmodSubclassTvT extends Event
  147. +{
  148. +   // Is event active?
  149. +   private static boolean _isActive = false;
  150. +   // Start npc ID
  151. +   private static final int _npc_id = 31212;
  152. +   // Initialize players list
  153. +   private List<L2PcInstance> _players;
  154. +   // Npc
  155. +   private L2Npc _npc;
  156. +   // Event Task
  157. +   ScheduledFuture<?> _eventTask = null;
  158. +   // Teams; Team1 is red, Team2 is blue
  159. +   List<L2PcInstance> _team1 = new FastList<L2PcInstance>();
  160. +   List<L2PcInstance> _team2 = new FastList<L2PcInstance>();
  161. +   // Teams score
  162. +   private static int _team1_score = 0;
  163. +   private static int _team2_score = 0;
  164. +   // Instance ID
  165. +   int _instance_id = 0;
  166. +  
  167. +   public static void main(String[] args)
  168. +   {
  169. +       new eventmodSubclassTvT(-1, "eventmodSubclassTvT", "mods");
  170. +   }
  171. +  
  172. +   public eventmodSubclassTvT(int questId, String name, String descr)
  173. +   {
  174. +       super(questId, name, descr);
  175. +      
  176. +       addStartNpc(_npc_id);
  177. +       addFirstTalkId(_npc_id);
  178. +       addTalkId(_npc_id);
  179. +      
  180. +       // Initialize players list
  181. +       _players = new FastList<L2PcInstance>();
  182. +      
  183. +   }
  184. +  
  185. +   @Override
  186. +   public boolean eventStart()
  187. +   {
  188. +       // Don't start event if its active
  189. +       if (_isActive)
  190. +           return false;
  191. +       //Clear player list, npc lists and score
  192. +       _team1_score = 0;
  193. +       _team2_score = 0;
  194. +       _npc = null;
  195. +       _team1.clear();
  196. +       _team2.clear();
  197. +       _players.clear();
  198. +      
  199. +       // Create instance for event
  200. +       try
  201. +       {
  202. +           _instance_id = InstanceManager.getInstance().createDynamicInstance("subclass.xml");
  203. +       }
  204. +       catch (Exception e)
  205. +       {
  206. +           Announcements.getInstance().announceToAll("Event error");
  207. +           eventStop();
  208. +           e.printStackTrace();
  209. +       }
  210. +      
  211. +       // Set active
  212. +       _isActive = true;
  213. +       // Spawn event manager
  214. +       _npc = addSpawn(_npc_id, 82798, 148650, -3464, 0, false, 0);
  215. +      
  216. +       // Announce event start
  217. +       Announcements.getInstance().announceToAll("Subclass TvT event started");
  218. +       Announcements.getInstance().announceToAll("Visit event manager in Giran castle town for register");
  219. +      
  220. +       _eventTask = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  221. +       {
  222. +           public void run()
  223. +           {
  224. +               Announcements.getInstance().announceToAll("Subclass TvT Event: 10 minutes left");
  225. +               try
  226. +               {
  227. +                   Thread.sleep(5 * 60 * 1000); //1 min
  228. +                   Announcements.getInstance().announceToAll("Subclass TvT Event: 5 minutes left");
  229. +                   Thread.sleep(2 * 60 * 1000); //1 min
  230. +                   Announcements.getInstance().announceToAll("Subclass TvT Event: 3 minutes left");
  231. +                   Thread.sleep(2 * 60 * 1000); //1 min
  232. +                   Announcements.getInstance().announceToAll("Subclass TvT Event: 1 minutes left");
  233. +                   Thread.sleep(1 * 60 * 1000); //1 min
  234. +                   StartEvent();
  235. +               }
  236. +               catch (InterruptedException e)
  237. +               {
  238. +                   Announcements.getInstance().announceToAll("Event error");
  239. +                   eventStop();
  240. +               }
  241. +           }
  242. +       }, 1);
  243. +      
  244. +       return true;
  245. +   }
  246. +  
  247. +   @Override
  248. +   public boolean eventStop()
  249. +   {
  250. +       // Don't stop inactive event
  251. +       if (!_isActive)
  252. +           return false;
  253. +      
  254. +       // Set inactive
  255. +       _isActive = false;
  256. +       // Thread stop
  257. +       if (!_eventTask.isDone())
  258. +           _eventTask.cancel(true);
  259. +       // Remove instance
  260. +       InstanceManager.getInstance().destroyInstance(_instance_id);
  261. +       // Remove NPC
  262. +       if (_npc != null)
  263. +           _npc.deleteMe();
  264. +      
  265. +       // Announce winning team
  266. +       if (_team1_score > _team2_score)
  267. +       {
  268. +           Announcements.getInstance().announceToAll("Red team won");
  269. +       }
  270. +       else if (_team1_score < _team2_score)
  271. +       {
  272. +           Announcements.getInstance().announceToAll("Blue team won");
  273. +       }
  274. +       else if (_team1_score == _team2_score)
  275. +       {
  276. +           Announcements.getInstance().announceToAll("No winner this time");
  277. +       }
  278. +      
  279. +       // Remove team marker, give reward and teleport back
  280. +       for (L2PcInstance player : _players)
  281. +       {
  282. +           if (_team1_score > _team2_score)
  283. +           {
  284. +               player.sendPacket(new ExCubeGameEnd(true));
  285. +               if (_team1.contains(player))
  286. +                   player.addItem("eventmodSubclassTvT", 4037, 10, _npc, true);
  287. +           }
  288. +           else if (_team1_score < _team2_score)
  289. +           {
  290. +               player.sendPacket(new ExCubeGameEnd(false));
  291. +               if (_team2.contains(player))
  292. +                   player.addItem("eventmodSubclassTvT", 4037, 10, _npc, true);
  293. +           }
  294. +           else
  295. +           {
  296. +               player.sendPacket(new ExCubeGameEnd(false));
  297. +               if (player.isDead())
  298. +                   player.doRevive();
  299. +               player.removeNotifyQuestOfDeath(player.getQuestState(getName()));
  300. +               player.setTeam(0);
  301. +               player.setInstanceId(0);
  302. +               player.teleToLocation(83478, 148628, -3405);
  303. +           }
  304. +       }
  305. +       // Clear teams
  306. +       _team1.clear();
  307. +       _team2.clear();
  308. +       // Clear player list
  309. +       _players.clear();
  310. +      
  311. +       Announcements.getInstance().announceToAll("Subclass TvT event finished");
  312. +      
  313. +       return true;
  314. +   }
  315. +  
  316. +   @Override
  317. +   public boolean eventBypass(L2PcInstance activeChar, String bypass)
  318. +   {
  319. +       return false;
  320. +   }
  321. +  
  322. +   @Override
  323. +   public String onFirstTalk(L2Npc npc, L2PcInstance player)
  324. +   {
  325. +       QuestState st = player.getQuestState(getName());
  326. +       if (st == null)
  327. +       {
  328. +           Quest q = QuestManager.getInstance().getQuest(getName());
  329. +           st = q.newQuestState(player);
  330. +       }
  331. +       if (npc.getNpcId() == _npc_id)
  332. +       {
  333. +           return _npc_id + ".htm";
  334. +       }
  335. +       return npc.getNpcId() + ".htm";
  336. +   }
  337. +  
  338. +   @Override
  339. +   public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  340. +   {
  341. +       // Registering
  342. +       if (event.startsWith("signup"))
  343. +       { //level check
  344. +           if (player.getLevel() == 40)
  345. +           { // Subclass check
  346. +               if (player.isSubClassActive())
  347. +               {
  348. +                   if (_players.contains(player))
  349. +                   {
  350. +                       return _npc_id + "-onlist.htm";
  351. +                   }
  352. +                   _players.add(player);
  353. +                   return _npc_id + "-signed.htm";
  354. +               }
  355. +               else
  356. +               {
  357. +                   return _npc_id + "-fail.htm";
  358. +               }
  359. +           }
  360. +           else
  361. +           {
  362. +               return _npc_id + "-fail.htm";
  363. +           }
  364. +          
  365. +       }
  366. +      
  367. +       // Unregistering
  368. +       if (event.startsWith("signdown"))
  369. +       {
  370. +           if (!_players.contains(player))
  371. +           {
  372. +               return _npc_id + "-notreg.htm";
  373. +           }
  374. +           _players.remove(player);
  375. +           return _npc_id + "-unsigned.htm";
  376. +       }
  377. +      
  378. +       return "";
  379. +   }
  380. +  
  381. +   private void StartEvent()
  382. +   {
  383. +      
  384. +       // Check for empty reg list
  385. +       if (_players.size() < 2)
  386. +       {
  387. +           Announcements.getInstance().announceToAll("Not enough players to start event");
  388. +           eventStop();
  389. +           return;
  390. +       }
  391. +      
  392. +       Announcements.getInstance().announceToAll("Subclass TvT event started");
  393. +      
  394. +       // Remove registration NPC
  395. +       if (_npc != null)
  396. +           _npc.deleteMe();
  397. +      
  398. +       // Make teams
  399. +       for (L2PcInstance player : _players)
  400. +       {
  401. +           if (player != null)
  402. +           {
  403. +               if (player.getLevel() == 40 && player.isSubClassActive())
  404. +               {
  405. +                   player.addNotifyQuestOfDeath(player.getQuestState(getName()));
  406. +                   if (_team1.size() > _team2.size())
  407. +                   {
  408. +                       player.setTeam(1);
  409. +                       _team2.add(player);
  410. +                      
  411. +                   }
  412. +                   else
  413. +                   {
  414. +                       player.setTeam(2);
  415. +                       _team1.add(player);
  416. +                   }
  417. +               }
  418. +               else
  419. +               {
  420. +                   player.sendMessage("You have been kicked from event because your level is not 40 or you dont have subclass active");
  421. +                   _players.remove(player);
  422. +               }
  423. +           }
  424. +       }
  425. +      
  426. +       // Teleport players, remove buffs, remove summons, ressurect and full heal
  427. +       for (L2PcInstance player : _team1)
  428. +       {
  429. +           player.stopAllEffectsExceptThoseThatLastThroughDeath();
  430. +           L2Summon summon = player.getPet();
  431. +           if (summon != null)
  432. +               summon.unSummon(player);
  433. +           if (player.isDead())
  434. +               player.doRevive();
  435. +           player.setCurrentCp(player.getMaxCp());
  436. +           player.setCurrentMp(player.getMaxMp());
  437. +           player.setCurrentHp(player.getMaxHp());
  438. +           player.setInstanceId(_instance_id);
  439. +           player.teleToLocation(150437, 47397, -3413);
  440. +       }
  441. +      
  442. +       for (L2PcInstance player : _team2)
  443. +       {
  444. +           player.stopAllEffectsExceptThoseThatLastThroughDeath();
  445. +           L2Summon summon = player.getPet();
  446. +           if (summon != null)
  447. +               summon.unSummon(player);
  448. +           if (player.isDead())
  449. +               player.doRevive();
  450. +           player.setCurrentCp(player.getMaxCp());
  451. +           player.setCurrentMp(player.getMaxMp());
  452. +           player.setCurrentHp(player.getMaxHp());
  453. +           player.setInstanceId(_instance_id);
  454. +           player.teleToLocation(148513, 46122, -3408);
  455. +       }
  456. +      
  457. +       _eventTask = ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  458. +       {
  459. +           public void run()
  460. +           {
  461. +               eventStop();
  462. +           }
  463. +       }, 20 * 60 * 1000);
  464. +      
  465. +   }
  466. +  
  467. +   @Override
  468. +   public String onDeath(final L2Character killer, final L2Character victim, QuestState qs)
  469. +   {
  470. +       if (((L2PcInstance) killer).getExpertiseWeaponPenalty() > 0 || ((L2PcInstance) killer).getExpertiseArmorPenalty() > 0)
  471. +       {
  472. +           SkillTable.getInstance().getInfo(4515, 1).getEffects(victim, killer);
  473. +           if (_team1.contains(killer))
  474. +               _team1_score--;
  475. +           else if (_team2.contains(killer))
  476. +               _team2_score--;
  477. +           killer.sendMessage("Your kill is not counted because you have grade penalty");
  478. +       }
  479. +      
  480. +       if (_team1.size() < 2 || _team2.size() < 2)
  481. +       {
  482. +           ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  483. +           {
  484. +               public void run()
  485. +               {
  486. +                   Announcements.getInstance().announceToAll("Too many players disconnected from event. Ending event");
  487. +                   eventStop();
  488. +               }
  489. +           }, 2 * 1000);
  490. +       }
  491. +      
  492. +       if (_team1.contains(killer) && _team2.contains(victim))
  493. +       {
  494. +          
  495. +           _team1_score++;
  496. +           ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  497. +           {
  498. +               public void run()
  499. +               {
  500. +                   victim.doRevive();
  501. +                   victim.teleToLocation(148513, 46122, -3408);
  502. +               }
  503. +           }, 2 * 1000);
  504. +          
  505. +       }
  506. +       else if (_team2.contains(killer) && _team1.contains(victim))
  507. +       {
  508. +           _team2_score++;
  509. +           ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  510. +           {
  511. +               public void run()
  512. +               {
  513. +                   victim.doRevive();
  514. +                   victim.teleToLocation(150437, 47397, -3413);
  515. +               }
  516. +           }, 2 * 1000);
  517. +          
  518. +       }
  519. +       else
  520. +       {
  521. +           ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  522. +           {
  523. +               public void run()
  524. +               {
  525. +                   victim.doRevive();
  526. +                   if (_team1.contains(killer))
  527. +                   {
  528. +                       victim.teleToLocation(148513, 46122, -3408);
  529. +                   }
  530. +                   else
  531. +                   {
  532. +                       victim.teleToLocation(150437, 47397, -3413);
  533. +                   }
  534. +               }
  535. +           }, 2 * 1000);
  536. +       }
  537. +      
  538. +       for (L2PcInstance player : _players)
  539. +       {
  540. +           player.sendPacket(new ExCubeGameChangePoints((int) _eventTask.getDelay(TimeUnit.SECONDS), _team2_score, _team1_score));
  541. +       }
  542. +       return super.onDeath(killer, victim, qs);
  543. +   }
  544. +  
  545. +}
  546. Index: data/scripts/mods/eventmodSubclassTvT/31212-onlist.htm
  547. ===================================================================
  548. --- data/scripts/mods/eventmodSubclassTvT/31212-onlist.htm  (revision 0)
  549. +++ data/scripts/mods/eventmodSubclassTvT/31212-onlist.htm  (revision 0)
  550. @@ -0,0 +1,10 @@
  551. +<html>
  552. +<body>
  553. +<center>
  554. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  555. +<br>
  556. +<font color=ff3333>Subclass event</font><br>
  557. +You are already on list.
  558. +</center>
  559. +</body>
  560. +</html>
  561. \ No newline at end of file
  562. Index: data/scripts/mods/eventmodSubclassTvT/31212-notreg.htm
  563. ===================================================================
  564. --- data/scripts/mods/eventmodSubclassTvT/31212-notreg.htm  (revision 0)
  565. +++ data/scripts/mods/eventmodSubclassTvT/31212-notreg.htm  (revision 0)
  566. @@ -0,0 +1,10 @@
  567. +<html>
  568. +<body>
  569. +<center>
  570. +<img src="L2UI_CH3.herotower_deco" height="32" width="256" align="center">
  571. +<br>
  572. +<font color=ff3333>Subclass event</font><br>
  573. +You are not registered.
  574. +</center>
  575. +</body>
  576. +</html>
  577. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement