| 1112 | float HowMuchInteresting(AIUnit* unit, const Target* tgt) |
| 1113 | { |
| 1114 | EntityAI* veh = unit->GetVehicle(); |
| 1115 | Vector3Val unitDir = veh->Direction(); |
| 1116 | Vector3Val unitPos = veh->Position(); |
| 1117 | AIGroup* grp = unit->GetGroup(); |
| 1118 | AICenter* cnt = grp->GetCenter(); |
| 1119 | float interesting = 1; |
| 1120 | // we get some points when unknown |
| 1121 | if (tgt->side == TSideUnknown) |
| 1122 | { |
| 1123 | interesting += 10; |
| 1124 | } |
| 1125 | // we get many point for being enemy |
| 1126 | if (cnt->IsEnemy(tgt->side)) |
| 1127 | { |
| 1128 | interesting += 50; |
| 1129 | } |
| 1130 | // we get some points for being human |
| 1131 | if (tgt->type->IsKindOf(GWorld->Preloaded(VTypeMan))) |
| 1132 | { |
| 1133 | interesting += 10; |
| 1134 | } |
| 1135 | // we get some points for moving |
| 1136 | EntityAI* entity = tgt->idExact; |
| 1137 | if (entity) |
| 1138 | { |
| 1139 | // we get many points for firing, screaming and moving |
| 1140 | // this is all calculated in audibility - making noise |
| 1141 | // if target is visible, we should also check VisibleMovement() |
| 1142 | // we check it always - hopefully it will not matter too much |
| 1143 | interesting += entity->Audible() * 5; |
| 1144 | interesting += entity->VisibleMovement(); |
| 1145 | // and also for speaking |
| 1146 | interesting += entity->GetSpeaking() * 30; |
| 1147 | } |
| 1148 | // we loose a lot for being out of natural focus area |
| 1149 | Vector3 tgtDir = tgt->position - unitPos; |
| 1150 | float cosAlpha = tgtDir * unitDir * tgtDir.InvSize(); |
| 1151 | float focus = floatMax(cosAlpha, 0.2); |
| 1152 | return interesting * focus; |
| 1153 | } |
| 1154 | |
| 1155 | Target* SelectInterestingTarget(AIUnit* unit, Target* thn) |
| 1156 | { |
| 1157 | Vector3Val uPos = unit->Position(); |
| 1158 | AIGroup* grp = unit->GetGroup(); |
no test coverage detected