Exemplo n.º 1
0
  public static FiringInstructions getNewPredictingFiringInstructions(
      MapBotBase bot, FiringDecision fd, float bulletSpeed) {
    Vector3f playerPos = bot.getBotPosition();
    Vector3f enemyPos = fd.enemyInfo.getBestVisibleEnemyPart(bot);

    // Calculate the time to hit
    double timeToHit = getTimeToHit(bulletSpeed, playerPos, enemyPos, fd.enemyInfo.predictedPos);
    if (timeToHit <= 1.5) {
      timeToHit = 1f;
    }

    // We add to enemy position the movement that the enemy is predicted to do in timeToHit.
    Vector3f hitPoint = CommFun.cloneVector(enemyPos);
    // movement is between bot position, not the visible part of the bot
    Vector3f movement =
        CommFun.getMovementBetweenVectors(
            fd.enemyInfo.getObjectPosition(), fd.enemyInfo.predictedPos);
    movement = CommFun.multiplyVectorByScalar(movement, (float) timeToHit);
    hitPoint.add(movement);

    return new FiringInstructions(CommFun.getNormalizedDirectionVector(playerPos, hitPoint));
  }
Exemplo n.º 2
0
 /**
  * * Point the enemy and shoot.
  *
  * @param fd
  * @param playerPos
  * @return
  */
 public static FiringInstructions getFastFiringInstructions(FiringDecision fd, MapBotBase bot) {
   Vector3f to = new Vector3f(fd.enemyInfo.getBestVisibleEnemyPart(bot));
   Vector3f fireDir = CommFun.getNormalizedDirectionVector(bot.getBotPosition(), to);
   //		bot.dtalk.addToLog("Fast firing.");
   return new FiringInstructions(fireDir);
 }