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()); }
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(); } } }
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()); } }