From 3159eb742d59401670473c669d09289e0a04311b Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 1 Nov 2024 10:11:54 +0100 Subject: [PATCH] improve game options parsing for scenarios, scenario adaptation --- .../LoweringTheBoom/LoweringTheBoom.mms | 5 + .../LoweringTheBoomReverse.mms | 5 + .../LoweringTheBoom/gameoptions3025.xml | 991 ++++++++++++++++++ megamek/docs/Scenarios/ScenarioV2 HowTo.mms | 17 +- .../megamek/common/scenario/ScenarioV2.java | 27 +- 5 files changed, 1029 insertions(+), 16 deletions(-) create mode 100644 megamek/data/scenarios/Kell Hounds/LoweringTheBoom/gameoptions3025.xml diff --git a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms index 57dbf21ec52..e5c8fe66e0b 100644 --- a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms +++ b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoom.mms @@ -40,6 +40,9 @@ map: terrain: water newlevel: 3 +options: + file: gameoptions3025.xml + factions: - name: Thirtieth Marik Militia @@ -134,6 +137,8 @@ messages: as many Meks as possible. Be careful! Some of your Meks have already sustained damage. + + *This game uses basic game rules.* image: loweringboom_map.png trigger: type: and diff --git a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoomReverse.mms b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoomReverse.mms index 73385650c2c..63b84f8b148 100644 --- a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoomReverse.mms +++ b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/LoweringTheBoomReverse.mms @@ -40,6 +40,9 @@ map: terrain: water newlevel: 3 +options: + file: gameoptions3025.xml + factions: - name: Kell Hounds, First Battalion @@ -124,6 +127,8 @@ messages: escape from this edge with as many Meks as possible. Some of their Meks have already sustained damage. + + *This game uses basic game rules.* image: loweringboom_map_reverse.png trigger: type: and diff --git a/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/gameoptions3025.xml b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/gameoptions3025.xml new file mode 100644 index 00000000000..fea948d7844 --- /dev/null +++ b/megamek/data/scenarios/Kell Hounds/LoweringTheBoom/gameoptions3025.xml @@ -0,0 +1,991 @@ + + + + multiuse_ams + false + + + tacops_heat + false + + + inf_move_later + false + + + year + 3025 + + + simultaneous_movement + false + + + extreme_temperature_survival + false + + + aero_ground_move + true + + + stratops_aaa_laser + false + + + sensors_detect_all + false + + + tacops_bap + false + + + stratops_harjel + false + + + no_hover_charge + false + + + tacops_gauss_weapons + false + + + alternate_masc + false + + + tacops_prone_fire + false + + + toughness + false + + + at2_nukes + false + + + tacops_ba_criticals + false + + + tacops_engine_explosions + false + + + conditional_ejection + false + + + stratops_space_bomb + false + + + real_blind_drop + false + + + mek_lance_movement_number + 4 + + + on_map_predesignate + false + + + autosave_msg + true + + + commander_killed + false + + + variable_damage_thresh + false + + + stratops_grav_effects + false + + + pilots_cannot_spot + false + + + team_initiative + true + + + individual_initiative + false + + + psr_jump_heavy_woods + false + + + canon_only + true + + + use_bv_ratio + false + + + protos_move_multi + false + + + allow_nukes + false + + + heat_by_bay + false + + + team_vision + true + + + inf_proto_move_multi + 3 + + + tacops_vtol_attacks + false + + + hide_unofficial + true + + + bridgeCF + 0 + + + clubs_punch + false + + + minefields + false + + + vehicle_advanced_maneuvers + false + + + tacops_sprint + false + + + vtol_strafing + false + + + tacops_energy_weapons + false + + + set_arty_player_homeedge + false + + + manual_shutdown + false + + + artillery_skill + false + + + check_victory + false + + + tacops_walk_backwards + false + + + no_premove_vibra + false + + + stratops_waypoint_launch + false + + + tacops_dig_in + false + + + ghost_target_max + 5 + + + vehicle_acceleration + false + + + tacops_angel_ecm + false + + + stratops_aa_fire + false + + + tacops_eccm + false + + + simultaneous_targeting + false + + + tacops_sensors + false + + + tacops_trip_attack + false + + + hidden_units + true + + + hide_legacy + true + + + inf_deploy_even + false + + + dumping_from_round + 1 + + + tacops_partial_cover + false + + + maxtech_movement_mods + false + + + tacops_manual_ams + false + + + single_no_cap + false + + + tacops_crit_roll + false + + + indirect_always_possible + false + + + stratops_partialrepairs + false + + + begin_shutdown + false + + + aero_sanity + false + + + tacops_ziplines + false + + + random_basements + true + + + tacops_burst + false + + + geometric_mean_bv + false + + + tacops_fatigue + false + + + disable_local_save + false + + + tacops_physical_psr + false + + + tacops_evade + false + + + tacops_jump_jet_attack + false + + + rng_log + false + + + protos_move_even + false + + + alternate_pilot_bv_mod + false + + + return_flyover + false + + + floating_crits + false + + + indirect_fire + false + + + no_night_move_pen + false + + + tacops_retractable_blades + false + + + double_blind + false + + + tacops_attack_physical_psr + false + + + no_clan_physical + false + + + exclusive_db_deployment + true + + + inclusive_sensor_range + false + + + alternate_masc_enhanced + false + + + max_external_heat + 15 + + + blind_drop + false + + + suppress_double_blind_bv + false + + + front_load_initiative + false + + + simultaneous_firing + false + + + use_bv_destroyed + false + + + increased_iserll_range + false + + + show_bay_detail + false + + + tacops_falling_expanded + false + + + tacops_ams + false + + + manei_domini + false + + + auto_abandon_unit + false + + + tacops_leaping + false + + + stratops_bracket_fire + false + + + reduced_overheat_modifier_bv + false + + + ejected_pilots_flee + false + + + tacops_clusterhitpen + false + + + tacops_LOS1 + false + + + stratops_quirks + false + + + tacops_mobile_hqs + false + + + protos_safe_from_infernos + false + + + ammo_explosions + false + + + tacops_take_cover + false + + + auto_ams + true + + + tacops_woods_cover + false + + + skip_ineligable_firing + false + + + stratops_sensor_shadow + false + + + no_immobile_vehicles + false + + + stratops_bearings_only_velocity + 50 + + + vehicles_threshold_divisor + 10 + + + falls_end_movement + false + + + kind_rapid_ac + false + + + tacops_attempting_stand + false + + + full_rotor_hits + false + + + skip_forced_victory + false + + + command_init + false + + + woods_burn_down_amount + 5 + + + tacops_fumbles + false + + + bv_ratio_percent + 300 + + + tacops_direct_blow + false + + + fuel_consumption + false + + + vehicles_can_eject + false + + + tacops_ba_weight + false + + + tacops_range + false + + + pilots_visual_range_one + false + + + tacops_hull_down + false + + + flamer_heat + false + + + uac_tworolls + false + + + tacops_grappling + false + + + no_ignite_clear + false + + + skip_ineligable_movement + false + + + expanded_kf_drive_damage + false + + + tacops_hotload + false + + + bv_destroyed_percent + 100 + + + rng_type + 1 + + + simultaneous_deployment + false + + + mek_lance_movement + false + + + num_hexes_predesignate + 5 + + + friendly_fire + false + + + tacops_vehicle_arcs + false + + + simultaneous_physical + false + + + hotload_in_game + false + + + clan_ignore_eq_limits + false + + + era_based + false + + + metal_content + false + + + magscan_nohills + false + + + tacops_called_shots + false + + + stratops_adv_pointdef + false + + + stratops_conv_fusion_bonus + false + + + tacops_glancing_blows + false + + + ba_grab_bars + false + + + tacops_taking_damage + false + + + stratops_ecm + false + + + tacops_standing_still + false + + + tacops_skin_of_the_teeth_ejection + false + + + paranoid_autosave + false + + + tacops_advanced_mech_hit_locations + false + + + tacops_dead_zones + false + + + tacops_tank_crews + false + + + stratops_capital_fighter + false + + + tacops_ppc_inhibitors + false + + + all_have_ei_cockpit + false + + + stratops_advanced_sensors + false + + + tacops_ba_vs_ba + false + + + increased_ac_dmg + false + + + map_area_predesignate + 1088 + + + tacops_charge_damage + false + + + woods_burn_down + false + + + stratops_over_penetrate + false + + + tacops_careful_stand + false + + + reverse_gear + false + + + tacops_los_range + false + + + assault_drop + false + + + turn_timer + 0 + + + vehicle_turn_mode + false + + + use_kill_count + false + + + vehicles_threshold + false + + + tacops_coolant_failure + false + + + lobby_ammo_dump + false + + + aa_move_mod + false + + + push_off_board + false + + + advanced_movement + false + + + vehicles_threshold_variable + false + + + edge + false + + + stratops_bearings_only + false + + + restrict_game_commands + false + + + vehicles_safe_from_infernos + false + + + inf_move_multi + false + + + aero_artillery_munitions + false + + + vehicle_lance_movement_number + 4 + + + tacops_skilled_evasion + false + + + breeze + false + + + rpg_gunnery + false + + + use_game_turn_limit + false + + + tacops_vehicle_effective + false + + + forest_fires_no_smoke + false + + + supress_all_double_blind_messages + false + + + no_forced_primary_targets + false + + + atmospheric_control + false + + + allow_illegal_units + false + + + tacops_start_fire + false + + + tacops_altdmg + false + + + techlevel + Standard + + + skip_ineligable_physical + true + + + initiative_streak_compensation + false + + + tacops_fast_infantry_move + false + + + tacops_self_destruct + false + + + tacops_ghost_target + false + + + tacops_battle_wreck + false + + + really_allow_nukes + false + + + deep_deployment + false + + + protos_move_later + false + + + tacops_ammunition + false + + + pilot_advantages + false + + + no_tac + false + + + armed_mechwarriors + false + + + game_kill_count + 4 + + + tacops_leg_damage + false + + + achieve_conditions + 1 + + + inf_move_even + false + + + game_turn_limit + 10 + + + allow_large_squadrons + false + + + tacops_rapid_ac + false + + + unjam_uac + false + + + vehicle_lance_movement + false + + + case_pilot_damage + false + + + paratroopers + false + + diff --git a/megamek/docs/Scenarios/ScenarioV2 HowTo.mms b/megamek/docs/Scenarios/ScenarioV2 HowTo.mms index 7461766df39..984e5de0416 100644 --- a/megamek/docs/Scenarios/ScenarioV2 HowTo.mms +++ b/megamek/docs/Scenarios/ScenarioV2 HowTo.mms @@ -135,13 +135,18 @@ map: # obviously, at least one of newterrain and newlevel must be given # Optional: game options -# when not given, user-set options are used -options: # default: MM's default options +# when not given, the options from the latest game are used +options: #from: Example_options.xml - #fixed: no # default: yes; in this case, the Game Options Dialog is - # not shown before the scenario starts - # Activate options by listing them; the values must be those from OptionsConstants, as used for the game type - - double_blind + file: Example_options.xml + # The file is always loaded first, the following list overrides individual settings + on: + # Activate options by listing them; the values must be those from OptionsConstants, as used for the game type + - double_blind + - single_blind_bots + off: + # Deactivate settings + - tacops_fatigue # Planetary Conditions ----------------------------------------------------------------------------------- diff --git a/megamek/src/megamek/common/scenario/ScenarioV2.java b/megamek/src/megamek/common/scenario/ScenarioV2.java index 1d5de9b8782..59b12cab8d5 100644 --- a/megamek/src/megamek/common/scenario/ScenarioV2.java +++ b/megamek/src/megamek/common/scenario/ScenarioV2.java @@ -60,6 +60,9 @@ public class ScenarioV2 implements Scenario { private static final String MAPS = "maps"; private static final String UNITS = "units"; private static final String OPTIONS = "options"; + private static final String OPTIONS_FILE = "file"; + private static final String OPTIONS_ON = "on"; + private static final String OPTIONS_OFF = "off"; private static final String OBJECTS = "objects"; private static final String MESSAGES = "messages"; private static final String END = "end"; @@ -220,18 +223,22 @@ private void parsePlayers(IGame game) throws ScenarioLoaderException, IOExceptio private void parseOptions(IGame game) { game.getOptions().initialize(); - if (node.has(PARAM_GAME_OPTIONS_FILE)) { - File optionsFile = new File(scenariofile.getParentFile(), node.get(PARAM_GAME_OPTIONS_FILE).textValue()); - game.getOptions().loadOptions(optionsFile, true); - } else { - game.getOptions().loadOptions(); - } if (node.has(OPTIONS)) { JsonNode optionsNode = node.get(OPTIONS); - if (optionsNode.isArray()) { - optionsNode.iterator().forEachRemaining(n -> game.getOptions().getOption(n.textValue()).setValue(true)); - } else if (optionsNode.isTextual()) { - game.getOptions().getOption(optionsNode.textValue()).setValue(true); + if (optionsNode.has(OPTIONS_FILE)) { + File optionsFile = new File(scenariofile.getParentFile(), optionsNode.get(OPTIONS_FILE).textValue()); + game.getOptions().loadOptions(optionsFile, true); + } else { + game.getOptions().loadOptions(); + } + + if (optionsNode.has(OPTIONS_ON)) { + JsonNode onNode = optionsNode.get(OPTIONS_ON); + onNode.iterator().forEachRemaining(n -> game.getOptions().getOption(n.textValue()).setValue(true)); + } + if (optionsNode.has(OPTIONS_OFF)) { + JsonNode offNode = optionsNode.get(OPTIONS_OFF); + offNode.iterator().forEachRemaining(n -> game.getOptions().getOption(n.textValue()).setValue(false)); } } }