diff --git a/Moose Development/Moose/AI/AI_A2A.lua b/Moose Development/Moose/AI/AI_A2A.lua index dc02a56a1..d9b61970f 100644 --- a/Moose Development/Moose/AI/AI_A2A.lua +++ b/Moose Development/Moose/AI/AI_A2A.lua @@ -400,7 +400,6 @@ end -- @param #string Event The Event string. -- @param #string To The To State string. function AI_A2A:onafterStart( Controllable, From, Event, To ) - self:F2() self:__Status( 10 ) -- Check status status every 30 seconds. @@ -423,8 +422,6 @@ end --- @param #AI_A2A self function AI_A2A:onafterStatus() - self:F( " Checking Status" ) - if self.Controllable and self.Controllable:IsAlive() then local RTB = false @@ -452,7 +449,7 @@ function AI_A2A:onafterStatus() if not self:Is( "Fuel" ) and not self:Is( "Home" ) then local Fuel = self.Controllable:GetFuelMin() - self:F({Fuel=Fuel}) + self:F({Fuel=Fuel, PatrolFuelThresholdPercentage=self.PatrolFuelThresholdPercentage}) if Fuel < self.PatrolFuelThresholdPercentage then if self.TankerName then self:E( self.Controllable:GetName() .. " is out of fuel: " .. Fuel .. " ... Refuelling at Tanker!" ) diff --git a/Moose Development/Moose/AI/AI_A2A_Cap.lua b/Moose Development/Moose/AI/AI_A2A_Cap.lua index 480bd39ec..41c8c8a5e 100644 --- a/Moose Development/Moose/AI/AI_A2A_Cap.lua +++ b/Moose Development/Moose/AI/AI_A2A_Cap.lua @@ -282,13 +282,14 @@ function AI_A2A_CAP:New( AICap, PatrolZone, PatrolFloorAltitude, PatrolCeilingAl end --- onafter State Transition for Event Patrol. --- @param #AI_A2A_GCI self +-- @param #AI_A2A_CAP self -- @param Wrapper.Group#GROUP AICap The AI Group managed by the FSM. -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. function AI_A2A_CAP:onafterStart( AICap, From, Event, To ) + self:GetParent( self ).onafterStart( self, AICap, From, Event, To ) AICap:HandleEvent( EVENTS.Takeoff, nil, self ) end diff --git a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua index 135a9a0fc..20af4f2fe 100644 --- a/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua +++ b/Moose Development/Moose/AI/AI_A2A_Dispatcher.lua @@ -2365,7 +2365,7 @@ do -- AI_A2A_DISPATCHER -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- -- -- Now Setup the default fuel treshold. - -- A2ADispatcher:SetDefaultRefuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. + -- A2ADispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- function AI_A2A_DISPATCHER:SetDefaultFuelThreshold( FuelThreshold ) @@ -2407,7 +2407,7 @@ do -- AI_A2A_DISPATCHER -- A2ADispatcher = AI_A2A_DISPATCHER:New( Detection ) -- -- -- Now Setup the default fuel treshold. - -- A2ADispatcher:SetDefaultRefuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. + -- A2ADispatcher:SetDefaultFuelThreshold( 0.30 ) -- Go RTB when only 30% of fuel remaining in the tank. -- -- -- Now Setup the default tanker. -- A2ADispatcher:SetDefaultTanker( "Tanker" ) -- The group name of the tanker is "Tanker" in the Mission Editor. diff --git a/Moose Development/Moose/AI/AI_A2A_Gci.lua b/Moose Development/Moose/AI/AI_A2A_Gci.lua index cc24341c3..53b7141ab 100644 --- a/Moose Development/Moose/AI/AI_A2A_Gci.lua +++ b/Moose Development/Moose/AI/AI_A2A_Gci.lua @@ -290,6 +290,7 @@ end -- @param #string To The To State string. function AI_A2A_GCI:onafterStart( AIIntercept, From, Event, To ) + self:GetParent( self ).onafterStart( self, AIIntercept, From, Event, To ) AIIntercept:HandleEvent( EVENTS.Takeoff, nil, self ) end diff --git a/Moose Development/Moose/Actions/Act_Route.lua b/Moose Development/Moose/Actions/Act_Route.lua index 9f858879f..d719f1f7b 100644 --- a/Moose Development/Moose/Actions/Act_Route.lua +++ b/Moose Development/Moose/Actions/Act_Route.lua @@ -362,7 +362,7 @@ do -- ACT_ROUTE_POINT local Distance = self.Coordinate:Get2DDistance( ProcessUnit:GetCoordinate() ) if Distance <= self.Range then - local RouteText = "You have arrived." + local RouteText = "Task \"" .. self:GetTask():GetName() .. "\", you have arrived." self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) return true end @@ -381,7 +381,7 @@ do -- ACT_ROUTE_POINT -- @param #string To function ACT_ROUTE_POINT:onafterReport( ProcessUnit, From, Event, To ) - local RouteText = self:GetRouteText( ProcessUnit ) + local RouteText = "Task \"" .. self:GetTask():GetName() .. "\", " .. self:GetRouteText( ProcessUnit ) self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Update ) end @@ -453,7 +453,7 @@ do -- ACT_ROUTE_ZONE function ACT_ROUTE_ZONE:onfuncHasArrived( ProcessUnit ) if ProcessUnit:IsInZone( self.Zone ) then - local RouteText = "You have arrived within the zone." + local RouteText = "Task \"" .. self:GetTask():GetName() .. "\", you have arrived within the zone." self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Information ) end @@ -471,7 +471,7 @@ do -- ACT_ROUTE_ZONE function ACT_ROUTE_ZONE:onafterReport( ProcessUnit, From, Event, To ) self:F( { ProcessUnit = ProcessUnit } ) - local RouteText = self:GetRouteText( ProcessUnit ) + local RouteText = "Task \"" .. self:GetTask():GetName() .. "\", " .. self:GetRouteText( ProcessUnit ) self:GetCommandCenter():MessageTypeToGroup( RouteText, ProcessUnit:GetGroup(), MESSAGE.Type.Update ) end diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 049f9b444..984f6eb5d 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -1929,17 +1929,20 @@ do -- COORDINATE -- @param Core.Settings#SETTINGS Settings -- @param Tasking.Task#TASK Task The task for which coordinates need to be calculated. -- @return #string The coordinate Text in the configured coordinate system. - function COORDINATE:ToString( Controllable, Settings, Task ) -- R2.2 + function COORDINATE:ToString( Controllable, Settings, Task ) self:F2( { Controllable = Controllable and Controllable:GetName() } ) local Settings = Settings or ( Controllable and _DATABASE:GetPlayerSettings( Controllable:GetPlayerName() ) ) or _SETTINGS local ModeA2A = false + self:E('A2A false') if Task then + self:E('Task ' .. Task.ClassName ) if Task:IsInstanceOf( TASK_A2A ) then ModeA2A = true + self:E('A2A true') else if Task:IsInstanceOf( TASK_A2G ) then ModeA2A = false diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 6fa79d6f5..15621ec6f 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -1229,6 +1229,29 @@ do -- SET_GROUP end return true end + + --- Iterate the SET_GROUP and call an iterator function for each alive GROUP that has any unit in the @{Core.Zone}, providing the GROUP and optional parameters to the called function. + -- @param #SET_GROUP self + -- @param Core.Zone#ZONE ZoneObject The Zone to be tested for. + -- @param #function IteratorFunction The function that will be called when there is an alive GROUP in the SET_GROUP. The function needs to accept a GROUP parameter. + -- @return #SET_GROUP self + function SET_GROUP:ForEachGroupAnyInZone( ZoneObject, IteratorFunction, ... ) + self:F2( arg ) + + self:ForEach( IteratorFunction, arg, self:GetSet(), + --- @param Core.Zone#ZONE_BASE ZoneObject + -- @param Wrapper.Group#GROUP GroupObject + function( ZoneObject, GroupObject ) + if GroupObject:IsAnyInZone( ZoneObject ) then + return true + else + return false + end + end, { ZoneObject } ) + + return self + end + --- Iterate the SET_GROUP and return true if at least one of the @{Wrapper.Group#GROUP} is completely inside the @{Core.Zone#ZONE} -- @param #SET_GROUP self @@ -3119,6 +3142,26 @@ do -- SET_STATIC end + --- Calculate the maxium A2G threat level of the SET_STATIC. + -- @param #SET_STATIC self + -- @return #number The maximum threatlevel + function SET_STATIC:CalculateThreatLevelA2G() + + local MaxThreatLevelA2G = 0 + local MaxThreatText = "" + for StaticName, StaticData in pairs( self:GetSet() ) do + local ThreatStatic = StaticData -- Wrapper.Static#STATIC + local ThreatLevelA2G, ThreatText = ThreatStatic:GetThreatLevel() + if ThreatLevelA2G > MaxThreatLevelA2G then + MaxThreatLevelA2G = ThreatLevelA2G + MaxThreatText = ThreatText + end + end + + self:F( { MaxThreatLevelA2G = MaxThreatLevelA2G, MaxThreatText = MaxThreatText } ) + return MaxThreatLevelA2G, MaxThreatText + + end --- -- @param #SET_STATIC self diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index d5361dc17..0f4ec262d 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -1204,7 +1204,7 @@ function TASK:MenuMarkToGroup( TaskGroup ) if TargetCoordinates then for TargetCoordinateID, TargetCoordinate in pairs( TargetCoordinates ) do local Report = REPORT:New():SetIndent( 0 ) - self.TaskInfo:Report( Report, "M", TaskGroup, TargetCoordinateID ) + self.TaskInfo:Report( Report, "M", TaskGroup, self ) local MarkText = Report:Text( ", " ) self:F( { Coordinate = TargetCoordinate, MarkText = MarkText } ) TargetCoordinate:MarkToGroup( MarkText, TaskGroup ) @@ -1214,7 +1214,7 @@ function TASK:MenuMarkToGroup( TaskGroup ) local TargetCoordinate = self.TaskInfo:GetData( "Coordinate" ) -- Core.Point#COORDINATE if TargetCoordinate then local Report = REPORT:New():SetIndent( 0 ) - self.TaskInfo:Report( Report, "M", TaskGroup ) + self.TaskInfo:Report( Report, "M", TaskGroup, self ) local MarkText = Report:Text( ", " ) self:F( { Coordinate = TargetCoordinate, MarkText = MarkText } ) TargetCoordinate:MarkToGroup( MarkText, TaskGroup ) @@ -1751,7 +1751,7 @@ function TASK:ReportSummary( ReportGroup ) -- Determine the status of the Task. Report:Add( "State: <" .. self:GetState() .. ">" ) - self.TaskInfo:Report( Report, "S", ReportGroup ) + self.TaskInfo:Report( Report, "S", ReportGroup, self ) return Report:Text( ', ' ) end @@ -1768,7 +1768,7 @@ function TASK:ReportOverview( ReportGroup ) local TaskName = self:GetName() local Report = REPORT:New() - self.TaskInfo:Report( Report, "O", ReportGroup ) + self.TaskInfo:Report( Report, "O", ReportGroup, self ) return Report:Text() end @@ -1852,7 +1852,7 @@ function TASK:ReportDetails( ReportGroup ) Report:AddIndent( Players ) end - self.TaskInfo:Report( Report, "D", ReportGroup ) + self.TaskInfo:Report( Report, "D", ReportGroup, self ) return Report:Text() end diff --git a/Moose Development/Moose/Tasking/TaskInfo.lua b/Moose Development/Moose/Tasking/TaskInfo.lua index 9a425311a..d3fc88350 100644 --- a/Moose Development/Moose/Tasking/TaskInfo.lua +++ b/Moose Development/Moose/Tasking/TaskInfo.lua @@ -284,8 +284,9 @@ end -- @param Core.Report#REPORT Report -- @param #TASKINFO.Detail Detail The detail Level. -- @param Wrapper.Group#GROUP ReportGroup +-- @param Tasking.Task#TASK Task -- @return #TASKINFO self -function TASKINFO:Report( Report, Detail, ReportGroup ) +function TASKINFO:Report( Report, Detail, ReportGroup, Task ) local Line = 0 local LineReport = REPORT:New() @@ -306,7 +307,7 @@ function TASKINFO:Report( Report, Detail, ReportGroup ) end if Key == "Coordinate" then local Coordinate = Data.Data -- Core.Point#COORDINATE - Text = Coordinate:ToString( ReportGroup:GetUnit(1), nil, self ) + Text = Coordinate:ToString( ReportGroup:GetUnit(1), nil, Task ) end if Key == "Threat" then local DataText = Data.Data -- #string @@ -322,15 +323,15 @@ function TASKINFO:Report( Report, Detail, ReportGroup ) end if Key == "QFE" then local Coordinate = Data.Data -- Core.Point#COORDINATE - Text = Coordinate:ToStringPressure( ReportGroup:GetUnit(1), nil, self ) + Text = Coordinate:ToStringPressure( ReportGroup:GetUnit(1), nil, Task ) end if Key == "Temperature" then local Coordinate = Data.Data -- Core.Point#COORDINATE - Text = Coordinate:ToStringTemperature( ReportGroup:GetUnit(1), nil, self ) + Text = Coordinate:ToStringTemperature( ReportGroup:GetUnit(1), nil, Task ) end if Key == "Wind" then local Coordinate = Data.Data -- Core.Point#COORDINATE - Text = Coordinate:ToStringWind( ReportGroup:GetUnit(1), nil, self ) + Text = Coordinate:ToStringWind( ReportGroup:GetUnit(1), nil, Task ) end if Key == "Cargo" then local DataText = Data.Data -- #string diff --git a/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua b/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua index 88cc801cc..7b099980f 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua @@ -289,16 +289,6 @@ do -- TASK_CARGO_CSAR self:F( { CargoDeployed = self.CargoDeployed ~= nil and "true" or "false" } ) - --- OnBefore Transition Handler for Event CargoPickedUp. - -- @function [parent=#TASK_CARGO_CSAR] OnBeforeCargoPickedUp - -- @param #TASK_CARGO_CSAR self - -- @param #string From The From State string. - -- @param #string Event The Event string. - -- @param #string To The To State string. - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that PickedUp the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - -- @return #boolean Return false to cancel Transition. - --- OnAfter Transition Handler for Event CargoPickedUp. -- @function [parent=#TASK_CARGO_CSAR] OnAfterCargoPickedUp -- @param #TASK_CARGO_CSAR self @@ -308,30 +298,6 @@ do -- TASK_CARGO_CSAR -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that PickedUp the cargo. You can use this to retrieve the PlayerName etc. -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - --- Synchronous Event Trigger for Event CargoPickedUp. - -- @function [parent=#TASK_CARGO_CSAR] CargoPickedUp - -- @param #TASK_CARGO_CSAR self - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that PickedUp the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - - --- Asynchronous Event Trigger for Event CargoPickedUp. - -- @function [parent=#TASK_CARGO_CSAR] __CargoPickedUp - -- @param #TASK_CARGO_CSAR self - -- @param #number Delay The delay in seconds. - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that PickedUp the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - - --- OnBefore Transition Handler for Event CargoDeployed. - -- @function [parent=#TASK_CARGO_CSAR] OnBeforeCargoDeployed - -- @param #TASK_CARGO_CSAR self - -- @param #string From The From State string. - -- @param #string Event The Event string. - -- @param #string To The To State string. - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that Deployed the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - -- @param Core.Zone#ZONE DeployZone The zone where the Cargo got Deployed or UnBoarded. - -- @return #boolean Return false to cancel Transition. - --- OnAfter Transition Handler for Event CargoDeployed. -- @function [parent=#TASK_CARGO_CSAR] OnAfterCargoDeployed -- @param #TASK_CARGO_CSAR self @@ -342,21 +308,6 @@ do -- TASK_CARGO_CSAR -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. -- @param Core.Zone#ZONE DeployZone The zone where the Cargo got Deployed or UnBoarded. - --- Synchronous Event Trigger for Event CargoDeployed. - -- @function [parent=#TASK_CARGO_CSAR] CargoDeployed - -- @param #TASK_CARGO_CSAR self - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that Deployed the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - -- @param Core.Zone#ZONE DeployZone The zone where the Cargo got Deployed or UnBoarded. - - --- Asynchronous Event Trigger for Event CargoDeployed. - -- @function [parent=#TASK_CARGO_CSAR] __CargoDeployed - -- @param #TASK_CARGO_CSAR self - -- @param #number Delay The delay in seconds. - -- @param Wrapper.Unit#UNIT TaskUnit The Unit (Client) that Deployed the cargo. You can use this to retrieve the PlayerName etc. - -- @param Core.Cargo#CARGO Cargo The Cargo that got PickedUp by the TaskUnit. You can use this to check Cargo Status. - -- @param Core.Zone#ZONE DeployZone The zone where the Cargo got Deployed or UnBoarded. - local Fsm = self:GetUnitProcess() local CargoReport = REPORT:New( "Rescue a downed pilot from the following position:") @@ -379,6 +330,8 @@ do -- TASK_CARGO_CSAR return self end + + function TASK_CARGO_CSAR:ReportOrder( ReportGroup ) diff --git a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua index 9f81a5d79..6833f197c 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua @@ -70,6 +70,7 @@ do -- TASK_CARGO_DISPATCHER -- @type TASK_CARGO_DISPATCHER -- @extends Tasking.Task_Manager#TASK_MANAGER -- @field TASK_CARGO_DISPATCHER.CSAR CSAR + -- @field Core.Set#SET_ZONE SetZonesCSAR --- @type TASK_CARGO_DISPATCHER.CSAR -- @field Wrapper.Unit#UNIT PilotUnit @@ -260,6 +261,18 @@ do -- TASK_CARGO_DISPATCHER -- -- Use the @{#TASK_CARGO_DISPATCHER.SetCSARDeployZone}() to setup one deployment zone, and @{#TASK_CARGO_DISPATCHER.SetCSARDeployZones}() to setup multiple default deployment zones in one call. -- + -- ## 4.4. **CSAR ejection zones**. + -- + -- Setup a set of zones where the pilots will only eject and a task is created for CSAR. When such a set of zones is given, any ejection outside those zones will not result in a pilot created for CSAR! + -- + -- Use the @{#TASK_CARGO_DISPATCHER.SetCSARZones}() to setup the set of zones. + -- + -- ## 4.5. **CSAR ejection maximum**. + -- + -- Setup how many pilots will eject the maximum. This to avoid an overload of CSAR tasks being created :-) The default is endless CSAR tasks. + -- + -- Use the @{#TASK_CARGO_DISPATCHER.SetMaxCSAR}() to setup the maximum of pilots that will eject for CSAR. + -- -- -- # 5) Handle cargo task events. -- @@ -395,6 +408,9 @@ do -- TASK_CARGO_DISPATCHER self:SetCSARRadius() self:__StartTasks( 5 ) + self.MaxCSAR = nil + self.CountCSAR = 0 + -- For CSAR missions, we process the event when a pilot ejects. self:HandleEvent( EVENTS.Ejection ) @@ -403,6 +419,47 @@ do -- TASK_CARGO_DISPATCHER end + --- Sets the set of zones were pilots will only be spawned (eject) when the planes crash. + -- Note that because this is a set of zones, the MD can create the zones dynamically within his mission! + -- Just provide a set of zones, see usage, but find the tactical situation here: + -- + -- ![CSAR Zones](../Tasking/CSAR_Zones.JPG) + -- + -- @param #TASK_CARGO_DISPATCHER self + -- @param Core.Set#SET_ZONE SetZonesCSAR The set of zones where pilots will only be spawned for CSAR when they eject. + -- @usage + -- + -- TaskDispatcher = TASK_CARGO_DISPATCHER:New( Mission, AttackGroups ) + -- + -- -- Use this call to pass the set of zones. + -- -- Note that you can create the set of zones inline, because the FilterOnce method (and other SET_ZONE methods return self). + -- -- So here the zones can be created as normal trigger zones (MOOSE creates a collection of ZONE objects when teh mission starts of all trigger zones). + -- -- Just name them as CSAR zones here. + -- TaskDispatcher:SetCSARZones( SET_ZONE:New():FilterPrefixes("CSAR"):FilterOnce() ) + -- + function TASK_CARGO_DISPATCHER:SetCSARZones( SetZonesCSAR ) + + self.SetZonesCSAR = SetZonesCSAR + + end + + + --- Sets the maximum of pilots that will be spawned (eject) when the planes crash. + -- @param #TASK_CARGO_DISPATCHER self + -- @param #number MaxCSAR The maximum of pilots that will eject for CSAR. + -- @usage + -- + -- TaskDispatcher = TASK_CARGO_DISPATCHER:New( Mission, AttackGroups ) + -- + -- -- Use this call to the maximum of CSAR to 10. + -- TaskDispatcher:SetMaxCSAR( 10 ) + -- + function TASK_CARGO_DISPATCHER:SetMaxCSAR( MaxCSAR ) + + self.MaxCSAR = MaxCSAR + + end + --- Handle the event when a pilot ejects. @@ -420,8 +477,15 @@ do -- TASK_CARGO_DISPATCHER -- Only add a CSAR task if the coalition of the mission is equal to the coalition of the ejected unit. if CSARCoalition == self.Mission:GetCommandCenter():GetCoalition() then - local CSARTaskName = self:AddCSARTask( self.CSARTaskName, CSARCoordinate, CSARHeading, CSARCountry, self.CSARBriefing ) - self:SetCSARDeployZones( CSARTaskName, self.CSARDeployZones ) + -- And only add if the eject is in one of the zones, if defined. + if not self.SetZonesCSAR or ( self.SetZonesCSAR and self.SetZonesCSAR:IsCoordinateInZone( CSARCoordinate ) ) then + -- And only if the maximum of pilots is not reached that ejected! + if not self.MaxCSAR or ( self.MaxCSAR and self.CountCSAR < self.MaxCSAR ) then + local CSARTaskName = self:AddCSARTask( self.CSARTaskName, CSARCoordinate, CSARHeading, CSARCountry, self.CSARBriefing ) + self:SetCSARDeployZones( CSARTaskName, self.CSARDeployZones ) + self.CountCSAR = self.CountCSAR + 1 + end + end end end diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 68f035bed..f86c5aff2 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1654,7 +1654,6 @@ end -- RouteToZone( GroundGroup, ZoneList[1] ) -- function CONTROLLABLE:TaskFunction( FunctionString, ... ) - self:E({TaskFunction=FunctionString, arguments=arg}) local DCSTask diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index d12f613d0..e00e79c4d 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -1008,6 +1008,23 @@ function GROUP:IsNotInZone( Zone ) return true end +--- Returns true if any units of the group are within a @{Core.Zone}. +-- @param #GROUP self +-- @param Core.Zone#ZONE_BASE Zone The zone to test. +-- @return #boolean Returns true if any unit of the Group is within the @{Core.Zone#ZONE_BASE} +function GROUP:IsAnyInZone( Zone ) + + if not self:IsAlive() then return false end + + for UnitID, UnitData in pairs( self:GetUnits() ) do + local Unit = UnitData -- Wrapper.Unit#UNIT + if Zone:IsVec3InZone( Unit:GetVec3() ) then + return true + end + end + return false +end + --- Returns the number of UNITs that are in the @{Zone} -- @param #GROUP self -- @param Core.Zone#ZONE_BASE Zone The zone to test. @@ -1217,6 +1234,25 @@ end function GROUP:GetMinHeight() self:F2() + local DCSGroup = self:GetDCSObject() + + if DCSGroup then + local GroupHeightMin = 999999999 + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + local UnitData = UnitData -- DCS#Unit + + local UnitHeight = UnitData:getPoint() + + if UnitHeight < GroupHeightMin then + GroupHeightMin = UnitHeight + end + end + + return GroupHeightMin + end + + return nil end --- Returns the current maximum height of the group. @@ -1226,6 +1262,25 @@ end function GROUP:GetMaxHeight() self:F2() + local DCSGroup = self:GetDCSObject() + + if DCSGroup then + local GroupHeightMax = -999999999 + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + local UnitData = UnitData -- DCS#Unit + + local UnitHeight = UnitData:getPoint() + + if UnitHeight > GroupHeightMax then + GroupHeightMax = UnitHeight + end + end + + return GroupHeightMax + end + + return nil end -- RESPAWNING