MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / canMakeSnap

Method canMakeSnap

src/Battlescape/TileEngine.cpp:909–929  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

907 * @return True if the target is valid.
908 */
909bool 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.

Callers

nothing calls this directly

Calls 11

getMainHandWeaponMethod · 0.80
getBattleTypeMethod · 0.80
getTimeUnitsMethod · 0.80
getActionTUsMethod · 0.80
getTUSnapMethod · 0.80
getOriginalFactionMethod · 0.80
isResearchedMethod · 0.80
getGeoscapeSaveMethod · 0.80
getRulesMethod · 0.45
getDirectionMethod · 0.45
getAmmoItemMethod · 0.45

Tested by

no test coverage detected