mirror of
https://github.com/glest/glest-source.git
synced 2025-08-26 09:24:24 +02:00
- 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:
@@ -363,8 +363,12 @@ int AiInterface::onSightUnitCount(){
|
|||||||
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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,10 +397,15 @@ const Unit *AiInterface::getOnSightUnit(int unitIndex){
|
|||||||
|
|
||||||
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()));
|
||||||
|
bool cannotSeeUnit = (unit->getType()->hasCellMap() == true &&
|
||||||
|
unit->getType()->getAllowEmptyCellMap() == true &&
|
||||||
|
unit->getType()->hasEmptyCellMap() == true);
|
||||||
|
|
||||||
|
if(sc->isVisible(teamIndex) && cannotSeeUnit == false) {
|
||||||
if(count==unitIndex) {
|
if(count==unitIndex) {
|
||||||
return u;
|
return unit;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
count ++;
|
count ++;
|
||||||
|
Reference in New Issue
Block a user