class
BulletAn interface object representing a bullet or missile spawned from an attack.
Contents
- Reference
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::
Base classes
-
template<typename Interface, typename Data>struct InterfaceDataWrapper<Bullet, BulletData>
Public functions
- auto exists() const -> bool
- Checks if the Bullet exists in the view of the BWAPI player.
- auto getAngle() const -> double
- Retrieve's the direction the Bullet is facing.
- auto getPlayer() const -> Player
- Retrieves the Player interface that owns the Bullet.
- auto getPosition() const -> Position
- Retrieves the Bullet's current position.
- auto getRemoveTimer() const -> int
- Retrieves the timer that indicates the Bullet's life span.
- auto getSource() const -> Unit
- Retrieves the Unit interface that the Bullet spawned from.
- auto getTarget() const -> Unit
- Retrieves the Unit interface that the Bullet is heading to.
- auto getTargetPosition() const -> Position
- Retrieves the target position that the Bullet is heading to.
- auto getType() const -> BulletType
- Retrieves the type of this Bullet.
- auto getVelocityX() const -> double
- Retrieves the X component of the Bullet's velocity, measured in pixels per frame.
- auto getVelocityY() const -> double
- Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.
- auto isVisible(Player player = nullptr) const -> bool
- Retrieves the visibility state of the Bullet.
Function documentation
bool BWAPI:: Bullet:: exists() const
Checks if the Bullet exists in the view of the BWAPI player.
Returns | |
---|---|
true | If the bullet exists or is visible. |
false | If the bullet was destroyed or has gone out of scope. |
If Flag::
If Flag::
Position BWAPI:: Bullet:: getPosition() const
Retrieves the Bullet's current position.
Returns | A Position containing the Bullet's current coordinates. |
---|---|
None | If the Bullet is inaccessible. |
int BWAPI:: Bullet:: getRemoveTimer() const
Retrieves the timer that indicates the Bullet's life span.
Returns | An integer representing the remaining number of frames until the Bullet self-destructs. |
---|---|
0 | If the Bullet is inaccessible. |
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.
Position BWAPI:: Bullet:: getTargetPosition() const
Retrieves the target position that the Bullet is heading to.
Returns | A Position indicating where the Bullet is headed. |
---|---|
None | If the bullet is inaccessible. |
BulletType BWAPI:: Bullet:: getType() const
Retrieves the type of this Bullet.
Returns | A BulletType representing the Bullet's type. |
---|---|
None | if the Bullet is inaccessible. |
double BWAPI:: Bullet:: getVelocityX() const
Retrieves the X component of the Bullet's velocity, measured in pixels per frame.
Returns | A double representing the number of pixels moved on the X axis per frame. |
---|---|
0.0 | if the Bullet is inaccessible. |
double BWAPI:: Bullet:: getVelocityY() const
Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.
Returns | A double representing the number of pixels moved on the Y axis per frame. |
---|---|
0.0 | if the Bullet is inaccessible. |
bool BWAPI:: Bullet:: isVisible(Player player = nullptr) const
Retrieves the visibility state of the Bullet.
Parameters | |
---|---|
player | (optional) 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 nullptr is used, which will check if the BWAPI player has vision of the Bullet. |
Returns | |
true | If the Bullet is visible to the specified player. |
false | If the Bullet is not visible to the specified player. |