How to select enemy units/buildings?

Started by Astazha, March 20, 2010, 10:26:02 PM

Previous topic - Next topic

Astazha

I'm looking for ways to select enemy units that are known by the AI and ideally get their location as well.


You can use AIFindUnit() with the enemy player number, but this returns units that the player has not seen yet and would be cheating.


Some of the tactical functions have scangroup enemy passed into them, but I don't know where this comes from.


Other than that AILastAttacker looks like it would return an enemy unit (though just the one), and the UnitGroup function with an appropriate filter looks like it might show some promise.


Has anyone had luck selecting an enemy unit or group?  Has anyone found a way to get a unit's location?


Among other things, I'm looking for a non-cheating way to identify the location of enemy expansions so that they can be directly targeted, and for Zerg and Protoss enemies I'm looking to send an Overlord to spy on them until it's no longer safe to do so.


You could just get the location of towns using the enemy player #, but I don't want the AI to cheat.

Kernel64

have you looked into the overseer code? Those thinks that check nearby enemies.

I haven't really gotten into this part yet myself, and having trouble with accessing even the ChronoBoost thing which works with other AI projects.

Anyway, if I get to this part and figure something out, I'll post them.

Astazha

It's using AIFind() and limiting the range, which might be an option, but yuck.


Quote

//  Check to see if there are enough basic units around to follow.
    if ((UnitGroupCount(AIFilterPathable(AIFindUnits(enemyPlayer, c_PU_Zealot, here, range, c_maxEnemyCount), here), c_unitCountAlive) >= 2) ||
        (UnitGroupCount(AIFilterPathable(AIFindUnits(enemyPlayer, c_ZU_Zergling, here, range, c_maxEnemyCount), here), c_unitCountAlive) >= 2) ||
        (UnitGroupCount(AIFilterPathable(AIFindUnits(enemyPlayer, c_TU_Marine, here, range, c_maxEnemyCount), here), c_unitCountAlive) >= 2)) {
        return ord;
    }


You'd essentially have to visit every one of your units every cycle and ask if there were any enemy buildings within it's sight range, and even then it would pick up things you shouldn't see, like anything cloaked.


All of the buildings show on the mini-map once you've seen them, you'd think their locations would Galaxy accessible somehow. 


Here's location once you have it:


UnitGetPosition(aiUnit);


I suppose you could monitor the known unit count for buildings and when it goes up go check the sight range of all of your units for that type of building in their range, grab the building, grab the location, and see whether it was far enough away from previous locations to warrant entry as a new "town"


Such a catalog would also help you pin down proxy gateways.  What a hassle though...

Kernel64

Indeed.

There should be some other way, but I guess making a custom function with those would serve its purpose?

Astazha

LOL, I suppose so.  I started messing with scouting because I wanted to have some easy successes after becoming frustrated by trying to make the AI calculate a build order on it's own.  That's harder than I expected.

Kernel64

Well, it's a long term goal. Something that *may* happen. It's not entirely impossible, wouldn't you agree?

Astazha