示例#1
0
  /** Checks for functional AES in both legs */
  @Override
  public boolean hasFunctionalLegAES() {
    boolean rightLeg = false;
    boolean leftLeg = false;

    for (Mounted mounted : getMisc()) {
      if ((mounted.getLocation() == Mech.LOC_LLEG) || (mounted.getLocation() == Mech.LOC_RLEG)) {
        if (((MiscType) mounted.getType()).hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)
            && !mounted.isDestroyed()
            && !mounted.isBreached()
            && !mounted.isMissing()) {
          if (mounted.getLocation() == Mech.LOC_LLEG) {
            leftLeg = true;
          } else {
            rightLeg = true;
          }
        } // AES is destroyed their for it cannot be used.
        else if (((MiscType) mounted.getType()).hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)) {
          return false;
        }
      }
    }

    return rightLeg && leftLeg;
  }
示例#2
0
  /**
   * Check to see how many shields of a certain size a mek has. you can have up to shields per mek.
   * However they can be of different size and each size has its own draw backs. So check each size
   * and add modifers based on the number shields of that size.
   */
  @Override
  public int getNumberOfShields(long size) {

    int raShield = 0;
    int laShield = 0;

    for (Mounted m : getMisc()) {
      EquipmentType type = m.getType();
      if ((type instanceof MiscType) && type.hasFlag(MiscType.F_CLUB) && (type.hasSubType(size))) {
        // ok so we have a shield of certain size. no which arm is it.
        if (m.getLocation() == Mech.LOC_RARM) {
          raShield = 1;
        }
        if (m.getLocation() == Mech.LOC_LARM) {
          laShield = 1;
        }
        // break now.
        if ((raShield > 0) && (laShield > 0)) {
          return 2;
        }
      }
    }
    return raShield + laShield;
  }
示例#3
0
  /** Checks is Biped Mek has functional AES in the location. Only works for Arms */
  @Override
  public boolean hasFunctionalArmAES(int location) {

    boolean hasAES = false;
    if ((location != Mech.LOC_RARM) && (location != Mech.LOC_LARM)) {
      return false;
    }

    for (Mounted mounted : getMisc()) {
      if ((mounted.getLocation() == location)
          && mounted.getType().hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)
          && !mounted.isDestroyed()
          && !mounted.isBreached()
          && !mounted.isMissing()) {
        hasAES = true;
      } // AES is destroyed their for it cannot be used.
      else if ((mounted.getLocation() == location)
          && mounted.getType().hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)) {
        return false;
      }
    }

    return hasAES;
  }
示例#4
0
 /**
  * Does the mech have any shields. a mech can have up to 2 shields.
  *
  * @return <code>true</code> if unit has a shield crit.
  */
 @Override
 public boolean hasShield() {
   for (Mounted m : getMisc()) {
     boolean isShield = (m.getType() instanceof MiscType) && ((MiscType) m.getType()).isShield();
     if (((m.getLocation() == Mech.LOC_LARM) || (m.getLocation() == Mech.LOC_RARM))
         && isShield
         && !m.isInoperable()
         && (getInternal(m.getLocation()) > 0)) {
       for (int slot = 0; slot < this.getNumberOfCriticals(m.getLocation()); slot++) {
         CriticalSlot cs = getCritical(m.getLocation(), slot);
         if ((cs != null)
             && (cs.getType() == CriticalSlot.TYPE_EQUIPMENT)
             && cs.getMount().equals(m)
             && !cs.isDestroyed()
             && !cs.isMissing()) {
           // when all crits of a shield are destroyed, it
           // no longer hinders movement and stuff
           return true;
         }
       }
     }
   }
   return false;
 }
示例#5
0
 /** Does the entity have a retracted blade in the given location */
 @Override
 public boolean hasRetractedBlade(int loc) {
   for (Mounted m : getEquipment()) {
     if ((m.getLocation() == loc)
         && !m.isDestroyed()
         && !m.isBreached()
         && (m.getType() instanceof MiscType)
         && m.getType().hasFlag(MiscType.F_CLUB)
         && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)
         && !m.curMode().equals("extended")) {
       return true;
     }
   }
   return false;
 }
