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; }
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); }
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; }
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(); } }
// 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(); }
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;});
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 }
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); }
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;});
SatisfyTechRequirement::SatisfyTechRequirement(BWAPI::TechType techType) :techType(techType) { taskName = "SatisfyTechRequirement(" + techType.getName() + ")"; taskType = STR; }
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; }
Resources::Resources(BWAPI::TechType type) { minerals = type.mineralPrice(); gas = type.gasPrice(); supply = 0.0; }
ActionTypeData ActionTypeData::GetActionTypeData(const BWAPI::TechType & a) { return GetActionTypeData(GetRaceID(a.getRace()), GetActionID(a)); }