public final class Bullet extends Object implements Comparable<Bullet>
The Bullet interface allows you to detect bullets, missiles, and other types of non-melee attacks or special abilities that would normally be visible through human eyes (A lurker spike or a Queen's flying parasite), allowing quicker reaction to unavoidable consequences.
For example, ordering medics to restore units that are about to receive a lockdown
to compensate for latency and minimize its effects. You can't know entirely which unit
will be receiving a lockdown unless you can detect the lockdown missile using the
Bullet
class.
Bullet
objects are re-used after they are destroyed, however their ID is updated when it
represents a new Bullet.
If Flag.CompleteMapInformation
is disabled, then a Bullet
is accessible if and only if
it is visible. Otherwise if Flag.CompleteMapInformation
is enabled, then all Bullets
in the game are accessible.
Game.getBullets()
,
exists()
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Bullet other) |
boolean |
equals(Object o) |
boolean |
exists()
Checks if the
Bullet exists in the view of the BWAPI player. |
double |
getAngle()
Retrieve's the direction the
Bullet is facing. |
int |
getID()
Retrieves a unique identifier for the current
Bullet . |
Player |
getPlayer()
Retrieves the
Player interface that owns the Bullet. |
Position |
getPosition()
Retrieves the Bullet's current position.
|
int |
getRemoveTimer()
Retrieves the timer that indicates the Bullet's life span.
|
Unit |
getSource()
|
Unit |
getTarget()
Retrieves the Unit interface that the
Bullet is heading to. |
Position |
getTargetPosition()
Retrieves the target position that the
Bullet is heading to. |
BulletType |
getType()
Retrieves the type of this
Bullet . |
double |
getVelocityX()
Retrieves the X component of the Bullet's velocity, measured in pixels per frame.
|
double |
getVelocityY()
Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.
|
int |
hashCode() |
boolean |
isVisible() |
boolean |
isVisible(Player player)
Retrieves the visibility state of the Bullet.
|
public int getID()
Bullet
.public boolean exists()
Bullet
exists in the view of the BWAPI player.
If Flag.CompleteMapInformation
is disabled, and a Bullet
is not visible, then the
return value will be false regardless of the Bullet's true existence. This is because
absolutely no state information on invisible enemy bullets is made available to the AI.
If Flag.CompleteMapInformation
is enabled, then this function is accurate for all
Bullet
information.
isVisible()
,
Unit.exists()
public BulletType getType()
Bullet
.BulletType
representing the Bullet's type. Returns BulletType.Unknown
if the Bullet
is inaccessible.public Unit getSource()
Unit
object. Returns null if the source can not be identified or is inaccessible.getTarget()
public Position getPosition()
Position
containing the Bullet's current coordinates. Returns Position.Unknown
if the Bullet
is inaccessible.getTargetPosition()
public double getAngle()
Bullet
is facing. Returns 0.0 if the bullet is inaccessible.public double getVelocityX()
Bullet
is inaccessible.getVelocityY()
,
getAngle()
public double getVelocityY()
Bullet
is inaccessible.getVelocityX()
,
getAngle()
public Unit getTarget()
Bullet
is heading to.Unit
is inaccessible, the Bullet
is targetting the ground, or if the Bullet
itself is inaccessible.getTargetPosition()
,
getSource()
public Position getTargetPosition()
Bullet
is heading to.Position
indicating where the Bullet
is headed. Returns Position.Unknown
if the bullet is inaccessible.getTarget()
,
getPosition()
public int getRemoveTimer()
Bullets are not permanent objects, so they will often have a limited life span. This life span is measured in frames. Normally a Bullet will reach its target before being removed.
public boolean isVisible()
public boolean isVisible(Player player)
player
- If this parameter is specified, then the Bullet's visibility to the given player is checked. If this parameter is omitted, then a default value of null is used, which will check if the BWAPI player has vision of the Bullet
.Bullet
is visible to the specified player, false if the Bullet
is not visible to the specified player.public int compareTo(Bullet other)
compareTo
in interface Comparable<Bullet>
Copyright © 2022. All rights reserved.