public void tick() { getSprites().setSprites(-1, -1); int sprite = -1; if (inCombat()) { Combat.combatLoop(this); } if (getFollow().getFollowing() != null && !isFrozen()) { getFollow().followEntity(); return; } if (minimumCoords == null || maximumCoords == null) { return; //cannot process walking } if (misc.randomDouble(1) > 0.8 && walkType == WalkType.RANGE && !inCombat() && !isDead() && !isFrozen()) { int tgtX = getLocation().getX() + misc.random(-1, 2); //random number from -1,0,1 int tgtY = getLocation().getY() + misc.random(-1, 2); //random number from -1,0,1 sprite = WalkingQueue.direction(getLocation().getX(), getLocation().getY(), tgtX, tgtY); if (tgtX > maximumCoords.getX() || tgtX < minimumCoords.getX() || tgtY > maximumCoords.getY() || tgtY < minimumCoords.getY()) { sprite = -1; } if (sprite != -1) { sprite >>= 1; faceDirection = (FaceDirection)sprite; getSprites().setSprites(sprite, -1); setLocation(new Location(tgtX, tgtY, getLocation().getZ())); } return; } }