Beispiel #1
0
  /** Returns the target movement modifier for attacks. */
  public static int getMovementModifier(MechRemote mech) {
    int modifier = 0;
    int displacement = 0;

    try {
      if (mech.getMovementMode() == 3) {
        modifier = modifier + 1;
      } // Target jumping modifier
      displacement =
          (int) getDistance(mech.getLocation(), mech.getLastLocation())
              / mech.getMap().getMapGridSize();
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    if (displacement >= 10) {
      modifier = modifier + 4;
    } // Target displacement modifier
    else if (displacement >= 7) {
      modifier = modifier + 3;
    } else if (displacement >= 5) {
      modifier = modifier + 2;
    } else if (displacement >= 3) {
      modifier = modifier + 1;
    }

    return (modifier);
  }
Beispiel #2
0
  /** Processes a Piloting Skill check. Returns true if check succeeds, false otherwise. */
  public static boolean rollPiloting(int modifier, MechRemote mech) {
    try {
      if (mech.isShutdown()
          || mech.getMW()
              .isUnconscious()) // If mech is shutdown or mechwarrior is unconscious, we fail and
                                // fall automatically
      {
        mech.fall();
        return false;
      }

      boolean pilotingCheck = checkPiloting(modifier, mech);

      if (pilotingCheck == false) // See if pilot can avoid fall
      {
        mech.fall();
        return false;
      }

      mech.getOwner().addOutput("Mech avoided fall!");
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return true;
  }
Beispiel #3
0
  /** Returns the difficulty for physical attacks. */
  public static int getPhysicalAttackDifficulty(MechRemote shooter, MechRemote target, int base) {
    int difficulty = base;

    try {
      Map map = shooter.getMap();

      difficulty = difficulty + shooter.getMovementMode(); // Shooter movement modifiers

      difficulty = difficulty + getMovementModifier(target); // Target movement modifier

      difficulty = difficulty + map.getTerrainModifier(shooter, target); // Terrain modifiers

      if (target.isProne()) {
        difficulty = difficulty - 2;
      } // Prone target modifier

      if (target.isShutdown() || target.getMW().isUnconscious()) // Immobile target modifier
      {
        difficulty = difficulty - 4;
      }
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return (difficulty);
  }
Beispiel #4
0
  /** Returns difficulty of a Piloting Skill check. */
  public static int getPilotingDifficulty(int modifier, MechRemote mech) {
    int difficulty = modifier;

    try {
      int pilotSkill = mech.getMW().getPiloting();
      int legModifier = (2 - mech.getBodyParts().legs()) * 5;
      int gyroModifier = mech.getComponents().getGyroHits() * 3;
      difficulty = difficulty + pilotSkill + legModifier + gyroModifier;
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return (difficulty);
  }
Beispiel #5
0
  /** Returns the difficulty for weapon attacks. */
  public static int getGunneryDifficulty(MechRemote shooter, MechRemote target, Weapon weapon) {
    int difficulty = 0;

    try {
      Map map = shooter.getMap();

      double distance = getDistance(shooter.getLocation(), target.getLocation());

      difficulty = difficulty + shooter.getMW().getGunnery(); // MechWarrior's Gunnery skill

      difficulty = difficulty + shooter.getAttackModifier(); // Shooter attack modifiers

      difficulty =
          difficulty + getRangeModifier(distance, weapon, map.getMapGridSize()); // Range modifiers

      difficulty = difficulty + map.getTerrainModifier(shooter, target); // Terrain modifiers

      if (target.isProne()) // Prone target modifier
      {
        if (distance <= map.getMapGridSize()) {
          difficulty = difficulty - 2;
        } else {
          difficulty = difficulty + 1;
        }
      }

      if (target.isShutdown() || target.getMW().isUnconscious()) // Immobile target modifier
      {
        difficulty = difficulty - 4;
      }

      difficulty = difficulty + getMovementModifier(target); // Target movement modifier
    } catch (java.rmi.RemoteException e) {
      System.out.println("Rules RemoteException!");
    }

    return (difficulty);
  }