mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
RAT v3
- improved stuff for helos
This commit is contained in:
@@ -2182,6 +2182,21 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
|
|||||||
|
|
||||||
-- Create a flightgroup object.
|
-- Create a flightgroup object.
|
||||||
local flightgroup=FLIGHTGROUP:New(group)
|
local flightgroup=FLIGHTGROUP:New(group)
|
||||||
|
|
||||||
|
function flightgroup.OnAfterPassingWaypoint(flightgroup, From, Event, To, Waypoint)
|
||||||
|
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
|
||||||
|
|
||||||
|
self:T(RAT.id..string.format("RAT passed waypoint %s [uid=%d]", waypoint.name, waypoint.uid))
|
||||||
|
|
||||||
|
RAT._WaypointFunction(group, self, waypoint.uid)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function flightgroup:OnAfterPassedFinalWaypoint(From, Event, To)
|
||||||
|
|
||||||
|
self:T(RAT.id..string.format("RAT passed FINAL waypoint"))
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- Increase counter of alive groups (also uncontrolled ones).
|
-- Increase counter of alive groups (also uncontrolled ones).
|
||||||
self.alive=self.alive+1
|
self.alive=self.alive+1
|
||||||
@@ -3515,6 +3530,8 @@ end
|
|||||||
-- @param #number forID (Optional) Send message only for this ID.
|
-- @param #number forID (Optional) Send message only for this ID.
|
||||||
function RAT:Status(message, forID)
|
function RAT:Status(message, forID)
|
||||||
|
|
||||||
|
self:T(RAT.id.."Checking status")
|
||||||
|
|
||||||
-- Optional arguments.
|
-- Optional arguments.
|
||||||
if message==nil then
|
if message==nil then
|
||||||
message=false
|
message=false
|
||||||
@@ -3530,13 +3547,17 @@ function RAT:Status(message, forID)
|
|||||||
local nalive=0
|
local nalive=0
|
||||||
|
|
||||||
-- Loop over all ratcraft.
|
-- Loop over all ratcraft.
|
||||||
for spawnindex,ratcraft in ipairs(self.ratcraft) do
|
for spawnindex,ratcraft in pairs(self.ratcraft) do
|
||||||
|
|
||||||
|
self:T(RAT.id..string.format("Ratcraft Index=%s", tostring(spawnindex)))
|
||||||
|
|
||||||
-- Get group.
|
-- Get group.
|
||||||
local group=ratcraft.group --Wrapper.Group#GROUP
|
local group=ratcraft.group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
if group and group:IsAlive() and (group:GetCoordinate() or group:GetVec3()) then
|
if group and group:IsAlive() and (group:GetCoordinate() or group:GetVec3()) then
|
||||||
nalive=nalive+1
|
nalive=nalive+1
|
||||||
|
|
||||||
|
self:T(RAT.id..string.format("Ratcraft Index=%s is ALIVE", tostring(spawnindex)))
|
||||||
|
|
||||||
-- Gather some information.
|
-- Gather some information.
|
||||||
local prefix=self:_GetPrefixFromGroup(group)
|
local prefix=self:_GetPrefixFromGroup(group)
|
||||||
@@ -3709,12 +3730,13 @@ function RAT:Status(message, forID)
|
|||||||
local idx=self:GetSpawnIndexFromGroup(group)
|
local idx=self:GetSpawnIndexFromGroup(group)
|
||||||
local coord=group:GetCoordinate()
|
local coord=group:GetCoordinate()
|
||||||
self:_Respawn(idx, coord, 0)
|
self:_Respawn(idx, coord, 0)
|
||||||
|
else
|
||||||
|
-- Despawn old group.
|
||||||
|
if self.despawnair then
|
||||||
|
self:_Despawn(group, 0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Despawn old group.
|
|
||||||
if self.despawnair then
|
|
||||||
self:_Despawn(group, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4738,7 +4760,7 @@ function RAT._WaypointFunction(group, rat, wp)
|
|||||||
local text
|
local text
|
||||||
|
|
||||||
-- Info on passing waypoint.
|
-- Info on passing waypoint.
|
||||||
text=string.format("Flight %s passing waypoint #%d %s.", group:GetName(), wp, rat.waypointdescriptions[wp])
|
text=string.format("Flight %s passing waypoint #%d %s", group:GetName(), wp, rat.waypointdescriptions[wp])
|
||||||
BASE.T(rat, RAT.id..text)
|
BASE.T(rat, RAT.id..text)
|
||||||
|
|
||||||
-- New status.
|
-- New status.
|
||||||
@@ -4770,7 +4792,7 @@ function RAT._WaypointFunction(group, rat, wp)
|
|||||||
MESSAGE:New(text, 10):ToAllIf(rat.Debug)
|
MESSAGE:New(text, 10):ToAllIf(rat.Debug)
|
||||||
BASE.T(rat, RAT.id..text)
|
BASE.T(rat, RAT.id..text)
|
||||||
-- Enable despawn switch. Next time the status function is called, the aircraft will be despawned.
|
-- Enable despawn switch. Next time the status function is called, the aircraft will be despawned.
|
||||||
rat.ratcraft[sdx].despawnme=true
|
ratcraft.despawnme=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5330,6 +5352,9 @@ function RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace, departure, take
|
|||||||
self:T(RAT.id..string.format("Group %s is spawned on farp/ship/runway %s.", self.alias, departure:GetName()))
|
self:T(RAT.id..string.format("Group %s is spawned on farp/ship/runway %s.", self.alias, departure:GetName()))
|
||||||
nfree=departure:GetFreeParkingSpotsNumber(termtype, true)
|
nfree=departure:GetFreeParkingSpotsNumber(termtype, true)
|
||||||
spots=departure:GetFreeParkingSpotsTable(termtype, true)
|
spots=departure:GetFreeParkingSpotsTable(termtype, true)
|
||||||
|
-- Had a case at a Gas Platform where nfree=1 but spots from GetFreeParkingSpotsTable were empty.
|
||||||
|
--spots=departure:GetParkingSpotsTable(termtype)
|
||||||
|
self:T(RAT.id..string.format("Free nfree=%d nspots=%d", nfree, #spots))
|
||||||
elseif parkingdata~=nil then
|
elseif parkingdata~=nil then
|
||||||
-- Parking data explicitly set by user as input parameter.
|
-- Parking data explicitly set by user as input parameter.
|
||||||
self:T2("Spawning with explicit parking data")
|
self:T2("Spawning with explicit parking data")
|
||||||
|
|||||||
@@ -1494,7 +1494,7 @@ function AIRBASE:GetFreeParkingSpotsTable(termtype, allowTOAC)
|
|||||||
-- Put coordinates of free spots into table.
|
-- Put coordinates of free spots into table.
|
||||||
local freespots={}
|
local freespots={}
|
||||||
for _,_spot in pairs(parkingfree) do
|
for _,_spot in pairs(parkingfree) do
|
||||||
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) and _spot.Term_Index>0 then
|
if AIRBASE._CheckTerminalType(_spot.Term_Type, termtype) then -- and _spot.Term_Index>0 then --Not sure why I had this in. But caused problems now for a Gas platform where a valid spot was not included!
|
||||||
if (allowTOAC and allowTOAC==true) or _spot.TO_AC==false then
|
if (allowTOAC and allowTOAC==true) or _spot.TO_AC==false then
|
||||||
|
|
||||||
local spot=self:_GetParkingSpotByID(_spot.Term_Index)
|
local spot=self:_GetParkingSpotByID(_spot.Term_Index)
|
||||||
|
|||||||
Reference in New Issue
Block a user