Exemplo n.º 1
0
  protected void randomRotate(Unit U) {
    // random rotate while exploring

    didsomething = true;
    rando = (int) (Math.random() * 2);
    if (rando == 0) U.rotateLeft();
    else U.rotateRight();

    U.usePoints(U.getRotationCost());
  }
Exemplo n.º 2
0
  protected void strategize(Unit U) {
    // cheat peek. 1/30 chance to look left and right to see if there are any enemies there
    // without spending points. Then rotate using points if enemies found
    // helps prevent the npc from just walking straight across the map
    // seaching simulator

    rando = (int) (Math.random() * 30);
    if (rando == 0) {
      U.rotateLeft();
      target = findTarget(U.abilities[0], U);
      if (target != null) U.usePoints(U.getRotationCost());
      else {
        U.rotateRight();
        U.rotateRight();
        target = findTarget(U.abilities[0], U);
        if (target != null) U.usePoints(U.getRotationCost());
        else U.rotateLeft();
      }
    }
  }
Exemplo n.º 3
0
  protected void rotateToHits(Unit U, HitIndicator I) {
    // rotate unit to face indicator direction

    // 0 up, 1 right, 2 down, 3 left

    while (!(U.getDirectionFacing() == I.getDirection())) {
      if (U.getDirectionFacing() == 0) {
        if (I.getDirection() == 3) U.rotateLeft();
        else U.rotateRight();
      } else if (U.getDirectionFacing() == 1) {
        if (I.getDirection() == 0) U.rotateLeft();
        else U.rotateRight();
      } else if (U.getDirectionFacing() == 2) {
        if (I.getDirection() == 1) U.rotateLeft();
        else U.rotateRight();
      } else if (U.getDirectionFacing() == 3) {
        if (I.getDirection() == 2) U.rotateLeft();
        else U.rotateRight();
      } else return; // error

      U.usePoints(U.getRotationCost());
    }
  }
Exemplo n.º 4
0
  protected void reconAction(Unit U, int I) {
    // recon tries trick shot and then runs away, or does normal attack, or basic movement

    didsomething = false;

    if (U.pointsLeft >= U.abilities[1].getCost()) {
      defaultAction(U, U.abilities[1], I);

      if (U.pointsLeft > 0) {
        rando = (int) (Math.random() * 2);
        if (rando == 0) U.rotateLeft();
        else U.rotateRight();
      }
    }

    if (!didsomething) {
      if (U.pointsLeft >= U.abilities[0].getCost()) defaultAction(U, U.abilities[0], I);
    }

    if (!didsomething) useMovement(U);
  }