示例#1
0
 @Override
 public final void teleportPlayer(L2PcInstance player, Location loc, int instanceId) {
   giveBuffs(player);
   final L2Summon pet = player.getPet();
   if (pet != null) {
     giveBuffs(pet);
   }
   player
       .getServitors()
       .values()
       .forEach(
           s -> {
             giveBuffs(s);
           });
   super.teleportPlayer(player, loc, instanceId);
 }
示例#2
0
  @Override
  public L2Object[] getTargetList(
      Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target) {
    final List<L2Character> targetList = new ArrayList<>();
    final int radius = skill.getAffectRange();
    if (activeChar.getParty() != null) {
      final List<L2PcInstance> partyList = activeChar.getParty().getMembers();
      for (L2PcInstance partyMember : partyList) {
        if (partyMember == activeChar) {
          continue;
        } else if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE, activeChar, partyMember, true)) {
          continue;
        } else {
          if (Skill.addPet(activeChar, partyMember, radius, false)) {
            targetList.add(partyMember.getPet());
          }

          partyMember
              .getServitors()
              .values()
              .forEach(
                  s -> {
                    if (Skill.addCharacter(activeChar, s, radius, false)) {
                      targetList.add(s);
                    }
                  });

          if (Skill.addCharacter(activeChar, partyMember, radius, false)) {
            targetList.add(partyMember);
          }

          targetList.add(partyMember);
        }
      }
    }
    return targetList.toArray(new L2Character[targetList.size()]);
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if ("DESPAWN_GUARDIAN".equals(event)) {
      if (npc != null) {
        npc.deleteMe();
      }
      return super.onAdvEvent(event, npc, player);
    }

    final QuestState qs = getQuestState(player, false);
    String htmltext = null;
    if (qs == null) {
      return htmltext;
    }

    switch (event) {
      case "30610-05.htm":
        {
          if (qs.isCreated()) {
            if (getQuestItemsCount(
                    player, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT)
                == 1) {
              final L2ItemInstance flute = getFlute(player);

              if (flute.getEnchantLevel() < MIN_HACHLING_LVL) {
                htmltext = "30610-06.html";
              } else {
                qs.startQuest();
                qs.setMemoState(100);
                qs.set("fluteObjectId", flute.getObjectId());
                htmltext = event;
              }
            } else {
              htmltext = "30610-06.html";
            }
          }
          break;
        }
      case "30747-04.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-02.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-03.html";
          } else {
            htmltext = event;
          }
          break;
        }
      case "30747-05.html":
        {
          final L2Summon summon = player.getPet();

          if (summon == null) {
            htmltext = "30747-06.html";
          } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
            htmltext = "30747-06.html";
          } else {
            giveItems(player, FAIRY_LEAF, 4);
            qs.setCond(2, true);
            qs.setMemoState(0);
            htmltext = event;
          }
          break;
        }
      case "30747-07.html":
      case "30747-08.html":
      case "30747-09.html":
      case "30747-10.html":
        {
          htmltext = event;
          break;
        }
    }
    return htmltext;
  }
  @Override
  public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) {
    final QuestState qs = getQuestState(attacker, false);
    if ((qs != null) && qs.isCond(2)) {
      if (isSummon) {
        final NpcData data = NPC_DATA.get(npc.getId());
        if ((qs.getMemoState() % data.memoStateMod) < data.memoStateValue) {
          final L2Summon pet = attacker.getPet();
          if ((pet != null) && (pet.getControlObjectId() == qs.getInt("fluteObjectId"))) {
            final int hits = qs.getInt("hits") + 1;
            qs.set("hits", hits);

            if (hits < data.minHits) {
              if ((npc.getId() == TREE_OF_ABYSS) && (getRandom(100) < 2)) {
                npc.setTarget(attacker);
                npc.doCast(DRYAD_ROOT.getSkill());
              }
            } else if (getRandom(100) < 2) {
              if (hasQuestItems(attacker, FAIRY_LEAF)) {
                npc.broadcastPacket(
                    new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.GIVE_ME_A_FAIRY_LEAF));
                takeItems(attacker, FAIRY_LEAF, 1);
                qs.setMemoState(qs.getMemoState() + data.memoStateValue);
                qs.unset("hits");
                playSound(attacker, QuestSound.ITEMSOUND_QUEST_MIDDLE);

                if (qs.getMemoState() == 15) {
                  qs.setCond(3);
                }
              }
            }
          }
        } else {
          switch (getRandom(3)) {
            case 0:
              npc.broadcastPacket(
                  new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WHY_DO_YOU_BOTHER_ME_AGAIN));
              break;
            case 1:
              npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, data.message));
              break;
            case 2:
              npc.broadcastPacket(
                  new NpcSay(
                      npc,
                      ChatType.NPC_GENERAL,
                      NpcStringId.LEAVE_NOW_BEFORE_YOU_INCUR_THE_WRATH_OF_THE_GUARDIAN_GHOST));
              break;
          }
        }
      } else if (getRandom(100) < 30) {
        npc.setTarget(attacker);
        npc.doCast(VICIOUS_POISON.getSkill());
      }
    } else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.67)) && (getRandom(100) < 30)) {
      npc.setTarget(attacker);
      npc.doCast(VICIOUS_POISON.getSkill());
    }

    return super.onAttack(npc, attacker, damage, isSummon);
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance talker) {
    final QuestState qs = getQuestState(talker, true);
    String htmltext = getNoQuestMsg(talker);

    switch (npc.getId()) {
      case CRONOS:
        {
          switch (qs.getState()) {
            case State.CREATED:
              {
                final long fluteCount =
                    getQuestItemsCount(
                        talker, DRAGONFLUTE_OF_WIND, DRAGONFLUTE_OF_STAR, DRAGONFLUTE_OF_TWILIGHT);
                if (fluteCount == 0) {
                  break; // this quest does not show up if no flute in inventory
                }

                if (talker.getLevel() < MIN_PLAYER_LVL) {
                  htmltext = "30610-01.htm";
                } else if (fluteCount > 1) {
                  htmltext = "30610-02.htm";
                } else if (getFlute(talker).getEnchantLevel() < MIN_HACHLING_LVL) {
                  htmltext = "30610-03.html";
                } else {
                  htmltext = "30610-04.htm";
                }
                break;
              }
            case State.STARTED:
              {
                htmltext = "30610-07.html";
                break;
              }
            case State.COMPLETED:
              {
                htmltext = getAlreadyCompletedMsg(talker);
                break;
              }
          }
          break;
        }
      case MIMYU:
        {
          switch (qs.getMemoState()) {
            case 100:
              {
                qs.setMemoState(200);
                htmltext = "30747-01.html";
                break;
              }
            case 200:
              {
                final L2Summon summon = talker.getPet();

                if (summon == null) {
                  htmltext = "30747-02.html";
                } else if (summon.getControlObjectId() != qs.getInt("fluteObjectId")) {
                  htmltext = "30747-03.html";
                } else {
                  htmltext = "30747-04.html";
                }
                break;
              }
            case 0:
              {
                htmltext = "30747-07.html";
                break;
              }
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
              {
                if (hasQuestItems(talker, FAIRY_LEAF)) {
                  htmltext = "30747-11.html";
                }
                break;
              }
            case 15:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  final L2Summon summon = talker.getPet();

                  if (summon == null) {
                    htmltext = "30747-12.html";
                  } else if (summon.getControlObjectId() == qs.getInt("fluteObjectId")) {
                    qs.setMemoState(16);
                    htmltext = "30747-13.html";
                  } else {
                    htmltext = "30747-14.html";
                  }
                }
                break;
              }
            case 16:
              {
                if (!hasQuestItems(talker, FAIRY_LEAF)) {
                  if (talker.hasSummon()) {
                    htmltext = "30747-15.html";
                  } else {
                    final long fluteCount =
                        getQuestItemsCount(
                            talker,
                            DRAGONFLUTE_OF_WIND,
                            DRAGONFLUTE_OF_STAR,
                            DRAGONFLUTE_OF_TWILIGHT);

                    if (fluteCount > 1) {
                      htmltext = "30747-17.html";
                    } else if (fluteCount == 1) {
                      final L2ItemInstance flute = getFlute(talker);

                      if (flute.getObjectId() == qs.getInt("fluteObjectId")) {
                        // TODO what if the hatchling has items in his inventory?
                        // Should they be transfered to the strider or given to the player?
                        switch (flute.getId()) {
                          case DRAGONFLUTE_OF_WIND:
                            takeItems(talker, DRAGONFLUTE_OF_WIND, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_WIND, 1);
                            break;
                          case DRAGONFLUTE_OF_STAR:
                            takeItems(talker, DRAGONFLUTE_OF_STAR, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_STAR, 1);
                            break;
                          case DRAGONFLUTE_OF_TWILIGHT:
                            takeItems(talker, DRAGONFLUTE_OF_TWILIGHT, -1);
                            giveItems(talker, DRAGON_BUGLE_OF_TWILIGHT, 1);
                            break;
                        }

                        qs.exitQuest(true, true);
                        htmltext = "30747-16.html";
                      } else {
                        npc.setTarget(talker);
                        npc.doCast(CURSE_OF_MIMYU.getSkill());
                        htmltext = "30747-18.html";
                      }
                    }
                  }
                }
                break;
              }
          }
          break;
        }
    }
    return htmltext;
  }