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

AtB - StratCon implementation #2144

Merged
merged 176 commits into from Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
8f2b011
start of conversion work;traitors modifier
NickAragua Feb 4, 2019
2b006fe
re-organization of map parameters editor GUI elements
NickAragua Feb 4, 2019
d39d775
bring back the GUI
NickAragua Feb 9, 2019
ed10019
some kind of changes
NickAragua Feb 20, 2019
beff8d6
xml file
NickAragua Feb 20, 2019
a0c1cbf
merge
NickAragua Feb 27, 2019
3002e32
merge from upstream
NickAragua Mar 5, 2019
da85b15
data structure work
NickAragua Mar 6, 2019
02eaa59
work on generating scenarios for specific track
NickAragua Mar 11, 2019
1361faa
hook it up, kind of
NickAragua Mar 12, 2019
d9c015f
force assignment UI prototype
NickAragua Mar 14, 2019
7ffb5e0
modifiers cleanup; template definitions;
NickAragua Mar 16, 2019
6c24826
scenario generation work
NickAragua Mar 16, 2019
1f6a53e
fix a few bugs; status display work
NickAragua Mar 19, 2019
2a512ee
merge from upstream
NickAragua Mar 26, 2019
00c8977
continued scenario lance assignment work
NickAragua Mar 26, 2019
75b54ef
merge from upstream again
NickAragua Mar 29, 2019
9219265
scenarios can be generated and populated in campaign
NickAragua Mar 29, 2019
2c2de01
initial map generation and facilities
NickAragua Apr 4, 2019
0067a4f
introduce scrolling
NickAragua Apr 4, 2019
6ea9e04
minor bugfixes
NickAragua Apr 7, 2019
05f3bd0
proper clicked hex detection
NickAragua Apr 8, 2019
34f5dff
continues work on track gui and rules
NickAragua Apr 24, 2019
b1c2e0f
hook up stratcon rules manager to mekhq event bus
NickAragua Apr 27, 2019
b096ba2
stratcon UI hookup, opfor gen tweak
NickAragua Apr 30, 2019
010c986
remove force gen files from tracking - we're not there yet
NickAragua Apr 30, 2019
ce41cc5
undo misguided PR cleanup attempt
NickAragua Apr 30, 2019
40d913c
fill transports feature
NickAragua May 2, 2019
b314c92
branch switch commit
NickAragua May 4, 2019
6f180f0
merge from upstream
NickAragua May 4, 2019
1eb5e5e
save campaign/track state; wreck force assignment
NickAragua May 4, 2019
119ff41
scenario setup work
NickAragua May 12, 2019
d8e5bc6
scenario revision
NickAragua May 12, 2019
e373025
work on scenario-force assignment UI
NickAragua May 22, 2019
51c9744
continued work on scenario management UI
NickAragua May 25, 2019
60e60c9
continued work on scenario setup wizard
NickAragua May 28, 2019
dab9569
reworked track scenario generation mechanism
NickAragua Jun 3, 2019
c26e5e0
continued work on scenario wizard
NickAragua Jun 4, 2019
cbf0f56
continued work on scenario UI, force assignment UI
NickAragua Jun 10, 2019
53ee7e4
continued scenario initiation work
NickAragua Jun 12, 2019
cb18b86
merge from upstream
NickAragua Jun 12, 2019
d510c6b
minor refactoring
NickAragua Jun 14, 2019
2548381
merge from upstream
NickAragua Jun 21, 2019
7cee408
higher rated units get nastier opposing force
NickAragua Jun 21, 2019
c05d07e
fix unit test error
NickAragua Jun 21, 2019
b6220b4
facility detection and fog of war rendering
NickAragua Jun 22, 2019
5c411e3
facility effects on scenarios
NickAragua Jun 27, 2019
ed6a5c0
merge from upstream
NickAragua Apr 12, 2020
c5f4857
merge changes
NickAragua Apr 18, 2020
ca46ea5
merge from upstream
NickAragua Jun 3, 2020
90b1ede
scenario info display
NickAragua Jun 4, 2020
b2f014d
merge from upstream
NickAragua Jun 24, 2020
40c89f9
facility serialization/deserialization
NickAragua Jun 24, 2020
2bd7638
merge from upstream
NickAragua Jul 13, 2020
d4f035c
merge from upstream
NickAragua Aug 9, 2020
47bdb33
adapt to LocalDate
NickAragua Aug 9, 2020
04c2cab
facilities work
NickAragua Aug 10, 2020
7d75eb4
facilities work
NickAragua Aug 10, 2020
f5bdaa4
facility definitions
NickAragua Aug 13, 2020
5830ebe
merge from upstream
NickAragua Aug 25, 2020
1d2b393
merge from upstream
NickAragua Aug 25, 2020
c862259
multiple bug fixes and hookup to actual campaign
NickAragua Aug 27, 2020
7c1cd73
base attack turret fix
NickAragua Aug 29, 2020
72a6f70
facility work
NickAragua Aug 29, 2020
338875e
modifier sorting; pirates
NickAragua Sep 3, 2020
5954e05
Facility display details
NickAragua Sep 3, 2020
3b8d316
logic shuffling for better scenario generation
NickAragua Sep 5, 2020
8f7cacb
scenario resolution processing; facility work
NickAragua Sep 9, 2020
935339a
merge from upstream
NickAragua Sep 9, 2020
b5f6220
data fixes; force undeployment by date;
NickAragua Sep 11, 2020
1122e2f
facility capture logic;data adjustments
NickAragua Sep 13, 2020
a8da6ab
merge from upstream
NickAragua Sep 13, 2020
dd96cc4
crew skill upgrader fix
NickAragua Sep 16, 2020
d1381bb
UI status updates; 'business' logic for scenario completion
NickAragua Sep 16, 2020
98a91fa
merge from upstream
NickAragua Sep 17, 2020
1f90f88
contract def data structure
NickAragua Sep 18, 2020
0b9be5a
pre-merge commit
NickAragua Oct 7, 2020
525709d
pre-merge commit #2
NickAragua Oct 7, 2020
04f10ee
merge from upstream
NickAragua Oct 7, 2020
9b2480a
save point
NickAragua Oct 11, 2020
8a0fc7e
enough of this is not api bullcrap
NickAragua Oct 11, 2020
8118366
initial implementation of objective/facility seeding
NickAragua Oct 13, 2020
c226cc5
objective/facility seeding; ui polish
NickAragua Oct 14, 2020
c05474e
contract definitions;polish;bugfixes
NickAragua Oct 16, 2020
998ab0f
merge from upstream
NickAragua Oct 16, 2020
684430e
Delete unitQuirksOverride.xml
NickAragua Oct 16, 2020
1a8ba7e
gm-reveal map; fixes for save/loading showstopper
NickAragua Oct 17, 2020
7d274ef
merge from upstream?
NickAragua Oct 17, 2020
bd14ef0
reroll population from actual lance; minefields; facility data fixes
NickAragua Oct 20, 2020
2eec6da
merge from upstream
NickAragua Oct 23, 2020
7fdf85e
fix force assignment save bug; facility name lengthening
NickAragua Oct 24, 2020
644f177
address some lgtm issues
NickAragua Oct 24, 2020
da4960f
template fixes; modifier application fixes; deployment return check f…
NickAragua Oct 25, 2020
dfca32f
merge from upstream
NickAragua Oct 28, 2020
b9e6b9d
stop modifier doubling
NickAragua Oct 28, 2020
05d025d
data fixes; hook up missed scenario method
NickAragua Oct 28, 2020
93020d1
tokenization; other stuff I don't remember
NickAragua Nov 3, 2020
24c2199
merge from upstream
NickAragua Dec 1, 2020
6fe11ed
merge from upstream
NickAragua Dec 22, 2020
ffaea50
revert ContractMarket
NickAragua Dec 22, 2020
d69c012
merge from upstream
NickAragua Feb 13, 2021
3f29441
fix NPE
NickAragua Feb 13, 2021
7f59899
merge from upstream
NickAragua Mar 6, 2021
b197521
merge from upstream
NickAragua Mar 9, 2021
c04f51a
render deployed forces; part of support point costs;
NickAragua Mar 10, 2021
f32def0
reinforcement deployment mechanics; facility visibility issue
NickAragua Mar 11, 2021
9f9de19
preferences; tokens
NickAragua Mar 12, 2021
929e851
minefield serialization; cosmetic updates
NickAragua Mar 13, 2021
8cd257a
legacy AtB scenario definition formatting
NickAragua Mar 13, 2021
a5382b0
additional code review changes
NickAragua Mar 14, 2021
69a98c0
static constructor replacement
NickAragua Mar 14, 2021
fe6e045
merge from upstream
NickAragua Mar 14, 2021
49aa475
fix compilation errors
NickAragua Mar 15, 2021
3712585
path constants; filter on inactive units; refresh campaign state prop…
NickAragua Mar 17, 2021
df692e1
additional unit eligibility checks
NickAragua Mar 17, 2021
558d523
use util funciton instead of hand-rolled mess
NickAragua Mar 17, 2021
aac2ced
code review changes
NickAragua Mar 18, 2021
8627de7
merge from upstream
NickAragua Mar 22, 2021
093eaeb
merge from upstream
NickAragua Mar 24, 2021
cc3a1c6
implement failed reinforcement attempts; fix scenario template retrie…
NickAragua Mar 24, 2021
5b5aeb8
UI cleanup; 'sticky' forces
NickAragua Mar 25, 2021
84c3b0b
ui adjustments to reduce jumping
NickAragua Mar 25, 2021
26e5b59
fix compilation warnings
NickAragua Mar 25, 2021
1343c8b
leadership force deployment rules/UI
NickAragua Mar 25, 2021
e5b1d3a
units deployed to StratCon tracks are ineligible for repairs
NickAragua Mar 25, 2021
41be2e4
force type data fixes
NickAragua Mar 26, 2021
796b672
scenario generation for deployed forces; bomb type fixes/expansion; s…
NickAragua Mar 26, 2021
d14fb80
code review changes
NickAragua Mar 28, 2021
3ad5f4e
missed a spot
NickAragua Mar 28, 2021
ded0a76
missed another spot
NickAragua Mar 29, 2021
3dded06
code review changes
NickAragua Mar 29, 2021
8a2b3d0
more code review changes
NickAragua Mar 29, 2021
82e5dd2
spacing fix
NickAragua Mar 29, 2021
28c4109
Apply suggestions from code review
NickAragua Mar 30, 2021
4354381
Apply suggestions from code review
NickAragua Mar 30, 2021
0244602
Apply suggestions from code review
NickAragua Mar 30, 2021
3714465
merge from upstream
NickAragua Mar 30, 2021
7ab4b9b
Update MekHQ/data/scenariomodifiers/FacilityHostileCapture.xml
NickAragua Mar 31, 2021
55af097
merge
NickAragua Mar 31, 2021
8c476d8
code review changes
NickAragua Apr 3, 2021
fbd59fb
Update MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml
NickAragua Apr 3, 2021
72a4646
Update MekHQ/data/scenariomodifiers/AlliedMechReinforcements.xml
NickAragua Apr 3, 2021
c2d264c
merge from upstream
NickAragua Apr 7, 2021
08c5d5b
merge from upstream
NickAragua Apr 7, 2021
9451101
missed folders in build script
NickAragua Apr 9, 2021
52905d6
fix new day nag NPEs
NickAragua Apr 9, 2021
882838f
disable legacy scenario generation for stratcon contracts
NickAragua Apr 9, 2021
c29f3db
don't save color if we don't have one
NickAragua Apr 13, 2021
5cc9941
Merge branch 'master' of https://github.com/MegaMek/mekhq into legacy…
NickAragua Apr 13, 2021
aed743f
deploy forces to currently selected track
NickAragua Apr 13, 2021
fde52dd
clean up phantom scenarios to prevent new day processing errors
NickAragua Apr 13, 2021
975ff32
sort lance lists by alphabetical order
NickAragua Apr 13, 2021
058ae23
code review changes
NickAragua Apr 13, 2021
01bf880
fix potential null color situation
NickAragua Apr 13, 2021
133e586
multiple bugs with ignoring scenarios; ground pirats on air maps
NickAragua Apr 14, 2021
0c8de94
calculate track odds granularly; fix scenario generation/saving under…
NickAragua Apr 15, 2021
ba7898a
update VP/SP in GUI when deploying reinforcements
NickAragua Apr 15, 2021
b08b95c
prevent transported infantry from throwing off reinforcement turn cal…
NickAragua Apr 16, 2021
e23eb59
faq
NickAragua Apr 16, 2021
ed3e5f5
prevent unlimited assignment of leadership auxiliaries
NickAragua Apr 16, 2021
3d8916c
add text resources; remove campaign scenarios after ignoring in strat…
NickAragua Apr 16, 2021
2e00ea9
code review changes
NickAragua Apr 17, 2021
78b310e
faq update
NickAragua Apr 17, 2021
c38a1f7
missed isempty
NickAragua Apr 17, 2021
e5f7b6e
fire brick error
NickAragua Apr 17, 2021
b36d9fa
whoops
NickAragua Apr 17, 2021
becffdc
code review changes; data fix; stop nagging once user hits 'no' once
NickAragua Apr 17, 2021
a6a4efc
Update MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
NickAragua Apr 17, 2021
42b305c
Update MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
NickAragua Apr 17, 2021
93299a0
Update MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java
NickAragua Apr 17, 2021
5d41cf6
last code review change; properly initialize and update strategic obj…
NickAragua Apr 18, 2021
4b7ca45
fix operator precedence to avoid NPE
NickAragua Apr 18, 2021
00ed93a
more NPE protection
NickAragua Apr 19, 2021
c4f072f
fix scenario dates; facility generation
NickAragua Apr 20, 2021
430dcc1
remove attacker/defender from dynamic scenario description
NickAragua Apr 20, 2021
ae5731c
last code review change; minor faq update
NickAragua Apr 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions MekHQ/data/scenariomodifiers/airBattleModifiers.xml
Expand Up @@ -22,9 +22,6 @@
<modifier>
GoodEquipment.xml
</modifier>
<modifier>
BadEvent.xml
</modifier>
<!--modifier>
Need ability to allow player to specifically deploy dropships
HotDrop.xml
Expand Down Expand Up @@ -71,9 +68,6 @@
<modifier>
PreBattleDamageAllies.xml
</modifier>
<modifier>
GoodEvent.xml
</modifier>
<modifier>
AlliedTraineesAir.xml
</modifier>
Expand Down
6 changes: 0 additions & 6 deletions MekHQ/data/scenariomodifiers/groundBattleModifiers.xml
Expand Up @@ -43,9 +43,6 @@
<modifier>
GoodEquipment.xml
</modifier>
<modifier>
BadEvent.xml
</modifier>
<!--modifier>
Need ability to allow player to specifically deploy dropships
HotDrop.xml
Expand Down Expand Up @@ -129,9 +126,6 @@
<modifier>
SearchAndRescue.xml
</modifier>
<modifier>
GoodEvent.xml
</modifier>
<modifier>
AlliedTraineesGround.xml
</modifier>
Expand Down
62 changes: 62 additions & 0 deletions MekHQ/docs/AtB Stuff/stratcon-faq.txt
@@ -0,0 +1,62 @@
StratCon reference and FAQ

