Nemo.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package gracia.AI.NPC.Nemo;
  20. import gracia.AI.Maguen;
  21. import ai.npc.AbstractNpcAI;
  22. import com.l2jserver.gameserver.ai.CtrlIntention;
  23. import com.l2jserver.gameserver.instancemanager.QuestManager;
  24. import com.l2jserver.gameserver.model.actor.L2Npc;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.quest.Quest;
  27. import com.l2jserver.gameserver.network.NpcStringId;
  28. /**
  29. * Nemo AI.
  30. * @author St3eT
  31. */
  32. public final class Nemo extends AbstractNpcAI
  33. {
  34. // NPC
  35. private static final int NEMO = 32735; // Nemo
  36. private static final int MAGUEN = 18839; // Wild Maguen
  37. // Items
  38. private static final int COLLECTOR = 15487; // Maguen Plasma Collector
  39. // Misc
  40. private static final int MAXIMUM_MAGUEN = 18; // Maximum maguens in one time
  41. public Nemo()
  42. {
  43. super(Nemo.class.getSimpleName(), "gracia/AI/NPC");
  44. addStartNpc(NEMO);
  45. addFirstTalkId(NEMO);
  46. addTalkId(NEMO);
  47. }
  48. @Override
  49. public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  50. {
  51. String htmltext = null;
  52. switch (event)
  53. {
  54. case "32735-01.html":
  55. {
  56. htmltext = event;
  57. break;
  58. }
  59. case "giveCollector":
  60. {
  61. if (hasQuestItems(player, COLLECTOR))
  62. {
  63. htmltext = "32735-03.html";
  64. }
  65. else if (!player.isInventoryUnder90(false))
  66. {
  67. htmltext = "32735-04.html";
  68. }
  69. else
  70. {
  71. htmltext = "32735-02.html";
  72. giveItems(player, COLLECTOR, 1);
  73. }
  74. break;
  75. }
  76. case "summonMaguen":
  77. {
  78. if ((player.getVariables().getInt("TEST_MAGUEN", 0) == 0) && (npc.getScriptValue() < MAXIMUM_MAGUEN))
  79. {
  80. final L2Npc maguen = addSpawn(MAGUEN, npc.getLocation(), true, 60000, true);
  81. maguen.getVariables().set("SUMMON_PLAYER", player);
  82. maguen.getVariables().set("SPAWNED_NPC", npc);
  83. maguen.getVariables().set("TEST_MAGUEN", 1);
  84. player.getVariables().set("TEST_MAGUEN", 1);
  85. maguen.setTitle(player.getName());
  86. maguen.setIsRunning(true);
  87. maguen.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
  88. maguen.broadcastStatusUpdate();
  89. showOnScreenMsg(player, NpcStringId.MAGUEN_APPEARANCE, 2, 4000);
  90. maguenAi().startQuestTimer("DIST_CHECK_TIMER", 1000, maguen, player);
  91. npc.setScriptValue(npc.getScriptValue() + 1);
  92. htmltext = "32735-05.html";
  93. }
  94. else
  95. {
  96. htmltext = "32735-06.html";
  97. }
  98. break;
  99. }
  100. case "DECREASE_COUNT":
  101. {
  102. final L2Npc spawnedNpc = npc.getVariables().getObject("SPAWNED_NPC", L2Npc.class);
  103. if ((spawnedNpc != null) && (spawnedNpc.getScriptValue() > 0))
  104. {
  105. player.getVariables().remove("TEST_MAGUEN");
  106. spawnedNpc.setScriptValue(spawnedNpc.getScriptValue() - 1);
  107. }
  108. }
  109. }
  110. return htmltext;
  111. }
  112. private Quest maguenAi()
  113. {
  114. return QuestManager.getInstance().getQuest(Maguen.class.getSimpleName());
  115. }
  116. }