public void start(Player player, int type, NpcInstance npc) {
    if (!player.isInParty()) {
      showHtmlFile(player, "rift/NoParty.htm", npc);
      return;
    }

    if (!player.isGM()) {
      if (!player.getParty().isLeader(player)) {
        showHtmlFile(player, "rift/NotPartyLeader.htm", npc);
        return;
      }

      if (player.getParty().isInDimensionalRift()) {
        showHtmlFile(player, "rift/Cheater.htm", npc);

        if (!player.isGM())
          _log.warn(
              "Player "
                  + player.getName()
                  + "("
                  + player.getObjectId()
                  + ") was cheating in dimension rift area!");

        return;
      }

      if (player.getParty().getMemberCount() < Config.RIFT_MIN_PARTY_SIZE) {
        showHtmlFile(player, "rift/SmallParty.htm", npc);
        return;
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!checkIfInPeaceZone(p.getLoc())) {
          showHtmlFile(player, "rift/NotInWaitingRoom.htm", npc);
          return;
        }

      ItemInstance i;
      for (Player p : player.getParty().getPartyMembers()) {
        i = p.getInventory().getItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID);
        if (i == null || i.getCount() < getNeededItems(type)) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
      }

      for (Player p : player.getParty().getPartyMembers())
        if (!p.getInventory()
            .destroyItemByItemId(DIMENSIONAL_FRAGMENT_ITEM_ID, getNeededItems(type))) {
          showHtmlFile(player, "rift/NoFragments.htm", npc);
          return;
        }
    }

    new DimensionalRift(player.getParty(), type, Rnd.get(1, _rooms.get(type).size() - 1));
  }
Beispiel #2
0
  @Override
  protected boolean thinkActive() {
    NpcInstance actor = getActor();
    Player player;

    // follow the player
    double distance;

    if (targetPlayers != null && targetPlayers.size() > 0 && followTargetIndex > 0) {
      player = targetPlayers.get(followTargetIndex - 1);

      // in case the player set to follow is null, fall back to the first player in the list
      if (player == null) player = targetPlayers.get(0);

      distance = (int) actor.getDistance(player);

      if (distance > maxFollowDistance) {
        if (GeoEngine.canSeeTarget(actor, player, false)) {
          // in case the NPC can see the player
          actor.setRunning();
          Location loc =
              new Location(
                  player.getX() + Rnd.get(-60, 60),
                  player.getY() + Rnd.get(-60, 60),
                  player.getZ());
          actor.followToCharacter(loc, player, minFollowDistance, false);
        } else {
          // in case the NPC cannot see the player, then teleport straight to him
          actor.teleToLocation(player.getLoc().getRandomLoc(100));
        }
        return true;
      }
    }

    return startAttack();
  }
Beispiel #3
0
 public static Location getRestartLocation(Player player, RestartType restartType) {
   return getRestartLocation(player, player.getLoc(), restartType);
 }
  public void teleportPlayer(FightBattleArenaObject arena) {
    Player player = _player;
    if (player == null) return;

    if (player.isTeleporting()) {
      _player = null;
      return;
    }

    if (player.isInObserverMode()) {
      if (player.getOlympiadObserveGame() != null) player.leaveOlympiadObserverMode(true);
      else player.leaveObserverMode();
    }

    // Un activate clan skills
    if (player.getClan() != null) player.getClan().disableSkills(player);

    // Remove Hero Skills
    player.activateHeroSkills(false);

    // Abort casting if player casting
    if (player.isCastingNow()) player.abortCast(true, true);

    // Abort attack if player attacking
    if (player.isAttackingNow()) player.abortAttack(true, true);

    // Удаляем баффы и чужие кубики
    for (Effect e : player.getEffectList().getEffects()) {
      if (!player.isSpecialEffect(e.getSkill())
          && (e.getEffectType() != EffectType.Cubic
              || player.getSkillLevel(e.getSkill().getId()) <= 0)) e.exit();
    }

    // Remove Servitor's Buffs
    Servitor[] servitors = player.getServitors();
    if (servitors.length > 0) {
      for (Servitor servitor : servitors) {
        if (servitor.isPet()) servitor.unSummon(false);
        else {
          servitor.getEffectList().stopAllEffects();
          servitor.transferOwnerBuffs();
        }
      }
    }

    // unsummon agathion
    if (player.getAgathionId() > 0) player.setAgathion(0);

    // Сброс кулдауна всех скилов, время отката которых меньше 15 минут
    for (TimeStamp sts : player.getSkillReuses()) {
      if (sts == null) continue;

      Skill skill = SkillTable.getInstance().getInfo(sts.getId(), sts.getLevel());
      if (skill == null) continue;

      if (sts.getReuseBasic() <= 15 * 60001L) player.enableSkill(skill);
    }

    // Обновляем скилл лист, после удаления скилов
    player.sendPacket(new SkillList(player));

    // Обновляем куллдаун, после сброса
    player.sendPacket(new SkillCoolTime(player));

    // Проверяем одетые вещи на возможность ношения.
    player.getInventory().validateItems();

    // remove bsps/sps/ss automation
    Set<Integer> activeSoulShots = player.getAutoSoulShot();
    for (int itemId : activeSoulShots) {
      player.removeAutoSoulShot(itemId);
      player.sendPacket(new ExAutoSoulShot(itemId, false));
    }

    // Разряжаем заряженные соул и спирит шоты
    ItemInstance weapon = player.getActiveWeaponInstance();
    if (weapon != null) {
      weapon.setChargedSpiritshot(ItemInstance.CHARGED_NONE);
      weapon.setChargedSoulshot(ItemInstance.CHARGED_NONE);
    }

    player.setCurrentCp(player.getMaxCp());
    player.setCurrentMp(player.getMaxMp());

    if (player.isDead()) {
      player.setCurrentHp(player.getMaxHp(), true);
      player.broadcastPacket(new Revive(player));
      // player.broadcastStatusUpdate();
    } else player.setCurrentHp(player.getMaxHp(), false);

    player.broadcastUserInfo(true);

    DuelEvent duel = player.getEvent(DuelEvent.class);
    if (duel != null) duel.abortDuel(player);

    _returnLoc = player.getStablePoint() == null ? player.getLoc() : player.getStablePoint();

    if (player.isSitting()) player.standUp();

    player.setTarget(null);

    player.leaveParty();

    player.setStablePoint(_returnLoc);

    Location loc =
        arena.getMember1() == this
            ? arena.getInfo().getTeleportLoc1()
            : arena.getInfo().getTeleportLoc2();
    player.teleToLocation(
        Location.findPointToStay(loc, 0, arena.getReflection().getGeoIndex()),
        arena.getReflection());

    setDamage(0.);
    setKilled(false);
  }