/*
   * (non-Javadoc)
   *
   * @see megamek.common.weapons.WeaponHandler#calcDamagePerHit()
   */
  @Override
  protected int calcDamagePerHit() {
    double toReturn = wtype.getDamage();
    // infantry get hit by all shots
    if ((target instanceof Infantry) && !(target instanceof BattleArmor)) {
      if (howManyShots > 1) { // Is this a cluser attack?
        // Compute maximum damage potential for cluster weapons
        toReturn = howManyShots * wtype.getDamage();
        toReturn =
            Compute.directBlowInfantryDamage(
                toReturn,
                bDirect ? toHit.getMoS() / 3 : 0,
                WeaponType.WEAPON_CLUSTER_BALLISTIC, // treat as cluster
                ((Infantry) target).isMechanized(),
                toHit.getThruBldg() != null,
                ae.getId(),
                calcDmgPerHitReport);
      } else { // No - only one shot fired
        toReturn =
            Compute.directBlowInfantryDamage(
                wtype.getDamage(),
                bDirect ? toHit.getMoS() / 3 : 0,
                wtype.getInfantryDamageClass(),
                ((Infantry) target).isMechanized(),
                toHit.getThruBldg() != null,
                ae.getId(),
                calcDmgPerHitReport);
      }
      // Cluster bonuses or penalties can't apply to "two rolls" UACs, so
      // if we have one, modify the damage per hit directly.
    } else if (bDirect && (howManyShots == 1 || twoRollsUltra)) {
      toReturn = Math.min(toReturn + (toHit.getMoS() / 3), toReturn * 2);
    }

    if (bGlancing && (howManyShots == 1 || twoRollsUltra)) {
      toReturn = (int) Math.floor(toReturn / 2.0);
    }

    if (game.getOptions().booleanOption(OptionsConstants.AC_TAC_OPS_RANGE)
        && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_LONG])) {
      toReturn = (int) Math.floor(toReturn * .75);
    }
    if (game.getOptions().booleanOption(OptionsConstants.AC_TAC_OPS_LOS_RANGE)
        && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_EXTREME])) {
      toReturn = (int) Math.floor(toReturn * .5);
    }
    return (int) toReturn;
  }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see megamek.common.weapons.WeaponHandler#calcDamagePerHit()
   */
  @Override
  protected int calcDamagePerHit() {
    double toReturn = wtype.getDamage();

    if (game.getOptions().booleanOption("tacops_energy_weapons") && wtype.hasModes()) {
      toReturn = Compute.dialDownDamage(weapon, wtype, nRange);
    }

    // during a swarm, all damage gets applied as one block to one location
    if ((ae instanceof BattleArmor)
        && (weapon.getLocation() == BattleArmor.LOC_SQUAD)
        && !(weapon.isSquadSupportWeapon())
        && (ae.getSwarmTargetId() == target.getTargetId())) {
      toReturn *= ((BattleArmor) ae).getShootingStrength();
    }
    // Check for Altered Damage from Energy Weapons (TacOp, pg.83)
    if (game.getOptions().booleanOption("tacops_altdmg")) {
      if (nRange <= 1) {
        toReturn++;
      } else if (nRange <= wtype.getMediumRange()) {
        // Do Nothing for Short and Medium Range
      } else if (nRange <= wtype.getLongRange()) {
        toReturn--;
      }
    }

    if (game.getOptions().booleanOption(OptionsConstants.AC_TAC_OPS_RANGE)
        && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_LONG])) {
      toReturn = (int) Math.floor(toReturn / 2.0);
    }
    if (game.getOptions().booleanOption(OptionsConstants.AC_TAC_OPS_LOS_RANGE)
        && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_EXTREME])) {
      toReturn = (int) Math.floor(toReturn / 3.0);
    }

    if ((target instanceof Infantry) && !(target instanceof BattleArmor)) {
      toReturn =
          Compute.directBlowInfantryDamage(
              toReturn,
              bDirect ? toHit.getMoS() / 3 : 0,
              wtype.getInfantryDamageClass(),
              ((Infantry) target).isMechanized());
    } else if (bDirect) {
      toReturn = Math.min(toReturn + (toHit.getMoS() / 3), toReturn * 2);
    }
    if (bGlancing) {
      toReturn = (int) Math.floor(toReturn / 2.0);
    }
    return (int) Math.ceil(toReturn);
  }