mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-24 15:49:10 +00:00
Ops
This commit is contained in:
@@ -5665,9 +5665,6 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
||||
-- Debug info.
|
||||
self:T2({airtemplate=template})
|
||||
|
||||
-- Create a flight group.
|
||||
--FLIGHTGROUP:New(template.name)
|
||||
|
||||
-- Spawn group.
|
||||
local group=_DATABASE:Spawn(template) --Wrapper.Group#GROUP
|
||||
|
||||
@@ -5701,13 +5698,17 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
|
||||
-- Nillify the group ID.
|
||||
template.groupId=nil
|
||||
|
||||
-- For group units, visible needs to be false.
|
||||
if asset.category==Group.Category.GROUND then
|
||||
--template.visible=false
|
||||
end
|
||||
|
||||
-- No late activation.
|
||||
template.lateActivation=false
|
||||
|
||||
if asset.missionTask then
|
||||
env.info("FF setting mission task to "..tostring(asset.missionTask))
|
||||
template.task=asset.missionTask
|
||||
end
|
||||
|
||||
-- No predefined task.
|
||||
--template.taskSelected=false
|
||||
|
||||
-- Set and empty route.
|
||||
template.route = {}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -2,19 +2,34 @@
|
||||
--
|
||||
-- See the [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) on Hoggit for further explanation and examples.
|
||||
--
|
||||
-- @module DCS
|
||||
-- @module ENUMS
|
||||
-- @image MOOSE.JPG
|
||||
|
||||
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
|
||||
-- @type ENUMS
|
||||
-- @field #ENUMS.ROE Rules Of Engagement.
|
||||
-- @field #ENUMS.ROT Reation On Threat.
|
||||
-- @field #ENUMS.WeaponFlag Weapon flags.
|
||||
|
||||
--- The world singleton contains functions centered around two different but extremely useful functions.
|
||||
-- * Events and event handlers are all governed within world.
|
||||
-- * A number of functions to get information about the game world.
|
||||
--
|
||||
-- See [https://wiki.hoggitworld.com/view/DCS_singleton_world](https://wiki.hoggitworld.com/view/DCS_singleton_world)
|
||||
-- @field #ENUMS
|
||||
ENUMS = {}
|
||||
|
||||
--- Rules of Engagement.
|
||||
-- @type ENUMS.ROE
|
||||
ENUMS.ROE = {
|
||||
HoldFire = 1,
|
||||
ReturnFire = 2,
|
||||
OpenFire = 3,
|
||||
WeaponFree = 4
|
||||
}
|
||||
|
||||
|
||||
--- Reaction On Thrat.
|
||||
-- @type ENUMS.ROT
|
||||
ENUMS.ROT = {
|
||||
NoReaction = 1,
|
||||
PassiveDefense = 2,
|
||||
@@ -22,10 +37,10 @@ ENUMS.ROT = {
|
||||
Vertical = 4
|
||||
}
|
||||
|
||||
--- Weapon types
|
||||
-- @type ENUMS.WeaponFlag
|
||||
ENUMS.WeaponFlag={
|
||||
-- Auto
|
||||
Auto=1073741822,
|
||||
-- Bombs
|
||||
Auto=1073741822, --Auto
|
||||
LGB=2,
|
||||
TvGB=4,
|
||||
SNSGB=8,
|
||||
@@ -46,4 +61,23 @@ ENUMS.WeaponFlag={
|
||||
CandleRocket=8192,
|
||||
HeavyRocket=16384,
|
||||
AnyRocket=30720 -- (LightRocket + MarkerRocket + CandleRocket + HeavyRocket)
|
||||
}
|
||||
|
||||
ENUMS.MissionTask={
|
||||
NOTHING="Nothing",
|
||||
AFAC="AFAC",
|
||||
ANTISHIPSTRIKE="Anti-ship Strike",
|
||||
AWACS="AWACS",
|
||||
CAP="CAP",
|
||||
CAS="CAS",
|
||||
ESCORT="Escort",
|
||||
FIGHTERSWEEP="Fighter Sweep",
|
||||
GROUNDATTACK="Ground Attack",
|
||||
INTERCEPT="Intercept",
|
||||
PINPOINTSTRIKE="Pinpoint Strike",
|
||||
RECONNAISSANCE="Reconnaissance",
|
||||
REFUELING="Refueling",
|
||||
RUNWAYATTACK="Runway Attack",
|
||||
SEAD="SEAD",
|
||||
TRANSPORT="Transport",
|
||||
}
|
||||
@@ -920,11 +920,11 @@ function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, D
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
attackQty = AttackQty or 1,
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
direction = Direction and math.rad(Direction) or 0,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
altitude = Altitude or 2000,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
attackType = Divebomb and "Dive" or nil,
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
--
|
||||
-- ### Author: **FlightControl**
|
||||
--
|
||||
-- ### Contributions:
|
||||
-- ### Contributions: **funkyfranky**
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
@@ -48,6 +48,10 @@ STATIC = {
|
||||
}
|
||||
|
||||
|
||||
--- Register a static object.
|
||||
-- @param #STATIC self
|
||||
-- @param #string StaticName Name of the static object.
|
||||
-- @return #STATIC self
|
||||
function STATIC:Register( StaticName )
|
||||
local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) )
|
||||
self.StaticName = StaticName
|
||||
@@ -71,21 +75,19 @@ end
|
||||
-- @param #STATIC self
|
||||
-- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor.
|
||||
-- @param #boolean RaiseError Raise an error if not found.
|
||||
-- @return #STATIC
|
||||
function STATIC:FindByName( StaticName, RaiseError )
|
||||
-- @return #STATIC self or *nil*
|
||||
function STATIC:FindByName( StaticName )
|
||||
|
||||
-- Find static in DB.
|
||||
local StaticFound = _DATABASE:FindStatic( StaticName )
|
||||
|
||||
-- Set static name.
|
||||
self.StaticName = StaticName
|
||||
|
||||
if StaticFound then
|
||||
StaticFound:F3( { StaticName } )
|
||||
return StaticFound
|
||||
end
|
||||
|
||||
if RaiseError == nil or RaiseError == true then
|
||||
error( "STATIC not found for: " .. StaticName )
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user