<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.hoggitworld.com/index.php?action=history&amp;feed=atom&amp;title=Mission_Scripting_Foundation_Documentation</id>
		<title>Mission Scripting Foundation Documentation - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.hoggitworld.com/index.php?action=history&amp;feed=atom&amp;title=Mission_Scripting_Foundation_Documentation"/>
		<link rel="alternate" type="text/html" href="https://wiki.hoggitworld.com/index.php?title=Mission_Scripting_Foundation_Documentation&amp;action=history"/>
		<updated>2026-04-29T16:53:29Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://wiki.hoggitworld.com/index.php?title=Mission_Scripting_Foundation_Documentation&amp;diff=91&amp;oldid=prev</id>
		<title>Grimes: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.hoggitworld.com/index.php?title=Mission_Scripting_Foundation_Documentation&amp;diff=91&amp;oldid=prev"/>
				<updated>2018-04-12T00:12:12Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Current release: 1.02&lt;br /&gt;
&lt;br /&gt;
[http://forums.eagle.ru/showthread.php?t=96572 ED Forums Thread] For discussion and downloads of current version.&lt;br /&gt;
&lt;br /&gt;
[[msfChangelog|MSF Changelog]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
This is transcribed from an auto-translation of the original Russian msf_mission_developers_guide.pdf documentation &lt;br /&gt;
Original Documention is available at the ED Forums thread linked above. &lt;br /&gt;
&lt;br /&gt;
This is a WIP 14/54 pages completed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Who should read this guide? ==&lt;br /&gt;
This guide is intended for developers using DCS World, who want to expand the standard features by means of the Simulator Scripting Engine (SSE) and this add-on script engine framework called the Mission Scripting Foundation (MSF).&lt;br /&gt;
&lt;br /&gt;
=== Assumed Knowledge ===&lt;br /&gt;
* Knowledge of the programming language Lua, Lexical conventions, Basic types, Expressions and operators, Scope&lt;br /&gt;
* The basic types, classes, methods and properties provided by SSE. &lt;br /&gt;
* Understanding the principles of programming ?Event Based Progamming Model? &lt;br /&gt;
* The Mission Editor (ME)&lt;br /&gt;
&lt;br /&gt;
=== General Guidelines for script for DCS World ===&lt;br /&gt;
* The texts of all the scripts used in the DCS World have to be encoded UTF8 without BOM. &lt;br /&gt;
* Names of groups and units for use with Mission Scripting Foundation, should meet the [http://www.lua.ru/doc/2.1.html]Lua:lexical naming conventions of Lua]&lt;br /&gt;
* Any script running under SSE is blocked; (does not return to DCS World until a result) so a hung script to hang the entire server and a slow script can slow the entire server.&lt;br /&gt;
* Heavy calculations in terms of performance should be distributed in time. &lt;br /&gt;
* Return code should be less than the frame period for an average FPS (at 30 FPS this is 22.5 ms). &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of the Mission Scripting Foundation ==&lt;br /&gt;
&lt;br /&gt;
Mission Scripting Foundation (MSF) - gives developers of SSE missions a working framework and examples of framework functionality that can be applied in missions to give; scripted behaviours to units, dynamic generation of groups and virtual-groups, interaction with and command of units and group/virtual-group enities to the end goal of creating intelligent air defense, dynamic artillery, dynamic logisitcs and transport systems, and many more possibilities. &lt;br /&gt;
&lt;br /&gt;
 MSF is developed on the basis of the script engine SSE, it relies on capabilities available in SSE. &lt;br /&gt;
&lt;br /&gt;
=== MSF Architecture ===&lt;br /&gt;
Mission Scripting Foundation provides functionality via the namespace mission.&lt;br /&gt;
&lt;br /&gt;
In turn, mission includes the following three components: &lt;br /&gt;
#'''mission.model''' is a structured meta-table of information about all the entities (objects). The model provides as close to a real-time table of the mission state as possible. The mission.model can take entities populated in the Mission Editor and dynamically add new functionality to create new model objects.&lt;br /&gt;
# '''mission.controller''' component provides a model to interact directly with the player as controller by using interfaces in the game such as the F10 Radio Menu, and text chat messages. When calling the respective controller methods in scripts. The mission.controller provides functions to start\stop the refresh cycle model and to route messages and audio transmissions to specific groups, countries and coalitions.&lt;br /&gt;
# '''mission.view''' component provides a table that is a queue of text messages for recipients virtual-groups\groups\coalitions\countries and allows for the playback of queued audio messages for virtual-groups\groups\coalitions\countries recipients. Components rely on the MSF mission.model because they require the meta-table. &lt;br /&gt;
# '''mission.utils''' component is a namespace that includes a set of various useful functions&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Using MSF ==&lt;br /&gt;
Step by step instruction for using in mission.&lt;br /&gt;
#'''Download''' the [[#top | latest versions of the script]]&lt;br /&gt;
# '''Load MSF.lua''' script  or MSF_beta_xxx.lua with trigger at start of mission.&lt;br /&gt;
#'''Initialize''' the state of the MSF mission.model &lt;br /&gt;
##'''Identify objects''' in the mission that you want to augment and communicate with via MSF.&lt;br /&gt;
##'''Add objects''' (by unit name or group name) to the mission.model using a basic MSF method called [[#addUnit | mission.model:addUnit()]] and use  advanced methods like [[#addAirDefenceGroupment | mission.model.addAirDefenceGroupment()]] to group units and attach event handlers related to air defence roles. You can write your own advanced methods using existing methods as a guide. Advanced methods and object types are described further in this document. ''Depending on the complexity of the mission and the behaviors programmed, the initialization script may be contained in a single lua file  or divided logically into several files. Example: ground_defense_init.lua, air_defense_init.lua, transport_init.lua etc ...''&lt;br /&gt;
##'''Optional: Add sound''' objects for use by MSF event handlers (for automatically generating speech events between units and groups). Use the [[#addSound | mission.model:addSound()]] method for each sound object you want to add. Put the list into an initialization file.&lt;br /&gt;
# '''Start Process'''. After adding objects the developer must call the [[#start | mission.controller:start()]] method that updates the mission table structure and begins the MSF processing loop. MSF constantly updates the status of the objects included in the mission.model. When an object's state changes, MSF gives notice in the form of events. MSF gives developers the opportunity to link these events with higher logic that can modify the course of the mission or the behavior of the objects involved in the mission. The most significant task the developer must perform is to determine what events need to be monitored and what objects require in terms of their role and what actions to perform.&lt;br /&gt;
# '''Mission completion'''. Mission end conditions are met then call [[#stop | mission.controller:stop()]] method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Utility functions of MSF ==&lt;br /&gt;
&lt;br /&gt;
Here we will describe available developmer tools in MSF that provide a utility function for use inside larger scripts. These utlity functions are widely used in examples further on in this documentation so familiarity with them will be helpful&lt;br /&gt;
&lt;br /&gt;
All utility  functions implemented in MSF are found in namespace: mission.utils&lt;br /&gt;
&lt;br /&gt;
We will list these functions, provide descriptions and examples of use. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getDistance(_point1,_point2)'''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' _point1 and _point2 are Vec3 points&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' returns Number in meters&lt;br /&gt;
&lt;br /&gt;
'''Example:'''&amp;lt;pre&amp;gt;&lt;br /&gt;
local _point1 = { x = ­100, y = 50, z = 400 };&lt;br /&gt;
local _point2 = { x = ­104, y = 51, z = 401 };&lt;br /&gt;
local _result = mission.utils.getDistance(_point1, _point2);&lt;br /&gt;
trigger.action.outText ('Distance between two points:' .. string.format (&amp;quot;% .3f&amp;quot;, _result), 15);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; The distance between the points: 4.123&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getHeading(_position)'''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' _position is an SSE Pos3 type --position and orientation&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' Number - as heading in degrees&lt;br /&gt;
&lt;br /&gt;
'''Example:''' Get the azimuth of an object with name Shilka.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local _shilka = Unit.getByName('Shilka'); then get position and orientation&lt;br /&gt;
local _shilka_position = _shilka:getPosition(); then azimuth&lt;br /&gt;
local _azimuth = mission.utils.getHeading (_shilka_position); &lt;br /&gt;
trigger.action.outText('Azimuth Shilka: ' .. string.format(“%.3f”, _azimuth));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.transformPoint(_position,_local_point)'''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' &lt;br /&gt;
_position is the position and orientation of a vehicle in a SSE Pos3 type&lt;br /&gt;
_local_point is point in space in a SSE Vec3 type&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' Vec3 --global point&lt;br /&gt;
&lt;br /&gt;
'''Example:''' Transform a coordinate from local to the object to the global coordinate system&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local _global_point = mission.utils.transformPoint(_shilka_position, _local_point); &lt;br /&gt;
trigger.action.outText('local point {x = 0, y = 0, z = 1}'..&lt;br /&gt;
'with respect to the unit _shilka ' .. &lt;br /&gt;
'in global co-orindates equals {'..&lt;br /&gt;
' x =' .. String.format(&amp;quot;% .3f&amp;quot;, _global_point.x) ..&lt;br /&gt;
' Y =' .. string.format(&amp;quot;% .3f&amp;quot;, _global_point.y) .. &lt;br /&gt;
' Z =' .. string.format(&amp;quot;% .3f&amp;quot;, _global_point.z) .. '}' ', 15);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' mission.utils.getLogic(Number)'''&lt;br /&gt;
&lt;br /&gt;
'''Arg:''' Number is probability from 0 to 1; &lt;br /&gt;
&lt;br /&gt;
'''Returns:''' Boolean&lt;br /&gt;
&lt;br /&gt;
'''Example:''' None Given&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getEnumItemNameById(Number _enum_value, Table _enum)'''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' &lt;br /&gt;
_enum_value --an index number&lt;br /&gt;
_enum enumeration type --an SSE table&lt;br /&gt;
&lt;br /&gt;
Returns: String --enumerated from table&lt;br /&gt;
&lt;br /&gt;
'''Example:'''&amp;lt;pre&amp;gt;&lt;br /&gt;
Local _shilka = Unit.getByName('Shilka'); --Returns Unit Object&lt;br /&gt;
local _shilka_country = _shilka:getCountry(); --returns Number&lt;br /&gt;
local _shilka_country_name = mission.utils.getEnumItemNameById( _shilka_country, country.id);&lt;br /&gt;
-- retrieves string of country name from SSE table country.id using index&lt;br /&gt;
trigger.action.outText ('Country of Shilka is :' .. _shilka_country_name, 15)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getRCS(_unit_type,_has_external_weapon)'''&lt;br /&gt;
&lt;br /&gt;
''This is a built-in function unique to MSF that uses a lookup table of pre-calculated values to get a more accurate value for Radar Cross Section''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' &lt;br /&gt;
_unit_type is SSE TypeName (only helicopters and aircraft)&lt;br /&gt;
_has_external_weapon is Boolean&lt;br /&gt;
&lt;br /&gt;
'''Example:''' None Given&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getGuidanceAt(_from,_to)'''&lt;br /&gt;
&lt;br /&gt;
'''Args:'''&lt;br /&gt;
_from is object that is the reference for guidance&lt;br /&gt;
_to is object that is the destination&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' Distance in meters, Azimuth in degrees&lt;br /&gt;
&lt;br /&gt;
'''Example:''' &amp;lt;pre&amp;gt;&lt;br /&gt;
local _shilka, _tank = Unit.getByName('Shilka'), Unit.getByName('Tank');&lt;br /&gt;
local _range, _azimuth = mission.utils.getGuidanceAt(_shilka, _tank);&lt;br /&gt;
trigger.action.outText ('azimuth goal Tank:' .. String.format (&amp;quot;% .3f&amp;quot;, _azimuth) .. ', delete:' .. string.format (&amp;quot;% .3f&amp;quot;, _range), 15)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getGuidanceAtAir(Object _from, Object _to)'''&lt;br /&gt;
&lt;br /&gt;
''Provides direction from one object in the air towards another airborne object''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' &lt;br /&gt;
_to is the object that is the target&lt;br /&gt;
_from is the object to recieve directions&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' &lt;br /&gt;
Number -- distance to target in meters&lt;br /&gt;
Number -- deviation in azimuth from present course in degrees (- left|right +)&lt;br /&gt;
Number -- difference in height in meters (- below|above +)&lt;br /&gt;
Number -- speed of convergence in m/s (- diverge|converge +)&lt;br /&gt;
&lt;br /&gt;
'''Example:''' &amp;lt;pre&amp;gt;&lt;br /&gt;
local _figther, _bandit = Unit.getByName('Figther'), Unit.getByName('Bandit');&lt;br /&gt;
local _range, _heading_diff, _altitude_diff, _closing_speed =&lt;br /&gt;
mission.utils.getGuidanceAtAir(_figther, _bandit);&lt;br /&gt;
&lt;br /&gt;
local _heading_dir = 'Right';&lt;br /&gt;
if _heading_diff &amp;lt; 0 then _heading_dir = 'left'; end&lt;br /&gt;
local _altitude_dir = 'above';&lt;br /&gt;
if _altitude_diff &amp;lt; 0 then _altitude_dir = 'below'; end&lt;br /&gt;
local _closing_status = 'Distance unchanged';&lt;br /&gt;
if _closing_speed &amp;lt; 0 then _closing_status = 'diverging'; end&lt;br /&gt;
if _closing_speed &amp;gt; 0 then _closing_status = 'converging'; end&lt;br /&gt;
&lt;br /&gt;
local _targeting_report = 'New target: \n';&lt;br /&gt;
_targeting_report = _targeting_report .. 'range: ' .. string.format(“%.2f”, _range) .. '\n';&lt;br /&gt;
if math.abs(_heading_diff) &amp;gt; 2 then ­­ ignore small course corrections  &lt;br /&gt;
_targeting_report = _targeting_report .. _heading_dir&lt;br /&gt;
.. string.format(“%.1f”, _heading_diff) .. '\n';&lt;br /&gt;
end&lt;br /&gt;
if math.abs(_heading_diff) &amp;gt; 100 then&lt;br /&gt;
­­ ignore altitude differences of less than 100m&lt;br /&gt;
if _altitude_diff &amp;gt; 1000 then _altitude_diff, _ = math.modf(_altitude_diff / 1000); end&lt;br /&gt;
_targeting_report = _targeting_report .. _altitude_dir&lt;br /&gt;
.. string.format(“%.1f”, _altitude_diff) .. '\n';&lt;br /&gt;
end&lt;br /&gt;
_targeting_report = _targeting_report .. _closing_status;&lt;br /&gt;
­­ convey intercept as message&lt;br /&gt;
trigger.action.outText(_targeting_report, 15);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getPYR(_position)'''&lt;br /&gt;
&lt;br /&gt;
''A function for obtaining direction angles, roll and pitch of an object''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' _position is position and orientation Position3 type&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' &lt;br /&gt;
Number Pitch in degrees&lt;br /&gt;
Number Direction in degrees&lt;br /&gt;
Number Roll in Degrees&lt;br /&gt;
&lt;br /&gt;
'''Example:''' Not given&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''[[# | mission.utils.getCargoTemplateByGroupName]](_group_name,_offset_point,_cargo_template)'''&lt;br /&gt;
&lt;br /&gt;
''A function for obtaining a cargo template for use in transportation groups.''&lt;br /&gt;
&lt;br /&gt;
'''Args:''' &lt;br /&gt;
_group_name is the group name from the editor to copy the template from.&lt;br /&gt;
_offset_point is Vec3 point offset from the landing point where the cargo will be positioned &lt;br /&gt;
_cargo_template is an MSF type for cargo templates. This arguement if an empty table will  populated with the correct strcuture. &lt;br /&gt;
&lt;br /&gt;
'''Returns:''' modifies _cargo_template&lt;br /&gt;
&lt;br /&gt;
'''Example:''' MSF Cargo types and examples are given in further chapters.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mission.utils.getGroupDescriptor(_group_name, _point, _unit_table)'''&lt;br /&gt;
&lt;br /&gt;
''A function to create new vehicle groups''&lt;br /&gt;
&lt;br /&gt;
'''Arguments:'''&lt;br /&gt;
_group_name is a group name which will be created. Should not already exist.&lt;br /&gt;
_point is a Vec3 point at which the group will be created&lt;br /&gt;
_unit_table is a MSF type table of units that should be included in new group. msfUnitDescriptor structure is described in future chapter on the msfGroup class.&lt;br /&gt;
&lt;br /&gt;
'''Returns:''' modifies mission databases&lt;br /&gt;
&lt;br /&gt;
== BITWISE operations ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
WIP &lt;br /&gt;
14/54 pages completed&lt;br /&gt;
Haven't even got near the good stuff yet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Grimes</name></author>	</entry>

	</feed>