Package megamek.common.battlevalue
Class BVCalculator
java.lang.Object
megamek.common.battlevalue.BVCalculator
- Direct Known Subclasses:
BattleArmorBVCalculator
,CombatVehicleBVCalculator
,GunEmplacementBVCalculator
,HandheldWeaponBVCalculator
,HeatTrackingBVCalculator
,InfantryBVCalculator
,ProtoMekBVCalculator
Base class for battle value calculators for all units. The subclasses implement overrides as necessary for the bv
calculation process that all unit types follow. To obtain the correct BVCalculator, use
getBVCalculator(Entity)
.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
The unit's BV with the C3 force bonus and pilot skill adjustmentprotected double
The unit's BV without any force adjustmentsprotected CalculationReport
protected double
protected final Entity
protected boolean
protected boolean
protected boolean
protected boolean
protected double
protected boolean
protected boolean
protected boolean
protected int
protected static final int
protected double
protected static final String
protected int
protected boolean
protected double
The unit's BV with the TAG force bonusprotected static final String
protected int
-
Method Summary
Modifier and TypeMethodDescriptionprotected double
protected void
adjustBV()
Adjust the BV with force bonuses (TAG, C3) and pilot skill.protected boolean
ammoCounts
(AmmoMounted ammo) protected double
protected double
protected BVCalculator.AssembledAmmo
protected void
static double
bvMultiplier
(Entity entity, List<String> pilotModifiers) Returns the BV multiplier for the gunnery/piloting of the given entity's pilot (TM p.315) as well as MD implants of the pilot.static double
bvSkillMultiplier
(int gunnery, int piloting) Returns the BV multiplier for the given gunnery and piloting values.int
Calculate and return the base battle value of the entity of this calculator.int
calculateBaseBV
(CalculationReport bvReport) Calculate and return the base battle value of the entity of this calculator.int
calculateBV
(boolean ignoreC3, boolean ignoreSkill) Calculate and return the current battle value of the entity of this calculator.int
calculateBV
(boolean ignoreC3, boolean ignoreSkill, CalculationReport bvReport) Calculate and return the current battle value of the entity of this calculator.protected boolean
countAsOffensiveWeapon
(Mounted<?> equipment) protected boolean
countMiscAsOffensiveWeapon
(Mounted<?> misc) protected boolean
countsAsDefensiveEquipment
(Mounted<?> equipment) protected void
protected String
equipmentDescriptor
(Mounted<?> mounted) protected double
Returns a Predicate that determines if a weapon is counted as a front or nose arc weapon -ONLY- for the purpose of determining if the weapon BV of front weapons exceeds that of rear weapons on unit types that care about rear weapons.protected double
static BVCalculator
getBVCalculator
(Entity entity) protected int
protected int
protected int
protected int
protected boolean
isFrontFacingVGL
(Mounted<?> weapon) protected boolean
isNominalRear
(Mounted<?> weapon) Returns true when a weapon is to be counted and calculated as a rear weapon.protected boolean
isNominalRearArc
(Mounted<?> weapon) Returns true when a weapon is to be counted and calculated as a "rear" arc weapon in large aerospace units.protected boolean
isRearFacingVGL
(Mounted<?> weapon) protected double
offensiveEquipmentBV
(MiscType misc, int location) protected double
offensiveSpeedFactor
(int mp) Returns the Speed Factor (TM p.316) for the given MP parameterprotected int
protected void
protected void
protected void
Calculates the base unit BV (without force and pilot modifiers).protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
Processes unit type modifiers of TM, p.316.protected void
protected void
protected void
protected void
protected void
Processes the sum of offensive and defensive battle rating and modifiers that affect this sum.void
Processes the BV bonus that a unit with TAG, LTAG or C3M gets for friendly units that have semi-guided or Arrow IV homing ammunition (TO:AUE p.198, https://bg.battletech.com/forums/tactical-operations/tagguided-munitions-and-bv/)protected void
protected double
processWeapon
(Mounted<?> weapon, boolean showInReport, boolean addToOffensiveValue) Forwards toprocessWeapon(Mounted, boolean, boolean, int)
with a weaponCount parameter of 1 (single weapon).protected double
processWeapon
(Mounted<?> weapon, boolean showInReport, boolean addToOffensiveValue, int weaponCount) Determines the BV for one or more weapons of a single type which may include a WeaponType, MiscType or AmmoType.protected void
protected double
processWeaponSection
(boolean showInReport, Predicate<Mounted<?>> weaponFilter, boolean addToOffensiveValue) protected void
Returns a Predicate that determines if a weapon is counted as a rear or aft arc weapon -ONLY- for the purpose of determining if the weapon BV of front weapons exceeds that of rear weapons on unit types that care about rear weapons.protected void
reset()
int
Retrieves a previously calculated base battle value of the unit without re-calculating it; seecalculateBaseBV()
! This should only be used when it is certain that the value is still correct.int
Retrieves a previously calculated full battle value of the unit without re-calculating it; seecalculateBV(boolean, boolean)
! This should only be used when it is certain that the value is still correct.int
Retrieves a previously calculated battle value of the unit without re-calculating it.protected void
Sets the jumping MP as used for battle value calculations.protected void
setRunMP()
Sets the running MP as used for battle value calculations.protected void
setUmuMP()
Sets the UMU MP as used for battle value calculations.protected double
tmmFactor
(int tmmRunning, int tmmJumping, int tmmUmu) protected boolean
protected boolean
validArmorLocation
(int location) Returns true when the given location is valid for armor BV calculations.protected long
workingTAGCount
(Entity entity)
-
Field Details
-
REAR
- See Also:
-
TURRET
- See Also:
-
NO_HEAT
protected static final int NO_HEAT- See Also:
-
entity
-
defensiveValue
protected double defensiveValue -
offensiveValue
protected double offensiveValue -
bvReport
-
ignoreC3
protected boolean ignoreC3 -
ignoreSkill
protected boolean ignoreSkill -
runMP
protected int runMP -
jumpMP
protected int jumpMP -
umuMP
protected int umuMP -
hasBlueShield
protected boolean hasBlueShield -
hasTC
protected boolean hasTC -
isDrone
protected boolean isDrone -
frontAndRearDecided
protected boolean frontAndRearDecided -
switchRearAndFront
protected boolean switchRearAndFront -
heatEfficiencyExceeded
protected boolean heatEfficiencyExceeded -
heatSum
protected double heatSum -
baseBV
protected double baseBVThe unit's BV without any force adjustments -
tagBV
protected double tagBVThe unit's BV with the TAG force bonus -
adjustedBV
protected double adjustedBVThe unit's BV with the C3 force bonus and pilot skill adjustment
-
-
Method Details
-
getBVCalculator
-
calculateBV
public int calculateBV(boolean ignoreC3, boolean ignoreSkill) Calculate and return the current battle value of the entity of this calculator. Depending on the parameters C3 bonuses and/or pilot skill may be removed from the calculation.- Parameters:
ignoreC3
- When true, the force bonus for C3 connections is not added.ignoreSkill
- When true, the pilot skill (including MD) is not factored in.- Returns:
- The newly calculated battle value.
-
calculateBV
Calculate and return the current battle value of the entity of this calculator. Depending on the parameters C3 bonuses and/or pilot skill may be removed from the calculation. The given report is filled in.- Parameters:
ignoreC3
- When true, the force bonus for C3 connections is not added.ignoreSkill
- When true, the pilot skill (including MD) is not factored in.bvReport
- The report to fill in with the calculation.- Returns:
- The newly calculated battle value.
-
calculateBaseBV
public int calculateBaseBV()Calculate and return the base battle value of the entity of this calculator. The base BV does not include any force bonuses, i.e. external stores, C3, pilot skill and TAG bonuses.- Returns:
- The newly calculated base unit battle value.
-
calculateBaseBV
Calculate and return the base battle value of the entity of this calculator. The base BV does not include any force bonuses, i.e. external stores, C3, pilot skill and TAG bonuses. The given report is filled in with the calculation.- Parameters:
bvReport
- The report to fill in with the calculation.- Returns:
- The newly calculated base unit battle value.
-
retrieveBaseBV
public int retrieveBaseBV()Retrieves a previously calculated base battle value of the unit without re-calculating it; seecalculateBaseBV()
! This should only be used when it is certain that the value is still correct. The base BV does not include any force bonuses.- Returns:
- The stored base unit battle value.
-
retrieveBVWithTag
public int retrieveBVWithTag()Retrieves a previously calculated battle value of the unit without re-calculating it. This BV includes the Tag force bonus but no other force bonuses! it can be used as a basis for calculating the C3 bonus without recalculating all units repeatedly. This should only be used when it is certain that the value is still correct.- Returns:
- The stored unit battle value including Tag bonus.
-
retrieveBV
public int retrieveBV()Retrieves a previously calculated full battle value of the unit without re-calculating it; seecalculateBV(boolean, boolean)
! This should only be used when it is certain that the value is still correct. The full BV includes all force bonuses.- Returns:
- The stored full unit battle value.
-
processBaseBV
protected void processBaseBV()Calculates the base unit BV (without force and pilot modifiers). -
processPreparation
protected void processPreparation() -
processCalculations
protected void processCalculations() -
processDefensiveValue
protected void processDefensiveValue() -
processOffensiveValue
protected void processOffensiveValue() -
reset
protected void reset() -
assembleMovementPoints
protected void assembleMovementPoints() -
setRunMP
protected void setRunMP()Sets the running MP as used for battle value calculations. This value should not factor in gravity or weather (as these aren't well visible in the calculation, may change over the course of a battle and aren't available in MHQ). It also should not factor in player-controlled transients such as cargo, trailers, bombs, heat, movement mode changes (LAM, WiGE, QuadVees), grounded/landed status (Aero) as these would also change BV in battle in strange ways. Also, it should ignore advanced rules such as TO Infantry Fast Movement to prevent base BV values different from those on the MUL.It should factor in intransient modifiers such as TSM, modular or hardened armor as well as damage to the unit (engine hits, motive damage, immobile status).
-
setJumpMP
protected void setJumpMP()Sets the jumping MP as used for battle value calculations. Here the same rules apply as withsetRunMP()
. -
setUmuMP
protected void setUmuMP()Sets the UMU MP as used for battle value calculations. Here the same rules apply as withsetRunMP()
. -
processTypeModifier
protected void processTypeModifier() -
validArmorLocation
protected boolean validArmorLocation(int location) Returns true when the given location is valid for armor BV calculations. Returns true by default. Override to exclude locations, e.g. hull on Aeros.- Parameters:
location
- The location to check- Returns:
- True when the given location must be considered for Armor BV
-
processArmor
protected void processArmor() -
armorFactor
protected double armorFactor()- Returns:
- The base factor to multiply armor by, i.e. 25 for capital aerosapce and 2.5 for all others.
-
equipmentDescriptor
-
addTorsoMountedCockpit
protected double addTorsoMountedCockpit() -
processStructure
protected void processStructure() -
countsAsDefensiveEquipment
-
processDefensiveEquipment
protected void processDefensiveEquipment() -
processExplosiveEquipment
protected void processExplosiveEquipment() -
processDefensiveFactor
protected void processDefensiveFactor() -
getRunningTMM
protected int getRunningTMM() -
getJumpingTMM
protected int getJumpingTMM() -
getUmuTMM
protected int getUmuTMM() -
tmmFactor
protected double tmmFactor(int tmmRunning, int tmmJumping, int tmmUmu) -
determineFront
protected void determineFront() -
processWeapons
protected void processWeapons() -
isRearFacingVGL
-
isFrontFacingVGL
-
processWeaponSection
-
isNominalRear
Returns true when a weapon is to be counted and calculated as a rear weapon. For units that deal with rear weapons this is usually true when the weapon is actually rear-facing but may be false when weapon facing is reversed (when the front weapons BV is smaller than the rear weapon BV). This method should rely on the switchRearAndFront field to decide the return value. switchRearAndFront is set before weapons are processed by the call todetermineFront()
. By default, this returns false which is correct for units that do not deal with rear weapons such as ProtoMeks. This is overridden as necessary for units that deal with rear weapons (Mek, Aero, Tanks, but not large aerospace that use arcs).- Parameters:
weapon
- The Mounted equipment to check- Returns:
- True when the weapon is to be counted as if it was rear-facing
-
isNominalRearArc
Returns true when a weapon is to be counted and calculated as a "rear" arc weapon in large aerospace units. The nominal rear arcs are those that are valued at 25% only. By default, this returns false. This is overridden for large aerospace units.- Parameters:
weapon
- The Mounted equipment to check- Returns:
- True when the weapon is to be counted as in a "rear" arc
-
usesWeaponHeat
protected boolean usesWeaponHeat()- Returns:
- When true, will show individual weapon heat sums. Used in Meks, AF, CF, and SC.
-
arcFactor
- Returns:
- The multiplier for the arc that the given equipment is in (1, 0.5, or 0.25). Overridden for large aerospace units. When not 1, the factor is shown in the report and multiplied into the resulting BV.
-
processWeapon
protected double processWeapon(Mounted<?> weapon, boolean showInReport, boolean addToOffensiveValue) Forwards toprocessWeapon(Mounted, boolean, boolean, int)
with a weaponCount parameter of 1 (single weapon). -
processWeapon
protected double processWeapon(Mounted<?> weapon, boolean showInReport, boolean addToOffensiveValue, int weaponCount) Determines the BV for one or more weapons of a single type which may include a WeaponType, MiscType or AmmoType. When showInReport is false, nothing is written to the report. Otherwise, a line with the weapon's name and (if it has a WeaponType) location as well as the calculation and modifiers is shown.- Parameters:
weapon
- The Mounted to process - may include a WeaponType, MiscType or AmmoTypeshowInReport
- When true, will write a line for this weapon to the report.weaponCount
- The number of this particular type of weapon (multiplies the BV)addToOffensiveValue
- When true, will add the result to offensiveValue and show the result- Returns:
- The BV for this weapon
-
frontWeaponFilter
Returns a Predicate that determines if a weapon is counted as a front or nose arc weapon -ONLY- for the purpose of determining if the weapon BV of front weapons exceeds that of rear weapons on unit types that care about rear weapons. By default, returns true so that all weapons count safely as front weapons. Should be overridden for all unit types that account for rear-facing weapons. Does not need to be overridden for unit types that don't (such as ProtoMeks).- Returns:
- A Predicate identifying if a weapon counts as a front weapon (read above!)
-
rearWeaponFilter
Returns a Predicate that determines if a weapon is counted as a rear or aft arc weapon -ONLY- for the purpose of determining if the weapon BV of front weapons exceeds that of rear weapons on unit types that care about rear weapons. By default, returns false so that all weapons count safely as front weapons. Should be overridden for all unit types that account for rear-facing weapons. Does not need to be overridden for unit types that don't (such as ProtoMeks).- Returns:
- A Predicate identifying if a weapon counts as a front weapon (read above!)
-
countAsOffensiveWeapon
-
countMiscAsOffensiveWeapon
-
fireControlModifier
protected double fireControlModifier()- Returns:
- The BV modifier for AFC or BFC. Override as necessary.
-
processOffensiveEquipment
protected void processOffensiveEquipment() -
offensiveEquipmentBV
-
processAmmo
protected void processAmmo() -
heatEfficiency
protected int heatEfficiency()- Returns:
- The unit's heat dissipation for BV purposes. Override as necessary.
-
processWeight
protected void processWeight() -
processSpeedFactor
protected void processSpeedFactor() -
offensiveSpeedFactor
protected double offensiveSpeedFactor(int mp) Returns the Speed Factor (TM p.316) for the given MP parameter- Parameters:
mp
- The MP value for the unit (base value: Walk + 1/2 Jump/UMU)- Returns:
- The Speed Factor as a two-digit-rounded double such as 1.76
-
offensiveSpeedFactorMP
protected int offensiveSpeedFactorMP()- Returns:
- the MP value to use for the Offensive Speed Factor (TM p.316) for this unit.
-
processOffensiveTypeModifier
protected void processOffensiveTypeModifier()Processes unit type modifiers of TM, p.316. -
ammoCounts
- Returns:
- true when the given ammo (must be AmmoType) counts towards offensive ammo BV calculation.
-
processSummarize
protected void processSummarize()Processes the sum of offensive and defensive battle rating and modifiers that affect this sum. -
assembleAmmo
-
getAmmoBV
-
adjustBV
protected void adjustBV()Adjust the BV with force bonuses (TAG, C3) and pilot skill. -
bvMultiplier
Returns the BV multiplier for the gunnery/piloting of the given entity's pilot (TM p.315) as well as MD implants of the pilot. Returns 1 if the given entity's crew is null. Special treatment is given to infantry units where units unable to make anti-mek attacks use 5 as their anti-mek (piloting) value as well as LAM pilots that use the average of their aero and mek values.- Parameters:
entity
- The entity to get the skill modifier for- Returns:
- The BV multiplier for the given entity's pilot
-
bvSkillMultiplier
public static double bvSkillMultiplier(int gunnery, int piloting) Returns the BV multiplier for the given gunnery and piloting values. Returns 1 for the neutral values 4/5.- Parameters:
gunnery
- the gunnery skill of a pilotpiloting
- the piloting skill of a pilot- Returns:
- a multiplier to the BV of whatever unit the pilot is piloting.
-
processTagBonus
public void processTagBonus()Processes the BV bonus that a unit with TAG, LTAG or C3M gets for friendly units that have semi-guided or Arrow IV homing ammunition (TO:AUE p.198, https://bg.battletech.com/forums/tactical-operations/tagguided-munitions-and-bv/) -
workingTAGCount
-
processExternalStores
protected void processExternalStores()
-