Username
Password
order SpawnLarva (int player, unit aiUnit) { order ord; unitgroup hatcheries; unitgroup larvas; int larvaCount; // Only cast if idle. // if (UnitOrder(aiUnit, 0) != null) { return null; } ord = AICreateOrder(player, c_AB_SpawnMutantLarva, 0); if (!UnitOrderIsValid(aiUnit, ord)) { return null; } larvas = AIFindUnits(player, c_ZU_Larva, UnitGetPosition(aiUnit), 15, c_noMaxCount) ; // Don't cast if we already own at least 10 larva // larvaCount = UnitGroupCount(larvas, c_unitCountAll); //TechTreeBehaviorCount(player, c_BF_MutantLarvaTimer, c_techCountQueuedOrBetter) * 4 //+ TechTreeUnitCount(player, c_ZU_Larva, c_techCountQueuedOrBetter) //; if (larvaCount >= 10) { return null; } hatcheries = AIFindUnits(player, c_ZB_Hatchery_Alias, UnitGetPosition(aiUnit), 15, c_noMaxCount) ; return AIUnitGroupGetValidOrder(hatcheries, ord, aiUnit, c_backwards);}
if (type == c_ZU_Queen) { //AIWaveAddUnitPriority(AIWaveGet(player, c_waveHome), u, c_prioWavePeon);c_prioWaveIdle doesn't work return; }
I'll try to look into it. I've been playing with expansion/base development stuff. Really just trying to figure out what is possible at this point... so many functions without clear documentation...In the BuildAI.galaxy file there are some constants for build locations, and the protoss Starcrack code makes some use of them to put the pylons next to "factories" once a reasonable powerfield has been established. One of the locations you can specify is choke point, but I haven't done any testing to see whether telling the Terran AI to build supply depots and barracks and bunkers at the choke point will actually result in a wall in or if they will just put it in the vicinity. I fear the latter.
AISetStock(player, 2, c_ZB_Hatchery_Alias); AISetStock(player, 1, c_ZB_Hive);
AISetStock(player, 2, c_ZB_Hatchery); AISetStock(player, 1, c_ZB_Hive);
I did some more testing on this.This code:QuoteAISetStock(player, 2, c_ZB_Hatchery_Alias); AISetStock(player, 1, c_ZB_Hive);will produce 1 Hive and 1 additional Hatchery.This code:QuoteAISetStock(player, 2, c_ZB_Hatchery); AISetStock(player, 1, c_ZB_Hive);will produce 1 Hive and 2 additional Hatcheries.Based on that, I would say that c_ZB_Hatchery_Alias does include the basic Hatchery. It appears to me that aliases are just not appropriate for us in AIFindUnit() even though they work correctly in the Stock functions.
//--------------------------------------------------------------------------------------------------// SpawnLarva() - original by Blizzard, modified by Astazha and Kernel64//// Checks for hatcheries in a radius of 25 around the queen// Checks for larva in a radius of 3.6 around each hatchery.// Spawns larva if less than 16 are found at a hatchery.// Some overlap will occur between very close hatcheries but the function works very well regardless.//--------------------------------------------------------------------------------------------------order SpawnLarva (int player, unit aiUnit) { order ord; unitgroup hatcheries; unitgroup lairs; unitgroup hives; unitgroup larvas; unitgroup vacancyHatches; int larvaCount; int numHatcheries; int numLairs; int numHives; int i; unit thisHatchery; // Only cast if idle. // if (UnitOrder(aiUnit, 0) != null) { return null; } ord = AICreateOrder(player, c_AB_SpawnMutantLarva, 0); if (!UnitOrderIsValid(aiUnit, ord)) { return null; } //Count the various types of Hatcheries. Hatchery_Alias cannot be used here. hatcheries = AIFindUnits(player, c_ZB_Hatchery, UnitGetPosition(aiUnit), 25, c_noMaxCount) ; lairs = AIFindUnits(player, c_ZB_Lair, UnitGetPosition(aiUnit), 25, c_noMaxCount) ; hives = AIFindUnits(player, c_ZB_Hive, UnitGetPosition(aiUnit), 25, c_noMaxCount) ; numHatcheries=UnitGroupCount(hatcheries, c_unitCountAll); numLairs=UnitGroupCount(lairs, c_unitCountAll); numHives=UnitGroupCount(hives, c_unitCountAll); //Create an empty unitgroup vacancyHatches = UnitGroup(null, -1, RegionCircle(null, 0), null, 0); //iterate through the groups. For each Hatchery find the larva within a small radius around it. //if the number of larva is small enough, add it to the group of Hatcheries that may receive //a spawn larva. This group will also include Hatcheries under construction but the queen will not spawn //on them anyway. //Hatcheries************************* i=1; while (i<=numHatcheries) { thisHatchery=UnitGroupUnit(hatcheries,i); larvas = AIFindUnits(player, c_ZU_Larva, UnitGetPosition(thisHatchery), 3.6, c_noMaxCount) ; larvaCount = UnitGroupCount(larvas, c_unitCountAll); if (larvaCount<16) { UnitGroupAdd(vacancyHatches,thisHatchery);// TriggerDebugOutput(1, StringToText("Adding a Hatchery to unitgroup vacancyHatches"), true); }// TriggerDebugOutput(1, StringToText("Hatchery"+ IntToString(i)+" has "+IntToString(larvaCount)+" within 3.5"), true); i=i+1; } //Lairs***************************** i=1; while (i<=numLairs) { thisHatchery=UnitGroupUnit(lairs,i); larvas = AIFindUnits(player, c_ZU_Larva, UnitGetPosition(thisHatchery), 3.6, c_noMaxCount) ; larvaCount = UnitGroupCount(larvas, c_unitCountAll); if (larvaCount<16) { UnitGroupAdd(vacancyHatches,thisHatchery);// TriggerDebugOutput(1, StringToText("Adding a Lair to unitgroup vacancyHatches"), true); }// TriggerDebugOutput(1, StringToText("Lair"+ IntToString(i)+" has "+IntToString(larvaCount)+" within 3.5"), true); i=i+1; } //Hives****************************** i=1; while (i<=numHives) { thisHatchery=UnitGroupUnit(hives,i); larvas = AIFindUnits(player, c_ZU_Larva, UnitGetPosition(thisHatchery), 3.6, c_noMaxCount) ; larvaCount = UnitGroupCount(larvas, c_unitCountAll); if (larvaCount<16) { UnitGroupAdd(vacancyHatches,thisHatchery);// TriggerDebugOutput(1, StringToText("Adding a Hive to unitgroup vacancyHatches"), true); }// TriggerDebugOutput(1, StringToText("Hive"+ IntToString(i)+" has "+IntToString(larvaCount)+" within 3.5"), true); i=i+1; }// TriggerDebugOutput(1, StringToText("There are "+ IntToString(UnitGroupCount(vacancyHatches, c_unitCountAll))+" hatches with vacancy."), true); //do not spawn larva if there are no hatcheries that can receive it (if unitgroup vacancyHatches is empty.) if (UnitGroupCount(vacancyHatches, c_unitCountAll)<1) { return null; } return AIUnitGroupGetValidOrder(vacancyHatches, ord, aiUnit, c_backwards);}