Exemplo n.º 1
0
  /**
   * Did a situation occur in which the duel has to be ended?
   *
   * @return DuelResult duel status
   */
  public DuelResult checkEndDuelCondition() {
    // one of the players might leave during duel
    if ((_playerA == null) || (_playerB == null)) {
      return DuelResult.Canceled;
    }

    // got a duel surrender request?
    if (_surrenderRequest != 0) {
      if (_surrenderRequest == 1) {
        return DuelResult.Team1Surrender;
      }
      return DuelResult.Team2Surrender;
    }
    // duel timed out
    else if (getRemainingTime() <= 0) {
      return DuelResult.Timeout;
    }
    // Has a player been declared winner yet?
    else if (_playerA.getDuelState() == DUELSTATE_WINNER) {
      // If there is a Winner already there should be no more fighting going on
      stopFighting();
      return DuelResult.Team1Win;
    } else if (_playerB.getDuelState() == DUELSTATE_WINNER) {
      // If there is a Winner already there should be no more fighting going on
      stopFighting();
      return DuelResult.Team2Win;
    }

    // More end duel conditions for 1on1 duels
    else if (!_partyDuel) {
      // Duel was interrupted e.g.: player was attacked by mobs / other players
      if ((_playerA.getDuelState() == DUELSTATE_INTERRUPTED)
          || (_playerB.getDuelState() == DUELSTATE_INTERRUPTED)) {
        return DuelResult.Canceled;
      }

      // Are the players too far apart?
      if (!_playerA.isInsideRadius(_playerB, 1600, false, false)) {
        return DuelResult.Canceled;
      }

      // Did one of the players engage in PvP combat?
      if (isDuelistInPvp(true)) {
        return DuelResult.Canceled;
      }

      // is one of the players in a Siege, Peace or PvP zone?
      if (_playerA.isInsideZone(ZoneId.PEACE)
          || _playerB.isInsideZone(ZoneId.PEACE)
          || _playerA.isInsideZone(ZoneId.SIEGE)
          || _playerB.isInsideZone(ZoneId.SIEGE)
          || _playerA.isInsideZone(ZoneId.PVP)
          || _playerB.isInsideZone(ZoneId.PVP)) {
        return DuelResult.Canceled;
      }
    }

    return DuelResult.Continue;
  }
Exemplo n.º 2
0
 /**
  * Get the duel looser
  *
  * @return looser
  */
 public L2PcInstance getLooser() {
   if (!getFinished() || (_playerA == null) || (_playerB == null)) {
     return null;
   }
   if (_playerA.getDuelState() == DUELSTATE_WINNER) {
     return _playerB;
   } else if (_playerB.getDuelState() == DUELSTATE_WINNER) {
     return _playerA;
   }
   return null;
 }
Exemplo n.º 3
0
  /**
   * This function is called whenever a player was defeated in a duel
   *
   * @param player the player defeated.
   */
  public void onPlayerDefeat(L2PcInstance player) {
    // Set player as defeated
    player.setDuelState(DUELSTATE_DEAD);

    if (_partyDuel) {
      boolean teamdefeated = true;
      for (L2PcInstance temp : player.getParty().getMembers()) {
        if (temp.getDuelState() == DUELSTATE_DUELLING) {
          teamdefeated = false;
          break;
        }
      }

      if (teamdefeated) {
        L2PcInstance winner = _playerA;
        if (_playerA.getParty().getMembers().contains(player)) {
          winner = _playerB;
        }

        for (L2PcInstance temp : winner.getParty().getMembers()) {
          temp.setDuelState(DUELSTATE_WINNER);
        }
      }
    } else {
      if ((player != _playerA) && (player != _playerB)) {
        _log.warning("Error in onPlayerDefeat(): player is not part of this 1vs1 duel");
      }

      if (_playerA == player) {
        _playerB.setDuelState(DUELSTATE_WINNER);
      } else {
        _playerA.setDuelState(DUELSTATE_WINNER);
      }
    }
  }