Beispiel #1
0
  public void evolve() {
    Player player = getSelf();
    NpcInstance npc = getNpc();
    if (player == null || npc == null) {
      return;
    }
    Summon pl_pet = player.getPet();
    if (player.getInventory().getItemByItemId(BABY_COUGAR_CHIME) == null) {
      show("scripts/services/petevolve/no_item.htm", player, npc);
      return;
    }
    if (pl_pet == null || pl_pet.isDead()) {
      show("scripts/services/petevolve/evolve_no.htm", player, npc);
      return;
    }
    if (pl_pet.getNpcId() != BABY_COUGAR) {
      show("scripts/services/petevolve/no_pet.htm", player, npc);
      return;
    }
    if (pl_pet.getLevel() < 55) {
      show("scripts/services/petevolve/no_level.htm", player, npc);
      return;
    }

    int controlItemId = player.getPet().getControlItemObjId();
    player.getPet().unSummon();

    ItemInstance control = player.getInventory().getItemByObjectId(controlItemId);
    control.setItemId(IN_COUGAR_CHIME);
    control.setEnchantLevel(L2Pet.IMPROVED_BABY_COUGAR.getMinLevel());
    control.setJdbcState(JdbcEntityState.UPDATED);
    control.update();
    player.sendItemList(false);

    show("scripts/services/petevolve/yes_pet.htm", player, npc);
  }
  @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";
  }