Merge branch 'master' into funkyfranky

This commit is contained in:
funkyfranky 2017-10-22 22:55:07 +02:00
commit e41b038730
12 changed files with 1304 additions and 566 deletions

View File

@ -2,8 +2,19 @@
--
-- ====
--
-- 1) @{#DATABASE} class, extends @{Base#BASE}
-- ===================================================
-- ### Author: **Sven Van de Velde (FlightControl)**
-- ### Contributions:
--
-- ====
--
-- @module Database
--- @type DATABASE
-- @extends Core.Base#BASE
--- # DATABASE class, extends @{Base#BASE}
--
-- Mission designers can use the DATABASE class to refer to:
--
-- * STATICS
@ -17,35 +28,10 @@
--
-- On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.
--
-- Moose will automatically create one instance of the DATABASE class into the **global** object _DATABASE.
-- Moose refers to _DATABASE within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
-- The singleton object **_DATABASE** is automatically created by MOOSE, that administers all objects within the mission.
-- Moose refers to **_DATABASE** within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
--
-- 1.1) DATABASE iterators
-- -----------------------
-- 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.ForEachUnit}: Calls a function for each @{UNIT} it finds within the DATABASE.
-- * @{#DATABASE.ForEachGroup}: Calls a function for each @{GROUP} it finds within the DATABASE.
-- * @{#DATABASE.ForEachPlayer}: Calls a function for each alive player it finds within the DATABASE.
-- * @{#DATABASE.ForEachPlayerJoined}: Calls a function for each joined player it finds within the DATABASE.
-- * @{#DATABASE.ForEachClient}: Calls a function for each @{CLIENT} it finds within the DATABASE.
-- * @{#DATABASE.ForEachClientAlive}: Calls a function for each alive @{CLIENT} it finds within the DATABASE.
--
-- ===
--
--
-- ### Author: **Sven Van de Velde (FlightControl)**
-- ### Contributions:
--
-- ====
-- @module Database
--- DATABASE class
-- @type DATABASE
-- @extends Core.Base#BASE
-- @field #DATABASE
DATABASE = {
ClassName = "DATABASE",
Templates = {
@ -418,10 +404,13 @@ end
--- Private method that registers new Group Templates within the DATABASE Object.
-- @param #DATABASE self
-- @param #table GroupTemplate
-- @param Dcs.DCScoalition#coalition.side CoalitionSide The coalition.side of the object.
-- @param Dcs.DCSObject#Object.Category CategoryID The Object.category of the object.
-- @param Dcs.DCScountry#country.id CountryID the country.id of the object
-- @return #DATABASE self
function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionID, CategoryID, CountryID )
function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName )
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
local GroupTemplateName = GroupName or env.getValueDictByKey( GroupTemplate.name )
local TraceTable = {}
@ -436,7 +425,7 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionID, CategoryID
end
GroupTemplate.CategoryID = CategoryID
GroupTemplate.CoalitionID = CoalitionID
GroupTemplate.CoalitionID = CoalitionSide
GroupTemplate.CountryID = CountryID
self.Templates.Groups[GroupTemplateName].GroupName = GroupTemplateName
@ -445,7 +434,7 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionID, CategoryID
self.Templates.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
self.Templates.Groups[GroupTemplateName].Units = GroupTemplate.units
self.Templates.Groups[GroupTemplateName].CategoryID = CategoryID
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionID
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionSide
self.Templates.Groups[GroupTemplateName].CountryID = CountryID
@ -472,13 +461,13 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionID, CategoryID
self.Templates.Units[UnitTemplate.name].GroupTemplate = GroupTemplate
self.Templates.Units[UnitTemplate.name].GroupId = GroupTemplate.groupId
self.Templates.Units[UnitTemplate.name].CategoryID = CategoryID
self.Templates.Units[UnitTemplate.name].CoalitionID = CoalitionID
self.Templates.Units[UnitTemplate.name].CoalitionID = CoalitionSide
self.Templates.Units[UnitTemplate.name].CountryID = CountryID
if UnitTemplate.skill and (UnitTemplate.skill == "Client" or UnitTemplate.skill == "Player") then
self.Templates.ClientsByName[UnitTemplate.name] = UnitTemplate
self.Templates.ClientsByName[UnitTemplate.name].CategoryID = CategoryID
self.Templates.ClientsByName[UnitTemplate.name].CoalitionID = CoalitionID
self.Templates.ClientsByName[UnitTemplate.name].CoalitionID = CoalitionSide
self.Templates.ClientsByName[UnitTemplate.name].CountryID = CountryID
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
end
@ -1155,3 +1144,5 @@ end

View File

@ -298,7 +298,7 @@ function SPAWN:New( SpawnTemplatePrefix )
local self = BASE:Inherit( self, BASE:New() ) -- #SPAWN
self:F( { SpawnTemplatePrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
local TemplateGroup = GROUP:FindByName( SpawnTemplatePrefix )
if TemplateGroup then
self.SpawnTemplatePrefix = SpawnTemplatePrefix
self.SpawnIndex = 0
@ -342,7 +342,7 @@ function SPAWN:NewWithAlias( SpawnTemplatePrefix, SpawnAliasPrefix )
local self = BASE:Inherit( self, BASE:New() )
self:F( { SpawnTemplatePrefix, SpawnAliasPrefix } )
local TemplateGroup = Group.getByName( SpawnTemplatePrefix )
local TemplateGroup = GROUP:FindByName( SpawnTemplatePrefix )
if TemplateGroup then
self.SpawnTemplatePrefix = SpawnTemplatePrefix
self.SpawnAliasPrefix = SpawnAliasPrefix
@ -1244,14 +1244,18 @@ function SPAWN:SpawnFromVec3( Vec3, SpawnIndex )
local TY = Vec3.z + ( SY - BY )
SpawnTemplate.units[UnitID].x = TX
SpawnTemplate.units[UnitID].y = TY
SpawnTemplate.units[UnitID].alt = Vec3.y
if SpawnTemplate.CategoryID ~= Group.Category.SHIP then
SpawnTemplate.units[UnitID].alt = Vec3.y
end
self:T( 'After Translation SpawnTemplate.units['..UnitID..'].x = ' .. SpawnTemplate.units[UnitID].x .. ', SpawnTemplate.units['..UnitID..'].y = ' .. SpawnTemplate.units[UnitID].y )
end
SpawnTemplate.route.points[1].x = Vec3.x
SpawnTemplate.route.points[1].y = Vec3.z
SpawnTemplate.route.points[1].alt = Vec3.y
if SpawnTemplate.CategoryID ~= Group.Category.SHIP then
SpawnTemplate.route.points[1].alt = Vec3.y
end
SpawnTemplate.x = Vec3.x
SpawnTemplate.y = Vec3.z

View File

@ -458,12 +458,17 @@ end
-- @param #ZONE_RADIUS self
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
-- @param #number Points (optional) The amount of points in the circle.
-- @param #number AddHeight (optional) The height to be added for the smoke.
-- @param #number AddOffSet (optional) The angle to be added for the smoking start position.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:SmokeZone( SmokeColor, Points )
function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset )
self:F2( SmokeColor )
local Point = {}
local Vec2 = self:GetVec2()
AddHeight = AddHeight or 0
AngleOffset = AngleOffset or 0
Points = Points and Points or 360
@ -471,10 +476,10 @@ function ZONE_RADIUS:SmokeZone( SmokeColor, Points )
local RadialBase = math.pi*2
for Angle = 0, 360, 360 / Points do
local Radial = Angle * RadialBase / 360
local Radial = ( Angle + AngleOffset ) * RadialBase / 360
Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius()
Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius()
POINT_VEC2:New( Point.x, Point.y ):Smoke( SmokeColor )
POINT_VEC2:New( Point.x, Point.y, AddHeight ):Smoke( SmokeColor )
end
return self
@ -486,13 +491,16 @@ end
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
-- @param #number Points (optional) The amount of points in the circle.
-- @param Dcs.DCSTypes#Azimuth Azimuth (optional) Azimuth The azimuth of the flare.
-- @param #number AddHeight (optional) The height to be added for the smoke.
-- @return #ZONE_RADIUS self
function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth )
function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth, AddHeight )
self:F2( { FlareColor, Azimuth } )
local Point = {}
local Vec2 = self:GetVec2()
AddHeight = AddHeight or 0
Points = Points and Points or 360
local Angle
@ -502,7 +510,7 @@ function ZONE_RADIUS:FlareZone( FlareColor, Points, Azimuth )
local Radial = Angle * RadialBase / 360
Point.x = Vec2.x + math.cos( Radial ) * self:GetRadius()
Point.y = Vec2.y + math.sin( Radial ) * self:GetRadius()
POINT_VEC2:New( Point.x, Point.y ):Flare( FlareColor, Azimuth )
POINT_VEC2:New( Point.x, Point.y, AddHeight ):Flare( FlareColor, Azimuth )
end
return self

File diff suppressed because it is too large Load Diff

View File

@ -110,9 +110,33 @@ GROUPTEMPLATE.Takeoff = {
[GROUP.Takeoff.Cold] = { "TakeOffParking", "From Parking Area" }
}
--- Create a new GROUP from a DCSGroup
--- Create a new GROUP from a given GroupTemplate as a parameter.
-- Note that the GroupTemplate is NOT spawned into the mission.
-- It is merely added to the @{Database}.
-- @param #GROUP self
-- @param Dcs.DCSWrapper.Group#Group GroupName The DCS Group name
-- @param #table GroupTemplate The GroupTemplate Structure exactly as defined within the mission editor.
-- @param Dcs.DCScoalition#coalition.side CoalitionSide The coalition.side of the group.
-- @param Dcs.DCSGroup#Group.Category CategoryID The Group.Category of the group.
-- @param Dcs.DCScountry#country.id CountryID the country.id of the group.
-- @return #GROUP self
function GROUP:NewTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID )
local GroupName = GroupTemplate.name
_DATABASE:_RegisterGroupTemplate( GroupTemplate, CategoryID, CountryID, CoalitionSide, GroupName )
self = BASE:Inherit( self, CONTROLLABLE:New( GroupName ) )
self:F2( GroupName )
self.GroupName = GroupName
_DATABASE:AddGroup( GroupName )
self:SetEventPriority( 4 )
return self
end
--- Create a new GROUP from an existing Group in the Mission.
-- @param #GROUP self
-- @param #string GroupName The Group name
-- @return #GROUP self
function GROUP:Register( GroupName )
self = BASE:Inherit( self, CONTROLLABLE:New( GroupName ) )

View File

@ -1,5 +1,5 @@
env.info('*** MOOSE DYNAMIC INCLUDE START *** ')
env.info('Moose Generation Timestamp: 20171010_2141')
env.info('Moose Generation Timestamp: 20171021_1203')
local base=_G
__Moose={}
__Moose.Include=function(IncludeFile)

View File

@ -165,19 +165,7 @@
<h2><a id="#(AIRBASEPOLICE_BASE)">Type <code>AIRBASEPOLICE_BASE</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).AirbaseNames">AIRBASEPOLICE_BASE.AirbaseNames</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).Monitor">AIRBASEPOLICE_BASE:Monitor(AirbaseNames)</a></td>
<td class="summary">
<p>Monitor a table of airbase names.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).New">AIRBASEPOLICE_BASE:New(SetClient, Airbases)</a></td>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).New">AIRBASEPOLICE_BASE:New(SetClient, Airbases, AirbaseList)</a></td>
<td class="summary">
<p>Creates a new AIRBASEPOLICE_BASE object.</p>
</td>
@ -186,6 +174,12 @@
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).SetClient">AIRBASEPOLICE_BASE.SetClient</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_BASE).SmokeRunways">AIRBASEPOLICE_BASE:SmokeRunways(SmokeColor)</a></td>
<td class="summary">
<p>Smoke the airbases runways.</p>
</td>
</tr>
<tr>
@ -199,7 +193,7 @@
<h2><a id="#(AIRBASEPOLICE_CAUCASUS)">Type <code>AIRBASEPOLICE_CAUCASUS</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_CAUCASUS).New">AIRBASEPOLICE_CAUCASUS:New(SetClient)</a></td>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_CAUCASUS).New">AIRBASEPOLICE_CAUCASUS:New(SetClient, AirbaseNames)</a></td>
<td class="summary">
<p>Creates a new AIRBASEPOLICE_CAUCASUS object.</p>
</td>
@ -209,7 +203,7 @@
<h2><a id="#(AIRBASEPOLICE_NEVADA)">Type <code>AIRBASEPOLICE_NEVADA</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_NEVADA).New">AIRBASEPOLICE_NEVADA:New(SetClient)</a></td>
<td class="name" nowrap="nowrap"><a href="##(AIRBASEPOLICE_NEVADA).New">AIRBASEPOLICE_NEVADA:New(SetClient, AirbaseNames)</a></td>
<td class="summary">
<p>Creates a new AIRBASEPOLICE_NEVADA object.</p>
</td>
@ -418,49 +412,8 @@ AirbasePoliceNevada = AIRBASEPOLICE_NEVADA:New( AllClientsSet )
<dl class="function">
<dt>
<em></em>
<a id="#(AIRBASEPOLICE_BASE).AirbaseNames" >
<strong>AIRBASEPOLICE_BASE.AirbaseNames</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(AIRBASEPOLICE_BASE).Monitor" >
<strong>AIRBASEPOLICE_BASE:Monitor(AirbaseNames)</strong>
</a>
</dt>
<dd>
<p>Monitor a table of airbase names.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="##(AIRBASEPOLICE_BASE.AirbaseNames)">#AIRBASEPOLICE_BASE.AirbaseNames</a> AirbaseNames </em></code>:
A list of AirbaseNames to monitor. If this parameters is nil, then all airbases will be monitored.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(AIRBASEPOLICE_BASE)">#AIRBASEPOLICE_BASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(AIRBASEPOLICE_BASE).New" >
<strong>AIRBASEPOLICE_BASE:New(SetClient, Airbases)</strong>
<strong>AIRBASEPOLICE_BASE:New(SetClient, Airbases, AirbaseList)</strong>
</a>
</dt>
<dd>
@ -480,6 +433,11 @@ A SET_CLIENT object that will contain the CLIENT objects to be monitored if they
<p><code><em> Airbases </em></code>:
A table of Airbase Names.</p>
</li>
<li>
<p><code><em> AirbaseList </em></code>: </p>
</li>
</ul>
<h3>Return value</h3>
@ -501,6 +459,33 @@ self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(AIRBASEPOLICE_BASE).SmokeRunways" >
<strong>AIRBASEPOLICE_BASE:SmokeRunways(SmokeColor)</strong>
</a>
</dt>
<dd>
<p>Smoke the airbases runways.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="Utilities.Utils.html##(SMOKECOLOR)">Utilities.Utils#SMOKECOLOR</a> SmokeColor </em></code>:
The color of the smoke around the runways.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="##(AIRBASEPOLICE_BASE)">#AIRBASEPOLICE_BASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
@ -525,20 +510,26 @@ self</p>
<dt>
<a id="#(AIRBASEPOLICE_CAUCASUS).New" >
<strong>AIRBASEPOLICE_CAUCASUS:New(SetClient)</strong>
<strong>AIRBASEPOLICE_CAUCASUS:New(SetClient, AirbaseNames)</strong>
</a>
</dt>
<dd>
<p>Creates a new AIRBASEPOLICE_CAUCASUS object.</p>
<h3>Parameter</h3>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em> SetClient </em></code>:
A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase.</p>
</li>
<li>
<p><code><em> AirbaseNames </em></code>:
A list {} of airbase names (Use AIRBASE.Caucasus enumerator).</p>
</li>
</ul>
<h3>Return value</h3>
@ -555,20 +546,26 @@ self</p>
<dt>
<a id="#(AIRBASEPOLICE_NEVADA).New" >
<strong>AIRBASEPOLICE_NEVADA:New(SetClient)</strong>
<strong>AIRBASEPOLICE_NEVADA:New(SetClient, AirbaseNames)</strong>
</a>
</dt>
<dd>
<p>Creates a new AIRBASEPOLICE_NEVADA object.</p>
<h3>Parameter</h3>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em> SetClient </em></code>:
A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase.</p>
</li>
<li>
<p><code><em> AirbaseNames </em></code>:
A list {} of airbase names (Use AIRBASE.Nevada enumerator).</p>
</li>
</ul>
<h3>Return value</h3>

