Class TWDamageManager

java.lang.Object
megamek.server.totalWarfare.TWDamageManager
All Implemented Interfaces:
IDamageManager

public class TWDamageManager extends Object implements IDamageManager
  • Field Details

    • manager

      protected TWGameManager manager
    • game

      protected Game game
    • initialized

      protected boolean initialized
  • Constructor Details

    • TWDamageManager

      public TWDamageManager()
    • TWDamageManager

      public TWDamageManager(TWGameManager manager)
    • TWDamageManager

      public TWDamageManager(TWGameManager manager, Game game)
  • Method Details

    • setGame

      public void setGame(Game game)
    • setManager

      public void setManager(TWGameManager manager)
    • damageEntity

      public Vector<Report> damageEntity(DamageInfo damageInfo)
      Unpacks DamageInfo Record into arguments and checks that the Game Manager and Game are initialized
      Specified by:
      damageEntity in interface IDamageManager
      Parameters:
      damageInfo - DamageInfo for 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 damaged
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      damageIS - Whether damage is going straight to the internal structure
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      reportVec - Vector of Reports containing prior reports; usually modded and returned
      Returns:
      A Vector of Report objects
    • 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 returned
      proto - ProtoMek entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      mods - 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 returned
      mek - Mek entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      mods - 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 to
      aero - the aerospace unit taking damage
      hit - the hit location data, including singleAV for weapon groups
      damage - the total damage to apply
      ammoExplosion - true if this damage is from an ammo explosion
      damageType - the type of damage (standard, armor-piercing, etc.)
      areaSatArty - true if this is area saturation artillery
      throughFront - true if attack came through front arc
      underWater - true if target is underwater
      nukeS2S - true if this is ship-to-ship nuclear damage
      mods - 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 returned
      tank - Tank entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      mods - 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 returned
      entity - Squadron Fighter entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      damageIS - Whether damage is going straight to the internal structure
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - 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 returned
      entity - BA squad entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      damageIS - Whether damage is going straight to the internal structure
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      mods - 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 returned
      battleArmor - BA entity we are damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Type of damage, mainly used for specialized armor
      areaSatArty - Whether damage is caused by AE attack
      throughFront - Through front arc or no, for some specialized armors
      underWater - Whether damage is being dealt underwater, for breach check
      nukeS2S - Whether damage is from a nuclear weapon
      mods - 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

      protected Vector<Report> applySuicideImplantReaction(Entity infantry, int deadTroopers)
      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 troopers
      deadTroopers - The number of troopers killed
      Returns:
      Vector of reports describing the reactive damage
    • calcCritBonus

      public int calcCritBonus(Entity attacker, Entity entity, int damageOriginal, boolean areaSatArty)
      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 attacked
      damageOriginal - Original damage amount
      areaSatArty - Whether damage is being dealt by area saturation artillery
      Returns:
      int number of bonus crits to deal to entity
    • checkFerroFibrous

      public boolean checkFerroFibrous(Entity entity, HitData hit)
      Determines if the entity being damaged has Ferro-Fibrous armor of any kind.
      Parameters:
      entity - entity that we are damaging
      hit - HitData recording aspects of the incoming damage
      Returns:
      boolean true if FF armor found, otherwise false
    • applyModularArmor

      public int applyModularArmor(Entity entity, HitData hit, int damage, boolean ammoExplosion, boolean damageIS, Vector<Report> reportVec)
    • 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 damaged
      hit - the incoming hit
      damage - the incoming damage
      ammoExplosion - 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 bridge
      reportVec - 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 damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      reportVec - 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 damaging
      reportVec - Vector of Reports containing prior reports; usually modded and returned
      hit - HitData recording aspects of the incoming damage
      mods - damage modifiers and state tracking
      damageType - 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 damaging
      hit - HitData recording aspects of the incoming damage
      damageIS - Whether damage is going straight to the internal structure
      damageOriginal - Original damage value being applied to the entity, before mods and armor
      crits - "Baked in" crits; this is modified as damage is applied.
      Returns:
      ModsInfo object storing various values for other code to use and modify
    • updateArmorTypeMap

      protected void updateArmorTypeMap(TWDamageManager.ModsInfo mods, Entity entity, HitData hit)
      Modifies various armor-tracking fields in mods depending on damaged entity and location
      Parameters:
      mods - damage modifiers and state tracking
      entity - Entity we are damaging
      hit - 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 damaging
      reportVec - Vector of Reports containing prior reports; usually modded and returned
      damage - Actual amount of incoming damage
      damageType - Type of damage, mainly used for specialized armor
      hit - HitData recording aspects of the incoming damage
      isPlatoon - Whether the entity being damaged is an infantry group
      mods - 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 damaging
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageType - Special damage type info that determines how passengers may be affected
      reportVec - 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 damaged
      hit - HitData recording aspects of the incoming damage
      damage - Actual amount of incoming damage
      ammoExplosion - Whether damage was caused by an ammo explosion
      damageIS - Whether damage is going straight to the internal structure
      areaSatArty - Whether damage is caused by AE attack
      reportVec - Vector of Reports containing prior reports; usually modded and returned
      Returns:
      Remaining damage not absorbed by armor
    • getArmorFriendlyName

      public String getArmorFriendlyName(TWDamageManager.ModsInfo mods)