protected boolean checkObjectInRange(VisibleObject newObject) {
    // check if Z distance is greater than maxZvisibleDistance
    if (Math.abs(owner.getZ() - newObject.getZ()) > owner.getMaxZVisibleDistance()) {
      return false;
    }

    return MathUtil.isInRange(owner, newObject, owner.getVisibilityDistance());
  }
示例#2
0
文件: Skill.java 项目: soulxj/aion-cn
 public boolean shouldAffectTarget(VisibleObject object) {
   // If creature is at least 2 meters above the terrain, ground skill cannot be applied
   if (GeoDataConfig.GEO_ENABLE) {
     if (isGroundSkill()) {
       if ((object.getZ() - GeoService.getInstance().getZ(object) > 1.0f)
           || (object.getZ() - GeoService.getInstance().getZ(object) < -2.0f)) return false;
     }
     return GeoService.getInstance().canSee(getFirstTarget(), object);
   }
   return true;
 }
 public double getDistanceToTarget() {
   if (isFollowTarget) {
     VisibleObject target = owner.getTarget();
     if (target != null)
       return MathUtil.getDistance(
           owner.getX(), owner.getY(), owner.getZ(), target.getX(), target.getY(), target.getZ());
   }
   return MathUtil.getDistance(
       owner.getX(), owner.getY(), owner.getZ(), targetX, targetY, targetZ);
 }
 /**
  * Returns MapRegion that contains coordinates of VisibleObject. If the region doesn't exist, it's
  * created.
  *
  * @param object
  * @return a MapRegion
  */
 MapRegion getRegion(VisibleObject object) {
   return getRegion(object.getX(), object.getY(), object.getZ());
 }
  private void move() {
    /** Demo npc skills - prevent movement while casting */
    if (!owner.canPerformMove() || owner.isCasting()) {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
      return;
    }

    VisibleObject target = owner.getTarget();

    if (isFollowTarget && target != null) {
      setNewDirection(target.getX(), target.getY(), target.getZ());
    }

    float ownerX = owner.getX();
    float ownerY = owner.getY();
    float ownerZ = owner.getZ();

    double dist = MathUtil.getDistance(ownerX, ownerY, ownerZ, targetX, targetY, targetZ);
    if (dist > this.distance) {
      isStopped = false;

      float x2;
      float y2;
      float z2;
      float mod = 1;
      if (dist < speed * 0.5) {
        x2 = (targetX - ownerX);
        y2 = (targetY - ownerY);
        z2 = (targetZ - ownerZ);
      } else {
        x2 = (float) (((targetX - ownerX) / dist) * speed * 0.5);
        y2 = (float) (((targetY - ownerY) / dist) * speed * 0.5);
        z2 = (float) (((targetZ - ownerZ) / dist) * speed * 0.5);
        mod = 0.5f;
      }

      byte heading2 = (byte) (Math.toDegrees(Math.atan2(y2, x2)) / 3);

      if (directionChanged) {
        PacketSendUtility.broadcastPacket(
            owner,
            new SM_MOVE(
                owner.getObjectId(),
                ownerX,
                ownerY,
                ownerZ,
                (x2 / mod),
                (y2 / mod),
                (z2 / mod),
                heading2,
                MovementType.MOVEMENT_START_KEYBOARD));
        directionChanged = false;
      }

      moveCounter++;
      World.getInstance()
          .updatePosition(
              owner, ownerX + x2, ownerY + y2, ownerZ + z2, heading2, moveCounter % 5 == 0);
    } else {
      if (!isStopped) {
        isStopped = true;
        owner.getController().stopMoving();
      }
    }
  }
示例#6
0
  protected final boolean checkObjectInRange(VisibleObject owner, VisibleObject newObject) {
    // check if Z distance is greater than maxZvisibleDistance
    if (Math.abs(owner.getZ() - newObject.getZ()) > maxZvisibleDistance) return false;

    return MathUtil.isInRange(owner, newObject, visibilityDistance);
  }