diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 3f48db8b3..58f12c4f1 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -3326,6 +3326,405 @@ function SET_CLIENT:IsIncludeObject( MClient ) return MClientInclude end +--- SET_PLAYER + + +--- @type SET_PLAYER +-- @extends Core.Set#SET_BASE + + + +--- # 4) SET_PLAYER class, extends @{Set#SET_BASE} +-- +-- Mission designers can use the @{Set#SET_PLAYER} class to build sets of units belonging to alive players: +-- +-- ## 4.1) SET_PLAYER constructor +-- +-- Create a new SET_PLAYER object with the @{#SET_PLAYER.New} method: +-- +-- * @{#SET_PLAYER.New}: Creates a new SET_PLAYER object. +-- +-- ## 4.3) SET_PLAYER filter criteria +-- +-- You can set filter criteria to define the set of clients within the SET_PLAYER. +-- Filter criteria are defined by: +-- +-- * @{#SET_PLAYER.FilterCoalitions}: Builds the SET_PLAYER with the clients belonging to the coalition(s). +-- * @{#SET_PLAYER.FilterCategories}: Builds the SET_PLAYER with the clients belonging to the category(ies). +-- * @{#SET_PLAYER.FilterTypes}: Builds the SET_PLAYER with the clients belonging to the client type(s). +-- * @{#SET_PLAYER.FilterCountries}: Builds the SET_PLAYER with the clients belonging to the country(ies). +-- * @{#SET_PLAYER.FilterPrefixes}: Builds the SET_PLAYER with the clients starting with the same prefix string(s). +-- +-- Once the filter criteria have been set for the SET_PLAYER, you can start filtering using: +-- +-- * @{#SET_PLAYER.FilterStart}: Starts the filtering of the clients within the SET_PLAYER. +-- +-- Planned filter criteria within development are (so these are not yet available): +-- +-- * @{#SET_PLAYER.FilterZones}: Builds the SET_PLAYER with the clients within a @{Zone#ZONE}. +-- +-- ## 4.4) SET_PLAYER iterators +-- +-- Once the filters have been defined and the SET_PLAYER has been built, you can iterate the SET_PLAYER with the available iterator methods. +-- The iterator methods will walk the SET_PLAYER set, and call for each element within the set a function that you provide. +-- The following iterator methods are currently available within the SET_PLAYER: +-- +-- * @{#SET_PLAYER.ForEachClient}: Calls a function for each alive client it finds within the SET_PLAYER. +-- +-- === +-- @field #SET_PLAYER SET_PLAYER +SET_PLAYER = { + ClassName = "SET_PLAYER", + Clients = {}, + Filter = { + Coalitions = nil, + Categories = nil, + Types = nil, + Countries = nil, + ClientPrefixes = nil, + }, + FilterMeta = { + Coalitions = { + red = coalition.side.RED, + blue = coalition.side.BLUE, + neutral = coalition.side.NEUTRAL, + }, + Categories = { + plane = Unit.Category.AIRPLANE, + helicopter = Unit.Category.HELICOPTER, + ground = Unit.Category.GROUND_UNIT, + ship = Unit.Category.SHIP, + structure = Unit.Category.STRUCTURE, + }, + }, +} + + +--- Creates a new SET_PLAYER object, building a set of clients belonging to a coalitions, categories, countries, types or with defined prefix names. +-- @param #SET_PLAYER self +-- @return #SET_PLAYER +-- @usage +-- -- Define a new SET_PLAYER Object. This DBObject will contain a reference to all Clients. +-- DBObject = SET_PLAYER:New() +function SET_PLAYER:New() + -- Inherits from BASE + local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.PLAYERS ) ) + + return self +end + +--- Add CLIENT(s) to SET_PLAYER. +-- @param Core.Set#SET_PLAYER self +-- @param #string AddClientNames A single name or an array of CLIENT names. +-- @return self +function SET_PLAYER:AddClientsByName( AddClientNames ) + + local AddClientNamesArray = ( type( AddClientNames ) == "table" ) and AddClientNames or { AddClientNames } + + for AddClientID, AddClientName in pairs( AddClientNamesArray ) do + self:Add( AddClientName, CLIENT:FindByName( AddClientName ) ) + end + + return self +end + +--- Remove CLIENT(s) from SET_PLAYER. +-- @param Core.Set#SET_PLAYER self +-- @param Wrapper.Client#CLIENT RemoveClientNames A single name or an array of CLIENT names. +-- @return self +function SET_PLAYER:RemoveClientsByName( RemoveClientNames ) + + local RemoveClientNamesArray = ( type( RemoveClientNames ) == "table" ) and RemoveClientNames or { RemoveClientNames } + + for RemoveClientID, RemoveClientName in pairs( RemoveClientNamesArray ) do + self:Remove( RemoveClientName.ClientName ) + end + + return self +end + + +--- Finds a Client based on the Player Name. +-- @param #SET_PLAYER self +-- @param #string PlayerName +-- @return Wrapper.Client#CLIENT The found Client. +function SET_PLAYER:FindClient( PlayerName ) + + local ClientFound = self.Set[PlayerName] + return ClientFound +end + + + +--- Builds a set of clients of coalitions joined by specific players. +-- Possible current coalitions are red, blue and neutral. +-- @param #SET_PLAYER self +-- @param #string Coalitions Can take the following values: "red", "blue", "neutral". +-- @return #SET_PLAYER self +function SET_PLAYER:FilterCoalitions( Coalitions ) + if not self.Filter.Coalitions then + self.Filter.Coalitions = {} + end + if type( Coalitions ) ~= "table" then + Coalitions = { Coalitions } + end + for CoalitionID, Coalition in pairs( Coalitions ) do + self.Filter.Coalitions[Coalition] = Coalition + end + return self +end + + +--- Builds a set of clients out of categories joined by players. +-- Possible current categories are plane, helicopter, ground, ship. +-- @param #SET_PLAYER self +-- @param #string Categories Can take the following values: "plane", "helicopter", "ground", "ship". +-- @return #SET_PLAYER self +function SET_PLAYER:FilterCategories( Categories ) + if not self.Filter.Categories then + self.Filter.Categories = {} + end + if type( Categories ) ~= "table" then + Categories = { Categories } + end + for CategoryID, Category in pairs( Categories ) do + self.Filter.Categories[Category] = Category + end + return self +end + + +--- Builds a set of clients of defined client types joined by players. +-- Possible current types are those types known within DCS world. +-- @param #SET_PLAYER self +-- @param #string Types Can take those type strings known within DCS world. +-- @return #SET_PLAYER self +function SET_PLAYER:FilterTypes( Types ) + if not self.Filter.Types then + self.Filter.Types = {} + end + if type( Types ) ~= "table" then + Types = { Types } + end + for TypeID, Type in pairs( Types ) do + self.Filter.Types[Type] = Type + end + return self +end + + +--- Builds a set of clients of defined countries. +-- Possible current countries are those known within DCS world. +-- @param #SET_PLAYER self +-- @param #string Countries Can take those country strings known within DCS world. +-- @return #SET_PLAYER self +function SET_PLAYER:FilterCountries( Countries ) + if not self.Filter.Countries then + self.Filter.Countries = {} + end + if type( Countries ) ~= "table" then + Countries = { Countries } + end + for CountryID, Country in pairs( Countries ) do + self.Filter.Countries[Country] = Country + end + return self +end + + +--- Builds a set of clients of defined client prefixes. +-- All the clients starting with the given prefixes will be included within the set. +-- @param #SET_PLAYER self +-- @param #string Prefixes The prefix of which the client name starts with. +-- @return #SET_PLAYER self +function SET_PLAYER:FilterPrefixes( Prefixes ) + if not self.Filter.ClientPrefixes then + self.Filter.ClientPrefixes = {} + end + if type( Prefixes ) ~= "table" then + Prefixes = { Prefixes } + end + for PrefixID, Prefix in pairs( Prefixes ) do + self.Filter.ClientPrefixes[Prefix] = Prefix + end + return self +end + + + + +--- Starts the filtering. +-- @param #SET_PLAYER self +-- @return #SET_PLAYER self +function SET_PLAYER:FilterStart() + + if _DATABASE then + self:_FilterStart() + end + + return self +end + +--- Handles the Database to check on an event (birth) that the Object was added in the Database. +-- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! +-- @param #SET_PLAYER self +-- @param Core.Event#EVENTDATA Event +-- @return #string The name of the CLIENT +-- @return #table The CLIENT +function SET_PLAYER:AddInDatabase( Event ) + self:F3( { Event } ) + + return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] +end + +--- Handles the Database to check on any event that Object exists in the Database. +-- This is required, because sometimes the _DATABASE event gets called later than the SET_BASE event or vise versa! +-- @param #SET_PLAYER self +-- @param Core.Event#EVENTDATA Event +-- @return #string The name of the CLIENT +-- @return #table The CLIENT +function SET_PLAYER:FindInDatabase( Event ) + self:F3( { Event } ) + + return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] +end + +--- Iterate the SET_PLAYER and call an interator function for each **alive** CLIENT, providing the CLIENT and optional parameters. +-- @param #SET_PLAYER self +-- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter. +-- @return #SET_PLAYER self +function SET_PLAYER:ForEachPlayer( IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set ) + + return self +end + +--- Iterate the SET_PLAYER and call an iterator function for each **alive** CLIENT presence completely in a @{Zone}, providing the CLIENT and optional parameters to the called function. +-- @param #SET_PLAYER self +-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. +-- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter. +-- @return #SET_PLAYER self +function SET_PLAYER:ForEachPlayerInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set, + --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self +end + +--- Iterate the SET_PLAYER and call an iterator function for each **alive** CLIENT presence not in a @{Zone}, providing the CLIENT and optional parameters to the called function. +-- @param #SET_PLAYER self +-- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. +-- @param #function IteratorFunction The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter. +-- @return #SET_PLAYER self +function SET_PLAYER:ForEachPlayerNotInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self.Set, + --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Client#CLIENT ClientObject + function( ZoneObject, ClientObject ) + if ClientObject:IsNotInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self +end + +--- +-- @param #SET_PLAYER self +-- @param Wrapper.Client#CLIENT MClient +-- @return #SET_PLAYER self +function SET_PLAYER:IsIncludeObject( MClient ) + self:F2( MClient ) + + local MClientInclude = true + + if MClient then + local MClientName = MClient.UnitName + + if self.Filter.Coalitions then + local MClientCoalition = false + for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do + local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName ) + self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } ) + if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then + MClientCoalition = true + end + end + self:T( { "Evaluated Coalition", MClientCoalition } ) + MClientInclude = MClientInclude and MClientCoalition + end + + if self.Filter.Categories then + local MClientCategory = false + for CategoryID, CategoryName in pairs( self.Filter.Categories ) do + local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName ) + self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } ) + if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then + MClientCategory = true + end + end + self:T( { "Evaluated Category", MClientCategory } ) + MClientInclude = MClientInclude and MClientCategory + end + + if self.Filter.Types then + local MClientType = false + for TypeID, TypeName in pairs( self.Filter.Types ) do + self:T3( { "Type:", MClient:GetTypeName(), TypeName } ) + if TypeName == MClient:GetTypeName() then + MClientType = true + end + end + self:T( { "Evaluated Type", MClientType } ) + MClientInclude = MClientInclude and MClientType + end + + if self.Filter.Countries then + local MClientCountry = false + for CountryID, CountryName in pairs( self.Filter.Countries ) do + local ClientCountryID = _DATABASE:GetCountryFromClientTemplate(MClientName) + self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } ) + if country.id[CountryName] and country.id[CountryName] == ClientCountryID then + MClientCountry = true + end + end + self:T( { "Evaluated Country", MClientCountry } ) + MClientInclude = MClientInclude and MClientCountry + end + + if self.Filter.ClientPrefixes then + local MClientPrefix = false + for ClientPrefixId, ClientPrefix in pairs( self.Filter.ClientPrefixes ) do + self:T3( { "Prefix:", string.find( MClient.UnitName, ClientPrefix, 1 ), ClientPrefix } ) + if string.find( MClient.UnitName, ClientPrefix, 1 ) then + MClientPrefix = true + end + end + self:T( { "Evaluated Prefix", MClientPrefix } ) + MClientInclude = MClientInclude and MClientPrefix + end + end + + self:T2( MClientInclude ) + return MClientInclude +end + --- @type SET_AIRBASE -- @extends Core.Set#SET_BASE diff --git a/Moose Development/Moose/Core/Velocity.lua b/Moose Development/Moose/Core/Velocity.lua new file mode 100644 index 000000000..333ad0f88 --- /dev/null +++ b/Moose Development/Moose/Core/Velocity.lua @@ -0,0 +1,184 @@ +--- **Core** -- VELOCITY models a speed, which can be expressed in various formats according the Settings. +-- +-- === +-- +-- ### Author: **Sven Van de Velde (FlightControl)** +-- ### Contributions: +-- +-- ==== +-- +-- @module Base + +do -- Velocity + + --- @type VELOCITY + -- @extends Core.Base#BASE + + + --- # VELOCITY class, extends @{Base#BASE} + -- + -- VELOCITY models a speed, which can be expressed in various formats according the Settings. + -- + -- ## 1. VELOCITY constructor + -- + -- * @{#VELOCITY.New}(): Creates a new VELOCITY object. + -- + -- @field #VELOCITY + VELOCITY = { + ClassName = "VELOCITY", + } + + --- VELOCITY Constructor. + -- @param #VELOCITY self + -- @param #number VelocityMps The velocity in meters per second. + -- @return #VELOCITY + function VELOCITY:New( VelocityMps ) + local self = BASE:Inherit( self, BASE:New() ) -- #VELOCITY + self:F( {} ) + self.Velocity = VelocityMps + return self + end + + --- Set the velocity in Mps (meters per second). + -- @param #VELOCITY self + -- @param #number VelocityMps The velocity in meters per second. + -- @return #VELOCITY + function VELOCITY:Set( VelocityMps ) + self.Velocity = VelocityMps + return self + end + + --- Get the velocity in Mps (meters per second). + -- @param #VELOCITY self + -- @return #number The velocity in meters per second. + function VELOCITY:Get() + return self.Velocity + end + + --- Set the velocity in Kmph (kilometers per hour). + -- @param #VELOCITY self + -- @param #number VelocityKmph The velocity in kilometers per hour. + -- @return #VELOCITY + function VELOCITY:SetKmph( VelocityKmph ) + self.Velocity = UTILS.KmphToMps( VelocityKmph ) + return self + end + + --- Get the velocity in Kmph (kilometers per hour). + -- @param #VELOCITY self + -- @return #number The velocity in kilometers per hour. + function VELOCITY:GetKmph() + + return UTILS.MpsToKmph( self.Velocity ) + end + + --- Set the velocity in Miph (miles per hour). + -- @param #VELOCITY self + -- @param #number VelocityMiph The velocity in miles per hour. + -- @return #VELOCITY + function VELOCITY:SetMiph( VelocityMiph ) + self.Velocity = UTILS.MiphToMps( VelocityMiph ) + return self + end + + --- Get the velocity in Miph (miles per hour). + -- @param #VELOCITY self + -- @return #number The velocity in miles per hour. + function VELOCITY:GetMiph() + return UTILS.MpsToMiph( self.Velocity ) + end + + + --- Get the velocity in text, according the player @{Settings}. + -- @param #VELOCITY self + -- @param Core.Settings#SETTINGS Settings + -- @return #string The velocity in text. + function VELOCITY:GetText( Settings ) + local Settings = Settings or _SETTINGS + if self.Velocity ~= 0 then + if Settings:IsMetric() then + return string.format( "%d km/h", UTILS.MpsToKmph( self.Velocity ) ) + else + return string.format( "%d mi/h", UTILS.MpsToMiph( self.Velocity ) ) + end + else + return "stationary" + end + end + + --- Get the velocity in text, according the player or default @{Settings}. + -- @param #VELOCITY self + -- @param Wrapper.Controllable#CONTROLLABLE Controllable + -- @param Core.Settings#SETTINGS Settings + -- @return #string The velocity in text according the player or default @{Settings} + function VELOCITY:ToString( VelocityGroup, Settings ) -- R2.3 + self:F( { Group = VelocityGroup and VelocityGroup:GetName() } ) + local Settings = Settings or ( VelocityGroup and _DATABASE:GetPlayerSettings( VelocityGroup:GetPlayerName() ) ) or _SETTINGS + return self:GetText( Settings ) + end + +end + +do -- VELOCITY_POSITIONABLE + + --- @type VELOCITY_POSITIONABLE + -- @extends Core.Base#BASE + + + --- # VELOCITY_POSITIONABLE class, extends @{Base#BASE} + -- + -- VELOCITY_POSITIONABLE monitors the speed of an @{Positionable} in the simulation, which can be expressed in various formats according the Settings. + -- + -- ## 1. VELOCITY_POSITIONABLE constructor + -- + -- * @{#VELOCITY_POSITIONABLE.New}(): Creates a new VELOCITY_POSITIONABLE object. + -- + -- @field #VELOCITY_POSITIONABLE + VELOCITY_POSITIONABLE = { + ClassName = "VELOCITY_POSITIONABLE", + } + + --- VELOCITY_POSITIONABLE Constructor. + -- @param #VELOCITY_POSITIONABLE self + -- @param Wrapper.Positionable#POSITIONABLE Positionable The Positionable to monitor the speed. + -- @return #VELOCITY_POSITIONABLE + function VELOCITY_POSITIONABLE:New( Positionable ) + local self = BASE:Inherit( self, VELOCITY:New() ) -- #VELOCITY_POSITIONABLE + self:F( {} ) + self.Positionable = Positionable + return self + end + + --- Get the velocity in Mps (meters per second). + -- @param #VELOCITY_POSITIONABLE self + -- @return #number The velocity in meters per second. + function VELOCITY_POSITIONABLE:Get() + return self.Positionable:GetVelocityMPS() or 0 + end + + --- Get the velocity in Kmph (kilometers per hour). + -- @param #VELOCITY_POSITIONABLE self + -- @return #number The velocity in kilometers per hour. + function VELOCITY_POSITIONABLE:GetKmph() + + return UTILS.MpsToKmph( self.Positionable:GetVelocityMPS() or 0) + end + + --- Get the velocity in Miph (miles per hour). + -- @param #VELOCITY_POSITIONABLE self + -- @return #number The velocity in miles per hour. + function VELOCITY_POSITIONABLE:GetMiph() + return UTILS.MpsToMiph( self.Positionable:GetVelocityMPS() or 0 ) + end + + --- Get the velocity in text, according the player or default @{Settings}. + -- @param #VELOCITY_POSITIONABLE self + -- @return #string The velocity in text according the player or default @{Settings} + function VELOCITY_POSITIONABLE:ToString() -- R2.3 + self:F( { Group = self.Positionable and self.Positionable:GetName() } ) + local Settings = Settings or ( self.Positionable and _DATABASE:GetPlayerSettings( self.Positionable:GetPlayerName() ) ) or _SETTINGS + self.Velocity = self.Positionable:GetVelocityMPS() + return self:GetText( Settings ) + end + +end \ No newline at end of file diff --git a/Moose Development/Moose/Functional/AirbasePolice.lua b/Moose Development/Moose/Functional/AirbasePolice.lua index 7d5f5811f..912fac1ad 100644 --- a/Moose Development/Moose/Functional/AirbasePolice.lua +++ b/Moose Development/Moose/Functional/AirbasePolice.lua @@ -29,19 +29,19 @@ AIRBASEPOLICE_BASE = { --- Creates a new AIRBASEPOLICE_BASE object. -- @param #AIRBASEPOLICE_BASE self --- @param SetClient A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase. -- @param Airbases A table of Airbase Names. -- @return #AIRBASEPOLICE_BASE self -function AIRBASEPOLICE_BASE:New( SetClient, Airbases, AirbaseList ) +function AIRBASEPOLICE_BASE:New( Airbases, AirbaseList ) -- Inherits from BASE - local self = BASE:Inherit( self, BASE:New() ) - self:E( { self.ClassName, SetClient, Airbases } ) + local self = BASE:Inherit( self, BASE:New() ) -- #AIRBASEPOLICE_BASE + self:E( { self.ClassName, Airbases } ) - self.SetClient = SetClient self.Airbases = Airbases - self.AirbaseList = AirbaseList + + self.SetClient = SET_CLIENT:New():FilterCategories( "plane" ):FilterStart() + for AirbaseID, Airbase in pairs( self.Airbases ) do Airbase.ZoneBoundary = _DATABASE:FindAirbase( AirbaseID ):GetZone() @@ -69,15 +69,19 @@ function AIRBASEPOLICE_BASE:New( SetClient, Airbases, AirbaseList ) function( Client ) Client:SetState( self, "Speeding", false ) Client:SetState( self, "Warnings", 0) + Client:SetState( self, "IsOffRunway", false ) + Client:SetState( self, "OffRunwayWarnings", 0 ) Client:SetState( self, "Taxi", false ) end ) - self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, {}, 0, 2, 0.05 ) + self.AirbaseMonitor = SCHEDULER:New( self, self._AirbaseMonitor, {self }, 0, 2, 0.05 ) -- This is simple slot blocker is used on the server. SSB = USERFLAG:New( "SSB" ) SSB:Set( 100 ) + + self:SetKickSpeedKmph( 100 ) return self end @@ -97,14 +101,36 @@ function AIRBASEPOLICE_BASE:SmokeRunways( SmokeColor ) end +--- Set the maximum speed in Kmph until the player gets kicked. +-- @param #AIRBASEPOLICE_BASE self +-- @param #number KickSpeed Set the maximum speed in Kmph until the player gets kicked. +-- @return #AIRBASEPOLICE_BASE self +function AIRBASEPOLICE_BASE:SetKickSpeedKmph( KickSpeed ) + + self.KickSpeed = UTILS.KmphToMps( KickSpeed ) +end + +--- Set the maximum speed in Miph until the player gets kicked. +-- @param #AIRBASEPOLICE_BASE self +-- @param #number KickSpeedMiph Set the maximum speed in Mph until the player gets kicked. +-- @return #AIRBASEPOLICE_BASE self +function AIRBASEPOLICE_BASE:SetKickSpeedMiph( KickSpeedMiph ) + + self.KickSpeed = UTILS.MiphToMps( KickSpeedMiph ) +end + + + --- @param #AIRBASEPOLICE_BASE self function AIRBASEPOLICE_BASE:_AirbaseMonitor() + self:E( "In Scheduler") + for AirbaseID, AirbaseMeta in pairs( self.Airbases ) do if AirbaseMeta.Monitor == true then - self:E( AirbaseID ) + self:E( AirbaseID, AirbaseMeta.MaximumSpeed ) self.SetClient:ForEachClientInZone( AirbaseMeta.ZoneBoundary, @@ -112,32 +138,40 @@ function AIRBASEPOLICE_BASE:_AirbaseMonitor() function( Client ) self:E( Client.UnitName ) - if Client:IsAlive() then + if Client and Client:IsAlive() then local NotInRunwayZone = true for ZoneRunwayID, ZoneRunway in pairs( AirbaseMeta.ZoneRunways ) do NotInRunwayZone = ( Client:IsNotInZone( ZoneRunway ) == true ) and NotInRunwayZone or false end if NotInRunwayZone then - local Taxi = self:GetState( self, "Taxi" ) + local Taxi = Client:GetState( self, "Taxi" ) self:E( Taxi ) if Taxi == false then - Client:Message( "Welcome at " .. AirbaseID .. ". The maximum taxiing speed is " .. AirbaseMeta.MaximumSpeed " km/h.", 20, "ATC" ) - self:SetState( self, "Taxi", true ) + Client:Message( "Welcome at " .. AirbaseID .. ". The maximum taxiing speed is " .. AirbaseMeta.MaximumSpeed .. " km/h.", 20, "ATC" ) + Client:SetState( self, "Taxi", true ) end -- TODO: GetVelocityKMH function usage - local VelocityVec3 = Client:GetVelocity() - local Velocity = ( VelocityVec3.x ^ 2 + VelocityVec3.y ^ 2 + VelocityVec3.z ^ 2 ) ^ 0.5 -- in meters / sec - local Velocity = Velocity * 3.6 -- now it is in km/h. - -- MESSAGE:New( "Velocity = " .. Velocity, 1 ):ToAll() + local Velocity = VELOCITY_POSITIONABLE:New( Client ) + --MESSAGE:New( "Velocity = " .. Velocity:ToString(), 1 ):ToAll() local IsAboveRunway = Client:IsAboveRunway() local IsOnGround = Client:InAir() == false self:T( IsAboveRunway, IsOnGround ) - if IsAboveRunway and IsOnGround then + if IsOnGround then + if Velocity:Get() > self.KickSpeed then + MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " is kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll() + Client:Destroy() + Client:SetState( self, "Speeding", false ) + Client:SetState( self, "Warnings", 0 ) + end + end + - if Velocity > AirbaseMeta.MaximumSpeed then + if IsOnGround then + + if Velocity:GetKmph() > AirbaseMeta.MaximumSpeed then local IsSpeeding = Client:GetState( self, "Speeding" ) if IsSpeeding == true then @@ -146,7 +180,7 @@ function AIRBASEPOLICE_BASE:_AirbaseMonitor() if SpeedingWarnings <= 3 then Client:Message( "Warning " .. SpeedingWarnings .. "/3! Airbase traffic rule violation! Slow down now! Your speed is " .. - string.format( "%2.0f km/h", Velocity ), 5, "ATC" ) + string.format( "%s", Velocity:ToString() ), 5, "ATC" ) Client:SetState( self, "Warnings", SpeedingWarnings + 1 ) else MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " is kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll() @@ -157,7 +191,7 @@ function AIRBASEPOLICE_BASE:_AirbaseMonitor() end else - Client:Message( "Attention! You are speeding on the taxiway, slow down! Your speed is " .. string.format( "%2.0f km/h", Velocity ), 5, "ATC" ) + Client:Message( "Attention! You are speeding on the taxiway, slow down! Your speed is " .. string.format( "%s", Velocity:ToString() ), 5, "ATC" ) Client:SetState( self, "Speeding", true ) Client:SetState( self, "Warnings", 1 ) end @@ -168,13 +202,45 @@ function AIRBASEPOLICE_BASE:_AirbaseMonitor() end end + if IsOnGround and not IsAboveRunway then + + local IsOffRunway = Client:GetState( self, "IsOffRunway" ) + + if IsOffRunway == true then + local OffRunwayWarnings = Client:GetState( self, "OffRunwayWarnings" ) + self:T( OffRunwayWarnings ) + + if OffRunwayWarnings <= 3 then + Client:Message( "Warning " .. OffRunwayWarnings .. "/3! Airbase traffic rule violation! Get back on the taxi immediately!", 5, "ATC" ) + Client:SetState( self, "OffRunwayWarnings", OffRunwayWarnings + 1 ) + else + MESSAGE:New( "Penalty! Player " .. Client:GetPlayerName() .. " is kicked, due to a severe airbase traffic rule violation ...", 10, "ATC" ):ToAll() + --- @param Wrapper.Client#CLIENT Client + Client:Destroy() + Client:SetState( self, "IsOffRunway", false ) + Client:SetState( self, "OffRunwayWarnings", 0 ) + end + else + Client:Message( "Attention! You are off the taxiway. Get back on the taxiway immediately!", 5, "ATC" ) + Client:SetState( self, "IsOffRunway", true ) + Client:SetState( self, "OffRunwayWarnings", 1 ) + end + + else + Client:SetState( self, "IsOffRunway", false ) + Client:SetState( self, "OffRunwayWarnings", 0 ) + end + + else Client:SetState( self, "Speeding", false ) Client:SetState( self, "Warnings", 0 ) - local Taxi = self:GetState( self, "Taxi" ) + Client:SetState( self, "IsOffRunway", false ) + Client:SetState( self, "OffRunwayWarnings", 0 ) + local Taxi = Client:GetState( self, "Taxi" ) if Taxi == true then Client:Message( "You have progressed to the runway ... Await take-off clearance ...", 20, "ATC" ) - self:SetState( self, "Taxi", false ) + Client:SetState( self, "Taxi", false ) end end end @@ -257,11 +323,8 @@ end -- -- -- This creates a new AIRBASEPOLICE_CAUCASUS object. -- --- -- Create a set of all clients in the mission. --- AllClientsSet = SET_CLIENT:New():FilterStart() --- -- -- Monitor for these clients the airbases. --- AirbasePoliceCaucasus = AIRBASEPOLICE_CAUCASUS:New( AllClientsSet ) +-- AirbasePoliceCaucasus = AIRBASEPOLICE_CAUCASUS:New() -- -- @field #AIRBASEPOLICE_CAUCASUS AIRBASEPOLICE_CAUCASUS = { @@ -554,13 +617,12 @@ AIRBASEPOLICE_CAUCASUS = { --- Creates a new AIRBASEPOLICE_CAUCASUS object. -- @param #AIRBASEPOLICE_CAUCASUS self --- @param SetClient A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase. -- @param AirbaseNames A list {} of airbase names (Use AIRBASE.Caucasus enumerator). -- @return #AIRBASEPOLICE_CAUCASUS self -function AIRBASEPOLICE_CAUCASUS:New( SetClient, AirbaseNames ) +function AIRBASEPOLICE_CAUCASUS:New( AirbaseNames ) -- Inherits from BASE - local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( SetClient, self.Airbases, AirbaseNames ) ) + local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( self.Airbases, AirbaseNames ) ) @@ -828,16 +890,25 @@ end -- -- -- This creates a new AIRBASEPOLICE_NEVADA object. -- --- -- Create a set of all clients in the mission. --- AllClientsSet = SET_CLIENT:New():FilterStart() --- -- -- Monitor for these clients the airbases. --- AirbasePoliceNevada = AIRBASEPOLICE_NEVADA:New( AllClientsSet ) +-- AirbasePoliceCaucasus = AIRBASEPOLICE_NEVADA:New() -- -- @field #AIRBASEPOLICE_NEVADA AIRBASEPOLICE_NEVADA = { ClassName = "AIRBASEPOLICE_NEVADA", Airbases = { + + [AIRBASE.Nevada.Beatty_Airport] = { + PointsRunways = { + [1] = { + [1]={["y"]=-174950.05857143,["x"]=-329679.65,}, + [2]={["y"]=-174946.53828571,["x"]=-331394.03885715,}, + [3]={["y"]=-174967.10971429,["x"]=-331394.32457143,}, + [4]={["y"]=-174971.01828571,["x"]=-329682.59171429,}, + }, + }, + MaximumSpeed = 50, + }, [AIRBASE.Nevada.Boulder_City_Airport] = { PointsRunways = { [1] = { @@ -951,6 +1022,17 @@ AIRBASEPOLICE_NEVADA = { }, MaximumSpeed = 50, }, + [AIRBASE.Nevada.Lincoln_County] = { + PointsRunways = { + [1] = { + [1]={["y"]=33222.34171429,["x"]=-223959.40171429,}, + [2]={["y"]=33200.040000004,["x"]=-225369.36828572,}, + [3]={["y"]=33177.634571428,["x"]=-225369.21485715,}, + [4]={["y"]=33201.198857147,["x"]=-223960.54457143,}, + }, + }, + MaximumSpeed = 50, + }, [AIRBASE.Nevada.McCarran_International_Airport] = { PointsRunways = { [1] = { @@ -1085,13 +1167,12 @@ AIRBASEPOLICE_NEVADA = { --- Creates a new AIRBASEPOLICE_NEVADA object. -- @param #AIRBASEPOLICE_NEVADA self --- @param SetClient A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase. -- @param AirbaseNames A list {} of airbase names (Use AIRBASE.Nevada enumerator). -- @return #AIRBASEPOLICE_NEVADA self -function AIRBASEPOLICE_NEVADA:New( SetClient, AirbaseNames ) +function AIRBASEPOLICE_NEVADA:New( AirbaseNames ) -- Inherits from BASE - local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( SetClient, self.Airbases, AirbaseNames ) ) + local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( self.Airbases, AirbaseNames ) ) @@ -1107,6 +1188,13 @@ function AIRBASEPOLICE_NEVADA:New( SetClient, AirbaseNames ) --[[ + -- Beatty + do + local VillagePrefix = "Beatty" + local Runway1 = GROUP:FindByName( VillagePrefix .. " 1" ) + local Zone1 = ZONE_POLYGON:New( VillagePrefix .. " 1", Runway1 ):SmokeZone(SMOKECOLOR.Red):Flush() + end + -- Boulder do local VillagePrefix = "Boulder" @@ -1168,7 +1256,7 @@ function AIRBASEPOLICE_NEVADA:New( SetClient, AirbaseNames ) -- Lincoln do - local VillagePrefix = "Laughlin" + local VillagePrefix = "Lincoln" local Runway1 = GROUP:FindByName( VillagePrefix .. " 1" ) local Zone1 = ZONE_POLYGON:New( VillagePrefix .. " 1", Runway1 ):SmokeZone(SMOKECOLOR.Red):Flush() end @@ -1299,11 +1387,8 @@ end -- -- -- This creates a new AIRBASEPOLICE_NORMANDY object. -- --- -- Create a set of all clients in the mission. --- AllClientsSet = SET_CLIENT:New():FilterStart() --- -- -- Monitor for these clients the airbases. --- AirbasePoliceCaucasus = AIRBASEPOLICE_NORMANDY:New( AllClientsSet ) +-- AirbasePoliceCaucasus = AIRBASEPOLICE_NORMANDY:New() -- -- @field #AIRBASEPOLICE_NORMANDY AIRBASEPOLICE_NORMANDY = { @@ -1701,13 +1786,12 @@ AIRBASEPOLICE_NORMANDY = { --- Creates a new AIRBASEPOLICE_NORMANDY object. -- @param #AIRBASEPOLICE_NORMANDY self --- @param SetClient A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase. -- @param AirbaseNames A list {} of airbase names (Use AIRBASE.Normandy enumerator). -- @return #AIRBASEPOLICE_NORMANDY self -function AIRBASEPOLICE_NORMANDY:New( SetClient, AirbaseNames ) +function AIRBASEPOLICE_NORMANDY:New( AirbaseNames ) -- Inherits from BASE - local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( SetClient, self.Airbases, AirbaseNames ) ) + local self = BASE:Inherit( self, AIRBASEPOLICE_BASE:New( self.Airbases, AirbaseNames ) ) -- These lines here are for the demonstration mission. -- They create in the dcs.log the coordinates of the runway polygons, that are then diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index e07579827..02e442d2c 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -544,7 +544,7 @@ do -- TASK_A2G_BAI local TargetCoordinate = self:GetInfo( "Coordinate" ) -- Core.Point#COORDINATE - local Velocity = self.TargetSetUnit:GetVelocity() + local Velocity = self.TargetSetUnit:GetVelocityVec3() local Heading = self.TargetSetUnit:GetHeading() TargetCoordinate:SetHeading( Heading ) diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index c2fb6e081..cd54b4e1f 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -236,26 +236,36 @@ UTILS.FeetToMeters = function(feet) return feet*0.3048 end -UTILS.MpsToKnots = function(mps) - return mps*3600/1852 -end - -UTILS.MpsToKmph = function(mps) - return mps*3.6 -end - -UTILS.KnotsToMps = function(knots) - return knots*1852/3600 -end - UTILS.KnotsToKmph = function(knots) return knots* 1.852 end -UTILS.KmphToMps = function(kmph) - return kmph/3.6 +UTILS.KmphToMps = function( kmph ) + return kmph / 3.6 end +UTILS.MpsToKmph = function( mps ) + return mps * 3.6 +end + +UTILS.MiphToMps = function( miph ) + return miph * 0.44704 +end + +UTILS.MpsToMiph = function( mps ) + return mps / 0.44704 +end + +UTILS.MpsToKnots = function( mps ) + return mps * 3600 / 1852 +end + +UTILS.KnotsToMps = function( knots ) + return knots * 1852 / 3600 +end + + + --[[acc: in DM: decimal point of minutes. In DMS: decimal point of seconds. diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 177875c89..d349211b0 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -326,16 +326,35 @@ function POSITIONABLE:InAir() return nil end - ---- Returns the POSITIONABLE velocity vector. + +--- Returns the a @{Velocity} object from the positionable. -- @param Wrapper.Positionable#POSITIONABLE self --- @return Dcs.DCSTypes#Vec3 The velocity vector +-- @return Core.Velocity#VELOCITY Velocity The Velocity object. -- @return #nil The POSITIONABLE is not existing or alive. function POSITIONABLE:GetVelocity() self:F2( self.PositionableName ) local DCSPositionable = self:GetDCSObject() + if DCSPositionable then + local Velocity = VELOCITY:New( self ) + return Velocity + end + + return nil +end + + + +--- Returns the POSITIONABLE velocity Vec3 vector. +-- @param Wrapper.Positionable#POSITIONABLE self +-- @return Dcs.DCSTypes#Vec3 The velocity Vec3 vector +-- @return #nil The POSITIONABLE is not existing or alive. +function POSITIONABLE:GetVelocityVec3() + self:F2( self.PositionableName ) + + local DCSPositionable = self:GetDCSObject() + if DCSPositionable then local PositionableVelocityVec3 = DCSPositionable:getVelocity() self:T3( PositionableVelocityVec3 ) @@ -377,7 +396,7 @@ function POSITIONABLE:GetVelocityKMH() local DCSPositionable = self:GetDCSObject() if DCSPositionable then - local VelocityVec3 = self:GetVelocity() + local VelocityVec3 = self:GetVelocityVec3() local Velocity = ( VelocityVec3.x ^ 2 + VelocityVec3.y ^ 2 + VelocityVec3.z ^ 2 ) ^ 0.5 -- in meters / sec local Velocity = Velocity * 3.6 -- now it is in km/h. self:T3( Velocity ) @@ -396,7 +415,7 @@ function POSITIONABLE:GetVelocityMPS() local DCSPositionable = self:GetDCSObject() if DCSPositionable then - local VelocityVec3 = self:GetVelocity() + local VelocityVec3 = self:GetVelocityVec3() local Velocity = ( VelocityVec3.x ^ 2 + VelocityVec3.y ^ 2 + VelocityVec3.z ^ 2 ) ^ 0.5 -- in meters / sec self:T3( Velocity ) return Velocity diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 237565886..31eaf98ef 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -761,10 +761,9 @@ function UNIT:IsInZone( Zone ) if self:IsAlive() then local IsInZone = Zone:IsVec3InZone( self:GetVec3() ) - self:T2( { IsInZone } ) + self:E( { Unit = self.UnitName, IsInZone = IsInZone } ) return IsInZone end - return false end diff --git a/Moose Mission Setup/Moose.files b/Moose Mission Setup/Moose.files index 657ffe1bd..4d9f53b43 100644 --- a/Moose Mission Setup/Moose.files +++ b/Moose Mission Setup/Moose.files @@ -14,6 +14,7 @@ Core/Zone.lua Core/Database.lua Core/Set.lua Core/Point.lua +Core/Velocity.lua Core/Message.lua Core/Fsm.lua Core/Radio.lua diff --git a/Moose Mission Setup/Moose_.lua b/Moose Mission Setup/Moose_.lua index f76d65845..1cdef6beb 100644 --- a/Moose Mission Setup/Moose_.lua +++ b/Moose Mission Setup/Moose_.lua @@ -1,5 +1,5 @@ env.info('*** MOOSE DYNAMIC INCLUDE START *** ') -env.info('Moose Generation Timestamp: 20171021_1203') +env.info('Moose Generation Timestamp: 20171023_1007') local base=_G __Moose={} __Moose.Include=function(IncludeFile) @@ -31,6 +31,7 @@ __Moose.Include('Core/Zone.lua') __Moose.Include('Core/Database.lua') __Moose.Include('Core/Set.lua') __Moose.Include('Core/Point.lua') +__Moose.Include('Core/Velocity.lua') __Moose.Include('Core/Message.lua') __Moose.Include('Core/Fsm.lua') __Moose.Include('Core/Radio.lua') diff --git a/docs/Documentation/AI_A2A.html b/docs/Documentation/AI_A2A.html index 54b845efc..67ca9d37e 100644 --- a/docs/Documentation/AI_A2A.html +++ b/docs/Documentation/AI_A2A.html @@ -671,6 +671,7 @@
+ #number AI_A2A.IdleCount diff --git a/docs/Documentation/AirbasePolice.html b/docs/Documentation/AirbasePolice.html index 00e8852a2..7e4b6b2aa 100644 --- a/docs/Documentation/AirbasePolice.html +++ b/docs/Documentation/AirbasePolice.html @@ -153,6 +153,16 @@

