Package l2p.util

Examples of l2p.util.Location


      }
    }
    _flyLoc = null;
    if(skill.getFlyType() == FlyType.DUMMY || skill.getFlyType() == FlyType.CHARGE)
    {
      Location flyLoc = getFlyLocation(target, skill);
      if(flyLoc != null)
      {
        _flyLoc = flyLoc;
        broadcastPacket(new FlyToLocation(this, flyLoc, skill.getFlyType()));
      }
View Full Code Here


  private Location getFlyLocation(L2Object target, L2Skill skill)
  {
    if(target != null && target != this)
    {
      Location loc;
      double radian = Util.convertHeadingToRadian(target.getHeading());
      if(skill.isFlyToBack())
      {
        loc = new Location(target.getX() + (int) (Math.sin(radian) * 40), target.getY() - (int) (Math.cos(radian) * 40), target.getZ());
      }
      else
      {
        loc = new Location(target.getX() - (int) (Math.sin(radian) * 40), target.getY() + (int) (Math.cos(radian) * 40), target.getZ());
      }
      if(isFlying())
      {
        if(isPlayer() && ((L2Player) this).isInFlyingTransform() && (loc.z <= 0 || loc.z >= 6000))
        {
          return null;
        }
        if(GeoEngine.moveCheckInAir(getX(), getY(), getZ(), loc.x, loc.y, loc.z, getColRadius(), getReflection().getGeoIndex()) == null)
        {
          return null;
        }
      }
      else
      {
        loc.correctGeoZ();
        if(!GeoEngine.canMoveToCoord(getX(), getY(), getZ(), loc.x, loc.y, loc.z, getReflection().getGeoIndex()))
        {
          loc = target.getLoc(); // Если не получается встать рядом с объектом, пробуем встать прямо в него
          if(!GeoEngine.canMoveToCoord(getX(), getY(), getZ(), loc.x, loc.y, loc.z, getReflection().getGeoIndex()))
          {
View Full Code Here

   */
  public Location getIntersectionPoint(L2Character target)
  {
    if(!isInFront(target, 90))
    {
      return new Location(target.getX(), target.getY(), target.getZ());
    }
    double angle = Util.convertHeadingToDegree(target.getHeading()); // угол в градусах
    double radian = Math.toRadians(angle - 90); // угол в радианах
    double range = target.getMoveSpeed() / 2; // расстояние, пройденное за 1 секунду, равно скорости. Берем половину.
    return new Location((int) (target.getX() - range * Math.sin(radian)), (int) (target.getY() + range * Math.cos(radian)), target.getZ());
  }
View Full Code Here

    long dy = points.get(points.size() - 1).y - points.get(0).y;
    long dz = points.get(points.size() - 1).z - points.get(0).z;
    double distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
    if(distance <= offset)
    {
      Location point = points.get(0);
      points.clear();
      points.add(point);
      return points;
    }
    if(distance >= 1)
View Full Code Here

  }

  public boolean buildPathTo(int dest_x, int dest_y, int dest_z, int offset, boolean pathFind, boolean _follow)
  {
    int ref = getReflection().getGeoIndex();
    Location dest;
    if(_forestalling && isFollow && getFollowTarget() != null && getFollowTarget().isMoving)
    {
      dest = getIntersectionPoint(getFollowTarget());
    }
    else
    {
      dest = new Location(dest_x, dest_y, dest_z);
    }
    if(isInVehicle() || isVehicle())
    {
      applyOffset(dest, offset);
      return setSimplePath(dest);
    }
    if(isFlying() || isSwimming() || isInWater() || L2World.isWater(dest))
    {
      applyOffset(dest, offset);
      if(GeoEngine.canSeeCoord(this, dest.x, dest.y, dest.z, isFlying()))
      {
        return setSimplePath(dest);
      }
      Location nextloc;
      if(isFlying())
      {
        nextloc = GeoEngine.moveCheckInAir(getX(), getY(), getZ(), dest.x, dest.y, dest.z, getColRadius(), ref);
      }
      else
      {
        nextloc = GeoEngine.moveInWaterCheck(getX(), getY(), getZ(), dest.x, dest.y, dest.z, ref);
      }
      if(nextloc != null && !nextloc.equals(getX(), getY(), getZ()))
      {
        return setSimplePath(nextloc);
      }
      return false;
    }
View Full Code Here

  public boolean moveToLocation(int x_dest, int y_dest, int z_dest, int offset, boolean pathfinding)
  {
    synchronized(_targetRecorder)
    {
      offset = Math.max(offset, 0);
      Location dst_geoloc = new Location(x_dest, y_dest, z_dest).world2geo();
      if(isMoving && !isFollow && movingDestTempPos.equals(dst_geoloc))
      {
        sendActionFailed();
        return true;
      }
      getAI().clearNextAction();
      if(isMovementDisabled())
      {
        getAI().setNextAction(nextAction.MOVE, new Location(x_dest, y_dest, z_dest), offset, pathfinding, false);
        sendActionFailed();
        return false;
      }
      isFollow = false;
      if(_moveTask != null)
View Full Code Here

      stopMove();
      return;
    }
    if(!firstMove)
    {
      Location dest = destination;
      if(dest != null)
      {
        setLoc(dest, true);
      }
    }
    double distance;
    synchronized(_targetRecorder)
    {
      if(_targetRecorder.isEmpty())
      {
        isMoving = false;
        destination = null;
        if(isFollow)
        {
          isFollow = false;
          ThreadPoolManager.getInstance().executeAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_TARGET, null, null), isPlayable());
        }
        else
        {
          ThreadPoolManager.getInstance().executeAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED, null, null), isPlayable());
        }
        validateLocation(isPlayer() ? 2 : 1);
        return;
      }
      moveList = _targetRecorder.remove(0);
      Location begin = moveList.get(0).clone().geo2world();
      Location end = moveList.get(moveList.size() - 1).clone().geo2world();
      destination = end;
      distance = begin.distance3D(end);
      isMoving = true;
    }
    broadcastMove();
View Full Code Here

    }
    else if(skill.getSoulsConsume() > 0)
    {
      setConsumedSouls(getConsumedSouls() - skill.getSoulsConsume(), null);
    }
    Location flyLoc;
    switch(skill.getFlyType())
    {
      case THROW_UP:
      case THROW_HORIZONTAL:
        for(L2Character target : targets)
View Full Code Here

  {
    if(target == null || target == this)
    {
      return;
    }
    setHeading(new Location(target.getX(), target.getY(), target.getZ()), toChar); // не менять на getLoc() иначе будет цикл из за getHeading() внутри getLoc()
  }
View Full Code Here

    abortCast(true);
    if(isPlayable())
    {
      clearHateList(true);
    }
    if(!isVehicle() && !isFlying() && !L2World.isWater(new Location(x, y, z)))
    {
      z = GeoEngine.getHeight(x, y, z, getReflection().getGeoIndex());
    }
    if(isPlayer() && DimensionalRiftManager.getInstance().checkIfInRiftZone(getLoc(), true))
    {
      L2Player player = (L2Player) this;
      if(player.isInParty() && player.getParty().isInDimensionalRift())
      {
        Location newCoords = DimensionalRiftManager.getInstance().getRoom(0, 0).getTeleportCoords();
        x = newCoords.x;
        y = newCoords.y;
        z = newCoords.z;
        player.getParty().getDimensionalRift().usedTeleport(player);
      }
View Full Code Here

TOP

Related Classes of l2p.util.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.