mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Lots of bugs fixed
- MISSILETRAINER: is working now... SET_CLIENT. Is working much better now. Had to rework DATABASE, SPAWN to get this straight. BASE: Fixed a bug that has been in de system for a very long time. the parent should have never been deepcopied when inheriting from it. - SCHEDULER: Fixed a nasty bug with the scheduler, when the repeatparameters was nil, i was still repeating, very wrong. fixed now.
This commit is contained in:
parent
bd81d16327
commit
b335e99d5b
@ -116,7 +116,8 @@ end
|
||||
-- @return #BASE Child
|
||||
function BASE:Inherit( Child, Parent )
|
||||
local Child = routines.utils.deepCopy( Child )
|
||||
local Parent = routines.utils.deepCopy( Parent )
|
||||
--local Parent = routines.utils.deepCopy( Parent )
|
||||
--local Parent = Parent
|
||||
if Child ~= nil then
|
||||
setmetatable( Child, Parent )
|
||||
Child.__index = Child
|
||||
|
||||
@ -133,6 +133,7 @@ function CLIENT:Register( ClientName )
|
||||
--self.AliveCheckScheduler = routines.scheduleFunction( self._AliveCheckScheduler, { self }, timer.getTime() + 1, 5 )
|
||||
self.AliveCheckScheduler = SCHEDULER:New( self, self._AliveCheckScheduler, {}, 1, 5 )
|
||||
|
||||
self:E( self )
|
||||
return self
|
||||
end
|
||||
|
||||
@ -230,10 +231,10 @@ end
|
||||
-- @param #CLIENT self
|
||||
-- @param #function CallBack Function.
|
||||
-- @return #CLIENT
|
||||
function CLIENT:Alive( CallBack, ... )
|
||||
function CLIENT:Alive( CallBackFunction, ... )
|
||||
self:F()
|
||||
|
||||
self.ClientCallBack = CallBack
|
||||
self.ClientCallBack = CallBackFunction
|
||||
self.ClientParameters = arg
|
||||
|
||||
return self
|
||||
@ -241,7 +242,7 @@ end
|
||||
|
||||
--- @param #CLIENT self
|
||||
function CLIENT:_AliveCheckScheduler()
|
||||
self:F( { self.ClientName, self.ClientAlive2, self.ClientBriefingShown } )
|
||||
self:F( { self.ClientName, self.ClientAlive2, self.ClientBriefingShown, self.ClientCallBack } )
|
||||
|
||||
if self:IsAlive() then -- Polymorphic call of UNIT
|
||||
if self.ClientAlive2 == false then
|
||||
|
||||
@ -75,11 +75,11 @@ local _DATABASECoalition =
|
||||
|
||||
local _DATABASECategory =
|
||||
{
|
||||
[Unit.Category.AIRPLANE] = "Plane",
|
||||
[Unit.Category.HELICOPTER] = "Helicopter",
|
||||
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
||||
[Unit.Category.SHIP] = "Ship",
|
||||
[Unit.Category.STRUCTURE] = "Structure",
|
||||
["plane"] = Unit.Category.AIRPLANE,
|
||||
["helicopter"] = Unit.Category.HELICOPTER,
|
||||
["vehicle"] = Unit.Category.GROUND_UNIT,
|
||||
["ship"] = Unit.Category.SHIP,
|
||||
["static"] = Unit.Category.STRUCTURE,
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
||||
SpawnTemplate.SpawnCountryID = nil
|
||||
SpawnTemplate.SpawnCategoryID = nil
|
||||
|
||||
self:_RegisterTemplate( SpawnTemplate )
|
||||
self:_RegisterTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
||||
|
||||
self:T3( SpawnTemplate )
|
||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||
@ -283,14 +283,15 @@ function DATABASE:GetStatusGroup( GroupName )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Private method that registers new Group Templates within the DATABASE Object.
|
||||
-- @param #DATABASE self
|
||||
-- @param #table GroupTemplate
|
||||
-- @return #DATABASE self
|
||||
function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionName, CategoryName, CountryName )
|
||||
function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, CountryID )
|
||||
|
||||
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
||||
|
||||
local TraceTable = {}
|
||||
|
||||
if not self.Templates.Groups[GroupTemplateName] then
|
||||
self.Templates.Groups[GroupTemplateName] = {}
|
||||
@ -307,11 +308,22 @@ function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionName, CategoryName,
|
||||
self.Templates.Groups[GroupTemplateName].groupId = GroupTemplate.groupId
|
||||
self.Templates.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
|
||||
self.Templates.Groups[GroupTemplateName].Units = GroupTemplate.units
|
||||
self.Templates.Groups[GroupTemplateName].CategoryName = CategoryName
|
||||
self.Templates.Groups[GroupTemplateName].CoalitionName = CoalitionName
|
||||
self.Templates.Groups[GroupTemplateName].CountryName = CountryName
|
||||
self.Templates.Groups[GroupTemplateName].CategoryID = CategoryID
|
||||
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionID
|
||||
self.Templates.Groups[GroupTemplateName].CountryID = CountryID
|
||||
|
||||
self:T2( { "Group", self.Templates.Groups[GroupTemplateName].GroupName, self.Templates.Groups[GroupTemplateName].UnitCount } )
|
||||
|
||||
TraceTable[#TraceTable+1] = "Group"
|
||||
TraceTable[#TraceTable+1] = self.Templates.Groups[GroupTemplateName].GroupName
|
||||
|
||||
TraceTable[#TraceTable+1] = "Coalition"
|
||||
TraceTable[#TraceTable+1] = self.Templates.Groups[GroupTemplateName].CoalitionID
|
||||
TraceTable[#TraceTable+1] = "Category"
|
||||
TraceTable[#TraceTable+1] = self.Templates.Groups[GroupTemplateName].CategoryID
|
||||
TraceTable[#TraceTable+1] = "Country"
|
||||
TraceTable[#TraceTable+1] = self.Templates.Groups[GroupTemplateName].CountryID
|
||||
|
||||
TraceTable[#TraceTable+1] = "Units"
|
||||
|
||||
for unit_num, UnitTemplate in pairs( GroupTemplate.units ) do
|
||||
|
||||
@ -322,21 +334,35 @@ function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionName, CategoryName,
|
||||
self.Templates.Units[UnitTemplateName].GroupName = GroupTemplateName
|
||||
self.Templates.Units[UnitTemplateName].GroupTemplate = GroupTemplate
|
||||
self.Templates.Units[UnitTemplateName].GroupId = GroupTemplate.groupId
|
||||
self.Templates.Units[UnitTemplateName].CategoryName = CategoryName
|
||||
self.Templates.Units[UnitTemplateName].CoalitionName = CoalitionName
|
||||
self.Templates.Units[UnitTemplateName].CountryName = CountryName
|
||||
self:E( {"skill",UnitTemplate.skill})
|
||||
self.Templates.Units[UnitTemplateName].CategoryID = CategoryID
|
||||
self.Templates.Units[UnitTemplateName].CoalitionID = CoalitionID
|
||||
self.Templates.Units[UnitTemplateName].CountryID = CountryID
|
||||
|
||||
if UnitTemplate.skill and (UnitTemplate.skill == "Client" or UnitTemplate.skill == "Player") then
|
||||
self.Templates.ClientsByName[UnitTemplateName] = UnitTemplate
|
||||
self.Templates.ClientsByName[UnitTemplateName].CategoryName = CategoryName
|
||||
self.Templates.ClientsByName[UnitTemplateName].CoalitionName = CoalitionName
|
||||
self.Templates.ClientsByName[UnitTemplateName].CountryName = CountryName
|
||||
self.Templates.ClientsByName[UnitTemplateName].CategoryID = CategoryID
|
||||
self.Templates.ClientsByName[UnitTemplateName].CoalitionID = CoalitionID
|
||||
self.Templates.ClientsByName[UnitTemplateName].CountryID = CountryID
|
||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||
end
|
||||
self:E( { "Unit", self.Templates.Units[UnitTemplateName].UnitName } )
|
||||
|
||||
TraceTable[#TraceTable+1] = self.Templates.Units[UnitTemplateName].UnitName
|
||||
end
|
||||
|
||||
self:E( TraceTable )
|
||||
end
|
||||
|
||||
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
||||
return self.Templates.ClientsByName[ClientName].CoalitionID
|
||||
end
|
||||
|
||||
function DATABASE:GetCategoryFromClientTemplate( ClientName )
|
||||
return self.Templates.ClientsByName[ClientName].CategoryID
|
||||
end
|
||||
|
||||
function DATABASE:GetCountryFromClientTemplate( ClientName )
|
||||
return self.Templates.ClientsByName[ClientName].CountryID
|
||||
end
|
||||
|
||||
--- Private method that registers all alive players in the mission.
|
||||
-- @param #DATABASE self
|
||||
@ -671,7 +697,12 @@ function DATABASE:_RegisterTemplates()
|
||||
for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
||||
|
||||
if GroupTemplate and GroupTemplate.units and type(GroupTemplate.units) == 'table' then --making sure again- this is a valid group
|
||||
self:_RegisterTemplate( GroupTemplate, CoalitionName, CategoryName, CountryName )
|
||||
self:_RegisterTemplate(
|
||||
GroupTemplate,
|
||||
coalition.side[string.upper(CoalitionName)],
|
||||
_DATABASECategory[string.lower(CategoryName)],
|
||||
country.id[string.upper(CountryName)]
|
||||
)
|
||||
end --if GroupTemplate and GroupTemplate.units then
|
||||
end --for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
||||
end --if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then
|
||||
|
||||
@ -72,11 +72,72 @@
|
||||
|
||||
--- The MISSILETRAINER class
|
||||
-- @type MISSILETRAINER
|
||||
-- @field Set#SET_CLIENT DBClients
|
||||
-- @extends Base#BASE
|
||||
MISSILETRAINER = {
|
||||
ClassName = "MISSILETRAINER",
|
||||
TrackingMissiles = {},
|
||||
}
|
||||
|
||||
function MISSILETRAINER._Alive( Client, self )
|
||||
|
||||
if self.Briefing then
|
||||
Client:Message( self.Briefing, 15, "HELLO WORLD", "Trainer" )
|
||||
end
|
||||
|
||||
if self.MenusOnOff == true then
|
||||
Client:Message( "Use the 'Radio Menu' -> 'Other (F10)' -> 'Missile Trainer' menu options to change the Missile Trainer settings (for all players).", 15, "MENU", "Trainer" )
|
||||
|
||||
Client.MainMenu = MENU_CLIENT:New( Client, "Missile Trainer", nil ) -- Menu#MENU_CLIENT
|
||||
|
||||
Client.MenuMessages = MENU_CLIENT:New( Client, "Messages", Client.MainMenu )
|
||||
Client.MenuOn = MENU_CLIENT_COMMAND:New( Client, "Messages On", Client.MenuMessages, self._MenuMessages, { MenuSelf = self, MessagesOnOff = true } )
|
||||
Client.MenuOff = MENU_CLIENT_COMMAND:New( Client, "Messages Off", Client.MenuMessages, self._MenuMessages, { MenuSelf = self, MessagesOnOff = false } )
|
||||
|
||||
Client.MenuTracking = MENU_CLIENT:New( Client, "Tracking", Client.MainMenu )
|
||||
Client.MenuTrackingToAll = MENU_CLIENT_COMMAND:New( Client, "To All", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingToAll = true } )
|
||||
Client.MenuTrackingToTarget = MENU_CLIENT_COMMAND:New( Client, "To Target", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingToAll = false } )
|
||||
Client.MenuTrackOn = MENU_CLIENT_COMMAND:New( Client, "Tracking On", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingOnOff = true } )
|
||||
Client.MenuTrackOff = MENU_CLIENT_COMMAND:New( Client, "Tracking Off", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingOnOff = false } )
|
||||
Client.MenuTrackIncrease = MENU_CLIENT_COMMAND:New( Client, "Frequency Increase", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingFrequency = -1 } )
|
||||
Client.MenuTrackDecrease = MENU_CLIENT_COMMAND:New( Client, "Frequency Decrease", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingFrequency = 1 } )
|
||||
|
||||
Client.MenuAlerts = MENU_CLIENT:New( Client, "Alerts", Client.MainMenu )
|
||||
Client.MenuAlertsToAll = MENU_CLIENT_COMMAND:New( Client, "To All", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsToAll = true } )
|
||||
Client.MenuAlertsToTarget = MENU_CLIENT_COMMAND:New( Client, "To Target", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsToAll = false } )
|
||||
Client.MenuHitsOn = MENU_CLIENT_COMMAND:New( Client, "Hits On", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsHitsOnOff = true } )
|
||||
Client.MenuHitsOff = MENU_CLIENT_COMMAND:New( Client, "Hits Off", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsHitsOnOff = false } )
|
||||
Client.MenuLaunchesOn = MENU_CLIENT_COMMAND:New( Client, "Launches On", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsLaunchesOnOff = true } )
|
||||
Client.MenuLaunchesOff = MENU_CLIENT_COMMAND:New( Client, "Launches Off", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsLaunchesOnOff = false } )
|
||||
|
||||
Client.MenuDetails = MENU_CLIENT:New( Client, "Details", Client.MainMenu )
|
||||
Client.MenuDetailsDistanceOn = MENU_CLIENT_COMMAND:New( Client, "Range On", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsRangeOnOff = true } )
|
||||
Client.MenuDetailsDistanceOff = MENU_CLIENT_COMMAND:New( Client, "Range Off", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsRangeOnOff = false } )
|
||||
Client.MenuDetailsBearingOn = MENU_CLIENT_COMMAND:New( Client, "Bearing On", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsBearingOnOff = true } )
|
||||
Client.MenuDetailsBearingOff = MENU_CLIENT_COMMAND:New( Client, "Bearing Off", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsBearingOnOff = false } )
|
||||
|
||||
Client.MenuDistance = MENU_CLIENT:New( Client, "Set distance to plane", Client.MainMenu )
|
||||
Client.MenuDistance50 = MENU_CLIENT_COMMAND:New( Client, "50 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 50 / 1000 } )
|
||||
Client.MenuDistance100 = MENU_CLIENT_COMMAND:New( Client, "100 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 100 / 1000 } )
|
||||
Client.MenuDistance150 = MENU_CLIENT_COMMAND:New( Client, "150 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 150 / 1000 } )
|
||||
Client.MenuDistance200 = MENU_CLIENT_COMMAND:New( Client, "200 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 200 / 1000 } )
|
||||
else
|
||||
if Client.MainMenu then
|
||||
Client.MainMenu:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
local ClientID = Client:GetID()
|
||||
self:T( ClientID )
|
||||
if not self.TrackingMissiles[ClientID] then
|
||||
self.TrackingMissiles[ClientID] = {}
|
||||
end
|
||||
self.TrackingMissiles[ClientID].Client = Client
|
||||
if not self.TrackingMissiles[ClientID].MissileData then
|
||||
self.TrackingMissiles[ClientID].MissileData = {}
|
||||
end
|
||||
end
|
||||
|
||||
--- Creates the main object which is handling missile tracking.
|
||||
-- When a missile is fired a SCHEDULER is set off that follows the missile. When near a certain a client player, the missile will be destroyed.
|
||||
-- @param #MISSILETRAINER self
|
||||
@ -101,76 +162,23 @@ function MISSILETRAINER:New( Distance, Briefing )
|
||||
|
||||
_EVENTDISPATCHER:OnShot( self._EventShot, self )
|
||||
|
||||
self.DB = DATABASE:New():FilterStart()
|
||||
self.DBClients = self.DB.Clients
|
||||
self.DBUnits = self.DB.Units
|
||||
|
||||
for ClientID, Client in pairs( self.DBClients ) do
|
||||
|
||||
local function _Alive( Client )
|
||||
|
||||
if self.Briefing then
|
||||
Client:Message( self.Briefing, 15, "HELLO WORLD", "Trainer" )
|
||||
end
|
||||
|
||||
if self.MenusOnOff == true then
|
||||
Client:Message( "Use the 'Radio Menu' -> 'Other (F10)' -> 'Missile Trainer' menu options to change the Missile Trainer settings (for all players).", 15, "MENU", "Trainer" )
|
||||
|
||||
Client.MainMenu = MENU_CLIENT:New( Client, "Missile Trainer", nil ) -- Menu#MENU_CLIENT
|
||||
|
||||
Client.MenuMessages = MENU_CLIENT:New( Client, "Messages", Client.MainMenu )
|
||||
Client.MenuOn = MENU_CLIENT_COMMAND:New( Client, "Messages On", Client.MenuMessages, self._MenuMessages, { MenuSelf = self, MessagesOnOff = true } )
|
||||
Client.MenuOff = MENU_CLIENT_COMMAND:New( Client, "Messages Off", Client.MenuMessages, self._MenuMessages, { MenuSelf = self, MessagesOnOff = false } )
|
||||
|
||||
Client.MenuTracking = MENU_CLIENT:New( Client, "Tracking", Client.MainMenu )
|
||||
Client.MenuTrackingToAll = MENU_CLIENT_COMMAND:New( Client, "To All", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingToAll = true } )
|
||||
Client.MenuTrackingToTarget = MENU_CLIENT_COMMAND:New( Client, "To Target", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingToAll = false } )
|
||||
Client.MenuTrackOn = MENU_CLIENT_COMMAND:New( Client, "Tracking On", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingOnOff = true } )
|
||||
Client.MenuTrackOff = MENU_CLIENT_COMMAND:New( Client, "Tracking Off", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingOnOff = false } )
|
||||
Client.MenuTrackIncrease = MENU_CLIENT_COMMAND:New( Client, "Frequency Increase", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingFrequency = -1 } )
|
||||
Client.MenuTrackDecrease = MENU_CLIENT_COMMAND:New( Client, "Frequency Decrease", Client.MenuTracking, self._MenuMessages, { MenuSelf = self, TrackingFrequency = 1 } )
|
||||
|
||||
Client.MenuAlerts = MENU_CLIENT:New( Client, "Alerts", Client.MainMenu )
|
||||
Client.MenuAlertsToAll = MENU_CLIENT_COMMAND:New( Client, "To All", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsToAll = true } )
|
||||
Client.MenuAlertsToTarget = MENU_CLIENT_COMMAND:New( Client, "To Target", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsToAll = false } )
|
||||
Client.MenuHitsOn = MENU_CLIENT_COMMAND:New( Client, "Hits On", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsHitsOnOff = true } )
|
||||
Client.MenuHitsOff = MENU_CLIENT_COMMAND:New( Client, "Hits Off", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsHitsOnOff = false } )
|
||||
Client.MenuLaunchesOn = MENU_CLIENT_COMMAND:New( Client, "Launches On", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsLaunchesOnOff = true } )
|
||||
Client.MenuLaunchesOff = MENU_CLIENT_COMMAND:New( Client, "Launches Off", Client.MenuAlerts, self._MenuMessages, { MenuSelf = self, AlertsLaunchesOnOff = false } )
|
||||
|
||||
Client.MenuDetails = MENU_CLIENT:New( Client, "Details", Client.MainMenu )
|
||||
Client.MenuDetailsDistanceOn = MENU_CLIENT_COMMAND:New( Client, "Range On", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsRangeOnOff = true } )
|
||||
Client.MenuDetailsDistanceOff = MENU_CLIENT_COMMAND:New( Client, "Range Off", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsRangeOnOff = false } )
|
||||
Client.MenuDetailsBearingOn = MENU_CLIENT_COMMAND:New( Client, "Bearing On", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsBearingOnOff = true } )
|
||||
Client.MenuDetailsBearingOff = MENU_CLIENT_COMMAND:New( Client, "Bearing Off", Client.MenuDetails, self._MenuMessages, { MenuSelf = self, DetailsBearingOnOff = false } )
|
||||
|
||||
Client.MenuDistance = MENU_CLIENT:New( Client, "Set distance to plane", Client.MainMenu )
|
||||
Client.MenuDistance50 = MENU_CLIENT_COMMAND:New( Client, "50 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 50 / 1000 } )
|
||||
Client.MenuDistance100 = MENU_CLIENT_COMMAND:New( Client, "100 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 100 / 1000 } )
|
||||
Client.MenuDistance150 = MENU_CLIENT_COMMAND:New( Client, "150 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 150 / 1000 } )
|
||||
Client.MenuDistance200 = MENU_CLIENT_COMMAND:New( Client, "200 meter", Client.MenuDistance, self._MenuMessages, { MenuSelf = self, Distance = 200 / 1000 } )
|
||||
else
|
||||
if Client.MainMenu then
|
||||
Client.MainMenu:Remove()
|
||||
end
|
||||
end
|
||||
self.DBClients = SET_CLIENT:New():FilterStart()
|
||||
|
||||
|
||||
local ClientID = Client:GetID()
|
||||
self:T( ClientID )
|
||||
if not self.TrackingMissiles[ClientID] then
|
||||
self.TrackingMissiles[ClientID] = {}
|
||||
end
|
||||
self.TrackingMissiles[ClientID].Client = Client
|
||||
if not self.TrackingMissiles[ClientID].MissileData then
|
||||
self.TrackingMissiles[ClientID].MissileData = {}
|
||||
end
|
||||
-- for ClientID, Client in pairs( self.DBClients.Database ) do
|
||||
-- self:E( "ForEach:" .. Client.UnitName )
|
||||
-- Client:Alive( self._Alive, self )
|
||||
-- end
|
||||
--
|
||||
self.DBClients:ForEachClient(
|
||||
function( Client )
|
||||
self:E( "ForEach:" .. Client.UnitName )
|
||||
Client:Alive( self._Alive, self )
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
Client:Alive( _Alive )
|
||||
|
||||
end
|
||||
|
||||
-- self.DB:ForEachClient(
|
||||
-- --- @param Client#CLIENT Client
|
||||
-- function( Client )
|
||||
@ -205,6 +213,7 @@ end
|
||||
-- Initialization methods.
|
||||
|
||||
|
||||
|
||||
--- Sets by default the display of any message to be ON or OFF.
|
||||
-- @param #MISSILETRAINER self
|
||||
-- @param #boolean MessagesOnOff true or false
|
||||
@ -446,7 +455,7 @@ function MISSILETRAINER:_EventShot( Event )
|
||||
|
||||
self:T(TrainerTargetDCSUnitName )
|
||||
|
||||
local Client = self.DBClients[TrainerTargetDCSUnitName]
|
||||
local Client = self.DBClients:FindClient( TrainerTargetDCSUnitName )
|
||||
if Client then
|
||||
|
||||
local TrainerSourceUnit = UNIT:Find( TrainerSourceDCSUnit )
|
||||
@ -468,6 +477,7 @@ function MISSILETRAINER:_EventShot( Event )
|
||||
end
|
||||
|
||||
local ClientID = Client:GetID()
|
||||
self:T( ClientID )
|
||||
local MissileData = {}
|
||||
MissileData.TrainerSourceUnit = TrainerSourceUnit
|
||||
MissileData.TrainerWeapon = TrainerWeapon
|
||||
|
||||
@ -49,8 +49,10 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
||||
|
||||
if RepeatSecondsInterval then
|
||||
self.RepeatSecondsInterval = RepeatSecondsInterval
|
||||
self.Repeat = true
|
||||
else
|
||||
self.RepeatSecondsInterval = 0
|
||||
self.Repeat = false
|
||||
end
|
||||
|
||||
if RandomizationFactor then
|
||||
@ -63,7 +65,6 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
||||
self.StopSeconds = StopSeconds
|
||||
end
|
||||
|
||||
self.Repeat = false
|
||||
|
||||
self.StartTime = timer.getTime()
|
||||
|
||||
@ -78,7 +79,6 @@ end
|
||||
function SCHEDULER:Start()
|
||||
self:F2( self.TimeEventObject )
|
||||
|
||||
self.Repeat = true
|
||||
timer.scheduleFunction( self._Scheduler, self, timer.getTime() + self.StartSeconds + .01 )
|
||||
|
||||
return self
|
||||
@ -115,14 +115,16 @@ function SCHEDULER:_Scheduler()
|
||||
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||
end
|
||||
|
||||
self:T( { Status, Result } )
|
||||
self:T( { Status, Result, self.StartTime, self.RepeatSecondsInterval, self.RandomizationFactor, self.StopSeconds } )
|
||||
|
||||
if Status and ( ( not Result == nil ) or ( Result and Result ~= false ) ) then
|
||||
if Status and ( ( Result == nil ) or ( Result and Result ~= false ) ) then
|
||||
if self.Repeat and ( not self.StopSeconds or ( self.StopSeconds and timer.getTime() <= self.StartTime + self.StopSeconds ) ) then
|
||||
local ScheduleTime = timer.getTime() + self.RepeatSecondsInterval + math.random( - ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ), ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ) ) + 0.01
|
||||
self:T( { timer.getTime(), ScheduleTime } )
|
||||
timer.scheduleFunction(
|
||||
self._Scheduler,
|
||||
self,
|
||||
timer.getTime() + self.RepeatSecondsInterval + math.random( - ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ), ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ) ) + 0.01
|
||||
ScheduleTime
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -187,7 +187,6 @@
|
||||
SET_BASE = {
|
||||
ClassName = "SET_BASE",
|
||||
Set = {},
|
||||
Database = {},
|
||||
}
|
||||
|
||||
--- Creates a new SET_BASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.
|
||||
@ -198,11 +197,13 @@ SET_BASE = {
|
||||
-- DBObject = SET_BASE:New()
|
||||
function SET_BASE:New( Database )
|
||||
|
||||
env.info( tostring( Database ) )
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
|
||||
self.Database = Database
|
||||
|
||||
|
||||
self.YieldInterval = 10
|
||||
self.TimeInterval = 0.001
|
||||
|
||||
@ -1247,11 +1248,11 @@ SET_CLIENT = {
|
||||
neutral = coalition.side.NEUTRAL,
|
||||
},
|
||||
Categories = {
|
||||
plane = "plane",
|
||||
helicopter = "helicopter",
|
||||
ground = "vehicle",
|
||||
ship = "ship",
|
||||
structure = "static",
|
||||
plane = Unit.Category.AIRPLANE,
|
||||
helicopter = Unit.Category.HELICOPTER,
|
||||
ground = Unit.Category.GROUND_UNIT,
|
||||
ship = Unit.Category.SHIP,
|
||||
structure = Unit.Category.STRUCTURE,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1264,7 +1265,6 @@ SET_CLIENT = {
|
||||
-- -- Define a new SET_CLIENT Object. This DBObject will contain a reference to all Clients.
|
||||
-- DBObject = SET_CLIENT:New()
|
||||
function SET_CLIENT:New()
|
||||
|
||||
-- Inherits from BASE
|
||||
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CLIENTS ) )
|
||||
|
||||
@ -1518,9 +1518,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
||||
if self.Filter.Coalitions then
|
||||
local MClientCoalition = false
|
||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||
local ClientCoalitionName = _DATABASE.Templates.ClientsByName[MClientName].CoalitionName
|
||||
self:T3( { "Coalition:", ClientCoalitionName, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionName then
|
||||
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
|
||||
@ -1531,9 +1531,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
||||
if self.Filter.Categories then
|
||||
local MClientCategory = false
|
||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||
local ClientCategoryName = _DATABASE.Templates.ClientsByName[MClientName].CategoryName
|
||||
self:T3( { "Category:", ClientCategoryName, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryName then
|
||||
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
|
||||
@ -1556,9 +1556,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
||||
if self.Filter.Countries then
|
||||
local MClientCountry = false
|
||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||
local ClientCountryName = _DATABASE.Templates.ClientsByName[MClientName].CountryName
|
||||
self:T3( { "Country:", ClientCountryName, country.id[CountryName], CountryName } )
|
||||
if country.id[CountryName] and country.id[ClientCountryName] and country.id[CountryName] == country.id[ClientCountryName] then
|
||||
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
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
|
||||
SetClient = SET_CLIENT:New():FilterCoalitions("blue"):FilterCategories("plane"):FilterCountries("USA"):FilterStart()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user