Working CSAR ... huray

This commit is contained in:
FlightControl_Master 2018-04-03 07:43:55 +02:00
parent 25831db057
commit ec973fcc76
6 changed files with 58 additions and 34 deletions

View File

@ -4,7 +4,7 @@
--- @type CoalitionObject
-- @extends Dcs.DCSWrapper.Object#Object
coalition = {} --#coalition
--- Returns coalition of the object.
-- @function [parent=#CoalitionObject] getCoalition

View File

@ -12,3 +12,5 @@
--- @function [parent=#coalition] getCountryCoalition
-- @param #number countryId
-- @return #number coalitionId
coalition = coalition -- #coalition

View File

@ -220,6 +220,14 @@ function COMMANDCENTER:GetShortText()
end
--- Gets the coalition of the command center.
-- @param #COMMANDCENTER self
-- @return DCScoalition#coalition
function COMMANDCENTER:GetCoalition()
return self.CommandCenterCoalition
end
--- Gets the POSITIONABLE of the HQ command center.
-- @param #COMMANDCENTER self

View File

@ -29,7 +29,7 @@ MISSION = {
-- @param #string MissionName is the name of the mission. This name will be used to reference the status of each mission by the players.
-- @param #string MissionPriority is a string indicating the "priority" of the Mission. f.e. "Primary", "Secondary" or "First", "Second". It is free format and up to the Mission designer to choose. There are no rules behind this field.
-- @param #string MissionBriefing is a string indicating the mission briefing to be shown when a player joins a @{CLIENT}.
-- @param Dcs.DCSCoalitionWrapper.Object#coalition MissionCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"...
-- @param #string MissionCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"...
-- @return #MISSION self
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
@ -265,6 +265,8 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi
end
--- FSM function for a MISSION
-- @param #MISSION self
-- @param #string From

View File

@ -177,6 +177,7 @@ do -- TASK_CARGO_DISPATCHER
Mission = nil,
Tasks = {},
CSAR = {},
CSARSpawned = 0,
}
@ -210,26 +211,6 @@ do -- TASK_CARGO_DISPATCHER
-- For CSAR missions, we process the event when a pilot ejects.
self:HandleEvent( EVENTS.Ejection )
-- Create the CSAR Pilot SPAWN object.
-- Let us create the Template for the replacement Pilot :-)
local Template = {
["visible"] = false,
["taskSelected"] = true,
["hidden"] = false,
["units"] =
{
[1] =
{
["type"] = "Soldier M4",
["skill"] = "Excellent",
["playerCanDrive"] = false,
}, -- end of [1]
}, -- end of ["units"]
["task"] = "Ground Nothing",
}
self.PilotSpawn = SPAWN:NewFromTemplate( Template, "CSAR Pilot" )
return self
end
@ -242,19 +223,50 @@ do -- TASK_CARGO_DISPATCHER
self:E( { EventData = EventData } )
self.CSARSpawned = self.CSARSpawned + 1
local PlaneUnit = EventData.IniUnit
local CSARName = EventData.IniUnitName
local PointVec2Spawn = EventData.IniUnit:GetPointVec2()
local CargoPointVec2 = EventData.IniUnit:GetPointVec2()
local CargoCoalition = EventData.IniUnit:GetCoalition()
local CargoCountry = EventData.IniUnit:GetCountry()
-- Only add a CSAR task if the coalition of the mission is equal to the coalition of the ejected unit.
self.PilotSpawn:InitHeading( EventData.IniUnit:GetHeading() ) -- This will ensure that the new pilot will point towards the same heading as the plane.
self.PilotSpawn:InitCategory( Group.Category.GROUND )
self.PilotSpawn:InitCountry( EventData.IniUnit:GetCountry() )
self.PilotSpawn:InitCoalition( EventData.IniUnit:GetCoalition() )
self.CSAR[#self.CSAR+1] = {}
self.CSAR[#self.CSAR].PilotGroup = self.PilotSpawn:SpawnFromPointVec2( PointVec2Spawn )
self.CSAR[#self.CSAR].Task = nil
if CargoCoalition == self.Mission:GetCommandCenter():GetCoalition() then
-- Create the CSAR Pilot SPAWN object.
-- Let us create the Template for the replacement Pilot :-)
local Template = {
["visible"] = false,
["hidden"] = false,
["task"] = "Ground Nothing",
["name"] = string.format( "CSAR Pilot#%03d", self.CSARSpawned ),
["x"] = CargoPointVec2:GetLat(),
["y"] = CargoPointVec2:GetLon(),
["units"] =
{
[1] =
{
["type"] = ( CargoCoalition == coalition.side.BLUE ) and "Soldier M4" or "Infantry AK",
["name"] = string.format( "CSAR Pilot#%03d-01", self.CSARSpawned ),
["skill"] = "Excellent",
["playerCanDrive"] = false,
["x"] = CargoPointVec2:GetLat(),
["y"] = CargoPointVec2:GetLon(),
["heading"] = EventData.IniUnit:GetHeading(),
}, -- end of [1]
}, -- end of ["units"]
}
local CargoGroup = GROUP:NewTemplate( Template, CargoCoalition, Group.Category.GROUND, CargoCountry )
self.CSAR[#self.CSAR+1] = {}
self.CSAR[#self.CSAR].PilotGroup = CargoGroup
self.CSAR[#self.CSAR].Task = nil
end
return self
end
@ -294,7 +306,7 @@ do -- TASK_CARGO_DISPATCHER
--- Define the deploy zones for the CSAR tasks.
-- @param #TASK_CARGO_DISPATCHER self
-- @param DeployZones A list of the deploy zones.
-- @param CSARDeployZones A list of the deploy zones.
-- @return #TASK_CARGO_DISPATCHER
function TASK_CARGO_DISPATCHER:SetCSARDeployZones( CSARDeployZones )
@ -361,12 +373,12 @@ do -- TASK_CARGO_DISPATCHER
if CSARData.Task then
else
-- New CSAR Task
self:F( { PilotGroup = CSARData.PilotGroup } )
local SetCargo = self:EvaluateCSAR( CSARData.PilotGroup )
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, string.format( "CSAR.%03d", CSARID ), SetCargo )
CSARTask:SetDeployZones( self.CSARDeployZones or {} )
Mission:AddTask( CSARTask )
TaskReport:Add( CSARTask:GetName() )
CSARData.Task = CSARTask
end
end

View File

@ -121,7 +121,7 @@ GROUPTEMPLATE.Takeoff = {
-- @return #GROUP self
function GROUP:NewTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID )
local GroupName = GroupTemplate.name
_DATABASE:_RegisterGroupTemplate( GroupTemplate, CategoryID, CountryID, CoalitionSide, GroupName )
_DATABASE:_RegisterGroupTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID, GroupName )
self = BASE:Inherit( self, CONTROLLABLE:New( GroupName ) )
self:F2( GroupName )
self.GroupName = GroupName