Class AIUtils

Object
AIUtils

public class AIUtils extends Object
Contains methods that deal with a single combat entity and how it views the battle map. These methods respect the fog of war, unlike those in CombatUtils.
Since:
1.0
Author:
LazyWizard
  • Method Details

    • getNearestObjective

      @Nullable public static BattleObjectiveAPI getNearestObjective(CombatEntityAPI entity)
      Find the closest BattleObjectiveAPI to an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The BattleObjectiveAPI closest to entity, or null if none are found.
      Since:
      1.0
    • getNearestEnemy

      @Nullable public static ShipAPI getNearestEnemy(CombatEntityAPI entity)
      Find the closest visible enemy of an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The enemy closest to entity who can be seen within the fog of war, or null if none are found.
      Since:
      1.0
    • getNearestAlly

      @Nullable public static ShipAPI getNearestAlly(CombatEntityAPI entity)
      Find the closest ally of an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The ally closest to entity, or null if none are found.
      Since:
      1.0
    • getNearestShip

      @Nullable public static ShipAPI getNearestShip(CombatEntityAPI entity)
      Find the closest visible ship near an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The ship closest to entity that can be seen within the fog of war, or null if none are found.
      Since:
      1.0
    • getNearestMissile

      @Nullable public static MissileAPI getNearestMissile(CombatEntityAPI entity)
      Find the closest visible missile near entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The MissileAPI closest to entity that can be seen within the fog of war, or null if none are found.
      Since:
      1.4
    • getEnemiesOnMap

      public static List<ShipAPI> getEnemiesOnMap(CombatEntityAPI entity)
      Find all present and visible enemies of an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      All enemies of entity on the battle map that can be seen within the fog of war.
      Since:
      1.0
    • getNearbyEnemies

      public static List<ShipAPI> getNearbyEnemies(CombatEntityAPI entity, float range)
      Finds all visible enemies within a certain range around an entity.
      Parameters:
      entity - The entity to search around.
      range - How far around entity to search.
      Returns:
      A List containing all enemy ships within range that can be seen within the fog of war.
      Since:
      1.0
    • getAlliesOnMap

      public static List<ShipAPI> getAlliesOnMap(CombatEntityAPI entity)
      Find all present allies of an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      All allies of entity on the battle map.
      Since:
      1.0
    • getNearbyAllies

      public static List<ShipAPI> getNearbyAllies(CombatEntityAPI entity, float range)
      Finds all allies within a certain range around an entity.
      Parameters:
      entity - The entity to search around.
      range - How far around entity to search.
      Returns:
      A List containing all allied ships within range.
      Since:
      1.0
    • getNearestEnemyMissile

      @Nullable public static MissileAPI getNearestEnemyMissile(CombatEntityAPI entity)
      Find the closest visible enemy missile near an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      The enemy MissileAPI closest to entity that can be seen within the fog of war, or null if none are found.
      Since:
      1.4
    • getEnemyMissilesOnMap

      public static List<MissileAPI> getEnemyMissilesOnMap(CombatEntityAPI entity)
      Find all present visible enemy missiles of an entity.
      Parameters:
      entity - The CombatEntityAPI to search around.
      Returns:
      All enemy MissileAPIs of entity on the battle map that can be seen within the fog of war.
      Since:
      1.4
    • getNearbyEnemyMissiles

      public static List<MissileAPI> getNearbyEnemyMissiles(CombatEntityAPI entity, float range)
      Finds all visible enemy missiles within a certain range around an entity.
      Parameters:
      entity - The entity to search around.
      range - How far around entity to search.
      Returns:
      A List containing all enemy missiles within range that can be seen within the fog of war.
      Since:
      1.4
    • getBestInterceptPoint

      @Nullable public static Vector2f getBestInterceptPoint(Vector2f point, float speed, Vector2f targetLoc, Vector2f targetVel)
      Returns the best place to aim to hit a target, given its current location and velocity. This method does not take acceleration into account.
      Parameters:
      point - The origin point of the object that will attempt to collide with the target (usually a weapon's projectile spawn point).
      speed - The speed of the object that will attempt to collide with the target (usually a projectile's travel speed).
      targetLoc - The location of the target.
      targetVel - The current velocity of the target.
      Returns:
      The best point to aim towards to hit target given current velocities, or null if a collision is not possible.
      Since:
      1.9
    • canUseSystemThisFrame

      public static boolean canUseSystemThisFrame(ShipAPI ship)
      Check if a ship's system can be used/toggled this frame. Equivalent to checking whether the 'use system' key would do anything this frame. This still returns true if the shipsystem is already on!
      Parameters:
      ship - The ship to check the system of.
      Returns:
      true if ship can use its system, false otherwise.
      Since:
      1.0