@Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    if (player.getClan() == null) {
      return null;
    }

    QuestState st = null;

    if (player.isClanLeader()) {
      st = player.getQuestState(getClass());
    } else {
      L2PcInstance pleader = player.getClan().getLeader().getPlayerInstance();
      if (pleader != null && player.isInsideRadius(pleader, 1500, true, false)) {
        st = pleader.getQuestState(getClass());
      }
    }

    if (st != null && st.isStarted()) {
      int raid = st.getInt("raid");
      if (REWARD_POINTS.containsKey(raid)) {
        if (npc.getNpcId() == REWARD_POINTS.get(raid)[0]
            && !st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
          st.rewardItems(REWARD_POINTS.get(raid)[1], 1);
          st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
        }
      }
    }
    return null;
  }
示例#2
0
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) {
      return;
    }
    if (player.getClan() == null) {
      player.sendPacket(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER);
      return;
    }
    if (!player.isClanLeader()) {
      player.sendPacket(SystemMessageId.ONLY_CLAN_LEADER_WITHDRAW_ALLY);
      return;
    }
    L2Clan clan = player.getClan();
    if (clan.getAllyId() == 0) {
      player.sendPacket(SystemMessageId.NO_CURRENT_ALLIANCES);
      return;
    }
    if (clan.getClanId() == clan.getAllyId()) {
      player.sendPacket(SystemMessageId.ALLIANCE_LEADER_CANT_WITHDRAW);
      return;
    }

    long currentTime = System.currentTimeMillis();
    clan.setAllyId(0);
    clan.setAllyName(null);
    clan.changeAllyCrest(0, true);
    clan.setAllyPenaltyExpiryTime(
        currentTime + Config.ALT_ALLY_JOIN_DAYS_WHEN_LEAVED * 86400000L,
        L2Clan.PENALTY_TYPE_CLAN_LEAVED); // 24*60*60*1000 = 86400000
    clan.updateClanInDB();

    player.sendPacket(SystemMessageId.YOU_HAVE_WITHDRAWN_FROM_ALLIANCE);
  }
