diff --git a/src/Unit.cpp b/src/Unit.cpp index a1899596721f341e235b90b2ad678d75e91e36e8..9b30f7b2ecb6f80f897e57437a78022c9325a28d 100644 --- a/src/Unit.cpp +++ b/src/Unit.cpp @@ -296,4 +296,29 @@ bool Unit::isConstructing(const UnitType & type) const { sc2::AbilityID buildAbility = m_bot->Data(type).buildAbility; return (getUnitPtr()->orders.size() > 0) && (getUnitPtr()->orders[0].ability_id == buildAbility); -} \ No newline at end of file +} + +Unit Unit::getTarget() const +{ + BOT_ASSERT(isValid(), "Unit is not valid"); + + //if unit has order, check tag of target of first order + if(getUnitPtr()->orders.size() > 0){ + //pray that this value can be declared as CCUnitID + CCUnitID t_id = getUnitPtr()->orders[0].target_unit_tag; + //let IDAbot find the unit with this tag + return m_bot->GetUnit(t_id); + } + + return; +} + +bool Unit::isBlip() const +{ + BOT_ASSERT(isValid(), "Unit is not valid"); +#ifdef SC2API + return m_unit->is_blip; +#else + return m_unit->isBlip(); +#endif +} diff --git a/src/Unit.h b/src/Unit.h index 5770bd80b8b0d33faf89747bce3faaed0e993862..fdfa940bce982dcf04ae051d6e5ad18e91208b3d 100644 --- a/src/Unit.h +++ b/src/Unit.h @@ -47,6 +47,9 @@ public: bool isTraining() const; bool isConstructing(const UnitType & type) const; + bool isBlip() const; + Unit getTarget() const; + void stop () const; void attackUnit (const Unit & target) const; void attackMove (const CCPosition & targetPosition) const;