Skip to content
Snippets Groups Projects
Forked from Starcraft AI Course / PyCommandCenter
169 commits behind the upstream repository.
  • David Bergström's avatar
    2d160564
    Merge branch 'sofab194/pycommandcenter-master' · 2d160564
    David Bergström authored
    Following change description:
    
    * Added getTarget() to Unit: (Accessed via unit.target in python)
      Returns target if unit has one, otherwise will fail the assertion (make
      sure not to call this unless certain that the unit has a target!).
    * Added hasTarget() to Unit: (Accessed via unit.has_target in python)
      Returns true if unit has a valid target.
    * Added isBlip() to Unit: (Accessed via unit.is_blip in python) Returns
      true if unit is a "blip" - a ping on the map.
    * Added possible access to the current frame of the game in python
      (IDABot.current_frame).
    2d160564
    History
    Merge branch 'sofab194/pycommandcenter-master'
    David Bergström authored
    Following change description:
    
    * Added getTarget() to Unit: (Accessed via unit.target in python)
      Returns target if unit has one, otherwise will fail the assertion (make
      sure not to call this unless certain that the unit has a target!).
    * Added hasTarget() to Unit: (Accessed via unit.has_target in python)
      Returns true if unit has a valid target.
    * Added isBlip() to Unit: (Accessed via unit.is_blip in python) Returns
      true if unit is a "blip" - a ping on the map.
    * Added possible access to the current frame of the game in python
      (IDABot.current_frame).
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Unit.h 2.22 KiB
#pragma once

#include "Common.h"
#include "UnitType.h"

class IDABot;

class Unit
{
    mutable IDABot * m_bot;
    CCUnitID    m_unitID;
    UnitType    m_unitType;

    const sc2::Unit * m_unit;

public:

    Unit();

    Unit(const sc2::Unit * unit, IDABot & bot);
    const sc2::Unit * getUnitPtr() const;
    const sc2::UnitTypeID & getAPIUnitType() const;

    bool operator < (const Unit & rhs) const;
    bool operator == (const Unit & rhs) const;

    const UnitType & getType() const;

    CCPosition getPosition() const;
    CCTilePosition getTilePosition() const;
    CCHealth getHitPoints() const;
    CCHealth getShields() const;
    CCHealth getEnergy() const;
    CCPlayer getPlayer() const;
    CCUnitID getID() const;
    std::vector< CCBuff > buffs() const;
    float getBuildPercentage() const;
    int getWeaponCooldown() const;
    bool isCompleted() const;
    bool isBeingConstructed() const;
    bool isCloaked() const;
    bool isFlying() const;
    bool isAlive() const;
    bool isPowered() const;
    bool isIdle() const;
    bool isBurrowed() const;
    bool isValid() const;
    bool isTraining() const;
    bool isConstructing(const UnitType & type) const;

    bool isBlip() const;
    bool hasTarget() const;
    Unit getTarget() const;
    CCHealth getMaxHitPoints() const;

    void stop           () const;
    void attackUnit     (const Unit & target) const;
    void attackMove     (const CCPosition & targetPosition) const;
    void move           (const CCPosition & targetPosition) const;
    void move           (const CCTilePosition & targetTilePosition) const;
    void rightClick     (const Unit & target) const;
    void repair         (const Unit & target) const;
    void build          (const UnitType & buildingType, CCTilePosition pos) const;
    void buildTarget    (const UnitType & buildingType, const Unit & target) const;
    void train          (const UnitType & buildingType) const;
    void morph          (const UnitType & type) const;
    void research       (sc2::UpgradeID upgrade) const;
    void ability        (sc2::AbilityID ability) const;
    void ability        (sc2::AbilityID ability, const sc2::Point2D & point) const;
    void ability        (sc2::AbilityID ability, const Unit & target) const;
};