mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-12 04:31:09 +00:00
Ops
This commit is contained in:
@@ -2589,6 +2589,34 @@ function WAREHOUSE:SetAutoDefenceOff()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set valid parking spot IDs.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #table ParkingIDs Table of numbers.
|
||||
-- @return #WAREHOUSE self
|
||||
function WAREHOUSE:SetParkingIDs(ParkingIDs)
|
||||
self.parkingIDs=ParkingIDs
|
||||
return self
|
||||
end
|
||||
|
||||
--- Check parking ID.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot.
|
||||
-- @return #boolean If true, parking is valid.
|
||||
function WAREHOUSE:_CheckParkingValid(spot)
|
||||
if self.parkingIDs==nil then
|
||||
return true
|
||||
end
|
||||
|
||||
for _,id in pairs(self.parkingIDs or {}) do
|
||||
if spot.TerminalID==id then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
--- Enable auto save of warehouse assets at mission end event.
|
||||
-- @param #WAREHOUSE self
|
||||
-- @param #string path Path where to save the asset data file.
|
||||
@@ -7500,7 +7528,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
||||
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||
|
||||
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) then
|
||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) then
|
||||
|
||||
-- Coordinate of the parking spot.
|
||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||
|
||||
@@ -453,19 +453,19 @@ end
|
||||
|
||||
--- Create a new generic patrol point.
|
||||
-- @param #AIRWING self
|
||||
-- @param Core.Point#COORDINATE Coordinate Coordinate of the patrol point.
|
||||
-- @param #number Heading Heading in degrees.
|
||||
-- @param #number LegLength Length of race-track orbit in NM.
|
||||
-- @param #number Altitude Orbit altitude in feet.
|
||||
-- @param #number Speed Orbit speed in knots.
|
||||
-- @param Core.Point#COORDINATE Coordinate Coordinate of the patrol point. Default 10-15 NM away from the location of the airwing.
|
||||
-- @param #number Heading Heading in degrees. Default random (0, 360] degrees.
|
||||
-- @param #number LegLength Length of race-track orbit in NM. Default 15 NM.
|
||||
-- @param #number Altitude Orbit altitude in feet. Default random between Angels 10 and 20.
|
||||
-- @param #number Speed Orbit speed in knots. Default 350 knots.
|
||||
-- @return #AIRWING.PatrolData Patrol point table.
|
||||
function AIRWING:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed)
|
||||
|
||||
local cappoint={} --#AIRWING.PatrolData
|
||||
cappoint.coord=Coordinate
|
||||
cappoint.heading=Heading or 090
|
||||
cappoint.coord=Coordinate or self:GetCoordinate():Translate(UTILS.NMToMeters(math.random(10, 15)), math.random(360))
|
||||
cappoint.heading=Heading or math.random(360)
|
||||
cappoint.leg=LegLength or 15
|
||||
cappoint.altitude=Altitude
|
||||
cappoint.altitude=Altitude or math.random(10,20)*1000
|
||||
cappoint.speed=Speed or 350
|
||||
cappoint.noccupied=0
|
||||
|
||||
@@ -627,15 +627,8 @@ function AIRWING:_GetPatrolData(PatrolPoints)
|
||||
return PatrolPoints[1]
|
||||
|
||||
else
|
||||
|
||||
|
||||
local Coordinate=self:GetCoordinate()
|
||||
local Heading=math.random(360)
|
||||
local LegLength=math.random(10, 15)
|
||||
local Altitude=math.random(10,15)*1000
|
||||
local Speed=math.random(250, 350)
|
||||
|
||||
return self:NewPatrolPoint(Coordinate, Heading, LegLength, Altitude, Speed)
|
||||
return self:NewPatrolPoint()
|
||||
|
||||
end
|
||||
|
||||
@@ -695,6 +688,8 @@ function AIRWING:CheckTANKER()
|
||||
|
||||
local patrol=self:_GetPatrolData(self.pointsTANKER)
|
||||
|
||||
patrol.coord:MarkToAll("Patrol point boom")
|
||||
|
||||
local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 0)
|
||||
|
||||
mission.patroldata=patrol
|
||||
@@ -709,6 +704,8 @@ function AIRWING:CheckTANKER()
|
||||
|
||||
local patrol=self:_GetPatrolData(self.pointsTANKER)
|
||||
|
||||
patrol.coord:MarkToAll("Patrol point probe")
|
||||
|
||||
local mission=AUFTRAG:NewTANKER(patrol.coord, patrol.speed, patrol.heading, patrol.leg, patrol.altitude, 1)
|
||||
|
||||
mission.patroldata=patrol
|
||||
|
||||
@@ -356,6 +356,8 @@ function AUFTRAG:NewORBIT(Coordinate, Speed, Heading, Leg, Altitude)
|
||||
end
|
||||
|
||||
auftrag.missionAltitude=auftrag.orbitCoord.y*0.9
|
||||
|
||||
auftrag.missionFraction=0.9
|
||||
|
||||
auftrag.DCStask=auftrag:GetDCSMissionTask()
|
||||
|
||||
@@ -602,7 +604,7 @@ end
|
||||
-- @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.
|
||||
-- @param #table TargetTypes Types of targets to engage automatically. Default is {"Air"}, i.e. all enemy airborne units. Set to {} for a simple "FOLLOW" mission.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetTypes)
|
||||
|
||||
|
||||
@@ -3495,7 +3495,7 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
|
||||
end
|
||||
|
||||
-- Add enroute tasks.
|
||||
for _,task in mission.enrouteTasks do
|
||||
for _,task in pairs(mission.enrouteTasks) do
|
||||
self:AddTaskEnroute(task)
|
||||
end
|
||||
|
||||
@@ -3503,7 +3503,7 @@ function FLIGHTGROUP:RouteToMission(mission, delay)
|
||||
local speed=UTILS.KmphToKnots(math.min(self.speedmax*0.8, 1000))
|
||||
|
||||
-- Add waypoint.
|
||||
self:AddWaypointAir(waypointcoord, nextwaypoint, self.speedmax*0.8, false)
|
||||
self:AddWaypointAir(waypointcoord, nextwaypoint, speed, false)
|
||||
|
||||
-- Add waypoint task. UpdateRoute is called inside.
|
||||
local waypointtask=self:AddTaskWaypoint(mission.DCStask, nextwaypoint, mission.name, mission.prio, mission.duration)
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
-- @field #number Ngroups Number of asset flight groups this squadron has.
|
||||
-- @field #number engageRange Engagement range in meters.
|
||||
-- @field #string attribute Generalized attribute of the squadron template group.
|
||||
-- @field #number refuelSystem For tanker squads, the refuel system used.
|
||||
-- @field #number tankerSystem For tanker squads, the refuel system used (boom=0 or probpe=1). Default nil.
|
||||
-- @field #number refuelSystem For refuelable squads, the refuel system used (boom=0 or probpe=1). Default nil.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- Be surprised!
|
||||
@@ -54,6 +55,7 @@ SQUADRON = {
|
||||
airwing = nil,
|
||||
Ngroups = nil,
|
||||
engageRange = nil,
|
||||
tankerSystem = nil,
|
||||
refuelSystem = nil,
|
||||
}
|
||||
|
||||
@@ -70,7 +72,7 @@ SQUADRON.version="0.0.3"
|
||||
-- TODO list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Engage radius.
|
||||
-- DONE: Engage radius.
|
||||
-- TODO: Modex.
|
||||
-- TODO: Call signs.
|
||||
|
||||
@@ -114,7 +116,8 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
||||
|
||||
self.attribute=self.templategroup:GetAttribute()
|
||||
|
||||
_,self.refuelSystem=self.templategroup:GetUnit(1):IsTanker()
|
||||
_,self.refuelSystem=self.templategroup:GetUnit(1):IsRefuelable()
|
||||
_,self.tankerSystem=self.templategroup:GetUnit(1):IsTanker()
|
||||
|
||||
|
||||
-- Start State.
|
||||
@@ -216,12 +219,19 @@ function SQUADRON:SetMissonTypes(MissionTypes)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get mission types this squadron is able to perform.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #table MissionTypes Table of mission types.
|
||||
function SQUADRON:GetMissonTypes()
|
||||
return self.missiontypes
|
||||
end
|
||||
|
||||
--- Set max engagement range.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #number EngageRange Engagement range in NM. Default 250 NM.
|
||||
-- @param #number EngageRange Engagement range in NM. Default 80 NM.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetEngagementRange(EngageRange)
|
||||
self.engageRange=UTILS.NMToMeters(EngageRange or 250)
|
||||
self.engageRange=UTILS.NMToMeters(EngageRange or 80)
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -334,9 +344,10 @@ function SQUADRON:CanMission(Mission)
|
||||
-- Check that tanker mission
|
||||
if cando and Mission.type==AUFTRAG.Type.TANKER then
|
||||
|
||||
if Mission.refuelSystem and Mission.refuelSystem==self.refuelSystem then
|
||||
if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then
|
||||
-- Correct refueling system.
|
||||
else
|
||||
env.info(string.format("wrong refuling system mi=%s ta=%s", tostring(Mission.refuelSystem), tostring(self.tankerSystem)))
|
||||
cando=false
|
||||
end
|
||||
|
||||
|
||||
@@ -447,7 +447,7 @@ function UNIT:IsRefuelable()
|
||||
|
||||
local system=nil
|
||||
|
||||
local Desc=self:GetDesc().attributes
|
||||
local Desc=self:GetDesc()
|
||||
if Desc and Desc.tankerType then
|
||||
system=Desc.tankerType
|
||||
end
|
||||
@@ -466,25 +466,26 @@ function UNIT:IsTanker()
|
||||
|
||||
local system=nil
|
||||
|
||||
local Desc=self:GetDesc().attributes
|
||||
local Desc=self:GetDesc()
|
||||
if Desc and Desc.tankerType then
|
||||
system=Desc.tankerType
|
||||
end
|
||||
|
||||
local typename=self:GetTypeName()
|
||||
|
||||
if typename=="IL-78M" then
|
||||
system=1 --probe
|
||||
elseif typename=="KC130" then
|
||||
system=-1 --?
|
||||
system=1 --probe
|
||||
elseif typename=="KC135BDA" then
|
||||
system=-1 --?
|
||||
elseif typename=="KC135BDA" then
|
||||
system=-1 --?
|
||||
system=1 --probe
|
||||
elseif typename=="KC135MPRS" then
|
||||
system=0 --boom
|
||||
system=1 --probe
|
||||
elseif typename=="S-3B Tanker" then
|
||||
system=1 --probe
|
||||
end
|
||||
|
||||
env.info(string.format("unit %s type=%s: tanker=%s system=%s", tostring(self.UnitName), tostring(typename), tostring(tanker), tostring(system)))
|
||||
|
||||
return tanker, system
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user