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

update planetary conditions chance logic #3834

Merged
merged 44 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
042caf8
lower the pitch black light condition chance
kuronekochomusuke Feb 9, 2024
cdcd74b
add common function to set light
kuronekochomusuke Feb 10, 2024
661e8ff
update weather percentages, allow overlaps
kuronekochomusuke Feb 10, 2024
4ba64aa
check restrictions
kuronekochomusuke Feb 10, 2024
ac37726
if restricted set to none
kuronekochomusuke Feb 10, 2024
b6e1204
code cleanup
kuronekochomusuke Feb 10, 2024
c37f84b
code cleanup
kuronekochomusuke Feb 10, 2024
7b907ad
code cleanup
kuronekochomusuke Feb 10, 2024
83ceb2c
set weather by terrain type
kuronekochomusuke Feb 10, 2024
8cb333a
update percentages
kuronekochomusuke Feb 10, 2024
cd6b05f
if extreme heat check blowing sand
kuronekochomusuke Feb 10, 2024
7440d9f
foggier, extreme cold
kuronekochomusuke Feb 10, 2024
00a08fb
lower chance ranges
kuronekochomusuke Feb 10, 2024
5d4b180
if blowing sand, set wind to moderate gale
kuronekochomusuke Feb 10, 2024
d83056e
add rollCondition and pass in the odds needed
kuronekochomusuke Feb 11, 2024
342a253
pass blowing sand and EMI to game when starting
kuronekochomusuke Feb 11, 2024
d4f99c2
check that values returned are valid
kuronekochomusuke Feb 12, 2024
e6c916b
move restricted check into rollBlowingSand()
kuronekochomusuke Feb 12, 2024
3e12030
correct miss chance
kuronekochomusuke Feb 12, 2024
8726653
correct miss chance
kuronekochomusuke Feb 12, 2024
7c46fc9
remove tempature logic to make converting to a config file simpler in…
kuronekochomusuke Feb 13, 2024
d27a234
use map type to determine odds
kuronekochomusuke Feb 14, 2024
dfd0433
add dark group
kuronekochomusuke Feb 14, 2024
2463b90
code cleanup
kuronekochomusuke Feb 14, 2024
03dcaaa
Merge remote-tracking branch 'origin/master' into pitchBlackChance
kuronekochomusuke Feb 14, 2024
65103dc
add emi, set odds when fixed map
kuronekochomusuke Feb 15, 2024
083e9f6
code cleanup
kuronekochomusuke Feb 15, 2024
c3a13c0
use displayable value functions
kuronekochomusuke Feb 16, 2024
38b838f
use config file to determine terrain, switch back to terran to determ…
kuronekochomusuke Feb 18, 2024
130a9f5
code cleanup
kuronekochomusuke Feb 18, 2024
aeedb6e
fix paht
kuronekochomusuke Feb 18, 2024
3707ff4
Merge remote-tracking branch 'origin/master' into pitchBlackChance
kuronekochomusuke Feb 24, 2024
b3c5705
fix warnings
kuronekochomusuke Feb 24, 2024
4116c0e
fix light case. fix heavy templates
kuronekochomusuke Feb 24, 2024
23df016
used enums. show changed tempature
kuronekochomusuke Mar 2, 2024
c833278
Merge remote-tracking branch 'origin/master' into pitchBlackChance
kuronekochomusuke Mar 2, 2024
ccce404
use config file to map terrain to weather odds
kuronekochomusuke Mar 3, 2024
c96d59f
code cleanup
kuronekochomusuke Mar 3, 2024
0bf09d6
fix error
kuronekochomusuke Mar 3, 2024
63c5fe3
fix error
kuronekochomusuke Mar 4, 2024
fce7f76
Merge remote-tracking branch 'origin/master' into pitchBlackChance
kuronekochomusuke Mar 20, 2024
03ed42a
fix imports
kuronekochomusuke Mar 20, 2024
667bb82
Merge branch 'master' into pitchBlackChance
kuronekochomusuke Mar 23, 2024
f7a11a4
Merge remote-tracking branch 'origin/master' into pitchBlackChance
kuronekochomusuke Mar 23, 2024
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
5 changes: 3 additions & 2 deletions MekHQ/data/scenariotemplates/Allied Facility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<isAlliedFacility>true</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>3</allowedTerrainType>
<allowedTerrainType>6</allowedTerrainType>
<allowedTerrainType>ColdFacility</allowedTerrainType>
<allowedTerrainType>HotFacility</allowedTerrainType>
<allowedTerrainType>TemperateFacility</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
5 changes: 3 additions & 2 deletions MekHQ/data/scenariotemplates/Hostile Facility.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<isHostileFacility>true</isHostileFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>3</allowedTerrainType>
<allowedTerrainType>6</allowedTerrainType>
<allowedTerrainType>ColdFacility</allowedTerrainType>
<allowedTerrainType>HotFacility</allowedTerrainType>
<allowedTerrainType>TemperateFacility</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
5 changes: 3 additions & 2 deletions MekHQ/data/scenariotemplates/Irregular Forces.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<isAlliedFacility>false</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>3</allowedTerrainType>
<allowedTerrainType>6</allowedTerrainType>
<allowedTerrainType>ColdUrban</allowedTerrainType>
<allowedTerrainType>HotUrban</allowedTerrainType>
<allowedTerrainType>Urban</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/data/scenariotemplates/LegacyAtB/AceDuel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<isAlliedFacility>false</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>1</allowedTerrainType>
<allowedTerrainType>Hills</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/data/scenariotemplates/LegacyAtB/AlliedTraitors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<isAlliedFacility>false</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>1</allowedTerrainType>
<allowedTerrainType>Hills</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
2 changes: 1 addition & 1 deletion MekHQ/data/scenariotemplates/LegacyAtB/OfficerDuel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<isAlliedFacility>false</isAlliedFacility>
<mapParameters>
<allowedTerrainTypes>
<allowedTerrainType>1</allowedTerrainType>
<allowedTerrainType>Hills</allowedTerrainType>
</allowedTerrainTypes>
<allowRotation>false</allowRotation>
<baseHeight>0</baseHeight>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ lblLight.text=Light:
lblWeather.text=Weather:
lblWind.text=Wind:
lblFog.text=Fog:
lblBlowingSand.text=Blowing Sand:
lblEMI.text=EMI:
lblAtmosphere.text=Atmosphere:
lblGravity.text=Gravity:
lblPlayerStart.text=Player Start:
Expand Down
2 changes: 2 additions & 0 deletions MekHQ/resources/mekhq/resources/ScenarioViewPanel.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ lblLight.text=<html><b>Light:</b></html>
lblWeather.text=<html><b>Weather:</b></html>
lblWind.text=<html><b>Wind:</b></html>
lblFog.text=<html><b>Fog:</b></html>
lblBlowingSand.text=<html><b>Blowing Sand:</b></html>
lblEMI.text=<html><b>EMI:</b></html>
lblAtmosphere.text=<html><b>Atmosphere:</b></html>
lblGravity.text=<html><b>Gravity:</b></html>
lblTemperature.text=<html><b>Temperature:</b></html>
Expand Down
12 changes: 8 additions & 4 deletions MekHQ/src/mekhq/AtBGameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,15 @@ public void run() {
mapSettings.getBoardsSelectedVector().clear();

// if the scenario is taking place in space, do space settings instead
if (scenario.getTerrainType() == Scenario.TER_SPACE) {
if (scenario.getBoardType() == Scenario.T_SPACE) {
mapSettings.setMedium(MapSettings.MEDIUM_SPACE);
mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED);
} else if (scenario.isUsingFixedMap()) {
mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", "")); // TODO : remove inline file type
String board = scenario.getMap().replace(".board", ""); // TODO : remove inline file type
board = board.replace("\\", "/");
mapSettings.getBoardsSelectedVector().add(board);

if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) {
if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) {
mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE);
}
} else {
Expand All @@ -138,7 +140,7 @@ public void run() {
LogManager.getLogger().error("Could not load map file data/mapgen/" + scenario.getMap() + ".xml", ex); // TODO : Remove inline file path
}

if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) {
if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) {
mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE);
}

