Package megamek.server.totalWarfare
Class TWDamageManager
java.lang.Object
megamek.server.totalWarfare.TWDamageManager
- All Implemented Interfaces:
IDamageManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRecord-type class that various methods pass around and modify -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTWDamageManager(TWGameManager manager) TWDamageManager(TWGameManager manager, Game game) -
Method Summary
Modifier and TypeMethodDescriptionintapplyBridgeLayerAbsorption(Entity entity, HitData hit, int damage, boolean ammoExplosion, TWDamageManager.ModsInfo mods, Vector<Report> reportVec) Applies a carried Bridge-Layer (AVLB) folding bridge as damage protection, TM p.242 / TW: an attack that would hit the location where the bridge is mounted (or, on a Support Vehicle, the turret) hits the bridge instead, reducing its Construction Factor by the damage.intapplyEntityArmorDamage(Entity entity, HitData hit, int damage, boolean ammoExplosion, boolean damageIS, boolean areaSatArty, Vector<Report> reportVec, TWDamageManager.ModsInfo mods) Apply damage to the armor in the hit location; remaining damage will be applied elsewhere.intapplyModularArmor(Entity entity, HitData hit, int damage, boolean ammoExplosion, boolean damageIS, Vector<Report> reportVec) applySuicideImplantReaction(Entity infantry, int deadTroopers) Applies suicide implant reactive damage when conventional infantry troopers are killed.intapplyTankCASEDamageReduction(Tank tank, HitData hit, int damage, boolean ammoExplosion, Vector<Report> reportVec) Determine how much damage will be reduced by tank CASE equipmentintcalcCritBonus(Entity attacker, Entity entity, int damageOriginal, boolean areaSatArty) Determines what, if any, additional critical damage will be applied by this damage instancebooleancheckFerroFibrous(Entity entity, HitData hit) Determines if the entity being damaged has Ferro-Fibrous armor of any kind.protected TWDamageManager.ModsInfocreateDamageModifiers(Entity entity, HitData hit, boolean damageIS, int damageOriginal, int crits) voiddamageAeroSpace(Vector<Report> reportVec, Aero aero, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) Applies damage to an aerospace unit (fighter, small craft, dropship, etc.).voiddamageBA(Vector<Report> reportVec, BattleArmor battleArmor, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) damageEntity(DamageInfo damageInfo) Unpacks DamageInfo Record into arguments and checks that the Game Manager and Game are initializeddamageEntity(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, Vector<Report> reportVec) Top-level damage function; calls specialized functions to deal with damage to specific unit types.voiddamageHandheldWeapon(Vector<Report> reportVec, HandheldWeapon hhw, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddamageInfantry(Vector<Report> reportVec, ConvInfantry infantry, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddamageMek(Vector<Report> reportVec, Mek mek, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddamageMultipleBAs(Vector<Report> reportVec, Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddamageProtoMek(Vector<Report> reportVec, ProtoMek proto, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddamageSquadronFighter(Vector<Report> reportVec, Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S) voiddamageTank(Vector<Report> reportVec, Tank tank, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) voiddealSpecialCritEffects(Entity entity, Vector<Report> reportVec, HitData hit, TWDamageManager.ModsInfo mods, DamageType damageType) Deals special critical damage effects to the entity taking damage.inthandleExternalPassengerDamage(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, Vector<Report> reportVec) Deals damage to external passengers (BAs, infantry, etc.) on a unit that is receiving external damage.intmanageDamageTypeReports(Entity entity, Vector<Report> reportVec, int damage, DamageType damageType, HitData hit, boolean isPlatoon, TWDamageManager.ModsInfo mods) Reports on special damage-modifying effects and returns any remaining damage that should be applied to the entity in question.voidvoidsetManager(TWGameManager manager) protected voidupdateArmorTypeMap(TWDamageManager.ModsInfo mods, Entity entity, HitData hit) Modifies various armor-tracking fields in mods depending on damaged entity and location
-
Field Details
-
manager
-
game
-
initialized
protected boolean initialized
-
-
Constructor Details
-
TWDamageManager
public TWDamageManager() -
TWDamageManager
-
TWDamageManager
-
-
Method Details
-
setGame
-
setManager
-
damageEntity
Unpacks DamageInfo Record into arguments and checks that the Game Manager and Game are initialized- Specified by:
damageEntityin interfaceIDamageManager- Parameters:
damageInfo-DamageInfofor details- Returns:
- Vector of reports detailing damage dealt.
-
damageEntity
public Vector<Report> damageEntity(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, Vector<Report> reportVec) Top-level damage function; calls specialized functions to deal with damage to specific unit types.- Parameters:
entity- Entity being damagedhit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armordamageIS- Whether damage is going straight to the internal structureareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponreportVec- Vector of Reports containing prior reports; usually modded and returned- Returns:
- A Vector of
Reportobjects
-
damageProtoMek
public void damageProtoMek(Vector<Report> reportVec, ProtoMek proto, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedproto- ProtoMek entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armorareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponmods- damage modifiers and state tracking
-
damageMek
public void damageMek(Vector<Report> reportVec, Mek mek, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedmek- Mek entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armorareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponmods- damage modifiers and state tracking
-
damageAeroSpace
public void damageAeroSpace(Vector<Report> reportVec, Aero aero, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) Applies damage to an aerospace unit (fighter, small craft, dropship, etc.).Per Strategic Operations p.116, when a weapon group/bay fires multiple weapons, the threshold critical check uses only a single weapon's damage value (stored in
HitData.getSingleAV()), NOT the total damage from all weapons. The full damage is still applied to the target, but threshold is checked against the single weapon value. This prevents unrealistic threshold criticals from massed small weapons like 22 medium lasers (110 damage total, but threshold check uses only 5 damage from one laser).- Parameters:
reportVec- the vector to add combat reports toaero- the aerospace unit taking damagehit- the hit location data, including singleAV for weapon groupsdamage- the total damage to applyammoExplosion- true if this damage is from an ammo explosiondamageType- the type of damage (standard, armor-piercing, etc.)areaSatArty- true if this is area saturation artillerythroughFront- true if attack came through front arcunderWater- true if target is underwaternukeS2S- true if this is ship-to-ship nuclear damagemods- damage modifiers and state tracking
-
damageTank
public void damageTank(Vector<Report> reportVec, Tank tank, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedtank- Tank entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armorareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponmods- damage modifiers and state tracking
-
damageHandheldWeapon
public void damageHandheldWeapon(Vector<Report> reportVec, HandheldWeapon hhw, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) -
damageSquadronFighter
public void damageSquadronFighter(Vector<Report> reportVec, Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedentity- Squadron Fighter entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armordamageIS- Whether damage is going straight to the internal structureareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weapon
-
damageMultipleBAs
public void damageMultipleBAs(Vector<Report> reportVec, Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean damageIS, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedentity- BA squad entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armordamageIS- Whether damage is going straight to the internal structureareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponmods- damage modifiers and state tracking
-
damageBA
public void damageBA(Vector<Report> reportVec, BattleArmor battleArmor, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) - Parameters:
reportVec- Vector of Reports containing prior reports; usually modded and returnedbattleArmor- BA entity we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Type of damage, mainly used for specialized armorareaSatArty- Whether damage is caused by AE attackthroughFront- Through front arc or no, for some specialized armorsunderWater- Whether damage is being dealt underwater, for breach checknukeS2S- Whether damage is from a nuclear weaponmods- damage modifiers and state tracking
-
damageInfantry
public void damageInfantry(Vector<Report> reportVec, ConvInfantry infantry, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, boolean areaSatArty, boolean throughFront, boolean underWater, boolean nukeS2S, TWDamageManager.ModsInfo mods) -
applySuicideImplantReaction
Applies suicide implant reactive damage when conventional infantry troopers are killed. Per IO pg 83: "Conventional infantry equipped with suicide implants will also deliver an automatic 'attack' against all opposing units in the same hex for every trooper they lose during the same attack."- Parameters:
infantry- The infantry unit that lost troopersdeadTroopers- The number of troopers killed- Returns:
- Vector of reports describing the reactive damage
-
calcCritBonus
Determines what, if any, additional critical damage will be applied by this damage instance- Parameters:
attacker- Entity attacking the target (needed for ability checks)entity- Entity being attackeddamageOriginal- Original damage amountareaSatArty- Whether damage is being dealt by area saturation artillery- Returns:
- int number of bonus crits to deal to entity
-
checkFerroFibrous
Determines if the entity being damaged has Ferro-Fibrous armor of any kind.- Parameters:
entity- entity that we are damaginghit- HitData recording aspects of the incoming damage- Returns:
- boolean true if FF armor found, otherwise false
-
applyModularArmor
-
applyBridgeLayerAbsorption
public int applyBridgeLayerAbsorption(Entity entity, HitData hit, int damage, boolean ammoExplosion, TWDamageManager.ModsInfo mods, Vector<Report> reportVec) Applies a carried Bridge-Layer (AVLB) folding bridge as damage protection, TM p.242 / TW: an attack that would hit the location where the bridge is mounted (or, on a Support Vehicle, the turret) hits the bridge instead, reducing its Construction Factor by the damage. Once the bridge's CF reaches 0 it is destroyed and any remaining damage passes to the location normally. A critical hit while the bridge is still carried disables the deploy mechanism (the first one; further crits have no effect) and does not carry through to the location. The carried bridge does not protect against ammo explosions or damage applied directly to internal structure.- Parameters:
entity- the unit being damagedhit- the incoming hitdamage- the incoming damageammoExplosion- whether the damage is from an ammo explosion (not absorbed)mods- damage modifiers; critical-hit flags are cleared when a crit is consumed by the bridgereportVec- the running report list, appended to with absorption/destruction/crit reports- Returns:
- the damage remaining after the bridge absorbs what it can
-
applyTankCASEDamageReduction
public int applyTankCASEDamageReduction(Tank tank, HitData hit, int damage, boolean ammoExplosion, Vector<Report> reportVec) Determine how much damage will be reduced by tank CASE equipment- Parameters:
tank- Tank entity that we are damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosionreportVec- Vector of Reports containing prior reports; usually modded and returned- Returns:
- int total of damage remaining after reduction by CASE
-
dealSpecialCritEffects
public void dealSpecialCritEffects(Entity entity, Vector<Report> reportVec, HitData hit, TWDamageManager.ModsInfo mods, DamageType damageType) Deals special critical damage effects to the entity taking damage.- Parameters:
entity- Entity we are damagingreportVec- Vector of Reports containing prior reports; usually modded and returnedhit- HitData recording aspects of the incoming damagemods- damage modifiers and state trackingdamageType- Type of damage, mainly used for specialized armor
-
createDamageModifiers
protected TWDamageManager.ModsInfo createDamageModifiers(Entity entity, HitData hit, boolean damageIS, int damageOriginal, int crits) - Parameters:
entity- Entity we are damaginghit- HitData recording aspects of the incoming damagedamageIS- Whether damage is going straight to the internal structuredamageOriginal- Original damage value being applied to the entity, before mods and armorcrits- "Baked in" crits; this is modified as damage is applied.- Returns:
- ModsInfo object storing various values for other code to use and modify
-
updateArmorTypeMap
Modifies various armor-tracking fields in mods depending on damaged entity and location- Parameters:
mods- damage modifiers and state trackingentity- Entity we are damaginghit- HitData recording aspects of the incoming damage
-
manageDamageTypeReports
public int manageDamageTypeReports(Entity entity, Vector<Report> reportVec, int damage, DamageType damageType, HitData hit, boolean isPlatoon, TWDamageManager.ModsInfo mods) Reports on special damage-modifying effects and returns any remaining damage that should be applied to the entity in question.- Parameters:
entity- Entity we are damagingreportVec- Vector of Reports containing prior reports; usually modded and returneddamage- Actual amount of incoming damagedamageType- Type of damage, mainly used for specialized armorhit- HitData recording aspects of the incoming damageisPlatoon- Whether the entity being damaged is an infantry groupmods- damage modifiers and state tracking- Returns:
- int Any remaining damage that must be processed further
-
handleExternalPassengerDamage
public int handleExternalPassengerDamage(Entity entity, HitData hit, int damage, boolean ammoExplosion, DamageType damageType, Vector<Report> reportVec) Deals damage to external passengers (BAs, infantry, etc.) on a unit that is receiving external damage.- Parameters:
entity- Entity that we are in the process of damaginghit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageType- Special damage type info that determines how passengers may be affectedreportVec- Vector of Reports containing prior reports; usually modded and returned- Returns:
- int total of damage remaining after pasengers absorb damage
-
applyEntityArmorDamage
public int applyEntityArmorDamage(Entity entity, HitData hit, int damage, boolean ammoExplosion, boolean damageIS, boolean areaSatArty, Vector<Report> reportVec, TWDamageManager.ModsInfo mods) Apply damage to the armor in the hit location; remaining damage will be applied elsewhere.- Parameters:
entity- Entity being damagedhit- HitData recording aspects of the incoming damagedamage- Actual amount of incoming damageammoExplosion- Whether damage was caused by an ammo explosiondamageIS- Whether damage is going straight to the internal structureareaSatArty- Whether damage is caused by AE attackreportVec- Vector of Reports containing prior reports; usually modded and returned- Returns:
- Remaining damage not absorbed by armor
-
getArmorFriendlyName
-