Banner Image

The AIRBASEPOLICE_NEVADA class monitors the speed of the airplanes at the airbase during taxi.

+ + + + AIRBASEPOLICE_NORMANDY + +

AIRBASEPOLICE_NORMANDY, extends #AIRBASEPOLICE_BASE

+ +

Banner Image

+ +

The AIRBASEPOLICE_NORMANDY class monitors the speed of the airplanes at the airbase during taxi.

@@ -165,7 +175,31 @@

Type AIRBASEPOLICE_BASE

- + + + + + + + + + + + + + + + + + @@ -174,6 +208,18 @@ + + + + + + + + @@ -193,7 +239,7 @@

Type AIRBASEPOLICE_CAUCASUS

AIRBASEPOLICE_BASE:New(SetClient, Airbases, AirbaseList)AIRBASEPOLICE_BASE.AirbaseList + +
AIRBASEPOLICE_BASE.AirbaseMonitor + +
AIRBASEPOLICE_BASE.Airbases + +
AIRBASEPOLICE_BASE.KickSpeed + +
AIRBASEPOLICE_BASE:New(Airbases, AirbaseList)

Creates a new AIRBASEPOLICE_BASE object.

AIRBASEPOLICE_BASE.SetClient +
AIRBASEPOLICE_BASE:SetKickSpeedKmph(KickSpeed) +

