bool Debug::execute(aithread &thread) const { // Perform independant behaviours if ( this->getOpcode() == AISCRIPT::Enum::FATAL_ERROR ) { // Message Broodwar->sendText("Illegal AI script executed."); // Debug thread.saveDebug(Text::Green, this->getOpcode()); // Kill the script thread.killThread(); thread.noretry(); return false; } else if ( this->getOpcode() == AISCRIPT::Enum::DEBUG ) { // Read parameters WORD wJump; thread.readTuple( std::tie( wJump) ); // Send the message Broodwar->sendText("%s", &pbAIScriptBinary[thread.getScriptOffset()] ); // Jump to offset thread.setScriptOffset(wJump); thread.saveDebug(Text::Green, this->getOpcode(), "p_%X %s", wJump, &pbAIScriptBinary[thread.getScriptOffset()]); } return true; }
bool Wait_FinishAttack::execute(aithread &thread) const { // Debug thread.saveDebug(Text::Red, this->getOpcode()); // Check if AI is attacking // if ( AIIsAttacking ) { return thread.noretry(); } return thread.retry(); }
bool Wait_Upgrades::execute(aithread &thread) const { // Debug thread.saveDebug(Text::Green, this->getOpcode()); // If upgrades are finished, then move on to next opcode if ( MainController.getFlags() & CONTROLLER_UPGRADES_FINISHED ) return thread.noretry(); // Otherwise retry this opcode return thread.retry(); }
bool Wait_Train::execute(aithread &thread) const { // Parameters BYTE bCount; WORD wUnitType; thread.readTuple( std::tie(bCount, wUnitType) ); // Debug thread.saveDebug(Text::Green, this->getOpcode(), "%u %s", bCount, AISCRIPT::getUnitName(wUnitType) ); // Perform actions if ( GetStandardUnitCount(wUnitType) < bCount ) return thread.retry(); return thread.noretry(); }
bool Return::execute(aithread &thread) const { thread.saveDebug(Text::Green, this->getOpcode()); bool result = thread.ret(); // Error handling, kill the script if the callstack is empty if ( !result ) { thread.killThread(); thread.noretry(); return false; } // Success return true; }
bool Train::execute(aithread &thread) const { // Parameters BYTE bCount; WORD wUnitType; thread.readTuple( std::tie(bCount, wUnitType) ); // Debug thread.saveDebug(Text::Green, this->getOpcode(), "%u %s", bCount, AISCRIPT::getUnitName(wUnitType) ); // Perform actions if ( GetStandardUnitCount(wUnitType, this->getOpcode() != AISCRIPT::Enum::TRAIN) < bCount ) { MainController.wWaitForType = (int)wUnitType + 1; if ( this->getOpcode() != AISCRIPT::Enum::DO_MORPH ) return thread.retry(); } return thread.noretry(); }