//--------------------------------------------- ISSUE COMMAND ---------------------------------------------- bool UnitImpl::issueCommand(UnitCommand command) { if ( !canIssueCommand(command) ) return false; command.unit = this; if (command.type == UnitCommandTypes::Train || command.type == UnitCommandTypes::Morph) if (getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva ) command.unit = *getLarva().begin(); BWAPIC::UnitCommand c; c.type = command.type; c.unitIndex = command.unit->getID(); if ( command.target ) c.targetIndex = command.target->getID(); else c.targetIndex = -1; c.x = command.x; c.y = command.y; c.extra = command.extra; Command(command).execute(0); ((GameImpl*)Broodwar)->addUnitCommand(c); lastCommandFrame = Broodwar->getFrameCount(); lastCommand = command; return true; }
//--------------------------------------------- ISSUE COMMAND ---------------------------------------------- bool UnitImpl::issueCommand(UnitCommand command) { if ( !canIssueCommand(command) ) return false; command.unit = this; // If using train or morph on a hatchery, automatically switch selection to larva // (assuming canIssueCommand ensures that there is a larva) if ( (command.type == UnitCommandTypes::Train || command.type == UnitCommandTypes::Morph) && getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva ) { Unitset larvae( this->getLarva() ); foreach (Unit larva, larvae) { if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() ) { command.unit = larva; break; } } if ( command.unit == this ) return false; }
//--------------------------------------------- ISSUE COMMAND ---------------------------------------------- bool UnitImpl::issueCommand(UnitCommand command) { if ( !canIssueCommand(command) ) return false; command.unit = this; // If using train or morph on a hatchery, automatically switch selection to larva // (assuming canIssueCommand ensures that there is a larva) if ( (command.type == UnitCommandTypes::Train || command.type == UnitCommandTypes::Morph) && getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva ) { Unitset larvae( this->getLarva() ); for (Unit larva : larvae) { if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() ) { command.unit = larva; break; } } if ( command.unit == this ) return false; } BWAPIC::UnitCommand c; c.type = command.type; #pragma warning(suppress: 6011) c.unitIndex = command.unit->getID(); if ( command.target ) c.targetIndex = command.target->getID(); else c.targetIndex = -1; c.x = command.x; c.y = command.y; c.extra = command.extra; Command(command).execute(0); static_cast<GameImpl*>(BroodwarPtr)->addUnitCommand(c); lastCommandFrame = Broodwar->getFrameCount(); lastCommand = command; return true; }
bool UnitImpl::prepareIssueCommand(UnitCommand &command) { command.unit = this; // If using train or morph on a hatchery, automatically switch selection to larva // (assuming canIssueCommand ensures that there is a larva) if ( (command.type == UnitCommandTypes::Train || command.type == UnitCommandTypes::Morph) && getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva ) { Unitset larvae( this->getLarva() ); for(Unit larva : larvae) { if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() ) { command.unit = larva; break; } } if ( command.unit == this ) return false; } // Set last command and command frames static_cast<UnitImpl*>(command.unit)->lastCommandFrame = BroodwarImpl.getFrameCount(); static_cast<UnitImpl*>(command.unit)->lastCommand = command; static_cast<UnitImpl*>(command.unit)->setLastImmediateCommand(command); if (command.type == UnitCommandTypes::Use_Tech_Unit && command.target && (command.extra == TechTypes::Archon_Warp || command.extra == TechTypes::Dark_Archon_Meld)) { static_cast<UnitImpl*>(command.target)->lastCommandFrame = BroodwarImpl.getFrameCount(); static_cast<UnitImpl*>(command.target)->lastCommand = command; static_cast<UnitImpl*>(command.target)->setLastImmediateCommand(command); } // Add to command optimizer if possible, as well as the latency compensation buffer BroodwarImpl.addToCommandBuffer(new Command(command)); return BroodwarImpl.commandOptimizer.add(command); }