Set the maximum speed in Kmph until the player gets kicked.

+
AIRBASEPOLICE_BASE:SetKickSpeedMiph(KickSpeedMiph) +

Set the maximum speed in Miph until the player gets kicked.

- + @@ -203,9 +249,19 @@

Type AIRBASEPOLICE_NEVADA

AIRBASEPOLICE_CAUCASUS:New(SetClient, AirbaseNames)AIRBASEPOLICE_CAUCASUS:New(AirbaseNames)

Creates a new AIRBASEPOLICE_CAUCASUS object.

- + + +
AIRBASEPOLICE_NEVADA:New(SetClient, AirbaseNames)AIRBASEPOLICE_NEVADA:New(AirbaseNames)

Creates a new AIRBASEPOLICE_NEVADA object.

+
+ +

Type AIRBASEPOLICE_NORMANDY

+ + + +
AIRBASEPOLICE_NORMANDY:New(AirbaseNames) +

Creates a new AIRBASEPOLICE_NORMANDY object.

@@ -306,11 +362,8 @@ AIRBASEPOLICE is communicating with this modified script to kick players!

-- This creates a new AIRBASEPOLICE_CAUCASUS object.
 
--- Create a set of all clients in the mission.
-AllClientsSet = SET_CLIENT:New():FilterStart()
-
 -- Monitor for these clients the airbases.
