Skip to content

Commit

Permalink
Merge pull request #2788 from NickAragua/facility_implementation
Browse files Browse the repository at this point in the history
Facility implementation
  • Loading branch information
Windchild292 authored Aug 15, 2021
2 parents f6e24e2 + a4e9daf commit 715d834
Show file tree
Hide file tree
Showing 23 changed files with 318 additions and 65 deletions.
7 changes: 7 additions & 0 deletions MekHQ/data/scenariomodifiers/HostileBVBudgetIncrease.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<AtBScenarioModifier>
<additionalBriefingText>Local coordination has allowed the opposition to deploy a larger force to respond to your presence.</additionalBriefingText>
<benefitsPlayer>false</benefitsPlayer>
<eventTiming>PreForceGeneration</eventTiming>
<eventRecipient>Opposing</eventRecipient>
<bvBudgetAdditiveMultiplier>-1</bvBudgetAdditiveMultiplier>
</AtBScenarioModifier>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<AtBScenarioModifier>
<additionalBriefingText>Improved coordination allows friendly reinforcements to deploy quicker.</additionalBriefingText>
<benefitsPlayer>true</benefitsPlayer>
<eventTiming>PreForceGeneration</eventTiming>
<eventRecipient>Allied</eventRecipient>
<reinforcementDelayReduction>1</reinforcementDelayReduction>
</AtBScenarioModifier>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<AtBScenarioModifier>
<additionalBriefingText>Improved coordination allows hostile reinforcements to deploy quicker.</additionalBriefingText>
<benefitsPlayer>false</benefitsPlayer>
<eventTiming>PreForceGeneration</eventTiming>
<eventRecipient>Opposing</eventRecipient>
<reinforcementDelayReduction>1</reinforcementDelayReduction>
</AtBScenarioModifier>
3 changes: 3 additions & 0 deletions MekHQ/data/scenariomodifiers/groundBattleModifiers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<modifier>
GoodEquipment.xml
</modifier>
<modifier>
HostileBVBudgetIncrease.xml
</modifier>
<!--modifier>
Need ability to allow player to specifically deploy dropships
HotDrop.xml
Expand Down
9 changes: 9 additions & 0 deletions MekHQ/data/scenariomodifiers/modifiermanifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<modifier>
GoodEquipment.xml
</modifier>
<modifier>
HostileBVBudgetIncrease.xml
</modifier>
<modifier>
BadEvent.xml
</modifier>
Expand Down Expand Up @@ -86,6 +89,12 @@
<modifier>
PiratesPresentGround.xml
</modifier>
<modifier>
ReinforcementDelayReductionHostile.xml
</modifier>
<modifier>
ReinforcementDelayReductionAllied.xml
</modifier>
<!--modifier>
Need "special duel flag".
Duel.xml
Expand Down
1 change: 1 addition & 0 deletions MekHQ/data/stratconfacilities/AlliedDataCenter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<displayableName>Data Center</displayableName>
<facilityType>DataCenter</facilityType>
<owner>Allied</owner>
<revealTrack>true</revealTrack>
<visible>true</visible>
</StratconFacility>
2 changes: 2 additions & 0 deletions MekHQ/data/stratconfacilities/AlliedEarlyWarningSystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
<displayableName>Early Warning Center</displayableName>
<facilityType>EarlyWarningSystem</facilityType>
<owner>Allied</owner>
<localModifiers>ReinforcementDelayReductionAllied.xml</localModifiers>
<sharedModifiers>ReinforcementDelayReductionAllied.xml</sharedModifiers>
<visible>true</visible>
</StratconFacility>
1 change: 1 addition & 0 deletions MekHQ/data/stratconfacilities/AlliedOrbitalDefense.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<displayableName>Orbital Defense</displayableName>
<facilityType>OrbitalDefense</facilityType>
<owner>Allied</owner>
<preventAerospace>true</preventAerospace>
<visible>true</visible>
</StratconFacility>
1 change: 1 addition & 0 deletions MekHQ/data/stratconfacilities/AlliedSupplyDepot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<displayableName>Supply Depot</displayableName>
<facilityType>SupplyDepot</facilityType>
<owner>Allied</owner>
<weeklySPModifier>1</weeklySPModifier>
<visible>true</visible>
</StratconFacility>
1 change: 1 addition & 0 deletions MekHQ/data/stratconfacilities/HostileDataCenter.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<StratconFacility>
<scenarioOddsModifier>5</scenarioOddsModifier>
<capturedDefinition>AlliedDataCenter.xml</capturedDefinition>
<displayableName>Data Center</displayableName>
<facilityType>DataCenter</facilityType>
Expand Down
4 changes: 3 additions & 1 deletion MekHQ/data/stratconfacilities/HostileEarlyWarningSystem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<capturedDefinition>AlliedEarlyWarningSystem.xml</capturedDefinition>
<displayableName>Early Warning Center</displayableName>
<facilityType>EarlyWarningSystem</facilityType>
<owner>Allied</owner>
<owner>Opposing</owner>
<localModifiers>ReinforcementDelayReductionHostile.xml</localModifiers>
<sharedModifiers>ReinforcementDelayReductionHostile.xml</sharedModifiers>
<visible>true</visible>
</StratconFacility>
1 change: 1 addition & 0 deletions MekHQ/data/stratconfacilities/HostileOrbitalDefense.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<displayableName>Orbital Defense</displayableName>
<facilityType>OrbitalDefense</facilityType>
<owner>Opposing</owner>
<preventAerospace>true</preventAerospace>
<visible>false</visible>
</StratconFacility>
3 changes: 3 additions & 0 deletions MekHQ/data/stratconfacilities/HostileSupplyDepot.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<StratconFacility>
<bvBudgetModifier>0.05</bvBudgetModifier>
<capturedDefinition>AlliedSupplyDepot.xml</capturedDefinition>
<displayableName>Supply Depot</displayableName>
<localModifiers>HostileBVBudgetIncrease.xml</localModifiers>
<sharedModifiers>HostileBVBudgetIncrease.xml</sharedModifiers>
<facilityType>SupplyDepot</facilityType>
<owner>Opposing</owner>
<visible>false</visible>
Expand Down
41 changes: 30 additions & 11 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public static class BenchedEntityData {
private static final String PLAYER_UNIT_SWAP_TEMPLATE_ELEMENT = "Template";
private static final String PLAYER_UNIT_SWAP_ENTITY_ELEMENT = "entity";

// derived fields used for various calculations
private int effectivePlayerUnitCount;
private int effectivePlayerBV;
private double effectivePlayerUnitCountMultiplier;
private double effectivePlayerBVMultiplier;

private int friendlyReinforcementDelayReduction;
private int hostileReinforcementDelayReduction;

// derived fields used for various calculations
private int effectiveOpforSkill;
private int effectiveOpforQuality;

Expand Down Expand Up @@ -230,20 +233,20 @@ public void removeBotForce(int x) {
super.removeBotForce(x);
}

public int getEffectivePlayerUnitCount() {
return effectivePlayerUnitCount;
public double getEffectivePlayerUnitCountMultiplier() {
return effectivePlayerUnitCountMultiplier;
}

public void setEffectivePlayerUnitCount(int unitCount) {
effectivePlayerUnitCount = unitCount;
public void setEffectivePlayerUnitCountMultiplier(double multiplier) {
effectivePlayerUnitCountMultiplier = multiplier;
}

public int getEffectivePlayerBV() {
return effectivePlayerBV;
public double getEffectivePlayerBVMultiplier() {
return effectivePlayerBVMultiplier;
}

public void setEffectivePlayerBV(int unitCount) {
effectivePlayerBV = unitCount;
public void setEffectivePlayerBVMultiplier(double multiplier) {
effectivePlayerBVMultiplier = multiplier;
}

public void setScenarioTemplate(ScenarioTemplate template) {
Expand Down Expand Up @@ -294,6 +297,22 @@ public void setEffectiveOpforQuality(int qualityLevel) {
effectiveOpforQuality = qualityLevel;
}

public int getFriendlyReinforcementDelayReduction() {
return friendlyReinforcementDelayReduction;
}

public void setFriendlyReinforcementDelayReduction(int friendlyReinforcementDelayReduction) {
this.friendlyReinforcementDelayReduction = friendlyReinforcementDelayReduction;
}

public int getHostileReinforcementDelayReduction() {
return hostileReinforcementDelayReduction;
}

public void setHostileReinforcementDelayReduction(int hostileReinforcementDelayReduction) {
this.hostileReinforcementDelayReduction = hostileReinforcementDelayReduction;
}

/**
* This is used to indicate that player forces have been assigned to this scenario
* and that AtBDynamicScenarioFactory.finalizeScenario() has been called on this scenario to
Expand Down
27 changes: 18 additions & 9 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,9 @@ public static int calculateEffectiveBV(AtBDynamicScenario scenario, Campaign cam
bvBudget += forceBVBudget;
}
}

bvBudget += bvBudget * scenario.getEffectivePlayerBVMultiplier();


// allied bot forces that contribute to BV do not get multiplied by the difficulty
// even if the player is super good, the AI doesn't get any better
Expand Down Expand Up @@ -1934,29 +1937,35 @@ private static void setDeploymentTurns(AtBDynamicScenario scenario) {
for (int x = 0; x < scenario.getNumBots(); x++) {
BotForce currentBotForce = scenario.getBotForce(x);
ScenarioForceTemplate forceTemplate = scenario.getBotForceTemplates().get(currentBotForce);
setDeploymentTurns(currentBotForce, forceTemplate.getArrivalTurn(), scenario);
setDeploymentTurns(currentBotForce, forceTemplate, scenario);
}
}

/**
* Sets up deployment turns for all bot units within the specified bot force according to the specified force template's rules.
* @param botForce The bot force to process
* @param deployRound The specific deployment round, or a special constant.
* Also makes use of the given scenarios reinforcement delay modifier.
*
* ARRIVAL_TURN_STAGGERED_BY_LANCE is not implemented.
* ARRIVAL_TURN_STAGGERED is processed just prior to scenario start instead (?)
*/
public static void setDeploymentTurns(BotForce botForce, int deployRound,
public static void setDeploymentTurns(BotForce botForce, ScenarioForceTemplate forceTemplate,
AtBDynamicScenario scenario) {
// deployment turns don't matter for transported entities
List<Entity> untransportedEntities = scenario.filterUntransportedUnits(botForce.getEntityList());

if (deployRound == ScenarioForceTemplate.ARRIVAL_TURN_STAGGERED_BY_LANCE) {
if (forceTemplate.getArrivalTurn() == ScenarioForceTemplate.ARRIVAL_TURN_STAGGERED_BY_LANCE) {
setDeploymentTurnsStaggeredByLance(untransportedEntities);
} else if (deployRound == ScenarioForceTemplate.ARRIVAL_TURN_AS_REINFORCEMENTS) {
setDeploymentTurnsForReinforcements(untransportedEntities, 0);
} else if (forceTemplate.getArrivalTurn() == ScenarioForceTemplate.ARRIVAL_TURN_AS_REINFORCEMENTS) {
if (forceTemplate.getForceAlignment() == ForceAlignment.Opposing.ordinal()) {
setDeploymentTurnsForReinforcements(untransportedEntities, scenario.getHostileReinforcementDelayReduction());
} else if (forceTemplate.getForceAlignment() != ForceAlignment.Third.ordinal()) {
setDeploymentTurnsForReinforcements(untransportedEntities, scenario.getFriendlyReinforcementDelayReduction());
} else {
setDeploymentTurnsForReinforcements(untransportedEntities, 0);
}
} else {
for (Entity entity : untransportedEntities) {
entity.setDeployRound(deployRound);
entity.setDeployRound(forceTemplate.getArrivalTurn());
}
}
}
Expand Down Expand Up @@ -1997,7 +2006,7 @@ public static void setPlayerDeploymentTurns(AtBDynamicScenario scenario, Campaig
if (deployRound == ScenarioForceTemplate.ARRIVAL_TURN_STAGGERED_BY_LANCE) {
setDeploymentTurnsStaggeredByLance(forceEntities);
} else if (deployRound == ScenarioForceTemplate.ARRIVAL_TURN_AS_REINFORCEMENTS) {
setDeploymentTurnsForReinforcements(forceEntities, strategy);
setDeploymentTurnsForReinforcements(forceEntities, strategy + scenario.getFriendlyReinforcementDelayReduction());
} else {
for (Entity entity : forceEntities) {
entity.setDeployRound(deployRound);
Expand Down
32 changes: 31 additions & 1 deletion MekHQ/src/mekhq/campaign/mission/atb/AtBScenarioModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public enum EventTiming {
private Boolean useAmbushLogic = null;
private Boolean switchSides = null;
private Integer numExtraEvents = null;
private Double bvBudgetAdditiveMultiplier = null;
private Integer reinforcementDelayReduction = null;
private List<ScenarioObjective> objectives = new ArrayList<>();

private Map<String, String> linkedModifiers = new HashMap<>();
Expand Down Expand Up @@ -392,7 +394,17 @@ public void processModifier(AtBDynamicScenario scenario, Campaign campaign, Even
}

if ((getNumExtraEvents() != null) && (getNumExtraEvents() > 0)) {
AtBScenarioModifierApplicator.applyExtraEvent(scenario, getEventRecipient() == ForceAlignment.Allied);
for (int x = 0; x < getNumExtraEvents(); x++) {
AtBScenarioModifierApplicator.applyExtraEvent(scenario, getEventRecipient() == ForceAlignment.Allied);
}
}

if (getBVBudgetAdditiveMultiplier() != null) {
scenario.setEffectivePlayerBVMultiplier(getBVBudgetAdditiveMultiplier());
}

if ((getReinforcementDelayReduction() != null) && (getEventRecipient() != null)) {
AtBScenarioModifierApplicator.applyReinforcementDelayReduction(scenario, eventRecipient, getReinforcementDelayReduction());
}
}
}
Expand Down Expand Up @@ -422,6 +434,8 @@ public AtBScenarioModifier clone() {
copy.useAmbushLogic = useAmbushLogic;
copy.linkedModifiers = linkedModifiers == null ? new HashMap<>() : new HashMap<>(linkedModifiers);
copy.objectives = objectives == null ? new ArrayList<>() : new ArrayList<>(objectives);
copy.bvBudgetAdditiveMultiplier = bvBudgetAdditiveMultiplier;
copy .reinforcementDelayReduction = reinforcementDelayReduction;
return copy;
}

Expand Down Expand Up @@ -561,6 +575,22 @@ public void setNumExtraEvents(Integer numExtraEvents) {
this.numExtraEvents = numExtraEvents;
}

public Double getBVBudgetAdditiveMultiplier() {
return bvBudgetAdditiveMultiplier;
}

public void setBVBudgetAdditiveMultiplier(Double bvBudgetAdditiveMultiplier) {
this.bvBudgetAdditiveMultiplier = bvBudgetAdditiveMultiplier;
}

public Integer getReinforcementDelayReduction() {
return reinforcementDelayReduction;
}

public void setReinforcementDelayReduction(Integer reinforcementDelayReduction) {
this.reinforcementDelayReduction = reinforcementDelayReduction;
}

/**
* Map containing string tuples:
* "Alternate" briefing description, name of file containing other modifiers associated with this one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static void postAddForce(Campaign campaign, AtBDynamicScenario scenario,
// the most recently added bot force is the one we just generated
BotForce generatedBotForce = scenario.getBotForce(scenario.getNumBots() - 1);
generatedBotForce.setStart(deploymentZone);
AtBDynamicScenarioFactory.setDeploymentTurns(generatedBotForce, templateToApply.getArrivalTurn(), scenario);
AtBDynamicScenarioFactory.setDeploymentTurns(generatedBotForce, templateToApply, scenario);
AtBDynamicScenarioFactory.setDestinationZone(generatedBotForce, templateToApply);

// at this point, we have to re-translate the scenario objectives
Expand Down Expand Up @@ -354,4 +354,15 @@ public static void applyExtraEvent(AtBDynamicScenario scenario, boolean goodEven
scenario.addScenarioModifier(AtBScenarioModifier.getRandomBattleModifier(scenario.getTemplate().mapParameters.getMapLocation(),
(Boolean) goodEvent));
}

/**
* Applies a flat reduction to the reinforcement arrival times, either of player/allied forces or hostile forces.
*/
public static void applyReinforcementDelayReduction(AtBDynamicScenario scenario, ForceAlignment recipient, int value) {
if (recipient == ForceAlignment.Allied) {
scenario.setFriendlyReinforcementDelayReduction(value);
} else if (recipient == ForceAlignment.Opposing) {
scenario.setHostileReinforcementDelayReduction(value);
}
}
}
Loading

0 comments on commit 715d834

Please sign in to comment.