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

Method minimumDistance

src/Geoscape/DogfightState.cpp:1211–1231  ·  view source on GitHub ↗

* Sets the craft to the minimum distance * required to fire a weapon. */

Source from the content-addressed store, hash-verified

1209 * required to fire a weapon.
1210 */
1211void DogfightState::minimumDistance()
1212{
1213 int max = 0;
1214 for (std::vector<CraftWeapon*>::iterator i = _craft->getWeapons()->begin(); i < _craft->getWeapons()->end(); ++i)
1215 {
1216 if (*i == 0)
1217 continue;
1218 if ((*i)->getRules()->getRange() > max && (*i)->getAmmo() > 0)
1219 {
1220 max = (*i)->getRules()->getRange();
1221 }
1222 }
1223 if (max == 0)
1224 {
1225 _targetDist = STANDOFF_DIST;
1226 }
1227 else
1228 {
1229 _targetDist = max * 8;
1230 }
1231}
1232
1233/**
1234 * Sets the craft to the maximum distance

Callers

nothing calls this directly

Calls 4

getWeaponsMethod · 0.45
getRangeMethod · 0.45
getRulesMethod · 0.45
getAmmoMethod · 0.45

Tested by

no test coverage detected