Applied proper documentation

This commit is contained in:
FlightControl 2016-04-30 07:22:48 +02:00
parent 0990e34fef
commit 6a28902305
11 changed files with 1038 additions and 299 deletions

View File

@ -73,6 +73,12 @@
<td class="name" nowrap="nowrap"><a href="#CoalitionObject">CoalitionObject</a></td> <td class="name" nowrap="nowrap"><a href="#CoalitionObject">CoalitionObject</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="#coalition">coalition</a></td>
<td class="summary">
</td> </td>
</tr> </tr>
</table> </table>
@ -88,6 +94,38 @@
<td class="name" nowrap="nowrap"><a href="##(CoalitionObject).getCountry">CoalitionObject:getCountry()</a></td> <td class="name" nowrap="nowrap"><a href="##(CoalitionObject).getCountry">CoalitionObject:getCountry()</a></td>
<td class="summary"> <td class="summary">
<p>Returns object country.</p> <p>Returns object country.</p>
</td>
</tr>
</table>
<h2><a id="#(coalition)">Type <code>coalition</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(coalition).side">coalition.side</a></td>
<td class="summary">
</td>
</tr>
</table>
<h2><a id="#(coalition.side)">Type <code>coalition.side</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(coalition.side).BLUE">coalition.side.BLUE</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(coalition.side).NEUTRAL">coalition.side.NEUTRAL</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(coalition.side).RED">coalition.side.RED</a></td>
<td class="summary">
</td> </td>
</tr> </tr>
</table> </table>
@ -105,6 +143,20 @@
</dd>
</dl>
<dl class="function">
<dt>
<em><a href="##(coalition)">#coalition</a></em>
<a id="coalition" >
<strong>coalition</strong>
</a>
</dt>
<dd>
</dd> </dd>
</dl> </dl>
<h2><a id="#(DCSCoalitionObject)" >Type <code>DCSCoalitionObject</code></a></h2> <h2><a id="#(DCSCoalitionObject)" >Type <code>DCSCoalitionObject</code></a></h2>
@ -124,7 +176,7 @@
<h3>Return value</h3> <h3>Return value</h3>
<p><em><a href="##(coalition.side)">#coalition.side</a>:</em></p> <p><em><a href="DCSTypes.html##(coalition.side)">DCSTypes#coalition.side</a>:</em></p>
</dd> </dd>
@ -145,10 +197,67 @@
<p><em><a href="##(country.id)">#country.id</a>:</em></p> <p><em><a href="##(country.id)">#country.id</a>:</em></p>
</dd>
</dl>
<h2><a id="#(coalition)" >Type <code>coalition</code></a></h2>
<h3>Field(s)</h3>
<dl class="function">
<dt>
<em><a href="##(coalition.side)">#coalition.side</a></em>
<a id="#(coalition).side" >
<strong>coalition.side</strong>
</a>
</dt>
<dd>
</dd> </dd>
</dl> </dl>
<h2><a id="#(coalition.side)" >Type <code>coalition.side</code></a></h2> <h2><a id="#(coalition.side)" >Type <code>coalition.side</code></a></h2>
<h3>Field(s)</h3>
<dl class="function">
<dt>
<a id="#(coalition.side).BLUE" >
<strong>coalition.side.BLUE</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(coalition.side).NEUTRAL" >
<strong>coalition.side.NEUTRAL</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(coalition.side).RED" >
<strong>coalition.side.RED</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<h2><a id="#(country.id)" >Type <code>country.id</code></a></h2> <h2><a id="#(country.id)" >Type <code>country.id</code></a></h2>

View File

