Skip to content

Commit

Permalink
vtols off the ground; bombs expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAragua committed Jun 12, 2021
1 parent ac90643 commit 5e4e651
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
3 changes: 2 additions & 1 deletion MekHQ/src/mekhq/AtBGameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ public void run() {

// we need to wait until the game has actually started to do transport loading
// This will load the bot's infantry into APCs
Thread.sleep(MekHQ.getMekHQOptions().getStartGameDelay());
// sometimes it needs more time?
Thread.sleep(MekHQ.getMekHQOptions().getStartGameDelay() * 2);
if (scenario != null) {
AtBDynamicScenarioFactory.loadTransports(scenario, botClient);
}
Expand Down
30 changes: 27 additions & 3 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public class AtBDynamicScenarioFactory {
*/
public static final int UNIT_WEIGHT_UNSPECIFIED = -1;

private static final int[] validBotBombs = { BombType.B_HE, BombType.B_CLUSTER, BombType.B_RL, BombType.B_INFERNO, BombType.B_THUNDER, BombType.B_FAE_SMALL, BombType.B_FAE_LARGE, BombType.B_LG, BombType.B_TAG };
// bomb types assignable to aerospace units on ground maps
private static final int[] validBotBombs = { BombType.B_HE, BombType.B_CLUSTER, BombType.B_RL,
BombType.B_INFERNO, BombType.B_THUNDER, BombType.B_FAE_SMALL, BombType.B_FAE_LARGE,
BombType.B_LG, BombType.B_ARROW, BombType.B_HOMING, BombType.B_TAG };
private static final int[] validBotAABombs = { BombType.B_RL, BombType.B_LAA, BombType.B_AAA };

private static final int[] minimumBVPercentage = { 50, 60, 70, 80, 90, 100 };
Expand Down Expand Up @@ -2311,6 +2314,15 @@ private static void setStartingAltitude(List<Entity> entityList, int startingAlt
((IAero) entity).land();
}
}

// hack - set helis and WIGEs to an explicit altitude of 1
// currently there is no support for setting elevation for "ground" units
// in the scenario template editor, but it looks dumb to have choppers
// start out on the ground
if (entity.getMovementMode() == EntityMovementMode.VTOL ||
entity.getMovementMode() == EntityMovementMode.WIGE) {
entity.setElevation(1);;
}
}
}

Expand Down Expand Up @@ -2366,9 +2378,21 @@ private static void loadBombs(Entity entity, int[] validBombChoices, int year) {
}

// pick out the index in the BombType array
int bombIndex = actualValidBombChoices.get(Compute.randomInt(actualValidBombChoices.size()));
int randomBombChoiceIndex = Compute.randomInt(actualValidBombChoices.size());
int bombIndex = actualValidBombChoices.get(randomBombChoiceIndex);
int weightModifier = 0;

// hack: we only really need one "tag", so add it then pack on some more bombs
if (bombIndex == BombType.B_TAG) {
weightModifier = 5;
bombChoices[bombIndex] = 1;
actualValidBombChoices.remove(randomBombChoiceIndex);
bombIndex = Utilities.getRandomItem(actualValidBombChoices);
}

// # of bombs is the unit's weight / (bomb cost * 5)
int numBombs = (int) (entity.getWeight() / (BombType.getBombCost(bombIndex) * 5));
int numBombs = (int) ((entity.getWeight() - weightModifier) /
(BombType.getBombCost(bombIndex) * 5));
bombChoices[bombIndex] = numBombs;

((IBomber) entity).setBombChoices(bombChoices);
Expand Down

0 comments on commit 5e4e651

Please sign in to comment.