|
BWAPI
|
#include <AOEThreat.h>

Public Member Functions | |
| AOEThreatClass (Unit unit) | |
| AOEThreatClass (BWAPI::Bullet *bullet) | |
| bool | hasGone () const |
| Position | getPosition () const |
| int | getRadius () const |
| Unit | getTarget () const |
| bool | isAirThreat () const |
| bool | isGroundThreat () const |
| bool | isEnergyThreat () const |
| void | draw () const |
Private Attributes | |
| Unit | mUnit |
| BWAPI::Bullet * | mBullet |
Definition at line 5 of file AOEThreat.h.
| AOEThreatClass::AOEThreatClass | ( | Unit | unit | ) |
Definition at line 3 of file AOEThreat.cpp.
| AOEThreatClass::AOEThreatClass | ( | BWAPI::Bullet * | bullet | ) |
Definition at line 9 of file AOEThreat.cpp.
| void AOEThreatClass::draw | ( | ) | const |
Definition at line 81 of file AOEThreat.cpp.
References BWAPI::Broodwar, BWAPI::Game::drawCircleMap(), getPosition(), getRadius(), BWAPI::Colors::Red, BWAPI::Position::x(), and BWAPI::Position::y().
{
const Position &pos = getPosition();
BWAPI::Broodwar->drawCircleMap(pos.x(), pos.y(), getRadius(), BWAPI::Colors::Red);
}

| Position AOEThreatClass::getPosition | ( | ) | const |
Definition at line 20 of file AOEThreat.cpp.
References BWAPI::BulletTypes::EMP_Missile, BWAPI::Bullet::exists(), BWAPI::Bullet::getPosition(), BWAPI::Bullet::getTargetPosition(), BWAPI::Bullet::getType(), BWAPI::Positions::Invalid, mBullet, mUnit, BWAPI::UnitTypes::Protoss_Scarab, BWAPI::BulletTypes::Psionic_Storm, and BWAPI::UnitTypes::Terran_Vulture_Spider_Mine.
Referenced by draw(), and hasGone().
{
if(mUnit && mUnit->exists())
{
const BWAPI::UnitType &type = mUnit->getType();
if(type == BWAPI::UnitTypes::Terran_Vulture_Spider_Mine)
{
if(mUnit->getTarget())
return mUnit->getTarget()->getPosition();
else
return mUnit->getPosition();
}
else if(type == BWAPI::UnitTypes::Protoss_Scarab)
{
if(mUnit->getTarget())
return mUnit->getTarget()->getPosition();
else
return BWAPI::Positions::Invalid;
}
else
return mUnit->getPosition();
}
else if(mBullet && mBullet->exists())
{
const BWAPI::BulletType &type = mBullet->getType();
if(type == BWAPI::BulletTypes::Psionic_Storm)
return mBullet->getPosition();
else if(type == BWAPI::BulletTypes::EMP_Missile)
return mBullet->getTargetPosition();
}
return BWAPI::Positions::Invalid;
}


| int AOEThreatClass::getRadius | ( | ) | const |
Definition at line 54 of file AOEThreat.cpp.
References BWAPI::BulletTypes::EMP_Missile, BWAPI::Bullet::exists(), BWAPI::Bullet::getType(), isAirThreat(), isGroundThreat(), mBullet, mUnit, and BWAPI::BulletTypes::Psionic_Storm.
Referenced by draw().
{
if(mUnit && mUnit->exists())
{
int radius = 0;
if(isAirThreat())
radius = mUnit->getType().airWeapon().medianSplashRadius();
if(isGroundThreat())
radius = std::max(mUnit->getType().groundWeapon().medianSplashRadius(), radius);
if(!mUnit->getTarget())
return radius / 2;
else
return radius;
}
else if(mBullet && mBullet->exists())
{
const BWAPI::BulletType &type = mBullet->getType();
if(type == BWAPI::BulletTypes::Psionic_Storm)
return 64;
else if(type == BWAPI::BulletTypes::EMP_Missile)
return 96;
}
return 0;
}


| Unit AOEThreatClass::getTarget | ( | ) | const |
Definition at line 87 of file AOEThreat.cpp.
References mUnit, and StaticUnits::nullunit.
{
if(mUnit && mUnit->exists())
return mUnit->getTarget();
return StaticUnits::nullunit;
}
| bool AOEThreatClass::hasGone | ( | ) | const |
Definition at line 15 of file AOEThreat.cpp.
References getPosition(), and BWAPI::Positions::Invalid.
{
return getPosition() == BWAPI::Positions::Invalid;
}

| bool AOEThreatClass::isAirThreat | ( | ) | const |
Definition at line 95 of file AOEThreat.cpp.
References BWAPI::Bullet::exists(), BWAPI::Bullet::getType(), mBullet, and BWAPI::BulletTypes::Psionic_Storm.
Referenced by getRadius().
{
if(mBullet && mBullet->exists())
{
if(mBullet->getType() == BWAPI::BulletTypes::Psionic_Storm)
return true;
}
return false;
}


| bool AOEThreatClass::isEnergyThreat | ( | ) | const |
Definition at line 123 of file AOEThreat.cpp.
References BWAPI::BulletTypes::EMP_Missile, BWAPI::Bullet::exists(), BWAPI::Bullet::getType(), and mBullet.
{
if(mBullet && mBullet->exists())
{
if(mBullet->getType() == BWAPI::BulletTypes::EMP_Missile)
return true;
}
return false;
}
| bool AOEThreatClass::isGroundThreat | ( | ) | const |
Definition at line 106 of file AOEThreat.cpp.
References BWAPI::Bullet::exists(), BWAPI::Bullet::getType(), mBullet, mUnit, BWAPI::UnitTypes::Protoss_Scarab, BWAPI::BulletTypes::Psionic_Storm, and BWAPI::UnitTypes::Terran_Vulture_Spider_Mine.
Referenced by getRadius().
{
if(mUnit && mUnit->exists())
{
const BWAPI::UnitType &type = mUnit->getType();
if(type == BWAPI::UnitTypes::Protoss_Scarab || type == BWAPI::UnitTypes::Terran_Vulture_Spider_Mine)
return true;
}
else if(mBullet && mBullet->exists())
{
if(mBullet->getType() == BWAPI::BulletTypes::Psionic_Storm)
return true;
}
return false;
}


BWAPI::Bullet* AOEThreatClass::mBullet [private] |
Definition at line 25 of file AOEThreat.h.
Referenced by getPosition(), getRadius(), isAirThreat(), isEnergyThreat(), and isGroundThreat().
Unit AOEThreatClass::mUnit [private] |
Definition at line 24 of file AOEThreat.h.
Referenced by getPosition(), getRadius(), getTarget(), and isGroundThreat().
1.7.6.1