Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use current Manei Domini BV calculation rules from IO #4536

Merged
merged 2 commits into from
Jun 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1124,7 +1124,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 @@ -1136,14 +1137,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 @@ -1171,7 +1173,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 @@ -1186,7 +1188,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 @@ -1201,27 +1249,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