dcs.mission module¶
The mission module is the entry point to all pydcs functions.
-
class
dcs.mission.
StartType
¶ Bases:
enum.Enum
Enum class for start types.
-
Cold
= None¶ Coldstart from ramp.
-
Warm
= None¶ Warmstart from ramp.
-
Runway
= None¶ Start from runway.
-
static
from_string
(s: str)¶ Returns the StartType enum for a string value.
[“cold”, “warm”, “runway”]
Parameters: s – string representation of the starttype Returns: the correct StartType.
-
-
class
dcs.mission.
Mission
(terrain: typing.Union=None)¶ Bases:
object
This class represents the whole dcs .miz file.
A .miz file is a zip file containing all needed files to run a mission. example.miz:
- mission
- options
- warehouses
- i10n
- DEFAULT
- dictionary
- mapResource
- [localized resource files, .wav, .jpg, ...]
Parameters: terrain – the used terrain for this mission. -
season_from_start_time
= None¶ If set to True the mission season will be set by the value of
Mission.start_time
-
load_file
(filename: str)¶ Load a mission file (.miz) file, replacing all current data.
Parameters: filename – path to the mission(.miz) file. Returns: True if everything loaded correctly Return type: bool Raises: RuntimeError
– if an unknown value is encountered
-
sortie_text
() → str¶ Returns the mission sortie text.
Returns: the mission sortie text
-
set_sortie_text
(text: str)¶ Sets the mission sortie text.
Parameters: text – text to set.
-
description_text
() → str¶ Returns the mission description text.
Returns: the mission description text
-
set_description_text
(text: str)¶ Sets the mission descsription text.
Parameters: text – text to set.
-
description_bluetask_text
() → str¶ Returns the blue task description text.
Returns: the blue task description text
-
set_description_bluetask_text
(text: str)¶ Sets the red coalitions task description text.
Parameters: text – text to set.
-
description_redtask_text
() → str¶ Returns the red task description text.
Returns: the red task description text
-
set_description_redtask_text
(text: str)¶ Sets the red coalitions task description text.
Parameters: text – text to set.
-
add_picture_red
(filepath: str) → str¶ Adds a new briefing picture to the red coalition.
Parameters: filepath – path to the image, jpg or bmp. Returns: the resource key of the picture
-
add_picture_blue
(filepath: str) → str¶ Adds a new briefing picture to the blue coalition.
Parameters: filepath – path to the image, jpg or bmp. Returns: the resource key of the picture
-
next_group_id
()¶ Get the next free group id
Returns: a new group id
-
next_unit_id
()¶ Get the next free unit id
Returns: a new unit id
-
next_dict_id
()¶ Get the next free dictionary id
Returns: a new dictionary id
-
eplrs_for
(group: str) → typing.Dict¶ Searches all vehicle eplrs using groups and writes them in a mapping
Parameters: group – which group to look for eplrs task, [“helicopter”, “plane”, “vehicle”] Returns: a dict mapping groups to used eplrs id
-
next_eplrs
(group_type: str) → int¶ Get next eplrs for the given group type.
Parameters: group_type – one of “vehicle”, “helicopter” or “plane” Returns: the next eplrs id to use Return type: int
-
string
(s, lang='DEFAULT')¶ Create a new String() object for translation
Parameters: - s – string for lang
- lang – language for s
Returns: A new String() object for string s
Return type:
-
static
(name, _type: dcs.unittype.UnitType) → dcs.unit.Static¶ Creates a plain static object to be added to a group
Parameters: - name – of the static object
- _type (StaticType) – type of the static
Returns: a new static object
Return type:
-
static_group
(country, name, _type: dcs.unittype.UnitType, position: dcs.mapping.Point, heading=0, hidden=False, dead=False)¶ Add a static group with 1 static object.
Parameters: - country (Country) – the object belongs too
- name – name of the group
- _type – what kind of object
- position (dcs.mapping.Point) – where to place the object
- heading – of the object
- hidden – should the object be hidden on the map
- dead – should the object be rendered as dead
Returns: the new static group
Return type:
-
vehicle
(name, _type: dcs.unittype.VehicleType) → dcs.unit.Vehicle¶ Creates a plain vehicle unit to be added to a group
Parameters: - name – of the vehicle
- _type – vehicle type
Returns: a new vehicle unit.
Return type:
-
vehicle_group
(country, name, _type: dcs.unittype.VehicleType, position: dcs.mapping.Point, heading=0, group_size=1, formation=<Formation.Line: 1>, move_formation: dcs.point.PointAction=<PointAction.OffRoad: 'Off Road'>) → dcs.unitgroup.VehicleGroup¶ Adds a new vehicle group to the given country.
Parameters: country – which the vehicle group will belong too Returns: the new vehicle group object Return type: VehicleGroup
-
vehicle_group_platoon
(country, name, types: typing.List, position: dcs.mapping.Point, heading=0, formation=<Formation.Line: 1>, move_formation: dcs.point.PointAction=<PointAction.OffRoad: 'Off Road'>) → dcs.unitgroup.VehicleGroup¶ Adds a new vehicle group to the given country and given vehicle types.
Parameters: country – which the vehicle group will belong too Returns: the new vehicle group object Return type: VehicleGroup
-
ship
(name, _type: dcs.unittype.ShipType) → dcs.unit.Ship¶ Creates a plain ship unit to be added to a group
Parameters: - name – of the ship
- _type – ship type
Returns: a new ship unit.
Return type:
-
ship_group
(country, name, _type: dcs.unittype.ShipType, position: dcs.mapping.Point, heading=0, group_size=1) → dcs.unitgroup.ShipGroup¶ Adds a ship group to the given country.
Parameters: - country (Country) – which the ship group will belong too
- name – of the ship group
- _type – which kind of ship to add
- position (dcs.mapping.Point) – where the new group will be placed
- heading – initial heading of the group, only used if no additional waypoints
- group_size – how many ships of _type
Returns: the new ship group object
Return type:
-
plane_group
(name) → dcs.unitgroup.PlaneGroup¶ This creates a plain plane group without any units or starting points.
This method is a advanced interface method not intended for simple use. For adding full featured plane group see
Parameters: name – Group name Returns: A new dcs.unitgroup.PlaneGroup
Return type: PlaneGroup
-
plane
(name, _type: dcs.planes.PlaneType, country: dcs.country.Country)¶ Creates a new plane unit.
This method is a advanced interface method not intended for simple usage. For adding full a featured plane group see
Parameters: - name – unit name
- _type – type of the plane
- country (Country) – the plane belongs, needed for default liveries
Returns: A new
dcs.unit.Plane
Return type:
-
helicopter
(name, _type: dcs.helicopters.HelicopterType, country: dcs.country.Country)¶ Creates a new helicopter unit.
This method is a advanced interface method not intended for simple usage. For adding full a featured helicopter group see
Parameters: - name – unit name
- _type – type of the helicopter
- country (Country) – the helicopter belongs, needed for default liveries
Returns: A new
dcs.unit.Helicopter
Return type:
-
aircraft
(name, _type: dcs.unittype.FlyingType, country: dcs.country.Country) → typing.Union¶ Creates a new plane or helicopter unit, depending on the _type.
This method is a advanced interface method not intended for simple usage. For adding full a featured plane/helicopter group see
Parameters: - name – unit name
- _type – type of the aircraft
- country (Country) – the aircraft belongs, needed for default liveries
Returns: A new
dcs.unit.Plane
ordcs.unit.Helicopter
Return type:
-
helicopter_group
(name) → dcs.unitgroup.HelicopterGroup¶ Creates a plain helicopter group without any units or starting points.
This method is a advanced interface method not intended for simple usage. For adding a full featured helicopter group see
Parameters: name – Group name Returns: A new dcs.unitgroup.HelicopterGroup
Return type: HelicopterGroup
-
flight_group_inflight
(country, name: str, aircraft_type: dcs.unittype.FlyingType, position: dcs.mapping.Point, altitude: int, speed=None, maintask: typing.Union=None, group_size: int=1) → typing.Union¶ Add a new Plane/Helicopter group inflight.
The type of the resulting group depends on the given aircraft_type.
Parameters: - country (Country) – the new group will belong to
- name – of the new group
- aircraft_type (FlyingType) – type of all units in the group
- position (dcs.mapping.Point) – where the new group will be placed
- altitude – of the new group
- speed – of the new group, if none a default will be picked
- maintask (MainTask) – if none the default task for the aircraft_type wil be used
- group_size – number of units in the group(maximum 4 or 1 for certain types)
Returns: a new
dcs.unitgroup.PlaneGroup
ordcs.unitgroup.HelicopterGroup
Return type:
-
flight_group_from_airport
(country: dcs.country.Country, name, aircraft_type: dcs.unittype.FlyingType, airport: dcs.terrain.terrain.Airport, maintask: dcs.task.MainTask=None, start_type: dcs.mission.StartType=<StartType.Cold: 1>, group_size=1, parking_slots: typing.List=None) → typing.Union¶ Add a new Plane/Helicopter group at the given airport.
Runway, warm/cold start depends on the given start_type.
Parameters: - country (Country) – Country object the plane group belongs to
- name – Name of the aircraft group
- maintask (MainTask) – Task of the aircraft group
- aircraft_type (FlyingType) – FlyingType class that describes the aircraft_type
- airport (Airport) – Airport object on which to spawn the helicopter
- start_type (StartType) – Start from runway, cold or warm parking position
- parking_slots – List of parking slots to use for aircrafts
- group_size – number of units in the group(maximum 4 or 1 for certain types)
Returns: a new
dcs.unitgroup.PlaneGroup
ordcs.unitgroup.HelicopterGroup
Return type:
-
flight_group_from_unit
(country: dcs.country.Country, name, aircraft_type: dcs.unittype.FlyingType, carrier_unit: typing.Union, maintask: dcs.task.MainTask=None, start_type: dcs.mission.StartType=<StartType.Cold: 1>, group_size=1) → typing.Union¶ Add a new Plane/Helicopter group at the given FARP or carrier unit.
Parameters: - country (Country) – Country object the plane group belongs to
- name – Name of the aircraft group
- maintask (MainTask) – Task of the aircraft group
- aircraft_type (FlyingType) – FlyingType class that describes the aircraft_type
- carrier_unit (Unit) – Group(Ship, FARP) on which to spawn
- start_type (StartType) – Start from runway, cold or warm parking position, ignored for now
- group_size – number of units in the group(maximum 4 or 1 for certain types)
Returns: a new
dcs.unitgroup.PlaneGroup
ordcs.unitgroup.HelicopterGroup
Return type:
-
flight_group
(country: dcs.country.Country, name: str, aircraft_type: dcs.unittype.FlyingType, airport: typing.Union, position: typing.Union, altitude=3000, speed=500, maintask: typing.Union=None, start_type: dcs.mission.StartType=<StartType.Runway: 3>, group_size=1) → dcs.unitgroup.FlyingGroup¶ This is wrapper around flight_group_inflight and flight_group_from_airport.
Depending on the airport parameter a flight group will added inflight or on an airport.
Parameters: - country (Country) – Country object the plane group belongs to
- name – Name of the aircraft group
- aircraft_type (FlyingType) – FlyingType class that describes the aircraft_type
- airport (Airport) – Airport object on which to spawn the helicopter
- position (dcs.mapping.Point) – where the new group will be placed, if inflight
- altitude – initial altitude of the group if inflight
- speed – initial speed of the group if inflight
- maintask (MainTask) – Task of the aircraft group
- start_type (StartType) – Start from runway, cold or warm parking position
- group_size – number of units in the group(maximum 4 or 1 for certain types)
Returns: a new
dcs.unitgroup.PlaneGroup
ordcs.unitgroup.HelicopterGroup
Return type:
-
awacs_flight
(country: dcs.country.Country, name: str, plane_type: dcs.planes.PlaneType, airport: typing.Union, position: dcs.mapping.Point, race_distance=30000, heading=90, altitude=4500, speed=550, start_type: dcs.mission.StartType=<StartType.Cold: 1>, frequency=140) → dcs.unitgroup.PlaneGroup¶ Add an AWACS flight group.
This is simple way to add an AWACS flight group to your mission. It needs an initial orbit point, race distance and heading from this point.
If an airport is given the AWACS flight will start from there otherwise, it will placed 2 km in front of the reference position.
Parameters: - country (Country) – Country object the awacs group belongs to
- name – of the AWACS flight
- plane_type (PlaneType) – AWACS plane type. e.g E_3A
- airport (Airport) – starting airport, use None if you want it to spawn inflight
- position (dcs.mapping.Point) – reference point for the race-track
- race_distance – distance for the race-track pattern
- heading – direction from the referene position
- altitude – of the AWACS race-track
- speed – of the AWACS flight
- start_type (StartType) – of the flight if starts from airport
- frequency – VHF-AM frequencey in mhz
Returns: the created AWACS flight group
Return type:
-
refuel_flight
(country, name: str, plane_type: dcs.planes.PlaneType, airport: typing.Union, position: dcs.mapping.Point, race_distance=30000, heading=90, altitude=4500, speed=407, start_type: dcs.mission.StartType=<StartType.Cold: 1>, frequency=140, tacanchannel='10X') → dcs.unitgroup.PlaneGroup¶ Add an refuel flight group.
This is simple way to add an refuel flight group to your mission. It needs an initial orbit point, race distance and heading from this point.
If an airport is given the refuel flight will start from there otherwise, it will placed 2 km in front of the reference position.
Parameters: - country (Country) – Country object the awacs group belongs to
- name – of the refuel flight
- plane_type (PlaneType) – refuel plane type. e.g KC_135
- airport (Airport) – starting airport, use None if you want it to spawn inflight
- position (dcs.mapping.Point) – reference point for the race-track
- race_distance – distance for the race-track pattern
- heading – direction from the referene position
- altitude – of the refuel race-track
- speed – of the refuel flight
- start_type (StartType) – of the flight if starts from airport
- frequency – VHF-AM frequencey in mhz
- tacanchannel – if the PlaneType supports tacan this channel will be set.
Returns: the created refuel flight group
Return type:
-
escort_flight
(country, name: str, escort_type: dcs.planes.PlaneType, airport: typing.Union, group_to_escort: dcs.unitgroup.FlyingGroup, start_type: dcs.mission.StartType=<StartType.Cold: 1>, group_size=2)¶ Add an escort flight group to the mission.
An escort flight is a flight group that will use the
dcs.task.EscortTaskAction
to escort another flight group.If no airport is given, the escort flight will spawn near the group to escort.
Parameters: - country (Country) – the escort flight belongs too
- name – of the flight group
- escort_type (PlaneType) – PlaneType for the escort task
- airport (Airport) – starting airport, use None if you want it to spawn inflight
- group_to_escort – id of the group to escort
- start_type (StartType) – of the flight if starts from airport
- group_size – how many planes should be in the escort flight
Returns: the created escort group
Return type:
-
patrol_flight
(country, name: str, patrol_type: dcs.planes.PlaneType, airport: typing.Union, pos1, pos2, start_type: dcs.mission.StartType=<StartType.Cold: 1>, speed=600, altitude=4000, max_engage_distance=60000, group_size=2)¶ Add an patrol flight group to the mission.
A patrol flight is a flight group that will fly a orbit between 2 given points and will engage any incoming air threats within max_engage_distance.
If no airport is given, the patrol flight will spawn near the first patrol point(pos1).
Parameters: - country (Country) – the flight belongs too
- name – name of the patrol flight
- patrol_type (PlaneType) – PlaneType for the patrol flight
- airport (Airport) – starting airport, use None if you want it to spawn inflight
- pos1 (dcs.mapping.Point) – first orbit waypoint
- pos2 (dcs.mapping.Point) – second orbit waypoint
- start_type (StartType) – of the flight if starts from airport
- speed – orbit speed
- altitude – initial altitude and orbit altitude
- max_engage_distance – the distance in KM the patrol flight will respond to enemy threats
- group_size – how many planes should be in the flight group
Returns: the created patrol group
Return type:
-
country
(name)¶ Returns the country object for the mission by the given string
Parameters: name – string representation of the country Returns: the object of the country, None if not found. Return type: Country
-
find_group
(group_name, search='exact') → typing.Union¶ Searches a group with the given name.
Parameters: - group_name – part or exact name of the group
- search –
search mode to use
- ‘exact’: whole name must match
- ‘match’: part of the name must match
Returns: the group found, otherwise None
Return type:
-
is_red
(country: dcs.country.Country) → bool¶ Checks if the given country object is part o the red coalition.
Parameters: country (Country) – object to check Returns: True if it is part of the red coalition, else False. Return type: bool
-
is_blue
(country: dcs.country.Country) → bool¶ Checks if the given country object is part o the blue coalition.
Parameters: country (Country) – object to check Returns: True if it is part of the blue coalition, else False. Return type: bool
-
stats
() → typing.Dict¶ Gather some mission stats.
This method counts up the different group types and used units and returns them as easy to print dict.
Returns: dict containing various group and unit counts.
-
print_stats
(d)¶ Print the given mission stats to standard output.
Parameters: d – stats dict to print, dcs.mission.Mission.stats()
-
reload
()¶ Reloads the current loaded file
Raises: RuntimeError
– if there is currently no file loaded.
-
save
(filename=None)¶ Save the current Mission object to the given file.
Parameters: - filename – filepath to save the Mission object
- show_stats (bool) – if True print mission stats to standard out.
-
dict
()¶
-
class
dcs.mission.
MapResource
(mission: dcs.mission.Mission)¶ Bases:
object
MapResource is responsibly to manage all additional mission resource files.
Mission resource files are briefing images, lua scripts, sounds files.
Parameters: mission (Mission) – the mission this MapResource belongs too, needed for dictionary ids -
load_from_dict
(_dict, zipf: zipfile.ZipFile, lang='DEFAULT')¶
-
add_resource_file
(filepath, lang='DEFAULT', key=None)¶ Adds a file to the mission resource depot.
Parameters: - filepath – path to the file to add
- lang – language this file belongs too.
- key – should None, needed for loading
Returns: resource key to use in scripts
-
store
(zipf: zipfile.ZipFile, lang='DEFAULT')¶
-