Package megamek.client.bot.princess
Class FireControl
java.lang.Object
megamek.client.bot.princess.FireControl
- Direct Known Subclasses:
AerospaceFireControl,InfantryFireControl,MultiTargetFireControl
FireControl selects which weapons a unit wants to fire and at whom Pay attention to the difference between "guess"
and "get". Guess will be much faster, but inaccurate
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe possible fire control types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final doubleprotected static final doubleprotected static final doubleprotected static final doubleprotected static final doubleprotected static final doubleprotected static final doubleprotected final Princessprotected static final doubleprotected static final doubleprotected static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyTsmHeatIncentive(Entity shooter, FiringPlan firingPlan) Adds a utility bonus for a Mek carrying heat-activated standard Triple-Strength Myomer when a firing plan would bring its projected end-of-turn heat up to theTSM_DESIRED_HEATactivation threshold.protected doubleprotected doublecalcCommandUtility(Targetable target) protected intcalcHeatTolerance(Entity entity, Boolean isAero) protected intcalcHeatTolerance(Entity entity, Boolean isAero, int predictedMovementHeat) Calculates how much weapon heat this unit is willing to generate before overheating becomes a disutility.protected doubleprotected doublecalcStrategicBuildingTargetUtility(Targetable target, double expectedDamage) protected doubleCalculates the logarithmic scaling factor for target damage potential in the utility equation, using the target's potential damage, the weight value TARGET_POTENTIAL_DAMAGE_UTILITY, and Princess's self-preservation value.static intcorrectFacing(int facing) makes sure facing falls between 0 and 5 This function likely already exists somewhere elseprotected static booleaneffectivelyAmmoless(WeaponType weaponType) booleanentityCanIndirectFireMissile(FireControlState fireControlState, Entity shooter) Determines if the given entity can use indirect fire as in LRMs.protected booleanfiringActivatesTsm(Entity shooter, FiringPlan firingPlan) Reports whether firing this plan is what switches a heat-activated standard Triple-Strength Myomer on this turn: the shooter's projected end-of-turn heat reachesTSM_DESIRED_HEATwith the plan's heat but would fall short of it without.protected ToHitDatagetAttackerMovementModifier(Game game, int shooterId, EntityMovementType shooterMoveType) Returns the movement modifier calculated byCompute.getAttackerMovementModifier(Game, int, EntityMovementType).protected FiringPlangetDiveBombPlan(Entity shooter, MovePath flightPath, Targetable target, Game game, boolean passedOverTarget, boolean guess) Creates a firing plan that fires dive bombs, dropping all bombs on the given targetgetFindClubAction(Entity shooter) Return a "Find Club" action, if the unit in question can find a club.static doublegetMaxDamageAtRange(Entity shooter, int range, boolean useExtremeRange, boolean useLOSRange) Calculates the maximum damage a unit can do at a given range.getSearchLightAction(Entity shooter, FiringPlan plan) Given a firing plan, calculate the best target to light up with a searchlightgetSpotAction(FiringPlan plan, Entity spotter, FireControlState fireControlState) Determines if the given entity (potentially employing a given firing plan) can/should spot.protected List<Targetable> getTargetableEnemyEntities(Entity shooter, Game game, FireControlState fireControlState) Gets all the entities that are potential targetsprotected ToHitDatagetTargetMovementModifier(int hexesMoved, boolean jumping, boolean airborneNonAerospace, Game game) Returns the movement modifier calculated byCompute.getTargetMovementModifier(int, boolean, boolean, Game)getUnjamWeaponPlan(Entity shooter) This function evaluates whether or not a unit should spend its time unjamming weapons instead of firing, and returns the appropriate firing plan if that's the case.getValidFacingChanges(Entity shooter) protected FiringPlanguessBestFiringPlanUnderHeat(Entity shooter, EntityState shooterState, Targetable target, EntityState targetState, int maxHeat, Game game) Guesses the 'best' firing plan under a certain heat No twisting is doneprotected intguessDistance(Entity shooter, EntityState shooterState, Targetable target, EntityState targetState, Game game) The range this guessed shot is resolved at, from a hypothetical shooter pose.protected booleanisCommander(Entity entity) protected booleanReturns the value ofComputeArc.isInArc(Coords, int, Targetable, int).protected booleanisSubCommander(Entity entity)
-
Field Details
-
DAMAGE_UTILITY
protected static final double DAMAGE_UTILITY- See Also:
-
CRITICAL_UTILITY
protected static final double CRITICAL_UTILITY- See Also:
-
KILL_UTILITY
protected static final double KILL_UTILITY- See Also:
-
OVERHEAT_DISUTILITY
protected static final double OVERHEAT_DISUTILITY- See Also:
-
OVERHEAT_DISUTILITY_AERO
protected static final double OVERHEAT_DISUTILITY_AERO- See Also:
-
TSM_DESIRED_HEAT
protected static final int TSM_DESIRED_HEAT- See Also:
-
TSM_HEAT_CEILING
protected static final int TSM_HEAT_CEILING- See Also:
-
TSM_ACTIVATION_UTILITY
protected static final double TSM_ACTIVATION_UTILITY- See Also:
-
EJECTED_PILOT_DISUTILITY
protected static final double EJECTED_PILOT_DISUTILITY- See Also:
-
CIVILIAN_TARGET_DISUTILITY
protected static final double CIVILIAN_TARGET_DISUTILITY- See Also:
-
TARGET_HP_FRACTION_DEALT_UTILITY
protected static final double TARGET_HP_FRACTION_DEALT_UTILITY- See Also:
-
owner
-
-
Constructor Details
-
FireControl
Constructor- Parameters:
owningPrincess- ThePrincessbot that utilizes this class for computing firing solutions.
-
-
Method Details
-
getAttackerMovementModifier
@StaticWrapper protected ToHitData getAttackerMovementModifier(Game game, int shooterId, EntityMovementType shooterMoveType) Returns the movement modifier calculated byCompute.getAttackerMovementModifier(Game, int, EntityMovementType).- Parameters:
game- The currentGameshooterId- The ID of the unit doing the shooting.shooterMoveType- TheEntityMovementTypeof the unit doing the shooting.- Returns:
- The attacker movement modifier as a
ToHitDataobject.
-
getTargetMovementModifier
@StaticWrapper protected ToHitData getTargetMovementModifier(int hexesMoved, boolean jumping, boolean airborneNonAerospace, Game game) Returns the movement modifier calculated byCompute.getTargetMovementModifier(int, boolean, boolean, Game) -
isInArc
@StaticWrapper protected boolean isInArc(Coords shooterPosition, int shooterFacing, Coords targetPosition, int weaponArc) Returns the value ofComputeArc.isInArc(Coords, int, Targetable, int). -
guessDistance
protected int guessDistance(Entity shooter, EntityState shooterState, Targetable target, EntityState targetState, Game game) The range this guessed shot is resolved at, from a hypothetical shooter pose.Its own method so that CASPAR's aerospace gunnery can replace it without reproducing the rest of the to-hit guess. The stock behaviour is unchanged.
- Parameters:
shooter- the unit doing the shootingshooterState- the pose the shooter would be firing fromtarget- the unit being fired ontargetState- the pose the target would be ingame- the current game- Returns:
- the range to look up on the weapon's range brackets
-
calcStrategicBuildingTargetUtility
-
calcPriorityUnitTargetUtility
-
calcCivilianTargetDisutility
-
calcCommandUtility
-
isCommander
-
isSubCommander
-
calcTargetPotentialDamageMultiplier
Calculates the logarithmic scaling factor for target damage potential in the utility equation, using the target's potential damage, the weight value TARGET_POTENTIAL_DAMAGE_UTILITY, and Princess's self-preservation value. This is mostly here to not clutter up the utility calculation method with all this extra math. -
getDiveBombPlan
protected FiringPlan getDiveBombPlan(Entity shooter, MovePath flightPath, Targetable target, Game game, boolean passedOverTarget, boolean guess) Creates a firing plan that fires dive bombs, dropping all bombs on the given target- Parameters:
shooter- The unit doing the shooting.target- The unit being fired on.game- The currentGamepassedOverTarget- Set TRUE to automatically assume the target will be under the flight path rather than going through the full calculation.guess- Whether we're just thinking about this firing plan or about to- Returns:
- The
FiringPlancontaining all bombs on target, if the shooter is capable of dropping bombs.
-
calcHeatTolerance
-
calcHeatTolerance
Calculates how much weapon heat this unit is willing to generate before overheating becomes a disutility. The tolerance is lowered by every source of heat the engine will add this turn on top of the unit's current, already-resolved heat: heat already committed this turn (movement heat sits inEntity.heatBuilduponce the unit has moved), the projected heat of a move still being evaluated (predictedMovementHeat), and predicted environmental heat from planetary temperature (seepredictEnvironmentalHeat(Entity)). Extreme cold raises the tolerance, modelling the free cooling the engine grants below -30 C.- Parameters:
entity- the unit that would be firingisAero-trueif the shooter is an Aero (stiffer overheat penalty), ornullto derive it fromentitypredictedMovementHeat- heat the unit would gain from a move currently being evaluated but not yet committed (0 during the firing phase, where committed movement heat is already inEntity.heatBuildup)- Returns:
- the overheat tolerance, or
Entity.DOES_NOT_TRACK_HEATfor units that ignore heat
-
guessBestFiringPlanUnderHeat
protected FiringPlan guessBestFiringPlanUnderHeat(Entity shooter, @Nullable EntityState shooterState, Targetable target, @Nullable EntityState targetState, int maxHeat, Game game) Guesses the 'best' firing plan under a certain heat No twisting is done- Parameters:
shooter- The unit doing the shooting.shooterState- The current state of the shooting unit.target- The unit being shot at.targetState- The current state of the target unit.maxHeat- How much heat we're willing to tolerate.game- The currentGame- Returns:
- the 'best' firing plan under a certain heat.
-
applyTsmHeatIncentive
Adds a utility bonus for a Mek carrying heat-activated standard Triple-Strength Myomer when a firing plan would bring its projected end-of-turn heat up to theTSM_DESIRED_HEATactivation threshold. TSM grants +2 walk MP and double physical damage, so a TSM Mek wants to run hot; this nudges it to fire enough to switch TSM on. The reward peaks at the threshold and tapers to zero atTSM_HEAT_CEILING, so the Mek stays as close to the threshold as it can rather than riding up into shutdown territory; heat past the ceiling gets no reward and the overheat disutility pulls it back. A plan that adds no weapon heat earns nothing, so a Mek already hot from passive sources is not nudged toward not firing. No effect on non-TSM Meks or on prototype/industrial TSM, which do not use the heat threshold.- Parameters:
shooter- the unit doing the shootingfiringPlan- the plan whose utility is adjusted in place
-
firingActivatesTsm
Reports whether firing this plan is what switches a heat-activated standard Triple-Strength Myomer on this turn: the shooter's projected end-of-turn heat reachesTSM_DESIRED_HEATwith the plan's heat but would fall short of it without. This lets callers keep an otherwise trivial heat-building shot instead of discarding it (for example, in favour of spotting for indirect fire). Returnsfalsefor non-TSM Meks, prototype/industrial TSM, and Meks already at or above the activation threshold on their own (which do not need the shot to stay active).- Parameters:
shooter- the unit doing the shootingfiringPlan- the firing plan under consideration- Returns:
trueif firing the plan activates standard TSM this turn, otherwisefalse
-
entityCanIndirectFireMissile
Determines if the given entity can use indirect fire as in LRMs. -
getSpotAction
Determines if the given entity (potentially employing a given firing plan) can/should spot. If yes, then return a spot action. -
getTargetableEnemyEntities
protected List<Targetable> getTargetableEnemyEntities(Entity shooter, Game game, FireControlState fireControlState) Gets all the entities that are potential targets- Parameters:
shooter- The unit doing the shooting.game- The currentGame- Returns:
- A list of potential targets.
-
getMaxDamageAtRange
public static double getMaxDamageAtRange(Entity shooter, int range, boolean useExtremeRange, boolean useLOSRange) Calculates the maximum damage a unit can do at a given range. Chance to hit is not a factor.- Parameters:
shooter- The firing unit.range- The range to be checked.useExtremeRange- Is the extreme range optional rule in effect?- Returns:
- The most damage done at that range.
-
correctFacing
public static int correctFacing(int facing) makes sure facing falls between 0 and 5 This function likely already exists somewhere else- Parameters:
facing- The facing to be corrected.- Returns:
- The properly adjusted facing.
-
getValidFacingChanges
-
getUnjamWeaponPlan
This function evaluates whether or not a unit should spend its time unjamming weapons instead of firing, and returns the appropriate firing plan if that's the case.- Parameters:
shooter- Entity being considered.- Returns:
- Unjam action plan, if we conclude that we should spend time unjamming weapons.
-
getFindClubAction
Return a "Find Club" action, if the unit in question can find a club. -
getSearchLightAction
Given a firing plan, calculate the best target to light up with a searchlight -
effectivelyAmmoless
- Parameters:
weaponType- that uses ammo that is not tracked, or not actually ammo- Returns:
- true if weaponType doesn't actually track ammo
-