-AirbasePoliceCaucasus = AIRBASEPOLICE_CAUCASUS:New( AllClientsSet )
+AirbasePoliceCaucasus = AIRBASEPOLICE_CAUCASUS:New()
 
@@ -378,11 +431,77 @@ AIRBASEPOLICE is communicating with this modified script to kick players!

-- This creates a new AIRBASEPOLICE_NEVADA object.
 
--- Create a set of all clients in the mission.
-AllClientsSet = SET_CLIENT:New():FilterStart()
+-- Monitor for these clients the airbases.
+AirbasePoliceCaucasus = AIRBASEPOLICE_NEVADA:New()
+
+ + + +
+
+
+ + #AIRBASEPOLICE_NORMANDY + +AIRBASEPOLICE_NORMANDY + +
+
+ +

AIRBASEPOLICE_NORMANDY, extends #AIRBASEPOLICE_BASE

+ +

Banner Image

+ +

The AIRBASEPOLICE_NORMANDY class monitors the speed of the airplanes at the airbase during taxi.

+ + +

The pilots may not drive faster than the maximum speed for the airbase, or they will be despawned.

+ +

The pilot will receive 3 times a warning during speeding. After the 3rd warning, if the pilot is still driving +faster than the maximum allowed speed, the pilot will be kicked.

+ +

Different airbases have different maximum speeds, according safety regulations.

+ +

Airbases monitored

+ +

The following airbases are monitored at the Caucasus region:

+ + + + +

Installation

+ +

In Single Player Missions

+ +

AIRBASEPOLICE is fully functional in single player.

+ +

In Multi Player Missions

+ +

AIRBASEPOLICE is NOT functional in multi player, for client machines connecting to the server, running the mission. +Due to a bug in DCS since release 1.5, the despawning of clients are not anymore working in multi player. +To work around this problem, a much better solution has been made, using the slot blocker script designed +by Ciribob. With the help of Ciribob, this script has been extended to also kick client players while in flight. +AIRBASEPOLICE is communicating with this modified script to kick players!

+ +

Install the file SimpleSlotBlockGameGUI.lua on the server, following the installation instructions described by Ciribob.

+ +

Simple Slot Blocker from Ciribob & FlightControl

+ +

Script it!

+ +

1. AIRBASEPOLICE_NORMANDY Constructor

+ +

Creates a new AIRBASEPOLICE_NORMANDY object that will monitor pilots taxiing behaviour.

+ +
-- This creates a new AIRBASEPOLICE_NORMANDY object.
 
 -- Monitor for these clients the airbases.
-AirbasePoliceNevada = AIRBASEPOLICE_NEVADA:New( AllClientsSet )
+AirbasePoliceCaucasus = AIRBASEPOLICE_NORMANDY:New()
 
@@ -412,8 +531,64 @@ AirbasePoliceNevada = AIRBASEPOLICE_NEVADA:New( AllClientsSet )
+ + +AIRBASEPOLICE_BASE.AirbaseList + +
+
+ + + +
+
+
+
+ + + +AIRBASEPOLICE_BASE.AirbaseMonitor + +
+
+ + + +
+
+
+
+ + + +AIRBASEPOLICE_BASE.Airbases + +
+
+ + + +
+
+
+
+ + + +AIRBASEPOLICE_BASE.KickSpeed + +
+
+ + + +
+
+
+
+ -AIRBASEPOLICE_BASE:New(SetClient, Airbases, AirbaseList) +AIRBASEPOLICE_BASE:New(Airbases, AirbaseList)
@@ -424,12 +599,6 @@ AirbasePoliceNevada = AIRBASEPOLICE_NEVADA:New( AllClientsSet )
  • -

    SetClient : -A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase.

    - -
  • -
  • -

    Airbases : A table of Airbase Names.

    @@ -459,6 +628,60 @@ self

    +
+
+
+
+ + +AIRBASEPOLICE_BASE:SetKickSpeedKmph(KickSpeed) + +
+
+ +

Set the maximum speed in Kmph until the player gets kicked.

+ +

Parameter

+
    +
  • + +

    #number KickSpeed : +Set the maximum speed in Kmph until the player gets kicked.

    + +
  • +
+

Return value

+ +

#AIRBASEPOLICE_BASE: +self

+ +
+
+
+
+ + +AIRBASEPOLICE_BASE:SetKickSpeedMiph(KickSpeedMiph) + +
+
+ +

Set the maximum speed in Miph until the player gets kicked.

+ +

Parameter

+
    +
  • + +

    #number KickSpeedMiph : +Set the maximum speed in Mph until the player gets kicked.

    + +
  • +
+

Return value

+ +

#AIRBASEPOLICE_BASE: +self

+
@@ -510,23 +733,17 @@ self

-AIRBASEPOLICE_CAUCASUS:New(SetClient, AirbaseNames) +AIRBASEPOLICE_CAUCASUS:New(AirbaseNames)

Creates a new AIRBASEPOLICE_CAUCASUS object.

-

Parameters

+

Parameter

  • -

    SetClient : -A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase.

    - -
  • -
  • -

    AirbaseNames : A list {} of airbase names (Use AIRBASE.Caucasus enumerator).

    @@ -546,23 +763,17 @@ self

    -AIRBASEPOLICE_NEVADA:New(SetClient, AirbaseNames) +AIRBASEPOLICE_NEVADA:New(AirbaseNames)

    Creates a new AIRBASEPOLICE_NEVADA object.

    -

    Parameters

    +

    Parameter

    • -

      SetClient : -A SET_CLIENT object that will contain the CLIENT objects to be monitored if they follow the rules of the airbase.

      - -
    • -
    • -

      AirbaseNames : A list {} of airbase names (Use AIRBASE.Nevada enumerator).

      @@ -573,6 +784,36 @@ A list {} of airbase names (Use AIRBASE.Nevada enumerator).

      #AIRBASEPOLICE_NEVADA: self

      +
    +
+ +

Type AIRBASEPOLICE_NORMANDY

+

Field(s)

+
+
+ + +AIRBASEPOLICE_NORMANDY:New(AirbaseNames) + +
+
+ +

Creates a new AIRBASEPOLICE_NORMANDY object.

+ +

Parameter

+
    +
  • + +

    AirbaseNames : +A list {} of airbase names (Use AIRBASE.Normandy enumerator).

    + +
  • +
+

Return value

+ +

#AIRBASEPOLICE_NORMANDY: +self

+
diff --git a/docs/Documentation/Base.html b/docs/Documentation/Base.html index 2a96f397b..2d446b98b 100644 --- a/docs/Documentation/Base.html +++ b/docs/Documentation/Base.html @@ -115,12 +115,9 @@

Module Base

-

Core -- BASE forms the basis of the MOOSE framework.

+

Core -- VELOCITY models a speed, which can be expressed in various formats according the Settings.

-

Each class within the MOOSE framework derives from BASE.

- -

Banner Image


@@ -133,435 +130,126 @@

Global(s)

- + - +
BASEVELOCITY -

1) #BASE class

+

VELOCITY class, extends Base#BASE

-

All classes within the MOOSE framework are derived from the BASE class.

+

VELOCITY models a speed, which can be expressed in various formats according the Settings.

FORMATIONVELOCITY_POSITIONABLE +

VELOCITY_POSITIONABLE class, extends Base#BASE

+

VELOCITY_POSITIONABLE monitors the speed of an Positionable in the simulation, which can be expressed in various formats according the Settings.

-

Type BASE

+

Type VELOCITY

- + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
BASE.ClassIDVELOCITY:Get() -

The ID number of the class.

+

Get the velocity in Mps (meters per second).

BASE.ClassNameVELOCITY:GetKmph() -

The name of the class.

+

Get the velocity in Kmph (kilometers per hour).

BASE.ClassNameAndIDVELOCITY:GetMiph() -

The name of the class concatenated with the ID number of the class.

+

Get the velocity in Miph (miles per hour).

BASE:ClearState(Object, StateName)VELOCITY:GetText(Settings) - +

Get the velocity in text, according the player Settings.

BASE:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)VELOCITY:New(VelocityMps) -

Creation of a Birth Event.

+

VELOCITY Constructor.

BASE:CreateEventCrash(EventTime, Initiator)VELOCITY:Set(VelocityMps) -

Creation of a Crash Event.

+

Set the velocity in Mps (meters per second).

BASE:CreateEventTakeoff(EventTime, Initiator)VELOCITY:SetKmph(VelocityKmph) -

Creation of a Takeoff Event.

+

Set the velocity in Kmph (kilometers per hour).

BASE:E(Arguments)VELOCITY:SetMiph(VelocityMiph) -

Log an exception which will be traced always.

+

Set the velocity in Miph (miles per hour).

BASE:EventDispatcher()VELOCITY:ToString(Controllable, Settings, VelocityGroup) -

Returns the event dispatcher

+

Get the velocity in text, according the player or default Settings.

BASE:EventRemoveAll() -

Remove all subscribed events

-
BASE:F(Arguments) -

Trace a function call.

-
BASE:F2(Arguments) -

Trace a function call level 2.

-
BASE:F3(Arguments) -

Trace a function call level 3.

-
BASE:GetClassID() -

Get the ClassID of the class instance.

-
BASE:GetClassName() -

Get the ClassName of the class instance.

-
BASE:GetClassNameAndID() -

Get the ClassName + ClassID of the class instance.

-
BASE:GetEventPriority() -

Get the Class Event processing Priority.

-
BASE:GetParent(Child, FromClass) -

This is the worker method to retrieve the Parent class.

-
BASE:GetState(Object, Key) -

Get a Value given a Key from the Object.

-
BASE:HandleEvent(Event, EventFunction) -

Subscribe to a DCS Event.

-
BASE:Inherit(Child, Parent) -

This is the worker method to inherit from a parent class.

-
BASE:IsInstanceOf(ClassName) -

This is the worker method to check if an object is an (sub)instance of a class.

-
BASE:IsTrace() -

Enquires if tracing is on (for the class).

-
BASE:New() -

BASE constructor.

-
BASE:OnEvent(EventData) -

Occurs when an object is completely destroyed.

-
BASE:OnEventBaseCaptured(EventData) -

Occurs when a ground unit captures either an airbase or a farp.

-
BASE:OnEventBirth(EventData) -

Occurs when any object is spawned into the mission.

-
BASE:OnEventCrash(EventData) -

Occurs when any aircraft crashes into the ground and is completely destroyed.

-
BASE:OnEventDead(EventData) -

Occurs when an object is dead.

-
BASE:OnEventEjection(EventData) -

Occurs when a pilot ejects from an aircraft -initiator : The unit that has ejected

-
BASE:OnEventEngineShutdown(EventData) -

Occurs when any aircraft shuts down its engines.

-
BASE:OnEventEngineStartup(EventData) -

Occurs when any aircraft starts its engines.

-
BASE:OnEventHit(EventData) -

Occurs whenever an object is hit by a weapon.

-
BASE:OnEventHumanFailure(EventData) -

Occurs when any system fails on a human controlled aircraft.

-
BASE:OnEventLand(EventData) -