@ -68,7 +68,70 @@
<p>Administers the Initial Sets of the Mission Templates as defined within the Mission Editor.</p> <p>Administers the Initial Sets of the Mission Templates as defined within the Mission Editor.</p>
<p>Administers the Spawning of new Groups within the DCSRTE and administers these new Groups within the DATABASE object(s).</p> <p>Mission designers can use the DATABASE class to build sets of units belonging to certain:</p>
<ul>
<li>coalitions</li>
<li>categories</li>
<li>countries</li>
<li>unit types</li>
<li>starting with certain prefix strings.</li>
</ul>
<p> Note that this is an initial filter set. More to follow, like zones etc.</p>
<h1>DATABASE construction methods:</h1>
<p>Create a new DATABASE object with the <a href="##(DATABASE).New">DATABASE.New</a> method:</p>
<ul>
<li><a href="##(DATABASE).New">DATABASE.New</a>: Creates a new DATABASE object.</li>
</ul>
<h1>DATABASE filter criteria: </h1>
<p>You can set filter criteria to define the set of units within the database.
Filter criteria are defined by:</p>
<ul>
<li><a href="##(DATABASE).FilterCoalitions">DATABASE.FilterCoalitions</a>: Builds the DATABASE with the units belonging to the coalition(s).</li>
<li><a href="##(DATABASE).FilterCategories">DATABASE.FilterCategories</a>: Builds the DATABASE with the units belonging to the category(ies).</li>
<li><a href="##(DATABASE).FilterTypes">DATABASE.FilterTypes</a>: Builds the DATABASE with the units belonging to the unit type(s).</li>
<li><a href="##(DATABASE).FilterCountries">DATABASE.FilterCountries</a>: Builds the DATABASE with the units belonging to the country(ies).</li>
<li><a href="##(DATABASE).FilterUnitPrefixes">DATABASE.FilterUnitPrefixes</a>: Builds the DATABASE with the units starting with the same prefix string(s).</li>
</ul>
<p>Once the filter criteria have been set for the DATABASE, you can start filtering using:</p>
<ul>
<li><a href="##(DATABASE).FilterStart">DATABASE.FilterStart</a>: Starts the filtering of the units within the database.</li>
</ul>
<p>Planned filter criteria within development are (so these are not yet available):</p>
<ul>
<li><a href="##(DATABASE).FilterGroupPrefixes">DATABASE.FilterGroupPrefixes</a>: Builds the DATABASE with the groups of the units starting with the same prefix string(s).</li>
<li><a href="##(DATABASE).FilterZones">DATABASE.FilterZones</a>: Builds the DATABASE with the units within a <a href="Zone.html##(ZONE)">Zone#ZONE</a>.</li>
</ul>
<h1>DATABASE iterators:</h1>
<p>Once the filters have been defined and the DATABASE has been built, you can iterate the database with the available iterator methods.
The iterator methods will walk the DATABASE set, and call for each element within the set a function that you provide.
The following iterator methods are currently available within the DATABASE:</p>
<ul>
<li><a href="##(DATABASE).ForEachAliveUnit">DATABASE.ForEachAliveUnit</a>: Calls a function for each alive unit it finds within the DATABASE.</li>
</ul>
<p>Planned iterators methods in development are (so these are not yet available):</p>
<ul>
<li><a href="##(DATABASE).ForEachUnit">DATABASE.ForEachUnit</a>: Calls a function for each unit contained within the DATABASE.</li>
<li><a href="##(DATABASE).ForEachGroup">DATABASE.ForEachGroup</a>: Calls a function for each group contained within the DATABASE.</li>
<li><a href="##(DATABASE).ForEachUnitInZone">DATABASE.ForEachUnitInZone</a>: Calls a function for each unit within a certain zone contained within the DATABASE.
</li>
</ul>
<h2>Global(s)</h2> <h2>Global(s)</h2>
<table class="function_list"> <table class="function_list">
@ -76,19 +139,13 @@
<td class="name" nowrap="nowrap"><a href="#DATABASE">DATABASE</a></td> <td class="name" nowrap="nowrap"><a href="#DATABASE">DATABASE</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="#_Database">_Database</a></td>
<td class="summary">
</td> </td>
</tr> </tr>
</table> </table>
<h2><a id="#(DATABASE)">Type <code>DATABASE</code></a></h2> <h2><a id="#(DATABASE)">Type <code>DATABASE</code></a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).ActivePlayers">DATABASE.ActivePlayers</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).AlivePlayers">DATABASE.AlivePlayers</a></td>
<td class="summary"> <td class="summary">
</td> </td>
@ -109,6 +166,90 @@
<td class="name" nowrap="nowrap"><a href="##(DATABASE).ClientsByName">DATABASE.ClientsByName</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).ClientsByName">DATABASE.ClientsByName</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).DCSGroups">DATABASE.DCSGroups</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).DCSGroupsAlive">DATABASE.DCSGroupsAlive</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).DCSUnits">DATABASE.DCSUnits</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).DCSUnitsAlive">DATABASE.DCSUnitsAlive</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).Filter">DATABASE.Filter</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterCategory">DATABASE:FilterCategory(Categories)</a></td>
<td class="summary">
<p>Builds a set of units out of categories.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterCoalition">DATABASE:FilterCoalition(Coalitions)</a></td>
<td class="summary">
<p>Builds a set of units of coalitons.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterCountries">DATABASE:FilterCountries(Countries)</a></td>
<td class="summary">
<p>Builds a set of units of defined countries.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterGroupPrefix">DATABASE:FilterGroupPrefix(Prefixes)</a></td>
<td class="summary">
<p>Builds a set of units of defined group prefixes.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterMeta">DATABASE.FilterMeta</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterStart">DATABASE:FilterStart()</a></td>
<td class="summary">
<p>Starts the filtering.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterType">DATABASE:FilterType(Types)</a></td>
<td class="summary">
<p>Builds a set of units of defined unit types.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).FilterUnitPrefix">DATABASE:FilterUnitPrefix(Prefixes)</a></td>
<td class="summary">
<p>Builds a set of units of defined unit prefixes.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).ForEachAliveUnit">DATABASE:ForEachAliveUnit(IteratorFunction, ...)</a></td>
<td class="summary">
<p>Interate the DATABASE and call an interator function for each <strong>alive</strong> unit, providing the Unit and optional parameters.</p>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -132,13 +273,19 @@
<tr> <tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).New">DATABASE:New()</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).New">DATABASE:New()</a></td>
<td class="summary"> <td class="summary">
<p>Creates a new DATABASE Object to administer the Groups defined and alive within the DCSRTE.</p> <p>Creates a new DATABASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).Players">DATABASE.Players</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).Players">DATABASE.Players</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).ScanEnvironment">DATABASE:ScanEnvironment()</a></td>
<td class="summary">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -157,12 +304,42 @@
<td class="name" nowrap="nowrap"><a href="##(DATABASE).Statics">DATABASE.Statics</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).Statics">DATABASE.Statics</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).TraceDatabase">DATABASE:TraceDatabase()</a></td>
<td class="summary">
<p>Traces the current database contents in the log ...</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE).Units">DATABASE.Units</a></td> <td class="name" nowrap="nowrap"><a href="##(DATABASE).Units">DATABASE.Units</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE)._EventOnBirth">DATABASE:_EventOnBirth(Event)</a></td>
<td class="summary">
<p>Handles the OnBirth event for the alive units set.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE)._EventOnDeadOrCrash">DATABASE:_EventOnDeadOrCrash(Event)</a></td>
<td class="summary">
<p>Handles the OnDead or OnCrash event for alive units set.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE)._IsAliveDCSUnit">DATABASE:_IsAliveDCSUnit(DCSUnit)</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(DATABASE)._IsIncludeDCSUnit">DATABASE:_IsIncludeDCSUnit(DCSUnit)</a></td>
<td class="summary">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -186,20 +363,6 @@
</dd>
</dl>
<dl class="function">
<dt>
<em><a href="Database.html##(DATABASE)">Database#DATABASE</a></em>
<a id="_Database" >
<strong>_Database</strong>
</a>
</dt>
<dd>
</dd> </dd>
</dl> </dl>
<h2><a id="#(Database)" >Type <code>Database</code></a></h2> <h2><a id="#(Database)" >Type <code>Database</code></a></h2>
@ -213,8 +376,8 @@
<dt> <dt>
<em></em> <em></em>
<a id="#(DATABASE).ActivePlayers" > <a id="#(DATABASE).AlivePlayers" >
<strong>DATABASE.ActivePlayers</strong> <strong>DATABASE.AlivePlayers</strong>
</a> </a>
</dt> </dt>
<dd> <dd>
@ -263,6 +426,320 @@
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).DCSGroups" >
<strong>DATABASE.DCSGroups</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).DCSGroupsAlive" >
<strong>DATABASE.DCSGroupsAlive</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).DCSUnits" >
<strong>DATABASE.DCSUnits</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).DCSUnitsAlive" >
<strong>DATABASE.DCSUnitsAlive</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).Filter" >
<strong>DATABASE.Filter</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterCategory" >
<strong>DATABASE:FilterCategory(Categories)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units out of categories.</p>
<p>Possible current categories are plane, helicopter, ground, ship.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Categories </em></code>:
Can take the following values: "plane", "helicopter", "ground", "ship".</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterCoalition" >
<strong>DATABASE:FilterCoalition(Coalitions)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units of coalitons.</p>
<p>Possible current coalitions are red, blue and neutral.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Coalitions </em></code>:
Can take the following values: "red", "blue", "neutral".</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterCountries" >
<strong>DATABASE:FilterCountries(Countries)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units of defined countries.</p>
<p>Possible current countries are those known within DCS world.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Countries </em></code>:
Can take those country strings known within DCS world.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterGroupPrefix" >
<strong>DATABASE:FilterGroupPrefix(Prefixes)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units of defined group prefixes.</p>
<p>All the units starting with the given group prefixes will be included within the set.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Prefixes </em></code>:
The prefix of which the group name where the unit belongs to starts with.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(DATABASE).FilterMeta" >
<strong>DATABASE.FilterMeta</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterStart" >
<strong>DATABASE:FilterStart()</strong>
</a>
</dt>
<dd>
<p>Starts the filtering.</p>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterType" >
<strong>DATABASE:FilterType(Types)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units of defined unit types.</p>
<p>Possible current types are those types known within DCS world.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Types </em></code>:
Can take those type strings known within DCS world.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).FilterUnitPrefix" >
<strong>DATABASE:FilterUnitPrefix(Prefixes)</strong>
</a>
</dt>
<dd>
<p>Builds a set of units of defined unit prefixes.</p>
<p>All the units starting with the given prefixes will be included within the set.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string Prefixes </em></code>:
The prefix of which the unit name starts with.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).ForEachAliveUnit" >
<strong>DATABASE:ForEachAliveUnit(IteratorFunction, ...)</strong>
</a>
</dt>
<dd>
<p>Interate the DATABASE and call an interator function for each <strong>alive</strong> unit, providing the Unit and optional parameters.</p>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em>#function IteratorFunction </em></code>:
The function that will be called when there is an alive unit in the database. The function needs to accept a UNIT parameter.</p>
</li>
<li>
<p><code><em> ... </em></code>: </p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd> </dd>
</dl> </dl>
<dl class="function"> <dl class="function">
@ -323,12 +800,12 @@
</dt> </dt>
<dd> <dd>
<p>Creates a new DATABASE Object to administer the Groups defined and alive within the DCSRTE.</p> <p>Creates a new DATABASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.</p>
<h3>Return value</h3> <h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em></p>
<p>DATABASE</p>
<h3>Usage:</h3> <h3>Usage:</h3>
<pre class="example"><code>-- Define a new DATABASE Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE. <pre class="example"><code>-- Define a new DATABASE Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE.
@ -348,6 +825,19 @@ DBObject = DATABASE:New()</code></pre>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).ScanEnvironment" >
<strong>DATABASE:ScanEnvironment()</strong>
</a>
</dt>
<dd>
</dd> </dd>
</dl> </dl>
<dl class="function"> <dl class="function">
@ -414,6 +904,27 @@ This method is used by the SPAWN class.</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE).TraceDatabase" >
<strong>DATABASE:TraceDatabase()</strong>
</a>
</dt>
<dd>
<p>Traces the current database contents in the log ...</p>
<p>(for debug reasons).</p>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd> </dd>
</dl> </dl>
<dl class="function"> <dl class="function">
@ -428,6 +939,100 @@ This method is used by the SPAWN class.</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE)._EventOnBirth" >
<strong>DATABASE:_EventOnBirth(Event)</strong>
</a>
</dt>
<dd>
<p>Handles the OnBirth event for the alive units set.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="Event.html##(EVENTDATA)">Event#EVENTDATA</a> Event </em></code>: </p>
</li>
</ul>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE)._EventOnDeadOrCrash" >
<strong>DATABASE:_EventOnDeadOrCrash(Event)</strong>
</a>
</dt>
<dd>
<p>Handles the OnDead or OnCrash event for alive units set.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="Event.html##(EVENTDATA)">Event#EVENTDATA</a> Event </em></code>: </p>
</li>
</ul>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE)._IsAliveDCSUnit" >
<strong>DATABASE:_IsAliveDCSUnit(DCSUnit)</strong>
</a>
</dt>
<dd>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="DCSUnit.html##(Unit)">DCSUnit#Unit</a> DCSUnit </em></code>: </p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(DATABASE)._IsIncludeDCSUnit" >
<strong>DATABASE:_IsIncludeDCSUnit(DCSUnit)</strong>
</a>
</dt>
<dd>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="DCSUnit.html##(Unit)">DCSUnit#Unit</a> DCSUnit </em></code>: </p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(DATABASE)">#DATABASE</a>:</em>
self</p>
</dd> </dd>
</dl> </dl>
<dl class="function"> <dl class="function">

