bool BuildOrderManager::hasResources(BWAPI::TechType t)
{
  if (BWAPI::Broodwar->self()->cumulativeMinerals()-this->usedMinerals<t.mineralPrice())
    return false;
  if (BWAPI::Broodwar->self()->cumulativeGas()-this->usedGas<t.gasPrice())
    return false;
  return true;
}
示例#2
0
bool BuildOrderManager::hasResources(BWAPI::TechType t, int time)
{
  pair<int, Resources> res;
  res.first=time;
  res.second.minerals=t.mineralPrice();
  res.second.gas=t.gasPrice();
  return hasResources(res);
}
示例#3
0
ActionID ActionTypeData::GetActionID(const BWAPI::TechType & type) 
{
    const RaceID raceID = GetRaceID(type.getRace());
    for (ActionID a(0); a < ActionTypeData::GetNumActionTypes(raceID); ++a)
    {
        const ActionTypeData & data = GetActionTypeData(raceID, a);
        if (data.isTech() && data.getTechType() == type)
        {
            return data.getActionID();
        }
    }
   
	BOSS_ASSERT(false, "Could not find TechType: %d %s", type.getID(), type.getName().c_str());
    return 0;
}
示例#4
0
void UnitClass::useTech(BWAPI::TechType tech, Unit target)
{
	if(exists() && target)
	{
		if(!target->exists())
		{
			move(target->getPosition());
			return;
		}

		if(mUnit->getOrder() == tech.getOrder())
		{
			if(mUnit->getOrderTarget() == target->mUnit)
				return;
		}

		if(mUnit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Use_Tech_Unit && mUnit->getLastCommand().getTechType() == tech && mUnit->getLastCommand().getTarget() == target->mUnit)
		{
			if(mLastOrderExecuteTime >= BWAPI::Broodwar->getFrameCount())
				return;
		}

		if(mUnit->useTech(tech, target->mUnit))
			mLastOrderExecuteTime = BWAPI::Broodwar->getFrameCount() + BWAPI::Broodwar->getRemainingLatencyFrames();
	}
}
示例#5
0
// TechType action
ActionTypeData::ActionTypeData(BWAPI::TechType t, const ActionID id)
	: type(TechType)
	, tech(t)
	, actionID(id)
    , raceID(GetRaceID(t.getRace()))
	, mineralPriceVal(t.mineralPrice() * Constants::RESOURCE_SCALE)
	, gasPriceVal(t.gasPrice() * Constants::RESOURCE_SCALE)
	, supplyRequiredVal(0)
	, supplyProvidedVal(0)
	, buildTimeVal(t.researchTime())
	, numberProduced(1)
	, name(t.getName())
	, metaName(t.getName())
	, building(false)
	, worker(false)
	, refinery(false)
	, resourceDepot(false)
	, supplyProvider(false)
	, canProduceBool(false)
	, canAttackBool(false)
	, whatBuildsUnitType(t.whatResearches())
    , addon(false)
    , reqAddon(false)
    , reqAddonID(0)
    , morphed(false)
{
    setShortName();
}
示例#6
0
ResearchTest::ResearchTest(BWAPI::TechType techType) : techType(techType),
                                                       researcher(NULL),
                                                       startResearchFrame(-1),
                                                       nextUpdateFrame(-1)
{
  fail = false;
  running = false;
  researcherType = techType.whatResearches();
  BWAssertF(researcherType!=UnitTypes::None,{fail=true;return;});
示例#7
0
bool UnitWrap::UseTech(BWAPI::TechType tech, Unit pTarget, int targBit)
{
  if ( !pTarget )
    return false;

  if ( pUnit->getOrder() == tech.getOrder() && pUnit->getTarget() == pTarget ) // Already targetting it
    return false;
  
  int targFlags = UnitWrap(pTarget).GetTargetFlags();
  if ( targFlags & targBit )
    return false;

  if ( pUnit->useTech(tech, pTarget) ) // Use the tech!
  {
    UnitWrap(pTarget).SetTargetFlags(targFlags | targBit);
    SetVirtualUnitOrder( (Orders::Enum::Enum)tech.getOrder().getID() );
    return true;
  }
  return false;   // If the tech failed
}
示例#8
0
bool CheeseStrategies::StandardPlay::startTech(BWAPI::TechType tech) {
   UnitType techBuildingType = tech.whatResearches();

    if (Broodwar->self()->completedUnitCount(techBuildingType) == 0) {
        return false;
    }

    UnitSet myUnits = BWAPI::Broodwar->self()->getUnits();
    UnitSet::iterator it;

    BWAPI::Unit* techBuilding;

    for (it=myUnits.begin(); it!=myUnits.end(); it++) {
        if ((*it)->getType() == techBuildingType) {
            techBuilding = (*it);
        }
    }

    return techBuilding->research(tech);
}
示例#9
0
UseTechTest::UseTechTest(BWAPI::TechType techType) : techType(techType),
                                                     startFrame(-1),
                                                     nextFrame(-1),
                                                     user(NULL),
                                                     targetPosition(Positions::None),
                                                     targetUnit(NULL),
                                                     isInPosition(false),
                                                     usedTech(false),
                                                     testSucceeded(false),
                                                     startPosition(Positions::None),
                                                     targetType(UnitTypes::None),
                                                     currentEnergy(0)
{
  fail = false;
  running = false;
  for (UnitType u : techType.whatUses())
  {
    if (u.isHero()==false)
      userType = u;
  }
  BWAssertF(userType!=UnitTypes::None,{fail=true;return;});
示例#10
0
SatisfyTechRequirement::SatisfyTechRequirement(BWAPI::TechType techType)
	:techType(techType)
{
	taskName = "SatisfyTechRequirement(" + techType.getName() + ")";
	taskType = STR;
}
示例#11
0
void BuildOrderManager::spendResources(BWAPI::TechType t)
{
  this->usedMinerals+=t.mineralPrice();
  this->usedGas+=t.gasPrice();
}
MetaType::MetaType (BWAPI::TechType t)
    : _techType(t)
    , _type(MetaTypes::Tech)
    , _race(t.getRace())
{
}
bool TechManager::research(BWAPI::TechType type)
{
  researchQueues[*type.whatResearches()].push_back(type);
  plannedTech.insert(type);
  return true;
}
示例#14
0
Resources::Resources(BWAPI::TechType type)
{
  minerals = type.mineralPrice();
  gas      = type.gasPrice();
  supply   = 0.0;
}
示例#15
0
ActionTypeData ActionTypeData::GetActionTypeData(const BWAPI::TechType & a)
{
    return GetActionTypeData(GetRaceID(a.getRace()), GetActionID(a));
}