Occurs when an aircraft lands at an airbase, farp or ship -initiator : The unit that has landed -place: Object that the unit landed on.

-
BASE:OnEventMissionEnd(EventData) -

Occurs when a mission ends

-
BASE:OnEventMissionStart(EventData) -

Occurs when a mission starts

-
BASE:OnEventPilotDead(EventData) -

Occurs when the pilot of an aircraft is killed.

-
BASE:OnEventPlayerEnterUnit(EventData) -

Occurs when any player assumes direct control of a unit.

-
BASE:OnEventPlayerLeaveUnit(EventData) -

Occurs when any player relieves control of a unit to the AI.

-
BASE:OnEventRefueling(EventData) -

Occurs when an aircraft connects with a tanker and begins taking on fuel.

-
BASE:OnEventRefuelingStop(EventData) -

Occurs when an aircraft is finished taking fuel.

-
BASE:OnEventShootingEnd(EventData) -

Occurs when any unit stops firing its weapon.

-
BASE:OnEventShootingStart(EventData) -

Occurs when any unit begins firing a weapon that has a high rate of fire.

-
BASE:OnEventShot(EventData) -

Occurs whenever any unit in a mission fires a weapon.

-
BASE:OnEventTakeoff(EventData) -

Occurs when an aircraft takes off from an airbase, farp, or ship.

-
BASE:ScheduleOnce(Start, SchedulerFunction, ...) -

Schedule a new time event.

-
BASE:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...) -

Schedule a new time event.

-
BASE:ScheduleStop(SchedulerFunction) -

Stops the Schedule.

-
BASE.SchedulerObject - -
BASE:SetEventPriority(EventPriority) -

Set the Class Event processing Priority.

-
BASE:SetState(Object, Key, Value) -

Set a state or property of the Object given a Key and a Value.

-
BASE:T(Arguments) -

Trace a function logic level 1.

-
BASE:T2(Arguments) -

Trace a function logic level 2.

-
BASE:T3(Arguments) -

Trace a function logic level 3.

-
BASE:TraceAll(TraceAll) -

Trace all methods in MOOSE

-
BASE:TraceClass(Class) -

Set tracing for a class

-
BASE:TraceClassMethod(Class, Method) -

Set tracing for a specific method of class

-
BASE:TraceLevel(Level) -

Set trace level

-
BASE:TraceOnOff(TraceOnOff) -

Set trace on or off -Note that when trace is off, no debug statement is performed, increasing performance! -When Moose is loaded statically, (as one file), tracing is switched off by default.

-
BASE:UnHandleEvent(Event) -

UnSubscribe to a DCS event.

-
BASE._ - -
BASE:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) -

Trace a function call.

-
BASE:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) -

Trace a function logic.

-
BASE.__ - -
BASE:onEvent(event)VELOCITY.Velocity
-

Type FORMATION

+

Type VELOCITY_POSITIONABLE

- + - + + + + + + + + + + + + + + + + + + + + + @@ -572,1510 +260,287 @@ When Moose is loaded statically, (as one file), tracing is switched off by defau
- #BASE - -BASE + #VELOCITY + +VELOCITY
-

1) #BASE class

+

VELOCITY class, extends Base#BASE

-

All classes within the MOOSE framework are derived from the BASE class.

+

VELOCITY models a speed, which can be expressed in various formats according the Settings.

-

-BASE provides facilities for :

+ +

1. VELOCITY constructor

    -
  • The construction and inheritance of MOOSE classes.
  • -
  • The class naming and numbering system.
  • -
  • The class hierarchy search system.
  • -
  • The tracing of information or objects during mission execution for debuggin purposes.
  • -
  • The subscription to DCS events for event handling in MOOSE objects.
  • +
  • VELOCITY.New(): Creates a new VELOCITY object.
-

Note: The BASE class is an abstract class and is not meant to be used directly.

- -

1.1) BASE constructor

- -

Any class derived from BASE, will use the Base#BASE.New constructor embedded in the Base#BASE.Inherit method. -See an example at the Base#BASE.New method how this is done.

- -

1.2) Trace information for debugging

- -

The BASE class contains trace methods to trace progress within a mission execution of a certain object. -These trace methods are inherited by each MOOSE class interiting BASE, soeach object created from derived class from BASE can use the tracing methods to trace its execution.

- -

Any type of information can be passed to these tracing methods. See the following examples:

- -
self:E( "Hello" )
-
- -

Result in the word "Hello" in the dcs.log.

- -
local Array = { 1, nil, "h", { "a","b" }, "x" }
-self:E( Array )
-
- -

Results with the text [1]=1,[3]="h",[4]={[1]="a",[2]="b"},[5]="x"} in the dcs.log.

- -
local Object1 = "Object1"
-local Object2 = 3
-local Object3 = { Object 1, Object 2 }
-self:E( { Object1, Object2, Object3 } )
-
- -

Results with the text [1]={[1]="Object",[2]=3,[3]={[1]="Object",[2]=3}} in the dcs.log.

- -
local SpawnObject = SPAWN:New( "Plane" )
-local GroupObject = GROUP:FindByName( "Group" )
-self:E( { Spawn = SpawnObject, Group = GroupObject } )
-
- -

Results with the text [1]={Spawn={....),Group={...}} in the dcs.log.

- -

Below a more detailed explanation of the different method types for tracing.

- -

1.2.1) Tracing methods categories

- -

There are basically 3 types of tracing methods available:

- -
    -
  • BASE.F: Used to trace the entrance of a function and its given parameters. An F is indicated at column 44 in the DCS.log file.
  • -
  • BASE.T: Used to trace further logic within a function giving optional variables or parameters. A T is indicated at column 44 in the DCS.log file.
  • -
  • BASE.E: Used to always trace information giving optional variables or parameters. An E is indicated at column 44 in the DCS.log file.
  • -
- -

1.2.2) Tracing levels

- -

There are 3 tracing levels within MOOSE.
-These tracing levels were defined to avoid bulks of tracing to be generated by lots of objects.

- -

As such, the F and T methods have additional variants to trace level 2 and 3 respectively:

- -
    -
  • BASE.F2: Trace the beginning of a function and its given parameters with tracing level 2.
  • -
  • BASE.F3: Trace the beginning of a function and its given parameters with tracing level 3.
  • -
  • BASE.T2: Trace further logic within a function giving optional variables or parameters with tracing level 2.
  • -
  • BASE.T3: Trace further logic within a function giving optional variables or parameters with tracing level 3.
  • -
- -

1.2.3) Trace activation.

- -

Tracing can be activated in several ways:

- -
    -
  • Switch tracing on or off through the BASE.TraceOnOff() method.
  • -
  • Activate all tracing through the BASE.TraceAll() method.
  • -
  • Activate only the tracing of a certain class (name) through the BASE.TraceClass() method.
  • -
  • Activate only the tracing of a certain method of a certain class through the BASE.TraceClassMethod() method.
  • -
  • Activate only the tracing of a certain level through the BASE.TraceLevel() method.
  • -
- -

1.2.4) Check if tracing is on.

- -

The method BASE.IsTrace() will validate if tracing is activated or not.

- -

1.3 DCS simulator Event Handling

- -

The BASE class provides methods to catch DCS Events. These are events that are triggered from within the DCS simulator, -and handled through lua scripting. MOOSE provides an encapsulation to handle these events more efficiently.

- -

1.3.1 Subscribe / Unsubscribe to DCS Events

- -

At first, the mission designer will need to Subscribe to a specific DCS event for the class. -So, when the DCS event occurs, the class will be notified of that event. -There are two methods which you use to subscribe to or unsubscribe from an event.

- - - -

1.3.2 Event Handling of DCS Events

- -

Once the class is subscribed to the event, an Event Handling method on the object or class needs to be written that will be called -when the DCS event occurs. The Event Handling method receives an Event#EVENTDATA structure, which contains a lot of information -about the event that occurred.

- -

Find below an example of the prototype how to write an event handling function for two units:

- -
 local Tank1 = UNIT:FindByName( "Tank A" )
- local Tank2 = UNIT:FindByName( "Tank B" )
-
- -- Here we subscribe to the Dead events. So, if one of these tanks dies, the Tank1 or Tank2 objects will be notified.
- Tank1:HandleEvent( EVENTS.Dead )
- Tank2:HandleEvent( EVENTS.Dead )
-
- --- This function is an Event Handling function that will be called when Tank1 is Dead.
- -- @param Wrapper.Unit#UNIT self 
- -- @param Core.Event#EVENTDATA EventData
- function Tank1:OnEventDead( EventData )
-
-   self:SmokeGreen()
- end
-
- --- This function is an Event Handling function that will be called when Tank2 is Dead.
- -- @param Wrapper.Unit#UNIT self 
- -- @param Core.Event#EVENTDATA EventData
- function Tank2:OnEventDead( EventData )
-
-   self:SmokeBlue()
- end
-
- - - -

See the Event module for more information about event handling.

- -

1.4) Class identification methods

- -

BASE provides methods to get more information of each object:

- -
    -
  • BASE.GetClassID(): Gets the ID (number) of the object. Each object created is assigned a number, that is incremented by one.
  • -
  • BASE.GetClassName(): Gets the name of the object, which is the name of the class the object was instantiated from.
  • -
  • BASE.GetClassNameAndID(): Gets the name and ID of the object.
  • -
- -

1.5) All objects derived from BASE can have "States"

- -

A mechanism is in place in MOOSE, that allows to let the objects administer states.
-States are essentially properties of objects, which are identified by a Key and a Value.

- -

The method BASE.SetState() can be used to set a Value with a reference Key to the object.
-To read or retrieve a state Value based on a Key, use the BASE.GetState method.

- -

These two methods provide a very handy way to keep state at long lasting processes. -Values can be stored within the objects, and later retrieved or changed when needed. -There is one other important thing to note, the BASE.SetState() and BASE.GetState methods -receive as the first parameter the object for which the state needs to be set. -Thus, if the state is to be set for the same object as the object for which the method is used, then provide the same -object name to the method.

- -

1.10) Inheritance

- -

The following methods are available to implement inheritance

- -
    -
  • BASE.Inherit: Inherits from a class.
  • -
  • BASE.GetParent: Returns the parent object from the object it is handling, or nil if there is no parent object.
  • -
- -
-
- #FORMATION - -FORMATION + #VELOCITY_POSITIONABLE + +VELOCITY_POSITIONABLE
+

VELOCITY_POSITIONABLE class, extends Base#BASE

+ +

VELOCITY_POSITIONABLE monitors the speed of an Positionable in the simulation, which can be expressed in various formats according the Settings.

+ + + +

1. VELOCITY_POSITIONABLE constructor

+ +

Type Base

-

Type BASE

+

Type VELOCITY

Field(s)

- -BASE.ClassID + +VELOCITY:Get()
-

The ID number of the class.

- -
-
-
-
- - -BASE.ClassName - -
-
- -

The name of the class.

- -
-
-
-
- - -BASE.ClassNameAndID - -
-
- -

The name of the class concatenated with the ID number of the class.

- -
-
-
-
- - -BASE:ClearState(Object, StateName) - -
-
- - - -

Parameters

-
    -
  • - -

    Object :

    - -
  • -
  • - -

    StateName :

    - -
  • -
-
-
-
-
- - -BASE:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace) - -
-
- -

Creation of a Birth Event.

- -

Parameters

-
    -
  • - -

    Dcs.DCSTypes#Time EventTime : -The time stamp of the event.

    - -
  • -
  • - -

    Dcs.DCSWrapper.Object#Object Initiator : -The initiating object of the event.

    - -
  • -
  • - -

    #string IniUnitName : -The initiating unit name.

    - -
  • -
  • - -

    place :

    - -
  • -
  • - -

    subplace :

    - -
  • -
-
-
-
-
- - -BASE:CreateEventCrash(EventTime, Initiator) - -
-
- -

Creation of a Crash Event.

- -

Parameters

- -
-
-
-
- - -BASE:CreateEventTakeoff(EventTime, Initiator) - -
-
- -

Creation of a Takeoff Event.

- -

Parameters

- -
-
-
-
- - -BASE:E(Arguments) - -
-
- -

Log an exception which will be traced always.

- - -

Can be anywhere within the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:EventDispatcher() - -
-
- -

Returns the event dispatcher

- -

Return value

- -

Core.Event#EVENT:

- - -
-
-
-
- - -BASE:EventRemoveAll() - -
-
- -

Remove all subscribed events

- -

Return value

- -

#BASE:

- - -
-
-
-
- - -BASE:F(Arguments) - -
-
- -

Trace a function call.

- - -

Must be at the beginning of the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:F2(Arguments) - -
-
- -

Trace a function call level 2.

- - -

Must be at the beginning of the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:F3(Arguments) - -
-
- -

Trace a function call level 3.

- - -

Must be at the beginning of the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:GetClassID() - -
-
- -

Get the ClassID of the class instance.

- -

Return value

- -

#string: -The ClassID of the class instance.

- -
-
-
-
- - -BASE:GetClassName() - -
-
- -

Get the ClassName of the class instance.

- -

Return value

- -

#string: -The ClassName of the class instance.

- -
-
-
-
- - -BASE:GetClassNameAndID() - -
-
- -

Get the ClassName + ClassID of the class instance.

- - -

The ClassName + ClassID is formatted as '%s#%09d'.

- -

Return value

- -

#string: -The ClassName + ClassID of the class instance.

- -
-
-
-
- - -BASE:GetEventPriority() - -
-
- -

Get the Class Event processing Priority.

- - -

The Event processing Priority is a number from 1 to 10, -reflecting the order of the classes subscribed to the Event to be processed.

+

Get the velocity in Mps (meters per second).

Return value

#number: -The Event processing Priority.

+The velocity in meters per second.