View File

@ -3806,7 +3806,6 @@ The range till cargo will board.</p>
<dl class="function">
<dt>
<em>#number</em>
<a id="#(CARGO_UNIT).RunCount" >
<strong>CARGO_UNIT.RunCount</strong>
</a>

View File

@ -1106,7 +1106,7 @@ function below will use the range 1-7 just in case</p>
<dl class="function">
<dt>
<em>#number</em>
<em></em>
<a id="#(DESIGNATE).LaseDuration" >
<strong>DESIGNATE.LaseDuration</strong>
</a>

View File

@ -237,6 +237,7 @@ on defined intervals (currently every minute).</p>
<dl class="function">
<dt>
<em>#number</em>
<a id="#(MOVEMENT).AliveUnits" >
<strong>MOVEMENT.AliveUnits</strong>
</a>
@ -245,6 +246,9 @@ on defined intervals (currently every minute).</p>
<p> Contains the counter how many units are currently alive</p>
</dd>
</dl>
<dl class="function">

View File

@ -1983,6 +1983,7 @@ The height in meters to add to the altitude of the positionable.</p>
<dl class="function">
<dt>
<em><a href="Core.Spot.html##(SPOT)">Core.Spot#SPOT</a></em>
<a id="#(POSITIONABLE).Spot" >
<strong>POSITIONABLE.Spot</strong>
</a>

View File

@ -2308,6 +2308,9 @@ The group that was spawned. You can use this group for further actions.</p>
<p> Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.</p>
</dd>
</dl>
<dl class="function">
@ -3282,7 +3285,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
<dl class="function">
<dt>
<em></em>
<em>#boolean</em>
<a id="#(SPAWN).SpawnUnControlled" >
<strong>SPAWN.SpawnUnControlled</strong>
</a>