Skip to content

Commit

Permalink
Static 2.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
FlightControl-User committed Oct 31, 2017
1 parent cf28cca commit e95522f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 52 deletions.
63 changes: 33 additions & 30 deletions Moose Mission Setup/Moose.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20171029_1956' )
env.info( 'Moose Generation Timestamp: 20171031_1115' )

--- Various routines
-- @module routines
Expand Down Expand Up @@ -37445,8 +37445,6 @@ end
-- @field #string skill Skill of AI.
-- @field #boolean ATCswitch Enable/disable ATC if set to true/false.
-- @field #string parking_id String with a special parking ID for the aircraft.
-- @field #number wp_final Index of the final waypoint.
-- @field #number wp_holding Index of the holding waypoint.
-- @field #boolean radio If true/false disables radio messages from the RAT groups.
-- @field #number frequency Radio frequency used by the RAT groups.
-- @field #string modulation Ratio modulation. Either "FM" or "AM".
Expand Down Expand Up @@ -37666,8 +37664,6 @@ RAT={
skill="High", -- Skill of AI.
ATCswitch=true, -- Enable ATC.
parking_id=nil, -- Specific parking ID when aircraft are spawned at airports.
wp_final=nil, -- Index of the final waypoint.
wp_holding=nil, -- Index of the holding waypoint.
radio=nil, -- If true/false disables radio messages from the RAT groups.
frequency=nil, -- Radio frequency used by the RAT groups.
modulation=nil, -- Ratio modulation. Either "FM" or "AM".
Expand Down Expand Up @@ -37784,7 +37780,7 @@ RAT.id="RAT | "

--- RAT version.
-- @field #string version
RAT.version="2.0.0"
RAT.version="2.0.1"

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -38058,15 +38054,6 @@ function RAT:_CheckConsistency()
self.Ndeparture_Zones=self.Ndeparture_Zones+1
end
end

-- Count destination airports and zones.
for _,name in pairs(self.destination_ports) do
if self:_AirportExists(name) then
self.Ndestination_Airports=self.Ndestination_Airports+1
elseif self:_ZoneExists(name) then
self.Ndestination_Zones=self.Ndestination_Zones+1
end
end

-- What can go wrong?
-- Only zones but not takeoff air == > Enable takeoff air.
Expand All @@ -38085,6 +38072,16 @@ function RAT:_CheckConsistency()

-- User has used SetDestination()
if not self.random_destination then

-- Count destination airports and zones.
for _,name in pairs(self.destination_ports) do
if self:_AirportExists(name) then
self.Ndestination_Airports=self.Ndestination_Airports+1
elseif self:_ZoneExists(name) then
self.Ndestination_Zones=self.Ndestination_Zones+1
end
end

-- One zone specified as destination ==> Enable destination zone.
-- This does not apply to return zone because the destination is the zone and not the final destination which can be an airport.
if self.Ndestination_Zones>0 and self.landing~=RAT.wp.air and not self.returnzone then
Expand Down Expand Up @@ -38769,23 +38766,23 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
-- Set takeoff type.
local takeoff=self.takeoff
local landing=self.landing

-- Random choice between cold and hot.
if self.takeoff==RAT.wp.coldorhot then
local temp={RAT.wp.cold, RAT.wp.hot}
takeoff=temp[math.random(2)]
end


-- Overrule takeoff/landing by what comes in.
if _takeoff then
takeoff=_takeoff
end
if _landing then
landing=_landing
end

-- Random choice between cold and hot.
if takeoff==RAT.wp.coldorhot then
local temp={RAT.wp.cold, RAT.wp.hot}
takeoff=temp[math.random(2)]
end

-- Set flight plan.
local departure, destination, waypoints = self:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
local departure, destination, waypoints, WPholding, WPfinal = self:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)

-- Return nil if we could not find a departure destination or waypoints
if not (departure and destination and waypoints) then
Expand Down Expand Up @@ -38869,6 +38866,8 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
-- Each aircraft gets its own takeoff type.
self.ratcraft[self.SpawnIndex].takeoff=takeoff
self.ratcraft[self.SpawnIndex].landing=landing
self.ratcraft[self.SpawnIndex].wpholding=WPholding
self.ratcraft[self.SpawnIndex].wpfinal=WPfinal

-- Livery
self.ratcraft[self.SpawnIndex].livery=livery
Expand Down Expand Up @@ -39100,7 +39099,6 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
-- Departure airport or zone.
local departure=nil
if _departure then

if self:_AirportExists(_departure) then
-- Check if new departure is an airport.
departure=AIRBASE:FindByName(_departure)
Expand Down Expand Up @@ -39518,6 +39516,8 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
-- Waypoints and coordinates
local wp={}
local c={}
local wpholding=nil
local wpfinal=nil

