/** 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); }
/** 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); }
/** 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); }