@Override public String onEvent(String event, QuestState st, NpcInstance npc) { int _state = st.getState(); ItemInstance dragonflute = GetDragonflute(st); int dragonflute_id = st.getInt("dragonflute"); int cond = st.getCond(); if (event.equalsIgnoreCase("30610_05.htm") && _state == CREATED) { st.setState(STARTED); st.setCond(1); st.playSound(SOUND_ACCEPT); } else if ((event.equalsIgnoreCase("30747_03.htm") || event.equalsIgnoreCase("30747_04.htm")) && _state == STARTED && cond == 1) { if (dragonflute == null) return "noquest"; if (dragonflute.getObjectId() != dragonflute_id) { if (Rnd.chance(10)) { st.takeItems(dragonflute.getItemId(), 1); st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); } return "30747_00.htm"; } if (!HatchlingSummoned(st, false)) return event.equalsIgnoreCase("30747_04.htm") ? "30747_04a.htm" : "30747_02.htm"; if (event.equalsIgnoreCase("30747_04.htm")) { st.setCond(2); st.takeItems(Fairy_Leaf, -1); st.giveItems(Fairy_Leaf, 4); st.playSound(SOUND_MIDDLE); } } return event; }
private static ItemInstance GetDragonflute(QuestState st) { List<ItemInstance> Dragonflutes = new ArrayList<ItemInstance>(); for (ItemInstance item : st.getPlayer().getInventory().getItems()) if (item != null && (item.getItemId() == Dragonflute_of_Wind || item.getItemId() == Dragonflute_of_Star || item.getItemId() == Dragonflute_of_Twilight)) Dragonflutes.add(item); if (Dragonflutes.isEmpty()) return null; if (Dragonflutes.size() == 1) return Dragonflutes.get(0); if (st.getState() == CREATED) return null; int dragonflute_id = st.getInt("dragonflute"); for (ItemInstance item : Dragonflutes) if (item.getObjectId() == dragonflute_id) return item; return null; }
@Override public String onTalk(NpcInstance npc, QuestState st) { int _state = st.getState(); int npcId = npc.getNpcId(); int cond = st.getCond(); ItemInstance dragonflute = GetDragonflute(st); int dragonflute_id = st.getInt("dragonflute"); if (_state == CREATED) { if (npcId != Cronos) return "noquest"; if (st.getPlayer().getLevel() < 45) { st.exitCurrentQuest(true); return "30610_01.htm"; } if (dragonflute == null) { st.exitCurrentQuest(true); return "30610_02.htm"; } if (dragonflute.getEnchantLevel() < 55) { st.exitCurrentQuest(true); return "30610_03.htm"; } st.setCond(0); st.set("dragonflute", String.valueOf(dragonflute.getObjectId())); return "30610_04.htm"; } if (_state != STARTED) return "noquest"; if (npcId == Cronos) { if (dragonflute == null) return "30610_02.htm"; return dragonflute.getObjectId() == dragonflute_id ? "30610_07.htm" : "30610_06.htm"; } if (npcId == Mimyu) { if (st.getQuestItemsCount(Dragon_Bugle_of_Wind) + st.getQuestItemsCount(Dragon_Bugle_of_Star) + st.getQuestItemsCount(Dragon_Bugle_of_Twilight) > 0) return "30747_00b.htm"; if (dragonflute == null) return "noquest"; if (cond == 1) return "30747_01.htm"; if (cond == 2) { if (!HatchlingSummoned(st, false)) return "30747_09.htm"; if (st.getQuestItemsCount(Fairy_Leaf) == 0) { st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); return "30747_11.htm"; } return "30747_10.htm"; } if (cond == 3) { if (dragonflute.getObjectId() != dragonflute_id) return "30747_00a.htm"; if (st.getQuestItemsCount(Fairy_Leaf) > 0) { st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); return "30747_11.htm"; } if (!(CheckTree(st, Fairy_Tree_of_Wind) && CheckTree(st, Fairy_Tree_of_Star) && CheckTree(st, Fairy_Tree_of_Twilight) && CheckTree(st, Fairy_Tree_of_Abyss))) { st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); return "30747_11.htm"; } if (st.getInt("welldone") == 0) { if (!HatchlingSummoned(st, false)) return "30747_09.htm"; st.set("welldone", "1"); return "30747_12.htm"; } if (HatchlingSummoned(st, false) || st.getPlayer().getSummonList().getPet() != null) return "30747_13a.htm"; dragonflute.setItemId(Dragon_Bugle_of_Wind + dragonflute.getItemId() - Dragonflute_of_Wind); dragonflute.setJdbcState(JdbcEntityState.UPDATED); dragonflute.update(); st.getPlayer().sendPacket(new InventoryUpdate().addModifiedItem(dragonflute)); st.playSound(SOUND_FINISH); st.exitCurrentQuest(true); return "30747_13.htm"; } } return "noquest"; }