Skip to content

Commit

Permalink
Merge pull request #5145 from IllianiCBT/fg3_balancing
Browse files Browse the repository at this point in the history
[Fg3] Refactored Difficulty Multiplier Application
  • Loading branch information
HammerGS authored Oct 29, 2024
2 parents 3095a14 + cbff0b0 commit b561291
Showing 1 changed file with 11 additions and 15 deletions.
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

0 comments on commit b561291

Please sign in to comment.