Package megamek.common.units
Class MagneticPulseState
java.lang.Object
megamek.common.units.MagneticPulseState
- All Implemented Interfaces:
Serializable
Per-unit state for the Magnetic Pulse (MP, TO:AUE p.182) and Improved Magnetic Pulse (iATM IMP) missile effects.
Holds the effect counters and the heat-accumulation remainders, and derives the to-hit, movement and hostile-ECM
modifiers from the number of warheads that have hit the unit.
Held by Entity as a single field; Entity exposes the effects through thin delegating methods, and the various
subsystems (to-hit, movement, ECM, heat, unit display) read through that API. This keeps the effect's state and math
in one focused, testable place.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intWarheads per +1 outside heat for the two standard Magnetic Pulse rates (TO:AUE p.182).static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddImpHits(int missiles) voidRecords a standard MP hit: the +1 to-hit lasts through the End Phase of the following turn.intcomputeImpHeat(int missiles) intcomputeStandardHeat(int missiles, int heatDivisor) Accumulates standard MP heat, carrying the sub-threshold remainder across salvos in the same turn.intintintgetImpMpReduction(boolean isFusion, boolean isProtoMek) intgetImpToHitModifier(boolean isProtoMek) intbooleanvoidnewRound()Advances the Magnetic Pulse effects one round: decrements the standard MP window and rolls the IMP hit count over so this turn's hits become the previous turn's.voidsetImpLastTurn(int impLastTurn)
-
Field Details
-
LRM_HEAT_DIVISOR
public static final int LRM_HEAT_DIVISORWarheads per +1 outside heat for the two standard Magnetic Pulse rates (TO:AUE p.182).- See Also:
-
SRM_HEAT_DIVISOR
public static final int SRM_HEAT_DIVISOR- See Also:
-
-
Constructor Details
-
MagneticPulseState
public MagneticPulseState()
-
-
Method Details
-
applyStandardPulse
public void applyStandardPulse()Records a standard MP hit: the +1 to-hit lasts through the End Phase of the following turn. Additional hits while the effect is already active do not extend or restart the window (TO:AUE p.182), so the counter is only started when the unit is not already affected. -
getStandardRounds
public int getStandardRounds() -
computeStandardHeat
public int computeStandardHeat(int missiles, int heatDivisor) Accumulates standard MP heat, carrying the sub-threshold remainder across salvos in the same turn. The remainder is tracked separately per rate, so an MML firing both modes does not cross the 5- and 3-warhead rates.- Parameters:
missiles- warheads that hit in this salvoheatDivisor- warheads per +1 heat (LRM_HEAT_DIVISORorSRM_HEAT_DIVISOR)- Returns:
- the outside heat to bank for this salvo
-
addImpHits
public void addImpHits(int missiles) -
computeImpHeat
public int computeImpHeat(int missiles) - Parameters:
missiles- warheads that hit in this salvo- Returns:
- the outside heat to bank for an IMP salvo: +1 per 3 warheads, remainder carried across salvos in the same turn
-
getActiveImpHits
public int getActiveImpHits()- Returns:
- warheads currently affecting the unit (this turn plus the previous turn).
-
getImpToHitModifier
public int getImpToHitModifier(boolean isProtoMek) - Parameters:
isProtoMek- whether the affected unit is a ProtoMek (higher cap)- Returns:
- the +to-hit penalty from IMP missiles: +1 per 3 warheads, capped at +2 (or +3 for ProtoMeks). Applies to fusion and non-fusion units alike.
-
getImpMpReduction
public int getImpMpReduction(boolean isFusion, boolean isProtoMek) - Parameters:
isFusion- whether the affected unit is fusion-poweredisProtoMek- whether the affected unit is a ProtoMek (higher cap)- Returns:
- the Walk/Jump MP reduction from IMP missiles: -1 per 3 warheads, capped at -2 (or -3 for ProtoMeks). Non-fusion units ignore this reduction.
-
isImpEcmAffected
public boolean isImpEcmAffected()- Returns:
trueonce at least 3 IMP warheads are affecting the unit (hostile ECM threshold).
-
getImpLastTurn
public int getImpLastTurn() -
setImpLastTurn
public void setImpLastTurn(int impLastTurn) -
newRound
public void newRound()Advances the Magnetic Pulse effects one round: decrements the standard MP window and rolls the IMP hit count over so this turn's hits become the previous turn's. Called fromEntity.newRound(int).
-