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

[Fg3] Refactored Difficulty Multiplier Application #5145

Merged
merged 1 commit into from
Oct 29, 2024
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
26 changes: 11 additions & 15 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ private static int generateForces(AtBDynamicScenario scenario, AtBContract contr
// how close to the allowances do we want to get?
int targetPercentage = 100 + ((Compute.randomInt(8) - 3) * 5);
logger.info(String.format("Target Percentage: %s", targetPercentage));
logger.info(String.format("Difficulty Multiplier: %s", getDifficultyMultiplier(campaign)));

for (int generationOrder : generationOrders) {
List<ScenarioForceTemplate> currentForceTemplates = orderedForceTemplates.get(generationOrder);
Expand All @@ -283,10 +284,8 @@ private static int generateForces(AtBDynamicScenario scenario, AtBContract contr
generatedLanceCount += generateFixedForce(scenario, contract, campaign, forceTemplate);
} else {
int weightClass = randomForceWeight();
logger.info(String.format("++ Generating a force for the %s template ++", forceTemplate.getForceName()).toUpperCase());

if (forceTemplate.isPlayerForce()) {
logger.info(String.format("++ Generating a force for the %s template ++", forceTemplate.getForceName()).toUpperCase());
}
generatedLanceCount += generateForce(scenario, contract, campaign,
effectiveBV, effectiveUnitCount, weightClass, forceTemplate, false);
}
Expand Down Expand Up @@ -390,11 +389,15 @@ public static int generateForce(AtBDynamicScenario scenario, AtBContract contrac
break;
case Opposing:
factionCode = contract.getEnemyCode();

// We only want the difficulty multipliers applying to enemy forces
double difficultyMultiplier = getDifficultyMultiplier(campaign);
effectiveBV = (int) round(effectiveBV * difficultyMultiplier);
effectiveUnitCount = (int) round(effectiveUnitCount * difficultyMultiplier);

// Intentional fall-through: opposing third parties are either the contracted
// enemy or
// "Unidentified Hostiles" which are considered pirates or bandit caste with
// random
// quality and skill
// enemy or "Unidentified Hostiles" which are considered pirates or bandit caste
// with random quality and skill
case Third:
skill = scenario.getEffectiveOpforSkill();
quality = scenario.getEffectiveOpforQuality();
Expand Down Expand Up @@ -2689,7 +2692,6 @@ public static int calculateEffectiveBV(AtBDynamicScenario scenario, Campaign cam
// for each deployed player and bot force that's marked as contributing to the
// BV budget
int bvBudget = 0;
double difficultyMultiplier = getDifficultyMultiplier(campaign);

String generationMethod = campaign.getCampaignOptions().isUseGenericBattleValue() ?
"Generic BV" : "BV2";
Expand Down Expand Up @@ -2720,9 +2722,7 @@ public static int calculateEffectiveBV(AtBDynamicScenario scenario, Campaign cam
double bvMultiplier = scenario.getEffectivePlayerBVMultiplier();

if (bvMultiplier > 0) {
bvBudget = (int) round(bvBudget * scenario.getEffectivePlayerBVMultiplier() * difficultyMultiplier);
} else {
bvBudget = (int) round(bvBudget * difficultyMultiplier);
bvBudget = (int) round(bvBudget * scenario.getEffectivePlayerBVMultiplier());
}

// allied bot forces that contribute to BV do not get multiplied by the
Expand Down Expand Up @@ -2756,7 +2756,6 @@ public static int calculateEffectiveUnitCount(AtBDynamicScenario scenario, Campa
// for each deployed player and bot force that's marked as contributing to the
// unit count budget
int unitCount = 0;
double difficultyMultiplier = getDifficultyMultiplier(campaign);

// deployed player forces:
for (int forceID : scenario.getForceIDs()) {
Expand All @@ -2776,9 +2775,6 @@ public static int calculateEffectiveUnitCount(AtBDynamicScenario scenario, Campa
}
}

// the player unit count is now multiplied by the difficulty multiplier
unitCount = (int) Math.floor((double) unitCount * difficultyMultiplier);

// allied bot forces that contribute to BV do not get multiplied by the
// difficulty even if the player is good, the AI doesn't get any better
for (int index = 0; index < scenario.getNumBots(); index++) {
Expand Down