/*
  * (non-Javadoc)
  *
  * @see megamek.common.weapons.WeaponHandler#doChecks(java.util.Vector)
  */
 @Override
 protected boolean doChecks(Vector<Report> vPhaseReport) {
   if ((roll == 2) && (howManyShots == 2) && !(ae instanceof Infantry)) {
     Report r = new Report();
     r.subject = subjectId;
     weapon.setJammed(true);
     isJammed = true;
     if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA)
         || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
       r.messageId = 3160;
     } else {
       r.messageId = 3170;
     }
     vPhaseReport.addElement(r);
   }
   return false;
 }
Example #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * megamek.common.weapons.WeaponHandler#handleEntityDamage(megamek.common
  * .Entity, java.util.Vector, megamek.common.Building, int, int, int, int)
  */
 @Override
 protected void handleEntityDamage(
     Entity entityTarget,
     Vector<Report> vPhaseReport,
     Building bldg,
     int hits,
     int nCluster,
     int bldgAbsorbs) {
   super.handleEntityDamage(entityTarget, vPhaseReport, bldg, hits, nCluster, bldgAbsorbs);
   if (!missed && ((entityTarget instanceof Mech) || (entityTarget instanceof Aero))) {
     Report r = new Report(3400);
     r.subject = subjectId;
     r.indent(2);
     int extraHeat = 0;
     // if this is a fighter squadron, we need to account for number of
     // weapons
     // should default to one for non squadrons
     for (int i = 0; i < nweaponsHit; i++) {
       extraHeat += Compute.d6();
     }
     if (entityTarget.getArmor(hit) > 0
         && (entityTarget.getArmorType(hit.getLocation()) == EquipmentType.T_ARMOR_REFLECTIVE)) {
       entityTarget.heatFromExternal += Math.max(1, extraHeat / 2);
       r.add(Math.max(1, extraHeat / 2));
       r.choose(true);
       r.messageId = 3406;
       r.add(extraHeat);
       r.add(EquipmentType.armorNames[entityTarget.getArmorType(hit.getLocation())]);
     } else if (entityTarget.getArmor(hit) > 0
         && (entityTarget.getArmorType(hit.getLocation())
             == EquipmentType.T_ARMOR_HEAT_DISSIPATING)) {
       entityTarget.heatFromExternal += extraHeat / 2;
       r.add(extraHeat / 2);
       r.choose(true);
       r.messageId = 3406;
       r.add(extraHeat);
       r.add(EquipmentType.armorNames[entityTarget.getArmorType(hit.getLocation())]);
     } else {
       entityTarget.heatFromExternal += extraHeat;
       r.add(extraHeat);
       r.choose(true);
     }
     vPhaseReport.addElement(r);
   }
 }
  /**
   * handle this weapons firing
   *
   * @return a <code>boolean</code> value indicating wether this should be kept or not
   */
  @Override
  public boolean handle(IGame.Phase phase, Vector<Report> vPhaseReport) {
    if (!this.cares(phase)) {
      return true;
    }

    // Report weapon attack and its to-hit value.
    Report r = new Report(3115);
    r.indent();
    r.newlines = 0;
    r.subject = subjectId;
    r.add(wtype.getName());
    r.messageId = 3120;
    r.add(target.getDisplayName(), true);
    vPhaseReport.addElement(r);
    if (toHit.getValue() == TargetRoll.IMPOSSIBLE) {
      r = new Report(3135);
      r.subject = subjectId;
      r.add(toHit.getDesc());
      vPhaseReport.addElement(r);
      return false;
    } else if (toHit.getValue() == TargetRoll.AUTOMATIC_FAIL) {
      r = new Report(3140);
      r.newlines = 0;
      r.subject = subjectId;
      r.add(toHit.getDesc());
      vPhaseReport.addElement(r);
    } else if (toHit.getValue() == TargetRoll.AUTOMATIC_SUCCESS) {
      r = new Report(3145);
      r.newlines = 0;
      r.subject = subjectId;
      r.add(toHit.getDesc());
      vPhaseReport.addElement(r);
    }

    addHeat();

    // deliver screen
    Coords coords = target.getPosition();
    server.deliverScreen(coords, vPhaseReport);

    // damage any entities in the hex
    for (Entity entity : game.getEntitiesVector(coords)) {
      // if fighter squadron all fighters are damaged
      if (entity instanceof FighterSquadron) {
        for (Entity fighter : ((FighterSquadron) entity).getFighters()) {
          ToHitData squadronToHit = new ToHitData();
          squadronToHit.setHitTable(ToHitData.HIT_NORMAL);
          HitData hit = fighter.rollHitLocation(squadronToHit.getHitTable(), ToHitData.SIDE_FRONT);
          hit.setCapital(false);
          vPhaseReport.addAll(server.damageEntity(fighter, hit, attackValue));
          server.creditKill(fighter, ae);
        }
      } else {
        ToHitData hexToHit = new ToHitData();
        hexToHit.setHitTable(ToHitData.HIT_NORMAL);
        HitData hit = entity.rollHitLocation(hexToHit.getHitTable(), ToHitData.SIDE_FRONT);
        hit.setCapital(false);
        vPhaseReport.addAll(server.damageEntity(entity, hit, attackValue));
        server.creditKill(entity, ae);
      }
    }
    return false;
  }