- -BASE:GetParent(Child, FromClass) + +VELOCITY:GetKmph()
-

This is the worker method to retrieve the Parent class.

+

Get the velocity in Kmph (kilometers per hour).

- -

Note that the Parent class must be passed to call the parent class method.

- -
self:GetParent(self):ParentMethod()
-
-
-
- -

Parameters

-
    -
  • - -

    #BASE Child : -is the Child class from which the Parent class needs to be retrieved.

    - -
  • -
  • - -

    FromClass :

    - -
  • -
-

Return value

- -

#BASE:

- - -
-
-
-
- - -BASE:GetState(Object, Key) - -
-
- -

Get a Value given a Key from the Object.

- - -

Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.

- -

Parameters

-
    -
  • - -

    Object : -The object that holds the Value set by the Key.

    - -
  • -
  • - -

    Key : -The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!

    - -
  • -
-

Return value

- - -

The Value retrieved.

- -
-
-
-
- - -BASE:HandleEvent(Event, EventFunction) - -
-
- -

Subscribe to a DCS Event.

- -

Parameters

-
    -
  • - -

    Core.Event#EVENTS Event :

    - -
  • -
  • - -

    #function EventFunction : -(optional) The function to be called when the event occurs for the unit.

    - -
  • -
-

Return value

- -

#BASE:

- - -
-
-
-
- - -BASE:Inherit(Child, Parent) - -
-
- -

This is the worker method to inherit from a parent class.

- -

Parameters

-
    -
  • - -

    Child : -is the Child class that inherits.

    - -
  • -
  • - -

    #BASE Parent : -is the Parent class that the Child inherits from.

    - -
  • -
-

Return value

- -

#BASE: -Child

- -
-
-
-
- - -BASE:IsInstanceOf(ClassName) - -
-
- -

This is the worker method to check if an object is an (sub)instance of a class.

- - - -

Examples:

- -
    -
  • ZONE:New( 'some zone' ):IsInstanceOf( ZONE ) will return true

  • -
  • ZONE:New( 'some zone' ):IsInstanceOf( 'ZONE' ) will return true

  • -
  • ZONE:New( 'some zone' ):IsInstanceOf( 'zone' ) will return true

  • -
  • ZONE:New( 'some zone' ):IsInstanceOf( 'BASE' ) will return true

  • -
  • ZONE:New( 'some zone' ):IsInstanceOf( 'GROUP' ) will return false

  • -
- - -

Parameter

-
    -
  • - -

    ClassName : -is the name of the class or the class itself to run the check against

    - -
  • -
-

Return value

- -

#boolean:

- - -
-
-
-
- - -BASE:IsTrace() - -
-
- -

Enquires if tracing is on (for the class).

- -

Return value

- -

#boolean:

- - -
-
-
-
- - -BASE:New() - -
-
- -

BASE constructor.

- - - -

This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE.

- -
function EVENT:New()
-  local self = BASE:Inherit( self, BASE:New() ) -- #EVENT
-  return self
-end
-  
-
- -

Return value

- -

#BASE:

- - -
-
-
-
- - -BASE:OnEvent(EventData) - -
-
- -

Occurs when an object is completely destroyed.

- - -

initiator : The unit that is was destroyed.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventBaseCaptured(EventData) - -
-
- -

Occurs when a ground unit captures either an airbase or a farp.

- - -

initiator : The unit that captured the base -place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventBirth(EventData) - -
-
- -

Occurs when any object is spawned into the mission.

- - -

initiator : The unit that was spawned

- -

Parameter

- -
-
-
-
- - -BASE:OnEventCrash(EventData) - -
-
- -

Occurs when any aircraft crashes into the ground and is completely destroyed.

- - -

initiator : The unit that has crashed

- -

Parameter

- -
-
-
-
- - -BASE:OnEventDead(EventData) - -
-
- -

Occurs when an object is dead.

- - -

initiator : The unit that is dead.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventEjection(EventData) - -
-
- -

Occurs when a pilot ejects from an aircraft -initiator : The unit that has ejected

- -

Parameter

- -
-
-
-
- - -BASE:OnEventEngineShutdown(EventData) - -
-
- -

Occurs when any aircraft shuts down its engines.

- - -

initiator : The unit that is stopping its engines.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventEngineStartup(EventData) - -
-
- -

Occurs when any aircraft starts its engines.

- - -

initiator : The unit that is starting its engines.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventHit(EventData) - -
-
- -

Occurs whenever an object is hit by a weapon.

- - -

initiator : The unit object the fired the weapon -weapon: Weapon object that hit the target -target: The Object that was hit.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventHumanFailure(EventData) - -
-
- -

Occurs when any system fails on a human controlled aircraft.

- - -

initiator : The unit that had the failure

- -

Parameter

- -
-
-
-
- - -BASE:OnEventLand(EventData) - -
-
- -

Occurs when an aircraft lands at an airbase, farp or ship -initiator : The unit that has landed -place: Object that the unit landed on.

- - -

Can be an Airbase Object, FARP, or Ships

- -

Parameter

- -
-
-
-
- - -BASE:OnEventMissionEnd(EventData) - -
-
- -

Occurs when a mission ends

- -

Parameter

- -
-
-
-
- - -BASE:OnEventMissionStart(EventData) - -
-
- -

Occurs when a mission starts

- -

Parameter

- -
-
-
-
- - -BASE:OnEventPilotDead(EventData) - -
-
- -

Occurs when the pilot of an aircraft is killed.

- - -

Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane. -initiator : The unit that the pilot has died in.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventPlayerEnterUnit(EventData) - -
-
- -

Occurs when any player assumes direct control of a unit.

- - -

initiator : The unit that is being taken control of.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventPlayerLeaveUnit(EventData) - -
-
- -

Occurs when any player relieves control of a unit to the AI.

- - -

initiator : The unit that the player left.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventRefueling(EventData) - -
-
- -

Occurs when an aircraft connects with a tanker and begins taking on fuel.

- - -

initiator : The unit that is receiving fuel.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventRefuelingStop(EventData) - -
-
- -

Occurs when an aircraft is finished taking fuel.

- - -

initiator : The unit that was receiving fuel.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventShootingEnd(EventData) - -
-
- -

Occurs when any unit stops firing its weapon.

- - -

Event will always correspond with a shooting start event. -initiator : The unit that was doing the shooing.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventShootingStart(EventData) - -
-
- -

Occurs when any unit begins firing a weapon that has a high rate of fire.

- - -

Most common with aircraft cannons (GAU-8), autocannons, and machine guns. -initiator : The unit that is doing the shooing. -target: The unit that is being targeted.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventShot(EventData) - -
-
- -

Occurs whenever any unit in a mission fires a weapon.

- - -

But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.

- -

Parameter

- -
-
-
-
- - -BASE:OnEventTakeoff(EventData) - -
-
- -

Occurs when an aircraft takes off from an airbase, farp, or ship.

- - -

initiator : The unit that tookoff -place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships

- -

Parameter

- -
-
-
-
- - -BASE:ScheduleOnce(Start, SchedulerFunction, ...) - -
-
- -

Schedule a new time event.

- - -

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

- -

Parameters

-
    -
  • - -

    #number Start : -Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

    - -
  • -
  • - -

    #function SchedulerFunction : -The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

    - -
  • -
  • - -

    #table ... : -Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

    - -
  • -

Return value

#number: -The ScheduleID of the planned schedule.

+The velocity in kilometers per hour.

- -BASE:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...) + +VELOCITY:GetMiph()
-

Schedule a new time event.

+

Get the velocity in Miph (miles per hour).

- -

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

- -

Parameters

-
    -
  • - -

    #number Start : -Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

    - -
  • -
  • - -

    #number Repeat : -Specifies the interval in seconds when the scheduler will call the event function.

    - -
  • -
  • - -

    #number RandomizeFactor : -Specifies a randomization factor between 0 and 1 to randomize the Repeat.

    - -
  • -
  • - -

    #number Stop : -Specifies the amount of seconds when the scheduler will be stopped.

    - -
  • -
  • - -

    #function SchedulerFunction : -The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

    - -
  • -
  • - -

    #table ... : -Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

    - -
  • -

Return value

#number: -The ScheduleID of the planned schedule.

+The velocity in miles per hour.

- -BASE:ScheduleStop(SchedulerFunction) + +VELOCITY:GetText(Settings)
-

Stops the Schedule.

+

Get the velocity in text, according the player Settings.

Parameter

  • -

    #function SchedulerFunction : -The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

    +

    Core.Settings#SETTINGS Settings :

+

Return value

+ +

#string: +The velocity in text.

+ +
+
+
+
+ + +VELOCITY:New(VelocityMps) + +
+
+ +

VELOCITY Constructor.

+ +

Parameter

+
    +
  • + +

    #number VelocityMps : +The velocity in meters per second.

    + +
  • +
+

Return value

+ +

#VELOCITY:

+ + +
+
+
+
+ + +VELOCITY:Set(VelocityMps) + +
+
+ +

Set the velocity in Mps (meters per second).

+ +

Parameter

+
    +
  • + +

    #number VelocityMps : +The velocity in meters per second.

    + +
  • +
+

Return value

+ +

#VELOCITY:

+ + +
+
+
+
+ + +VELOCITY:SetKmph(VelocityKmph) + +
+
+ +

Set the velocity in Kmph (kilometers per hour).

+ +

Parameter

+
    +
  • + +

    #number VelocityKmph : +The velocity in kilometers per hour.

    + +
  • +
+

Return value

+ +

#VELOCITY:

+ + +
+
+
+
+ + +VELOCITY:SetMiph(VelocityMiph) + +
+
+ +

Set the velocity in Miph (miles per hour).

+ +

Parameter

+
    +
  • + +

    #number VelocityMiph : +The velocity in miles per hour.

    + +
  • +
+

Return value

+ +

#VELOCITY:

+ + +
+
+
+
+ + +VELOCITY:ToString(Controllable, Settings, VelocityGroup) + +
+
+ +

Get the velocity in text, according the player or default Settings.

+ +

Parameters

+ +

Return value

+ +

#string: +The velocity in text according the player or default Settings

+
- -BASE.SchedulerObject + +VELOCITY.Velocity
@@ -2084,466 +549,128 @@ The event function to be called when a timer event occurs. The event function ne
+ +

Type VELOCITY_POSITIONABLE

+

Field(s)

- -BASE:SetEventPriority(EventPriority) + +VELOCITY_POSITIONABLE:Get()
-

Set the Class Event processing Priority.

+

Get the velocity in Mps (meters per second).

+

Return value

+ +

#number: +The velocity in meters per second.

+ +
+
+
+
+ + +VELOCITY_POSITIONABLE:GetKmph() + +
+
-

The Event processing Priority is a number from 1 to 10, -reflecting the order of the classes subscribed to the Event to be processed.

+

Get the velocity in Kmph (kilometers per hour).

+ +

Return value

+ +

#number: +The velocity in kilometers per hour.

+ +
+
+
+
+ + +VELOCITY_POSITIONABLE:GetMiph() + +
+
+ +

Get the velocity in Miph (miles per hour).

+ +

Return value

+ +

#number: +The velocity in miles per hour.

+ +
+
+
+
+ + +VELOCITY_POSITIONABLE:New(Positionable) + +
+
+ +

VELOCITY_POSITIONABLE Constructor.

Parameter

Return value

+

#VELOCITY_POSITIONABLE:

-

self

- -BASE:SetState(Object, Key, Value) + + +VELOCITY_POSITIONABLE.Positionable
-

Set a state or property of the Object given a Key and a Value.

- -

Note that if the Object is destroyed, nillified or garbage collected, then the Values and Keys will also be gone.

- -

Parameters

-
    -
  • - -

    Object : -The object that will hold the Value set by the Key.

    - -
  • -
  • - -

    Key : -The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!

    - -
  • -
  • - -

    Value : -The value to is stored in the object.

    - -
  • -
-

Return values

-
    -
  1. - - -

    The Value set.

    - -
  2. -
  3. - -

    #nil: -The Key was not found and thus the Value could not be retrieved.

    - -
  4. -
-
-
-
-
- - -BASE:T(Arguments) - -
-
- -

Trace a function logic level 1.

- - -

Can be anywhere within the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:T2(Arguments) - -
-
- -

Trace a function logic level 2.

- - -

Can be anywhere within the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:T3(Arguments) - -
-
- -

Trace a function logic level 3.

- - -

Can be anywhere within the function logic.

- -

Parameter

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
-
-
-
-
- - -BASE:TraceAll(TraceAll) - -
-
- -

Trace all methods in MOOSE

- -

Parameter

-
    -
  • - -

    #boolean TraceAll : -true = trace all methods in MOOSE.

    - -
  • -
-
-
-
-
- - -BASE:TraceClass(Class) - -
-
- -

Set tracing for a class

- -

Parameter

-
    -
  • - -

    #string Class :

    - -
  • -
-
-
-
-
- - -BASE:TraceClassMethod(Class, Method) - -
-
- -

Set tracing for a specific method of class

- -

Parameters

-
    -
  • - -

    #string Class :

    - -
  • -
  • - -

    #string Method :

    - -
  • -
-
-
-
-
- - -BASE:TraceLevel(Level) - -
-
- -

Set trace level

- -

Parameter

-
    -
  • - -

    #number Level :

    - -
  • -
-
-
-
-
- - -BASE:TraceOnOff(TraceOnOff) - -
-
- -

Set trace on or off -Note that when trace is off, no debug statement is performed, increasing performance! -When Moose is loaded statically, (as one file), tracing is switched off by default.

- - -

So tracing must be switched on manually in your mission if you are using Moose statically. -When moose is loading dynamically (for moose class development), tracing is switched on by default.

