Exemple #1
0
  public EnterInstanceResult reEnterInstance(L2PcInstance player) {
    InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);

    if (world != null) {
      if (!(world instanceof FortunaWorld)) {
        player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
        return EnterInstanceResult.ANOTHER_INSTANCE;
      }

      if (!((FortunaWorld) world).playersInside.contains(player)) {
        ((FortunaWorld) world).playersInside.add(player);
        world.allowed.add(Integer.valueOf(player.getObjectId()));
      }

      player.teleToInstance(LAIR_ENTRANCE, world.instanceId);
      return EnterInstanceResult.OK;
    }
    return EnterInstanceResult.CANNOT_REENTER;
  }
Exemple #2
0
  protected EnterInstanceResult enterInstance(L2PcInstance player, String template) {
    InstanceManager.InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);

    if (world != null) {
      if (!(world instanceof FortunaWorld)) {
        player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
        return EnterInstanceResult.ANOTHER_INSTANCE;
      }
    }

    world = new FortunaWorld();

    int instanceTemplateId = InstanceZoneId.FORTUNA.getId();
    EnterInstanceResult reason = checkConditions(player, instanceTemplateId);
    if (reason != EnterInstanceResult.OK) {
      return reason;
    }
    int instanceId = InstanceManager.getInstance().createDynamicInstance(template);

    world.instanceId = instanceId;
    world.templateId = instanceTemplateId;
    world.status = 0;

    InstanceManager.getInstance().addWorld(world);
    init((FortunaWorld) world);

    if ((player.isGM()) && (player.getParty() == null)) {
      player.teleToInstance(ENTRANCE, instanceId);
      world.allowed.add(Integer.valueOf(player.getObjectId()));
      ((FortunaWorld) world).playersInside.add(player);
      return EnterInstanceResult.OK;
    }

    if (player.getParty() != null) {
      for (L2PcInstance member : player.getParty().getMembers()) {
        member.teleToInstance(ENTRANCE, instanceId);
        world.allowed.add(Integer.valueOf(member.getObjectId()));
        ((FortunaWorld) world).playersInside.add(member);
      }
      return EnterInstanceResult.OK;
    }
    return EnterInstanceResult.NO_PARTY;
  }
Exemple #3
0
  private EnterInstanceResult checkConditions(L2PcInstance player, int instanceTemplateId) {
    L2Party party = player.getParty();

    if (player.isGM()) {
      Long reEnterTime =
          Long.valueOf(
              InstanceManager.getInstance()
                  .getInstanceTime(player.getObjectId(), instanceTemplateId));
      if (System.currentTimeMillis() < reEnterTime.longValue()) {
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET)
                .addPcName(player));
        return EnterInstanceResult.LOCKED_DUE_TO_ENTER_TIME;
      }
      return EnterInstanceResult.OK;
    }

    if (player.getParty() == null) {
      player.sendPacket(SystemMessageId.NOT_IN_PARTY_CANT_ENTER);
      return EnterInstanceResult.NO_PARTY;
    }

    int minPlayers = ConfigGrandBoss.MIN_FORTUNA_PLAYERS;
    int maxPlayers = ConfigGrandBoss.MAX_FORTUNA_PLAYERS;
    int minLevel = ConfigGrandBoss.MIN_LEVEL_FORTUNA_PLAYERS;

    if (party.getLeader() != player) {
      party.getCommandChannel().broadcastMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_ENTER);
      return EnterInstanceResult.NOT_LEADER;
    }
    if (party.getMemberCount() > maxPlayers) {
      party.broadcastMessage(SystemMessageId.PARTY_EXCEEDED_THE_LIMIT_CANT_ENTER);
      return EnterInstanceResult.TOO_MANY_MEMBERS;
    }
    if (party.getMemberCount() < minPlayers) {
      party.broadcastPacket(
          SystemMessage.getSystemMessage(
                  SystemMessageId.NOT_ENOUGH_PEOPLE_TO_ENTER_INSTANCE_ZONE_NEED_S1)
              .addNumber(minPlayers));
      return EnterInstanceResult.TOO_LESS_MEMBERS;
    }

    for (L2PcInstance member : party.getMembers()) {
      if ((member == null) || (member.getLevel() < minLevel) || (!member.isAwakened())) {
        party.broadcastPacket(
            SystemMessage.getSystemMessage(SystemMessageId.C1_LEVEL_REQUIREMENT_NOT_SUFFICIENT)
                .addPcName(member));
        return EnterInstanceResult.TOO_LOW_LEVEL;
      }
      if (!Util.checkIfInRange(1000, player, member, true)) {
        party.broadcastPacket(
            SystemMessage.getSystemMessage(SystemMessageId.C1_IS_IN_LOCATION_THAT_CANNOT_BE_ENTERED)
                .addPcName(member));
        return EnterInstanceResult.MEMBER_OUT_OF_RANGE;
      }
      Long reEnterTime =
          Long.valueOf(
              InstanceManager.getInstance()
                  .getInstanceTime(member.getObjectId(), instanceTemplateId));
      if (System.currentTimeMillis() < reEnterTime.longValue()) {
        party.broadcastPacket(
            SystemMessage.getSystemMessage(SystemMessageId.C1_MAY_NOT_REENTER_YET)
                .addPcName(member));
        return EnterInstanceResult.LOCKED_DUE_TO_ENTER_TIME;
      }
    }
    return EnterInstanceResult.OK;
  }