Skip to content

Commit

Permalink
Merge pull request #4536 from SJuliez/BV_MD
Browse files Browse the repository at this point in the history
Use current Manei Domini BV calculation rules from IO
  • Loading branch information
SJuliez authored Jun 18, 2023
2 parents 542a6d6 + 16d1f1d commit d00f923
Showing 1 changed file with 54 additions and 27 deletions.
81 changes: 54 additions & 27 deletions megamek/src/megamek/common/battlevalue/BVCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,8 @@ protected double getAmmoBV(Mounted ammo) {
protected void adjustBV() {
adjustedBV = (int) Math.round(baseBV);
double c3Bonus = ignoreC3 ? 0 : entity.getExtraC3BV((int) Math.round(adjustedBV));
double pilotFactor = ignoreSkill ? 1 : BVCalculator.bvMultiplier(entity);
List<String> pilotModifiers = new ArrayList<>();
double pilotFactor = ignoreSkill ? 1 : BVCalculator.bvMultiplier(entity, pilotModifiers);

processTagBonus();

Expand All @@ -1137,14 +1138,15 @@ protected void adjustBV() {

processExternalStores();

if (pilotFactor != 1) {
if ((pilotFactor != 1) || !pilotModifiers.isEmpty()) {
bvReport.addLine("Pilot Modifier:",
formatForReport(adjustedBV) + " x " + formatForReport(pilotFactor),
formatForReport(adjustedBV) + " x " + formatForReport(pilotFactor)
+ (pilotModifiers.isEmpty() ? "" : " (" + String.join(", ", pilotModifiers) + ")"),
"= " + formatForReport(adjustedBV * pilotFactor));
adjustedBV *= pilotFactor;
}

if (adjustedBV != (int) Math.round(baseBV)) {
if ((adjustedBV != (int) Math.round(baseBV)) || !pilotModifiers.isEmpty()) {
bvReport.addLine("--- Adjusted BV:", formatForReport(adjustedBV) + ", rn",
"= " + (int) Math.round(adjustedBV));
}
Expand Down Expand Up @@ -1172,7 +1174,7 @@ protected void adjustBV() {
* @param entity The entity to get the skill modifier for
* @return The BV multiplier for the given entity's pilot
*/
public static double bvMultiplier(Entity entity) {
public static double bvMultiplier(Entity entity, List<String> pilotModifiers) {
if (entity.getCrew() == null) {
return 1;
}
Expand All @@ -1187,7 +1189,53 @@ public static double bvMultiplier(Entity entity) {
gunnery = (lamPilot.getGunneryMech() + lamPilot.getGunneryAero()) / 2;
piloting = (lamPilot.getPilotingMech() + lamPilot.getPilotingAero()) / 2;
}
return bvImplantMultiplier(entity) * bvSkillMultiplier(gunnery, piloting);
double skillMultiplier = bvSkillMultiplier(gunnery, piloting);
if (skillMultiplier != 1) {
pilotModifiers.add("Skill");
}

if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_PAIN_SHUNT)) {
piloting = Math.max(0, piloting - 1);
pilotModifiers.add("Pain Shunt");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_COMM_IMPLANT)) {
piloting = Math.max(0, piloting - 1);
pilotModifiers.add("Comm. Implant");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_VDNI)
&& entity.hasMisc(MiscType.F_BATTLEMECH_NIU)) {
piloting = Math.max(0, piloting - 1);
gunnery = Math.max(0, gunnery - 1);
pilotModifiers.add("VDNI");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_BVDNI)
&& entity.hasMisc(MiscType.F_BATTLEMECH_NIU)) {
gunnery = Math.max(0, gunnery - 1);
pilotModifiers.add("Buf. VDNI");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_MM_IMPLANTS)
|| entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_ENH_MM_IMPLANTS)
|| entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_CYBER_IMP_LASER)
|| entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_CYBER_IMP_AUDIO)
|| entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_CYBER_IMP_VISUAL)) {
gunnery = Math.max(0, gunnery - 1);
pilotModifiers.add("Sensory Implants");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_PROTO_DNI)
&& entity.hasMisc(MiscType.F_BATTLEMECH_NIU)) {
piloting = Math.max(0, piloting - 3);
gunnery = Math.max(0, gunnery - 2);
pilotModifiers.add("Proto DNI");
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_TRIPLE_CORE_PROCESSOR)) {
if (entity.isMek() || entity.isCombatVehicle() || entity.isAerospaceFighter()) {
gunnery = Math.max(0, gunnery - 1);
} else {
piloting = Math.max(0, piloting - 1);
}
pilotModifiers.add("TCP");
}
return bvSkillMultiplier(gunnery, piloting);
}

/**
Expand All @@ -1202,27 +1250,6 @@ public static double bvSkillMultiplier(int gunnery, int piloting) {
return bvMultipliers[MathUtility.clamp(gunnery, 0, 8)][MathUtility.clamp(piloting, 0, 8)];
}

/**
* Returns the BV multiplier for any MD implants that the crew of the given entity has. When the crew
* doesn't have any relevant MD implants, returns 1.
*
* @param entity The entity to get the skill modifier for
* @return a multiplier to the BV of the given entity
*/
public static double bvImplantMultiplier(Entity entity) {
int level = 1;
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_PAIN_SHUNT)) {
level = 2;
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_VDNI)) {
level = 3;
}
if (entity.getCrew().getOptions().booleanOption(OptionsConstants.MD_BVDNI)) {
level = 5;
}
return level / 4.0 + 0.75;
}

/**
* Processes the BV bonus that a unit with TAG, LTAG or C3M gets for friendly units that have semi-guided
* or Arrow IV homing ammunition
Expand Down

0 comments on commit d00f923

Please sign in to comment.