@Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    if (npc.getNpcId() == EDRIC) {
      if (player.getLevel() < 75) {
        return "32527-00.htm";
      } else if (st.isCreated()) {
        return "32527-01.htm";
      } else if (player.isGM()) {
        st.startQuest();
        return "32527-10.html";
      } else if (st.getCond() == 1) {
        L2Party party = player.getParty();
        if (st.getInt("timeDiff") > 0) {
          if (giveReward(st, st.getInt("timeDiff"))) {
            // Clear quest
            st.unset("timeDiff");
            st.unset("cond");
            st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
            st.exitQuest(QuestType.REPEATABLE);
            return "32527-reward.html";
          } else {
            // Clear quest
            st.unset("timeDiff");
            st.unset("cond");
            st.playSound(QuestSound.ITEMSOUND_QUEST_FINISH);
            st.exitQuest(QuestType.REPEATABLE);
            return "32527-noreward.html";
          }
        } else if (party == null) {
          return "32527-noparty.html";
        } else if (!party.getLeader().equals(player)) {
          return prepareHtml(player, "32527-noleader.html", party.getLeader().getName());
        } else {
          for (L2PcInstance pm : party.getMembers()) {
            QuestState state = pm.getQuestState(getClass());
            if (state == null || state.getCond() != 1) {
              return prepareHtml(player, "32527-noquest.html", pm.getName());
            }
          }
          return "32527-10.html";
        }
      }
    }
    return null;
  }
Ejemplo n.º 2
0
  @Override
  public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets) {
    if (!(activeChar instanceof L2PcInstance)) {
      return;
    }

    boolean isMastersCall = skill.getId() == 23249;

    L2PcInstance activePlayer = activeChar.getActingPlayer();

    if (!isMastersCall && !activePlayer.getSummonFriendController().checkSummonerStatus()) {
      return;
    }

    try {
      for (L2Character target : (L2Character[]) targets) {
        if (target == null || activeChar.equals(target) || !target.isPlayer()) {
          continue;
        }

        if (isMastersCall) // Master's Call
        {
          L2Party party = target.getParty();
          if (party != null) {
            party
                .getMembers()
                .stream()
                .filter(partyMember -> !target.equals(partyMember))
                .forEach(
                    partyMember ->
                        partyMember.teleToLocation(
                            target.getX(), target.getY(), target.getZ(), true));
          } else {
            activePlayer.sendPacket(
                SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                    .addSkillName(skill));
          }
        } else {
          if (skill.isClanSkill()) // Призыв Клана
          {
            if (!target.getActingPlayer().isInSameClan(activePlayer)) {
              activePlayer.sendPacket(
                  SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                      .addSkillName(skill));
              continue;
            } else if (!target.getActingPlayer().isInSameParty(activePlayer)) {
              activePlayer.sendPacket(
                  SystemMessage.getSystemMessage(SystemMessageId.S1_CANNOT_BE_USED)
                      .addSkillName(skill));
              continue;
            }
          }

          L2PcInstance targetPlayer = target.getActingPlayer();

          if (!Util.checkIfInRange(500, activeChar, target, false)) {
            if (!targetPlayer.getSummonFriendController().setSummoner(activePlayer, skill)) {
              SystemMessage sm =
                  SystemMessage.getSystemMessage(SystemMessageId.C1_ALREADY_SUMMONED);
              sm.addString(target.getName());
              activePlayer.sendPacket(sm);
            }

            ConfirmDlg confirm =
                new ConfirmDlg(
                    SystemMessageId.C1_WISHES_TO_SUMMON_YOU_FROM_S2_DO_YOU_ACCEPT.getId());
            confirm.addCharName(activeChar);
            confirm.addZoneName(activeChar.getX(), activeChar.getY(), activeChar.getZ());
            confirm.addTime(30000);
            confirm.addRequesterId(activePlayer.getObjectId());
            target.sendPacket(confirm);
            // targetPlayer.getSummonFriendController().teleport();
          }
        }
      }
    } catch (Exception e) {
      _log.log(Level.ERROR, "", e);
    }
  }