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
|
-- @return #BASE Child
|
||||||
function BASE:Inherit( Child, Parent )
|
function BASE:Inherit( Child, Parent )
|
||||||
local Child = routines.utils.deepCopy( Child )
|
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
|
if Child ~= nil then
|
||||||
setmetatable( Child, Parent )
|
setmetatable( Child, Parent )
|
||||||
Child.__index = Child
|
Child.__index = Child
|
||||||
|
|||||||
@ -133,6 +133,7 @@ function CLIENT:Register( ClientName )
|
|||||||
--self.AliveCheckScheduler = routines.scheduleFunction( self._AliveCheckScheduler, { self }, timer.getTime() + 1, 5 )
|
--self.AliveCheckScheduler = routines.scheduleFunction( self._AliveCheckScheduler, { self }, timer.getTime() + 1, 5 )
|
||||||
self.AliveCheckScheduler = SCHEDULER:New( self, self._AliveCheckScheduler, {}, 1, 5 )
|
self.AliveCheckScheduler = SCHEDULER:New( self, self._AliveCheckScheduler, {}, 1, 5 )
|
||||||
|
|
||||||
|
self:E( self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -230,10 +231,10 @@ end
|
|||||||
-- @param #CLIENT self
|
-- @param #CLIENT self
|
||||||
-- @param #function CallBack Function.
|
-- @param #function CallBack Function.
|
||||||
-- @return #CLIENT
|
-- @return #CLIENT
|
||||||
function CLIENT:Alive( CallBack, ... )
|
function CLIENT:Alive( CallBackFunction, ... )
|
||||||
self:F()
|
self:F()
|
||||||
|
|
||||||
self.ClientCallBack = CallBack
|
self.ClientCallBack = CallBackFunction
|
||||||
self.ClientParameters = arg
|
self.ClientParameters = arg
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -241,7 +242,7 @@ end
|
|||||||
|
|
||||||
--- @param #CLIENT self
|
--- @param #CLIENT self
|
||||||
function CLIENT:_AliveCheckScheduler()
|
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:IsAlive() then -- Polymorphic call of UNIT
|
||||||
if self.ClientAlive2 == false then
|
if self.ClientAlive2 == false then
|
||||||
|
|||||||
@ -75,11 +75,11 @@ local _DATABASECoalition =
|
|||||||
|
|
||||||
local _DATABASECategory =
|
local _DATABASECategory =
|
||||||
{
|
{
|
||||||
[Unit.Category.AIRPLANE] = "Plane",
|
["plane"] = Unit.Category.AIRPLANE,
|
||||||
[Unit.Category.HELICOPTER] = "Helicopter",
|
["helicopter"] = Unit.Category.HELICOPTER,
|
||||||
[Unit.Category.GROUND_UNIT] = "Vehicle",
|
["vehicle"] = Unit.Category.GROUND_UNIT,
|
||||||
[Unit.Category.SHIP] = "Ship",
|
["ship"] = Unit.Category.SHIP,
|
||||||
[Unit.Category.STRUCTURE] = "Structure",
|
["static"] = Unit.Category.STRUCTURE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ function DATABASE:Spawn( SpawnTemplate )
|
|||||||
SpawnTemplate.SpawnCountryID = nil
|
SpawnTemplate.SpawnCountryID = nil
|
||||||
SpawnTemplate.SpawnCategoryID = nil
|
SpawnTemplate.SpawnCategoryID = nil
|
||||||
|
|
||||||
self:_RegisterTemplate( SpawnTemplate )
|
self:_RegisterTemplate( SpawnTemplate, SpawnCoalitionID, SpawnCategoryID, SpawnCountryID )
|
||||||
|
|
||||||
self:T3( SpawnTemplate )
|
self:T3( SpawnTemplate )
|
||||||
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
coalition.addGroup( SpawnCountryID, SpawnCategoryID, SpawnTemplate )
|
||||||
@ -283,14 +283,15 @@ function DATABASE:GetStatusGroup( GroupName )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Private method that registers new Group Templates within the DATABASE Object.
|
--- Private method that registers new Group Templates within the DATABASE Object.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #table GroupTemplate
|
-- @param #table GroupTemplate
|
||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionName, CategoryName, CountryName )
|
function DATABASE:_RegisterTemplate( GroupTemplate, CoalitionID, CategoryID, CountryID )
|
||||||
|
|
||||||
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
local GroupTemplateName = env.getValueDictByKey(GroupTemplate.name)
|
||||||
|
|
||||||
|
local TraceTable = {}
|
||||||
|
|
||||||
if not self.Templates.Groups[GroupTemplateName] then
|
if not self.Templates.Groups[GroupTemplateName] then
|
||||||
self.Templates.Groups[GroupTemplateName] = {}
|
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].groupId = GroupTemplate.groupId
|
||||||
self.Templates.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
|
self.Templates.Groups[GroupTemplateName].UnitCount = #GroupTemplate.units
|
||||||
self.Templates.Groups[GroupTemplateName].Units = GroupTemplate.units
|
self.Templates.Groups[GroupTemplateName].Units = GroupTemplate.units
|
||||||
self.Templates.Groups[GroupTemplateName].CategoryName = CategoryName
|
self.Templates.Groups[GroupTemplateName].CategoryID = CategoryID
|
||||||
self.Templates.Groups[GroupTemplateName].CoalitionName = CoalitionName
|
self.Templates.Groups[GroupTemplateName].CoalitionID = CoalitionID
|
||||||
self.Templates.Groups[GroupTemplateName].CountryName = CountryName
|
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
|
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].GroupName = GroupTemplateName
|
||||||
self.Templates.Units[UnitTemplateName].GroupTemplate = GroupTemplate
|
self.Templates.Units[UnitTemplateName].GroupTemplate = GroupTemplate
|
||||||
self.Templates.Units[UnitTemplateName].GroupId = GroupTemplate.groupId
|
self.Templates.Units[UnitTemplateName].GroupId = GroupTemplate.groupId
|
||||||
self.Templates.Units[UnitTemplateName].CategoryName = CategoryName
|
self.Templates.Units[UnitTemplateName].CategoryID = CategoryID
|
||||||
self.Templates.Units[UnitTemplateName].CoalitionName = CoalitionName
|
self.Templates.Units[UnitTemplateName].CoalitionID = CoalitionID
|
||||||
self.Templates.Units[UnitTemplateName].CountryName = CountryName
|
self.Templates.Units[UnitTemplateName].CountryID = CountryID
|
||||||
self:E( {"skill",UnitTemplate.skill})
|
|
||||||
if UnitTemplate.skill and (UnitTemplate.skill == "Client" or UnitTemplate.skill == "Player") then
|
if UnitTemplate.skill and (UnitTemplate.skill == "Client" or UnitTemplate.skill == "Player") then
|
||||||
self.Templates.ClientsByName[UnitTemplateName] = UnitTemplate
|
self.Templates.ClientsByName[UnitTemplateName] = UnitTemplate
|
||||||
self.Templates.ClientsByName[UnitTemplateName].CategoryName = CategoryName
|
self.Templates.ClientsByName[UnitTemplateName].CategoryID = CategoryID
|
||||||
self.Templates.ClientsByName[UnitTemplateName].CoalitionName = CoalitionName
|
self.Templates.ClientsByName[UnitTemplateName].CoalitionID = CoalitionID
|
||||||
self.Templates.ClientsByName[UnitTemplateName].CountryName = CountryName
|
self.Templates.ClientsByName[UnitTemplateName].CountryID = CountryID
|
||||||
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
self.Templates.ClientsByID[UnitTemplate.unitId] = UnitTemplate
|
||||||
end
|
end
|
||||||
self:E( { "Unit", self.Templates.Units[UnitTemplateName].UnitName } )
|
|
||||||
|
TraceTable[#TraceTable+1] = self.Templates.Units[UnitTemplateName].UnitName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:E( TraceTable )
|
||||||
end
|
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.
|
--- Private method that registers all alive players in the mission.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
@ -671,7 +697,12 @@ function DATABASE:_RegisterTemplates()
|
|||||||
for group_num, GroupTemplate in pairs(obj_type_data.group) do
|
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
|
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 --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
|
||||||
end --if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then
|
end --if ((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
|
--- The MISSILETRAINER class
|
||||||
-- @type MISSILETRAINER
|
-- @type MISSILETRAINER
|
||||||
|
-- @field Set#SET_CLIENT DBClients
|
||||||
-- @extends Base#BASE
|
-- @extends Base#BASE
|
||||||
MISSILETRAINER = {
|
MISSILETRAINER = {
|
||||||
ClassName = "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.
|
--- 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.
|
-- 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
|
-- @param #MISSILETRAINER self
|
||||||
@ -101,76 +162,23 @@ function MISSILETRAINER:New( Distance, Briefing )
|
|||||||
|
|
||||||
_EVENTDISPATCHER:OnShot( self._EventShot, self )
|
_EVENTDISPATCHER:OnShot( self._EventShot, self )
|
||||||
|
|
||||||
self.DB = DATABASE:New():FilterStart()
|
self.DBClients = SET_CLIENT: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
|
|
||||||
|
|
||||||
|
|
||||||
local ClientID = Client:GetID()
|
-- for ClientID, Client in pairs( self.DBClients.Database ) do
|
||||||
self:T( ClientID )
|
-- self:E( "ForEach:" .. Client.UnitName )
|
||||||
if not self.TrackingMissiles[ClientID] then
|
-- Client:Alive( self._Alive, self )
|
||||||
self.TrackingMissiles[ClientID] = {}
|
-- end
|
||||||
end
|
--
|
||||||
self.TrackingMissiles[ClientID].Client = Client
|
self.DBClients:ForEachClient(
|
||||||
if not self.TrackingMissiles[ClientID].MissileData then
|
function( Client )
|
||||||
self.TrackingMissiles[ClientID].MissileData = {}
|
self:E( "ForEach:" .. Client.UnitName )
|
||||||
end
|
Client:Alive( self._Alive, self )
|
||||||
end
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Client:Alive( _Alive )
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- self.DB:ForEachClient(
|
-- self.DB:ForEachClient(
|
||||||
-- --- @param Client#CLIENT Client
|
-- --- @param Client#CLIENT Client
|
||||||
-- function( Client )
|
-- function( Client )
|
||||||
@ -205,6 +213,7 @@ end
|
|||||||
-- Initialization methods.
|
-- Initialization methods.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Sets by default the display of any message to be ON or OFF.
|
--- Sets by default the display of any message to be ON or OFF.
|
||||||
-- @param #MISSILETRAINER self
|
-- @param #MISSILETRAINER self
|
||||||
-- @param #boolean MessagesOnOff true or false
|
-- @param #boolean MessagesOnOff true or false
|
||||||
@ -446,7 +455,7 @@ function MISSILETRAINER:_EventShot( Event )
|
|||||||
|
|
||||||
self:T(TrainerTargetDCSUnitName )
|
self:T(TrainerTargetDCSUnitName )
|
||||||
|
|
||||||
local Client = self.DBClients[TrainerTargetDCSUnitName]
|
local Client = self.DBClients:FindClient( TrainerTargetDCSUnitName )
|
||||||
if Client then
|
if Client then
|
||||||
|
|
||||||
local TrainerSourceUnit = UNIT:Find( TrainerSourceDCSUnit )
|
local TrainerSourceUnit = UNIT:Find( TrainerSourceDCSUnit )
|
||||||
@ -468,6 +477,7 @@ function MISSILETRAINER:_EventShot( Event )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local ClientID = Client:GetID()
|
local ClientID = Client:GetID()
|
||||||
|
self:T( ClientID )
|
||||||
local MissileData = {}
|
local MissileData = {}
|
||||||
MissileData.TrainerSourceUnit = TrainerSourceUnit
|
MissileData.TrainerSourceUnit = TrainerSourceUnit
|
||||||
MissileData.TrainerWeapon = TrainerWeapon
|
MissileData.TrainerWeapon = TrainerWeapon
|
||||||
|
|||||||
@ -49,8 +49,10 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
|||||||
|
|
||||||
if RepeatSecondsInterval then
|
if RepeatSecondsInterval then
|
||||||
self.RepeatSecondsInterval = RepeatSecondsInterval
|
self.RepeatSecondsInterval = RepeatSecondsInterval
|
||||||
|
self.Repeat = true
|
||||||
else
|
else
|
||||||
self.RepeatSecondsInterval = 0
|
self.RepeatSecondsInterval = 0
|
||||||
|
self.Repeat = false
|
||||||
end
|
end
|
||||||
|
|
||||||
if RandomizationFactor then
|
if RandomizationFactor then
|
||||||
@ -63,7 +65,6 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
|||||||
self.StopSeconds = StopSeconds
|
self.StopSeconds = StopSeconds
|
||||||
end
|
end
|
||||||
|
|
||||||
self.Repeat = false
|
|
||||||
|
|
||||||
self.StartTime = timer.getTime()
|
self.StartTime = timer.getTime()
|
||||||
|
|
||||||
@ -78,7 +79,6 @@ end
|
|||||||
function SCHEDULER:Start()
|
function SCHEDULER:Start()
|
||||||
self:F2( self.TimeEventObject )
|
self:F2( self.TimeEventObject )
|
||||||
|
|
||||||
self.Repeat = true
|
|
||||||
timer.scheduleFunction( self._Scheduler, self, timer.getTime() + self.StartSeconds + .01 )
|
timer.scheduleFunction( self._Scheduler, self, timer.getTime() + self.StartSeconds + .01 )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -115,14 +115,16 @@ function SCHEDULER:_Scheduler()
|
|||||||
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||||
end
|
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
|
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(
|
timer.scheduleFunction(
|
||||||
self._Scheduler,
|
self._Scheduler,
|
||||||
self,
|
self,
|
||||||
timer.getTime() + self.RepeatSecondsInterval + math.random( - ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ), ( self.RandomizationFactor * self.RepeatSecondsInterval / 2 ) ) + 0.01
|
ScheduleTime
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -187,7 +187,6 @@
|
|||||||
SET_BASE = {
|
SET_BASE = {
|
||||||
ClassName = "SET_BASE",
|
ClassName = "SET_BASE",
|
||||||
Set = {},
|
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.
|
--- 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()
|
-- DBObject = SET_BASE:New()
|
||||||
function SET_BASE:New( Database )
|
function SET_BASE:New( Database )
|
||||||
|
|
||||||
|
env.info( tostring( Database ) )
|
||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
|
|
||||||
self.Database = Database
|
self.Database = Database
|
||||||
|
|
||||||
self.YieldInterval = 10
|
self.YieldInterval = 10
|
||||||
self.TimeInterval = 0.001
|
self.TimeInterval = 0.001
|
||||||
|
|
||||||
@ -1247,11 +1248,11 @@ SET_CLIENT = {
|
|||||||
neutral = coalition.side.NEUTRAL,
|
neutral = coalition.side.NEUTRAL,
|
||||||
},
|
},
|
||||||
Categories = {
|
Categories = {
|
||||||
plane = "plane",
|
plane = Unit.Category.AIRPLANE,
|
||||||
helicopter = "helicopter",
|
helicopter = Unit.Category.HELICOPTER,
|
||||||
ground = "vehicle",
|
ground = Unit.Category.GROUND_UNIT,
|
||||||
ship = "ship",
|
ship = Unit.Category.SHIP,
|
||||||
structure = "static",
|
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.
|
-- -- Define a new SET_CLIENT Object. This DBObject will contain a reference to all Clients.
|
||||||
-- DBObject = SET_CLIENT:New()
|
-- DBObject = SET_CLIENT:New()
|
||||||
function SET_CLIENT:New()
|
function SET_CLIENT:New()
|
||||||
|
|
||||||
-- Inherits from BASE
|
-- Inherits from BASE
|
||||||
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CLIENTS ) )
|
local self = BASE:Inherit( self, SET_BASE:New( _DATABASE.CLIENTS ) )
|
||||||
|
|
||||||
@ -1518,9 +1518,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
|||||||
if self.Filter.Coalitions then
|
if self.Filter.Coalitions then
|
||||||
local MClientCoalition = false
|
local MClientCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
local ClientCoalitionName = _DATABASE.Templates.ClientsByName[MClientName].CoalitionName
|
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
||||||
self:T3( { "Coalition:", ClientCoalitionName, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionName then
|
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then
|
||||||
MClientCoalition = true
|
MClientCoalition = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1531,9 +1531,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
|||||||
if self.Filter.Categories then
|
if self.Filter.Categories then
|
||||||
local MClientCategory = false
|
local MClientCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local ClientCategoryName = _DATABASE.Templates.ClientsByName[MClientName].CategoryName
|
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
||||||
self:T3( { "Category:", ClientCategoryName, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryName then
|
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then
|
||||||
MClientCategory = true
|
MClientCategory = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1556,9 +1556,9 @@ function SET_CLIENT:IsIncludeObject( MClient )
|
|||||||
if self.Filter.Countries then
|
if self.Filter.Countries then
|
||||||
local MClientCountry = false
|
local MClientCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
local ClientCountryName = _DATABASE.Templates.ClientsByName[MClientName].CountryName
|
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate(MClientName)
|
||||||
self:T3( { "Country:", ClientCountryName, country.id[CountryName], CountryName } )
|
self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } )
|
||||||
if country.id[CountryName] and country.id[ClientCountryName] and country.id[CountryName] == country.id[ClientCountryName] then
|
if country.id[CountryName] and country.id[CountryName] == ClientCountryID then
|
||||||
MClientCountry = true
|
MClientCountry = true
|
||||||
end
|
end
|
||||||
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