Esempio n. 1
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);
   }
 }
Esempio n. 2
0
  @Override
  protected void handleClearDamage(Vector<Report> vPhaseReport, Building bldg, int nDamage) {
    if (!bSalvo) {
      // hits!
      Report r = new Report(2270);
      r.subject = subjectId;
      vPhaseReport.addElement(r);
    }

    nDamage *= 2; // Plasma weapons deal double damage to woods.

    // report that damage was "applied" to terrain
    Report r = new Report(3385);
    r.indent(2);
    r.subject = subjectId;
    r.add(nDamage);
    vPhaseReport.addElement(r);

    // Any clear attempt can result in accidental ignition, even
    // weapons that can't normally start fires. that's weird.
    // Buildings can't be accidentally ignited.
    // TODO: change this for TacOps - now you roll another 2d6 first and on
    // a 5 or less
    // you do a normal ignition as though for intentional fires
    if ((bldg != null)
        && server.tryIgniteHex(
            target.getPosition(),
            subjectId,
            true,
            false,
            new TargetRoll(wtype.getFireTN(), wtype.getName()),
            5,
            vPhaseReport)) {
      return;
    }
    Vector<Report> clearReports = server.tryClearHex(target.getPosition(), nDamage, subjectId);
    if (clearReports.size() > 0) {
      vPhaseReport.lastElement().newlines = 0;
    }
    vPhaseReport.addAll(clearReports);
    return;
  }
Esempio n. 3
0
  /**
   * 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;
  }