How do I get this started?
Go to the AtB tab in Campaign Options and check "Use StratCon" at the very bottom.


How do I use the StratCon tab?
It's a graphical representation of one or more theatres of operations for your current AtB contract. It will have meaningful data once you arrive on the contract planet and the contract begins.

Hexes where you've conducted recon are displayed as light gray, hexes where you have not are dark gray. Pro tip: if you want to reveal hexes faster, use a lance with the "scout" disposition, that'll reveal all hexes around the deployment hex.

Allied facilities are displayed as green squares.
Hostile facilities are displayed as red squares.
Your forces deployed to the track are displayed as cyan circles.
Pending scenarios against hostile forces are concentric red squares.


That's great, how do I win?
Under Integrated and House command, you need to keep your VP count positive. Every time you win a scenario which you didn't initiate, that's +1 VP. Every time you lose a scenario you didn't initiate, that's -1 VP.

Under Liaison command, you need to keep your VP count positive AND you're responsible for completing the given number of strategic objectives. On defensive contracts, this may include keeping allied facilities intact and under allied control. On offensive contracts, it's usually capturing/destroying facilities or winning specific scenarios. VPs are only affected by scenarios in which a liaison participates.

Under Independent command, you're only responsible for completing strategic objectives.


This scenario looks pretty tough, how do I bring in more forces?
Right click on it and select 'manage scenario'. Now you have a couple of options:

