Example #1
0
  @Override
  protected void d_() {
    OProfiler.a("ai");
    if (this.f > 0) {
      --this.f;
    }

    this.e = this.F();
    float var1 = 16.0F;
    if (this.d == null) {
      this.d = this.o();
      if (this.d != null) {
        this.a = this.bi.a(this, this.d, var1, true, false, false, true);
      }
    } else if (!this.d.aE()) {
      this.d = null;
    } else {
      float var2 = this.d.i(this);
      if (this.h(this.d)) {
        this.a(this.d, var2);
      } else {
        this.b(this.d, var2);
      }
    }

    OProfiler.a();
    if (!this.e && this.d != null && (this.a == null || this.bS.nextInt(20) == 0)) {
      this.a = this.bi.a(this, this.d, var1, true, false, false, true);
    } else if (!this.e
        && (this.a == null && this.bS.nextInt(180) == 0 || this.bS.nextInt(120) == 0 || this.f > 0)
        && this.aV < 100) {
      this.G();
    }

    int var21 = OMathHelper.b(this.bw.b + 0.5D);
    boolean var3 = this.aU();
    boolean var4 = this.aV();
    this.bt = 0.0F;
    if (this.a != null && this.bS.nextInt(100) != 0) {
      OProfiler.a("followpath");
      OVec3D var5 = this.a.a(this);
      double var6 = (this.bG * 2.0F);

      while (var5 != null && var5.d(this.bm, var5.b, this.bo) < var6 * var6) {
        this.a.a();
        if (this.a.b()) {
          var5 = null;
          this.a = null;
        } else {
          var5 = this.a.a(this);
        }
      }

      this.aZ = false;
      if (var5 != null) {
        double var8 = var5.a - this.bm;
        double var10 = var5.c - this.bo;
        double var12 = var5.b - var21;
        float var14 = (float) (Math.atan2(var10, var8) * 180.0D / 3.1415927410125732D) - 90.0F;
        float var15 = var14 - this.bs;

        for (this.aX = this.bb; var15 < -180.0F; var15 += 360.0F) {;
        }

        while (var15 >= 180.0F) {
          var15 -= 360.0F;
        }

        if (var15 > 30.0F) {
          var15 = 30.0F;
        }

        if (var15 < -30.0F) {
          var15 = -30.0F;
        }

        this.bs += var15;
        if (this.e && this.d != null) {
          double var16 = this.d.bm - this.bm;
          double var18 = this.d.bo - this.bo;
          float var20 = this.bs;
          this.bs = (float) (Math.atan2(var18, var16) * 180.0D / 3.1415927410125732D) - 90.0F;
          var15 = (var20 - this.bs + 90.0F) * 3.1415927F / 180.0F;
          this.aW = -OMathHelper.a(var15) * this.aX * 1.0F;
          this.aX = OMathHelper.b(var15) * this.aX * 1.0F;
        }

        if (var12 > 0.0D) {
          this.aZ = true;
        }
      }

      if (this.d != null) {
        this.a(this.d, 30.0F, 30.0F);
      }

      if (this.by && !this.H()) {
        this.aZ = true;
      }

      if (this.bS.nextFloat() < 0.8F && (var3 || var4)) {
        this.aZ = true;
      }

      OProfiler.a();
    } else {
      super.d_();
      this.a = null;
    }
  }