View File

@ -1835,6 +1835,7 @@ self</p>
<dl class="function"> <dl class="function">
<dt> <dt>
<em></em>
<a id="#(ESCORT).ReportTargetsScheduler" > <a id="#(ESCORT).ReportTargetsScheduler" >
<strong>ESCORT.ReportTargetsScheduler</strong> <strong>ESCORT.ReportTargetsScheduler</strong>
</a> </a>

View File

@ -73,12 +73,6 @@
<td class="name" nowrap="nowrap"><a href="#EVENT">EVENT</a></td> <td class="name" nowrap="nowrap"><a href="#EVENT">EVENT</a></td>
<td class="summary"> <td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="#_EVENTDISPATCHER">_EVENTDISPATCHER</a></td>
<td class="summary">
<p>Declare the event dispatcher based on the EVENT class</p>
</td> </td>
</tr> </tr>
</table> </table>
@ -389,20 +383,6 @@
</dd>
</dl>
<dl class="function">
<dt>
<em><a href="##(EVENT)">#EVENT</a></em>
<a id="_EVENTDISPATCHER" >
<strong>_EVENTDISPATCHER</strong>
</a>
</dt>
<dd>
<p>Declare the event dispatcher based on the EVENT class</p>
</dd> </dd>
</dl> </dl>
<h2><a id="#(Event)" >Type <code>Event</code></a></h2> <h2><a id="#(Event)" >Type <code>Event</code></a></h2>

View File

