if (isIndirect) { c3spotter = ae; }
	private static ToHitData getRangeMods(Game game, Entity ae, int weaponId, Targetable target) {		Mounted weapon = ae.getEquipment(weaponId);		WeaponType wtype = (WeaponType)weapon.getType();		int[] weaponRanges = wtype.getRanges();		boolean isWeaponInfantry = (ae instanceof Infantry);		boolean isLRMInfantry = isWeaponInfantry && wtype.getAmmoType() == AmmoType.T_LRM;				ToHitData mods = new ToHitData();				// modify the ranges for ATM missile systems based on the ammo selected		// TODO: this is not the right place to hardcode these		if (wtype.getAmmoType() == AmmoType.T_ATM) {			AmmoType atype = (AmmoType)weapon.getLinked().getType();			if (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE) {				weaponRanges = new int[] {4, 9, 18, 27};			}			else if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) {				weaponRanges = new int[] {0, 3, 6, 9};			}		}		// determine base distance & range bracket		int distance = effectiveDistance(game, ae, target);		int range = rangeBracket(distance, weaponRanges);        		// short circuit if at zero range or out of range		if (range == RANGE_OUT_OF) {			return new ToHitData(ToHitData.AUTOMATIC_FAIL, "Target out of range");		}		if (range == 0 && !isWeaponInfantry) {			return new ToHitData(ToHitData.AUTOMATIC_FAIL, "Only infantry shoot at zero range");		}		// find any c3 spotters that could help		Entity c3spotter = findC3Spotter(game, ae, target);		int c3dist = effectiveDistance(game, c3spotter, target);		int c3range = rangeBracket(c3dist, weaponRanges);				// determine which range we're using		int usingRange = Math.min(range, c3range);         		// add range modifier		if (usingRange == range) {			// no c3 adjustment			if (range == RANGE_MEDIUM) {				mods.addModifier(2, "medium range");			}			else if (range == RANGE_LONG) {				mods.addModifier(4, "long range");			}		}		else {			// report c3 adjustment			if (c3range == RANGE_SHORT) {				mods.addModifier(0, "short range due to C3 spotter");			}			else if (c3range == RANGE_MEDIUM) {				mods.addModifier(2, "medium range due to C3 spotter");			}		}        		// add infantry LRM maximum range penalty		if (isLRMInfantry && distance == weaponRanges[RANGE_LONG]) {			mods.addModifier(1, "infantry LRM maximum range");		}        		// add infantry zero-range modifier		// TODO: this is not the right place to hardcode these		if (isWeaponInfantry && distance == 0) {			// Infantry platoons attacking with infantry weapons can attack			// in the same hex with a base of 2, except for flamers and			// SRMs, which have a base of 3 and LRMs, which suffer badly.			if (wtype.hasFlag(WeaponType.F_FLAMER)) {				mods.addModifier(-1, "infantry flamer assault");			} else if (wtype.getAmmoType() == AmmoType.T_SRM ) {				mods.addModifier(-1, "infantry SRM assault");			} else if (wtype.getAmmoType() != AmmoType.T_LRM) {				mods.addModifier(-2, "infantry assault");			}		}        		// add minumum range modifier		int minRange = weaponRanges[RANGE_MINIMUM];		if (minRange > 0 && distance <= minRange) {			int minPenalty = (minRange - distance) + 1;			// Infantry LRMs suffer double minimum range penalties.			if (isLRMInfantry) {				mods.addModifier(minPenalty * 2, "infantry LRM minumum range");			} else {				mods.addModifier(minPenalty, "minumum range");			}		}        		// add any target stealth modifier		if ((target instanceof Entity) && ((Entity)target).isStealthActive()) {			mods.append(((Entity)target).getStealthModifier(usingRange));		}		return mods;	}