示例#6
0
  /** Does the mech have an shield in no defense mode */
  @Override
  public boolean hasNoDefenseShield(int location) {

    if ((location != Mech.LOC_RARM) && (location != Mech.LOC_LARM)) {
      return false;
    }

    for (int slot = 0; slot < this.getNumberOfCriticals(location); slot++) {
      CriticalSlot cs = getCritical(location, slot);

      if (cs == null) {
        continue;
      }

      if (cs.getType() != CriticalSlot.TYPE_EQUIPMENT) {
        continue;
      }

      if (cs.isDamaged()) {
        continue;
      }

      Mounted m = cs.getMount();
      EquipmentType type = m.getType();
      if ((type instanceof MiscType)
          && ((MiscType) type).isShield()
          && (m.curMode().equals(MiscType.S_NO_SHIELD)
              || isShutDown()
              || // if
              // he
              // has
              // a
              // shield
              // and
              // the mek is SD or pilot
              // KOed then it goes to no
              // defense mode
              getCrew().isKoThisRound()
              || getCrew().isUnconscious())) {
        return m.getCurrentDamageCapacity(this, m.getLocation()) > 0;
      }
    }
    return false;
  }
示例#7
0
  /**
   * Does the mech have a passive shield This should only be called by
   * hasPassiveShield(location,rear)
   */
  @Override
  public boolean hasPassiveShield(int location) {

    if (isShutDown() || (getCrew().isKoThisRound() || getCrew().isUnconscious())) {
      return false;
    }

    if ((location != Mech.LOC_RARM) && (location != Mech.LOC_LARM)) {
      return false;
    }

    for (int slot = 0; slot < this.getNumberOfCriticals(location); slot++) {
      CriticalSlot cs = getCritical(location, slot);

      if (cs == null) {
        continue;
      }

      if (cs.getType() != CriticalSlot.TYPE_EQUIPMENT) {
        continue;
      }

      if (cs.isDamaged()) {
        continue;
      }

      Mounted m = cs.getMount();
      EquipmentType type = m.getType();
      if ((type instanceof MiscType)
          && ((MiscType) type).isShield()
          && m.curMode().equals(MiscType.S_PASSIVE_SHIELD)) {
        return m.getCurrentDamageCapacity(this, m.getLocation()) > 0;
      }
    }
    return false;
  }
示例#8
0
  /** Returns the Compute.ARC that the weapon fires into. */
  @Override
  public int getWeaponArc(int wn) {
    final Mounted mounted = getEquipment(wn);

    // B-Pods need to be special-cased, the have 360 firing arc
    if ((mounted.getType() instanceof WeaponType)
        && mounted.getType().hasFlag(WeaponType.F_B_POD)) {
      return Compute.ARC_360;
    }
    // VGLs always be considered forward, since arc is set by VGL facing
    if (mounted.getType().hasFlag(WeaponType.F_VGL)) {
      return Compute.ARC_FORWARD;
    }
    switch (mounted.getLocation()) {
      case LOC_BODY:
        // Body mounted C3Ms fire into the front arc,
        // per
        // http://forums.classicbattletech.com/index.php/topic,9400.0.html
      case LOC_FRONT:
        if (mounted.isPintleTurretMounted()) {
          return Compute.ARC_PINTLE_TURRET_FRONT;
        }
        if (game.getOptions().booleanOption("tacops_vehicle_arcs")) {
          return Compute.ARC_NOSE;
        }
      case LOC_TURRET:
        if (game.getOptions().booleanOption("tacops_vehicle_arcs")) {
          return Compute.ARC_TURRET;
        }
        return Compute.ARC_FORWARD;
      case LOC_FRONTRIGHT:
      case LOC_REARRIGHT:
        if (mounted.isSponsonTurretMounted()) {
          return Compute.ARC_SPONSON_TURRET_RIGHT;
        }
        if (mounted.isPintleTurretMounted()) {
          return Compute.ARC_PINTLE_TURRET_RIGHT;
        }
        if (game.getOptions().booleanOption("tacops_vehicle_arcs")) {
          return Compute.ARC_RIGHT_BROADSIDE;
        }
        return Compute.ARC_RIGHTSIDE;
      case LOC_FRONTLEFT:
      case LOC_REARLEFT:
        if (mounted.isSponsonTurretMounted()) {
          return Compute.ARC_SPONSON_TURRET_LEFT;
        }
        if (mounted.isPintleTurretMounted()) {
          return Compute.ARC_PINTLE_TURRET_LEFT;
        }
        if (game.getOptions().booleanOption("tacops_vehicle_arcs")) {
          return Compute.ARC_LEFT_BROADSIDE;
        }
        return Compute.ARC_LEFTSIDE;
      case LOC_REAR:
        if (mounted.isPintleTurretMounted()) {
          return Compute.ARC_PINTLE_TURRET_REAR;
        }
        if (game.getOptions().booleanOption("tacops_vehicle_arcs")) {
          return Compute.ARC_AFT;
        }
        return Compute.ARC_REAR;
      default:
        return Compute.ARC_360;
    }
  }