If your primary lance leader has leadership, and you have "auxiliary units" available (ones that are not of the same type as the main unit type of the primary force), you can deploy as many auxiliaries as you have leadership points.

If your primary lance is in a 'defend' role, you can deploy up to 2 * (x + 1) your lance leader's tactics skill in infantry, battle armor squads and minefields. Any "left-over" defensive points are automatically converted into standard minefields.

Finally, you can bring in additional lances, with rules as follows:
- If the lance is already on the same track as the scenario, you can just deploy it as is.
- If you have a support point or a victory point to spare, you can deploy the lance as is.
- If the lance is in a 'fight' role, you can deploy it. However, on a 8- on a 2d6, it will add an extra negative modifier to the scenario.
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
- Otherwise, you can attempt to deploy a lance anyway. 2-5 means deployment failure, 6-8 adds extra negative modifier, 9+ succeeds.
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved


I want to leave a lance deployed in the field so I don't have to pay SPs or risk extra negative modifiers, can I do that?
Yep, right click on it and select 'remain deployed'. Now it will stay in the field until you uncheck that setting and be able to reinforce any scenarios you want without problems. However, you won't be able to carry out repairs or reloads.


I don't want to do this scenario, can I skip it?
Under integrated or house command, or if the liaison is coming along for the ride, you will lose a VP.
Additionally, if there's an allied facility on the track, the scenario will move towards the nearest allied facility. Sometimes, you need to keep those intact as part of the contract. And if they get captured without a fight, the enemy will put them to use, making subsequent scenarios more difficult.


