From fe55555c67552c9c73cd1f1c48162cce61bf53de Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 30 Jan 2021 23:28:07 +0100 Subject: [PATCH] OPS - Fixed inAir check for spawned groups - Reduced SCHEDULER min delay to 0.001 sec (was 0.1 sec) --- Moose Development/Moose/AI/AI_Formation.lua | 4 ++-- Moose Development/Moose/Core/ScheduleDispatcher.lua | 2 +- Moose Development/Moose/Ops/FlightGroup.lua | 7 ++++--- Moose Development/Moose/Ops/OpsGroup.lua | 2 +- Moose Development/Moose/Wrapper/Unit.lua | 7 ++++--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Formation.lua b/Moose Development/Moose/AI/AI_Formation.lua index 17c1b5345..aaf4fbe54 100644 --- a/Moose Development/Moose/AI/AI_Formation.lua +++ b/Moose Development/Moose/AI/AI_Formation.lua @@ -1140,8 +1140,8 @@ end -- @param DCS#Vec3 CV2 Vec3 function AI_FORMATION:FollowMe(FollowGroup, ClientUnit, CT1, CV1, CT2, CV2) - if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then - + if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation and not self:Is("Stopped") then + self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )}) FollowGroup:OptionROTEvadeFire() diff --git a/Moose Development/Moose/Core/ScheduleDispatcher.lua b/Moose Development/Moose/Core/ScheduleDispatcher.lua index bfd1dabb4..db04a1500 100644 --- a/Moose Development/Moose/Core/ScheduleDispatcher.lua +++ b/Moose Development/Moose/Core/ScheduleDispatcher.lua @@ -122,7 +122,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr self.Schedule[Scheduler][CallID].Function = ScheduleFunction self.Schedule[Scheduler][CallID].Arguments = ScheduleArguments self.Schedule[Scheduler][CallID].StartTime = timer.getTime() + ( Start or 0 ) - self.Schedule[Scheduler][CallID].Start = Start + 0.1 + self.Schedule[Scheduler][CallID].Start = Start + 0.001 self.Schedule[Scheduler][CallID].Repeat = Repeat or 0 self.Schedule[Scheduler][CallID].Randomize = Randomize or 0 self.Schedule[Scheduler][CallID].Stop = Stop diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index ce641b949..ad0f1a6ce 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -1169,7 +1169,8 @@ function FLIGHTGROUP:OnEventBirth(EventData) -- Set element to spawned state. self:T(self.lid..string.format("EVENT: Element %s born at airbase %s==> spawned", element.name, self.homebase and self.homebase:GetName() or "unknown")) - self:ElementSpawned(element) + -- This is delayed by a millisec because inAir check for units spawned in air failed (returned false even though the unit was spawned in air). + self:__ElementSpawned(0.0, element) end @@ -1436,7 +1437,7 @@ function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element) -- Set element status. self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED) - if Element.unit:InAir() then + if Element.unit:InAir(true) then -- Trigger ElementAirborne event. Add a little delay because spawn is also delayed! self:__ElementAirborne(0.11, Element) else @@ -2008,7 +2009,7 @@ function FLIGHTGROUP:onafterUpdateRoute(From, Event, To, n) if #wp>1 then -- Route group to all defined waypoints remaining. - self:Route(wp, 1) + self:Route(wp) else diff --git a/Moose Development/Moose/Ops/OpsGroup.lua b/Moose Development/Moose/Ops/OpsGroup.lua index c202ab0ff..b8f52b52e 100644 --- a/Moose Development/Moose/Ops/OpsGroup.lua +++ b/Moose Development/Moose/Ops/OpsGroup.lua @@ -2223,7 +2223,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task) local TaskFinal=self.group:TaskCombo({TaskControlled, TaskDone}) -- Set task for group. - self:SetTask(TaskFinal, 1) + self:SetTask(TaskFinal) end diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 705e29303..beb43fc4c 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -1174,8 +1174,9 @@ end --- Returns true if the UNIT is in the air. -- @param #UNIT self +-- @param #boolean NoHeloCheck If true, no additonal checks for helos are performed. -- @return #boolean Return true if in the air or #nil if the UNIT is not existing or alive. -function UNIT:InAir() +function UNIT:InAir(NoHeloCheck) self:F2( self.UnitName ) -- Get DCS unit object. @@ -1185,14 +1186,14 @@ function UNIT:InAir() -- Get DCS result of whether unit is in air or not. local UnitInAir = DCSUnit:inAir() - + -- Get unit category. local UnitCategory = DCSUnit:getDesc().category -- If DCS says that it is in air, check if this is really the case, since we might have landed on a building where inAir()=true but actually is not. -- This is a workaround since DCS currently does not acknoledge that helos land on buildings. -- Note however, that the velocity check will fail if the ground is moving, e.g. on an aircraft carrier! - if UnitInAir==true and UnitCategory == Unit.Category.HELICOPTER then + if UnitInAir==true and UnitCategory == Unit.Category.HELICOPTER and (not NoHeloCheck) then local VelocityVec3 = DCSUnit:getVelocity() local Velocity = UTILS.VecNorm(VelocityVec3) local Coordinate = DCSUnit:getPoint()