------------------------------------------- CAN COMMAND ------------------------------------------------
| 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 | { |
no test coverage detected