There seems to be an excessive amount of enemy reinforcements coming into my battles, what gives?
Might be a hostile facility or three on the track. Better do some recon and take them out, or, even better, capture them so you can use them. Or, you might just be having bad luck - each scenario can receive up to three modifiers.


How do I capture a hostile facility?
You'll need to complete the 'capture' objective in an attack scenario on it, without completing the 'destroy' objective. Meaning, you'll need to leave the facility turrets intact (though disabling them via crew kills, equipment destruction or ammo depletion is fine), while routing any mobile enemy ground units


How do I manually deploy units to a track?
Right click on the desired hex, and click the 'deploy force' item, then pick a force. Easy! Just watch out, the hostiles might not like it and may intercept your force.


My units aren't showing up in the repair tab! Why?
You've probably got them deployed to a StratCon track. Wait for them to come back, and don't deploy them to any additional scenarios.
18 changes: 13 additions & 5 deletions MekHQ/src/mekhq/campaign/Campaign.java
Expand Up @@ -101,6 +101,7 @@
import mekhq.campaign.market.ShoppingList;
import mekhq.campaign.market.UnitMarket;
import mekhq.campaign.mission.AtBContract;
import mekhq.campaign.mission.AtBDynamicScenario;
import mekhq.campaign.mission.AtBScenario;
import mekhq.campaign.mission.Contract;
import mekhq.campaign.mission.Mission;
Expand Down Expand Up @@ -3025,12 +3026,19 @@ && getLocation().getJumpPath().getLastSystem().getId().equals(contract.getSystem
continue;
}
if ((s.getDate() != null) && s.getDate().isBefore(getLocalDate())) {
s.setStatus(Scenario.S_DEFEAT);
s.clearAllForcesAndPersonnel(this);
contract.addPlayerMinorBreach();
if (getCampaignOptions().getUseStratCon() &&
s instanceof AtBDynamicScenario) {
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
StratconRulesManager.processIgnoredScenario(
(AtBDynamicScenario) s, contract.getStratconCampaignState());
} else {
s.setStatus(Scenario.S_DEFEAT);
s.clearAllForcesAndPersonnel(this);
contract.addPlayerMinorBreach();
s.generateStub(this);
}

addReport("Failure to deploy for " + s.getName()
+ " resulted in defeat and a minor contract breach.");
s.generateStub(this);
+ " resulted in defeat and a minor contract breach.");
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java
Expand Up @@ -381,7 +381,7 @@ public boolean alreadyHasModifier(AtBScenarioModifier modifier) {

@Override
public int getScenarioType() {
return 0;
return DYNAMIC;
}

@Override
Expand Down
17 changes: 11 additions & 6 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Expand Up @@ -1930,23 +1930,28 @@ 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());
setDeploymentTurns(currentBotForce, forceTemplate.getArrivalTurn(), 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.
* 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, int deployRound,
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) {
setDeploymentTurnsStaggeredByLance(botForce.getEntityList());
setDeploymentTurnsStaggeredByLance(untransportedEntities);
} else if (deployRound == ScenarioForceTemplate.ARRIVAL_TURN_AS_REINFORCEMENTS) {
setDeploymentTurnsForReinforcements(botForce.getEntityList(), 0);
setDeploymentTurnsForReinforcements(untransportedEntities, 0);
} else {
for (Entity entity : botForce.getEntityList()) {
for (Entity entity : untransportedEntities) {
entity.setDeployRound(deployRound);
}
}
Expand Down Expand Up @@ -2115,7 +2120,7 @@ public static void setDeploymentTurnsForReinforcements(List<Entity> entityList,
if (entity.getTransportId() != Entity.NONE) {
continue;
}

int speed = calculateAtBSpeed(entity);

// don't reduce minimum speed to 0, since dividing by zero further down is problematic
Expand Down
25 changes: 25 additions & 0 deletions MekHQ/src/mekhq/campaign/mission/AtBScenario.java
Expand Up @@ -27,10 +27,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.StringJoiner;
import java.util.UUID;
import java.util.Vector;
Expand Down Expand Up @@ -70,6 +72,7 @@ public abstract class AtBScenario extends Scenario implements IAtBScenario {
//region Variable Declarations
private static final long serialVersionUID = 1148105510264408943L;

public static final int DYNAMIC = -1;
public static final int BASEATTACK = 0;
public static final int EXTRACTION = 1;
public static final int CHASE = 2;
Expand Down Expand Up @@ -1957,6 +1960,28 @@ protected String getCsvFromList(List<?> list) {
public AtBContract getContract(Campaign c) {
return (AtBContract) c.getMission(getMissionId());
}

/**
* Gets all the entities that are part of the given entity list and are
* not in this scenario's transport linkages as a transported unit.
*/
public List<Entity> filterUntransportedUnits(List<Entity> entities) {
List<Entity> retVal = new ArrayList<>();

// assemble a set of transported units for easier lookup
Set<String> transportedUnits = new HashSet<>();
for (List<String> transported : getTransportLinkages().values()) {
transportedUnits.addAll(transported);
}

for (Entity entity : entities) {
if (!transportedUnits.contains(entity.getExternalIdAsString())) {
retVal.add(entity);
}
}

return retVal;
}

public int getLanceForceId() {
return lanceForceId;
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/src/mekhq/campaign/mission/ScenarioTemplate.java
Expand Up @@ -60,6 +60,8 @@ public ScenarioTemplate clone() {
st.name = this.name;
st.shortBriefing = this.shortBriefing;
st.detailedBriefing = this.detailedBriefing;
st.isHostileFacility = this.isHostileFacility;
st.isAlliedFacility = this.isAlliedFacility;
for (ScenarioForceTemplate sft : scenarioForces.values()) {
st.scenarioForces.put(sft.getForceName(), sft.clone());
}
Expand Down
Expand Up @@ -74,7 +74,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());
AtBDynamicScenarioFactory.setDeploymentTurns(generatedBotForce, templateToApply.getArrivalTurn(), scenario);
AtBDynamicScenarioFactory.setDestinationZone(generatedBotForce, templateToApply);

// at this point, we have to re-translate the scenario objectives
Expand All @@ -95,6 +95,11 @@ private static void preAddForce(Campaign campaign, AtBDynamicScenario scenario,
* Worker function that removes the number of units from the specified side.
*/
public static void removeUnits(AtBDynamicScenario scenario, Campaign campaign, ForceAlignment eventRecipient, int unitRemovalCount) {
// can't do this if we don't have bots
if (scenario.getNumBots() == 0) {
return;
}

int actualUnitsToRemove = unitRemovalCount;

if (unitRemovalCount == ScenarioForceTemplate.FIXED_UNIT_SIZE_LANCE) {
Expand All @@ -112,7 +117,11 @@ public static void removeUnits(AtBDynamicScenario scenario, Campaign campaign, F
for (int x = 0; x < actualUnitsToRemove; x++) {
int botForceIndex = Compute.randomInt(scenario.getNumBots());
BotForce bf = scenario.getBotForce(botForceIndex);
if (bf.getTeam() == ScenarioForceTemplate.TEAM_IDS.get(eventRecipient.ordinal())) {

// only remove units from a bot force if it's on the affected team
// AND if it has any units to remove
if ((bf.getTeam() == ScenarioForceTemplate.TEAM_IDS.get(eventRecipient.ordinal()))
&& (bf.getEntityList().size() > 0)) {
Windchild292 marked this conversation as resolved.
Show resolved Hide resolved
int unitIndexToRemove = Compute.randomInt(bf.getEntityList().size());
bf.removeEntity(unitIndexToRemove);
}
Expand Down