| 613 | } |
| 614 | |
| 615 | bool EntityAI::CanLock(TargetType* type, int weapon) const |
| 616 | { |
| 617 | // check current ammo |
| 618 | |
| 619 | if (weapon < 0) |
| 620 | { |
| 621 | weapon = _currentWeapon; |
| 622 | } |
| 623 | if (weapon < 0) |
| 624 | { |
| 625 | return false; |
| 626 | } |
| 627 | |
| 628 | const WeaponModeType* mode = GetWeaponMode(weapon); |
| 629 | if (!mode) |
| 630 | { |
| 631 | // FIX |
| 632 | // if there is no mode, use some other way to check if it is LAW |
| 633 | // check weapon typical magazine |
| 634 | const MagazineSlot& slot = GetMagazineSlot(weapon); |
| 635 | const MuzzleType* muzzle = slot._muzzle; |
| 636 | if (!muzzle) |
| 637 | { |
| 638 | return false; |
| 639 | } |
| 640 | if (muzzle->_magazines.Size() <= 0) |
| 641 | { |
| 642 | return false; |
| 643 | } |
| 644 | MagazineType* magazine = muzzle->_magazines[0]; |
| 645 | if (!magazine) |
| 646 | { |
| 647 | magazine = muzzle->_typicalMagazine; |
| 648 | } |
| 649 | if (!magazine) |
| 650 | { |
| 651 | return false; |
| 652 | } |
| 653 | // check first magazine mode |
| 654 | if (magazine->_modes.Size() <= 0) |
| 655 | { |
| 656 | return false; |
| 657 | } |
| 658 | mode = magazine->_modes[0]; |
| 659 | } |
| 660 | if (!mode) |
| 661 | { |
| 662 | return false; |
| 663 | } |
| 664 | if (!mode->_ammo) |
| 665 | { |
| 666 | return false; |
| 667 | } |
| 668 | return type->LockPossible(mode->_ammo); |
| 669 | } |
| 670 | |
| 671 | bool EntityAI::LockPossible(const AmmoType* ammo) const |
| 672 | { |
no test coverage detected