@ -89,43 +89,50 @@ Groups will follow the following naming structure when spawned at run-time:</p>
<p>Some additional notes that need to be remembered:</p> <p>Some additional notes that need to be remembered:</p>
<ul> <ul>
<li><p>Templates are actually groups defined within the mission editor, with the flag "Late Activation" set. As such, these groups are never used within the mission, but are used by the <a href="##(SPAWN)">#SPAWN</a> module.</p></li> <li>Templates are actually groups defined within the mission editor, with the flag "Late Activation" set. As such, these groups are never used within the mission, but are used by the <a href="##(SPAWN)">#SPAWN</a> module.</li>
<li><p>It is important to defined BEFORE you spawn new groups, a proper initialization of the SPAWN instance is done with the options you want to use.</p></li> <li>It is important to defined BEFORE you spawn new groups, a proper initialization of the SPAWN instance is done with the options you want to use.</li>
<li><p>When designing a mission, NEVER name groups using a "#" within the name of the group Spawn Template(s), or the SPAWN module logic won't work anymore.</p></li> <li>When designing a mission, NEVER name groups using a "#" within the name of the group Spawn Template(s), or the SPAWN module logic won't work anymore.</li>
<li><h2>SPAWN object construction methods:</h2> </ul>
<p>Create a new SPAWN object with the <a href="##(SPAWN).New">SPAWN.New</a> or the <a href="##(SPAWN).NewWithAlias">SPAWN.NewWithAlias</a> methods:</p></li>
<li><p><a href="##(SPAWN).New">SPAWN.New</a>: Creates a new SPAWN object taking the name of the group that functions as the Template.</p></li> <h1>SPAWN construction methods:</h1>
<p>Create a new SPAWN object with the <a href="##(SPAWN).New">SPAWN.New</a> or the <a href="##(SPAWN).NewWithAlias">SPAWN.NewWithAlias</a> methods:</p>
<ul>
<li><a href="##(SPAWN).New">SPAWN.New</a>: Creates a new SPAWN object taking the name of the group that functions as the Template.</li>
</ul> </ul>
<p>It is important to understand how the SPAWN class works internally. The SPAWN object created will contain internally a list of groups that will be spawned and that are already spawned. <p>It is important to understand how the SPAWN class works internally. The SPAWN object created will contain internally a list of groups that will be spawned and that are already spawned.
The initialization functions will modify this list of groups so that when a group gets spawned, ALL information is already prepared when spawning. This is done for performance reasons. The initialization functions will modify this list of groups so that when a group gets spawned, ALL information is already prepared when spawning. This is done for performance reasons.
So in principle, the group list will contain all parameters and configurations after initialization, and when groups get actually spawned, this spawning can be done quickly and efficient.</p> So in principle, the group list will contain all parameters and configurations after initialization, and when groups get actually spawned, this spawning can be done quickly and efficient.</p>
<ol> <h1>SPAWN initialization methods: </h1>
<li><h2>SPAWN object initialization methods: </h2> <p>A spawn object will behave differently based on the usage of initialization methods: </p>
<p>A spawn object will behave differently based on the usage of initialization methods: </p></li>
<li><p><a href="##(SPAWN).Limit">SPAWN.Limit</a>: Limits the amount of groups that can be alive at the same time and that can be dynamically spawned.</p></li> <ul>
<li><p><a href="##(SPAWN).RandomizeRoute">SPAWN.RandomizeRoute</a>: Randomize the routes of spawned groups.</p></li> <li><a href="##(SPAWN).Limit">SPAWN.Limit</a>: Limits the amount of groups that can be alive at the same time and that can be dynamically spawned.</li>
<li><p><a href="##(SPAWN).RandomizeTemplate">SPAWN.RandomizeTemplate</a>: Randomize the group templates so that when a new group is spawned, a random group template is selected from one of the templates defined. </p></li> <li><a href="##(SPAWN).RandomizeRoute">SPAWN.RandomizeRoute</a>: Randomize the routes of spawned groups.</li>
<li><p><a href="##(SPAWN).Uncontrolled">SPAWN.Uncontrolled</a>: Spawn plane groups uncontrolled.</p></li> <li><a href="##(SPAWN).RandomizeTemplate">SPAWN.RandomizeTemplate</a>: Randomize the group templates so that when a new group is spawned, a random group template is selected from one of the templates defined. </li>
<li><p><a href="##(SPAWN).Array">SPAWN.Array</a>: Make groups visible before they are actually activated, and order these groups like a batallion in an array.</p></li> <li><a href="##(SPAWN).Uncontrolled">SPAWN.Uncontrolled</a>: Spawn plane groups uncontrolled.</li>
<li><p><a href="##(SPAWN).Repeat">SPAWN.Repeat</a>: Re-spawn groups when they land at the home base. Similar functions are <a href="##(SPAWN).RepeatOnLanding">SPAWN.RepeatOnLanding</a> and <a href="##(SPAWN).RepeatOnEngineShutDown">SPAWN.RepeatOnEngineShutDown</a>.</p></li> <li><a href="##(SPAWN).Array">SPAWN.Array</a>: Make groups visible before they are actually activated, and order these groups like a batallion in an array.</li>
<li><h2>SPAWN object spawning methods:</h2> <li><a href="##(SPAWN).Repeat">SPAWN.Repeat</a>: Re-spawn groups when they land at the home base. Similar functions are <a href="##(SPAWN).RepeatOnLanding">SPAWN.RepeatOnLanding</a> and <a href="##(SPAWN).RepeatOnEngineShutDown">SPAWN.RepeatOnEngineShutDown</a>.</li>
<p>Groups can be spawned at different times and methods:</p></li> </ul>
<li><p><a href="##(SPAWN).Spawn">SPAWN.Spawn</a>: Spawn one new group based on the last spawned index.</p></li>
<li><p><a href="##(SPAWN).ReSpawn">SPAWN.ReSpawn</a>: Re-spawn a group based on a given index.</p></li> <h1>SPAWN spawning methods:</h1>
<li><p><a href="##(SPAWN).SpawnScheduled">SPAWN.SpawnScheduled</a>: Spawn groups at scheduled but randomized intervals. You can use <a href="##(SPAWN).SpawnScheduleStart">SPAWN.SpawnScheduleStart</a> and <a href="##(SPAWN).SpawnScheduleStop">SPAWN.SpawnScheduleStop</a> to start and stop the schedule respectively.</p></li> <p>Groups can be spawned at different times and methods:</p>
<li><p><a href="##(SPAWN).SpawnFromUnit">SPAWN.SpawnFromUnit</a>: Spawn a new group taking the position of a <a href="UNIT.html">UNIT</a>.</p></li>
<li><p><a href="##(SPAWN).SpawnInZone">SPAWN.SpawnInZone</a>: Spawn a new group in a <a href="ZONE.html">ZONE</a>.</p></li> <ul>
</ol> <li><a href="##(SPAWN).Spawn">SPAWN.Spawn</a>: Spawn one new group based on the last spawned index.</li>
<li><a href="##(SPAWN).ReSpawn">SPAWN.ReSpawn</a>: Re-spawn a group based on a given index.</li>
<li><a href="##(SPAWN).SpawnScheduled">SPAWN.SpawnScheduled</a>: Spawn groups at scheduled but randomized intervals. You can use <a href="##(SPAWN).SpawnScheduleStart">SPAWN.SpawnScheduleStart</a> and <a href="##(SPAWN).SpawnScheduleStop">SPAWN.SpawnScheduleStop</a> to start and stop the schedule respectively.</li>
<li><a href="##(SPAWN).SpawnFromUnit">SPAWN.SpawnFromUnit</a>: Spawn a new group taking the position of a <a href="UNIT.html">UNIT</a>.</li>
<li><a href="##(SPAWN).SpawnInZone">SPAWN.SpawnInZone</a>: Spawn a new group in a <a href="ZONE.html">ZONE</a>.</li>
</ul>
<p>Note that <a href="##(SPAWN).Spawn">SPAWN.Spawn</a> and <a href="##(SPAWN).ReSpawn">SPAWN.ReSpawn</a> return a <a href="GROUP.html##(GROUP).New">GROUP#GROUP.New</a> object, that contains a reference to the DCSGroup object. <p>Note that <a href="##(SPAWN).Spawn">SPAWN.Spawn</a> and <a href="##(SPAWN).ReSpawn">SPAWN.ReSpawn</a> return a <a href="GROUP.html##(GROUP).New">GROUP#GROUP.New</a> object, that contains a reference to the DCSGroup object.
You can use the <a href="GROUP.html">GROUP</a> object to do further actions with the DCSGroup.</p> You can use the <a href="GROUP.html">GROUP</a> object to do further actions with the DCSGroup.</p>
<ol> <h1>SPAWN object cleaning:</h1>
<li>SPAWN object cleaning: <p>Sometimes, it will occur during a mission run-time, that ground or especially air objects get damaged, and will while being damged stop their activities, while remaining alive.
<hr/>
Sometimes, it will occur during a mission run-time, that ground or especially air objects get damaged, and will while being damged stop their activities, while remaining alive.
In such cases, the SPAWN object will just sit there and wait until that group gets destroyed, but most of the time it won't, In such cases, the SPAWN object will just sit there and wait until that group gets destroyed, but most of the time it won't,
and it may occur that no new groups are or can be spawned as limits are reached. and it may occur that no new groups are or can be spawned as limits are reached.
To prevent this, a <a href="##(SPAWN).CleanUp">SPAWN.CleanUp</a> initialization method has been defined that will silently monitor the status of each spawned group. To prevent this, a <a href="##(SPAWN).CleanUp">SPAWN.CleanUp</a> initialization method has been defined that will silently monitor the status of each spawned group.
@ -133,8 +140,7 @@ You can use the <a href="GROUP.html">GROUP</a> object to do further actions with
There is a catch however :-) If a damaged group has returned to an airbase within the coalition, that group will not be considered as "lost"... There is a catch however :-) If a damaged group has returned to an airbase within the coalition, that group will not be considered as "lost"...
In such a case, when the inactive group is cleaned, a new group will Re-spawned automatically. In such a case, when the inactive group is cleaned, a new group will Re-spawned automatically.
This models AI that has succesfully returned to their airbase, to restart their combat activities. This models AI that has succesfully returned to their airbase, to restart their combat activities.
Check the <a href="##(SPAWN).CleanUp">SPAWN.CleanUp</a> for further info.</li> Check the <a href="##(SPAWN).CleanUp">SPAWN.CleanUp</a> for further info.</p>
</ol>
<h2>Global(s)</h2> <h2>Global(s)</h2>
@ -2052,7 +2058,7 @@ Nothing found</p>
<p> TODO Need to delete this... _Database does this now ...</p> <p> TODO Need to delete this... _DATABASE does this now ...</p>
<h3>Parameter</h3> <h3>Parameter</h3>
<ul> <ul>

