Skip to content
Snippets Groups Projects
Commit d80f5d9a authored by David Bergström's avatar David Bergström
Browse files

Merge branch 'sofab194/pycommandcenter-master'

parents 2d160564 a289d802
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,13 @@ void define_unit(py::module & m)
.def_property_readonly("target", &Unit::getTarget)
.def_property_readonly("has_target", &Unit::hasTarget)
.def_property_readonly("max_hit_points", &Unit::getMaxHitPoints)
.def_property_readonly("progress", &Unit::getProgress)
.def_property_readonly("current_ability_id", &Unit::getCurrentAbilityID, "The AbilityID of currently used ability")
.def_property_readonly("facing", &Unit::getFacing)
.def_property_readonly("radius", &Unit::getRadius)
.def("hold_position", &Unit::holdPosition)
.def("patrol", py::overload_cast<const CCPosition &>(&Unit::patrol, py::const_))
.def("stop_dance", &Unit::stopDance)
.def("stop", &Unit::stop)
.def("attack_unit", &Unit::attackUnit)
.def("attack_move", &Unit::attackMove)
......
......@@ -11,6 +11,8 @@ void define_unittype(py::module & m)
.def_property_readonly("name", &UnitType::getName)
.def_property_readonly("race", &UnitType::getRace)
.def_property_readonly("movement_speed", &UnitType::getMovementSpeed)
.def_property_readonly("sight_range", &UnitType::getSightRange)
.def_property_readonly("required_structure", &UnitType::getRequiredStructure)
.def_property_readonly("is_valid", &UnitType::isValid)
.def_property_readonly("is_building", &UnitType::isBuilding)
.def_property_readonly("is_combat_unit", &UnitType::isCombatUnit, "The unit is not any of the following: worker, supply provider, building, larva, egg")
......
......@@ -370,3 +370,57 @@ CCHealth Unit::getMaxHitPoints() const
BOT_ASSERT(isValid(), "Unit is not valid");
return m_unit->health_max;
}
float Unit::getFacing() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
return m_unit->facing;
}
float Unit::getRadius() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
return m_unit->radius;
}
float Unit::getProgress() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
// If unit has order, return progress of first order
if (getUnitPtr()->orders.size() > 0) {
return getUnitPtr()->orders[0].progress;
}
return -1;
}
sc2::AbilityID Unit::getCurrentAbilityID() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
// If unit has order, return AbilityID of first order
if (getUnitPtr()->orders.size() > 0) {
return getUnitPtr()->orders[0].ability_id;
}
// return invalid AbilityID
return sc2::ABILITY_ID::INVALID;
}
void Unit::holdPosition() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::HOLDPOSITION);
}
void Unit::patrol(const CCPosition & targetPosition) const
{
BOT_ASSERT(isValid(), "Unit is not valid");
m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::PATROL, targetPosition);
}
void Unit::stopDance() const
{
BOT_ASSERT(isValid(), "Unit is not valid");
m_bot->Actions()->UnitCommand(m_unit, sc2::ABILITY_ID::STOP_DANCE);
}
......@@ -52,6 +52,13 @@ public:
bool hasTarget() const;
Unit getTarget() const;
CCHealth getMaxHitPoints() const;
float getProgress() const;
sc2::AbilityID getCurrentAbilityID() const;
void holdPosition() const;
void patrol(const CCPosition & targetPosition) const;
void stopDance() const;
float getFacing() const;
float getRadius() const;
void stop () const;
void attackUnit (const Unit & target) const;
......
......@@ -377,3 +377,13 @@ int UnitType::getMovementSpeed() const
{
return m_bot->Observation()->GetUnitTypeData()[m_type].movement_speed;
}
int UnitType::getSightRange() const
{
return m_bot->Observation()->GetUnitTypeData()[m_type].sight_range;
}
sc2::UnitTypeID UnitType::getRequiredStructure() const
{
return m_bot->Observation()->GetUnitTypeData()[m_type].tech_requirement;
}
......@@ -24,6 +24,8 @@ public:
CCRace getRace() const;
int getMovementSpeed() const;
int getSightRange() const;
sc2::UnitTypeID getRequiredStructure() const;
bool isValid() const;
bool isBuilding() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment