Q423_TakeYourBestShot.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 quests.Q423_TakeYourBestShot;
  16. import com.l2jserver.gameserver.ai.CtrlIntention;
  17. import com.l2jserver.gameserver.instancemanager.QuestManager;
  18. import com.l2jserver.gameserver.model.actor.L2Attackable;
  19. import com.l2jserver.gameserver.model.actor.L2Npc;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.model.quest.Quest;
  22. import com.l2jserver.gameserver.model.quest.QuestState;
  23. import com.l2jserver.gameserver.model.quest.State;
  24. import com.l2jserver.gameserver.util.Util;
  25. import com.l2jserver.util.Rnd;
  26. /**
  27. ** @author Gnacik
  28. **
  29. ** 2010-06-26 Based on official server Franz
  30. */
  31. public class Q423_TakeYourBestShot extends Quest
  32. {
  33. private static final String qn = "423_TakeYourBestShot";
  34. // NPC
  35. private static final int _batracos = 32740;
  36. private static final int _johnny = 32744;
  37. // Item
  38. private static final int _seer_ugoros_pass = 15496;
  39. // Spawn chance x/1000
  40. private static final int _spawn_chance = 2;
  41. // Guard
  42. private static final int _tanta_guard = 18862;
  43. // Mobs
  44. private static final int[] _mobs = {
  45. 22768, 22769, 22770, 22771, 22772, 22773, 22774
  46. };
  47. @Override
  48. public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
  49. {
  50. String htmltext = event;
  51. QuestState st = player.getQuestState(qn);
  52. if (st == null)
  53. return htmltext;
  54. if (npc.getNpcId() == _johnny)
  55. {
  56. if (event.equalsIgnoreCase("32744-04.htm"))
  57. {
  58. st.setState(State.STARTED);
  59. st.set("cond", "1");
  60. st.playSound("ItemSound.quest_accept");
  61. }
  62. else if (event.equalsIgnoreCase("32744-quit.htm"))
  63. {
  64. st.exitQuest(true);
  65. }
  66. }
  67. return htmltext;
  68. }
  69. @Override
  70. public String onTalk(L2Npc npc, L2PcInstance player)
  71. {
  72. String htmltext = "<html><body>You are either not on a quest that involves this NPC, or you don't meet this NPC's minimum quest requirements.</body></html>";
  73. QuestState st = player.getQuestState(qn);
  74. if (st == null)
  75. return htmltext;
  76. if (npc.getNpcId() == _johnny)
  77. {
  78. switch(st.getState())
  79. {
  80. case State.CREATED :
  81. QuestState _prev = player.getQuestState("249_PoisonedPlainsOfTheLizardmen");
  82. if ((_prev != null) && (_prev.getState() == State.COMPLETED) && (player.getLevel() >= 82))
  83. if (st.hasQuestItems(_seer_ugoros_pass))
  84. htmltext = "32744-07.htm";
  85. else
  86. htmltext = "32744-01.htm";
  87. else
  88. htmltext = "32744-00.htm";
  89. break;
  90. case State.STARTED :
  91. if (st.getInt("cond") == 1)
  92. htmltext = "32744-05.htm";
  93. else if (st.getInt("cond") == 2)
  94. htmltext = "32744-06.htm";
  95. break;
  96. }
  97. }
  98. else if (npc.getNpcId() == _batracos)
  99. {
  100. if (st.getState() == State.CREATED)
  101. if (st.hasQuestItems(_seer_ugoros_pass))
  102. htmltext = "32740-05.htm";
  103. else
  104. htmltext = "32740-00.htm";
  105. else if (st.getState() == State.STARTED && st.getInt("cond") == 1)
  106. htmltext = "32740-02.htm";
  107. else if (st.getState() == State.STARTED && st.getInt("cond") == 2)
  108. {
  109. st.giveItems(_seer_ugoros_pass, 1);
  110. st.playSound("ItemSound.quest_finish");
  111. st.unset("cond");
  112. st.exitQuest(true);
  113. htmltext = "32740-04.htm";
  114. }
  115. }
  116. return htmltext;
  117. }
  118. @Override
  119. public String onFirstTalk(L2Npc npc, L2PcInstance player)
  120. {
  121. QuestState st = player.getQuestState(getName());
  122. if (st == null)
  123. {
  124. Quest q = QuestManager.getInstance().getQuest(getName());
  125. st = q.newQuestState(player);
  126. }
  127. if (npc.isInsideRadius(96782, 85918, 100, true))
  128. return "32740-ugoros.htm";
  129. else
  130. return "32740.htm";
  131. }
  132. @Override
  133. public String onKill(L2Npc npc, L2PcInstance player, boolean isPet)
  134. {
  135. QuestState st = player.getQuestState(qn);
  136. if (st == null)
  137. return null;
  138. if (Util.contains(_mobs, npc.getNpcId()) && Rnd.get(1000) <= _spawn_chance)
  139. {
  140. L2Npc guard = addSpawn(_tanta_guard, npc, false);
  141. attackPlayer((L2Attackable) guard, player);
  142. }
  143. else if (npc.getNpcId() == _tanta_guard && st.getInt("cond") == 1)
  144. {
  145. st.set("cond", "2");
  146. st.playSound("ItemSound.quest_middle");
  147. }
  148. return null;
  149. }
  150. private void attackPlayer(L2Attackable npc, L2PcInstance player)
  151. {
  152. npc.setIsRunning(true);
  153. npc.addDamageHate(player, 0, 999);
  154. npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
  155. }
  156. public Q423_TakeYourBestShot(int questId, String name, String descr)
  157. {
  158. super(questId, name, descr);
  159. addStartNpc(_johnny);
  160. addTalkId(_johnny);
  161. addStartNpc(_batracos);
  162. addTalkId(_batracos);
  163. addFirstTalkId(_batracos);
  164. addKillId(_tanta_guard);
  165. for(int _mob : _mobs)
  166. addKillId(_mob);
  167. }
  168. public static void main(String[] args)
  169. {
  170. new Q423_TakeYourBestShot(423, qn, "Take Your Best Shot!");
  171. }
  172. }