src/Util.cpp
bool Util::UnitCanMetaTypeNow(const Unit & unit, const UnitType & type, CCBot & m_bot)
{
#ifdef SC2API
    BOT_ASSERT(unit.isValid(), "Unit pointer was null");
    sc2::AvailableAbilities available_abilities = m_bot.Query()->GetAbilitiesForUnit(unit.getUnitPtr());
    
    // quick check if the unit can't do anything it certainly can't build the thing we want
    if (available_abilities.abilities.empty()) 
    {
        return false;
    }
    else 
    {
        // check to see if one of the unit's available abilities matches the build ability type
        sc2::AbilityID MetaTypeAbility = m_bot.Data(type).buildAbility;
        for (const sc2::AvailableAbility & available_ability : available_abilities.abilities) 
        {
            if (available_ability.ability_id == MetaTypeAbility)
            {
                return true;
            }
        }
    }
#else

#endif
    return false;
}
// checks where a given unit can make a given unit type now
// this is done by iterating its legal abilities for the build command to make the unit
checks where a given unit can make a given unit type now
this is done by iterating its legal abilities for the build command to make the unit
checks where a given unit can make a given unit type now this is done by iterating its legal abilities for the build command to make the unit
bool Util::UnitCanMetaTypeNow(const Unit & unit, const UnitType & type, CCBot & m_bot)
{
#ifdef SC2API
    BOT_ASSERT(unit.isValid(), "Unit pointer was null");
    sc2::AvailableAbilities available_abilities = m_bot.Query()->GetAbilitiesForUnit(unit.getUnitPtr());
    if (available_abilities.abilities.empty()) 
    {
        return false;
    }
    else 
    {
        sc2::AbilityID MetaTypeAbility = m_bot.Data(type).buildAbility;
        for (const sc2::AvailableAbility & available_ability : available_abilities.abilities) 
        {
            if (available_ability.ability_id == MetaTypeAbility)
            {
                return true;
            }
        }
    }
#else
#endif
    return false;
}
bool Util :: UnitCanMetaTypeNow ( const Unit & unit , const UnitType & type , CCBot & m_bot ) { #ifdef SC2API BOT_ASSERT ( unit . isValid ( ) , " " ) ; sc2 :: AvailableAbilities available_abilities = m_bot . Query ( ) -> GetAbilitiesForUnit ( unit . getUnitPtr ( ) ) ; if ( available_abilities . abilities . empty ( ) ) { return false ; } else { sc2 :: AbilityID MetaTypeAbility = m_bot . Data ( type ) . buildAbility ; for ( const sc2 :: AvailableAbility & available_ability : available_abilities . abilities ) { if ( available_ability . ability_id == MetaTypeAbility ) { return true ; } } } #else #endif return false ; }
checks where a given unit can make a given unit type now
this is done by iterating its legal abilities for the build command to make the unit
checks where a given unit can make a given unit type now this is done by iterating its legal abilities for the build command to make the unit
// quick check if the unit can't do anything it certainly can't build the thing we want // check to see if one of the unit's available abilities matches the build ability type