mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-11 11:48:38 +00:00
Ops
This commit is contained in:
@@ -193,41 +193,6 @@ function AIRWING:AddSquadron(Squadron)
|
||||
return self
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
--- Add a squadron to the air wing.
|
||||
-- @param #AIRWING self
|
||||
-- @param #string SquadronName Name of the squadron, e.g. "VFA-37".
|
||||
-- @param #table MissionTypes Table of mission types this squadron is able to perform.
|
||||
-- @param #string Livery The livery for all added flight group. Default is the livery of the template group.
|
||||
-- @param #string Skill The skill of all squadron members.
|
||||
-- @return #AIRWING.Squadron The squadron object.
|
||||
function AIRWING:AddSquadron(SquadronName, MissionTypes, Livery, Skill)
|
||||
|
||||
-- Ensure Missiontypes is a table.
|
||||
if MissionTypes and type(MissionTypes)~="table" then
|
||||
MissionTypes={MissionTypes}
|
||||
end
|
||||
|
||||
-- TODO: Mission types that anyone can do! ORBIT, Ferry, ???
|
||||
if not self:CheckMissionType(AUFTRAG.Type.ORBIT, MissionTypes) then
|
||||
table.insert(MissionTypes, AUFTRAG.Type.ORBIT)
|
||||
end
|
||||
|
||||
-- Set up new squadron data.
|
||||
local squadron={} --#AIRWING.Squadron
|
||||
squadron.name=SquadronName
|
||||
squadron.assets={}
|
||||
squadron.missiontypes=MissionTypes
|
||||
squadron.livery=Livery
|
||||
squadron.skill=Skill
|
||||
|
||||
self.squadrons[SquadronName]=squadron
|
||||
|
||||
return squadron
|
||||
end
|
||||
]]
|
||||
|
||||
--- Add a **new** payload to air wing resources.
|
||||
-- @param #AIRWING self
|
||||
-- @param Wrapper.Unit#UNIT Unit The unit, the payload is extracted from. Can also be given as *#string* name of the unit.
|
||||
@@ -854,9 +819,11 @@ function AIRWING:onafterMissionRequest(From, Event, To, Mission)
|
||||
-- Set asset to requested! Important so that new requests do not use this asset!
|
||||
asset.requested=true
|
||||
|
||||
--text=text..string.format("\n[%d] %s spawned=%s type=%s payload=%s", i, asset.spawngroupname, tostring(asset.spawned), asset.unittype, asset.payload and table.concat(asset.payload.missiontypes, ", ") or "no payload!")
|
||||
if Mission.missionTask then
|
||||
asset.missionTask=Mission.missionTask
|
||||
end
|
||||
|
||||
end
|
||||
--self:I(self.lid..text)
|
||||
|
||||
-- Add request to airwing warehouse.
|
||||
-- TODO: better Assignment string.
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
-- @field #number requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed.
|
||||
-- @field #boolean cancelContactLost If true, cancel mission if the contact is lost.
|
||||
--
|
||||
-- @field #string missionTask Mission task. Seed ENUMS.MissionTask.
|
||||
-- @field #number missionAltitude Mission altitude in meters.
|
||||
-- @field #number missionFraction Mission coordiante fraction. Default is 0.5.
|
||||
--
|
||||
-- @field #number missionRepeated Number of times mission was repeated.
|
||||
-- @field #number missionRepeatMax Number of times mission is repeated if failed.
|
||||
@@ -105,6 +107,7 @@ AUFTRAG = {
|
||||
auftragsnummer = nil,
|
||||
flightdata = {},
|
||||
assets = {},
|
||||
missionFraction = 0.5,
|
||||
}
|
||||
|
||||
--- Global mission counter.
|
||||
@@ -117,6 +120,8 @@ _AUFTRAGSNR=0
|
||||
-- @field #string AWACS AWACS mission.
|
||||
-- @field #string BAI Battlefield Air Interdiction.
|
||||
-- @field #string BOMBING Bombing mission.
|
||||
-- @field #string BOMBRUNWAY Bomb runway of an airbase.
|
||||
-- @field #string BOMBCARPET Carpet bombing.
|
||||
-- @field #string CAP Combat Air Patrol.
|
||||
-- @field #string CAS Close Air Support.
|
||||
-- @field #string ESCORT Escort mission.
|
||||
@@ -135,6 +140,8 @@ AUFTRAG.Type={
|
||||
AWACS="AWACS",
|
||||
BAI="BAI",
|
||||
BOMBING="Bombing",
|
||||
BOMBRUNWAY="Bomb Runway",
|
||||
BOMBCARPET="Carpet Bombing",
|
||||
CAP="CAP",
|
||||
CAS="CAS",
|
||||
ESCORT="Escort",
|
||||
@@ -219,8 +226,8 @@ AUFTRAG.version="0.0.7"
|
||||
-- TODO: Mission formation, etc.
|
||||
-- DONE: FSM events.
|
||||
-- TODO: F10 marker functions that are updated on Status event.
|
||||
-- TODO: Evaluate mission result ==> SUCCESS/FAILURE
|
||||
-- TODO: NewAUTO() NewA2G NewA2A
|
||||
-- DONE: Evaluate mission result ==> SUCCESS/FAILURE
|
||||
-- DONE: NewAUTO() NewA2G NewA2A
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
@@ -317,6 +324,8 @@ function AUFTRAG:NewANTISHIP(TargetUnitSet)
|
||||
mission.engageTargetUnitset=TargetUnitSet
|
||||
mission.engageTargetUnitset:FilterDeads():FilterCrashes()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.ANTISHIPSTRIKE
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
@@ -369,6 +378,26 @@ function AUFTRAG:NewPATROL(OrbitCoordinate, OrbitSpeed, Heading, Leg, Altitude)
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create an INTERCEPT mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Set#SET_GROUP TargetGroupSet The set of target groups to intercept. Can also be passed as a simple @{Wrapper.Group#GROUP} object.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewINTERCEPT(TargetGroupSet)
|
||||
|
||||
if TargetGroupSet:IsInstanceOf("GROUP") then
|
||||
TargetGroupSet=SET_GROUP:New():AddGroup(TargetGroupSet)
|
||||
end
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.INTERCEPT)
|
||||
|
||||
mission.engageTargetGroupset=TargetGroupSet
|
||||
mission.engageTargetGroupset:FilterDeads():FilterCrashes()
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create a CAP mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE OrbitCoordinate Where to orbit. Altitude is also taken from the coordinate.
|
||||
@@ -397,6 +426,8 @@ function AUFTRAG:NewCAP(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAP, Targ
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.CAP
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
@@ -428,45 +459,7 @@ function AUFTRAG:NewCAS(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAS, Targ
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Create a STRIKE mission. Flight will attack a specified coordinate.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE Coordinate Target Coordinate.
|
||||
-- @param #number Altitude Engage altitude in feet. Default 1000.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewSTRIKE(TargetCoordinate, Altitude)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.STRIKE)
|
||||
|
||||
mission.engageCoord=TargetCoordinate
|
||||
mission.engageAltitude=UTILS.FeetToMeters(Altitude or 1000)
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create an INTERCEPT mission.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Set#SET_GROUP TargetGroupSet The set of target groups to intercept.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewINTERCEPT(TargetGroupSet)
|
||||
|
||||
if TargetGroupSet:IsInstanceOf("GROUP") then
|
||||
env.info("Converting group to set!")
|
||||
TargetGroupSet=SET_GROUP:New():AddGroup(TargetGroupSet)
|
||||
end
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.INTERCEPT)
|
||||
|
||||
mission.engageTargetGroupset=TargetGroupSet
|
||||
mission.engageTargetGroupset:FilterDeads():FilterCrashes()
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
mission.missionTask=ENUMS.MissionTask.CAS
|
||||
|
||||
return mission
|
||||
end
|
||||
@@ -478,7 +471,6 @@ end
|
||||
function AUFTRAG:NewBAI(TargetGroupSet)
|
||||
|
||||
if TargetGroupSet:IsInstanceOf("GROUP") then
|
||||
env.info("Converting group to set!")
|
||||
TargetGroupSet=SET_GROUP:New():AddGroup(TargetGroupSet)
|
||||
end
|
||||
|
||||
@@ -489,9 +481,83 @@ function AUFTRAG:NewBAI(TargetGroupSet)
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.GROUNDATTACK
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create a STRIKE mission. Flight will attack a specified coordinate.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE TargetCoordinate Target coordinate.
|
||||
-- @param #number Altitude Engage altitude in feet. Default 1000.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewSTRIKE(TargetCoordinate, Altitude)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.STRIKE)
|
||||
|
||||
mission.engageCoord=TargetCoordinate
|
||||
mission.engageAltitude=UTILS.FeetToMeters(Altitude or 1000)
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.GROUNDATTACK
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
--- Create a BOMBING mission. Flight will attack a specified coordinate.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Core.Point#COORDINATE TargetCoordinate Target coordinate.
|
||||
-- @param #number Altitude Engage altitude in feet. Default 25000.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewBOMBING(TargetCoordinate, Altitude)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.BOMBING)
|
||||
|
||||
mission.engageCoord=TargetCoordinate
|
||||
mission.engageAltitude=UTILS.FeetToMeters(Altitude or 25000)
|
||||
|
||||
mission.missionAltitude=mission.engageAltitude
|
||||
|
||||
mission.missionFraction=0.3
|
||||
|
||||
mission.engageWeaponType=4030478 --2956984318 --ENUMS.WeaponFlag.AnyBomb
|
||||
mission.engageWeaponExpend=AI.Task.WeaponExpend.ALL
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.GROUNDATTACK
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
|
||||
--- Create an ESCORT mission. Flight will escort another group and automatically engage certain target types.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Wrapper.Group#GROUP EscortGroup The group to escort.
|
||||
-- @param DCS#Vec3 OffsetVector A table with x, y and z components specifying the offset of the flight to the escorted group. Default {x=200, y=0, z=-100} for 200 meters to the right, same alitude, 100 meters behind.
|
||||
-- @param #number EngageMaxDistance Max engage distance of targets in meters. Default auto (*nil*).
|
||||
-- @param #table TargetTypes Types of targets to engage automatically. Default is {"Air"}, i.e. all enemy airborne units.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetTypes)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.ESCORT)
|
||||
|
||||
mission.escortGroup=EscortGroup
|
||||
mission.escortVec3=OffsetVector or {x=200, y=0, z=-100}
|
||||
mission.engageMaxDistance=EngageMaxDistance
|
||||
mission.engageTargetTypes=TargetTypes or {"Air"}
|
||||
|
||||
mission.missionFraction=0.1
|
||||
|
||||
mission.DCStask=mission:GetDCSMissionTask()
|
||||
|
||||
mission.missionTask=ENUMS.MissionTask.ESCORT
|
||||
|
||||
return mission
|
||||
end
|
||||
|
||||
|
||||
--- Create a mission to attack a group. Mission type is automatically chosen from the group category.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param Wrapper.Group#GROUP EngageGroup Group to be engaged.
|
||||
@@ -1437,7 +1503,7 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
|
||||
local Vec2=self.engageCoord:GetVec2()
|
||||
|
||||
local DCStask=CONTROLLABLE.TaskBombing(self,Vec2, self.engageAsGroup, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType, Divebomb)
|
||||
local DCStask=CONTROLLABLE.TaskBombing(self, Vec2, self.engageAsGroup, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType, Divebomb)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
|
||||
@@ -2592,7 +2592,7 @@ function FLIGHTGROUP:onafterRTB(From, Event, To, airbase, SpeedTo, SpeedHold, Sp
|
||||
SpeedLand=SpeedLand or 170
|
||||
|
||||
-- Debug message.
|
||||
local text=string.format("Flight group set to hold at airbase %s", airbase:GetName())
|
||||
local text=string.format("Flight group set to hold at airbase %s. SpeedTo=%d, SpeedHold=%d, SpeedLand=%d", airbase:GetName(), SpeedTo, SpeedHold, SpeedLand)
|
||||
MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug)
|
||||
self:I(self.lid..text)
|
||||
|
||||
@@ -3390,11 +3390,12 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
|
||||
-- Create waypoint coordinate half way between us and the target.
|
||||
local targetcoord=mission:GetTargetCoordinate()
|
||||
local flightcoord=self.group:GetCoordinate()
|
||||
local waypointcoord=flightcoord:GetIntermediateCoordinate(targetcoord, 0.5)
|
||||
local waypointcoord=flightcoord:GetIntermediateCoordinate(targetcoord, mission.missionFraction)
|
||||
|
||||
-- Set altitude of mission waypoint.
|
||||
if mission.missionAltitude then
|
||||
waypointcoord.y=mission.missionAltitude
|
||||
env.info("FF mission altitude [m]="..waypointcoord.y)
|
||||
end
|
||||
|
||||
-- Add waypoint.
|
||||
|
||||
Reference in New Issue
Block a user