示例#3
0
 public L2ClanMember(L2PcInstance player) {
   if (player.getClan() == null) {
     throw new IllegalArgumentException("Can not create a ClanMember if player has a null clan.");
   }
   _clan = player.getClan();
   _player = player;
   _name = _player.getName();
   _level = _player.getLevel();
   _classId = _player.getBaseClassId();
   _objectId = _player.getObjectId();
   _powerGrade = _player.getPowerGrade();
   _pledgeType = _player.getPledgeType();
   _title = _player.getTitle();
   _apprentice = 0;
   _sponsor = 0;
   _sex = _player.getAppearance().getSex();
   _raceOrdinal = _player.getRace().ordinal();
 }
  @Override
  public String onTalk(L2Npc npc, QuestState st) {
    L2PcInstance player = st.getPlayer();

    L2Clan clan = player.getClan();

    switch (st.getState()) {
      case CREATED:
        return clan == null || !player.isClanLeader() || clan.getLevel() < 6
            ? "31331-0a.htm"
            : "31331-0b.htm";
      case STARTED:
        if (clan == null || !player.isClanLeader()) {
          st.exitQuest(QuestType.REPEATABLE);
          return "31331-6.html";
        }

        int raid = st.getInt("raid");

        if (REWARD_POINTS.containsKey(raid)) {
          if (st.hasQuestItems(REWARD_POINTS.get(raid)[1])) {
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_1);
            st.takeItems(REWARD_POINTS.get(raid)[1], -1);
            clan.addReputationScore(REWARD_POINTS.get(raid)[2], true);
            player.sendPacket(
                SystemMessage.getSystemMessage(
                        SystemMessageId.CLAN_QUEST_COMPLETED_AND_S1_POINTS_GAINED)
                    .addNumber(REWARD_POINTS.get(raid)[2]));
            clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
            return "31331-" + raid + "b.html";
          } else {
            return "31331-" + raid + "a.html";
          }
        } else {
          return "31331-0.html";
        }
    }
    return null;
  }
  @Override
  public String onAsk(L2PcInstance player, L2Npc npc, int ask, int reply) {
    int ownerId;
    if (ask == -1724) {
      switch (reply) {
        case 1: // Взойти на корабль
          if (player.isTransformed()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_TRANSFORMED);
            return null;
          }
          if (player.isParalyzed()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_PETRIFIED);
            return null;
          }
          if (player.isDead() || player.isFakeDeath()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_DEAD);
            return null;
          }
          if (player.isFishing()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_FISHING);
            return null;
          }
          if (player.isInCombat()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_IN_BATTLE);
            return null;
          }
          if (player.isInDuel()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_IN_A_DUEL);
            return null;
          }
          if (player.isSitting()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_SITTING);
            return null;
          }
          if (player.isCastingNow()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_CASTING);
            return null;
          }
          if (player.isCursedWeaponEquipped()) {
            player.sendPacket(
                SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_A_CURSED_WEAPON_IS_EQUIPPED);
            return null;
          }
          if (player.isCombatFlagEquipped()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_HOLDING_A_FLAG);
            return null;
          }
          if (!player.getPets().isEmpty() || player.isMounted()) {
            player.sendPacket(
                SystemMessageId.YOU_CANNOT_BOARD_AN_AIRSHIP_WHILE_A_PET_OR_A_SERVITOR_IS_SUMMONED);
            return null;
          }
          if (player.isFlyingMounted()) {
            player.sendPacket(SystemMessageId.YOU_CANNOT_BOARD_NOT_MEET_REQUEIREMENTS);
            return null;
          }

          if (_dockedShip != null) {
            _dockedShip.addPassenger(player);
          }
          break;
        case 2: // Призвать корабль
          if (_dockedShip != null) {
            if (_dockedShip.isOwner(player)) {
              player.sendPacket(SystemMessageId.THE_AIRSHIP_IS_ALREADY_EXISTS);
            }
            return null;
          }
          if (_isBusy) {
            player.sendPacket(SystemMessageId.ANOTHER_AIRSHIP_ALREADY_SUMMONED);
            return null;
          }
          if ((player.getClanPrivileges() & L2Clan.CP_CL_SUMMON_AIRSHIP)
              != L2Clan.CP_CL_SUMMON_AIRSHIP) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_NO_PRIVILEGES);
            return null;
          }
          ownerId = player.getClanId();
          if (!AirShipManager.getInstance().hasAirShipLicense(ownerId)) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_NEED_LICENSE_TO_SUMMON);
            return null;
          }
          if (AirShipManager.getInstance().hasAirShip(ownerId)) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_ALREADY_USED);
            return null;
          }
          if (!player.destroyItemByItemId(ProcessType.CONSUME, STARSTONE, SUMMON_COST, npc, true)) {
            player.sendPacket(
                SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NEED_MORE_S1)
                    .addItemName(STARSTONE));
            return null;
          }

          _isBusy = true;
          L2AirShipInstance ship =
              AirShipManager.getInstance()
                  .getNewAirShip(_shipSpawnX, _shipSpawnY, _shipSpawnZ, _shipHeading, ownerId);
          if (ship != null) {
            if (_arrivalPath != null) {
              ship.executePath(_arrivalPath);
            }

            if (_arrivalMessage == null) {
              _arrivalMessage =
                  new NS(
                      npc.getObjectId(),
                      ChatType.SHOUT,
                      npc.getNpcId(),
                      NpcStringId
                          .THE_AIRSHIP_HAS_BEEN_SUMMONED_IT_WILL_AUTOMATICALLY_DEPART_IN_5_MINUTES);
            }

            npc.broadcastPacket(_arrivalMessage);
          } else {
            _isBusy = false;
          }
          break;
        case 3: // Подать заявку
          if (player.getClan() == null || player.getClan().getLevel() < 5) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_NEED_CLANLVL_5_TO_SUMMON);
            return null;
          }
          if (!player.isClanLeader()) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_NO_PRIVILEGES);
            return null;
          }
          ownerId = player.getClanId();
          if (AirShipManager.getInstance().hasAirShipLicense(ownerId)) {
            player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
            return null;
          }
          if (!player.destroyItemByItemId(ProcessType.CONSUME, LICENSE, 1, npc, true)) {
            player.sendPacket(
                SystemMessage.getSystemMessage(SystemMessageId.THE_AIRSHIP_NEED_MORE_S1)
                    .addItemName(STARSTONE));
            return null;
          }

          AirShipManager.getInstance().registerLicense(ownerId);
          player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ENTERED);
          break;
      }
    } else if (ask == -2011) {
      switch (reply) {
        case 1: // Отправиться в Семя Бессмертия
          player.teleToLocation(-212808, 209672, 4257);
          return null;
        case 2: // Отправиться в Семя Разрушения
          player.teleToLocation(-248536, 250280, 4311);
          return null;
        case 3: // Отправиться в Семя Уничтожения
          player.teleToLocation(-175512, 154488, 2689);
          return null;
        case 4:
          player.teleToLocation(-149406, 255247, -80);
          return null;
        case 5: // Отправиться в Семя Индустриализции
          if (player.getLevel() >= 95) {
            player.teleToLocation(-147348, 152615, -14048);
            return null;
          }
      }
    }
    return null;
  }
