Advertisement
warc222

Basic Event Drop Monsters adapted l2jfrozen

Sep 24th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.91 KB | None | 0 0
  1. set //dropmonsters and wait 60secs to start
  2.  
  3.  
  4. basically its a event where you choose the id of the monsters " make some specials ones or w.e" setup a spawner, with random spawn " X coordinate - randomly generated number etc.) From what the code states there are 4 different spawner's, and it gets picked at random, so for example if it rolls aden castle, like the coordinates suggests then it will spawn the monsters there, and so on.
  5.  
  6. People have X amount of time to kill them and get special rewards, then after that X amount of time mobs disappear and then you can set the timer or set them manually from the admin commands.
  7.  
  8.  
  9. l2jfrozen\gameserver\model\entity\event DropMonstersEvent.java
  10.  
  11.  
  12. package com.l2jfrozen.gameserver.model.entity.event;
  13.  
  14. import java.sql.Connection;
  15. import java.sql.PreparedStatement;
  16. import java.sql.SQLException;
  17. import java.util.List;
  18.  
  19. import javolution.util.FastList;
  20.  
  21. import com.l2jfrozen.Config;
  22. import com.l2jfrozen.gameserver.datatables.sql.NpcTable;
  23. import com.l2jfrozen.gameserver.datatables.sql.SpawnTable;
  24. import com.l2jfrozen.gameserver.model.L2World;
  25. import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
  26. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jfrozen.gameserver.model.entity.Announcements;
  28. import com.l2jfrozen.gameserver.model.spawn.L2Spawn;
  29. import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  30. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  31. import com.l2jfrozen.util.database.L2DatabaseFactory;
  32. import com.l2jfrozen.util.random.Rnd;
  33.  
  34. /**
  35. * @author allanalcantara
  36. *
  37. */
  38.  
  39. public class DropMonstersEvent implements Runnable
  40. {
  41.  
  42. public static L2Spawn _mobsSpawn;
  43. public static boolean TownMonsterAtivo = false;
  44. public static int _bossHeading = 0;
  45. @SuppressWarnings("unused")
  46. public List<L2Spawn> _MonsterSpawn = new FastList<L2Spawn>();
  47.  
  48. static int[] mobs={ 21162, 21253, 21184, 21205, 21163, 21254, 21206, 21185, 21255, 21207, 21165, 21186 };
  49.  
  50.  
  51. public void eventomanager()
  52. {
  53. TownMonsterAtivo = true;
  54. Announcements.getInstance().gameAnnounceToAll("The event will start at 60 Seconds.");
  55. waitSecs(60);
  56. spawnMonstersEvent();
  57. Announcements.getInstance().gameAnnounceToAll("The event will finish in 30 Minutes.");
  58. wait(30);
  59. ThreadPoolManager.getInstance().scheduleGeneral(new unspawnMonstersrun(), 1);
  60. waitSecs(10);
  61. TownMonsterAtivo = false;
  62. Announcements.getInstance().gameAnnounceToAll("The event ended.");
  63. }
  64.  
  65. class unspawnMonstersrun implements Runnable
  66. {
  67. @Override
  68. public void run()
  69. {
  70. unspawnMonsters();
  71. }
  72. }
  73.  
  74. private void SpawnMonster1()
  75. {
  76. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  77.  
  78. try
  79. {
  80. int valorr = 1;
  81.  
  82. while (valorr < 25)
  83. {
  84. _mobsSpawn = new L2Spawn(tmpl);
  85.  
  86. _mobsSpawn.setLocx(149013 + Rnd.get(950) - Rnd.get(350) + Rnd.get(150)); // loc x
  87. _mobsSpawn.setLocy(16694 + Rnd.get(950) - Rnd.get(250) + Rnd.get(140)); // loc y
  88. _mobsSpawn.setLocz(-1541); // loc z
  89.  
  90. _mobsSpawn.setAmount(1);
  91. _mobsSpawn.setHeading(0);
  92. _mobsSpawn.setRespawnDelay(150000);
  93. _mobsSpawn.setLocation(0);
  94.  
  95. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  96. _MonsterSpawn.add(_mobsSpawn);
  97. _mobsSpawn = null;
  98.  
  99. valorr++;
  100.  
  101. }
  102. }
  103. catch (Exception e)
  104. {
  105. System.out.println("Error in event");
  106. }
  107. }
  108.  
  109. private void SpawnMonster01()
  110. {
  111. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  112.  
  113. try
  114. {
  115. int valorr = 1;
  116. Announcements.getInstance().gameAnnounceToAll("The boxes are in Aden Castle.");
  117.  
  118. while (valorr < 30)
  119. {
  120. _mobsSpawn = new L2Spawn(tmpl);
  121.  
  122. _mobsSpawn.setLocx(145885 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  123. _mobsSpawn.setLocy(16830 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
  124. _mobsSpawn.setLocz(-1560); // loc z
  125.  
  126. _mobsSpawn.setAmount(1);
  127. _mobsSpawn.setHeading(0);
  128. _mobsSpawn.setRespawnDelay(150000);
  129. _mobsSpawn.setLocation(0);
  130.  
  131. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  132. _MonsterSpawn.add(_mobsSpawn);
  133. _mobsSpawn = null;
  134.  
  135. valorr++;
  136.  
  137. }
  138. }
  139. catch (Exception e)
  140. {
  141. System.out.println("Error in event");
  142. }
  143. }
  144.  
  145. private void SpawnMonster2()
  146. {
  147. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  148.  
  149. try
  150. {
  151. int valorr = 1;
  152.  
  153. while (valorr < 25)
  154. {
  155. _mobsSpawn = new L2Spawn(tmpl);
  156.  
  157. _mobsSpawn.setLocx(87054 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  158. _mobsSpawn.setLocy(148844 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
  159. _mobsSpawn.setLocz(-3061); // loc z
  160.  
  161. _mobsSpawn.setAmount(1);
  162. _mobsSpawn.setHeading(0);
  163. _mobsSpawn.setRespawnDelay(150000);
  164. _mobsSpawn.setLocation(0);
  165.  
  166. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  167. _MonsterSpawn.add(_mobsSpawn);
  168. _mobsSpawn = null;
  169.  
  170. valorr++;
  171.  
  172. }
  173. }
  174. catch (Exception e)
  175. {
  176. System.out.println("Error in event");
  177. }
  178. }
  179.  
  180. private void SpawnMonster02()
  181. {
  182. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  183.  
  184. try
  185. {
  186. int valorr = 1;
  187. Announcements.getInstance().gameAnnounceToAll("The boxes are in entrance of Monastery.");
  188.  
  189. while (valorr < 30)
  190. {
  191. _mobsSpawn = new L2Spawn(tmpl);
  192.  
  193. _mobsSpawn.setLocx(124109 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  194. _mobsSpawn.setLocy(-74952 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
  195. _mobsSpawn.setLocz(-2915); // loc z
  196.  
  197. _mobsSpawn.setAmount(1);
  198. _mobsSpawn.setHeading(0);
  199. _mobsSpawn.setRespawnDelay(150000);
  200. _mobsSpawn.setLocation(0);
  201.  
  202. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  203. _MonsterSpawn.add(_mobsSpawn);
  204. _mobsSpawn = null;
  205.  
  206. valorr++;
  207.  
  208. }
  209. }
  210. catch (Exception e)
  211. {
  212. System.out.println("Error in event");
  213. }
  214. }
  215.  
  216. private void SpawnMonster3()
  217. {
  218. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  219.  
  220. try
  221. {
  222. int valorr = 1;
  223.  
  224. while (valorr < 25)
  225. {
  226. _mobsSpawn = new L2Spawn(tmpl);
  227.  
  228. _mobsSpawn.setLocx(124860 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  229. _mobsSpawn.setLocy(-75504 + Rnd.get(950) + (Rnd.get(20) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
  230. _mobsSpawn.setLocz(-2912); // loc z
  231.  
  232. _mobsSpawn.setAmount(1);
  233. _mobsSpawn.setHeading(0);
  234. _mobsSpawn.setRespawnDelay(150000);
  235. _mobsSpawn.setLocation(0);
  236.  
  237. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  238. _MonsterSpawn.add(_mobsSpawn);
  239. _mobsSpawn = null;
  240.  
  241. valorr++;
  242.  
  243. }
  244. }
  245. catch (Exception e)
  246. {
  247. System.out.println("Error in event");
  248. }
  249. }
  250.  
  251. private void SpawnMonster03()
  252. {
  253. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  254.  
  255. try
  256. {
  257. int valorr = 1;
  258. Announcements.getInstance().gameAnnounceToAll("The boxes are in Giran.");
  259.  
  260. while (valorr < 20)
  261. {
  262. _mobsSpawn = new L2Spawn(tmpl);
  263.  
  264. _mobsSpawn.setLocx(82732 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  265. _mobsSpawn.setLocy(148723 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(310) + Rnd.get(130)); // loc y
  266. _mobsSpawn.setLocz(-3471); // loc z
  267.  
  268. _mobsSpawn.setAmount(1);
  269. _mobsSpawn.setHeading(0);
  270. _mobsSpawn.setRespawnDelay(150000);
  271. _mobsSpawn.setLocation(0);
  272.  
  273. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  274. _MonsterSpawn.add(_mobsSpawn);
  275. _mobsSpawn = null;
  276.  
  277. valorr++;
  278.  
  279. }
  280. }
  281. catch (Exception e)
  282. {
  283. System.out.println("Error in event");
  284. }
  285. }
  286.  
  287. private void SpawnMonster4()
  288. {
  289. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  290.  
  291. try
  292. {
  293. int valorr = 1;
  294.  
  295. while (valorr < 25)
  296. {
  297. _mobsSpawn = new L2Spawn(tmpl);
  298.  
  299. _mobsSpawn.setLocx(81948 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  300. _mobsSpawn.setLocy(147837 + Rnd.get(950) + (Rnd.get(30) * 2) - Rnd.get(200) + Rnd.get(110)); // loc y
  301. _mobsSpawn.setLocz(-3471); // loc z
  302.  
  303. _mobsSpawn.setAmount(1);
  304. _mobsSpawn.setHeading(0);
  305. _mobsSpawn.setRespawnDelay(150000);
  306. _mobsSpawn.setLocation(0);
  307.  
  308. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  309. _MonsterSpawn.add(_mobsSpawn);
  310. _mobsSpawn = null;
  311.  
  312. valorr++;
  313.  
  314. }
  315. }
  316. catch (Exception e)
  317. {
  318. System.out.println("Error in event");
  319. }
  320. }
  321.  
  322. private void SpawnMonster04()
  323. {
  324. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  325.  
  326. try
  327. {
  328. int valorr = 1;
  329. Announcements.getInstance().gameAnnounceToAll("The boxes are in Near the Town of Dion.");
  330.  
  331. while (valorr < 15)
  332. {
  333. _mobsSpawn = new L2Spawn(tmpl);
  334.  
  335. _mobsSpawn.setLocx(19023 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  336. _mobsSpawn.setLocy(141199 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
  337. _mobsSpawn.setLocz(-3340); // loc z
  338.  
  339. _mobsSpawn.setAmount(1);
  340. _mobsSpawn.setHeading(0);
  341. _mobsSpawn.setRespawnDelay(150000);
  342. _mobsSpawn.setLocation(0);
  343.  
  344. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  345. _MonsterSpawn.add(_mobsSpawn);
  346. _mobsSpawn = null;
  347.  
  348. valorr++;
  349.  
  350. }
  351. }
  352. catch (Exception e)
  353. {
  354. System.out.println("Error in event");
  355. }
  356. }
  357.  
  358. private void SpawnMonster5()
  359. {
  360. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  361.  
  362. try
  363. {
  364. int valorr = 1;
  365.  
  366. while (valorr < 25)
  367. {
  368. _mobsSpawn = new L2Spawn(tmpl);
  369.  
  370. _mobsSpawn.setLocx(20781 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  371. _mobsSpawn.setLocy(140355 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
  372. _mobsSpawn.setLocz(-3464); // loc z
  373.  
  374. _mobsSpawn.setAmount(1);
  375. _mobsSpawn.setHeading(0);
  376. _mobsSpawn.setRespawnDelay(150000);
  377. _mobsSpawn.setLocation(0);
  378.  
  379. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  380. _MonsterSpawn.add(_mobsSpawn);
  381. _mobsSpawn = null;
  382.  
  383. valorr++;
  384.  
  385. }
  386. }
  387. catch (Exception e)
  388. {
  389. System.out.println("Error in event");
  390. }
  391. }
  392.  
  393. private void SpawnMonster05()
  394. {
  395. L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(mobs[Rnd.get(0, 11)]);// ID do mob
  396.  
  397. try
  398. {
  399. int valorr = 1;
  400. Announcements.getInstance().gameAnnounceToAll("The boxes are in west of gludin, Near the harbor.");
  401.  
  402. while (valorr < 20)
  403. {
  404. _mobsSpawn = new L2Spawn(tmpl);
  405.  
  406. _mobsSpawn.setLocx(-86372 + Rnd.get(950) + (Rnd.get(50) * 2) - Rnd.get(350) + Rnd.get(150)); // loc x
  407. _mobsSpawn.setLocy(150012 + Rnd.get(950) - (Rnd.get(30) * 2) + Rnd.get(200) + Rnd.get(110)); // loc y
  408. _mobsSpawn.setLocz(-3061); // loc z
  409.  
  410. _mobsSpawn.setAmount(1);
  411. _mobsSpawn.setHeading(0);
  412. _mobsSpawn.setRespawnDelay(150000);
  413. _mobsSpawn.setLocation(0);
  414.  
  415. //SpawnTable.getInstance().addNewSpawn(_mobsSpawn, false);
  416. _MonsterSpawn.add(_mobsSpawn);
  417. _mobsSpawn = null;
  418.  
  419. valorr++;
  420.  
  421. }
  422. }
  423. catch (Exception e)
  424. {
  425. System.out.println("Error in event");
  426. }
  427. }
  428.  
  429. public static void waitSecs(int i)
  430. {
  431. try
  432. {
  433. Thread.sleep(i * 1000);
  434. }
  435. catch (InterruptedException ie)
  436. {
  437. ie.printStackTrace();
  438. }
  439. }
  440.  
  441. public static void wait(int i)
  442. {
  443. try
  444. {
  445. Thread.sleep(i * 60000);
  446. }
  447. catch (InterruptedException ie)
  448. {
  449. ie.printStackTrace();
  450. }
  451. }
  452.  
  453. public final List<L2Spawn> getMonsterIds()
  454. {
  455. return _MonsterSpawn;
  456. }
  457.  
  458. public void unspawnMonsters()
  459. {
  460. for (L2Spawn spawn : getMonsterIds())
  461. {
  462. spawn.stopRespawn();
  463. spawn.getLastSpawn().doDie(spawn.getLastSpawn());
  464. }
  465.  
  466. getMonsterIds().clear();
  467. }
  468.  
  469. public void spawnMonstersEvent()
  470. {
  471. int city = Rnd.get(5) + 1;
  472. if (city == 1)
  473. {
  474. SpawnMonster1();
  475. SpawnMonster01();
  476. }
  477. else if (city == 2)
  478. {
  479. SpawnMonster2();
  480. SpawnMonster02();
  481. }
  482. else if (city == 3)
  483. {
  484. SpawnMonster3();
  485. SpawnMonster03();
  486. }
  487. else if (city == 4)
  488. {
  489. SpawnMonster4();
  490. SpawnMonster04();
  491. }
  492. else if (city == 5)
  493. {
  494. SpawnMonster5();
  495. SpawnMonster05();
  496. }
  497. for (L2Spawn spawn : getMonsterIds())
  498. if (spawn != null)
  499. {
  500. spawn.init();
  501. }
  502. }
  503.  
  504. @Override
  505. public void run()
  506. {
  507. if (TownMonsterAtivo == true)
  508. {
  509. return;
  510. }
  511.  
  512. eventomanager();
  513.  
  514. }
  515. }
  516.  
  517.  
  518. AdminDropMonstersEvent.java
  519. \gameserver\head-src\com\l2jfrozen\gameserver\handler\admincommandhandlers
  520.  
  521.  
  522. package com.l2jfrozen.gameserver.handler.admincommandhandlers;
  523.  
  524. import com.l2jfrozen.Config;
  525. import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  526. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  527. import com.l2jfrozen.gameserver.model.entity.event.DropMonstersEvent;
  528. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  529.  
  530. public class AdminDropMonstersEvent implements IAdminCommandHandler
  531. {
  532.  
  533. public AdminDropMonstersEvent()
  534. {
  535. }
  536.  
  537. @Override
  538. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  539. {
  540. if (command.startsWith("admin_dropmonsters"))
  541. {
  542. ThreadPoolManager.getInstance().scheduleGeneral(new DropMonstersEvent(), 1);
  543. }
  544. return true;
  545. }
  546.  
  547. @Override
  548. public String[] getAdminCommandList()
  549. {
  550. return ADMIN_COMMANDS;
  551. }
  552.  
  553. private static final String ADMIN_COMMANDS[] =
  554. {
  555. "admin_dropmonsters"
  556. };
  557.  
  558. }
  559.  
  560.  
  561. AdminCommandHandler.java
  562.  
  563. import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminDropMonstersEvent;
  564.  
  565.  
  566. registerAdminCommandHandler(new AdminDropMonstersEvent());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement