| 463 | } |
| 464 | |
| 465 | Person* GetPlayerPerson(EntityAI* vehicle) |
| 466 | { |
| 467 | if (!vehicle) |
| 468 | { |
| 469 | return nullptr; |
| 470 | } |
| 471 | Person* person = dyn_cast<Person>(vehicle); |
| 472 | if (person) |
| 473 | { |
| 474 | return person; |
| 475 | } |
| 476 | Transport* trans = dyn_cast<Transport>(vehicle); |
| 477 | if (!trans) |
| 478 | { |
| 479 | return nullptr; // may be Thing or Building |
| 480 | } |
| 481 | |
| 482 | // check if player is inside |
| 483 | Person* commander = trans->Commander(); |
| 484 | if (commander && commander->IsNetworkPlayer()) |
| 485 | { |
| 486 | return commander; |
| 487 | } |
| 488 | Person* gunner = trans->Gunner(); |
| 489 | if (gunner && gunner->IsNetworkPlayer()) |
| 490 | { |
| 491 | return gunner; |
| 492 | } |
| 493 | Person* driver = trans->Driver(); |
| 494 | if (driver && driver->IsNetworkPlayer()) |
| 495 | { |
| 496 | return driver; |
| 497 | } |
| 498 | |
| 499 | // check if anybody is inside |
| 500 | if (commander) |
| 501 | { |
| 502 | return commander; |
| 503 | } |
| 504 | if (gunner) |
| 505 | { |
| 506 | return gunner; |
| 507 | } |
| 508 | return driver; |
| 509 | } |
| 510 | |
| 511 | void AIStatsMission::RecordReportKill(EntityAI* killed, EntityAI* killer) |
| 512 | { |
no test coverage detected