3. Mission parser¶
Note
MissionParser
is responsible for parsing
whole mission files or sequences of strings which look like mission definition.
This parser detects sections in the stream of strings, selects a proper parser
for a certain section and combines results from all parsers into a single
whole. The output of this parser is a dict
.
Since many sections are optional (e.g., a list of moving ground units, their
routes, a list of available aircrafts at airfields, etc.) and some sections
may not be available in previous versions of the game (e.g., MDS
), so
we cannot talk about a clear and predefined structure of parser’s result.
To understand what may be in the output, it will be much easier and
clearer to use project’s demo.
Here we will go through the very principles on which the final result is formed. It may contain the following elements:
Example of parser result:
{
'location_loader': 'Slovakia/load_online.ini',
'player': {
'aircraft_index': 0,
'belligerent': Belligerents.red,
'fixed_weapons': False,
'flight_id': None,
},
'targets': [
{
'type': TargetTypes.recon,
'priority': TargetPriorities.secondary,
'in_sleep_mode': True,
'delay': 50,
'requires_landing': False,
'pos': Point2D(133978.0, 87574.0),
'radius': 1150,
},
{
'type': TargetTypes.recon,
'priority': TargetPriorities.primary,
'in_sleep_mode': True,
'delay': 40,
'requires_landing': True,
'pos': Point2D(134459.0, 85239.0),
'radius': 300,
'object': {
'waypoint': 0,
'id': '1_Chief',
'pos': Point2D(134360.0, 85346.0),
},
},
],
'conditions': {
'time_info': {
'date': datetime.date(1945, 4, 5),
'time': datetime.time(10, 0),
'is_fixed': False,
},
'meteorology': {
'cloud_base': 1300,
'gust': Gust.none,
'turbulence': Turbulence.none,
'weather': Conditions.hazy,
'wind': {
'direction': 180.0,
'speed': 2.0,
},
},
'communication': {
'ai_radio_silence': False,
'tower_communication': True,
'vectoring': True,
},
'scouting': {
'only_scouts_complete_targets': False,
'scouts_affect_radar': False,
'ships_affect_radar': False,
},
'respawn_time': {
'artillery': 1000000,
'balloons': 1000000,
'searchlights': 1000000,
'ships': {
'big': 1000000,
'small': 1000000,
},
},
'radar': {
'advanced_mode': False,
'refresh_interval': 0,
'scouts': {
'alpha': 5,
'max_height': 1500,
'max_range': 2,
},
'ships': {
'big': {
'max_height': 5000,
'max_range': 100,
'min_height': 100,
},
'small': {
'max_height': 2000,
'max_range': 25,
'min_height': 0,
},
},
},
'home_bases': {
'hide_ai_aircrafts_after_landing': False,
'hide_players_count': False,
'hide_unpopulated': True,
},
'crater_visibility_muptipliers': {
'gt_1000kg': 1.0,
'le_1000kg': 1.0,
'le_100kg': 1.0,
},
},
'objects': {
'moving_units': [
{
'id': '0_Chief',
'type': UnitTypes.train,
'code': 'Germany_CargoTrainA/AA',
'belligerent': Belligerents.blue,
'route': [
GroundRoutePoint(
pos=Point2D(21380.02, 41700.34),
is_checkpoint=True,
delay=10,
section_length=2,
speed=11.0,
),
GroundRoutePoint(
pos=Point2D(21500.00, 41700.00),
is_checkpoint=False,
),
],
},
],
'flights': [
{
'ai_only': False,
'air_force': AirForces.luftwaffe,
'aircrafts': [
{
'index': 0,
'has_markings': True,
'skill': Skills.ace,
},
],
'code': 'Do217_K2',
'count': 1,
'flight_index': 0,
'fuel': 100,
'id': 'g0100',
'regiment': None,
'squadron_index': 0,
'weapons': 'default',
'with_parachutes': True,
'route': [
FlightRouteTakeoffPoint(
type=RoutePointTypes.takeoff_normal,
pos=Point3D(193373.53, 99288.17, 0.0),
speed=0.0,
formation=None,
radio_silence=False,
delay=10,
spacing=20,
),
FlightRoutePoint(
type=RoutePointTypes.landing_straight,
pos=Point3D(185304.27, 54570.12, 0.00),
speed=0.00,
formation=None,
radio_silence=True,
),
],
},
],
'home_bases': [
{
'belligerent': Belligerents.red,
'friction': {
'enabled': False,
'value': 3.8,
},
'pos': Point2D(151796.0, 71045.0),
'radar': {
'max_height': 5000,
'min_height': 0,
'range': 50,
},
'range': 3000,
'show_default_icon': False,
'spawning': {
'aircraft_limitations': {
'allowed_aircrafts': [
{
'code': 'Il-2_3',
'limit': None,
'weapon_limitations': [
'4xRS82',
'4xBRS82',
'4xRS132',
]
},
{
'code': 'Il-2_M3',
'limit': None,
'weapon_limitations': [
'4xBRS132',
'4xM13',
'216xAJ-2',
],
},
],
'consider_lost': True,
'consider_stationary': True,
'enabled': True,
},
'allowed_air_forces': [
AirForces.vvs_rkka,
],
'enabled': True,
'in_air': {
'conditions': {
'always': False,
'if_deck_is_full': False,
},
'heading': 0,
'height': 1000,
'speed': 200,
},
'in_stationary': {
'enabled': False,
'return_to_start_position': False,
},
'max_pilots': 0,
'with_parachutes': True,
},
},
],
'stationary': [
StationaryObject(
belligerent=Belligerents.none,
id='6_Static',
code='Smoke20',
pos=Point2D(151404.61, 89009.57),
rotation_angle=0.00,
type=UnitTypes.stationary,
),
],
'buildings': [
Building(
id='0_bld',
belligerent=Belligerents.red,
code='Tent_Pyramid_US',
pos=Point2D(43471.34, 57962.08),
rotation_angle=270.00,
),
],
'cameras': [
StaticCamera(
belligerent=Belligerents.blue,
pos=Point3D(38426.0, 65212.0, 35.0),
),
],
'markers': [
FrontMarker(
id='FrontMarker0',
belligerent=Belligerents.red,
pos=Point2D(7636.65, 94683.02),
),
],
'rockets': [
Rocket(
id='0_Rocket',
code='Fi103_V1_ramp',
belligerent=Belligerents.blue,
pos=Point2D(84141.38, 114216.82),
rotation_angle=0.00,
delay=60.0,
count=10,
period=80.0,
destination=Point2D(83433.91, 115445.49),
),
],
},
}
3.1. location_loader¶
Contains name of location loader which is defined in MAIN section. Usually this element is always present.
3.2. player¶
Contains a dict
with information about player which is defined in
MAIN section. Usually this element is always present.
3.3. targets¶
Contains a list of targets which are defined in Target section.
3.4. conditions¶
Contains a dict
with information about different conditions in
mission:
3.4.1. time_info¶
A dict
with information about date and time from MAIN section
and SEASON section.
3.4.2. meteorology¶
A dict
with information about meteorology from MAIN section
and WEATHER section.
3.4.3. scouting¶
A dict
with information about scouting from MDS section. Can
also contain lists of scouts separately per each belligerent
(see MDS_Scouts section).
3.4.4. respawn_time¶
Contains result of parsing RespawnTime section.
3.4.5. radar¶
Contains common settings for radars from MDS section.
3.4.6. communication¶
Contains common communication settings from MDS section.
3.4.7. home_bases¶
Contains common settings for home bases from MDS section.
3.4.8. crater_visibility_muptipliers¶
Contains settings for craters visibility from MDS section.
3.5. objects¶
A dict
which contains lists of objects defined in mission:
3.5.1. moving_units¶
List of moving ground units which is defined in Chiefs section. Each unit also contains own route which is defined in Chief Road section.
3.5.2. flights¶
List of AI flights. Information is taken from Flight info sections which are listed in Wing section. Each flight also contains own route which is defined in Flight route section.
3.5.3. home_bases¶
List of airfields which are defined in BornPlace sections. Airfields also may contain information about allowed air forces from BornPlace air forces sections and information about allowed aircrafts from BornPlace aircrafts sections.
3.5.4. stationary¶
List of stationary objects defined in NStationary section.
3.5.5. buildings¶
List of buildings defined in Buildings section.
3.5.6. cameras¶
List of stationary cameras defined in StaticCamera section.
3.5.7. markers¶
List of frontline markers defined in FrontMarker section.
3.5.8. rockets¶
List of rockets defined in Rocket section.