diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 97f0fb280..ca1529950 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -561,7 +561,8 @@ do -- COORDINATE return self else --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 @@ -761,7 +762,8 @@ do -- COORDINATE -- Move the vector to start at the end of A. 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 --- Return the 2D distance in meters between the target COORDINATE and the COORDINATE. diff --git a/Moose Development/Moose/Core/Timer.lua b/Moose Development/Moose/Core/Timer.lua index 72fe2c19d..9b8a9200b 100644 --- a/Moose Development/Moose/Core/Timer.lua +++ b/Moose Development/Moose/Core/Timer.lua @@ -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. -- +-- It provides an easy interface to the DCS [timer.scheduleFunction](https://wiki.hoggitworld.com/view/DCS_func_scheduleFunction). +-- -- # Construction -- -- A new TIMER is created by the @{#TIMER.New}(*func*, *...*) function @@ -104,7 +106,7 @@ TIMER = { _TIMERID=0 --- Timer data base. -_TIMERDB={} +--_TIMERDB={} --- TIMER class version. -- @field #string version @@ -150,7 +152,7 @@ function TIMER:New(Function, ...) self.lid=string.format("TIMER UID=%d | ", self.uid) -- Add to DB. - _TIMERDB[self.uid]=self + --_TIMERDB[self.uid]=self return self end @@ -208,7 +210,7 @@ function TIMER:Stop(Delay) timer.removeFunction(self.tid) -- Remove DB entry. - _TIMERDB[self.uid]=nil + --_TIMERDB[self.uid]=nil end @@ -232,8 +234,6 @@ end -- @return #number Time when the function is called again or `nil` if the timer is stopped. function TIMER:_Function(time) - --self:I(self.lid.."FF calling timer _Function") - -- Call function. self.func(unpack(self.para)) diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 448667244..ca7afde95 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -227,7 +227,7 @@ function FLIGHTGROUP:New(group) self.lid=string.format("FLIGHTGROUP %s | ", self.groupname) -- Defaults - self:SetVerbosity(0) + --self:SetVerbosity(0) self:SetFuelLowThreshold() self:SetFuelLowRTB() self:SetFuelCriticalThreshold() @@ -410,6 +410,25 @@ function FLIGHTGROUP:GetFlightControl() 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. -- @param #FLIGHTGROUP self -- @param Ops.Airboss#AIRBOSS airboss The AIRBOSS object. @@ -1386,7 +1405,7 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To) if self.option.ROT then self:SwitchROT(self.option.ROT) else - self:SwitchROE(ENUMS.ROT.PassiveDefense) + self:SwitchROT(ENUMS.ROT.PassiveDefense) end -- Turn TACAN beacon on. @@ -1529,6 +1548,7 @@ function FLIGHTGROUP:onafterLanding(From, Event, To) end + --- On after "Landed" event. -- @param #FLIGHTGROUP self -- @param #string From From state. @@ -1538,16 +1558,24 @@ end function FLIGHTGROUP:onafterLanded(From, Event, To, airbase) self:T(self.lid..string.format("Flight landed at %s", airbase and airbase:GetName() or "unknown place")) - if self:IsLandingAt() then - self:LandedAt() - else - 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 + 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 +--- 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. -- @param #FLIGHTGROUP self -- @param #string From From state. @@ -2519,6 +2547,8 @@ function FLIGHTGROUP:_InitGroup() self.radio.Freq=self.template.frequency self.radio.Modu=self.template.modulation + self.radioDefault=UTILS.DeepCopy(self.radio) + --TODO callsign from template or getCallsign self.callsign.NumberSquad=self.template.units[1].callsign[1] self.callsign.NumberGroup=self.template.units[1].callsign[2] diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index 98bf57796..1e2102f51 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -95,7 +95,7 @@ OPSGROUP = { ClassName = "OPSGROUP", Debug = false, - verbose = 0, + verbose = 3, lid = nil, groupname = nil, group = nil, @@ -2443,7 +2443,7 @@ function OPSGROUP:_CheckInZones() for inzonename, inzone in pairs(self.inzones:GetSet()) do -- 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 isstillinzone then @@ -2463,7 +2463,7 @@ function OPSGROUP:_CheckInZones() local checkzone=_checkzone --Core.Zone#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 table.insert(enterzones, checkzone) @@ -3009,7 +3009,7 @@ function OPSGROUP:SwitchROE(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 @@ -3475,7 +3475,7 @@ function OPSGROUP:SwitchFormation(Formation) self.option.Formation=Formation -- 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 @@ -3771,7 +3771,11 @@ function OPSGROUP:_UpdateStatus(element, newstatus, airbase) --- if self:_AllSimilarStatus(newstatus) then - self:Landed(airbase) + if self:IsLandingAt() then + self:LandedAt() + else + self:Landed(airbase) + end end elseif newstatus==OPSGROUP.ElementStatus.ARRIVED then diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 7ceb235af..34172a162 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -951,7 +951,8 @@ function GROUP:GetVec2() local Unit=self:GetUnit(1) if Unit then - return Unit:GetVec2() + local vec2=Unit:GetVec2() + return vec2 end end @@ -965,7 +966,8 @@ function GROUP:GetVec3() local unit=self:GetUnit(1) if unit then - return unit:GetVec3() + local vec3=unit:GetVec3() + return vec3 end self:E("ERROR: Cannot get Vec3 of group "..tostring(self.GroupName)) @@ -996,13 +998,11 @@ end -- @param Wrapper.Group#GROUP self -- @return Core.Point#COORDINATE The COORDINATE of the GROUP. function GROUP:GetCoordinate() - self:F2( self.PositionableName ) local FirstUnit = self:GetUnit(1) if FirstUnit then local FirstUnitCoordinate = FirstUnit:GetCoordinate() - self:T3(FirstUnitCoordinate) return FirstUnitCoordinate end @@ -1176,7 +1176,7 @@ do -- Is Zone methods --- Check if any unit of a group is inside a @{Zone}. -- @param #GROUP self -- @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 ) if self:IsAlive() then @@ -1184,7 +1184,10 @@ function GROUP:IsInZone( Zone ) for UnitID, UnitData in pairs(self:GetUnits()) do 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. else -- This one is not but another could be.