BWAPI  4.1.2
An API for interacting with Starcraft: Broodwar (1.16.1)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules
Public Member Functions | List of all members
BWAPI::BulletInterface Class Referenceabstract
Inheritance diagram for BWAPI::BulletInterface:
Inheritance graph

Public Member Functions

virtual bool exists () const =0
 
virtual double getAngle () const =0
 
virtual int getID () const =0
 
virtual Player getPlayer () const =0
 
virtual Position getPosition () const =0
 
virtual int getRemoveTimer () const =0
 
virtual Unit getSource () const =0
 
virtual Unit getTarget () const =0
 
virtual Position getTargetPosition () const =0
 
virtual BulletType getType () const =0
 
virtual double getVelocityX () const =0
 
virtual double getVelocityY () const =0
 
virtual bool isVisible (Player player=nullptr) const =0
 

Detailed Description

An interface object representing a bullet or missile spawned from an attack.

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.

See also
Game::getBullets, BulletInterface::exists

Member Function Documentation

virtual int BWAPI::BulletInterface::getID ( ) const
pure virtual

Retrieves a unique identifier for the current Bullet.

Returns
An integer value containing the identifier.
virtual bool BWAPI::BulletInterface::exists ( ) const
pure virtual

Checks if the Bullet exists in the view of the BWAPI player.

Return values
trueIf the bullet exists or is visible.
falseIf the bullet was destroyed or has gone out of scope.

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.

See also
isVisible, UnitInterface::exists
virtual Player BWAPI::BulletInterface::getPlayer ( ) const
pure virtual

Retrieves the Player interface that owns the Bullet.

Return values
nullptrIf the Player object for this Bullet is inaccessible.
Returns
The owning Player interface object.
virtual BulletType BWAPI::BulletInterface::getType ( ) const
pure virtual

Retrieves the type of this Bullet.

Return values
BulletTypes::Unknownif the Bullet is inaccessible.
Returns
A BulletType representing the Bullet's type.
virtual Unit BWAPI::BulletInterface::getSource ( ) const
pure virtual

Retrieves the Unit interface that the Bullet spawned from.

Return values
nullptrIf the source can not be identified or is inaccessible.
Returns
The owning Unit interface object.
See also
getTarget
virtual Position BWAPI::BulletInterface::getPosition ( ) const
pure virtual

Retrieves the Bullet's current position.

Return values
Positions::UnknownIf the Bullet is inaccessible.
Returns
A Position containing the Bullet's current coordinates.
See also
getTargetPosition
virtual double BWAPI::BulletInterface::getAngle ( ) const
pure virtual

Retrieve's the direction the Bullet is facing.

If the angle is 0, then the Bullet is facing right.

Return values
0.0If the bullet is inaccessible.
Returns
A double representing the direction the Bullet is facing.
virtual double BWAPI::BulletInterface::getVelocityX ( ) const
pure virtual

Retrieves the X component of the Bullet's velocity, measured in pixels per frame.

Return values
0.0if the Bullet is inaccessible.
Returns
A double representing the number of pixels moved on the X axis per frame.
See also
getVelocityY, getAngle
virtual double BWAPI::BulletInterface::getVelocityY ( ) const
pure virtual

Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.

Return values
0.0if the Bullet is inaccessible.
Returns
A double representing the number of pixels moved on the Y axis per frame.
See also
getVelocityX, getAngle
virtual Unit BWAPI::BulletInterface::getTarget ( ) const
pure virtual

Retrieves the Unit interface that the Bullet is heading to.

Return values
nullptrIf the Bullet's target Unit is inaccessible, the Bullet is targetting the ground, or if the Bullet itself is inaccessible.
Returns
The target Unit interface object, if one exists.
See also
getTargetPosition, getSource
virtual Position BWAPI::BulletInterface::getTargetPosition ( ) const
pure virtual

Retrieves the target position that the Bullet is heading to.

Return values
Positions::UnknownIf the bullet is inaccessible.
Returns
A Position indicating where the Bullet is headed.
See also
getTarget, getPosition
virtual int BWAPI::BulletInterface::getRemoveTimer ( ) const
pure virtual

Retrieves the timer that indicates the Bullet's life span.

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.

Return values
0If the Bullet is inaccessible.
Returns
An integer representing the remaining number of frames until the Bullet self-destructs.
virtual bool BWAPI::BulletInterface::isVisible ( Player  player = nullptr) const
pure virtual

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.
Note
If player is nullptr and Broodwar->self() is also nullptr, then the visibility of the Bullet is determined by checking if at least one other player has vision of the Bullet.
Return values
trueIf the Bullet is visible to the specified player.
falseIf the Bullet is not visible to the specified player.