void ObserverScoutTask::updateRequirements()
{
	clearRequirements();

	if(!mUnit && !shouldReturnUnit())
	{
		RequirementGroup requirementOne;
		if(mData)
			requirementOne.addUnitFilterRequirement(10, Requirement::maxTime, UnitFilter(BWAPI::UnitTypes::Protoss_Observer) && UnitFilter(UnitFilterFlags::IsComplete), mData->getNextPosition());
		else
			requirementOne.addUnitFilterRequirement(10, Requirement::maxTime, UnitFilter(BWAPI::UnitTypes::Protoss_Observer) && UnitFilter(UnitFilterFlags::IsComplete));

		addRequirement(requirementOne);
	}
}
void ConstructionTask::updateRequirements()
{
	clearRequirements();

	if(!hasEnded())
	{
		reserveLocation();

		if(!finishedWithBuilder() && !mBuilder && (mProducedUnit || (mReservedLocation && mReservedLocation->isCalculated())))
		{
			Position location = mProducedUnit ? mProducedUnit->getPosition() : mReservedLocation->getPosition();
			int neededDuration = mType.getRace() == BWAPI::Races::Protoss ? BWAPI::Broodwar->getLatencyFrames() : mType.getRace() == BWAPI::Races::Zerg ? Requirement::maxTime : mType.buildTime();

			RequirementGroup requiredConditions;
			requiredConditions.addUnitFilterRequirement(40, neededDuration, UnitFilter(mType.whatBuilds().first) && UnitFilter(UnitFilterFlags::IsComplete), location);

			if(!mReservedResources && (!mProducedUnit || !mProducedUnit->exists()))
			{
				requiredConditions.addTechForTypeRequirement(mType);

				if(mType.mineralPrice() > 0) requiredConditions.addMineralRequirement(mType.mineralPrice());
				if(mType.gasPrice() > 0) requiredConditions.addGasRequirement(mType.gasPrice());
				if(mType.supplyRequired() > 0) requiredConditions.addSupplyRequirement(mType.supplyRequired());
			}

			addRequirement(requiredConditions);
		}
	}
}
Exemple #3
0
void GatherTask::updateRequirements()
{
	clearRequirements();

	//TODO: any worker will do that i can control, dont limit to my races workers
	Unit resourceDepot = mBase->getResourceDepot();
	if(resourceDepot)
	{
		int completeTime = 0;
		if(!resourceDepot->isCompleted())
			completeTime = resourceDepot->getCompletedTime();

		if(mResource->getType().isRefinery() && !mResource->isCompleted())
			completeTime = std::max(completeTime, mResource->getCompletedTime());

		if(!mWorkerOne)
		{
			RequirementGroup requirementOne;
			requirementOne.addUnitFilterRequirement(workerPriority(1), Requirement::maxTime, UnitFilter(UnitFilterFlags::IsWorker) && UnitFilter(UnitFilterFlags::IsComplete), mResource->getPosition());
			if(completeTime > 0)
				requirementOne.addTimeRequirement(completeTime);
			addRequirement(requirementOne);
		}

		if(!mWorkerTwo)
		{
			RequirementGroup requirementTwo;
			requirementTwo.addUnitFilterRequirement(workerPriority(2), Requirement::maxTime, UnitFilter(UnitFilterFlags::IsWorker) && UnitFilter(UnitFilterFlags::IsComplete), mResource->getPosition());
			if(completeTime > 0)
				requirementTwo.addTimeRequirement(completeTime);
			addRequirement(requirementTwo);
		}

		if(!mWorkerThree)
		{
			RequirementGroup requirementThree;
			requirementThree.addUnitFilterRequirement(workerPriority(3), Requirement::maxTime, UnitFilter(UnitFilterFlags::IsWorker) && UnitFilter(UnitFilterFlags::IsComplete), mResource->getPosition());
			if(completeTime > 0)
				requirementThree.addTimeRequirement(completeTime);
			addRequirement(requirementThree);
		}
	}
}
Exemple #4
0
void TechTask::updateRequirements()
{
	clearRequirements();

	if(!mUnit && !shouldReturnUnit())
	{
		RequirementGroup requiredConditions;

		assert(mReservedResources == false);
		requiredConditions.addTechForTypeRequirement(mType);
		requiredConditions.addUnitFilterRequirement(40, mType.researchTime(), UnitFilter(mType.whatResearches()) && UnitFilter(UnitFilterFlags::IsComplete));
		requiredConditions.addMineralRequirement(mType.mineralPrice());
		requiredConditions.addGasRequirement(mType.gasPrice());

		addRequirement(requiredConditions);
	}
}
Exemple #5
0
void TrainTask::updateRequirements()
{
	clearRequirements();

	if(!mProductionBuilding)
	{
		RequirementGroup requiredConditions;

		freeResources();

		requiredConditions.addUnitFilterRequirement(40, mType.buildTime(), UnitFilter(mType.whatBuilds().first) && UnitFilter(UnitFilterFlags::IsComplete) && !UnitFilter(UnitFilterFlags::IsLifted));

		requiredConditions.addTechForTypeRequirement(mType);

		if(mType.mineralPrice() > 0) requiredConditions.addMineralRequirement(mType.mineralPrice());
		if(mType.gasPrice() > 0) requiredConditions.addGasRequirement(mType.gasPrice());
		if(mType.supplyRequired() > 0) requiredConditions.addSupplyRequirement(mType.supplyRequired());

		addRequirement(requiredConditions);
	}
}