| 1282 | } |
| 1283 | |
| 1284 | bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled) |
| 1285 | { |
| 1286 | if (!isServerObject()) return false; |
| 1287 | if (!target) |
| 1288 | { |
| 1289 | target = mAimObject.getPointer(); |
| 1290 | if (!target) |
| 1291 | return false; |
| 1292 | } |
| 1293 | if (_checkEnabled) |
| 1294 | { |
| 1295 | if (target->getTypeMask() & ShapeBaseObjectType) |
| 1296 | { |
| 1297 | ShapeBase *shapeBaseCheck = static_cast<ShapeBase *>(target); |
| 1298 | if (shapeBaseCheck) |
| 1299 | if (shapeBaseCheck->getDamageState() != Enabled) return false; |
| 1300 | } |
| 1301 | else |
| 1302 | return false; |
| 1303 | } |
| 1304 | |
| 1305 | RayInfo ri; |
| 1306 | |
| 1307 | disableCollision(); |
| 1308 | |
| 1309 | S32 mountCount = target->getMountedObjectCount(); |
| 1310 | for (S32 i = 0; i < mountCount; i++) |
| 1311 | { |
| 1312 | target->getMountedObject(i)->disableCollision(); |
| 1313 | } |
| 1314 | |
| 1315 | Point3F checkPoint ; |
| 1316 | if (_useMuzzle) |
| 1317 | getMuzzlePointAI(0, &checkPoint ); |
| 1318 | else |
| 1319 | { |
| 1320 | MatrixF eyeMat; |
| 1321 | getEyeTransform(&eyeMat); |
| 1322 | eyeMat.getColumn(3, &checkPoint ); |
| 1323 | } |
| 1324 | |
| 1325 | bool hit = !gServerContainer.castRay(checkPoint, target->getBoxCenter(), sAIPlayerLoSMask, &ri); |
| 1326 | enableCollision(); |
| 1327 | |
| 1328 | for (S32 i = 0; i < mountCount; i++) |
| 1329 | { |
| 1330 | target->getMountedObject(i)->enableCollision(); |
| 1331 | } |
| 1332 | return hit; |
| 1333 | } |
| 1334 | |
| 1335 | DefineEngineMethod(AIPlayer, checkInLos, bool, (ShapeBase* obj, bool useMuzzle, bool checkEnabled),(nullAsType<ShapeBase*>(), false, false), |
| 1336 | "@brief Check whether an object is in line of sight.\n" |
no test coverage detected