* Selects a random known living Xcom or civilian unit. * @return if we found one. */
| 1084 | * @return if we found one. |
| 1085 | */ |
| 1086 | bool AlienBAIState::selectRandomTarget() |
| 1087 | { |
| 1088 | int farthest = -100; |
| 1089 | _aggroTarget = 0; |
| 1090 | |
| 1091 | for (std::vector<BattleUnit*>::const_iterator i = _save->getUnits()->begin(); i != _save->getUnits()->end(); ++i) |
| 1092 | { |
| 1093 | if (validTarget(*i, true, true)) |
| 1094 | { |
| 1095 | int dist = RNG::generate(0,20) - _save->getTileEngine()->distance(_unit->getPosition(), (*i)->getPosition()); |
| 1096 | if (dist > farthest) |
| 1097 | { |
| 1098 | farthest = dist; |
| 1099 | _aggroTarget = *i; |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | return _aggroTarget != 0; |
| 1104 | } |
| 1105 | |
| 1106 | /** |
| 1107 | * Selects a point near enough to our target to perform a melee attack. |
nothing calls this directly
no test coverage detected