mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
blanks
This commit is contained in:
parent
e3f4aa3d64
commit
207c9ed62e
@ -1,9 +1,9 @@
|
|||||||
--- **Core** - Manages several databases containing templates, mission objects, and mission information.
|
--- **Core** - Manages several databases containing templates, mission objects, and mission information.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ## Features:
|
-- ## Features:
|
||||||
--
|
--
|
||||||
-- * During mission startup, scan the mission environment, and create / instantiate intelligently the different objects as defined within the mission.
|
-- * During mission startup, scan the mission environment, and create / instantiate intelligently the different objects as defined within the mission.
|
||||||
-- * Manage database of DCS Group templates (as modelled using the mission editor).
|
-- * Manage database of DCS Group templates (as modelled using the mission editor).
|
||||||
-- - Group templates.
|
-- - Group templates.
|
||||||
@ -20,14 +20,14 @@
|
|||||||
-- * Manage database of hits to units and statics.
|
-- * Manage database of hits to units and statics.
|
||||||
-- * Manage database of destroys of units and statics.
|
-- * Manage database of destroys of units and statics.
|
||||||
-- * Manage database of @{Core.Zone#ZONE_BASE} objects.
|
-- * Manage database of @{Core.Zone#ZONE_BASE} objects.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
-- ### Contributions:
|
-- ### Contributions:
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module Core.Database
|
-- @module Core.Database
|
||||||
-- @image Core_Database.JPG
|
-- @image Core_Database.JPG
|
||||||
|
|
||||||
@ -36,9 +36,9 @@
|
|||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- Contains collections of wrapper objects defined within MOOSE that reflect objects within the simulator.
|
--- Contains collections of wrapper objects defined within MOOSE that reflect objects within the simulator.
|
||||||
--
|
--
|
||||||
-- Mission designers can use the DATABASE class to refer to:
|
-- Mission designers can use the DATABASE class to refer to:
|
||||||
--
|
--
|
||||||
-- * STATICS
|
-- * STATICS
|
||||||
-- * UNITS
|
-- * UNITS
|
||||||
-- * GROUPS
|
-- * GROUPS
|
||||||
@ -47,12 +47,12 @@
|
|||||||
-- * PLAYERSJOINED
|
-- * PLAYERSJOINED
|
||||||
-- * PLAYERS
|
-- * PLAYERS
|
||||||
-- * CARGOS
|
-- * CARGOS
|
||||||
--
|
--
|
||||||
-- On top, for internal MOOSE administration purposes, the DATBASE administers the Unit and Group TEMPLATES as defined within the Mission Editor.
|
-- 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.
|
-- 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.
|
-- Moose refers to **_DATABASE** within the framework extensively, but you can also refer to the _DATABASE object within your missions if required.
|
||||||
--
|
--
|
||||||
-- @field #DATABASE
|
-- @field #DATABASE
|
||||||
DATABASE = {
|
DATABASE = {
|
||||||
ClassName = "DATABASE",
|
ClassName = "DATABASE",
|
||||||
@ -116,7 +116,7 @@ function DATABASE:New()
|
|||||||
local self = BASE:Inherit( self, BASE:New() ) -- #DATABASE
|
local self = BASE:Inherit( self, BASE:New() ) -- #DATABASE
|
||||||
|
|
||||||
self:SetEventPriority( 1 )
|
self:SetEventPriority( 1 )
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
|
self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
|
||||||
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
|
||||||
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
|
||||||
@ -126,11 +126,11 @@ function DATABASE:New()
|
|||||||
self:HandleEvent( EVENTS.DeleteCargo )
|
self:HandleEvent( EVENTS.DeleteCargo )
|
||||||
self:HandleEvent( EVENTS.NewZone )
|
self:HandleEvent( EVENTS.NewZone )
|
||||||
self:HandleEvent( EVENTS.DeleteZone )
|
self:HandleEvent( EVENTS.DeleteZone )
|
||||||
|
|
||||||
-- Follow alive players and clients
|
-- Follow alive players and clients
|
||||||
--self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit ) -- This is not working anymore!, handling this through the birth event.
|
--self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit ) -- This is not working anymore!, handling this through the birth event.
|
||||||
self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
|
self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
|
||||||
|
|
||||||
self:_RegisterTemplates()
|
self:_RegisterTemplates()
|
||||||
self:_RegisterGroupsAndUnits()
|
self:_RegisterGroupsAndUnits()
|
||||||
self:_RegisterClients()
|
self:_RegisterClients()
|
||||||
@ -139,16 +139,16 @@ function DATABASE:New()
|
|||||||
self:_RegisterAirbases()
|
self:_RegisterAirbases()
|
||||||
|
|
||||||
self.UNITS_Position = 0
|
self.UNITS_Position = 0
|
||||||
|
|
||||||
--- @param #DATABASE self
|
--- @param #DATABASE self
|
||||||
local function CheckPlayers( self )
|
local function CheckPlayers( self )
|
||||||
|
|
||||||
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ), AlivePlayersNeutral = coalition.getPlayers( coalition.side.NEUTRAL )}
|
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ), AlivePlayersNeutral = coalition.getPlayers( coalition.side.NEUTRAL )}
|
||||||
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
|
||||||
--self:E( { "CoalitionData:", CoalitionData } )
|
--self:E( { "CoalitionData:", CoalitionData } )
|
||||||
for UnitId, UnitData in pairs( CoalitionData ) do
|
for UnitId, UnitData in pairs( CoalitionData ) do
|
||||||
if UnitData and UnitData:isExist() then
|
if UnitData and UnitData:isExist() then
|
||||||
|
|
||||||
local UnitName = UnitData:getName()
|
local UnitName = UnitData:getName()
|
||||||
local PlayerName = UnitData:getPlayerName()
|
local PlayerName = UnitData:getPlayerName()
|
||||||
local PlayerUnit = UNIT:Find( UnitData )
|
local PlayerUnit = UNIT:Find( UnitData )
|
||||||
@ -167,10 +167,10 @@ function DATABASE:New()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--self:E( "Scheduling" )
|
--self:E( "Scheduling" )
|
||||||
--PlayerCheckSchedule = SCHEDULER:New( nil, CheckPlayers, { self }, 1, 1 )
|
--PlayerCheckSchedule = SCHEDULER:New( nil, CheckPlayers, { self }, 1, 1 )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -193,10 +193,10 @@ function DATABASE:AddUnit( DCSUnitName )
|
|||||||
self:T( { "Add UNIT:", DCSUnitName } )
|
self:T( { "Add UNIT:", DCSUnitName } )
|
||||||
local UnitRegister = UNIT:Register( DCSUnitName )
|
local UnitRegister = UNIT:Register( DCSUnitName )
|
||||||
self.UNITS[DCSUnitName] = UNIT:Register( DCSUnitName )
|
self.UNITS[DCSUnitName] = UNIT:Register( DCSUnitName )
|
||||||
|
|
||||||
table.insert( self.UNITS_Index, DCSUnitName )
|
table.insert( self.UNITS_Index, DCSUnitName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.UNITS[DCSUnitName]
|
return self.UNITS[DCSUnitName]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ end
|
|||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
function DATABASE:DeleteUnit( DCSUnitName )
|
function DATABASE:DeleteUnit( DCSUnitName )
|
||||||
|
|
||||||
self.UNITS[DCSUnitName] = nil
|
self.UNITS[DCSUnitName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a Static based on the Static Name in the DATABASE.
|
--- Adds a Static based on the Static Name in the DATABASE.
|
||||||
@ -216,7 +216,7 @@ function DATABASE:AddStatic( DCSStaticName )
|
|||||||
self.STATICS[DCSStaticName] = STATIC:Register( DCSStaticName )
|
self.STATICS[DCSStaticName] = STATIC:Register( DCSStaticName )
|
||||||
return self.STATICS[DCSStaticName]
|
return self.STATICS[DCSStaticName]
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ end
|
|||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
function DATABASE:DeleteStatic( DCSStaticName )
|
function DATABASE:DeleteStatic( DCSStaticName )
|
||||||
|
|
||||||
--self.STATICS[DCSStaticName] = nil
|
--self.STATICS[DCSStaticName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Finds a STATIC based on the StaticName.
|
--- Finds a STATIC based on the StaticName.
|
||||||
@ -257,7 +257,7 @@ function DATABASE:AddAirbase( AirbaseName )
|
|||||||
if not self.AIRBASES[AirbaseName] then
|
if not self.AIRBASES[AirbaseName] then
|
||||||
self.AIRBASES[AirbaseName] = AIRBASE:Register( AirbaseName )
|
self.AIRBASES[AirbaseName] = AIRBASE:Register( AirbaseName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.AIRBASES[AirbaseName]
|
return self.AIRBASES[AirbaseName]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ end
|
|||||||
-- @param #string AirbaseName The name of the airbase
|
-- @param #string AirbaseName The name of the airbase
|
||||||
function DATABASE:DeleteAirbase( AirbaseName )
|
function DATABASE:DeleteAirbase( AirbaseName )
|
||||||
|
|
||||||
self.AIRBASES[AirbaseName] = nil
|
self.AIRBASES[AirbaseName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Finds an AIRBASE based on the AirbaseName.
|
--- Finds an AIRBASE based on the AirbaseName.
|
||||||
@ -288,29 +288,29 @@ do -- Zones
|
|||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
-- @return Core.Zone#ZONE_BASE The found ZONE.
|
-- @return Core.Zone#ZONE_BASE The found ZONE.
|
||||||
function DATABASE:FindZone( ZoneName )
|
function DATABASE:FindZone( ZoneName )
|
||||||
|
|
||||||
local ZoneFound = self.ZONES[ZoneName]
|
local ZoneFound = self.ZONES[ZoneName]
|
||||||
return ZoneFound
|
return ZoneFound
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a @{Zone} based on the zone name in the DATABASE.
|
--- Adds a @{Zone} based on the zone name in the DATABASE.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
-- @param Core.Zone#ZONE_BASE Zone The zone.
|
-- @param Core.Zone#ZONE_BASE Zone The zone.
|
||||||
function DATABASE:AddZone( ZoneName, Zone )
|
function DATABASE:AddZone( ZoneName, Zone )
|
||||||
|
|
||||||
if not self.ZONES[ZoneName] then
|
if not self.ZONES[ZoneName] then
|
||||||
self.ZONES[ZoneName] = Zone
|
self.ZONES[ZoneName] = Zone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Deletes a @{Zone} from the DATABASE based on the zone name.
|
--- Deletes a @{Zone} from the DATABASE based on the zone name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
function DATABASE:DeleteZone( ZoneName )
|
function DATABASE:DeleteZone( ZoneName )
|
||||||
|
|
||||||
self.ZONES[ZoneName] = nil
|
self.ZONES[ZoneName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -327,20 +327,20 @@ do -- Zones
|
|||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
self:AddZone( ZoneName, Zone )
|
self:AddZone( ZoneName, Zone )
|
||||||
end
|
end
|
||||||
|
|
||||||
for ZoneGroupName, ZoneGroup in pairs( self.GROUPS ) do
|
for ZoneGroupName, ZoneGroup in pairs( self.GROUPS ) do
|
||||||
if ZoneGroupName:match("#ZONE_POLYGON") then
|
if ZoneGroupName:match("#ZONE_POLYGON") then
|
||||||
local ZoneName1 = ZoneGroupName:match("(.*)#ZONE_POLYGON")
|
local ZoneName1 = ZoneGroupName:match("(.*)#ZONE_POLYGON")
|
||||||
local ZoneName2 = ZoneGroupName:match(".*#ZONE_POLYGON(.*)")
|
local ZoneName2 = ZoneGroupName:match(".*#ZONE_POLYGON(.*)")
|
||||||
local ZoneName = ZoneName1 .. ( ZoneName2 or "" )
|
local ZoneName = ZoneName1 .. ( ZoneName2 or "" )
|
||||||
|
|
||||||
self:I( { "Register ZONE_POLYGON:", Name = ZoneName } )
|
self:I( { "Register ZONE_POLYGON:", Name = ZoneName } )
|
||||||
local Zone_Polygon = ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
local Zone_Polygon = ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
self:AddZone( ZoneName, Zone_Polygon )
|
self:AddZone( ZoneName, Zone_Polygon )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -353,29 +353,29 @@ do -- Zone_Goal
|
|||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
-- @return Core.Zone#ZONE_BASE The found ZONE.
|
-- @return Core.Zone#ZONE_BASE The found ZONE.
|
||||||
function DATABASE:FindZoneGoal( ZoneName )
|
function DATABASE:FindZoneGoal( ZoneName )
|
||||||
|
|
||||||
local ZoneFound = self.ZONES_GOAL[ZoneName]
|
local ZoneFound = self.ZONES_GOAL[ZoneName]
|
||||||
return ZoneFound
|
return ZoneFound
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a @{Zone} based on the zone name in the DATABASE.
|
--- Adds a @{Zone} based on the zone name in the DATABASE.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
-- @param Core.Zone#ZONE_BASE Zone The zone.
|
-- @param Core.Zone#ZONE_BASE Zone The zone.
|
||||||
function DATABASE:AddZoneGoal( ZoneName, Zone )
|
function DATABASE:AddZoneGoal( ZoneName, Zone )
|
||||||
|
|
||||||
if not self.ZONES_GOAL[ZoneName] then
|
if not self.ZONES_GOAL[ZoneName] then
|
||||||
self.ZONES_GOAL[ZoneName] = Zone
|
self.ZONES_GOAL[ZoneName] = Zone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Deletes a @{Zone} from the DATABASE based on the zone name.
|
--- Deletes a @{Zone} from the DATABASE based on the zone name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
function DATABASE:DeleteZoneGoal( ZoneName )
|
function DATABASE:DeleteZoneGoal( ZoneName )
|
||||||
|
|
||||||
self.ZONES_GOAL[ZoneName] = nil
|
self.ZONES_GOAL[ZoneName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end -- Zone_Goal
|
end -- Zone_Goal
|
||||||
@ -385,31 +385,31 @@ do -- cargo
|
|||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string CargoName The name of the airbase
|
-- @param #string CargoName The name of the airbase
|
||||||
function DATABASE:AddCargo( Cargo )
|
function DATABASE:AddCargo( Cargo )
|
||||||
|
|
||||||
if not self.CARGOS[Cargo.Name] then
|
if not self.CARGOS[Cargo.Name] then
|
||||||
self.CARGOS[Cargo.Name] = Cargo
|
self.CARGOS[Cargo.Name] = Cargo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Deletes a Cargo from the DATABASE based on the Cargo Name.
|
--- Deletes a Cargo from the DATABASE based on the Cargo Name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string CargoName The name of the airbase
|
-- @param #string CargoName The name of the airbase
|
||||||
function DATABASE:DeleteCargo( CargoName )
|
function DATABASE:DeleteCargo( CargoName )
|
||||||
|
|
||||||
self.CARGOS[CargoName] = nil
|
self.CARGOS[CargoName] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Finds an CARGO based on the CargoName.
|
--- Finds an CARGO based on the CargoName.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string CargoName
|
-- @param #string CargoName
|
||||||
-- @return Wrapper.Cargo#CARGO The found CARGO.
|
-- @return Wrapper.Cargo#CARGO The found CARGO.
|
||||||
function DATABASE:FindCargo( CargoName )
|
function DATABASE:FindCargo( CargoName )
|
||||||
|
|
||||||
local CargoFound = self.CARGOS[CargoName]
|
local CargoFound = self.CARGOS[CargoName]
|
||||||
return CargoFound
|
return CargoFound
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Checks if the Template name has a #CARGO tag.
|
--- Checks if the Template name has a #CARGO tag.
|
||||||
-- If yes, the group is a cargo.
|
-- If yes, the group is a cargo.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
@ -418,10 +418,10 @@ do -- cargo
|
|||||||
function DATABASE:IsCargo( TemplateName )
|
function DATABASE:IsCargo( TemplateName )
|
||||||
|
|
||||||
TemplateName = env.getValueDictByKey( TemplateName )
|
TemplateName = env.getValueDictByKey( TemplateName )
|
||||||
|
|
||||||
local Cargo = TemplateName:match( "#(CARGO)" )
|
local Cargo = TemplateName:match( "#(CARGO)" )
|
||||||
|
|
||||||
return Cargo and Cargo == "CARGO"
|
return Cargo and Cargo == "CARGO"
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Private method that registers new Static Templates within the DATABASE Object.
|
--- Private method that registers new Static Templates within the DATABASE Object.
|
||||||
@ -430,7 +430,7 @@ do -- cargo
|
|||||||
function DATABASE:_RegisterCargos()
|
function DATABASE:_RegisterCargos()
|
||||||
|
|
||||||
local Groups = UTILS.DeepCopy( self.GROUPS ) -- This is a very important statement. CARGO_GROUP:New creates a new _DATABASE.GROUP entry, which will confuse the loop. I searched 4 hours on this to find the bug!
|
local Groups = UTILS.DeepCopy( self.GROUPS ) -- This is a very important statement. CARGO_GROUP:New creates a new _DATABASE.GROUP entry, which will confuse the loop. I searched 4 hours on this to find the bug!
|
||||||
|
|
||||||
for CargoGroupName, CargoGroup in pairs( Groups ) do
|
for CargoGroupName, CargoGroup in pairs( Groups ) do
|
||||||
self:I( { Cargo = CargoGroupName } )
|
self:I( { Cargo = CargoGroupName } )
|
||||||
if self:IsCargo( CargoGroupName ) then
|
if self:IsCargo( CargoGroupName ) then
|
||||||
@ -443,12 +443,12 @@ do -- cargo
|
|||||||
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?") or CargoName
|
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?") or CargoName
|
||||||
local LoadRadius = CargoParam and tonumber( CargoParam:match( "RR=([%a%d]+),?") )
|
local LoadRadius = CargoParam and tonumber( CargoParam:match( "RR=([%a%d]+),?") )
|
||||||
local NearRadius = CargoParam and tonumber( CargoParam:match( "NR=([%a%d]+),?") )
|
local NearRadius = CargoParam and tonumber( CargoParam:match( "NR=([%a%d]+),?") )
|
||||||
|
|
||||||
self:I({"Register CargoGroup:",Type=Type,Name=Name,LoadRadius=LoadRadius,NearRadius=NearRadius})
|
self:I({"Register CargoGroup:",Type=Type,Name=Name,LoadRadius=LoadRadius,NearRadius=NearRadius})
|
||||||
CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius, NearRadius )
|
CARGO_GROUP:New( CargoGroup, Type, Name, LoadRadius, NearRadius )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for CargoStaticName, CargoStatic in pairs( self.STATICS ) do
|
for CargoStaticName, CargoStatic in pairs( self.STATICS ) do
|
||||||
if self:IsCargo( CargoStaticName ) then
|
if self:IsCargo( CargoStaticName ) then
|
||||||
local CargoInfo = CargoStaticName:match("#CARGO(.*)")
|
local CargoInfo = CargoStaticName:match("#CARGO(.*)")
|
||||||
@ -459,7 +459,7 @@ do -- cargo
|
|||||||
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?") or CargoName
|
local Name = CargoParam and CargoParam:match( "N=([%a%d]+),?") or CargoName
|
||||||
local LoadRadius = CargoParam and tonumber( CargoParam:match( "RR=([%a%d]+),?") )
|
local LoadRadius = CargoParam and tonumber( CargoParam:match( "RR=([%a%d]+),?") )
|
||||||
local NearRadius = CargoParam and tonumber( CargoParam:match( "NR=([%a%d]+),?") )
|
local NearRadius = CargoParam and tonumber( CargoParam:match( "NR=([%a%d]+),?") )
|
||||||
|
|
||||||
if Category == "SLING" then
|
if Category == "SLING" then
|
||||||
self:I({"Register CargoSlingload:",Type=Type,Name=Name,LoadRadius=LoadRadius,NearRadius=NearRadius})
|
self:I({"Register CargoSlingload:",Type=Type,Name=Name,LoadRadius=LoadRadius,NearRadius=NearRadius})
|
||||||
CARGO_SLINGLOAD:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
CARGO_SLINGLOAD:New( CargoStatic, Type, Name, LoadRadius, NearRadius )
|
||||||
@ -471,7 +471,7 @@ do -- cargo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end -- cargo
|
end -- cargo
|
||||||
@ -517,9 +517,9 @@ function DATABASE:AddGroup( GroupName )
|
|||||||
if not self.GROUPS[GroupName] then
|
if not self.GROUPS[GroupName] then
|
||||||
self:T( { "Add GROUP:", GroupName } )
|
self:T( { "Add GROUP:", GroupName } )
|
||||||
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
self.GROUPS[GroupName] = GROUP:Register( GroupName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.GROUPS[GroupName]
|
return self.GROUPS[GroupName]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds a player based on the Player Name in the DATABASE.
|
--- Adds a player based on the Player Name in the DATABASE.
|
||||||
@ -621,7 +621,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
|||||||
for UnitID, UnitData in pairs( SpawnTemplate.units ) do
|
for UnitID, UnitData in pairs( SpawnTemplate.units ) do
|
||||||
self:AddUnit( UnitData.name )
|
self:AddUnit( UnitData.name )
|
||||||
end
|
end
|
||||||
|
|
||||||
return SpawnGroup
|
return SpawnGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -653,21 +653,21 @@ end
|
|||||||
function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName )
|
function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName )
|
||||||
|
|
||||||
local GroupTemplateName = GroupName or env.getValueDictByKey( GroupTemplate.name )
|
local GroupTemplateName = GroupName or env.getValueDictByKey( GroupTemplate.name )
|
||||||
|
|
||||||
if not self.Templates.Groups[GroupTemplateName] then
|
if not self.Templates.Groups[GroupTemplateName] then
|
||||||
self.Templates.Groups[GroupTemplateName] = {}
|
self.Templates.Groups[GroupTemplateName] = {}
|
||||||
self.Templates.Groups[GroupTemplateName].Status = nil
|
self.Templates.Groups[GroupTemplateName].Status = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delete the spans from the route, it is not needed and takes memory.
|
-- Delete the spans from the route, it is not needed and takes memory.
|
||||||
if GroupTemplate.route and GroupTemplate.route.spans then
|
if GroupTemplate.route and GroupTemplate.route.spans then
|
||||||
GroupTemplate.route.spans = nil
|
GroupTemplate.route.spans = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
GroupTemplate.CategoryID = CategoryID
|
GroupTemplate.CategoryID = CategoryID
|
||||||
GroupTemplate.CoalitionID = CoalitionSide
|
GroupTemplate.CoalitionID = CoalitionSide
|
||||||
GroupTemplate.CountryID = CountryID
|
GroupTemplate.CountryID = CountryID
|
||||||
|
|
||||||
self.Templates.Groups[GroupTemplateName].GroupName = GroupTemplateName
|
self.Templates.Groups[GroupTemplateName].GroupName = GroupTemplateName
|
||||||
self.Templates.Groups[GroupTemplateName].Template = GroupTemplate
|
self.Templates.Groups[GroupTemplateName].Template = GroupTemplate
|
||||||
self.Templates.Groups[GroupTemplateName].groupId = GroupTemplate.groupId
|
self.Templates.Groups[GroupTemplateName].groupId = GroupTemplate.groupId
|
||||||
@ -682,7 +682,7 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
|||||||
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
||||||
|
|
||||||
UnitTemplate.name = env.getValueDictByKey(UnitTemplate.name)
|
UnitTemplate.name = env.getValueDictByKey(UnitTemplate.name)
|
||||||
|
|
||||||
self.Templates.Units[UnitTemplate.name] = {}
|
self.Templates.Units[UnitTemplate.name] = {}
|
||||||
self.Templates.Units[UnitTemplate.name].UnitName = UnitTemplate.name
|
self.Templates.Units[UnitTemplate.name].UnitName = UnitTemplate.name
|
||||||
self.Templates.Units[UnitTemplate.name].Template = UnitTemplate
|
self.Templates.Units[UnitTemplate.name].Template = UnitTemplate
|
||||||
@ -700,8 +700,8 @@ function DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, Category
|
|||||||
self.Templates.ClientsByName[UnitTemplate.name].CountryID = CountryID
|
self.Templates.ClientsByName[UnitTemplate.name].CountryID = CountryID
|
||||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||||
end
|
end
|
||||||
|
|
||||||
UnitNames[#UnitNames+1] = self.Templates.Units[UnitTemplate.name].UnitName
|
UnitNames[#UnitNames+1] = self.Templates.Units[UnitTemplate.name].UnitName
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T( { Group = self.Templates.Groups[GroupTemplateName].GroupName,
|
self:T( { Group = self.Templates.Groups[GroupTemplateName].GroupName,
|
||||||
@ -730,13 +730,13 @@ function DATABASE:_RegisterStaticTemplate( StaticTemplate, CoalitionID, Category
|
|||||||
local StaticTemplate = UTILS.DeepCopy( StaticTemplate )
|
local StaticTemplate = UTILS.DeepCopy( StaticTemplate )
|
||||||
|
|
||||||
local StaticTemplateName = env.getValueDictByKey(StaticTemplate.name)
|
local StaticTemplateName = env.getValueDictByKey(StaticTemplate.name)
|
||||||
|
|
||||||
self.Templates.Statics[StaticTemplateName] = self.Templates.Statics[StaticTemplateName] or {}
|
self.Templates.Statics[StaticTemplateName] = self.Templates.Statics[StaticTemplateName] or {}
|
||||||
|
|
||||||
StaticTemplate.CategoryID = CategoryID
|
StaticTemplate.CategoryID = CategoryID
|
||||||
StaticTemplate.CoalitionID = CoalitionID
|
StaticTemplate.CoalitionID = CoalitionID
|
||||||
StaticTemplate.CountryID = CountryID
|
StaticTemplate.CountryID = CountryID
|
||||||
|
|
||||||
self.Templates.Statics[StaticTemplateName].StaticName = StaticTemplateName
|
self.Templates.Statics[StaticTemplateName].StaticName = StaticTemplateName
|
||||||
self.Templates.Statics[StaticTemplateName].GroupTemplate = StaticTemplate
|
self.Templates.Statics[StaticTemplateName].GroupTemplate = StaticTemplate
|
||||||
self.Templates.Statics[StaticTemplateName].UnitTemplate = StaticTemplate.units[1]
|
self.Templates.Statics[StaticTemplateName].UnitTemplate = StaticTemplate.units[1]
|
||||||
@ -747,12 +747,12 @@ function DATABASE:_RegisterStaticTemplate( StaticTemplate, CoalitionID, Category
|
|||||||
self:I( { Static = self.Templates.Statics[StaticTemplateName].StaticName,
|
self:I( { Static = self.Templates.Statics[StaticTemplateName].StaticName,
|
||||||
Coalition = self.Templates.Statics[StaticTemplateName].CoalitionID,
|
Coalition = self.Templates.Statics[StaticTemplateName].CoalitionID,
|
||||||
Category = self.Templates.Statics[StaticTemplateName].CategoryID,
|
Category = self.Templates.Statics[StaticTemplateName].CategoryID,
|
||||||
Country = self.Templates.Statics[StaticTemplateName].CountryID
|
Country = self.Templates.Statics[StaticTemplateName].CountryID
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
self:AddStatic( StaticTemplateName )
|
self:AddStatic( StaticTemplateName )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -820,7 +820,7 @@ function DATABASE:_RegisterPlayers()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -836,12 +836,12 @@ function DATABASE:_RegisterGroupsAndUnits()
|
|||||||
|
|
||||||
if DCSGroup:isExist() then
|
if DCSGroup:isExist() then
|
||||||
local DCSGroupName = DCSGroup:getName()
|
local DCSGroupName = DCSGroup:getName()
|
||||||
|
|
||||||
self:I( { "Register Group:", DCSGroupName } )
|
self:I( { "Register Group:", DCSGroupName } )
|
||||||
self:AddGroup( DCSGroupName )
|
self:AddGroup( DCSGroupName )
|
||||||
|
|
||||||
for DCSUnitId, DCSUnit in pairs( DCSGroup:getUnits() ) do
|
for DCSUnitId, DCSUnit in pairs( DCSGroup:getUnits() ) do
|
||||||
|
|
||||||
local DCSUnitName = DCSUnit:getName()
|
local DCSUnitName = DCSUnit:getName()
|
||||||
self:I( { "Register Unit:", DCSUnitName } )
|
self:I( { "Register Unit:", DCSUnitName } )
|
||||||
self:AddUnit( DCSUnitName )
|
self:AddUnit( DCSUnitName )
|
||||||
@ -849,10 +849,10 @@ function DATABASE:_RegisterGroupsAndUnits()
|
|||||||
else
|
else
|
||||||
self:E( { "Group does not exist: ", DCSGroup } )
|
self:E( { "Group does not exist: ", DCSGroup } )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T("Groups:")
|
self:T("Groups:")
|
||||||
for GroupName, Group in pairs( self.GROUPS ) do
|
for GroupName, Group in pairs( self.GROUPS ) do
|
||||||
self:T( { "Group:", GroupName } )
|
self:T( { "Group:", GroupName } )
|
||||||
@ -870,7 +870,7 @@ function DATABASE:_RegisterClients()
|
|||||||
self:T( { "Register Client:", ClientName } )
|
self:T( { "Register Client:", ClientName } )
|
||||||
self:AddClient( ClientName )
|
self:AddClient( ClientName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -884,7 +884,7 @@ function DATABASE:_RegisterStatics()
|
|||||||
|
|
||||||
if DCSStatic:isExist() then
|
if DCSStatic:isExist() then
|
||||||
local DCSStaticName = DCSStatic:getName()
|
local DCSStaticName = DCSStatic:getName()
|
||||||
|
|
||||||
self:T( { "Register Static:", DCSStaticName } )
|
self:T( { "Register Static:", DCSStaticName } )
|
||||||
self:AddStatic( DCSStaticName )
|
self:AddStatic( DCSStaticName )
|
||||||
else
|
else
|
||||||
@ -914,14 +914,14 @@ function DATABASE:_RegisterAirbases()
|
|||||||
|
|
||||||
for DCSAirbaseId, DCSAirbase in pairs(world.getAirbases()) do
|
for DCSAirbaseId, DCSAirbase in pairs(world.getAirbases()) do
|
||||||
local DCSAirbaseName = DCSAirbase:getName()
|
local DCSAirbaseName = DCSAirbase:getName()
|
||||||
|
|
||||||
-- This gives the incorrect value to be inserted into the airdromeID for DCS 2.5.6!
|
-- This gives the incorrect value to be inserted into the airdromeID for DCS 2.5.6!
|
||||||
local airbaseID=DCSAirbase:getID()
|
local airbaseID=DCSAirbase:getID()
|
||||||
|
|
||||||
local airbase=self:AddAirbase( DCSAirbaseName )
|
local airbase=self:AddAirbase( DCSAirbaseName )
|
||||||
|
|
||||||
self:I(string.format("Register Airbase: %s, getID=%d, GetID=%d (unique=%d)", DCSAirbaseName, DCSAirbase:getID(), airbase:GetID(), airbase:GetID(true)))
|
self:I(string.format("Register Airbase: %s, getID=%d, GetID=%d (unique=%d)", DCSAirbaseName, DCSAirbase:getID(), airbase:GetID(), airbase:GetID(true)))
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -937,7 +937,7 @@ function DATABASE:_EventOnBirth( Event )
|
|||||||
|
|
||||||
if Event.IniDCSUnit then
|
if Event.IniDCSUnit then
|
||||||
if Event.IniObjectCategory == 3 then
|
if Event.IniObjectCategory == 3 then
|
||||||
self:AddStatic( Event.IniDCSUnitName )
|
self:AddStatic( Event.IniDCSUnitName )
|
||||||
else
|
else
|
||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory == 1 then
|
||||||
self:AddUnit( Event.IniDCSUnitName )
|
self:AddUnit( Event.IniDCSUnitName )
|
||||||
@ -979,7 +979,7 @@ function DATABASE:_EventOnDeadOrCrash( Event )
|
|||||||
if Event.IniObjectCategory == 3 then
|
if Event.IniObjectCategory == 3 then
|
||||||
if self.STATICS[Event.IniDCSUnitName] then
|
if self.STATICS[Event.IniDCSUnitName] then
|
||||||
self:DeleteStatic( Event.IniDCSUnitName )
|
self:DeleteStatic( Event.IniDCSUnitName )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Event.IniObjectCategory == 1 then
|
if Event.IniObjectCategory == 1 then
|
||||||
if self.UNITS[Event.IniDCSUnitName] then
|
if self.UNITS[Event.IniDCSUnitName] then
|
||||||
@ -988,7 +988,7 @@ function DATABASE:_EventOnDeadOrCrash( Event )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:AccountDestroys( Event )
|
self:AccountDestroys( Event )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1042,7 +1042,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEach( IteratorFunction, FinalizeFunction, arg, Set )
|
function DATABASE:ForEach( IteratorFunction, FinalizeFunction, arg, Set )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
local function CoRoutine()
|
local function CoRoutine()
|
||||||
local Count = 0
|
local Count = 0
|
||||||
for ObjectID, Object in pairs( Set ) do
|
for ObjectID, Object in pairs( Set ) do
|
||||||
@ -1051,20 +1051,20 @@ function DATABASE:ForEach( IteratorFunction, FinalizeFunction, arg, Set )
|
|||||||
Count = Count + 1
|
Count = Count + 1
|
||||||
-- if Count % 100 == 0 then
|
-- if Count % 100 == 0 then
|
||||||
-- coroutine.yield( false )
|
-- coroutine.yield( false )
|
||||||
-- end
|
-- end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local co = coroutine.create( CoRoutine )
|
-- local co = coroutine.create( CoRoutine )
|
||||||
local co = CoRoutine
|
local co = CoRoutine
|
||||||
|
|
||||||
local function Schedule()
|
local function Schedule()
|
||||||
|
|
||||||
-- local status, res = coroutine.resume( co )
|
-- local status, res = coroutine.resume( co )
|
||||||
local status, res = co()
|
local status, res = co()
|
||||||
self:T3( { status, res } )
|
self:T3( { status, res } )
|
||||||
|
|
||||||
if status == false then
|
if status == false then
|
||||||
error( res )
|
error( res )
|
||||||
end
|
end
|
||||||
@ -1079,7 +1079,7 @@ function DATABASE:ForEach( IteratorFunction, FinalizeFunction, arg, Set )
|
|||||||
|
|
||||||
--local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 )
|
--local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 )
|
||||||
Schedule()
|
Schedule()
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachStatic( IteratorFunction, FinalizeFunction, ... ) --R2.1
|
function DATABASE:ForEachStatic( IteratorFunction, FinalizeFunction, ... ) --R2.1
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.STATICS )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.STATICS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1103,7 +1103,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachUnit( IteratorFunction, FinalizeFunction, ... )
|
function DATABASE:ForEachUnit( IteratorFunction, FinalizeFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.UNITS )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.UNITS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1116,7 +1116,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachGroup( IteratorFunction, FinalizeFunction, ... )
|
function DATABASE:ForEachGroup( IteratorFunction, FinalizeFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.GROUPS )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.GROUPS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1129,9 +1129,9 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachPlayer( IteratorFunction, FinalizeFunction, ... )
|
function DATABASE:ForEachPlayer( IteratorFunction, FinalizeFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERS )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1142,9 +1142,9 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachPlayerJoined( IteratorFunction, FinalizeFunction, ... )
|
function DATABASE:ForEachPlayerJoined( IteratorFunction, FinalizeFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERSJOINED )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERSJOINED )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1154,9 +1154,9 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachPlayerUnit( IteratorFunction, FinalizeFunction, ... )
|
function DATABASE:ForEachPlayerUnit( IteratorFunction, FinalizeFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERUNITS )
|
self:ForEach( IteratorFunction, FinalizeFunction, arg, self.PLAYERUNITS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1167,7 +1167,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachClient( IteratorFunction, ... )
|
function DATABASE:ForEachClient( IteratorFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, arg, self.CLIENTS )
|
self:ForEach( IteratorFunction, arg, self.CLIENTS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1179,7 +1179,7 @@ end
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:ForEachCargo( IteratorFunction, ... )
|
function DATABASE:ForEachCargo( IteratorFunction, ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
self:ForEach( IteratorFunction, arg, self.CARGOS )
|
self:ForEach( IteratorFunction, arg, self.CARGOS )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1306,7 +1306,7 @@ function DATABASE:_RegisterTemplates()
|
|||||||
|
|
||||||
if (CoalitionName == 'red' or CoalitionName == 'blue' or CoalitionName == 'neutrals') and type(coa_data) == 'table' then
|
if (CoalitionName == 'red' or CoalitionName == 'blue' or CoalitionName == 'neutrals') and type(coa_data) == 'table' then
|
||||||
--self.Units[coa_name] = {}
|
--self.Units[coa_name] = {}
|
||||||
|
|
||||||
local CoalitionSide = coalition.side[string.upper(CoalitionName)]
|
local CoalitionSide = coalition.side[string.upper(CoalitionName)]
|
||||||
if CoalitionName=="red" then
|
if CoalitionName=="red" then
|
||||||
CoalitionSide=coalition.side.RED
|
CoalitionSide=coalition.side.RED
|
||||||
@ -1339,10 +1339,10 @@ function DATABASE:_RegisterTemplates()
|
|||||||
|
|
||||||
local CountryName = string.upper(cntry_data.name)
|
local CountryName = string.upper(cntry_data.name)
|
||||||
local CountryID = cntry_data.id
|
local CountryID = cntry_data.id
|
||||||
|
|
||||||
self.COUNTRY_ID[CountryName] = CountryID
|
self.COUNTRY_ID[CountryName] = CountryID
|
||||||
self.COUNTRY_NAME[CountryID] = CountryName
|
self.COUNTRY_NAME[CountryID] = CountryName
|
||||||
|
|
||||||
--self.Units[coa_name][countryName] = {}
|
--self.Units[coa_name][countryName] = {}
|
||||||
--self.Units[coa_name][countryName]["countryId"] = cntry_data.id
|
--self.Units[coa_name][countryName]["countryId"] = cntry_data.id
|
||||||
|
|
||||||
@ -1361,18 +1361,18 @@ function DATABASE:_RegisterTemplates()
|
|||||||
for group_num, Template in pairs(obj_type_data.group) do
|
for group_num, Template in pairs(obj_type_data.group) do
|
||||||
|
|
||||||
if obj_type_name ~= "static" and Template and Template.units and type(Template.units) == 'table' then --making sure again- this is a valid group
|
if obj_type_name ~= "static" and Template and Template.units and type(Template.units) == 'table' then --making sure again- this is a valid group
|
||||||
self:_RegisterGroupTemplate(
|
self:_RegisterGroupTemplate(
|
||||||
Template,
|
Template,
|
||||||
CoalitionSide,
|
CoalitionSide,
|
||||||
_DATABASECategory[string.lower(CategoryName)],
|
_DATABASECategory[string.lower(CategoryName)],
|
||||||
CountryID
|
CountryID
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
self:_RegisterStaticTemplate(
|
self:_RegisterStaticTemplate(
|
||||||
Template,
|
Template,
|
||||||
CoalitionSide,
|
CoalitionSide,
|
||||||
_DATABASECategory[string.lower(CategoryName)],
|
_DATABASECategory[string.lower(CategoryName)],
|
||||||
CountryID
|
CountryID
|
||||||
)
|
)
|
||||||
end --if GroupTemplate and GroupTemplate.units then
|
end --if GroupTemplate and GroupTemplate.units then
|
||||||
end --for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
end --for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
||||||
@ -1393,35 +1393,35 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA Event
|
-- @param Core.Event#EVENTDATA Event
|
||||||
function DATABASE:AccountHits( Event )
|
function DATABASE:AccountHits( Event )
|
||||||
self:F( { Event } )
|
self:F( { Event } )
|
||||||
|
|
||||||
if Event.IniPlayerName ~= nil then -- It is a player that is hitting something
|
if Event.IniPlayerName ~= nil then -- It is a player that is hitting something
|
||||||
self:T( "Hitting Something" )
|
self:T( "Hitting Something" )
|
||||||
|
|
||||||
-- What is he hitting?
|
-- What is he hitting?
|
||||||
if Event.TgtCategory then
|
if Event.TgtCategory then
|
||||||
|
|
||||||
-- A target got hit
|
-- A target got hit
|
||||||
self.HITS[Event.TgtUnitName] = self.HITS[Event.TgtUnitName] or {}
|
self.HITS[Event.TgtUnitName] = self.HITS[Event.TgtUnitName] or {}
|
||||||
local Hit = self.HITS[Event.TgtUnitName]
|
local Hit = self.HITS[Event.TgtUnitName]
|
||||||
|
|
||||||
Hit.Players = Hit.Players or {}
|
Hit.Players = Hit.Players or {}
|
||||||
Hit.Players[Event.IniPlayerName] = true
|
Hit.Players[Event.IniPlayerName] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- It is a weapon initiated by a player, that is hitting something
|
-- It is a weapon initiated by a player, that is hitting something
|
||||||
-- This seems to occur only with scenery and static objects.
|
-- This seems to occur only with scenery and static objects.
|
||||||
if Event.WeaponPlayerName ~= nil then
|
if Event.WeaponPlayerName ~= nil then
|
||||||
self:T( "Hitting Scenery" )
|
self:T( "Hitting Scenery" )
|
||||||
|
|
||||||
-- What is he hitting?
|
-- What is he hitting?
|
||||||
if Event.TgtCategory then
|
if Event.TgtCategory then
|
||||||
|
|
||||||
if Event.WeaponCoalition then -- A coalition object was hit, probably a static.
|
if Event.WeaponCoalition then -- A coalition object was hit, probably a static.
|
||||||
-- A target got hit
|
-- A target got hit
|
||||||
self.HITS[Event.TgtUnitName] = self.HITS[Event.TgtUnitName] or {}
|
self.HITS[Event.TgtUnitName] = self.HITS[Event.TgtUnitName] or {}
|
||||||
local Hit = self.HITS[Event.TgtUnitName]
|
local Hit = self.HITS[Event.TgtUnitName]
|
||||||
|
|
||||||
Hit.Players = Hit.Players or {}
|
Hit.Players = Hit.Players or {}
|
||||||
Hit.Players[Event.WeaponPlayerName] = true
|
Hit.Players[Event.WeaponPlayerName] = true
|
||||||
else -- A scenery object was hit.
|
else -- A scenery object was hit.
|
||||||
@ -1429,13 +1429,13 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Account the destroys.
|
--- Account the destroys.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param Core.Event#EVENTDATA Event
|
-- @param Core.Event#EVENTDATA Event
|
||||||
function DATABASE:AccountDestroys( Event )
|
function DATABASE:AccountDestroys( Event )
|
||||||
self:F( { Event } )
|
self:F( { Event } )
|
||||||
|
|
||||||
local TargetUnit = nil
|
local TargetUnit = nil
|
||||||
local TargetGroup = nil
|
local TargetGroup = nil
|
||||||
local TargetUnitName = ""
|
local TargetUnitName = ""
|
||||||
@ -1447,26 +1447,26 @@ end
|
|||||||
local TargetUnitCoalition = nil
|
local TargetUnitCoalition = nil
|
||||||
local TargetUnitCategory = nil
|
local TargetUnitCategory = nil
|
||||||
local TargetUnitType = nil
|
local TargetUnitType = nil
|
||||||
|
|
||||||
if Event.IniDCSUnit then
|
if Event.IniDCSUnit then
|
||||||
|
|
||||||
TargetUnit = Event.IniUnit
|
TargetUnit = Event.IniUnit
|
||||||
TargetUnitName = Event.IniDCSUnitName
|
TargetUnitName = Event.IniDCSUnitName
|
||||||
TargetGroup = Event.IniDCSGroup
|
TargetGroup = Event.IniDCSGroup
|
||||||
TargetGroupName = Event.IniDCSGroupName
|
TargetGroupName = Event.IniDCSGroupName
|
||||||
TargetPlayerName = Event.IniPlayerName
|
TargetPlayerName = Event.IniPlayerName
|
||||||
|
|
||||||
TargetCoalition = Event.IniCoalition
|
TargetCoalition = Event.IniCoalition
|
||||||
--TargetCategory = TargetUnit:getCategory()
|
--TargetCategory = TargetUnit:getCategory()
|
||||||
--TargetCategory = TargetUnit:getDesc().category -- Workaround
|
--TargetCategory = TargetUnit:getDesc().category -- Workaround
|
||||||
TargetCategory = Event.IniCategory
|
TargetCategory = Event.IniCategory
|
||||||
TargetType = Event.IniTypeName
|
TargetType = Event.IniTypeName
|
||||||
|
|
||||||
TargetUnitType = TargetType
|
TargetUnitType = TargetType
|
||||||
|
|
||||||
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
|
self:T( { TargetUnitName, TargetGroupName, TargetPlayerName, TargetCoalition, TargetCategory, TargetType } )
|
||||||
end
|
end
|
||||||
|
|
||||||
local Destroyed = false
|
local Destroyed = false
|
||||||
|
|
||||||
-- What is the player destroying?
|
-- What is the player destroying?
|
||||||
@ -1475,8 +1475,3 @@ end
|
|||||||
self.DESTROYS[Event.IniUnitName] = true
|
self.DESTROYS[Event.IniUnitName] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user