- updated AI code for special empty cellmap units, so AI does not look for them (since they already cannot attack them)

This commit is contained in:
Mark Vejvoda 2011-02-03 19:19:27 +00:00
parent ba2b155f6f
commit 2498d44cd3

View File

@ -358,13 +358,17 @@ int AiInterface::getMyUpgradeCount() const{
return world->getFaction(factionIndex)->getUpgradeManager()->getUpgradeCount(); return world->getFaction(factionIndex)->getUpgradeManager()->getUpgradeCount();
} }
int AiInterface::onSightUnitCount(){ int AiInterface::onSightUnitCount() {
int count=0; int count=0;
Map *map= world->getMap(); Map *map= world->getMap();
for(int i=0; i<world->getFactionCount(); ++i){ for(int i=0; i<world->getFactionCount(); ++i) {
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){ for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(world->getFaction(i)->getUnit(j)->getPos())); Unit *unit = world->getFaction(i)->getUnit(j);
if(sc->isVisible(teamIndex)){ SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
unit->getType()->getAllowEmptyCellMap() == true &&
unit->getType()->hasEmptyCellMap() == true);
if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
count++; count++;
} }
} }
@ -386,19 +390,24 @@ const Unit *AiInterface::getMyUnit(int unitIndex){
return world->getFaction(factionIndex)->getUnit(unitIndex); return world->getFaction(factionIndex)->getUnit(unitIndex);
} }
const Unit *AiInterface::getOnSightUnit(int unitIndex){ const Unit *AiInterface::getOnSightUnit(int unitIndex) {
int count=0; int count=0;
Map *map= world->getMap(); Map *map= world->getMap();
for(int i=0; i<world->getFactionCount(); ++i){ for(int i=0; i<world->getFactionCount(); ++i) {
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){ for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
Unit *u= world->getFaction(i)->getUnit(j); Unit * unit= world->getFaction(i)->getUnit(j);
if(map->getSurfaceCell(Map::toSurfCoords(u->getPos()))->isVisible(teamIndex)){ SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(unit->getPos()));
if(count==unitIndex){ bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
return u; unit->getType()->getAllowEmptyCellMap() == true &&
unit->getType()->hasEmptyCellMap() == true);
if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
if(count==unitIndex) {
return unit;
} }
else{ else {
count ++; count ++;
} }
} }