mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Ops
This commit is contained in:
parent
5ee35f3fbb
commit
eb86d59203
@ -561,7 +561,8 @@ do -- COORDINATE
|
|||||||
return self
|
return self
|
||||||
else
|
else
|
||||||
--env.info("FF translate with NEW coordinate T="..timer.getTime())
|
--env.info("FF translate with NEW coordinate T="..timer.getTime())
|
||||||
return COORDINATE:New(x, y, z)
|
local coord=COORDINATE:New(x, y, z)
|
||||||
|
return coord
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -761,7 +762,8 @@ do -- COORDINATE
|
|||||||
-- Move the vector to start at the end of A.
|
-- Move the vector to start at the end of A.
|
||||||
vec=UTILS.VecAdd(self, vec)
|
vec=UTILS.VecAdd(self, vec)
|
||||||
|
|
||||||
return self:New(vec.x,vec.y,vec.z)
|
local coord=COORDINATE:New(vec.x,vec.y,vec.z)
|
||||||
|
return coord
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return the 2D distance in meters between the target COORDINATE and the COORDINATE.
|
--- Return the 2D distance in meters between the target COORDINATE and the COORDINATE.
|
||||||
|
|||||||
@ -38,6 +38,8 @@
|
|||||||
--
|
--
|
||||||
-- The TIMER class is the little sister of the SCHEDULER class. It does the same thing but is a bit easier to use and has less overhead. It should be sufficient in many cases.
|
-- The TIMER class is the little sister of the SCHEDULER class. It does the same thing but is a bit easier to use and has less overhead. It should be sufficient in many cases.
|
||||||
--
|
--
|
||||||
|
-- It provides an easy interface to the DCS [timer.scheduleFunction](https://wiki.hoggitworld.com/view/DCS_func_scheduleFunction).
|
||||||
|
--
|
||||||
-- # Construction
|
-- # Construction
|
||||||
--
|
--
|
||||||
-- A new TIMER is created by the @{#TIMER.New}(*func*, *...*) function
|
-- A new TIMER is created by the @{#TIMER.New}(*func*, *...*) function
|
||||||
@ -104,7 +106,7 @@ TIMER = {
|
|||||||
_TIMERID=0
|
_TIMERID=0
|
||||||
|
|
||||||
--- Timer data base.
|
--- Timer data base.
|
||||||
_TIMERDB={}
|
--_TIMERDB={}
|
||||||
|
|
||||||
--- TIMER class version.
|
--- TIMER class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
@ -150,7 +152,7 @@ function TIMER:New(Function, ...)
|
|||||||
self.lid=string.format("TIMER UID=%d | ", self.uid)
|
self.lid=string.format("TIMER UID=%d | ", self.uid)
|
||||||
|
|
||||||
-- Add to DB.
|
-- Add to DB.
|
||||||
_TIMERDB[self.uid]=self
|
--_TIMERDB[self.uid]=self
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -208,7 +210,7 @@ function TIMER:Stop(Delay)
|
|||||||
timer.removeFunction(self.tid)
|
timer.removeFunction(self.tid)
|
||||||
|
|
||||||
-- Remove DB entry.
|
-- Remove DB entry.
|
||||||
_TIMERDB[self.uid]=nil
|
--_TIMERDB[self.uid]=nil
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -232,8 +234,6 @@ end
|
|||||||
-- @return #number Time when the function is called again or `nil` if the timer is stopped.
|
-- @return #number Time when the function is called again or `nil` if the timer is stopped.
|
||||||
function TIMER:_Function(time)
|
function TIMER:_Function(time)
|
||||||
|
|
||||||
--self:I(self.lid.."FF calling timer _Function")
|
|
||||||
|
|
||||||
-- Call function.
|
-- Call function.
|
||||||
self.func(unpack(self.para))
|
self.func(unpack(self.para))
|
||||||
|
|
||||||
|
|||||||
@ -227,7 +227,7 @@ function FLIGHTGROUP:New(group)
|
|||||||
self.lid=string.format("FLIGHTGROUP %s | ", self.groupname)
|
self.lid=string.format("FLIGHTGROUP %s | ", self.groupname)
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
self:SetVerbosity(0)
|
--self:SetVerbosity(0)
|
||||||
self:SetFuelLowThreshold()
|
self:SetFuelLowThreshold()
|
||||||
self:SetFuelLowRTB()
|
self:SetFuelLowRTB()
|
||||||
self:SetFuelCriticalThreshold()
|
self:SetFuelCriticalThreshold()
|
||||||
@ -410,6 +410,25 @@ function FLIGHTGROUP:GetFlightControl()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set the homebase.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE HomeAirbase The home airbase.
|
||||||
|
-- @return #FLIGHTGROUP self
|
||||||
|
function FLIGHTGROUP:SetHomebase(HomeAirbase)
|
||||||
|
self.homebase=HomeAirbase
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the destination airbase. This is where the flight will go, when the final waypoint is reached.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE DestinationAirbase The destination airbase.
|
||||||
|
-- @return #FLIGHTGROUP self
|
||||||
|
function FLIGHTGROUP:SetDestinationbase(DestinationAirbase)
|
||||||
|
self.destbase=DestinationAirbase
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the AIRBOSS controlling this flight group.
|
--- Set the AIRBOSS controlling this flight group.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param Ops.Airboss#AIRBOSS airboss The AIRBOSS object.
|
-- @param Ops.Airboss#AIRBOSS airboss The AIRBOSS object.
|
||||||
@ -1386,7 +1405,7 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
if self.option.ROT then
|
if self.option.ROT then
|
||||||
self:SwitchROT(self.option.ROT)
|
self:SwitchROT(self.option.ROT)
|
||||||
else
|
else
|
||||||
self:SwitchROE(ENUMS.ROT.PassiveDefense)
|
self:SwitchROT(ENUMS.ROT.PassiveDefense)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Turn TACAN beacon on.
|
-- Turn TACAN beacon on.
|
||||||
@ -1529,6 +1548,7 @@ function FLIGHTGROUP:onafterLanding(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- On after "Landed" event.
|
--- On after "Landed" event.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@ -1538,16 +1558,24 @@ end
|
|||||||
function FLIGHTGROUP:onafterLanded(From, Event, To, airbase)
|
function FLIGHTGROUP:onafterLanded(From, Event, To, airbase)
|
||||||
self:T(self.lid..string.format("Flight landed at %s", airbase and airbase:GetName() or "unknown place"))
|
self:T(self.lid..string.format("Flight landed at %s", airbase and airbase:GetName() or "unknown place"))
|
||||||
|
|
||||||
if self:IsLandingAt() then
|
if self.flightcontrol and airbase and self.flightcontrol.airbasename==airbase:GetName() then
|
||||||
self:LandedAt()
|
-- Add flight to taxiinb queue.
|
||||||
else
|
self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.TAXIINB)
|
||||||
if self.flightcontrol and airbase and self.flightcontrol.airbasename==airbase:GetName() then
|
|
||||||
-- Add flight to taxiinb queue.
|
|
||||||
self.flightcontrol:SetFlightStatus(self, FLIGHTCONTROL.FlightStatus.TAXIINB)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- On after "LandedAt" event.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE airbase The airbase the flight landed.
|
||||||
|
function FLIGHTGROUP:onafterLandedAt(From, Event, To)
|
||||||
|
self:I(self.lid..string.format("Flight landed at"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- On after "Arrived" event.
|
--- On after "Arrived" event.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@ -2519,6 +2547,8 @@ function FLIGHTGROUP:_InitGroup()
|
|||||||
self.radio.Freq=self.template.frequency
|
self.radio.Freq=self.template.frequency
|
||||||
self.radio.Modu=self.template.modulation
|
self.radio.Modu=self.template.modulation
|
||||||
|
|
||||||
|
self.radioDefault=UTILS.DeepCopy(self.radio)
|
||||||
|
|
||||||
--TODO callsign from template or getCallsign
|
--TODO callsign from template or getCallsign
|
||||||
self.callsign.NumberSquad=self.template.units[1].callsign[1]
|
self.callsign.NumberSquad=self.template.units[1].callsign[1]
|
||||||
self.callsign.NumberGroup=self.template.units[1].callsign[2]
|
self.callsign.NumberGroup=self.template.units[1].callsign[2]
|
||||||
|
|||||||
@ -95,7 +95,7 @@
|
|||||||
OPSGROUP = {
|
OPSGROUP = {
|
||||||
ClassName = "OPSGROUP",
|
ClassName = "OPSGROUP",
|
||||||
Debug = false,
|
Debug = false,
|
||||||
verbose = 0,
|
verbose = 3,
|
||||||
lid = nil,
|
lid = nil,
|
||||||
groupname = nil,
|
groupname = nil,
|
||||||
group = nil,
|
group = nil,
|
||||||
@ -2443,7 +2443,7 @@ function OPSGROUP:_CheckInZones()
|
|||||||
for inzonename, inzone in pairs(self.inzones:GetSet()) do
|
for inzonename, inzone in pairs(self.inzones:GetSet()) do
|
||||||
|
|
||||||
-- Check if group is still inside the zone.
|
-- Check if group is still inside the zone.
|
||||||
local isstillinzone=self.group:IsPartlyOrCompletelyInZone(inzone)
|
local isstillinzone=self.group:IsInZone(inzone) --:IsPartlyOrCompletelyInZone(inzone)
|
||||||
|
|
||||||
-- If not, trigger, LeaveZone event.
|
-- If not, trigger, LeaveZone event.
|
||||||
if not isstillinzone then
|
if not isstillinzone then
|
||||||
@ -2463,7 +2463,7 @@ function OPSGROUP:_CheckInZones()
|
|||||||
local checkzone=_checkzone --Core.Zone#ZONE
|
local checkzone=_checkzone --Core.Zone#ZONE
|
||||||
|
|
||||||
-- Is group currtently in this check zone?
|
-- Is group currtently in this check zone?
|
||||||
local isincheckzone=self.group:IsPartlyOrCompletelyInZone(checkzone)
|
local isincheckzone=self.group:IsInZone(checkzone) --:IsPartlyOrCompletelyInZone(checkzone)
|
||||||
|
|
||||||
if isincheckzone and not self.inzones:_Find(checkzonename) then
|
if isincheckzone and not self.inzones:_Find(checkzonename) then
|
||||||
table.insert(enterzones, checkzone)
|
table.insert(enterzones, checkzone)
|
||||||
@ -3009,7 +3009,7 @@ function OPSGROUP:SwitchROE(roe)
|
|||||||
|
|
||||||
self.group:OptionROE(roe)
|
self.group:OptionROE(roe)
|
||||||
|
|
||||||
self:T(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.option.ROE))
|
self:I(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.option.ROE))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -3475,7 +3475,7 @@ function OPSGROUP:SwitchFormation(Formation)
|
|||||||
self.option.Formation=Formation
|
self.option.Formation=Formation
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Switching formation to %d", self.formation))
|
self:I(self.lid..string.format("Switching formation to %d", self.option.Formation))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3771,7 +3771,11 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if self:_AllSimilarStatus(newstatus) then
|
if self:_AllSimilarStatus(newstatus) then
|
||||||
self:Landed(airbase)
|
if self:IsLandingAt() then
|
||||||
|
self:LandedAt()
|
||||||
|
else
|
||||||
|
self:Landed(airbase)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then
|
elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then
|
||||||
|
|||||||
@ -951,7 +951,8 @@ function GROUP:GetVec2()
|
|||||||
local Unit=self:GetUnit(1)
|
local Unit=self:GetUnit(1)
|
||||||
|
|
||||||
if Unit then
|
if Unit then
|
||||||
return Unit:GetVec2()
|
local vec2=Unit:GetVec2()
|
||||||
|
return vec2
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -965,7 +966,8 @@ function GROUP:GetVec3()
|
|||||||
local unit=self:GetUnit(1)
|
local unit=self:GetUnit(1)
|
||||||
|
|
||||||
if unit then
|
if unit then
|
||||||
return unit:GetVec3()
|
local vec3=unit:GetVec3()
|
||||||
|
return vec3
|
||||||
end
|
end
|
||||||
|
|
||||||
self:E("ERROR: Cannot get Vec3 of group "..tostring(self.GroupName))
|
self:E("ERROR: Cannot get Vec3 of group "..tostring(self.GroupName))
|
||||||
@ -996,13 +998,11 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP self
|
-- @param Wrapper.Group#GROUP self
|
||||||
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
|
-- @return Core.Point#COORDINATE The COORDINATE of the GROUP.
|
||||||
function GROUP:GetCoordinate()
|
function GROUP:GetCoordinate()
|
||||||
self:F2( self.PositionableName )
|
|
||||||
|
|
||||||
local FirstUnit = self:GetUnit(1)
|
local FirstUnit = self:GetUnit(1)
|
||||||
|
|
||||||
if FirstUnit then
|
if FirstUnit then
|
||||||
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
local FirstUnitCoordinate = FirstUnit:GetCoordinate()
|
||||||
self:T3(FirstUnitCoordinate)
|
|
||||||
return FirstUnitCoordinate
|
return FirstUnitCoordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1176,7 +1176,7 @@ do -- Is Zone methods
|
|||||||
--- Check if any unit of a group is inside a @{Zone}.
|
--- Check if any unit of a group is inside a @{Zone}.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
|
-- @param Core.Zone#ZONE_BASE Zone The zone to test.
|
||||||
-- @return #boolean Returns true if at least one unit is inside the zone or false if no unit is inside.
|
-- @return #boolean Returns `true` if *at least one unit* is inside the zone or `false` if *no* unit is inside.
|
||||||
function GROUP:IsInZone( Zone )
|
function GROUP:IsInZone( Zone )
|
||||||
|
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
@ -1184,7 +1184,10 @@ function GROUP:IsInZone( Zone )
|
|||||||
for UnitID, UnitData in pairs(self:GetUnits()) do
|
for UnitID, UnitData in pairs(self:GetUnits()) do
|
||||||
local Unit = UnitData -- Wrapper.Unit#UNIT
|
local Unit = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
|
||||||
if Zone:IsVec3InZone(Unit:GetVec3()) then
|
-- Get 2D vector. That's all we need for the zone check.
|
||||||
|
local vec2=Unit:GetVec2()
|
||||||
|
|
||||||
|
if Zone:IsVec2InZone(vec2) then
|
||||||
return true -- At least one unit is in the zone. That is enough.
|
return true -- At least one unit is in the zone. That is enough.
|
||||||
else
|
else
|
||||||
-- This one is not but another could be.
|
-- This one is not but another could be.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user