mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AIRBOSS v0.5.4
This commit is contained in:
parent
07f313a4a6
commit
5201c73d35
@ -400,18 +400,18 @@ AIRBOSS = {
|
|||||||
|
|
||||||
--- Player aircraft types capable of landing on carriers.
|
--- Player aircraft types capable of landing on carriers.
|
||||||
-- @type AIRBOSS.AircraftPlayer
|
-- @type AIRBOSS.AircraftPlayer
|
||||||
-- @field #string AV8B AV-8B Night Harrier.
|
-- @field #string AV8B AV-8B Night Harrier (not yet supported).
|
||||||
-- @field #string HORNET F/A-18C Lot 20 Hornet.
|
-- @field #string HORNET F/A-18C Lot 20 Hornet.
|
||||||
-- @field #string A4EC Community A-4E-C mod.
|
-- @field #string A4EC Community A-4E-C mod.
|
||||||
AIRBOSS.AircraftPlayer={
|
AIRBOSS.AircraftPlayer={
|
||||||
AV8B="AV8BNA",
|
--AV8B="AV8BNA",
|
||||||
HORNET="FA-18C_hornet",
|
HORNET="FA-18C_hornet",
|
||||||
A4EC="A-4E-C",
|
A4EC="A-4E-C",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Aircraft types capable of landing on carrier (human+AI).
|
--- Aircraft types capable of landing on carrier (human+AI).
|
||||||
-- @type AIRBOSS.AircraftCarrier
|
-- @type AIRBOSS.AircraftCarrier
|
||||||
-- @field #string AV8B AV-8B Night Harrier.
|
-- @field #string AV8B AV-8B Night Harrier (not yet supported).
|
||||||
-- @field #string HORNET F/A-18C Lot 20 Hornet.
|
-- @field #string HORNET F/A-18C Lot 20 Hornet.
|
||||||
-- @field #string A4EC Community A-4E mod.
|
-- @field #string A4EC Community A-4E mod.
|
||||||
-- @field #string S3B Lockheed S-3B Viking.
|
-- @field #string S3B Lockheed S-3B Viking.
|
||||||
@ -420,7 +420,7 @@ AIRBOSS.AircraftPlayer={
|
|||||||
-- @field #string FA18C F/A-18C Hornet (AI).
|
-- @field #string FA18C F/A-18C Hornet (AI).
|
||||||
-- @field #string F14A F-14A (AI).
|
-- @field #string F14A F-14A (AI).
|
||||||
AIRBOSS.AircraftCarrier={
|
AIRBOSS.AircraftCarrier={
|
||||||
AV8B="AV8BNA",
|
--AV8B="AV8BNA",
|
||||||
HORNET="FA-18C_hornet",
|
HORNET="FA-18C_hornet",
|
||||||
A4EC="A-4E-C",
|
A4EC="A-4E-C",
|
||||||
S3B="S-3B",
|
S3B="S-3B",
|
||||||
@ -929,7 +929,7 @@ AIRBOSS.MenuF10={}
|
|||||||
|
|
||||||
--- Airboss class version.
|
--- Airboss class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRBOSS.version="0.5.3w"
|
AIRBOSS.version="0.5.4"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -1696,6 +1696,8 @@ function AIRBOSS:_CheckPlayerPatternDistance(player)
|
|||||||
-- Get angle between the two orientation vectors. Does the player aircraft nose point into the direction of the other aircraft? (Could be behind him!)
|
-- Get angle between the two orientation vectors. Does the player aircraft nose point into the direction of the other aircraft? (Could be behind him!)
|
||||||
local rhdg=math.deg(math.acos(UTILS.VecDot(vec12,vec1)/UTILS.VecNorm(vec12)/UTILS.VecNorm(vec1)))
|
local rhdg=math.deg(math.acos(UTILS.VecDot(vec12,vec1)/UTILS.VecNorm(vec12)/UTILS.VecNorm(vec1)))
|
||||||
|
|
||||||
|
-- TODO: Check altitude difference?
|
||||||
|
|
||||||
-- Direction in 30 degrees cone and distance < 200 meters.
|
-- Direction in 30 degrees cone and distance < 200 meters.
|
||||||
-- TODO: Test parameter values.
|
-- TODO: Test parameter values.
|
||||||
if math.abs(rhdg)<30 and dist<200 then
|
if math.abs(rhdg)<30 and dist<200 then
|
||||||
@ -2744,17 +2746,16 @@ function AIRBOSS:_MarshalAI(flight, nstack)
|
|||||||
|
|
||||||
if flight.case==1 then
|
if flight.case==1 then
|
||||||
-- Waypoint "north" of carrier's holding zone.
|
-- Waypoint "north" of carrier's holding zone.
|
||||||
wp[2]=p1:Translate(UTILS.NMToMeters(10), hdg):WaypointAirTurningPoint(nil, SpeedTransit, {}, "Prepare Entering Case I Marshal Pattern")
|
--wp[2]=p1:Translate(UTILS.NMToMeters(10), hdg):WaypointAirTurningPoint(nil, SpeedTransit, {}, "Prepare Entering Case I Marshal Pattern")
|
||||||
-- Enter pattern from "north" to "south".
|
-- Enter pattern from "north" to "south".
|
||||||
wp[3]=p1:Translate( UTILS.NMToMeters(5), hdg):WaypointAirTurningPoint(nil, SpeedTransit, {TaskArrivedHolding}, "Entering Case I Marshal Pattern")
|
wp[2]=p1:Translate( UTILS.NMToMeters(10), hdg):WaypointAirTurningPoint(nil, SpeedTransit, {TaskArrivedHolding}, "Entering Case I Marshal Pattern")
|
||||||
else
|
else
|
||||||
-- TODO: Test and tune!
|
-- TODO: Test and tune!
|
||||||
wp[2]=p1:WaypointAirTurningPoint(nil, SpeedTransit, {TaskArrivedHolding}, "Entering Marshal Pattern")
|
wp[2]=p1:WaypointAirTurningPoint(nil, SpeedTransit, {TaskArrivedHolding}, "Entering Marshal Pattern")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Set up waypoints including collapsing the stack.
|
-- Set up waypoints including collapsing the stack.
|
||||||
for stack=nstack, 1, -1 do
|
for stack=nstack, 1, -1 do
|
||||||
|
|
||||||
@ -2794,7 +2795,8 @@ function AIRBOSS:_MarshalAI(flight, nstack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Waypoint.
|
-- Waypoint.
|
||||||
wp[#wp+1]=p0:WaypointAirTurningPoint(nil, SpeedTransit, {TaskOrbit}, text)
|
-- TODO: p0?
|
||||||
|
wp[#wp+1]=p1:WaypointAirTurningPoint(nil, SpeedTransit, {TaskOrbit}, text)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2817,14 +2819,15 @@ function AIRBOSS:_LandAI(flight)
|
|||||||
local Speed=UTILS.KnotsToKmph(272)
|
local Speed=UTILS.KnotsToKmph(272)
|
||||||
|
|
||||||
local Carrier=self:GetCoordinate()
|
local Carrier=self:GetCoordinate()
|
||||||
|
local hdg=self:GetHeading()
|
||||||
|
|
||||||
-- Waypoints array.
|
-- Waypoints array.
|
||||||
local wp={}
|
local wp={}
|
||||||
|
|
||||||
wp[#wp+1]=flight.group:GetCoordinate():WaypointAirTurningPoint(nil, Speed, {}, "Current position")
|
wp[#wp+1]=flight.group:GetCoordinate():WaypointAirTurningPoint(nil, Speed, {}, "Current position")
|
||||||
|
|
||||||
-- Landing waypoint.
|
-- Landing waypoint 5 NM behind carrier at 250 ASL.
|
||||||
wp[#wp+1]=self:GetCoordinate():SetAltitude(250):WaypointAirLanding(Speed, self.airbase, nil, "Landing")
|
wp[#wp+1]=self:GetCoordinate():Translate(-UTILS.NMToMeters(5), hdg):SetAltitude(250):WaypointAirLanding(Speed, self.airbase, nil, "Landing")
|
||||||
|
|
||||||
-- Reinit waypoints.
|
-- Reinit waypoints.
|
||||||
flight.group:WayPointInitialize(wp)
|
flight.group:WayPointInitialize(wp)
|
||||||
@ -2864,13 +2867,13 @@ function AIRBOSS:_GetMarshalAltitude(stack, case)
|
|||||||
angels0=2
|
angels0=2
|
||||||
|
|
||||||
-- Distance 2.5 NM.
|
-- Distance 2.5 NM.
|
||||||
Dist=UTILS.NMToMeters(2.5)
|
Dist=UTILS.NMToMeters(2.5*math.sqrt(2))
|
||||||
|
|
||||||
-- Get true heading of carrier.
|
-- Get true heading of carrier.
|
||||||
local hdg=self.carrier:GetHeading()
|
local hdg=self.carrier:GetHeading()
|
||||||
|
|
||||||
-- Center of holding pattern point. We give it a little head start -70 instead of -90 degrees.
|
-- Center of holding pattern point. We give it a little head start -70 instead of -90 degrees.
|
||||||
p1=Carrier:Translate(Dist, hdg-70)
|
p1=Carrier:Translate(Dist, hdg-45)
|
||||||
else
|
else
|
||||||
-- CASE II/III: Holding at 6000 ft on a racetrack pattern astern the carrier.
|
-- CASE II/III: Holding at 6000 ft on a racetrack pattern astern the carrier.
|
||||||
angels0=6
|
angels0=6
|
||||||
@ -3005,9 +3008,14 @@ function AIRBOSS:_CollapseMarshalStack(flight, nopattern)
|
|||||||
self:MessageToPlayer(mflight, text, "MARSHAL")
|
self:MessageToPlayer(mflight, text, "MARSHAL")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Also decrease flag for section members of flight.
|
-- Debug info.
|
||||||
|
self:I(string.format("Flight %s case %d is changing marshal stack %d --> %d.", mflight.groupname, mflight.case, mstack, mstack-1))
|
||||||
|
|
||||||
|
-- Loop over section members.
|
||||||
for _,_sec in pairs(mflight.section) do
|
for _,_sec in pairs(mflight.section) do
|
||||||
local sec=_sec --#AIRBOSS.PlayerData
|
local sec=_sec --#AIRBOSS.PlayerData
|
||||||
|
|
||||||
|
-- Also decrease flag for section members of flight.
|
||||||
sec.flag:Set(mstack-1)
|
sec.flag:Set(mstack-1)
|
||||||
|
|
||||||
-- Inform section member.
|
-- Inform section member.
|
||||||
@ -3029,30 +3037,30 @@ function AIRBOSS:_CollapseMarshalStack(flight, nopattern)
|
|||||||
-- Debug
|
-- Debug
|
||||||
self:I(self.lid..string.format("Flight %s is leaving stack but not going to pattern.", flight.groupname))
|
self:I(self.lid..string.format("Flight %s is leaving stack but not going to pattern.", flight.groupname))
|
||||||
|
|
||||||
-- New time stamp for time in pattern.
|
-- Set flag to -1. -1 is rather arbitrary. Should not be -100 or positive.
|
||||||
flight.time=timer.getAbsTime()
|
|
||||||
|
|
||||||
-- Set flag to -1.
|
|
||||||
flight.flag:Set(-1)
|
flight.flag:Set(-1)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Debug
|
-- Debug
|
||||||
self:I(self.lid..string.format("Flight %s is commencing pattern.", flight.groupname))
|
local Tmarshal=UTILS.SecondsToClock(timer.getAbsTime()-flight.time)
|
||||||
|
self:I(self.lid..string.format("Flight %s is leaving marshal after %s and going pattern.", flight.groupname, Tmarshal))
|
||||||
-- New time stamp for time in pattern.
|
|
||||||
flight.time=timer.getAbsTime()
|
|
||||||
|
|
||||||
-- Decrease flag.
|
-- Decrease flag.
|
||||||
flight.flag:Set(stack-1)
|
flight.flag:Set(stack-1)
|
||||||
|
|
||||||
-- Add flight to pattern queue.
|
-- Add flight to pattern queue.
|
||||||
table.insert(self.Qpattern, flight)
|
table.insert(self.Qpattern, flight)
|
||||||
|
|
||||||
-- Remove flight from marshal queue.
|
|
||||||
self:_RemoveGroupFromQueue(self.Qmarshal, flight.group)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- New time stamp for time in pattern.
|
||||||
|
flight.time=timer.getAbsTime()
|
||||||
|
|
||||||
|
|
||||||
|
-- Remove flight from marshal queue.
|
||||||
|
self:_RemoveGroupFromQueue(self.Qmarshal, flight.group)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get next free stack depending on recovery case. Note that here we assume one flight group per stack!
|
--- Get next free stack depending on recovery case. Note that here we assume one flight group per stack!
|
||||||
@ -3150,7 +3158,8 @@ function AIRBOSS:_PrintQueue(queue, name)
|
|||||||
local flight=_flight --#AIRBOSS.FlightGroup
|
local flight=_flight --#AIRBOSS.FlightGroup
|
||||||
|
|
||||||
-- Timestamp.
|
-- Timestamp.
|
||||||
local clock=UTILS.SecondsToClock(flight.time)
|
--local clock=UTILS.SecondsToClock(timer.getAbsTime()-flight.time)
|
||||||
|
local clock=timer.getAbsTime()-flight.time
|
||||||
-- Recovery case of flight.
|
-- Recovery case of flight.
|
||||||
local case=flight.case
|
local case=flight.case
|
||||||
-- Stack and stack alt.
|
-- Stack and stack alt.
|
||||||
@ -3165,6 +3174,11 @@ function AIRBOSS:_PrintQueue(queue, name)
|
|||||||
local nsec=#flight.section
|
local nsec=#flight.section
|
||||||
local actype=flight.actype
|
local actype=flight.actype
|
||||||
local onboard=flight.onboard
|
local onboard=flight.onboard
|
||||||
|
local holding="false"
|
||||||
|
if flight.holding then
|
||||||
|
holding="true"
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: Include player data.
|
-- TODO: Include player data.
|
||||||
--[[
|
--[[
|
||||||
if not flight.ai then
|
if not flight.ai then
|
||||||
@ -3182,8 +3196,11 @@ function AIRBOSS:_PrintQueue(queue, name)
|
|||||||
k=playerData.waveoff
|
k=playerData.waveoff
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
text=text..string.format("\n[%d] %s*%d (%s): lead=%s (%d), onboard=%s, stackalt=%d ft, flag=%d, case=%d, time=%s, fuel=%d, ai=%s",
|
text=text..string.format("\n[%d] %s*%d (%s): lead=%s (%d), onboard=%s, flag=%d, case=%d, time=%d, fuel=%d, ai=%s, holding=%s",
|
||||||
i, flight.groupname, flight.nunits, actype, lead, nsec, onboard, alt, stack, case, clock, fuel, ai)
|
i, flight.groupname, flight.nunits, actype, lead, nsec, onboard, stack, case, clock, fuel, ai, holding)
|
||||||
|
if flight.holding then
|
||||||
|
text=text..string.format(" stackalt=%d ft", alt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
@ -3226,6 +3243,7 @@ function AIRBOSS:_CreateFlightGroup(group)
|
|||||||
flight.seclead=flight.group:GetUnit(1):GetName() -- Sec lead is first unitname of group but player name for players.
|
flight.seclead=flight.group:GetUnit(1):GetName() -- Sec lead is first unitname of group but player name for players.
|
||||||
flight.section={}
|
flight.section={}
|
||||||
flight.ballcall=false
|
flight.ballcall=false
|
||||||
|
flight.holding=nil
|
||||||
|
|
||||||
-- Note, this should be re-set elsewhere!
|
-- Note, this should be re-set elsewhere!
|
||||||
flight.case=self.case
|
flight.case=self.case
|
||||||
@ -7642,6 +7660,9 @@ function AIRBOSS:_SetSection(_unitName)
|
|||||||
text=string.format("You are already in the Pattern queue. Setting section no possible any more!")
|
text=string.format("You are already in the Pattern queue. Setting section no possible any more!")
|
||||||
else
|
else
|
||||||
|
|
||||||
|
-- Init array
|
||||||
|
playerData.section={}
|
||||||
|
|
||||||
-- Loop over all registered flights.
|
-- Loop over all registered flights.
|
||||||
for _,_flight in pairs(self.flights) do
|
for _,_flight in pairs(self.flights) do
|
||||||
local flight=_flight --#AIRBOSS.FlightGroup
|
local flight=_flight --#AIRBOSS.FlightGroup
|
||||||
|
|||||||
@ -215,7 +215,7 @@ RECOVERYTANKER = {
|
|||||||
|
|
||||||
--- Class version.
|
--- Class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
RECOVERYTANKER.version="0.9.7"
|
RECOVERYTANKER.version="0.9.8"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -842,9 +842,9 @@ function RECOVERYTANKER:onafterPatternUpdate(From, Event, To)
|
|||||||
-- Waypoints array.
|
-- Waypoints array.
|
||||||
local wp={}
|
local wp={}
|
||||||
|
|
||||||
-- New waypoint with orbit pattern task.
|
-- New waypoint with orbit pattern task. Speed expected in km/h.
|
||||||
wp[1]=self.tanker:GetCoordinate():WaypointAirTurningPoint(nil , self.speed, {}, "Current Position")
|
wp[1]=self.tanker:GetCoordinate():WaypointAirTurningPoint(nil , UTILS.MpsToKmph(self.speed), {}, "Current Position")
|
||||||
wp[2]=p0:WaypointAirTurningPoint(nil, self.speed, {taskorbit}, "Tanker Orbit")
|
wp[2]=p0:WaypointAirTurningPoint(nil, UTILS.MpsToKmph(self.speed), {taskorbit}, "Tanker Orbit")
|
||||||
|
|
||||||
--local wp=self:_Pattern()
|
--local wp=self:_Pattern()
|
||||||
|
|
||||||
@ -900,7 +900,7 @@ function RECOVERYTANKER:_Pattern()
|
|||||||
local coord=p[i] --Core.Point#COORDINATE
|
local coord=p[i] --Core.Point#COORDINATE
|
||||||
coord:MarkToAll(string.format("Waypoint %d", i))
|
coord:MarkToAll(string.format("Waypoint %d", i))
|
||||||
--table.insert(wp, coord:WaypointAirFlyOverPoint(nil , self.speed))
|
--table.insert(wp, coord:WaypointAirFlyOverPoint(nil , self.speed))
|
||||||
table.insert(wp, coord:WaypointAirTurningPoint(nil , self.speed))
|
table.insert(wp, coord:WaypointAirTurningPoint(nil , UTILS.MpsToKmph(self.speed)))
|
||||||
end
|
end
|
||||||
|
|
||||||
return wp
|
return wp
|
||||||
@ -1098,11 +1098,11 @@ function RECOVERYTANKER:_InitRoute(dist, delay)
|
|||||||
-- Waypoints.
|
-- Waypoints.
|
||||||
local wp={}
|
local wp={}
|
||||||
if self.takeoff==SPAWN.Takeoff.Air then
|
if self.takeoff==SPAWN.Takeoff.Air then
|
||||||
wp[#wp+1]=self.tanker:GetCoordinate():SetAltitude(self.altitude):WaypointAirTurningPoint(nil, self.speed, {}, "Spawn Position")
|
wp[#wp+1]=self.tanker:GetCoordinate():SetAltitude(self.altitude):WaypointAirTurningPoint(nil, UTILS.MpsToKmph(self.speed), {}, "Spawn Position")
|
||||||
else
|
else
|
||||||
wp[#wp+1]=Carrier:WaypointAirTakeOffParking()
|
wp[#wp+1]=Carrier:WaypointAirTakeOffParking()
|
||||||
end
|
end
|
||||||
wp[#wp+1]=p:WaypointAirTurningPoint(nil, self.speed, {task}, "Begin Pattern")
|
wp[#wp+1]=p:WaypointAirTurningPoint(nil, UTILS.MpsToKmph(self.speed), {task}, "Begin Pattern")
|
||||||
|
|
||||||
-- Set route.
|
-- Set route.
|
||||||
self.tanker:Route(wp, delay)
|
self.tanker:Route(wp, delay)
|
||||||
|
|||||||
@ -558,7 +558,7 @@ function UTILS.SecondsToClock(seconds)
|
|||||||
-- Seconds of this day.
|
-- Seconds of this day.
|
||||||
local _seconds=seconds%(60*60*24)
|
local _seconds=seconds%(60*60*24)
|
||||||
|
|
||||||
if seconds <= 0 then
|
if seconds<0 then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
local hours = string.format("%02.f", math.floor(_seconds/3600))
|
local hours = string.format("%02.f", math.floor(_seconds/3600))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user