Exemple #1
0
  /** Damage that a mech does with a successful DFA. */
  public static int getDamageFor(Entity entity, boolean targetInfantry) {
    int toReturn = (int) Math.ceil((entity.getWeight() / 10.0) * 3.0);

    if (DfaAttackAction.hasTalons(entity)) {
      toReturn *= 1.5;
    }

    if (targetInfantry) {
      toReturn = Math.max(1, toReturn / 10);
    }
    return toReturn;
  }
Exemple #2
0
  /** Checks if a death from above attack can hit the target, including movement */
  public static ToHitData toHit(IGame game, int attackerId, Targetable target, MovePath md) {
    final Entity ae = game.getEntity(attackerId);

    // Do to pretreatment of physical attacks, the target may be null.
    if (target == null) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is null");
    }

    Entity te = null;
    if (target.getTargetType() == Targetable.TYPE_ENTITY) {
      te = (Entity) target;
    }
    Coords chargeSrc = ae.getPosition();
    MoveStep chargeStep = null;

    // Infantry CAN'T dfa!!!
    if (ae instanceof Infantry) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Infantry can't D.F.A.");
    }

    if (ae.getJumpType() == Mech.JUMP_BOOSTER) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Can't D.F.A. using mechanical jump boosters.");
    }

    // let's just check this
    if (!md.contains(MoveStepType.DFA)) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "D.F.A. action not found in movement path");
    }

    // have to jump
    if (!md.contains(MoveStepType.START_JUMP)) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "D.F.A. must involve jumping");
    }

    // can't target airborne units
    if ((te != null) && te.isAirborne()) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Cannot D.F.A. an airborne target.");
    }

    // can't target dropships
    if ((te != null) && (te instanceof Dropship)) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Cannot D.F.A. a dropship.");
    }

    // Can't target a transported entity.
    if ((te != null) && (Entity.NONE != te.getTransportId())) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is a passenger.");
    }

    // no evading
    if (md.contains(MoveStepType.EVADE)) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "No evading while charging");
    }

    // Can't target a entity conducting a swarm attack.
    if ((te != null) && (Entity.NONE != te.getSwarmTargetId())) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is swarming a Mek.");
    }

    // determine last valid step
    md.compile(game, ae);
    for (final Enumeration<MoveStep> i = md.getSteps(); i.hasMoreElements(); ) {
      final MoveStep step = i.nextElement();
      if (!step.isLegal()) {
        break;
      }
      if (step.getType() == MoveStepType.DFA) {
        chargeStep = step;
      } else {
        chargeSrc = step.getPosition();
      }
    }

    // need to reach target
    if ((chargeStep == null) || !target.getPosition().equals(chargeStep.getPosition())) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Could not reach target with movement");
    }

    // target must have moved already, unless it's immobile
    if ((te != null) && (!te.isDone() && !te.isImmobile())) {
      return new ToHitData(TargetRoll.IMPOSSIBLE, "Target must be done with movement");
    }

    return DfaAttackAction.toHit(game, attackerId, target, chargeSrc);
  }
Exemple #3
0
 public ToHitData toHit(IGame game) {
   final Entity entity = game.getEntity(getEntityId());
   return DfaAttackAction.toHit(
       game, getEntityId(), game.getTarget(getTargetType(), getTargetId()), entity.getPosition());
 }