MCPcopy Create free account
hub / github.com/bwapi/bwapi / canTrain

Function canTrain

bwapi/Shared/Templates.h:874–910  ·  view source on GitHub ↗

------------------------------------------- CAN TRAIN --------------------------------------------------

Source from the content-addressed store, hash-verified

872 }
873 //------------------------------------------- CAN TRAIN --------------------------------------------------
874 static inline bool canTrain(Unit thisUnit, bool checkCommandibility = true)
875 {
876 if ( !checkCommandibility )
877 Broodwar->setLastError();
878 else if ( !canCommand(thisUnit) )
879 return false;
880
881 if ( thisUnit->getType().producesLarva() )
882 {
883 if ( !thisUnit->isConstructing() && thisUnit->isCompleted() )
884 return Broodwar->setLastError();
885 Unitset larvae( thisUnit->getLarva() );
886 for (Unit larva : larvae)
887 {
888 if ( !larva->isConstructing() && larva->isCompleted() && canCommand(larva) )
889 return Broodwar->setLastError();
890 }
891 return Broodwar->setLastError(Errors::Unit_Busy);
892 }
893
894 if ( thisUnit->isConstructing() ||
895 !thisUnit->isCompleted() ||
896 thisUnit->isLifted() )
897 return Broodwar->setLastError(Errors::Unit_Busy);
898 if ( !thisUnit->getType().canProduce() &&
899 thisUnit->getType() != UnitTypes::Enum::Terran_Nuclear_Silo &&
900 thisUnit->getType() != UnitTypes::Enum::Zerg_Hydralisk &&
901 thisUnit->getType() != UnitTypes::Enum::Zerg_Mutalisk &&
902 thisUnit->getType() != UnitTypes::Enum::Zerg_Creep_Colony &&
903 thisUnit->getType() != UnitTypes::Enum::Zerg_Spire &&
904 thisUnit->getType() != UnitTypes::Enum::Zerg_Larva )
905 return Broodwar->setLastError(Errors::Incompatible_UnitType);
906 if ( thisUnit->isHallucination() )
907 return Broodwar->setLastError(Errors::Incompatible_UnitType);
908
909 return true;
910 }
911 static inline bool canTrain(Unit thisUnit, UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true)
912 {
913 if ( !checkCommandibility )

Callers 5

canIssueCommandTypeFunction · 0.85
canIssueCommandFunction · 0.85
canIssueCommandGroupedFunction · 0.85
canTrainMethod · 0.85

Calls 14

canCommandFunction · 0.85
setLastErrorMethod · 0.80
producesLarvaMethod · 0.80
isConstructingMethod · 0.80
isCompletedMethod · 0.80
isLiftedMethod · 0.80
canProduceMethod · 0.80
isHallucinationMethod · 0.80
whatBuildsMethod · 0.80
canMakeMethod · 0.80
isAddonMethod · 0.80
isBuildingMethod · 0.80

Tested by

no test coverage detected