- -

Parameter

-
    -
  • - -

    #boolean TraceOnOff : -Switch the tracing on or off.

    - -
  • -
-

Usage:

-
-- Switch the tracing On
-BASE:TraceOnOff( true )
-
--- Switch the tracing Off
-BASE:TraceOnOff( false )
- -BASE:UnHandleEvent(Event) + +VELOCITY_POSITIONABLE:ToString()
-

UnSubscribe to a DCS event.

+

Get the velocity in text, according the player or default Settings.

-

Parameter

-

Return value

-

#BASE:

- +

#string: +The velocity in text according the player or default Settings

- #BASE._ - -BASE._ - -
-
- - - -
-
-
-
- - -BASE:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) - -
-
- -

Trace a function call.

- - -

This function is private.

- -

Parameters

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
  • - -

    DebugInfoCurrentParam :

    - -
  • -
  • - -

    DebugInfoFromParam :

    - -
  • -
-
-
-
-
- - -BASE:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam) - -
-
- -

Trace a function logic.

- -

Parameters

-
    -
  • - -

    Arguments : -A #table or any field.

    - -
  • -
  • - -

    DebugInfoCurrentParam :

    - -
  • -
  • - -

    DebugInfoFromParam :

    - -
  • -
-
-
-
-
- - #BASE.__ - -BASE.__ - -
-
- - - -
-
-
-
- - -BASE:onEvent(event) - -
-
- - - - -

TODO: Complete Dcs.DCSTypes#Event structure.
-- The main event handling function... This function captures all events generated for the class. - @param #BASE self - @param Dcs.DCSTypes#Event event

- -

Parameter

-
    -
  • - -

    event :

    - -
  • -
-
-
- -

Type BASE._

- -

Type BASE.__

- -

Type FORMATION

- -

The Formation Class

- -

Field(s)

-
-
- - -FORMATION.Cone - -
-
- -

A cone formation.

- -
-
-
-
- - #string - -FORMATION.Vee + + +VELOCITY_POSITIONABLE.Velocity
diff --git a/docs/Documentation/Cargo.html b/docs/Documentation/Cargo.html index b91b11290..ea6e33cb9 100644 --- a/docs/Documentation/Cargo.html +++ b/docs/Documentation/Cargo.html @@ -2269,7 +2269,6 @@ The amount of seconds to delay the action.

- CARGO_CRATE.CargoCarrier @@ -3698,7 +3697,6 @@ The range till cargo will board.

- CARGO_UNIT.CargoCarrier @@ -3806,6 +3804,7 @@ The range till cargo will board.

+ #number CARGO_UNIT.RunCount diff --git a/docs/Documentation/Database.html b/docs/Documentation/Database.html index 4629160d2..1e572dfd0 100644 --- a/docs/Documentation/Database.html +++ b/docs/Documentation/Database.html @@ -121,7 +121,19 @@
-

1) #DATABASE class, extends Base#BASE

+

Author: Sven Van de Velde (FlightControl)

+

Contributions:

+ +
+ + +

Global(s)

+
FORMATION.ConeVELOCITY_POSITIONABLE:Get() -

A cone formation.

+

Get the velocity in Mps (meters per second).

FORMATION.VeeVELOCITY_POSITIONABLE:GetKmph() +

Get the velocity in Kmph (kilometers per hour).

+
VELOCITY_POSITIONABLE:GetMiph() +

Get the velocity in Miph (miles per hour).

+
VELOCITY_POSITIONABLE:New(Positionable) +

VELOCITY_POSITIONABLE Constructor.

+
VELOCITY_POSITIONABLE.Positionable + +
VELOCITY_POSITIONABLE:ToString() +

Get the velocity in text, according the player or default Settings.

+
VELOCITY_POSITIONABLE.Velocity
+ + + + + + +
DATABASE +

DATABASE class, extends Base#BASE

+

Mission designers can use the DATABASE class to refer to:

    @@ -136,38 +148,6 @@

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.

- -

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:

- - - -
- - -

Author: Sven Van de Velde (FlightControl)

-

Contributions:

- -
- -

Global(s)

- - - - @@ -180,12 +160,6 @@ The following iterator methods are currently available within the DATABASE:

Type DATABASE

DATABASE -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -393,12 +331,6 @@ The following iterator methods are currently available within the DATABASE:

- - - - @@ -465,18 +397,6 @@ The following iterator methods are currently available within the DATABASE:

- - - - - - - - @@ -501,36 +421,6 @@ The following iterator methods are currently available within the DATABASE:

- - - - - - - - - - - - - - - - - - - - @@ -549,36 +439,18 @@ The following iterator methods are currently available within the DATABASE:

- - - - - - - - - - - - @@ -618,7 +490,7 @@ The following iterator methods are currently available within the DATABASE:

- + @@ -666,6 +538,27 @@ The following iterator methods are currently available within the DATABASE:

+

DATABASE class, extends Base#BASE

+ +

Mission designers can use the DATABASE class to refer to:

+ +
    +
  • STATICS
  • +
  • UNITS
  • +
  • GROUPS
  • +
  • CLIENTS
  • +
  • AIRBASES
  • +
  • PLAYERSJOINED
  • +
  • PLAYERS
  • +
  • CARGOS
  • +
+ +

On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.

+ + + +

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.

@@ -687,24 +580,7 @@ The following iterator methods are currently available within the DATABASE:

Type Database

Type DATABASE

- -

DATABASE class

- -

Field(s)

-
-
- - - -DATABASE.AIRBASES - -
-
- - - -
-
+

Field(s)

@@ -904,90 +780,6 @@ The name of the airbase

- -
-
-
- - - -DATABASE.CARGOS - -
-
- - - -
-
-
-
- - - -DATABASE.CLIENTS - -
-
- - - -
-
-
-
- - - -DATABASE.COUNTRY_ID - -
-
- - - -
-
-
-
- - - -DATABASE.COUNTRY_NAME - -
-
- - - -
-
-
-
- - #string - -DATABASE.ClassName - -
-
- - - -
-
-
-
- - - -DATABASE.DESTROYS - -
-
- - -
@@ -1584,20 +1376,6 @@ The function that will be called for each object in the database. The function n

#DATABASE: self

- -
-
-
- - - -DATABASE.GROUPS - -
-
- - -
@@ -1834,34 +1612,6 @@ self

- -
-
-
- - - -DATABASE.HITS - -
-
- - - -
-
-
-
- - - -DATABASE.NavPoints - -
-
- - -
@@ -1940,76 +1690,6 @@ DBObject = DATABASE:New() - -
-
-
- - - -DATABASE.PLAYERS - -
-
- - - -
-
-
-
- - - -DATABASE.PLAYERSETTINGS - -
-
- - - -
-
-
-
- - - -DATABASE.PLAYERSJOINED - -
-
- - - -
-
-
-
- - - -DATABASE.PLAYERUNITS - -
-
- - - -
-
-
-
- - - -DATABASE.STATICS - -
-
- - -
@@ -2098,20 +1778,6 @@ This method is used by the SPAWN class.

#DATABASE: self

- -
-
-
- - - -DATABASE.Templates - -
-
- - -
@@ -2126,20 +1792,6 @@ self

- -
-
-
- - - -DATABASE.UNITS_Index - -
-
- - -
@@ -2154,20 +1806,6 @@ self

- -
-
-
- - - -DATABASE.ZONENAMES - -
-
- - -
@@ -2289,7 +1927,7 @@ self

-DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionID, CategoryID, CountryID) +DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName)
@@ -2305,17 +1943,25 @@ self

  • -

    CoalitionID :

    +

    Dcs.DCScoalition#coalition.side CoalitionSide : +The coalition.side of the object.

  • -

    CategoryID :

    +

    Dcs.DCSObject#Object.Category CategoryID : +The Object.category of the object.

  • -

    CountryID :

    +

    Dcs.DCScountry#country.id CountryID : +the country.id of the object

    + +
  • +
  • + +

    GroupName :

  • diff --git a/docs/Documentation/Designate.html b/docs/Documentation/Designate.html index 8292e8e22..548df5b75 100644 --- a/docs/Documentation/Designate.html +++ b/docs/Documentation/Designate.html @@ -1106,7 +1106,7 @@ function below will use the range 1-7 just in case

    - + #number DESIGNATE.LaseDuration diff --git a/docs/Documentation/Group.html b/docs/Documentation/Group.html index 412fd6b3f..f3e51bd5e 100644 --- a/docs/Documentation/Group.html +++ b/docs/Documentation/Group.html @@ -460,6 +460,12 @@
    + + + + @@ -471,7 +477,7 @@ @@ -1801,6 +1807,55 @@ true if DCS Group contains Ships.

    + +GROUP:NewTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID) + +
    +
    + +

    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.

    + +

    Parameters

    + +

    Return value

    + +

    #GROUP: +self

    + +
    +
    +
    +
    + GROUP:OnReSpawn(ReSpawnFunction) @@ -1828,14 +1883,14 @@ true if DCS Group contains Ships.

    -

    Create a new GROUP from a DCSGroup

    +

    Create a new GROUP from an existing Group in the Mission.

    Parameter

    diff --git a/docs/Documentation/Point.html b/docs/Documentation/Point.html index 47cdcecd6..fbdfecd9e 100644 --- a/docs/Documentation/Point.html +++ b/docs/Documentation/Point.html @@ -3495,6 +3495,7 @@ The y coordinate.

    + POINT_VEC2.z diff --git a/docs/Documentation/Positionable.html b/docs/Documentation/Positionable.html index 3d38d59aa..b0a3587af 100644 --- a/docs/Documentation/Positionable.html +++ b/docs/Documentation/Positionable.html @@ -314,7 +314,7 @@
    @@ -327,6 +327,12 @@ + + + + @@ -1208,14 +1214,14 @@ The POSITIONABLE is not existing or alive.

    -

    Returns the POSITIONABLE velocity vector.

    +

    Returns the a Velocity object from the positionable.

    Return values

    1. -

      Dcs.DCSTypes#Vec3: -The velocity vector

      +

      Core.Velocity#VELOCITY: +Velocity The Velocity object.

    2. @@ -1266,6 +1272,34 @@ The velocity in meters per second.

      + +POSITIONABLE:GetVelocityVec3() + +
      +
      + +

      Returns the POSITIONABLE velocity Vec3 vector.

      + +

      Return values

      +
        +
      1. + +

        Dcs.DCSTypes#Vec3: +The velocity Vec3 vector

        + +
      2. +
      3. + +

        #nil: +The POSITIONABLE is not existing or alive.

        + +
      4. +
      +
      +
      +
      +
      + POSITIONABLE:HasCargo(Cargo) diff --git a/docs/Documentation/Set.html b/docs/Documentation/Set.html index e7f92fb7a..0b8836cf1 100644 --- a/docs/Documentation/Set.html +++ b/docs/Documentation/Set.html @@ -236,6 +236,22 @@
    3. Countries
    4. Starting with certain prefix strings.
    5. + +
    + + + @@ -951,6 +967,106 @@ mission designer to add a dedicated method

    + +
    DATABASE.AIRBASES - -
    DATABASE:AccountDestroys(Event)

    Account the destroys.

    @@ -237,42 +211,6 @@ The following iterator methods are currently available within the DATABASE:

    DATABASE:AddUnit(DCSUnitName)

    Adds a Unit based on the Unit Name in the DATABASE.

    -
    DATABASE.CARGOS - -
    DATABASE.CLIENTS - -
    DATABASE.COUNTRY_ID - -
    DATABASE.COUNTRY_NAME - -
    DATABASE.ClassName - -
    DATABASE.DESTROYS -
    DATABASE:ForEachUnit(IteratorFunction, FinalizeFunction, ...)

    Iterate the DATABASE and call an iterator function for each alive UNIT, providing the UNIT and optional parameters.

    -
    DATABASE.GROUPS -
    DATABASE:GetStatusGroup(GroupName)

    Get a status to a Group within the Database, this to check crossing events for example.

    -
    DATABASE.HITS - -
    DATABASE.NavPoints -
    DATABASE:OnEventNewCargo(EventData)

    Handles the OnEventNewCargo event.

    -
    DATABASE.PLAYERS - -
    DATABASE.PLAYERSETTINGS - -
    DATABASE.PLAYERSJOINED - -
    DATABASE.PLAYERUNITS - -
    DATABASE.STATICS -
    DATABASE:Spawn(SpawnTemplate)

    Instantiate new Groups within the DCSRTE.

    -
    DATABASE.Templates -
    DATABASE.UNITS -
    DATABASE.UNITS_Index -
    DATABASE.UNITS_Position -
    DATABASE.ZONENAMES -
    DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionID, CategoryID, CountryID)DATABASE:_RegisterGroupTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName)

    Private method that registers new Group Templates within the DATABASE Object.

    GROUP:IsShip()

    Returns if the DCS Group contains Ships.

    +
    GROUP:NewTemplate(GroupTemplate, CoalitionSide, CategoryID, CountryID) +

    Create a new GROUP from a given GroupTemplate as a parameter.

    GROUP:Register(GroupName) -

    Create a new GROUP from a DCSGroup

    +

    Create a new GROUP from an existing Group in the Mission.

    POSITIONABLE:GetVelocity() -

    Returns the POSITIONABLE velocity vector.

    +

    Returns the a Velocity object from the positionable.

    POSITIONABLE:GetVelocityMPS()

    Returns the POSITIONABLE velocity in meters per second.

    +
    POSITIONABLE:GetVelocityVec3() +

    Returns the POSITIONABLE velocity Vec3 vector.

    SET_PLAYER +

    4) SET_PLAYER class, extends Set#SET_BASE

    + +

    Mission designers can use the Set#SET_PLAYER class to build sets of units belonging to alive players:

    + +

    4.1) SET_PLAYER constructor

    + +

    Create a new SET_PLAYER object with the SET_PLAYER.New method:

    + +
    SET_GROUP:_EventOnDeadOrCrash(Event)

    Handles the OnDead or OnCrash event for alive groups set.

    +
    + +

    Type SET_PLAYER

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    SET_PLAYER:AddClientsByName(AddClientNames) +

    Add CLIENT(s) to SET_PLAYER.

    +
    SET_PLAYER:AddInDatabase(Event) +

    Handles the Database to check on an event (birth) that the Object was added in the Database.

    +
    SET_PLAYER:FilterCategories(Categories) +

    Builds a set of clients out of categories joined by players.

    +
    SET_PLAYER:FilterCoalitions(Coalitions) +

    Builds a set of clients of coalitions joined by specific players.

    +
    SET_PLAYER:FilterCountries(Countries) +

    Builds a set of clients of defined countries.

    +
    SET_PLAYER:FilterPrefixes(Prefixes) +

    Builds a set of clients of defined client prefixes.

    +
    SET_PLAYER:FilterStart() +

    Starts the filtering.

    +
    SET_PLAYER:FilterTypes(Types) +

    Builds a set of clients of defined client types joined by players.

    +
    SET_PLAYER:FindClient(PlayerName) +

    Finds a Client based on the Player Name.

    +
    SET_PLAYER:FindInDatabase(Event) +

    Handles the Database to check on any event that Object exists in the Database.

    +
    SET_PLAYER:ForEachPlayer(IteratorFunction, ...) +

    Iterate the SET_PLAYER and call an interator function for each alive CLIENT, providing the CLIENT and optional parameters.

    +
    SET_PLAYER:ForEachPlayerInZone(ZoneObject, IteratorFunction, ...) +

    Iterate the SET_PLAYER and call an iterator function for each alive CLIENT presence completely in a Zone, providing the CLIENT and optional parameters to the called function.

    +
    SET_PLAYER:ForEachPlayerNotInZone(ZoneObject, IteratorFunction, ...) +

    Iterate the SET_PLAYER and call an iterator function for each alive CLIENT presence not in a Zone, providing the CLIENT and optional parameters to the called function.

    +
    SET_PLAYER:IsIncludeObject(MClient) + +
    SET_PLAYER:New() +

    Creates a new SET_PLAYER object, building a set of clients belonging to a coalitions, categories, countries, types or with defined prefix names.

    +
    SET_PLAYER:RemoveClientsByName(RemoveClientNames) +

    Remove CLIENT(s) from SET_PLAYER.

    @@ -1664,6 +1780,69 @@ The following iterator methods are currently available within the SETGROUP:
    + + +
    +
    + + #SET_PLAYER + +SET_PLAYER + +
    +
    + +

    4) SET_PLAYER class, extends Set#SET_BASE

    + +

    Mission designers can use the Set#SET_PLAYER class to build sets of units belonging to alive players:

    + +

    4.1) SET_PLAYER constructor

    + +

    Create a new SET_PLAYER object with the SET_PLAYER.New method:

    + + + + +

    +

    4.3) SET_PLAYER filter criteria

    + +

    You can set filter criteria to define the set of clients within the SET_PLAYER. +Filter criteria are defined by:

    + + + +

    Once the filter criteria have been set for the SET_PLAYER, you can start filtering using:

    + + + +

    Planned filter criteria within development are (so these are not yet available):

    + + + +

    4.4) SET_PLAYER iterators

    + +

    Once the filters have been defined and the SETPLAYER has been built, you can iterate the SETPLAYER with the available iterator methods. +The iterator methods will walk the SETPLAYER set, and call for each element within the set a function that you provide. +The following iterator methods are currently available within the SETPLAYER:

    + + + +
    +
    @@ -4828,6 +5007,491 @@ A single name or an array of GROUP names.

    + +
    + +

    Type SET_PLAYER

    +

    Field(s)

    +
    +
    + + +SET_PLAYER:AddClientsByName(AddClientNames) + +
    +
    + +

    Add CLIENT(s) to SET_PLAYER.

    + +

    Parameter

    +
      +
    • + +

      #string AddClientNames : +A single name or an array of CLIENT names.

      + +
    • +
    +

    Return value

    + + +

    self

    + +
    +
    +
    +
    + + +SET_PLAYER:AddInDatabase(Event) + +
    +
    + +

    Handles the Database to check on an event (birth) that the Object was added in the Database.

    + + +

    This is required, because sometimes the DATABASE birth event gets called later than the SETBASE birth event!

    + +

    Parameter

    + +

    Return values

    +
      +
    1. + +

      #string: +The name of the CLIENT

      + +
    2. +
    3. + +

      #table: +The CLIENT

      + +
    4. +
    +
    +
    +
    +
    + + +SET_PLAYER:FilterCategories(Categories) + +
    +
    + +

    Builds a set of clients out of categories joined by players.

    + + +

    Possible current categories are plane, helicopter, ground, ship.

    + +

    Parameter

    +
      +
    • + +

      #string Categories : +Can take the following values: "plane", "helicopter", "ground", "ship".

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FilterCoalitions(Coalitions) + +
    +
    + +

    Builds a set of clients of coalitions joined by specific players.

    + + +

    Possible current coalitions are red, blue and neutral.

    + +

    Parameter

    +
      +
    • + +

      #string Coalitions : +Can take the following values: "red", "blue", "neutral".

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FilterCountries(Countries) + +
    +
    + +

    Builds a set of clients of defined countries.

    + + +

    Possible current countries are those known within DCS world.

    + +

    Parameter

    +
      +
    • + +

      #string Countries : +Can take those country strings known within DCS world.

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FilterPrefixes(Prefixes) + +
    +
    + +

    Builds a set of clients of defined client prefixes.

    + + +

    All the clients starting with the given prefixes will be included within the set.

    + +

    Parameter

    +
      +
    • + +

      #string Prefixes : +The prefix of which the client name starts with.

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FilterStart() + +
    +
    + +

    Starts the filtering.

    + +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FilterTypes(Types) + +
    +
    + +

    Builds a set of clients of defined client types joined by players.

    + + +

    Possible current types are those types known within DCS world.

    + +

    Parameter

    +
      +
    • + +

      #string Types : +Can take those type strings known within DCS world.

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:FindClient(PlayerName) + +
    +
    + +

    Finds a Client based on the Player Name.

    + +

    Parameter

    +
      +
    • + +

      #string PlayerName :

      + +
    • +
    +

    Return value

    + +

    Wrapper.Client#CLIENT: +The found Client.

    + +
    +
    +
    +
    + + +SET_PLAYER:FindInDatabase(Event) + +
    +
    + +

    Handles the Database to check on any event that Object exists in the Database.

    + + +

    This is required, because sometimes the DATABASE event gets called later than the SETBASE event or vise versa!

    + +

    Parameter

    + +

    Return values

    +
      +
    1. + +

      #string: +The name of the CLIENT

      + +
    2. +
    3. + +

      #table: +The CLIENT

      + +
    4. +
    +
    +
    +
    +
    + + +SET_PLAYER:ForEachPlayer(IteratorFunction, ...) + +
    +
    + +

    Iterate the SET_PLAYER and call an interator function for each alive CLIENT, providing the CLIENT and optional parameters.

    + +

    Parameters

    +
      +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:ForEachPlayerInZone(ZoneObject, IteratorFunction, ...) + +
    +
    + +

    Iterate the SET_PLAYER and call an iterator function for each alive CLIENT presence completely in a Zone, providing the CLIENT and optional parameters to the called function.

    + +

    Parameters

    +
      +
    • + +

      Core.Zone#ZONE ZoneObject : +The Zone to be tested for.

      + +
    • +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:ForEachPlayerNotInZone(ZoneObject, IteratorFunction, ...) + +
    +
    + +

    Iterate the SET_PLAYER and call an iterator function for each alive CLIENT presence not in a Zone, providing the CLIENT and optional parameters to the called function.

    + +

    Parameters

    +
      +
    • + +

      Core.Zone#ZONE ZoneObject : +The Zone to be tested for.

      + +
    • +
    • + +

      #function IteratorFunction : +The function that will be called when there is an alive CLIENT in the SET_PLAYER. The function needs to accept a CLIENT parameter.

      + +
    • +
    • + +

      ... :

      + +
    • +
    +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:IsIncludeObject(MClient) + +
    +
    + + + +

    Parameter

    + +

    Return value

    + +

    #SET_PLAYER: +self

    + +
    +
    +
    +
    + + +SET_PLAYER:New() + +
    +
    + +

    Creates a new SET_PLAYER object, building a set of clients belonging to a coalitions, categories, countries, types or with defined prefix names.

    + +

    Return value

    + +

    #SET_PLAYER:

    + + +

    Usage:

    +
    -- Define a new SET_PLAYER Object. This DBObject will contain a reference to all Clients.
    +DBObject = SET_PLAYER:New()
    + +
    +
    +
    +
    + + +SET_PLAYER:RemoveClientsByName(RemoveClientNames) + +
    +
    + +

    Remove CLIENT(s) from SET_PLAYER.

    + +

    Parameter

    + +

    Return value

    + + +

    self

    +
    diff --git a/docs/Documentation/Settings.html b/docs/Documentation/Settings.html index 15ac19c6a..200c0b2e4 100644 --- a/docs/Documentation/Settings.html +++ b/docs/Documentation/Settings.html @@ -1250,7 +1250,7 @@ true if metric.

    - + #boolean SETTINGS.Metric diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html index 749b3fc74..03f7632dc 100644 --- a/docs/Documentation/Spawn.html +++ b/docs/Documentation/Spawn.html @@ -848,6 +848,12 @@ and any spaces before and after the resulting name are removed.

    SPAWN:_TranslateRotate(SpawnIndex, SpawnRootX, SpawnRootY, SpawnX, SpawnY, SpawnAngle) +
    SPAWN.uncontrolled +
    @@ -2308,9 +2314,6 @@ The group that was spawned. You can use this group for further actions.

    - -

    Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.

    -
    @@ -2885,9 +2888,6 @@ when nothing was spawned.

    - -

    Overwrite unit names by default with group name.

    -
    @@ -3889,6 +3889,20 @@ True = Continue Scheduler

    + +
    +
    +
    + + + +SPAWN.uncontrolled + +
    +
    + + +
    diff --git a/docs/Documentation/SpawnStatic.html b/docs/Documentation/SpawnStatic.html index c23cc7a49..cc0683d6e 100644 --- a/docs/Documentation/SpawnStatic.html +++ b/docs/Documentation/SpawnStatic.html @@ -490,6 +490,7 @@ ptional) The name of the new static.

    + #number SPAWNSTATIC.SpawnIndex diff --git a/docs/Documentation/Task_Cargo.html b/docs/Documentation/Task_Cargo.html index 01e61d872..485834c04 100644 --- a/docs/Documentation/Task_Cargo.html +++ b/docs/Documentation/Task_Cargo.html @@ -562,7 +562,7 @@ based on the tasking capabilities defined in Task#TA
    - + Core.Cargo#CARGO FSM_PROCESS.Cargo @@ -576,6 +576,7 @@ based on the tasking capabilities defined in Task#TA
    + FSM_PROCESS.DeployZone @@ -640,7 +641,7 @@ based on the tasking capabilities defined in Task#TA
    - #number + TASK_CARGO.CargoLimit diff --git a/docs/Documentation/Utils.html b/docs/Documentation/Utils.html index c04656808..cf6b13576 100644 --- a/docs/Documentation/Utils.html +++ b/docs/Documentation/Utils.html @@ -317,6 +317,12 @@ which are excellent tools to be reused in an OO environment!.

    UTILS.MetersToNM(meters) + + + + UTILS.MiphToMps(miph) + + @@ -329,6 +335,12 @@ which are excellent tools to be reused in an OO environment!.

    UTILS.MpsToKnots(mps) + + + + UTILS.MpsToMiph(mps) + + @@ -910,6 +922,27 @@ is the name of the class to evaluate (can be either a string or a Moose class)
    + +UTILS.MiphToMps(miph) + +
    +
    + + + +

    Parameter

    +
      +
    • + +

      miph :

      + +
    • +
    +
    +
    +
    +
    + UTILS.MpsToKmph(mps) @@ -939,6 +972,27 @@ is the name of the class to evaluate (can be either a string or a Moose class)Parameter +
      +
    • + +

      mps :

      + +
    • +
    + +
    +
    +
    + + +UTILS.MpsToMiph(mps) + +
    +
    + + +

    Parameter

    Return value

    @@ -2712,7 +2718,7 @@ The new location of the zone.

    -ZONE_RADIUS:SmokeZone(SmokeColor, Points) +ZONE_RADIUS:SmokeZone(SmokeColor, Points, AddHeight, AddOffSet, AngleOffset)
    @@ -2732,6 +2738,23 @@ The smoke color.

    #number Points : (optional) The amount of points in the circle.

    + +
  • + +

    #number AddHeight : +(optional) The height to be added for the smoke.

    + +
  • +
  • + +

    #number AddOffSet : +(optional) The angle to be added for the smoking start position.

    + +
  • +
  • + +

    AngleOffset :

    +
  • Return value

    diff --git a/docs/Documentation/index.html b/docs/Documentation/index.html index 59b168ce2..387690e79 100644 --- a/docs/Documentation/index.html +++ b/docs/Documentation/index.html @@ -288,7 +288,7 @@ even when there are hardly any players in the mission.

    Base -

    Core -- BASE forms the basis of the MOOSE framework.

    +

    Core -- VELOCITY models a speed, which can be expressed in various formats according the Settings.