mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Working CSAR ... huray
This commit is contained in:
parent
25831db057
commit
ec973fcc76
@ -4,7 +4,7 @@
|
|||||||
--- @type CoalitionObject
|
--- @type CoalitionObject
|
||||||
-- @extends Dcs.DCSWrapper.Object#Object
|
-- @extends Dcs.DCSWrapper.Object#Object
|
||||||
|
|
||||||
coalition = {} --#coalition
|
|
||||||
|
|
||||||
--- Returns coalition of the object.
|
--- Returns coalition of the object.
|
||||||
-- @function [parent=#CoalitionObject] getCoalition
|
-- @function [parent=#CoalitionObject] getCoalition
|
||||||
|
|||||||
@ -12,3 +12,5 @@
|
|||||||
--- @function [parent=#coalition] getCountryCoalition
|
--- @function [parent=#coalition] getCountryCoalition
|
||||||
-- @param #number countryId
|
-- @param #number countryId
|
||||||
-- @return #number coalitionId
|
-- @return #number coalitionId
|
||||||
|
|
||||||
|
coalition = coalition -- #coalition
|
||||||
|
|||||||
@ -220,6 +220,14 @@ function COMMANDCENTER:GetShortText()
|
|||||||
end
|
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.
|
--- Gets the POSITIONABLE of the HQ command center.
|
||||||
-- @param #COMMANDCENTER self
|
-- @param #COMMANDCENTER self
|
||||||
|
|||||||
@ -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 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 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 #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
|
-- @return #MISSION self
|
||||||
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
||||||
|
|
||||||
@ -265,6 +265,8 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- FSM function for a MISSION
|
--- FSM function for a MISSION
|
||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @param #string From
|
-- @param #string From
|
||||||
|
|||||||
@ -177,6 +177,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
Mission = nil,
|
Mission = nil,
|
||||||
Tasks = {},
|
Tasks = {},
|
||||||
CSAR = {},
|
CSAR = {},
|
||||||
|
CSARSpawned = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,26 +211,6 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
-- For CSAR missions, we process the event when a pilot ejects.
|
-- For CSAR missions, we process the event when a pilot ejects.
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Ejection )
|
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
|
return self
|
||||||
end
|
end
|
||||||
@ -242,19 +223,50 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
|
|
||||||
self:E( { EventData = EventData } )
|
self:E( { EventData = EventData } )
|
||||||
|
|
||||||
|
self.CSARSpawned = self.CSARSpawned + 1
|
||||||
|
|
||||||
local PlaneUnit = EventData.IniUnit
|
local PlaneUnit = EventData.IniUnit
|
||||||
local CSARName = EventData.IniUnitName
|
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.
|
if CargoCoalition == self.Mission:GetCommandCenter():GetCoalition() then
|
||||||
self.PilotSpawn:InitCategory( Group.Category.GROUND )
|
|
||||||
self.PilotSpawn:InitCountry( EventData.IniUnit:GetCountry() )
|
-- Create the CSAR Pilot SPAWN object.
|
||||||
self.PilotSpawn:InitCoalition( EventData.IniUnit:GetCoalition() )
|
-- Let us create the Template for the replacement Pilot :-)
|
||||||
|
local Template = {
|
||||||
self.CSAR[#self.CSAR+1] = {}
|
["visible"] = false,
|
||||||
self.CSAR[#self.CSAR].PilotGroup = self.PilotSpawn:SpawnFromPointVec2( PointVec2Spawn )
|
["hidden"] = false,
|
||||||
self.CSAR[#self.CSAR].Task = nil
|
["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
|
return self
|
||||||
end
|
end
|
||||||
@ -294,7 +306,7 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
|
|
||||||
--- Define the deploy zones for the CSAR tasks.
|
--- Define the deploy zones for the CSAR tasks.
|
||||||
-- @param #TASK_CARGO_DISPATCHER self
|
-- @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
|
-- @return #TASK_CARGO_DISPATCHER
|
||||||
function TASK_CARGO_DISPATCHER:SetCSARDeployZones( CSARDeployZones )
|
function TASK_CARGO_DISPATCHER:SetCSARDeployZones( CSARDeployZones )
|
||||||
|
|
||||||
@ -361,12 +373,12 @@ do -- TASK_CARGO_DISPATCHER
|
|||||||
if CSARData.Task then
|
if CSARData.Task then
|
||||||
else
|
else
|
||||||
-- New CSAR Task
|
-- New CSAR Task
|
||||||
self:F( { PilotGroup = CSARData.PilotGroup } )
|
|
||||||
local SetCargo = self:EvaluateCSAR( CSARData.PilotGroup )
|
local SetCargo = self:EvaluateCSAR( CSARData.PilotGroup )
|
||||||
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, string.format( "CSAR.%03d", CSARID ), SetCargo )
|
local CSARTask = TASK_CARGO_CSAR:New( Mission, self.SetGroup, string.format( "CSAR.%03d", CSARID ), SetCargo )
|
||||||
CSARTask:SetDeployZones( self.CSARDeployZones or {} )
|
CSARTask:SetDeployZones( self.CSARDeployZones or {} )
|
||||||
Mission:AddTask( CSARTask )
|
Mission:AddTask( CSARTask )
|
||||||
TaskReport:Add( CSARTask:GetName() )
|
TaskReport:Add( CSARTask:GetName() )
|
||||||
|
CSARData.Task = CSARTask
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -121,7 +121,7 @@ GROUPTEMPLATE.Takeoff = {
|
|||||||
-- @return #GROUP self
|
-- @return #GROUP self
|
||||||
function GROUP:NewTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID )
|
function GROUP:NewTemplate( GroupTemplate, CoalitionSide, CategoryID, CountryID )
|
||||||
local GroupName = GroupTemplate.name
|
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 = BASE:Inherit( self, CONTROLLABLE:New( GroupName ) )
|
||||||
self:F2( GroupName )
|
self:F2( GroupName )
|
||||||
self.GroupName = GroupName
|
self.GroupName = GroupName
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user