- 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

@ -363,8 +363,12 @@ int AiInterface::onSightUnitCount(){
Map *map= world->getMap();
for(int i=0; i<world->getFactionCount(); ++i) {
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(world->getFaction(i)->getUnit(j)->getPos()));
if(sc->isVisible(teamIndex)){
Unit *unit = world->getFaction(i)->getUnit(j);
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++;
}
}
@ -393,10 +397,15 @@ const Unit *AiInterface::getOnSightUnit(int unitIndex){
for(int i=0; i<world->getFactionCount(); ++i) {
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j) {
Unit *u= world->getFaction(i)->getUnit(j);
if(map->getSurfaceCell(Map::toSurfCoords(u->getPos()))->isVisible(teamIndex)){
Unit * unit= world->getFaction(i)->getUnit(j);
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) {
if(count==unitIndex) {
return u;
return unit;
}
else {
count ++;