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

Function canCommand

bwapi/Shared/Templates.h:402–457  ·  view source on GitHub ↗

------------------------------------------- CAN COMMAND ------------------------------------------------

Source from the content-addressed store, hash-verified

400 }
401 //------------------------------------------- CAN COMMAND ------------------------------------------------
402 static inline bool canCommand(Unit thisUnit)
403 {
404 // Basic header
405 Broodwar->setLastError();
406 if ( thisUnit->getPlayer() != Broodwar->self() )
407 return Broodwar->setLastError(Errors::Unit_Not_Owned);
408
409 if ( !thisUnit->exists() )
410 return Broodwar->setLastError(Errors::Unit_Does_Not_Exist);
411
412 // Global can be ordered check
413 if ( thisUnit->isLockedDown() ||
414 thisUnit->isMaelstrommed() ||
415 thisUnit->isStasised() ||
416 !thisUnit->isPowered() ||
417 thisUnit->getOrder() == Orders::ZergBirth ||
418 thisUnit->isLoaded() )
419 {
420 if ( !thisUnit->getType().producesLarva() )
421 {
422 return Broodwar->setLastError(Errors::Unit_Busy);
423 }
424 else
425 {
426 Unitset larvae( thisUnit->getLarva() );
427 for (Unit larva : larvae)
428 {
429 if ( canCommand(larva) )
430 return Broodwar->setLastError();
431 }
432 return Broodwar->setLastError(Errors::Unit_Busy);
433 }
434 }
435
436 UnitType uType = thisUnit->getType();
437 if ( uType == UnitTypes::Protoss_Interceptor ||
438 uType == UnitTypes::Terran_Vulture_Spider_Mine ||
439 uType == UnitTypes::Spell_Scanner_Sweep ||
440 uType == UnitTypes::Special_Map_Revealer )
441 return Broodwar->setLastError(Errors::Incompatible_UnitType);
442 if ( thisUnit->isCompleted() &&
443 ( uType == UnitTypes::Protoss_Pylon ||
444 uType == UnitTypes::Terran_Supply_Depot ||
445 uType.isResourceContainer() ||
446 uType == UnitTypes::Protoss_Shield_Battery ||
447 uType == UnitTypes::Terran_Nuclear_Missile ||
448 uType.isPowerup() ||
449 ( uType.isSpecialBuilding() && !uType.isFlagBeacon() ) ) )
450 return Broodwar->setLastError(Errors::Incompatible_State);
451 if ( !thisUnit->isCompleted() &&
452 !uType.isBuilding() &&
453 !thisUnit->isMorphing() )
454 return Broodwar->setLastError(Errors::Incompatible_State);
455
456 return Broodwar->setLastError();
457 }
458 static inline bool canCommandGrouped(Unit thisUnit, bool checkCommandibility = true)
459 {

Callers 15

canCommandGroupedFunction · 0.85
canTargetUnitFunction · 0.85
canAttackFunction · 0.85
canAttackGroupedFunction · 0.85
canAttackMoveFunction · 0.85
canAttackMoveGroupedFunction · 0.85
canAttackUnitFunction · 0.85
canAttackUnitGroupedFunction · 0.85
canBuildFunction · 0.85
canBuildAddonFunction · 0.85
canTrainFunction · 0.85
canMorphFunction · 0.85

Calls 15

setLastErrorMethod · 0.80
isLockedDownMethod · 0.80
isMaelstrommedMethod · 0.80
isStasisedMethod · 0.80
isPoweredMethod · 0.80
isLoadedMethod · 0.80
producesLarvaMethod · 0.80
isCompletedMethod · 0.80
isResourceContainerMethod · 0.80
isPowerupMethod · 0.80
isSpecialBuildingMethod · 0.80
isFlagBeaconMethod · 0.80

Tested by

no test coverage detected