QUOTE(rasddasd @ Jul 3 2010, 03:16 AM)

I don't know how to access the positional data of the enemy Main/Natural.
If you have Flag::CompleteMapInformation enabled, the enemy's start location can be obtained via Broodwar->enemy()->getStartLocation().
If you don't have that cheat flag enabled, this function will be useless as it will just return TilePositions::Unknown and you'll need to scout the enemy's start location manually. Once you have a tile position that you know is in the enemy's main (such as once you scout an enemy Nexus/Command Center/Hatchery), you can use BWTA::getRegion() to return the region that the tile position is in, and from the region you can get the set of choke points that lead in to it, one of which is usually the choke point to the natural.
QUOTE(rasddasd @ Jul 3 2010, 03:16 AM)

Still having problems actually issuing orders to my units, basically i can scout and macro only, can't really micro my units whatsoever.
I don't know how to select the unit group, and then issue orders to that group.
I would appreciate any help.
Issuing orders to units is pretty simple. A list of all the unit commands you can issue are available on the Unit documentation page:
http://code.google.com/p/bwapi/wiki/UnitYou can get the set of Units you own using Broodwar->self()->getUnits(), and then you can issue whatever command you want to any of them. For example you could do something like this to get one of your marines to attack an enemy mutalisk:
CODE
Unit* marine = NULL;
Unit* mutalisk = NULL;
//iterate over friendly units looking for a marine
for(set<Unit*>::iterator u = Broodwar->self()->getUnits().begin(); u != Broodwar->self()->getUnits().end(); u++)
{
if ((*u)->getType()==UnitTypes::Terran_Marine)
{
marine = *u;//set marine variable to this unit
}
}
//iterate over enemy units looking for a mutalisk
for(set<Unit*>::iterator u = Broodwar->enemy()->getUnits().begin(); u != Broodwar->enemy()->getUnits().end(); u++)
{
if ((*u)->getType()==UnitTypes::Zerg_Mutalisk)
{
mutalisk= *u;//set mutalisk variable to this unit
}
}
if (marine!=NULL && mutalisk!=NULL)//make sure we actually found a marine and mutalisk
{
marine->attackUnit(mutalisk); //tell the marine to attack the mutalisk
}
Of course, effective micro involves a lot more than issuing a couple attack commands. Lately I've been working on some dragoon micro code and I'm still running into problems where dragoons sometimes just don't shoot because I'm giving them too many move commands and not enough time for them to actually attack.
Whatever micro code you end up making, it will probably need to somehow translate higher-level goals (like attack an enemy base, or perform a vulture drop), into lower level goals that actually affect individual units. While BWSAL doesn't have any managers that "micro", several of the managers need to micro-manage individual units to accomplish their high-level goals. If you don't know where to start, you could learn how BWSAL translates a higher level command like
buildManager->build(BWAPI::UnitTypes::Protoss_Pylon);
into individual unit commands where it has to find a probe and a build site, order the probe to move to the build site, and tell it to actually construct the pylon. Of course, the "micro" needed to construct a building is much simpler than the micro needed for attacking, defense, and harassment, so it wouldn't hurt to start with this simpler micro and then work up to something more complex.
You can store information about each unit between frames using a map, like:
CODE
struct MyData
{
int lastHP;
int lastShields;
};
std::map<Unit*,MyData> data;
and then in onFrame -
//iterate over all our units
for(set<Unit*>::iterator u = Broodwar->self()->getUnits().begin(); u != Broodwar->self()->getUnits().end(); u++)
{
//see if the unit's current amount of hit points is less than the amount it had on the last frame:
if ((*u)->getHitPoints()<data[*u].lastHP)
{
//if so, show an "ouch" message
Broodwar->drawTextMap((*u)->getPosition().x(),(*u)->getPosition().y(),"Ouch!");
}
}
//save the unit's current amount of hit points in the lastHP field:
for(set<Unit*>::iterator u = Broodwar->self()->getUnits().begin(); u != Broodwar->self()->getUnits().end(); u++)
{
data[*u].lastHP=(*u)->getHitPoints();
}
Also for combat micro I'm pretty sure potential fields would be a good way of representing risk/danger of each tile, which could then be used to move damaged units backwards to safety, but I haven't had a chance to add that to BWSAL yet.