From 6208c79d1f47ee6e3e9ca67e1a63f7a5c38e8ca7 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 2 Jan 2020 16:17:25 +0100 Subject: [PATCH 1/3] ARTY v1.1.7 & AIRBASE - Improved ARTY._PassingWaypoint function. - Corrected AIRBASE.Ras_Al_Khaimah --- .../Moose/Functional/Artillery.lua | 35 +++++++++---------- Moose Development/Moose/Wrapper/Airbase.lua | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Moose Development/Moose/Functional/Artillery.lua b/Moose Development/Moose/Functional/Artillery.lua index d1742c271..f5233e3b0 100644 --- a/Moose Development/Moose/Functional/Artillery.lua +++ b/Moose Development/Moose/Functional/Artillery.lua @@ -693,7 +693,7 @@ ARTY.db={ --- Arty script version. -- @field #string version -ARTY.version="1.1.6" +ARTY.version="1.1.7" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -3848,26 +3848,23 @@ end -- @param #boolean final True if it is the final waypoint. function ARTY._PassingWaypoint(group, arty, i, final) - -- Debug message. - local text=string.format("%s, passing waypoint %d.", group:GetName(), i) - if final then - text=string.format("%s, arrived at destination.", group:GetName()) - end - arty:T(self.lid..text) + if group and group:IsAlive() then + + local groupname=tostring(group:GetName()) - --[[ - if final then - MESSAGE:New(text, 10):ToCoalitionIf(group:GetCoalition(), arty.Debug or arty.report) - else - MESSAGE:New(text, 10):ToAllIf(arty.Debug) + -- Debug message. + local text=string.format("%s, passing waypoint %d.", groupname, i) + if final then + text=string.format("%s, arrived at destination.", groupname) + end + arty:T(arty.lid..text) + + -- Arrived event. + if final and arty.groupname==groupname then + arty:Arrived() + end + end - ]] - - -- Arrived event. - if final and arty.groupname==group:GetName() then - arty:Arrived() - end - end --- Relocate to another position, e.g. after an engagement to avoid couter strikes. diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index e3effd07c..37530551f 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -275,7 +275,7 @@ AIRBASE.PersianGulf = { ["Lavan_Island_Airport"] = "Lavan Island Airport", ["Liwa_Airbase"] = "Liwa Airbase", ["Qeshm_Island"] = "Qeshm Island", - ["Ras_Al_Khaimah_International_Airport"] = "Ras Al Khaimah International Airport", + ["Ras_Al_Khaimah"] = "Ras Al Khaimah", ["Sas_Al_Nakheel_Airport"] = "Sas Al Nakheel Airport", ["Sharjah_Intl"] = "Sharjah Intl", ["Shiraz_International_Airport"] = "Shiraz International Airport", From d5b8ed62ae49f202ae08f7a084bea83e11930836 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 2 Jan 2020 20:15:42 +0100 Subject: [PATCH 2/3] AI_AIR - Fixed call to .Resume function if AI_A2A_CAP is calling. --- Moose Development/Moose/AI/AI_Air.lua | 12 +++++++++++- Moose Development/Moose/AI/AI_Air_Patrol.lua | 1 - Moose Development/Moose/Core/Base.lua | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/AI/AI_Air.lua b/Moose Development/Moose/AI/AI_Air.lua index eeb9053b7..c829cc6e9 100644 --- a/Moose Development/Moose/AI/AI_Air.lua +++ b/Moose Development/Moose/AI/AI_Air.lua @@ -748,10 +748,20 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To ) AIGroup:OptionROEHoldFire() AIGroup:OptionROTEvadeFire() + + -- Get Class name for .Resume function + local classname=self:GetClassName() + + -- AI_A2A_CAP can call this function but does not have a .Resume function. Try to fix. + local fsm=self + if classname=="AI_A2A_CAP" then + fsm=self:GetParent(self, AI_A2A_CAP) + classname=fsm:GetClassName() + end local Tasks = {} Tasks[#Tasks+1] = AIGroup:TaskRefueling() - Tasks[#Tasks+1] = AIGroup:TaskFunction( self:GetClassName() .. ".Resume", self ) + Tasks[#Tasks+1] = AIGroup:TaskFunction( classname .. ".Resume", fsm ) RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks ) AIGroup:Route( RefuelRoute, self.TaskDelay ) diff --git a/Moose Development/Moose/AI/AI_Air_Patrol.lua b/Moose Development/Moose/AI/AI_Air_Patrol.lua index 6458c80d1..32bd99cea 100644 --- a/Moose Development/Moose/AI/AI_Air_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Air_Patrol.lua @@ -356,7 +356,6 @@ function AI_AIR_PATROL:onafterPatrolRoute( AIPatrol, From, Event, To ) local taskOrbit=AIPatrol:TaskOrbit(c1, altitude, UTILS.KmphToMps(speedkmh), c2) -- Task function to redo the patrol at other random position. - --local taskPatrol=AIPatrol:TaskFunction("AI_A2A_PATROL.PatrolRoute", self) local taskPatrol=AIPatrol:TaskFunction("AI_AIR_PATROL.___PatrolRoute", self) -- Controlled task with task condition. diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index d20f068ee..e95eac8ce 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -298,7 +298,8 @@ end -- -- -- @param #BASE self --- @param #BASE Child is the Child class from which the Parent class needs to be retrieved. +-- @param #BASE Child This is the Child class from which the Parent class needs to be retrieved. +-- @param #BASE FromClass (Optional) The class from which to get the parent. -- @return #BASE function BASE:GetParent( Child, FromClass ) From aa6515e1cabae024e237b947095a9384ceb19e6f Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 2 Jan 2020 22:50:35 +0100 Subject: [PATCH 3/3] AI_AIR - Fixed onafterRefuel --- Moose Development/Moose/AI/AI_A2A_Cap.lua | 2 +- Moose Development/Moose/AI/AI_Air.lua | 40 ++++++++++------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Moose Development/Moose/AI/AI_A2A_Cap.lua b/Moose Development/Moose/AI/AI_A2A_Cap.lua index ae4171ae5..a5bee30e4 100644 --- a/Moose Development/Moose/AI/AI_A2A_Cap.lua +++ b/Moose Development/Moose/AI/AI_A2A_Cap.lua @@ -119,7 +119,7 @@ function AI_A2A_CAP:New2( AICap, EngageMinSpeed, EngageMaxSpeed, EngageFloorAlti local AI_Air = AI_AIR:New( AICap ) local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AICap, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) -- #AI_AIR_PATROL local AI_Air_Engage = AI_AIR_ENGAGE:New( AI_Air_Patrol, AICap, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType ) - local self = BASE:Inherit( self, AI_Air_Engage ) + local self = BASE:Inherit( self, AI_Air_Engage ) --#AI_A2A_CAP self:SetFuelThreshold( .2, 60 ) self:SetDamageThreshold( 0.4 ) diff --git a/Moose Development/Moose/AI/AI_Air.lua b/Moose Development/Moose/AI/AI_Air.lua index c829cc6e9..5fbd84349 100644 --- a/Moose Development/Moose/AI/AI_Air.lua +++ b/Moose Development/Moose/AI/AI_Air.lua @@ -707,13 +707,14 @@ end function AI_AIR:onafterRefuel( AIGroup, From, Event, To ) self:F( { AIGroup, From, Event, To } ) - if AIGroup and AIGroup:IsAlive() then + + -- Get tanker group. local Tanker = GROUP:FindByName( self.TankerName ) - if Tanker:IsAlive() and Tanker:IsAirPlane() then + if Tanker and Tanker:IsAlive() and Tanker:IsAirPlane() then - self:I( "Group " .. self.Controllable:GetName() .. " ... Refuelling! ( " .. self:GetState() .. "), at tanker " .. self.TankerName ) + self:I( "Group " .. self.Controllable:GetName() .. " ... Refuelling! State=" .. self:GetState() .. ", Refuelling tanker " .. self.TankerName ) local RefuelRoute = {} @@ -724,27 +725,15 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To ) local ToRefuelSpeed = math.random( self.PatrolMinSpeed, self.PatrolMaxSpeed ) --- Create a route point of type air. - local FromRefuelRoutePoint = FromRefuelCoord:WaypointAir( - self.PatrolAltType, - POINT_VEC3.RoutePointType.TurningPoint, - POINT_VEC3.RoutePointAction.TurningPoint, - ToRefuelSpeed, - true - ) + local FromRefuelRoutePoint = FromRefuelCoord:WaypointAir(self.PatrolAltType, POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, ToRefuelSpeed, true) - --- Create a route point of type air. - local ToRefuelRoutePoint = FromRefuelCoord:WaypointAir( - self.PatrolAltType, - POINT_VEC3.RoutePointType.TurningPoint, - POINT_VEC3.RoutePointAction.TurningPoint, - ToRefuelSpeed, - true - ) + --- Create a route point of type air. NOT used! + local ToRefuelRoutePoint = Tanker:GetCoordinate():WaypointAir(self.PatrolAltType, POINT_VEC3.RoutePointType.TurningPoint, POINT_VEC3.RoutePointAction.TurningPoint, ToRefuelSpeed, true) self:F( { ToRefuelSpeed = ToRefuelSpeed } ) RefuelRoute[#RefuelRoute+1] = FromRefuelRoutePoint - --RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint + RefuelRoute[#RefuelRoute+1] = ToRefuelRoutePoint AIGroup:OptionROEHoldFire() AIGroup:OptionROTEvadeFire() @@ -753,21 +742,26 @@ function AI_AIR:onafterRefuel( AIGroup, From, Event, To ) local classname=self:GetClassName() -- AI_A2A_CAP can call this function but does not have a .Resume function. Try to fix. - local fsm=self if classname=="AI_A2A_CAP" then - fsm=self:GetParent(self, AI_A2A_CAP) - classname=fsm:GetClassName() + classname="AI_AIR_PATROL" end + + env.info("FF refueling classname="..classname) local Tasks = {} Tasks[#Tasks+1] = AIGroup:TaskRefueling() - Tasks[#Tasks+1] = AIGroup:TaskFunction( classname .. ".Resume", fsm ) + Tasks[#Tasks+1] = AIGroup:TaskFunction( classname .. ".Resume", self ) RefuelRoute[#RefuelRoute].task = AIGroup:TaskCombo( Tasks ) AIGroup:Route( RefuelRoute, self.TaskDelay ) + else + + -- No tanker defined ==> RTB! self:RTB() + end + end end