-- Departure/Take-off
c[#c+1]=Pdeparture
Expand Down Expand Up @@ -39615,7 +39615,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
wp[#wp+1]=self:_Waypoint(#wp+1, RAT.wp.holding, c[#wp+1], VxHolding, H_holding+h_holding)
self.waypointdescriptions[#wp]="Holding Point"
self.waypointstatus[#wp]=RAT.status.Holding
self.wp_holding=#wp
wpholding=#wp

-- Final destination.
c[#c+1]=Pdestination
Expand All @@ -39626,7 +39626,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
end

-- Final Waypoint
self.wp_final=#wp
wpfinal=#wp

-- Fill table with waypoints.
local waypoints={}
Expand All @@ -39640,9 +39640,9 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
-- Return departure, destination and waypoints.
if self.returnzone then
-- We return the actual zone here because returning the departure leads to problems with commute.
return departure, destination_returnzone, waypoints
return departure, destination_returnzone, waypoints, wpholding, wpfinal
else
return departure, destination, waypoints
return departure, destination, waypoints, wpholding, wpfinal
end

end
Expand Down Expand Up @@ -40793,6 +40793,9 @@ function RAT._WaypointFunction(group, rat, wp)
local departure=rat.ratcraft[sdx].departure:GetName()
local destination=rat.ratcraft[sdx].destination:GetName()
local landing=rat.ratcraft[sdx].landing
local WPholding=rat.ratcraft[sdx].wpholding
local WPfinal=rat.ratcraft[sdx].wpfinal


-- For messages
local text
Expand All @@ -40807,7 +40810,7 @@ function RAT._WaypointFunction(group, rat, wp)
--rat.ratcraft[sdx].status=status
rat:_SetStatus(group, status)

if wp==rat.wp_holding then
if wp==WPholding then

-- Aircraft arrived at holding point
text=string.format("Flight %s to %s ATC: Holding and awaiting landing clearance.", group:GetName(), destination)
Expand All @@ -40820,7 +40823,7 @@ function RAT._WaypointFunction(group, rat, wp)
end
end

if wp==rat.wp_final then
if wp==WPfinal then
text=string.format("Flight %s arrived at final destination %s.", group:GetName(), destination)
MESSAGE:New(text, 10):ToAllIf(rat.reportstatus)
env.info(RAT.id..text)
Expand Down
48 changes: 26 additions & 22 deletions Moose Mission Setup/Moose_.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
env.info('*** MOOSE STATIC INCLUDE START *** ')
env.info('Moose Generation Timestamp: 20171029_1956')
env.info('Moose Generation Timestamp: 20171031_1115')
env.setErrorMessageBoxEnabled(false)
routines={}
routines.majorVersion=3
Expand Down Expand Up @@ -18423,8 +18423,6 @@ livery=nil,
skill="High",
ATCswitch=true,
parking_id=nil,
wp_final=nil,
wp_holding=nil,
radio=nil,
frequency=nil,
modulation=nil,
Expand Down Expand Up @@ -18501,7 +18499,7 @@ delay=240,
RAT.markerid=0
RAT.MenuF10=nil
RAT.id="RAT | "
RAT.version="2.0.0"
RAT.version="2.0.1"
function RAT:New(groupname,alias)
env.info(RAT.id.."Version "..RAT.version)
env.info(RAT.id.."Creating new RAT object from template: "..groupname)
Expand Down Expand Up @@ -18649,13 +18647,6 @@ elseif self:_ZoneExists(name)then
self.Ndeparture_Zones=self.Ndeparture_Zones+1
end
end
for _,name in pairs(self.destination_ports)do
if self:_AirportExists(name)then
self.Ndestination_Airports=self.Ndestination_Airports+1
elseif self:_ZoneExists(name)then
self.Ndestination_Zones=self.Ndestination_Zones+1
end
end
if self.Ndeparture_Zones>0 and self.takeoff~=RAT.wp.air then
self.takeoff=RAT.wp.air
env.error(RAT.id.."At least one zone defined as departure and takeoff is NOT set to air. Enabling air start!")
Expand All @@ -18668,6 +18659,13 @@ MESSAGE:New(text,30):ToAll()
end
end
if not self.random_destination then
for _,name in pairs(self.destination_ports)do
if self:_AirportExists(name)then
self.Ndestination_Airports=self.Ndestination_Airports+1
elseif self:_ZoneExists(name)then
self.Ndestination_Zones=self.Ndestination_Zones+1
end
end
if self.Ndestination_Zones>0 and self.landing~=RAT.wp.air and not self.returnzone then
self.landing=RAT.wp.air
self.destinationzone=true
Expand Down Expand Up @@ -19041,17 +19039,17 @@ end
function RAT:_SpawnWithRoute(_departure,_destination,_takeoff,_landing,_livery,_waypoint)
local takeoff=self.takeoff
local landing=self.landing
if self.takeoff==RAT.wp.coldorhot then
local temp={RAT.wp.cold,RAT.wp.hot}
takeoff=temp[math.random(2)]
end
if _takeoff then
takeoff=_takeoff
end
if _landing then
landing=_landing
end
local departure,destination,waypoints=self:_SetRoute(takeoff,landing,_departure,_destination,_waypoint)
if takeoff==RAT.wp.coldorhot then
local temp={RAT.wp.cold,RAT.wp.hot}
takeoff=temp[math.random(2)]
end
local departure,destination,waypoints,WPholding,WPfinal=self:_SetRoute(takeoff,landing,_departure,_destination,_waypoint)
if not(departure and destination and waypoints)then
return nil
end
Expand Down Expand Up @@ -19101,6 +19099,8 @@ self.ratcraft[self.SpawnIndex]["Pnow"]=group:GetCoordinate()
self.ratcraft[self.SpawnIndex]["Distance"]=0
self.ratcraft[self.SpawnIndex].takeoff=takeoff
self.ratcraft[self.SpawnIndex].landing=landing
self.ratcraft[self.SpawnIndex].wpholding=WPholding
self.ratcraft[self.SpawnIndex].wpfinal=WPfinal
self.ratcraft[self.SpawnIndex].livery=livery
self.ratcraft[self.SpawnIndex].despawnme=false
if self.f10menu then
Expand Down Expand Up @@ -19502,6 +19502,8 @@ d_cruise=100
end
local wp={}
local c={}
local wpholding=nil
local wpfinal=nil
c[#c+1]=Pdeparture
wp[#wp+1]=self:_Waypoint(#wp+1,takeoff,c[#wp+1],VxClimb,H_departure,departure)
self.waypointdescriptions[#wp]="Departure"
Expand Down Expand Up @@ -19565,22 +19567,22 @@ c[#c+1]=Pholding
wp[#wp+1]=self:_Waypoint(#wp+1,RAT.wp.holding,c[#wp+1],VxHolding,H_holding+h_holding)
self.waypointdescriptions[#wp]="Holding Point"
self.waypointstatus[#wp]=RAT.status.Holding
self.wp_holding=#wp
wpholding=#wp
c[#c+1]=Pdestination
wp[#wp+1]=self:_Waypoint(#wp+1,landing,c[#wp+1],VxFinal,H_destination,destination)
self.waypointdescriptions[#wp]="Destination"
self.waypointstatus[#wp]=RAT.status.Destination
end
self.wp_final=#wp
wpfinal=#wp
local waypoints={}
for _,p in ipairs(wp)do
table.insert(waypoints,p)
end
self:_Routeinfo(waypoints,"Waypoint info in set_route:")
if self.returnzone then
return departure,destination_returnzone,waypoints
return departure,destination_returnzone,waypoints,wpholding,wpfinal
else
return departure,destination,waypoints
return departure,destination,waypoints,wpholding,wpfinal
end
end
function RAT:_PickDeparture(takeoff)
Expand Down Expand Up @@ -20298,20 +20300,22 @@ local sdx=rat:GetSpawnIndexFromGroup(group)
local departure=rat.ratcraft[sdx].departure:GetName()
local destination=rat.ratcraft[sdx].destination:GetName()
local landing=rat.ratcraft[sdx].landing
local WPholding=rat.ratcraft[sdx].wpholding
local WPfinal=rat.ratcraft[sdx].wpfinal
local text
text=string.format("Flight %s passing waypoint #%d %s.",group:GetName(),wp,rat.waypointdescriptions[wp])
env.info(RAT.id..text)
local status=rat.waypointstatus[wp]
rat:_SetStatus(group,status)
if wp==rat.wp_holding then
if wp==WPholding then
text=string.format("Flight %s to %s ATC: Holding and awaiting landing clearance.",group:GetName(),destination)
MESSAGE:New(text,10):ToAllIf(rat.reportstatus)
if rat.ATCswitch then
MENU_MISSION_COMMAND:New("Clear for landing",rat.Menu[rat.SubMenuName].groups[sdx],rat.ClearForLanding,rat,group:GetName())
rat:_ATCRegisterFlight(group:GetName(),Tnow)
end
end
if wp==rat.wp_final then
if wp==WPfinal then
text=string.format("Flight %s arrived at final destination %s.",group:GetName(),destination)
MESSAGE:New(text,10):ToAllIf(rat.reportstatus)
env.info(RAT.id..text)
Expand Down

0 comments on commit e95522f

Please sign in to comment.