New functions. These functions allow you to add to a list of what to train/build. Research has not been added yet. Can accept Expansion orders.
Declarations:
Uses:
The functions:
Inject Functions. Adds items to list when called.
Example usage. BlockOneSubA -- Injects drones ovie and expo then drones.
Running it under Zerg0.galaxy
CBlockStatus is a string. It is used for checking the list status, and later moving through lists, etc.
Declarations:
Quote
//for main blocks
string[20] UnitName; //the unit to make Expo -- for expand
string[20] UnitType; //build or struct? hatchery
int[20] MakeTotal; //how many use: TotalUnit + desired addition number of expos
int[20] MakeWhere; //c_townOne, etc. where to start searching for expo
int[20] BuildFlag; //build flags for buildings the expanddefault
int[20] DoNextCount; //the count to watch for us to do next in line same
int[20] DoNextCond; //the condition to watch regarding the count above same
//for expo
int[20] MinInBank;
int[20] GasInBank;
//for emergency blocks
string[20] EUnitName; //the unit to make
string[20] EUnitType; //build or struct?
int[20] EMakeTotal; //how many use: TotalUnit + desired addition
int[20] EMakeWhere; //c_townOne, etc.
int[20] EBuildFlag; //build flags for buildings
int[20] EDoNextCount; //the count to watch for us to do next in line
int[20] EDoNextCond; //the condition to watch regarding the count above
string ProcessOrder(int player); //returns InProgress or ListEmpty FOR MAIN BLOCKS
string EProcessOrder(int player); //returns InProgress or ListEmpty FOR EMERGECY BLOCKS
void InjectOrder(int player); //just a prototype
//for main list
string InjectItem(string UName, string UType, int Total, int TownWhere, int BFlag, int NextCount, int Cond, int player);
//forExpo
string InjectItemExpo(string UName, string UType, int Total, int TownWhere, int BankMin, int BankGas, int player);
//for emergency list
string EInjectItem(string UName, string UType, int Total, int TownWhere, int BFlag, int NextCount, int Cond, int player);
Uses:
Quote
//--------------------------------------------------------------------------------------------------
// Counts the specified unit all including in progress and queued
//--------------------------------------------------------------------------------------------------
int TotalUnit(string UCheck, int Tplayer){
int a = 0;
a = (AITechCount(Tplayer, UCheck, c_techCountInProgressOnly) +
AITechCount(Tplayer, UCheck, c_techCountQueuedOnly) +
AITechCount(Tplayer, UCheck, c_techCountCompleteOnly));
return a;
}
The functions:
Quote
//---------------------------------
// Main List Processor
string ProcessOrder(int player){
int i;
int j;
int CurrNumOrders;
int WantMore;
point MainTownLoc1;
int NearTown1;
point NewTownLoc1;
int ExpoCount;
i = 0;
j = 0;
CurrNumOrders = 0;
WantMore = 0;
// check if there's something to process
while ( (UnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if (CurrNumOrders != 0) { //we have something
if (UnitType[0] != "Expo") { //this is not an expansion directive
//check if TotalUnit of the said unit is less than what we specified
if ( TotalUnit(UnitName[0], player) < MakeTotal[0] ) {
//we have less and we want more...
//get how much more we want:
WantMore = MakeTotal[0] - TotalUnit(UnitName[0], player);
//check if it's a building or not...
if ( UnitType[0] == "Unit") { //we have a unit, use train
AITrain (player, 10, MakeWhere[0], UnitName[0], WantMore);
}
else if (UnitType[0] == "Struct") { //we have a structure, use build
AIBuild (player, 10, MakeWhere[0], UnitName[0], WantMore, BuildFlag[0]);
}
else {
//do for tech here
}
}
else if ( TotalUnit(UnitName[0], player) >= MakeTotal[0] ) {
//we have all we wanted, they're queued or in progress, or better.
//now we check if we can discard this order
if ( AITechCount(player, UnitName[0], DoNextCond[0]) == DoNextCount[0] ){
//our limit has arrived, and in the condition we specified
//it's time to take this out of the list, and move the rest up...
//get the maximum number of orders. you'll know it because it's not ""
CurrNumOrders = 0;
while ( (UnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if ((CurrNumOrders != 20) && (CurrNumOrders > 0)) { //we dont have full list but not empty
while( j < CurrNumOrders ) {
if (UnitType[j+1] == "Expo") { //if the next item is an expo
GasInBank[j] = GasInBank[j+1];
MinInBank[j] = MinInBank[j+1];
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
}
else {
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
BuildFlag[j] = BuildFlag[j + 1];
DoNextCount[j] = DoNextCount[j + 1];
DoNextCond[j] = DoNextCond[j + 1];
}
j = j + 1;
}
}
else {//we have full list
while( j < CurrNumOrders - 1) {
if (UnitType[j] == "Expo") { //if the next item is still an expo
GasInBank[j] = GasInBank[j+1];
MinInBank[j] = MinInBank[j+1];
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
}
else {
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
BuildFlag[j] = BuildFlag[j + 1];
DoNextCount[j] = DoNextCount[j + 1];
DoNextCond[j] = DoNextCond[j + 1];
}
j = j + 1;
}
UnitName[j] = "";
}
}
else {
}
}
else {
}
}
else { //this is an expo directive
MainTownLoc1 = AIGetTownLocation (player, MakeWhere[0]);
NearTown1 = AIGetClosestTown (player, MainTownLoc1);
NewTownLoc1 = AIGetTownLocation (player, NearTown1);
if ( AIHasRes(player, MinInBank[0], GasInBank[0]) ) { //we have res
ExpoCount = AIExpand (player, NewTownLoc1, UnitName[0]);
if (ExpoCount >= MakeTotal[0]) { // the number of expo is set and is equal to what we want to make
// proceed to the next in list, take this out
CurrNumOrders = 0;
while ( (UnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if ((CurrNumOrders != 20) && (CurrNumOrders > 0)) { //we dont have full list but not empty
while( j < CurrNumOrders ) {
if (UnitType[j+1] == "Expo") { //if the next item is an expo
GasInBank[j] = GasInBank[j+1];
MinInBank[j] = MinInBank[j+1];
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
}
else {
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
BuildFlag[j] = BuildFlag[j + 1];
DoNextCount[j] = DoNextCount[j + 1];
DoNextCond[j] = DoNextCond[j + 1];
}
j = j + 1;
}
}
else {//we have full list
while( j < CurrNumOrders - 1) {
if (UnitType[j] == "Expo") { //if the next item is still an expo
GasInBank[j] = GasInBank[j+1];
MinInBank[j] = MinInBank[j+1];
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
}
else {
UnitName[j] = UnitName[j + 1];
UnitType[j] = UnitType[j + 1];
MakeTotal[j] = MakeTotal[j + 1];
MakeWhere[j] = MakeWhere[j + 1];
BuildFlag[j] = BuildFlag[j + 1];
DoNextCount[j] = DoNextCount[j + 1];
DoNextCond[j] = DoNextCond[j + 1];
}
j = j + 1;
}
UnitName[j] = "";
}
}
else{// number of expos not in yet.
}
}
else { // we don't have res
}
}
return "InProgress";
}
else {
return "ListEmpty";
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Emergency List Processor
string EProcessOrder(int player){
int i;
int j;
int CurrNumOrders;
int WantMore;
i = 0;
j = 0;
CurrNumOrders = 0;
WantMore = 0;
// check if there's something to process
while ( (EUnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if (CurrNumOrders != 0) { //we have something
//check if TotalUnit of the said unit is less than what we specified
if ( TotalUnit(EUnitName[0], player) < EMakeTotal[0] ) {
//we have less and we want more...
//get how much more we want:
WantMore = EMakeTotal[0] - TotalUnit(EUnitName[0], player);
//check if it's a building or not...
if ( EUnitType[0] == "Unit") { //we have a unit, use train
AITrain (player, 10, EMakeWhere[0], EUnitName[0], WantMore);
}
else if (EUnitType[0] == "Struct") { //we have a structure, use build
AIBuild (player, 10, EMakeWhere[0], EUnitName[0], WantMore, EBuildFlag[0]);
}
else {
//do for tech here
}
}
else if ( TotalUnit(EUnitName[0], player) >= EMakeTotal[0] ) {
//we have all we wanted, they're queued or in progress, or better.
//now we check if we can discard this order
if ( AITechCount(player, EUnitName[0], EDoNextCond[0]) == EDoNextCount[0] ){
//our limit has arrived, and in the condition we specified
//it's time to take this out of the list, and move the rest up...
//get the maximum number of orders. you'll know it because it's not ""
CurrNumOrders = 0;
while ( (EUnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if ((CurrNumOrders != 20) && (CurrNumOrders > 0)) { //we dont have full list but not empty
while( j < CurrNumOrders ) {
EUnitName[j] = EUnitName[j + 1];
EUnitType[j] = EUnitType[j + 1];
EMakeTotal[j] = EMakeTotal[j + 1];
EMakeWhere[j] = EMakeWhere[j + 1];
EBuildFlag[j] = EBuildFlag[j + 1];
EDoNextCount[j] = EDoNextCount[j + 1];
EDoNextCond[j] = EDoNextCond[j + 1];
j = j + 1;
}
}
else {//we have full list
while( j < CurrNumOrders - 1) {
EUnitName[j] = EUnitName[j + 1];
EUnitType[j] = EUnitType[j + 1];
EMakeTotal[j] = EMakeTotal[j + 1];
EMakeWhere[j] = EMakeWhere[j + 1];
EBuildFlag[j] = EBuildFlag[j + 1];
EDoNextCount[j] = EDoNextCount[j + 1];
EDoNextCond[j] = EDoNextCond[j + 1];
j = j + 1;
}
EUnitName[j] = "";
}
}
else {
}
}
else {
}
return "InProgress";
}
else {
return "ListEmpty";
}
}
Inject Functions. Adds items to list when called.
Quote
// Main List Injector
//-------------------------------------------------------
string InjectItem(string UName, string UType, int Total, int TownWhere, int BFlag, int NextCount, int Cond, int player){
int CurrNumOrders=0;
int i=0;
// check if the list is full
while ( (UnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if (CurrNumOrders == 20) {
return "ListFull";
}
else {
//add item at the last spot
i = CurrNumOrders;
UnitName = UName;
UnitType = UType;
MakeTotal = Total;
MakeWhere = TownWhere;
BuildFlag = BFlag;
DoNextCount = NextCount;
DoNextCond = Cond;
return "Success";
}
}
string InjectItemExpo(string UName, string UType, int Total, int TownWhere, int BankMin, int BankGas, int player){
int CurrNumOrders=0;
int i=0;
// check if the list is full
while ( (UnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if (CurrNumOrders == 20) {
return "ListFull";
}
else {
//add item at the last spot
i = CurrNumOrders;
UnitName = UName;
UnitType = UType;
MakeTotal = Total;
MakeWhere = TownWhere;
MinInBank = BankMin;
GasInBank = BankGas;
return "Success";
}
}
// Emergency List Injector
//-------------------------------------------------------
string EInjectItem(string UName, string UType, int Total, int TownWhere, int BFlag, int NextCount, int Cond, int player){
int CurrNumOrders=0;
int i=0;
// check if the list is full
while ( (EUnitName[CurrNumOrders] != "") && (CurrNumOrders < 20) ) {
CurrNumOrders = CurrNumOrders + 1;
}
if (CurrNumOrders == 20) {
return "ListFull";
}
else {
//add item at the last spot
i = CurrNumOrders;
EUnitName = UName;
EUnitType = UType;
EMakeTotal = Total;
EMakeWhere = TownWhere;
EBuildFlag = BFlag;
EDoNextCount = NextCount;
EDoNextCond = Cond;
return "Success";
}
}
Example usage. BlockOneSubA -- Injects drones ovie and expo then drones.
Quote
string BlockOneSubA(int player) {
int b;
b= (TotalUnit(c_ZU_Drone, player) + 4);
if ( InjectItem(c_ZU_Drone,
"Unit",
b,
c_townOne,
c_nearCloseDropoff,
b,
c_techCountInProgressOrBetter,
player) != "Success") { return "ListFull"; }
if ( InjectItem(c_ZU_Overlord,
"Unit",
2,
c_townOne,
c_nearCloseDropoff,
2,
c_techCountInProgressOrBetter,
player) != "Success") { return "ListFull"; }
if ( InjectItem(c_ZU_Drone,
"Unit",
13,
c_townOne,
c_nearCloseDropoff,
13,
c_techCountInProgressOrBetter,
player) != "Success") {return "ListFull"; }
if ( InjectItemExpo(c_ZB_Hatchery,
"Expo",
1,
0,
250,
0,
player) != "Success") {return "ListFull"; }
if ( InjectItem(c_ZU_Drone,
"Unit",
18,
c_townOne,
c_nearCloseDropoff,
18,
c_techCountInProgressOrBetter,
player) != "Success") {return "ListFull"; }
else {
return "Success";
}
}
Running it under Zerg0.galaxy
Quote
CBlockStatus = ProcessOrder(player);
if((AIGetTime() < 2) && (CBlockStatus != "InProgress")){
CBlockStatus = BlockOneSubA(player);
}
if( CBlockStatus == "ListEmpty"){
}
else {
CBlockStatus = ProcessOrder(player);
UIDisplayMessage(PlayerGroupAll(), 1, StringToText(CBlockStatus));
}
CBlockStatus is a string. It is used for checking the list status, and later moving through lists, etc.