mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
xxx
This commit is contained in:
parent
e1ac5633f9
commit
fea05b552c
@ -28,17 +28,17 @@
|
|||||||
-- @field #booelan debug
|
-- @field #booelan debug
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
-- @field #number Interval
|
-- @field #number Interval
|
||||||
-- @field Core.Set#SET_CLIENT PilotSet
|
|
||||||
-- @field Core.Set#SET_GROUP GroundSet
|
-- @field Core.Set#SET_GROUP GroundSet
|
||||||
-- @field #string CoalitionText
|
|
||||||
-- @field #number Coalition
|
-- @field #number Coalition
|
||||||
-- @field Core.Set#SET_GROUP VehicleSet
|
-- @field Core.Set#SET_GROUP VehicleSet
|
||||||
-- @field Core.Set#SET_GROUP AAASet
|
-- @field Core.Set#SET_GROUP AAASet
|
||||||
-- @field Core.Set#SET_GROUP SAMSet
|
-- @field Core.Set#SET_GROUP SAMSet
|
||||||
|
-- @field Core.Set#SET_GROUP ExceptionSet
|
||||||
-- @field #number AAARange
|
-- @field #number AAARange
|
||||||
-- @field #number HeloSwitchRange
|
-- @field #number HeloSwitchRange
|
||||||
-- @field #number PlaneSwitchRange
|
-- @field #number PlaneSwitchRange
|
||||||
-- @field Core.Set#SET_GROUP FlightSet
|
-- @field Core.Set#SET_GROUP FlightSet
|
||||||
|
-- @field #boolean SwitchAAA
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -47,27 +47,28 @@
|
|||||||
-- @field #number range
|
-- @field #number range
|
||||||
-- @field #boolean invisible
|
-- @field #boolean invisible
|
||||||
-- @field #boolean AIOff
|
-- @field #boolean AIOff
|
||||||
|
-- @field #boolean exception
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- # Documentation
|
-- # Documentation
|
||||||
--
|
--
|
||||||
-- @field TIRESIAS
|
-- @field #TIRESIAS
|
||||||
TIRESIAS = {
|
TIRESIAS = {
|
||||||
ClassName = "TIRESIAS",
|
ClassName = "TIRESIAS",
|
||||||
debug = true,
|
debug = false,
|
||||||
version = "0.0.1",
|
version = "0.0.2",
|
||||||
Interval = 20,
|
Interval = 20,
|
||||||
PilotSet = nil,
|
|
||||||
GroundSet = nil,
|
GroundSet = nil,
|
||||||
CoalitionText = "blue",
|
|
||||||
Coalition = coalition.side.BLUE,
|
Coalition = coalition.side.BLUE,
|
||||||
VehicleSet = nil,
|
VehicleSet = nil,
|
||||||
AAASet = nil,
|
AAASet = nil,
|
||||||
SAMSet = nil,
|
SAMSet = nil,
|
||||||
AAARange = 60,
|
ExceptionSet = nil,
|
||||||
|
AAARange = 60, -- 60%
|
||||||
HeloSwitchRange = 10, -- NM
|
HeloSwitchRange = 10, -- NM
|
||||||
PlaneSwitchRange = 25, -- NM
|
PlaneSwitchRange = 25, -- NM
|
||||||
|
SwitchAAA = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -78,8 +79,6 @@ function TIRESIAS:New()
|
|||||||
-- Inherit everything from FSM class.
|
-- Inherit everything from FSM class.
|
||||||
local self = BASE:Inherit(self, FSM:New()) -- #TIRESIAS
|
local self = BASE:Inherit(self, FSM:New()) -- #TIRESIAS
|
||||||
|
|
||||||
self.PilotSet = SET_CLIENT:New():FilterActive(true):FilterCoalitions(self.CoalitionText):FilterStart()
|
|
||||||
|
|
||||||
--- FSM Functions ---
|
--- FSM Functions ---
|
||||||
|
|
||||||
-- Start State.
|
-- Start State.
|
||||||
@ -107,6 +106,29 @@ end
|
|||||||
--
|
--
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @param #TIRESIAS self
|
||||||
|
-- @param Core.Set#SET_GROUP Set
|
||||||
|
-- @return #TIRESIAS self
|
||||||
|
function TIRESIAS:AddExceptionSet(Set)
|
||||||
|
self:T(self.lid.."AddExceptionSet")
|
||||||
|
self.ExceptionSet = Set
|
||||||
|
|
||||||
|
Set:ForEachGroupAlive(
|
||||||
|
function(grp)
|
||||||
|
if not grp.Tiresias then
|
||||||
|
grp.Tiresias = { -- #TIRESIAS.Data
|
||||||
|
type = "Exception",
|
||||||
|
exception = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
BASE:I("TIRESIAS: Added exception group: "..grp:GetName())
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #TIRESIAS self
|
-- @param #TIRESIAS self
|
||||||
-- @param Wrapper.Group#GROUP Group
|
-- @param Wrapper.Group#GROUP Group
|
||||||
@ -139,25 +161,43 @@ end
|
|||||||
-- @param #TIRESIAS self
|
-- @param #TIRESIAS self
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:_InitGroups()
|
function TIRESIAS:_InitGroups()
|
||||||
self:I(self.lid.."_InitGroups")
|
self:T(self.lid.."_InitGroups")
|
||||||
-- Set all groups invisible/motionless
|
-- Set all groups invisible/motionless
|
||||||
local EngageRange = self.AAARange
|
local EngageRange = self.AAARange
|
||||||
|
local SwitchAAA = self.SwitchAAA
|
||||||
|
--- AAA
|
||||||
self.AAASet:ForEachGroupAlive(
|
self.AAASet:ForEachGroupAlive(
|
||||||
function(grp)
|
function(grp)
|
||||||
if not grp.Tiresias then
|
if not grp.Tiresias then
|
||||||
grp:OptionEngageRange(EngageRange)
|
grp:OptionEngageRange(EngageRange)
|
||||||
grp:SetCommandInvisible(true)
|
grp:SetCommandInvisible(true)
|
||||||
|
if SwitchAAA then
|
||||||
|
grp:SetAIOff()
|
||||||
|
grp:EnableEmission(false)
|
||||||
|
end
|
||||||
grp.Tiresias = { -- #TIRESIAS.Data
|
grp.Tiresias = { -- #TIRESIAS.Data
|
||||||
type = "AAA",
|
type = "AAA",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
range = EngageRange,
|
range = EngageRange,
|
||||||
|
exception = false,
|
||||||
|
AIOff = SwitchAAA,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||||
grp:SetCommandInvisible(true)
|
if grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||||
|
grp:SetCommandInvisible(true)
|
||||||
|
grp.Tiresias.invisible = true
|
||||||
|
if SwitchAAA then
|
||||||
|
grp:SetAIOff()
|
||||||
|
grp:EnableEmission(false)
|
||||||
|
grp.Tiresias.AIOff = true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
--BASE:I(string.format("Init/Switch off AAA %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
--- Vehicles
|
||||||
self.VehicleSet:ForEachGroupAlive(
|
self.VehicleSet:ForEachGroupAlive(
|
||||||
function(grp)
|
function(grp)
|
||||||
if not grp.Tiresias then
|
if not grp.Tiresias then
|
||||||
@ -167,14 +207,20 @@ function TIRESIAS:_InitGroups()
|
|||||||
type = "Vehicle",
|
type = "Vehicle",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
AIOff = true,
|
AIOff = true,
|
||||||
|
exception = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||||
grp:SetCommandInvisible(true)
|
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||||
grp:SetAIOff()
|
grp:SetCommandInvisible(true)
|
||||||
end
|
grp:SetAIOff()
|
||||||
|
grp.Tiresias.invisible = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--BASE:I(string.format("Init/Switch off Vehicle %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
--- SAM
|
||||||
self.SAMSet:ForEachGroupAlive(
|
self.SAMSet:ForEachGroupAlive(
|
||||||
function(grp)
|
function(grp)
|
||||||
if not grp.Tiresias then
|
if not grp.Tiresias then
|
||||||
@ -182,11 +228,16 @@ function TIRESIAS:_InitGroups()
|
|||||||
grp.Tiresias = { -- #TIRESIAS.Data
|
grp.Tiresias = { -- #TIRESIAS.Data
|
||||||
type = "SAM",
|
type = "SAM",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
|
exception = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
if grp.Tiresias and (not grp.Tiresias.exception == true) then
|
||||||
grp:SetCommandInvisible(true)
|
if grp.Tiresias and grp.Tiresias.invisible and grp.Tiresias.invisible == false then
|
||||||
|
grp:SetCommandInvisible(true)
|
||||||
|
grp.Tiresias.invisible = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
--BASE:I(string.format("Init/Switch off SAM %s (Exception %s)",grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
@ -197,7 +248,7 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:_EventHandler(EventData)
|
function TIRESIAS:_EventHandler(EventData)
|
||||||
self:I(string.format("%s Event = %d",self.lid, EventData.id))
|
self:T(string.format("%s Event = %d",self.lid, EventData.id))
|
||||||
local event = EventData -- Core.Event#EVENTDATA
|
local event = EventData -- Core.Event#EVENTDATA
|
||||||
if event.id == EVENTS.PlayerEnterAircraft or event.id == EVENTS.PlayerEnterUnit then
|
if event.id == EVENTS.PlayerEnterAircraft or event.id == EVENTS.PlayerEnterUnit then
|
||||||
local _coalition = event.IniCoalition
|
local _coalition = event.IniCoalition
|
||||||
@ -224,7 +275,7 @@ end
|
|||||||
-- @param #number radius Radius in NM
|
-- @param #number radius Radius in NM
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:_SwitchOnGroups(group,radius)
|
function TIRESIAS:_SwitchOnGroups(group,radius)
|
||||||
self:I(self.lid.."_SwitchOnGroups "..group:GetName().." Radius "..radius.." NM")
|
self:T(self.lid.."_SwitchOnGroups "..group:GetName().." Radius "..radius.." NM")
|
||||||
local zone = ZONE_GROUP:New("Zone-"..group:GetName(),group,UTILS.NMToMeters(radius))
|
local zone = ZONE_GROUP:New("Zone-"..group:GetName(),group,UTILS.NMToMeters(radius))
|
||||||
local ground = SET_GROUP:New():FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
local ground = SET_GROUP:New():FilterCategoryGround():FilterZones({zone}):FilterOnce()
|
||||||
local count = ground:CountAlive()
|
local count = ground:CountAlive()
|
||||||
@ -232,20 +283,27 @@ function TIRESIAS:_SwitchOnGroups(group,radius)
|
|||||||
local text = string.format("There are %d groups around this plane or helo!",count)
|
local text = string.format("There are %d groups around this plane or helo!",count)
|
||||||
self:I(text)
|
self:I(text)
|
||||||
end
|
end
|
||||||
|
local SwitchAAA = self.SwitchAAA
|
||||||
if ground:CountAlive() > 0 then
|
if ground:CountAlive() > 0 then
|
||||||
ground:ForEachGroupAlive(
|
ground:ForEachGroupAlive(
|
||||||
function(grp)
|
function(grp)
|
||||||
if grp.Tiresias and grp.Tiresias.type then
|
if grp.Tiresias and grp.Tiresias.type and (not grp.Tiresias.exception == true ) then
|
||||||
if grp.Tiresias.invisible == true then
|
if grp.Tiresias.invisible == true then
|
||||||
grp:SetCommandInvisible(false)
|
grp:SetCommandInvisible(false)
|
||||||
grp.Tiresias.invisible = false
|
grp.Tiresias.invisible = false
|
||||||
end
|
end
|
||||||
if grp.Tiresias.type == "Vehicle" and grp.Tiresias.AIOff and grp.Tiresias.AIOff == false then
|
if grp.Tiresias.type == "Vehicle" and grp.Tiresias.AIOff and grp.Tiresias.AIOff == true then
|
||||||
grp:SetAIOn()
|
grp:SetAIOn()
|
||||||
grp.Tiresias.AIOff = false
|
grp.Tiresias.AIOff = false
|
||||||
end
|
end
|
||||||
|
if SwitchAAA and grp.Tiresias.type == "AAA" and grp.Tiresias.AIOff and grp.Tiresias.AIOff == true then
|
||||||
|
grp:SetAIOn()
|
||||||
|
grp:EnableEmission(true)
|
||||||
|
grp.Tiresias.AIOff = false
|
||||||
|
end
|
||||||
|
--BASE:I(string.format("TIRESIAS - Switch on %s %s (Exception %s)",tostring(grp.Tiresias.type),grp:GetName(),tostring(grp.Tiresias.exception)))
|
||||||
else
|
else
|
||||||
BASE:I("TIRESIAS - This group has not been initialized!")
|
BASE:E("TIRESIAS - This group has not been initialized or is an exception!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -266,7 +324,7 @@ end
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:onafterStart(From, Event, To)
|
function TIRESIAS:onafterStart(From, Event, To)
|
||||||
self:I({From, Event, To})
|
self:T({From, Event, To})
|
||||||
|
|
||||||
local VehicleSet = SET_GROUP:New():FilterCategoryGround():FilterFunction(TIRESIAS._FilterAAA):FilterFunction(TIRESIAS._FilterSAM):FilterStart()
|
local VehicleSet = SET_GROUP:New():FilterCategoryGround():FilterFunction(TIRESIAS._FilterAAA):FilterFunction(TIRESIAS._FilterSAM):FilterStart()
|
||||||
local AAASet = SET_GROUP:New():FilterCategoryGround():FilterFunction(function(grp) return grp:IsAAA() end):FilterStart()
|
local AAASet = SET_GROUP:New():FilterCategoryGround():FilterFunction(function(grp) return grp:IsAAA() end):FilterStart()
|
||||||
@ -275,6 +333,22 @@ function TIRESIAS:onafterStart(From, Event, To)
|
|||||||
|
|
||||||
local EngageRange = self.AAARange
|
local EngageRange = self.AAARange
|
||||||
|
|
||||||
|
if self.ExceptionSet then
|
||||||
|
local ExceptionSet = self.ExceptionSet
|
||||||
|
function ExceptionSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||||
|
BASE:I("TIRESIAS: EXCEPTION Object Added: "..Object:GetName())
|
||||||
|
if Object and Object:IsAlive() then
|
||||||
|
Object.Tiresias = { -- #TIRESIAS.Data
|
||||||
|
type = "Exception",
|
||||||
|
exception = true,
|
||||||
|
}
|
||||||
|
Object:SetAIOn()
|
||||||
|
Object:SetCommandInvisible(false)
|
||||||
|
Object:EnableEmission(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function VehicleSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
function VehicleSet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||||
BASE:I("TIRESIAS: VEHCILE Object Added: "..Object:GetName())
|
BASE:I("TIRESIAS: VEHCILE Object Added: "..Object:GetName())
|
||||||
if Object and Object:IsAlive() then
|
if Object and Object:IsAlive() then
|
||||||
@ -284,20 +358,29 @@ function TIRESIAS:onafterStart(From, Event, To)
|
|||||||
type = "Vehicle",
|
type = "Vehicle",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
AIOff = true,
|
AIOff = true,
|
||||||
|
exception = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local SwitchAAA = self.SwitchAAA
|
||||||
|
|
||||||
function AAASet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
function AAASet:OnAfterAdded(From,Event,To,ObjectName,Object)
|
||||||
if Object and Object:IsAlive() then
|
if Object and Object:IsAlive() then
|
||||||
BASE:I("TIRESIAS: AAA Object Added: "..Object:GetName())
|
BASE:I("TIRESIAS: AAA Object Added: "..Object:GetName())
|
||||||
Object:OptionEngageRange(EngageRange)
|
Object:OptionEngageRange(EngageRange)
|
||||||
Object:SetCommandInvisible(true)
|
Object:SetCommandInvisible(true)
|
||||||
|
if SwitchAAA then
|
||||||
|
Object:SetAIOff()
|
||||||
|
Object:EnableEmission(false)
|
||||||
|
end
|
||||||
Object.Tiresias = { -- #TIRESIAS.Data
|
Object.Tiresias = { -- #TIRESIAS.Data
|
||||||
type = "AAA",
|
type = "AAA",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
range = EngageRange,
|
range = EngageRange,
|
||||||
}
|
exception = false,
|
||||||
|
AIOff = SwitchAAA,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -308,6 +391,7 @@ function TIRESIAS:onafterStart(From, Event, To)
|
|||||||
Object.Tiresias = { -- #TIRESIAS.Data
|
Object.Tiresias = { -- #TIRESIAS.Data
|
||||||
type = "SAM",
|
type = "SAM",
|
||||||
invisible = true,
|
invisible = true,
|
||||||
|
exception = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -343,7 +427,7 @@ end
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:onafterStatus(From, Event, To)
|
function TIRESIAS:onafterStatus(From, Event, To)
|
||||||
self:I({From, Event, To})
|
self:T({From, Event, To})
|
||||||
if self.debug then
|
if self.debug then
|
||||||
local count = self.VehicleSet:CountAlive()
|
local count = self.VehicleSet:CountAlive()
|
||||||
local AAAcount = self.AAASet:CountAlive()
|
local AAAcount = self.AAASet:CountAlive()
|
||||||
@ -376,7 +460,7 @@ end
|
|||||||
-- @param #string To
|
-- @param #string To
|
||||||
-- @return #TIRESIAS self
|
-- @return #TIRESIAS self
|
||||||
function TIRESIAS:onafterStop(From, Event, To)
|
function TIRESIAS:onafterStop(From, Event, To)
|
||||||
self:I({From, Event, To})
|
self:T({From, Event, To})
|
||||||
self:UnHandleEvent(EVENTS.PlayerEnterAircraft)
|
self:UnHandleEvent(EVENTS.PlayerEnterAircraft)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2999,19 +2999,19 @@ function GROUP:IsSAM()
|
|||||||
return issam
|
return issam
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [GROUND] Determine if a GROUP is a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
--- [GROUND] Determine if a GROUP has a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #boolean IsSAM True if AAA, else false
|
-- @return #boolean IsSAM True if AAA, else false
|
||||||
function GROUP:IsAAA()
|
function GROUP:IsAAA()
|
||||||
local issam = true
|
local issam = false
|
||||||
local units = self:GetUnits()
|
local units = self:GetUnits()
|
||||||
for _,_unit in pairs(units or {}) do
|
for _,_unit in pairs(units or {}) do
|
||||||
local unit = _unit -- Wrapper.Unit#UNIT
|
local unit = _unit -- Wrapper.Unit#UNIT
|
||||||
if unit:HasSEAD() or (not unit:IsGround()) then
|
local desc = unit:GetDesc() or {}
|
||||||
issam = false
|
local attr = desc.attributes or {}
|
||||||
if unit:HasAttribute("Mobile AAA") then
|
if unit:HasSEAD() then return false end
|
||||||
issam = true
|
if attr["AAA"] or attr["SAM related"] then
|
||||||
end
|
issam = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return issam
|
return issam
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user