* Checks the validity of a snap shot performed here. * @param unit The unit to check sight from. * @param target The unit to check sight TO. * @return True if the target is valid. */
| 907 | * @return True if the target is valid. |
| 908 | */ |
| 909 | bool TileEngine::canMakeSnap(BattleUnit *unit, BattleUnit *target) |
| 910 | { |
| 911 | BattleItem *weapon = unit->getMainHandWeapon(); |
| 912 | // has a weapon |
| 913 | if (weapon && |
| 914 | // has a melee weapon and is in melee range |
| 915 | ((weapon->getRules()->getBattleType() == BT_MELEE && |
| 916 | validMeleeRange(unit, target, unit->getDirection()) && |
| 917 | unit->getTimeUnits() > unit->getActionTUs(BA_HIT, weapon)) || |
| 918 | // has a gun capable of snap shot with ammo |
| 919 | (weapon->getRules()->getBattleType() != BT_MELEE && |
| 920 | weapon->getRules()->getTUSnap() && |
| 921 | weapon->getAmmoItem() && |
| 922 | unit->getTimeUnits() > unit->getActionTUs(BA_SNAPSHOT, weapon))) && |
| 923 | (unit->getOriginalFaction() != FACTION_PLAYER || |
| 924 | _save->getGeoscapeSave()->isResearched(weapon->getRules()->getRequirements()))) |
| 925 | { |
| 926 | return true; |
| 927 | } |
| 928 | return false; |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * Attempts to perform a reaction snap shot. |
nothing calls this directly
no test coverage detected