
Code: Select all
const UnitDef* CAICallback::GetUnitDef(int unitid)
{
CUnit* unit=uh->units[unitid];
if(unit && (unit->losStatus[gs->AllyTeam(team)] & LOS_INLOS)){
return unit->unitDef;
}
return 0;
}
In fact, i bet a good part of the AI instability issues across the board are due to enemies being saved and their defs getting called after the enemy left LOS (or say killed the only unit that could see it). Or say trying to get a unitdef of a unit that is in radar but not LOS.
Might also be worth noting that the cheat interface giving all enemy units is pretty useless since the AI is not allowed to find the position or def of the units returned by it. It should simply give the AI LOS for the whole map.
Hope this helps