Document correct upgrade procedure for Terran buildings
Terran buildings seemed to be fairly picky for applying upgrades. The correct way to do this seems to be like this:
if self.units(BARRACKSTECHLAB).ready.exists:
for lab in self.units(BARRACKSTECHLAB).ready:
abilities = await self.get_available_abilities(lab)
if AbilityId.RESEARCH_COMBATSHIELD in abilities and \
self.can_afford(AbilityId.RESEARCH_COMBATSHIELD):
await self.do(lab(AbilityId.RESEARCH_COMBATSHIELD))
Add example for building the basic upgrades.
could you also add example of building TECHLAB / BARRACKSTECHLAB
@vgainullin You can do it like this
for sp in self.units(STARPORT).ready:
if sp.add_on_tag == 0:
await self.do(sp.build(STARPORTTECHLAB))
You can check the existence of addon like this
def add_on_name(self, structure):
if structure.add_on_tag != 0:
return self.units.find_by_tag(structure.add_on_tag).name
else:
return "None"
e.g.
if ((len(barrack.orders) < 1) or (self.add_on_name(barrack) == "BarracksReactor" and len(barrack.orders) < 2)):
await self.train_unit_try(barrack, MARINE)
@alexander-kazakov I tried this 'add_on_tag' on the Command Center to check if the Command Center has Orbital Command. But failed, always got 0. Can it be using the same way to check on Command Center?
Orbital command works differently. It actually converts the command center unit into orbital command one.
So all your code where you select command center will not work for orbital command. To interact with orbital command, just use a selector for units(orbital command constant)
@alexander-kazakov Thanks!