View File

@ -1,8 +1,61 @@
--- Administers the Initial Sets of the Mission Templates as defined within the Mission Editor. --- Administers the Initial Sets of the Mission Templates as defined within the Mission Editor.
-- Administers the Spawning of new Groups within the DCSRTE and administers these new Groups within the DATABASE object(s). -- Mission designers can use the DATABASE class to build sets of units belonging to certain:
--
-- * coalitions
-- * categories
-- * countries
-- * unit types
-- * starting with certain prefix strings.
--
-- Note that this is an initial filter set. More to follow, like zones etc.
--
--
-- DATABASE construction methods:
-- =================================
-- Create a new DATABASE object with the @{#DATABASE.New} method:
--
-- * @{#DATABASE.New}: Creates a new DATABASE object.
--
--
-- DATABASE filter criteria:
-- =========================
-- You can set filter criteria to define the set of units within the database.
-- Filter criteria are defined by:
--
-- * @{#DATABASE.FilterCoalitions}: Builds the DATABASE with the units belonging to the coalition(s).
-- * @{#DATABASE.FilterCategories}: Builds the DATABASE with the units belonging to the category(ies).
-- * @{#DATABASE.FilterTypes}: Builds the DATABASE with the units belonging to the unit type(s).
-- * @{#DATABASE.FilterCountries}: Builds the DATABASE with the units belonging to the country(ies).
-- * @{#DATABASE.FilterUnitPrefixes}: Builds the DATABASE with the units starting with the same prefix string(s).
--
-- Once the filter criteria have been set for the DATABASE, you can start filtering using:
--
-- * @{#DATABASE.FilterStart}: Starts the filtering of the units within the database.
--
-- Planned filter criteria within development are (so these are not yet available):
--
-- * @{#DATABASE.FilterGroupPrefixes}: Builds the DATABASE with the groups of the units starting with the same prefix string(s).
-- * @{#DATABASE.FilterZones}: Builds the DATABASE with the units within a @{Zone#ZONE}.
--
--
-- DATABASE iterators:
-- ===================
-- Once the filters have been defined and the DATABASE has been built, you can iterate the database with the available iterator methods.
-- The iterator methods will walk the DATABASE set, and call for each element within the set a function that you provide.
-- The following iterator methods are currently available within the DATABASE:
--
-- * @{#DATABASE.ForEachAliveUnit}: Calls a function for each alive unit it finds within the DATABASE.
--
-- Planned iterators methods in development are (so these are not yet available):
--
-- * @{#DATABASE.ForEachUnit}: Calls a function for each unit contained within the DATABASE.
-- * @{#DATABASE.ForEachGroup}: Calls a function for each group contained within the DATABASE.
-- * @{#DATABASE.ForEachUnitInZone}: Calls a function for each unit within a certain zone contained within the DATABASE.
--
-- @module Database -- @module Database
-- @author FlightControl -- @author FlightControl
Include.File( "Routines" ) Include.File( "Routines" )
Include.File( "Base" ) Include.File( "Base" )
Include.File( "Menu" ) Include.File( "Menu" )
@ -89,7 +142,7 @@ end
-- @param #DATABASE self -- @param #DATABASE self
-- @param #string Coalitions Can take the following values: "red", "blue", "neutral". -- @param #string Coalitions Can take the following values: "red", "blue", "neutral".
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:FilterCoalition( Coalitions ) function DATABASE:FilterCoalitions( Coalitions )
if not self.Filter.Coalitions then if not self.Filter.Coalitions then
self.Filter.Coalitions = {} self.Filter.Coalitions = {}
end end
@ -107,7 +160,7 @@ end
-- @param #DATABASE self -- @param #DATABASE self
-- @param #string Categories Can take the following values: "plane", "helicopter", "ground", "ship". -- @param #string Categories Can take the following values: "plane", "helicopter", "ground", "ship".
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:FilterCategory( Categories ) function DATABASE:FilterCategories( Categories )
if not self.Filter.Categories then if not self.Filter.Categories then
self.Filter.Categories = {} self.Filter.Categories = {}
end end
@ -125,7 +178,7 @@ end
-- @param #DATABASE self -- @param #DATABASE self
-- @param #string Types Can take those type strings known within DCS world. -- @param #string Types Can take those type strings known within DCS world.
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:FilterType( Types ) function DATABASE:FilterTypes( Types )
if not self.Filter.Types then if not self.Filter.Types then
self.Filter.Types = {} self.Filter.Types = {}
end end
@ -161,7 +214,7 @@ end
-- @param #DATABASE self -- @param #DATABASE self
-- @param #string Prefixes The prefix of which the unit name starts with. -- @param #string Prefixes The prefix of which the unit name starts with.
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:FilterUnitPrefix( Prefixes ) function DATABASE:FilterUnitPrefixes( Prefixes )
if not self.Filter.UnitPrefixes then if not self.Filter.UnitPrefixes then
self.Filter.UnitPrefixes = {} self.Filter.UnitPrefixes = {}
end end
@ -179,7 +232,7 @@ end
-- @param #DATABASE self -- @param #DATABASE self
-- @param #string Prefixes The prefix of which the group name where the unit belongs to starts with. -- @param #string Prefixes The prefix of which the group name where the unit belongs to starts with.
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:FilterGroupPrefix( Prefixes ) function DATABASE:FilterGroupPrefixes( Prefixes )
if not self.Filter.GroupPrefixes then if not self.Filter.GroupPrefixes then
self.Filter.GroupPrefixes = {} self.Filter.GroupPrefixes = {}
end end
@ -204,10 +257,10 @@ function DATABASE:FilterStart()
for UnitRegistrationID, UnitRegistration in pairs( _DATABASE.Units ) do for UnitRegistrationID, UnitRegistration in pairs( _DATABASE.Units ) do
self:T( UnitRegistration ) self:T( UnitRegistration )
local DCSUnit = Unit.getByName( UnitRegistration.UnitName ) local DCSUnit = Unit.getByName( UnitRegistration.UnitName )
if self:IsIncludeDCSUnit( DCSUnit ) then if self:_IsIncludeDCSUnit( DCSUnit ) then
self.DCSUnits[DCSUnit:getName()] = DCSUnit self.DCSUnits[DCSUnit:getName()] = DCSUnit
end end
if self:IsAliveDCSUnit( DCSUnit ) then if self:_IsAliveDCSUnit( DCSUnit ) then
self.DCSUnitsAlive[DCSUnit:getName()] = DCSUnit self.DCSUnitsAlive[DCSUnit:getName()] = DCSUnit
end end
end end
@ -218,155 +271,6 @@ function DATABASE:FilterStart()
return self return self
end end
---
-- @param #DATABASE self
-- @param DCSUnit#Unit DCSUnit
-- @return #DATABASE self
function DATABASE:IsIncludeDCSUnit( DCSUnit )
self:F( DCSUnit )
local DCSUnitInclude = true
if self.Filter.Coalitions then
local DCSUnitCoalition = false
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
self:T( { "Coalition:", DCSUnit:getCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == DCSUnit:getCoalition() then
DCSUnitCoalition = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitCoalition
end
if self.Filter.Categories then
local DCSUnitCategory = false
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
self:T( { "Category:", DCSUnit:getDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == DCSUnit:getDesc().category then
DCSUnitCategory = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitCategory
end
if self.Filter.Types then
local DCSUnitType = false
for TypeID, TypeName in pairs( self.Filter.Types ) do
self:T( { "Type:", DCSUnit:getTypeName(), TypeName } )
if TypeName == DCSUnit:getTypeName() then
DCSUnitType = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitType
end
if self.Filter.Countries then
local DCSUnitCountry = false
for CountryID, CountryName in pairs( self.Filter.Countries ) do
self:T( { "Country:", DCSUnit:getCountry(), CountryName } )
if country.id[CountryName] == DCSUnit:getCountry() then
DCSUnitCountry = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitCountry
end
if self.Filter.UnitPrefixes then
local DCSUnitPrefix = false
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
self:T( { "Unit Prefix:", string.find( DCSUnit:getName(), UnitPrefix, 1 ), UnitPrefix } )
if string.find( DCSUnit:getName(), UnitPrefix, 1 ) then
DCSUnitPrefix = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitPrefix
end
self:T( DCSUnitInclude )
return DCSUnitInclude
end
---
-- @param #DATABASE self
-- @param DCSUnit#Unit DCSUnit
-- @return #DATABASE self
function DATABASE:IsAliveDCSUnit( DCSUnit )
self:F( DCSUnit )
local DCSUnitAlive = false
if DCSUnit and DCSUnit:isExist() and DCSUnit:isActive() then
if self.DCSUnits[DCSUnit:getName()] then
DCSUnitAlive = true
end
end
self:T( DCSUnitAlive )
return DCSUnitAlive
end
function DATABASE:ScanEnvironment()
self:F()
self.Navpoints = {}
self.Units = {}
--Build routines.db.units and self.Navpoints
for coa_name, coa_data in pairs(env.mission.coalition) do
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
--self.Units[coa_name] = {}
----------------------------------------------
-- build nav points DB
self.Navpoints[coa_name] = {}
if coa_data.nav_points then --navpoints
for nav_ind, nav_data in pairs(coa_data.nav_points) do
if type(nav_data) == 'table' then
self.Navpoints[coa_name][nav_ind] = routines.utils.deepCopy(nav_data)
self.Navpoints[coa_name][nav_ind]['name'] = nav_data.callsignStr -- name is a little bit more self-explanatory.
self.Navpoints[coa_name][nav_ind]['point'] = {} -- point is used by SSE, support it.
self.Navpoints[coa_name][nav_ind]['point']['x'] = nav_data.x
self.Navpoints[coa_name][nav_ind]['point']['y'] = 0
self.Navpoints[coa_name][nav_ind]['point']['z'] = nav_data.y
end
end
end
-------------------------------------------------
if coa_data.country then --there is a country table
for cntry_id, cntry_data in pairs(coa_data.country) do
local countryName = string.lower(cntry_data.name)
--self.Units[coa_name][countryName] = {}
--self.Units[coa_name][countryName]["countryId"] = cntry_data.id
if type(cntry_data) == 'table' then --just making sure
for obj_type_name, obj_type_data in pairs(cntry_data) do
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" or obj_type_name == "static" then --should be an unncessary check
local category = obj_type_name
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
--self.Units[coa_name][countryName][category] = {}
for group_num, GroupTemplate in pairs(obj_type_data.group) do
if GroupTemplate and GroupTemplate.units and type(GroupTemplate.units) == 'table' then --making sure again- this is a valid group
self:_RegisterGroup( GroupTemplate )
end --if GroupTemplate and GroupTemplate.units then
end --for group_num, GroupTemplate in pairs(obj_type_data.group) do
end --if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then
end --if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" or obj_type_name == "static" then
end --for obj_type_name, obj_type_data in pairs(cntry_data) do
end --if type(cntry_data) == 'table' then
end --for cntry_id, cntry_data in pairs(coa_data.country) do
end --if coa_data.country then --there is a country table
end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then
end --for coa_name, coa_data in pairs(mission.coalition) do
return self
end
--- Instantiate new Groups within the DCSRTE. --- Instantiate new Groups within the DCSRTE.
-- This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined: -- This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined:
@ -461,7 +365,7 @@ function DATABASE:_EventOnBirth( Event )
self:F( { Event } ) self:F( { Event } )
if Event.IniDCSUnit then if Event.IniDCSUnit then
if self:IsIncludeDCSUnit( Event.IniDCSUnit ) then if self:_IsIncludeDCSUnit( Event.IniDCSUnit ) then
self.DCSUnits[Event.IniDCSUnitName] = Event.IniDCSUnit self.DCSUnits[Event.IniDCSUnitName] = Event.IniDCSUnit
self.DCSUnitsAlive[Event.IniDCSUnitName] = Event.IniDCSUnit self.DCSUnitsAlive[Event.IniDCSUnitName] = Event.IniDCSUnit
end end
@ -490,63 +394,188 @@ function DATABASE:ForEachAliveUnit( IteratorFunction, ... )
self:F( arg ) self:F( arg )
local function CoRoutine() local function CoRoutine()
local Count = 0
for DCSUnitID, DCSUnit in pairs( self.DCSUnitsAlive ) do for DCSUnitID, DCSUnit in pairs( self.DCSUnitsAlive ) do
self:T2( DCSUnit ) self:T2( DCSUnit )
IteratorFunction( DCSUnit, unpack( arg ) ) IteratorFunction( DCSUnit, unpack( arg ) )
coroutine.yield() Count = Count + 1
if Count % 10 == 0 then
coroutine.yield( false )
end
end end
return true return true
end end
local co = coroutine.create( CoRoutine ) local co = coroutine.create( CoRoutine )
while true do local function Schedule()
local status, res = coroutine.resume( co ) local status, res = coroutine.resume( co )
self:T2( { status, res } ) self:T( { status, res } )
if status == false then if status == false then
error( res ) error( res )
end end
if res == true then if res == false then
break timer.scheduleFunction( Schedule, {}, timer.getTime() + 0.001 )
end end
end end
timer.scheduleFunction( Schedule, {}, timer.getTime() + 1 )
return self return self
end end
--- Interate the DATABASE and call an interator function for each unit, providing the UNIT and optional parameters. function DATABASE:ScanEnvironment()
self:F()
self.Navpoints = {}
self.Units = {}
--Build routines.db.units and self.Navpoints
for coa_name, coa_data in pairs(env.mission.coalition) do
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
--self.Units[coa_name] = {}
----------------------------------------------
-- build nav points DB
self.Navpoints[coa_name] = {}
if coa_data.nav_points then --navpoints
for nav_ind, nav_data in pairs(coa_data.nav_points) do
if type(nav_data) == 'table' then
self.Navpoints[coa_name][nav_ind] = routines.utils.deepCopy(nav_data)
self.Navpoints[coa_name][nav_ind]['name'] = nav_data.callsignStr -- name is a little bit more self-explanatory.
self.Navpoints[coa_name][nav_ind]['point'] = {} -- point is used by SSE, support it.
self.Navpoints[coa_name][nav_ind]['point']['x'] = nav_data.x
self.Navpoints[coa_name][nav_ind]['point']['y'] = 0
self.Navpoints[coa_name][nav_ind]['point']['z'] = nav_data.y
end
end
end
-------------------------------------------------
if coa_data.country then --there is a country table
for cntry_id, cntry_data in pairs(coa_data.country) do
local countryName = string.lower(cntry_data.name)
--self.Units[coa_name][countryName] = {}
--self.Units[coa_name][countryName]["countryId"] = cntry_data.id
if type(cntry_data) == 'table' then --just making sure
for obj_type_name, obj_type_data in pairs(cntry_data) do
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" or obj_type_name == "static" then --should be an unncessary check
local category = obj_type_name
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
--self.Units[coa_name][countryName][category] = {}
for group_num, GroupTemplate in pairs(obj_type_data.group) do
if GroupTemplate and GroupTemplate.units and type(GroupTemplate.units) == 'table' then --making sure again- this is a valid group
self:_RegisterGroup( GroupTemplate )
end --if GroupTemplate and GroupTemplate.units then
end --for group_num, GroupTemplate in pairs(obj_type_data.group) do
end --if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then
end --if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" or obj_type_name == "static" then
end --for obj_type_name, obj_type_data in pairs(cntry_data) do
end --if type(cntry_data) == 'table' then
end --for cntry_id, cntry_data in pairs(coa_data.country) do
end --if coa_data.country then --there is a country table
end --if coa_name == 'red' or coa_name == 'blue' and type(coa_data) == 'table' then
end --for coa_name, coa_data in pairs(mission.coalition) do
return self
end
---
-- @param #DATABASE self -- @param #DATABASE self
-- @param #function IteratorFunction The function that will be called when there is an alive unit in the database. The function needs to accept a UNIT parameter. -- @param DCSUnit#Unit DCSUnit
-- @return #DATABASE self -- @return #DATABASE self
function DATABASE:ForEachAliveUnit( IteratorFunction, ... ) function DATABASE:_IsIncludeDCSUnit( DCSUnit )
self:F( arg ) self:F( DCSUnit )
local DCSUnitInclude = true
local function CoRoutine() if self.Filter.Coalitions then
for DCSUnitID, DCSUnit in pairs( self.DCSUnits ) do local DCSUnitCoalition = false
self:T2( DCSUnit ) for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
IteratorFunction( DCSUnit, unpack( arg ) ) self:T( { "Coalition:", DCSUnit:getCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
coroutine.yield() if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == DCSUnit:getCoalition() then
DCSUnitCoalition = true
end end
return true end
DCSUnitInclude = DCSUnitInclude and DCSUnitCoalition
end end
local co = coroutine.create( CoRoutine ) if self.Filter.Categories then
local DCSUnitCategory = false
while true do for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
local status, res = coroutine.resume( co ) self:T( { "Category:", DCSUnit:getDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
self:T2( { status, res } ) if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == DCSUnit:getDesc().category then
DCSUnitCategory = true
if status == false then
error( res )
end end
if res == true then
break
end end
DCSUnitInclude = DCSUnitInclude and DCSUnitCategory
end end
return self if self.Filter.Types then
local DCSUnitType = false
for TypeID, TypeName in pairs( self.Filter.Types ) do
self:T( { "Type:", DCSUnit:getTypeName(), TypeName } )
if TypeName == DCSUnit:getTypeName() then
DCSUnitType = true
end end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitType
end
if self.Filter.Countries then
local DCSUnitCountry = false
for CountryID, CountryName in pairs( self.Filter.Countries ) do
self:T( { "Country:", DCSUnit:getCountry(), CountryName } )
if country.id[CountryName] == DCSUnit:getCountry() then
DCSUnitCountry = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitCountry
end
if self.Filter.UnitPrefixes then
local DCSUnitPrefix = false
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
self:T( { "Unit Prefix:", string.find( DCSUnit:getName(), UnitPrefix, 1 ), UnitPrefix } )
if string.find( DCSUnit:getName(), UnitPrefix, 1 ) then
DCSUnitPrefix = true
end
end
DCSUnitInclude = DCSUnitInclude and DCSUnitPrefix
end
self:T( DCSUnitInclude )
return DCSUnitInclude
end
---
-- @param #DATABASE self
-- @param DCSUnit#Unit DCSUnit
-- @return #DATABASE self
function DATABASE:_IsAliveDCSUnit( DCSUnit )
self:F( DCSUnit )
local DCSUnitAlive = false
if DCSUnit and DCSUnit:isExist() and DCSUnit:isActive() then
if self.DCSUnits[DCSUnit:getName()] then
DCSUnitAlive = true
end
end
self:T( DCSUnitAlive )
return DCSUnitAlive
end
--- Traces the current database contents in the log ... (for debug reasons). --- Traces the current database contents in the log ... (for debug reasons).
-- @param #DATABASE self -- @param #DATABASE self

View File

@ -449,14 +449,14 @@ end
do do
-- THE MAIN FUNCTION -- Accessed 100 times/sec. -- THE MAIN FUNCTION -- Accessed 100 times/sec.
routines.main = function() routines.main = function()
timer.scheduleFunction(routines.main, {}, timer.getTime() + 0.1) --reschedule first in case of Lua error timer.scheduleFunction(routines.main, {}, timer.getTime() + 2) --reschedule first in case of Lua error
---------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------
--area to add new stuff in --area to add new stuff in
routines.do_scheduled_functions() routines.do_scheduled_functions()
end -- end of routines.main end -- end of routines.main
timer.scheduleFunction(routines.main, {}, timer.getTime() + 0.1) timer.scheduleFunction(routines.main, {}, timer.getTime() + 2)
end end

View File

@ -21,8 +21,8 @@
-- * It is important to defined BEFORE you spawn new groups, a proper initialization of the SPAWN instance is done with the options you want to use. -- * It is important to defined BEFORE you spawn new groups, a proper initialization of the SPAWN instance is done with the options you want to use.
-- * When designing a mission, NEVER name groups using a "#" within the name of the group Spawn Template(s), or the SPAWN module logic won't work anymore. -- * When designing a mission, NEVER name groups using a "#" within the name of the group Spawn Template(s), or the SPAWN module logic won't work anymore.
-- --
-- 1. SPAWN object construction methods: -- SPAWN construction methods:
-- ------------------------------------- -- ===========================
-- Create a new SPAWN object with the @{#SPAWN.New} or the @{#SPAWN.NewWithAlias} methods: -- Create a new SPAWN object with the @{#SPAWN.New} or the @{#SPAWN.NewWithAlias} methods:
-- --
-- * @{#SPAWN.New}: Creates a new SPAWN object taking the name of the group that functions as the Template. -- * @{#SPAWN.New}: Creates a new SPAWN object taking the name of the group that functions as the Template.
@ -31,8 +31,8 @@
-- The initialization functions will modify this list of groups so that when a group gets spawned, ALL information is already prepared when spawning. This is done for performance reasons. -- The initialization functions will modify this list of groups so that when a group gets spawned, ALL information is already prepared when spawning. This is done for performance reasons.
-- So in principle, the group list will contain all parameters and configurations after initialization, and when groups get actually spawned, this spawning can be done quickly and efficient. -- So in principle, the group list will contain all parameters and configurations after initialization, and when groups get actually spawned, this spawning can be done quickly and efficient.
-- --
-- 2. SPAWN object initialization methods: -- SPAWN initialization methods:
-- --------------------------------------- -- =============================
-- A spawn object will behave differently based on the usage of initialization methods: -- A spawn object will behave differently based on the usage of initialization methods:
-- --
-- * @{#SPAWN.Limit}: Limits the amount of groups that can be alive at the same time and that can be dynamically spawned. -- * @{#SPAWN.Limit}: Limits the amount of groups that can be alive at the same time and that can be dynamically spawned.
@ -42,8 +42,8 @@
-- * @{#SPAWN.Array}: Make groups visible before they are actually activated, and order these groups like a batallion in an array. -- * @{#SPAWN.Array}: Make groups visible before they are actually activated, and order these groups like a batallion in an array.
-- * @{#SPAWN.Repeat}: Re-spawn groups when they land at the home base. Similar functions are @{#SPAWN.RepeatOnLanding} and @{#SPAWN.RepeatOnEngineShutDown}. -- * @{#SPAWN.Repeat}: Re-spawn groups when they land at the home base. Similar functions are @{#SPAWN.RepeatOnLanding} and @{#SPAWN.RepeatOnEngineShutDown}.
-- --
-- 2. SPAWN object spawning methods: -- SPAWN spawning methods:
-- --------------------------------- -- =======================
-- Groups can be spawned at different times and methods: -- Groups can be spawned at different times and methods:
-- --
-- * @{#SPAWN.Spawn}: Spawn one new group based on the last spawned index. -- * @{#SPAWN.Spawn}: Spawn one new group based on the last spawned index.
@ -55,8 +55,8 @@
-- Note that @{#SPAWN.Spawn} and @{#SPAWN.ReSpawn} return a @{GROUP#GROUP.New} object, that contains a reference to the DCSGroup object. -- Note that @{#SPAWN.Spawn} and @{#SPAWN.ReSpawn} return a @{GROUP#GROUP.New} object, that contains a reference to the DCSGroup object.
-- You can use the @{GROUP} object to do further actions with the DCSGroup. -- You can use the @{GROUP} object to do further actions with the DCSGroup.
-- --
-- 3. SPAWN object cleaning: -- SPAWN object cleaning:
-- ------------------------- -- =========================
-- Sometimes, it will occur during a mission run-time, that ground or especially air objects get damaged, and will while being damged stop their activities, while remaining alive. -- Sometimes, it will occur during a mission run-time, that ground or especially air objects get damaged, and will while being damged stop their activities, while remaining alive.
-- In such cases, the SPAWN object will just sit there and wait until that group gets destroyed, but most of the time it won't, -- In such cases, the SPAWN object will just sit there and wait until that group gets destroyed, but most of the time it won't,
-- and it may occur that no new groups are or can be spawned as limits are reached. -- and it may occur that no new groups are or can be spawned as limits are reached.

View File

@ -47,8 +47,9 @@ function ZONE:GetRandomPointVec2()
local Zone = trigger.misc.getZone( self.ZoneName ) local Zone = trigger.misc.getZone( self.ZoneName )
Point.x = Zone.point.x + math.random( Zone.radius * -1, Zone.radius ) local angle = math.random() * math.pi*2;
Point.y = Zone.point.z + math.random( Zone.radius * -1, Zone.radius ) Point.x = Zone.point.x + math.cos( angle ) * math.random() * Zone.radius;
Point.y = Zone.point.z + math.sin( angle ) * math.random() * Zone.radius;
self:T( { Zone, Point } ) self:T( { Zone, Point } )

View File

@ -2,21 +2,21 @@ Include.File( 'Database' )
Include.File( 'Spawn' ) Include.File( 'Spawn' )
DBBluePlanes = DATABASE:New() DBBluePlanes = DATABASE:New()
:FilterCoalition( "blue" ) :FilterCoalitions( "blue" )
:FilterCategory( "plane" ) :FilterCategories( "plane" )
:FilterStart() :FilterStart()
DBRedVehicles = DATABASE:New() DBRedVehicles = DATABASE:New()
:FilterCoalition( "red" ) :FilterCoalitions( "red" )
:FilterCategory( "ground" ) :FilterCategories( "ground" )
:FilterStart() :FilterStart()
DBShips = DATABASE:New() DBShips = DATABASE:New()
:FilterCategory( "ship" ) :FilterCategories( "ship" )
:FilterStart() :FilterStart()
DBBelgium = DATABASE:New() DBBelgium = DATABASE:New()
:FilterCategory( "helicopter" ) :FilterCategories( "helicopter" )
:FilterCountries( "BELGIUM" ) :FilterCountries( "BELGIUM" )
:FilterStart() :FilterStart()
@ -25,7 +25,7 @@ DBNorthKorea = DATABASE:New()
:FilterStart() :FilterStart()
DBKA50Vinson = DATABASE:New() DBKA50Vinson = DATABASE:New()
:FilterType( { "Ka-50", "VINSON" } ) :FilterTypes( { "Ka-50", "VINSON" } )
:FilterStart() :FilterStart()
DBBluePlanes:TraceDatabase() DBBluePlanes:TraceDatabase()
@ -51,6 +51,14 @@ GroupRU_Vehicle = SpawnRU_Vehicle:Spawn()
SpawnRU_Ship = SPAWN:New( 'Database Spawn Test RUSSIA Ship') SpawnRU_Ship = SPAWN:New( 'Database Spawn Test RUSSIA Ship')
GroupRU_Ship = SpawnRU_Ship:Spawn() GroupRU_Ship = SpawnRU_Ship:Spawn()
SpawnUS_AttackVehicle = SPAWN:New( 'Database Spawn Test USA Attack Vehicle' )
SpawnRU_AttackVehicle = SPAWN:New( 'Database Spawn Test RUSSIA Attack Vehicle' )
for i = 1, 10 do
GroupRU_AttackVehicle = SpawnRU_AttackVehicle:SpawnInZone( ZONE:New("Spawn Zone RU"), true)
GroupUS_AttackVehicle = SpawnUS_AttackVehicle:SpawnInZone( ZONE:New("Spawn Zone US"), true)
end
--DBBlue:TraceDatabase() --DBBlue:TraceDatabase()
routines.scheduleFunction( DBBluePlanes.TraceDatabase, { DBBluePlanes }, 1 ) routines.scheduleFunction( DBBluePlanes.TraceDatabase, { DBBluePlanes }, 1 )