Package org.lazywizard.lazylib.combat
Class AIUtils
Object
AIUtils
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 Summary
Modifier and TypeMethodDescriptionstatic boolean
canUseSystemThisFrame
(ShipAPI ship) Check if a ship's system can be used/toggled this frame.getAlliesOnMap
(CombatEntityAPI entity) Find all present allies of an entity.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.getEnemiesOnMap
(CombatEntityAPI entity) Find all present and visible enemies of an entity.static List<MissileAPI>
getEnemyMissilesOnMap
(CombatEntityAPI entity) Find all present visible enemy missiles of an entity.getNearbyAllies
(CombatEntityAPI entity, float range) Finds all allies within a certain range around an entity.getNearbyEnemies
(CombatEntityAPI entity, float range) Finds all visible enemies within a certain range around an entity.static List<MissileAPI>
getNearbyEnemyMissiles
(CombatEntityAPI entity, float range) Finds all visible enemy missiles within a certain range around an entity.static ShipAPI
getNearestAlly
(CombatEntityAPI entity) Find the closest ally of an entity.static ShipAPI
getNearestEnemy
(CombatEntityAPI entity) Find the closest visible enemy of an entity.static MissileAPI
Find the closest visible enemy missile near an entity.static MissileAPI
getNearestMissile
(CombatEntityAPI entity) Find the closest visible missile near entity.static BattleObjectiveAPI
getNearestObjective
(CombatEntityAPI entity) Find the closestBattleObjectiveAPI
to an entity.static ShipAPI
getNearestShip
(CombatEntityAPI entity) Find the closest visible ship near an entity.
-
Method Details
-
getNearestObjective
Find the closestBattleObjectiveAPI
to an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The
BattleObjectiveAPI
closest toentity
, ornull
if none are found. - Since:
- 1.0
-
getNearestEnemy
Find the closest visible enemy of an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The enemy closest to
entity
who can be seen within the fog of war, ornull
if none are found. - Since:
- 1.0
-
getNearestAlly
Find the closest ally of an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The ally closest to
entity
, ornull
if none are found. - Since:
- 1.0
-
getNearestShip
Find the closest visible ship near an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The ship closest to
entity
that can be seen within the fog of war, ornull
if none are found. - Since:
- 1.0
-
getNearestMissile
Find the closest visible missile near entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The
MissileAPI
closest toentity
that can be seen within the fog of war, ornull
if none are found. - Since:
- 1.4
-
getEnemiesOnMap
Find all present and visible enemies of an entity.- Parameters:
entity
- TheCombatEntityAPI
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
Finds all visible enemies within a certain range around an entity.- Parameters:
entity
- The entity to search around.range
- How far aroundentity
to search.- Returns:
- A
List
containing all enemy ships within range that can be seen within the fog of war. - Since:
- 1.0
-
getAlliesOnMap
Find all present allies of an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- All allies of
entity
on the battle map. - Since:
- 1.0
-
getNearbyAllies
Finds all allies within a certain range around an entity.- Parameters:
entity
- The entity to search around.range
- How far aroundentity
to search.- Returns:
- A
List
containing all allied ships within range. - Since:
- 1.0
-
getNearestEnemyMissile
Find the closest visible enemy missile near an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- The enemy
MissileAPI
closest toentity
that can be seen within the fog of war, ornull
if none are found. - Since:
- 1.4
-
getEnemyMissilesOnMap
Find all present visible enemy missiles of an entity.- Parameters:
entity
- TheCombatEntityAPI
to search around.- Returns:
- All enemy
MissileAPI
s ofentity
on the battle map that can be seen within the fog of war. - Since:
- 1.4
-
getNearbyEnemyMissiles
Finds all visible enemy missiles within a certain range around an entity.- Parameters:
entity
- The entity to search around.range
- How far aroundentity
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, ornull
if a collision is not possible. - Since:
- 1.9
-
canUseSystemThisFrame
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
ifship
can use its system,false
otherwise.- Since:
- 1.0
-