示例#6
0
  public int calculatePledgeClass(L2PcInstance player) {
    int pledgeClass = 0;

    if (player == null) {
      return pledgeClass;
    }

    L2Clan clan = player.getClan();
    if (clan != null) {
      switch (clan.getLevel()) {
        case 4:
          if (player.isClanLeader()) {
            pledgeClass = 3;
          }
          break;
        case 5:
          pledgeClass = player.isClanLeader() ? 4 : 2;
          break;
        case 6:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 2;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 5;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 4;
                    break;
                  case -1:
                  default:
                    pledgeClass = 3;
                    break;
                }
              }
              break;
          }
          break;
        case 7:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 3;
              break;
            case 1001:
            case 1002:
            case 2001:
            case 2002:
              pledgeClass = 2;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 7;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 6;
                    break;
                  case 1001:
                  case 1002:
                  case 2001:
                  case 2002:
                    pledgeClass = 5;
                    break;
                  case -1:
                  default:
                    pledgeClass = 4;
                    break;
                }
              }
              break;
          }
          break;
        case 8:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 4;
              break;
            case 1001:
            case 1002:
            case 2001:
            case 2002:
              pledgeClass = 3;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 8;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 7;
                    break;
                  case 1001:
                  case 1002:
                  case 2001:
                  case 2002:
                    pledgeClass = 6;
                    break;
                  case -1:
                  default:
                    pledgeClass = 5;
                    break;
                }
              }
              break;
          }
          break;
        case 9:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 5;
              break;
            case 1001:
            case 1002:
            case 2001:
            case 2002:
              pledgeClass = 4;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 9;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 8;
                    break;
                  case 1001:
                  case 1002:
                  case 2001:
                  case 2002:
                    pledgeClass = 7;
                    break;
                  case -1:
                  default:
                    pledgeClass = 6;
                    break;
                }
              }
              break;
          }
          break;
        case 10:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 6;
              break;
            case 1001:
            case 1002:
            case 2001:
            case 2002:
              pledgeClass = 5;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 10;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 9;
                    break;
                  case 1001:
                  case 1002:
                  case 2001:
                  case 2002:
                    pledgeClass = 8;
                    break;
                  case -1:
                  default:
                    pledgeClass = 7;
                    break;
                }
              }
              break;
          }
          break;
        case 11:
          switch (player.getPledgeType()) {
            case -1:
              pledgeClass = 1;
              break;
            case 100:
            case 200:
              pledgeClass = 7;
              break;
            case 1001:
            case 1002:
            case 2001:
            case 2002:
              pledgeClass = 6;
              break;
            case 0:
              if (player.isClanLeader()) {
                pledgeClass = 11;
              } else {
                switch (clan.getLeaderSubPledge(player.getObjectId())) {
                  case 100:
                  case 200:
                    pledgeClass = 10;
                    break;
                  case 1001:
                  case 1002:
                  case 2001:
                  case 2002:
                    pledgeClass = 9;
                    break;
                  case -1:
                  default:
                    pledgeClass = 8;
                    break;
                }
              }
              break;
          }
          break;
        default:
          pledgeClass = 1;
          break;
      }
    }
    return pledgeClass;
  }