diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 97f014c1c..24db4a706 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -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 @@ -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". @@ -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". @@ -37784,7 +37780,7 @@ RAT.id="RAT | " --- RAT version. -- @field #string version -RAT.version="2.0.0" +RAT.version="2.0.1" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -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. @@ -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 @@ -38769,13 +38766,7 @@ 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 @@ -38783,9 +38774,15 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live 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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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={} @@ -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 @@ -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 @@ -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) @@ -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) diff --git a/Moose Mission Setup/Moose_.lua b/Moose Mission Setup/Moose_.lua index a7ee8d103..c4e61a269 100644 --- a/Moose Mission Setup/Moose_.lua +++ b/Moose Mission Setup/Moose_.lua @@ -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 @@ -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, @@ -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) @@ -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!") @@ -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 @@ -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 @@ -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 @@ -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" @@ -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) @@ -20298,12 +20300,14 @@ 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 @@ -20311,7 +20315,7 @@ MENU_MISSION_COMMAND:New("Clear for landing",rat.Menu[rat.SubMenuName].groups[sd 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)