RaidbossInfo.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package custom.RaidbossInfo;
  16. import java.util.Map;
  17. import javolution.util.FastMap;
  18. import com.l2jserver.gameserver.datatables.NpcTable;
  19. import com.l2jserver.gameserver.datatables.SpawnTable;
  20. import com.l2jserver.gameserver.model.L2Spawn;
  21. import com.l2jserver.gameserver.model.Location;
  22. import com.l2jserver.gameserver.model.actor.L2Npc;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  25. import com.l2jserver.gameserver.model.quest.Quest;
  26. import com.l2jserver.gameserver.model.quest.QuestState;
  27. import com.l2jserver.gameserver.util.Util;
  28. /**
  29. * Raidboss Info AI.<br>
  30. * Original Jython script Kerberos.
  31. * @author Nyaran
  32. */
  33. public class RaidbossInfo extends Quest
  34. {
  35. private static final String qn = "RaidbossInfo";
  36. private static final int[] NPC =
  37. {
  38. 31729, 31730, 31731, 31732, 31733, 31734, 31735, 31736, 31737, 31738, 31739, 31740, 31741,
  39. 31742, 31743, 31744, 31745, 31746, 31747, 31748, 31749, 31750, 31751, 31752, 31753, 31754,
  40. 31755, 31756, 31757, 31758, 31759, 31760, 31761, 31762, 31763, 31764, 31765, 31766, 31767,
  41. 31768, 31769, 31770, 31771, 31772, 31773, 31774, 31775, 31776, 31777, 31778, 31779, 31780,
  42. 31781, 31782, 31783, 31784, 31785, 31786, 31787, 31788, 31789, 31790, 31791, 31792, 31793,
  43. 31794, 31795, 31796, 31797, 31798, 31799, 31800, 31801, 31802, 31803, 31804, 31805, 31806,
  44. 31807, 31808, 31809, 31810, 31811, 31812, 31813, 31814, 31815, 31816, 31817, 31818, 31819,
  45. 31820, 31821, 31822, 31823, 31824, 31825, 31826, 31827, 31828, 31829, 31830, 31831, 31832,
  46. 31833, 31834, 31835, 31836, 31837, 31838, 31839, 31840, 31841, 32337, 32338, 32339, 32340
  47. };
  48. private static final Map<Integer, Location> RADAR = new FastMap<>();
  49. @Override
  50. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  51. {
  52. String htmltext = event;
  53. QuestState st = player.getQuestState(qn);
  54. if (st == null)
  55. return htmltext;
  56. if (Util.isDigit(event))
  57. {
  58. htmltext = null;
  59. int rbid = Integer.parseInt(event);
  60. if (RADAR.containsKey(rbid))
  61. {
  62. Location loc = RADAR.get(rbid);
  63. st.addRadar(loc.getX(), loc.getY(), loc.getZ());
  64. }
  65. st.exitQuest(true);
  66. }
  67. return htmltext;
  68. }
  69. @Override
  70. public String onTalk(L2Npc npc, L2PcInstance player)
  71. {
  72. return "info.htm";
  73. }
  74. public RaidbossInfo(int id, String name, String descr)
  75. {
  76. super(id, name, descr);
  77. for (int i : NPC)
  78. {
  79. addStartNpc(i);
  80. addTalkId(i);
  81. }
  82. // Add all Raid Bosses to RAIDS list
  83. for (L2NpcTemplate raid : NpcTable.getInstance().getAllNpcOfClassType("L2RaidBoss"))
  84. {
  85. int x = 0, y = 0, z = 0;
  86. for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable())
  87. {
  88. if (spawn.getNpcid() == raid.getNpcId())
  89. {
  90. x = spawn.getLocx();
  91. y = spawn.getLocy();
  92. z = spawn.getLocz();
  93. break;
  94. }
  95. }
  96. RADAR.put(raid.getNpcId(), new Location(x, y, z));
  97. }
  98. }
  99. public static void main(String args[])
  100. {
  101. new RaidbossInfo(-1, qn, "custom");
  102. }
  103. }