Expand All @@ -158,6 +160,8 @@ public void run() {
planetaryConditions.setFog(scenario.getFog());
planetaryConditions.setAtmosphere(scenario.getAtmosphere());
planetaryConditions.setGravity(scenario.getGravity());
planetaryConditions.setEMI(scenario.usesEMI());
planetaryConditions.setBlowingSand(scenario.usesBlowingSand());
planetaryConditions.setTemperature(scenario.getTemperature());
client.sendPlanetaryConditions(planetaryConditions);
Thread.sleep(MekHQ.getMHQOptions().getStartGameDelay());
Expand Down
10 changes: 6 additions & 4 deletions MekHQ/src/mekhq/GameThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ public void run() {
mapSettings.getBoardsSelectedVector().clear();

// if the scenario is taking place in space, do space settings instead
if (scenario.getTerrainType() == Scenario.TER_SPACE) {
if (scenario.getBoardType() == Scenario.T_SPACE) {
mapSettings.setMedium(MapSettings.MEDIUM_SPACE);
mapSettings.getBoardsSelectedVector().add(MapSettings.BOARD_GENERATED);
} else if (scenario.isUsingFixedMap()) {
mapSettings.getBoardsSelectedVector().add(scenario.getMap().replace(".board", ""));
String board = scenario.getMap().replace(".board", ""); // TODO : remove inline file type
board = board.replace("\\", "/");
mapSettings.getBoardsSelectedVector().add(board);

if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) {
if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) {
mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE);
}
} else {
Expand All @@ -154,7 +156,7 @@ public void run() {
LogManager.getLogger().error("Could not load map file data/mapgen/" + scenario.getMap() + ".xml", ex); // TODO : remove inline file path
}

if (scenario.getTerrainType() == Scenario.TER_LOW_ATMO) {
if (scenario.getBoardType() == Scenario.T_ATMOSPHERE) {
mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE);
}

Expand Down
5 changes: 0 additions & 5 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,6 @@ protected void loadFieldsFromXmlNode(final Node wn, final Version version, final
super.loadFieldsFromXmlNode(wn, version, campaign);
}

@Override
public void setTerrain() {
AtBDynamicScenarioFactory.setTerrain(this);
}

@Override
public void refresh(Campaign campaign) {

Expand Down
138 changes: 34 additions & 104 deletions MekHQ/src/mekhq/campaign/mission/AtBDynamicScenarioFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import mekhq.campaign.personnel.Bloodname;
import mekhq.campaign.personnel.SkillType;
import mekhq.campaign.personnel.enums.Phenotype;
import mekhq.campaign.stratcon.StratconBiomeManifest;
import mekhq.campaign.stratcon.StratconContractInitializer;
import mekhq.campaign.unit.Unit;
import mekhq.campaign.universe.*;
import mekhq.campaign.universe.Faction.Tag;
Expand Down Expand Up @@ -465,7 +467,7 @@ public static int generateForce(AtBDynamicScenario scenario, AtBContract contrac
}

setStartingAltitude(generatedLance, forceTemplate.getStartingAltitude());
correctNonAeroFlyerBehavior(generatedLance, scenario.getTerrainType());
correctNonAeroFlyerBehavior(generatedLance, scenario.getBoardType());

// if force contributes to map size, increment the generated "lance" count
if (forceTemplate.getContributesToMapSize()) {
Expand Down Expand Up @@ -708,22 +710,7 @@ private static void scaleObjectiveTimeLimits(AtBDynamicScenario scenario, Campai
* @param scenario The scenario for which to set lighting conditions.
*/
private static void setLightConditions(AtBDynamicScenario scenario) {
int roll = Compute.randomInt(10) + 1;
int light;

if (roll < 6) {
light = PlanetaryConditions.L_DAY;
} else if (roll < 8) {
light = PlanetaryConditions.L_DUSK;
} else if (roll == 8) {
light = PlanetaryConditions.L_FULL_MOON;
} else if (roll == 9) {
light = PlanetaryConditions.L_MOONLESS;
} else {
light = PlanetaryConditions.L_PITCH_BLACK;
}

scenario.setLight(light);
scenario.setLightConditions();
}

/**
Expand All @@ -732,78 +719,7 @@ private static void setLightConditions(AtBDynamicScenario scenario) {
* @param scenario The scenario for which to set weather conditions.
*/
private static void setWeather(AtBDynamicScenario scenario) {
int weather = PlanetaryConditions.WE_NONE;
int wind = PlanetaryConditions.WI_NONE;
int fog = PlanetaryConditions.FOG_NONE;

// weather is irrelevant in these situations.
if (scenario.getTerrainType() == AtBScenario.TER_SPACE ||
scenario.getTerrainType() == AtBScenario.TER_LOW_ATMO) {
return;
}

int roll = Compute.randomInt(10) + 1;
int r2 = Compute.d6();
if (roll < 6) {
return;
} else if (roll == 6) {
if (r2 < 4) {
weather = PlanetaryConditions.WE_LIGHT_RAIN;
} else if (r2 < 6) {
weather = PlanetaryConditions.WE_MOD_RAIN;
} else {
weather = PlanetaryConditions.WE_HEAVY_RAIN;
}
} else if (roll == 7) {
if (r2 < 4) {
weather = PlanetaryConditions.WE_LIGHT_SNOW;
} else if (r2 < 6) {
weather = PlanetaryConditions.WE_MOD_SNOW;
} else {
weather = PlanetaryConditions.WE_HEAVY_SNOW;
}
} else if (roll == 8) {
if (r2 < 4) {
wind = PlanetaryConditions.WI_LIGHT_GALE;
} else if (r2 < 6) {
wind = PlanetaryConditions.WI_MOD_GALE;
} else {
wind = PlanetaryConditions.WI_STRONG_GALE;
}
} else if (roll == 9) {
if (r2 == 1) {
wind = PlanetaryConditions.WI_STORM;
} else if (r2 == 2) {
weather = PlanetaryConditions.WE_DOWNPOUR;
} else if (r2 == 3) {
weather = PlanetaryConditions.WE_SLEET;
} else if (r2 == 4) {
weather = PlanetaryConditions.WE_ICE_STORM;
} else if (r2 == 5) {
// tornadoes are classified as wind rather than weather.
wind = PlanetaryConditions.WI_TORNADO_F13;
} else if (r2 == 6) {
wind = PlanetaryConditions.WI_TORNADO_F4;
}
} else {
if (r2 < 5) {
fog = PlanetaryConditions.FOG_LIGHT;
} else {
fog = PlanetaryConditions.FOG_HEAVY;
}
}

if (!WeatherRestriction.IsWeatherRestricted(weather, scenario.getAtmosphere(), scenario.getTemperature())) {
scenario.setWeather(weather);
}

if (!WeatherRestriction.IsWindRestricted(wind, scenario.getAtmosphere(), scenario.getTemperature())) {
scenario.setWind(wind);
}

if (!WeatherRestriction.IsFogRestricted(fog, scenario.getAtmosphere(), scenario.getTemperature())) {
scenario.setFog(fog);
}
scenario.setWeather();
}

/**
Expand All @@ -812,26 +728,40 @@ private static void setWeather(AtBDynamicScenario scenario) {
* @param scenario The scenario to work on.
*/
public static void setTerrain(AtBDynamicScenario scenario) {
int terrainIndex;

// if we are allowing all terrain types, then pick one from the list
// otherwise, pick one from the allowed ones
if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.AllGroundTerrain) {
terrainIndex = Compute.randomInt(AtBScenario.terrainTypes.length);
scenario.setTerrainType(terrainIndex);
scenario.setBoardType(AtBScenario.T_GROUND);
StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance();
int kelvinTemp = scenario.getTemperature() + StratconContractInitializer.ZERO_CELSIUS_IN_KELVIN;
List<String> allowedTerrain = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_BIOME)
.floorEntry(kelvinTemp).getValue().allowedTerrainTypes;

int terrainIndex = Compute.randomInt(allowedTerrain.size());
scenario.setTerrainType(allowedTerrain.get(terrainIndex));
scenario.setMapFile();
} else if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.Space) {
scenario.setTerrainType(AtBScenario.TER_SPACE);
scenario.setBoardType(AtBScenario.T_SPACE);
scenario.setTerrainType("Space");
} else if (scenario.getTemplate().mapParameters.getMapLocation() == ScenarioMapParameters.MapLocation.LowAtmosphere) {
scenario.setBoardType(AtBScenario.T_ATMOSPHERE);
// low atmosphere actually makes use of the terrain, so we generate some here as well
terrainIndex = Compute.randomInt(AtBScenario.terrainTypes.length);
scenario.setTerrainType(terrainIndex);
scenario.setTerrain();
scenario.setMapFile();

// but then we set the terrain to low atmosphere
scenario.setTerrainType(AtBScenario.TER_LOW_ATMO);
} else {
terrainIndex = Compute.randomInt(scenario.getTemplate().mapParameters.allowedTerrainTypes.size());
StratconBiomeManifest biomeManifest = StratconBiomeManifest.getInstance();
int kelvinTemp = scenario.getTemperature() + StratconContractInitializer.ZERO_CELSIUS_IN_KELVIN;
List<String> allowedFacility = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_FACILITY_BIOME)
.floorEntry(kelvinTemp).getValue().allowedTerrainTypes;
List<String> allowedTerrain = biomeManifest.getTempMap(StratconBiomeManifest.TERRAN_BIOME)
.floorEntry(kelvinTemp).getValue().allowedTerrainTypes;
List<String> allowedTemplate = scenario.getTemplate().mapParameters.allowedTerrainTypes;
// try to filter on temp
allowedTerrain.addAll(allowedFacility);
allowedTemplate.retainAll(allowedTerrain);
allowedTemplate = allowedTemplate.size() > 0 ? allowedTemplate : scenario.getTemplate().mapParameters.allowedTerrainTypes;

int terrainIndex = Compute.randomInt(allowedTemplate.size());
scenario.setTerrainType(scenario.getTemplate().mapParameters.allowedTerrainTypes.get(terrainIndex));
scenario.setMapFile();
}
Expand All @@ -846,7 +776,7 @@ public static void setTerrain(AtBDynamicScenario scenario) {
* @param campaign The current campaign
*/
private static void setPlanetaryConditions(AtBDynamicScenario scenario, AtBContract mission, Campaign campaign) {
if (scenario.getTerrainType() == AtBScenario.TER_SPACE) {
if (scenario.getBoardType() == AtBScenario.T_SPACE) {
return;
}

Expand Down Expand Up @@ -2445,10 +2375,10 @@ private static void setStartingAltitude(List<Entity> entityList, int startingAlt
* This method contains various hacks intended to put "special units"
* such as LAMs, VTOLs and WIGEs into a reasonable state that the bot can use
*/
private static void correctNonAeroFlyerBehavior(List<Entity> entityList, int terrainType) {
private static void correctNonAeroFlyerBehavior(List<Entity> entityList, int boardType) {
for (Entity entity : entityList) {
boolean inSpace = terrainType == AtBScenario.TER_SPACE;
boolean inAtmo = terrainType == AtBScenario.TER_LOW_ATMO;
boolean inSpace = boardType == AtBScenario.T_SPACE;
boolean inAtmo = boardType == AtBScenario.T_ATMOSPHERE;

// hack for land-air mechs
if (entity instanceof LandAirMech) {
Expand Down
Loading
Loading