mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Improved Gauss, added spawn for FARPS/ships (untested)
This commit is contained in:
parent
a8e14b5e20
commit
6fc9baee07
@ -2141,21 +2141,21 @@ function RAT:_Waypoint(Type, Coord, Speed, Altitude, Airport)
|
|||||||
-- take-off with engine off
|
-- take-off with engine off
|
||||||
_Type="TakeOffParking"
|
_Type="TakeOffParking"
|
||||||
_Action="From Parking Area"
|
_Action="From Parking Area"
|
||||||
_Altitude = 2
|
_Altitude = 0
|
||||||
_alttype="RADIO"
|
_alttype="RADIO"
|
||||||
_AID = Airport:GetID()
|
_AID = Airport:GetID()
|
||||||
elseif Type==RAT.wp.hot then
|
elseif Type==RAT.wp.hot then
|
||||||
-- take-off with engine on
|
-- take-off with engine on
|
||||||
_Type="TakeOffParkingHot"
|
_Type="TakeOffParkingHot"
|
||||||
_Action="From Parking Area Hot"
|
_Action="From Parking Area Hot"
|
||||||
_Altitude = 2
|
_Altitude = 0
|
||||||
_alttype="RADIO"
|
_alttype="RADIO"
|
||||||
_AID = Airport:GetID()
|
_AID = Airport:GetID()
|
||||||
elseif Type==RAT.wp.runway then
|
elseif Type==RAT.wp.runway then
|
||||||
-- take-off from runway
|
-- take-off from runway
|
||||||
_Type="TakeOff"
|
_Type="TakeOff"
|
||||||
_Action="From Parking Area"
|
_Action="From Parking Area"
|
||||||
_Altitude = 2
|
_Altitude = 0
|
||||||
_alttype="RADIO"
|
_alttype="RADIO"
|
||||||
_AID = Airport:GetID()
|
_AID = Airport:GetID()
|
||||||
elseif Type==RAT.wp.air then
|
elseif Type==RAT.wp.air then
|
||||||
@ -2186,7 +2186,7 @@ function RAT:_Waypoint(Type, Coord, Speed, Altitude, Airport)
|
|||||||
elseif Type==RAT.wp.landing then
|
elseif Type==RAT.wp.landing then
|
||||||
_Type="Land"
|
_Type="Land"
|
||||||
_Action="Landing"
|
_Action="Landing"
|
||||||
_Altitude = 2
|
_Altitude = 0
|
||||||
_alttype="RADIO"
|
_alttype="RADIO"
|
||||||
_AID = Airport:GetID()
|
_AID = Airport:GetID()
|
||||||
else
|
else
|
||||||
@ -2218,7 +2218,7 @@ function RAT:_Waypoint(Type, Coord, Speed, Altitude, Airport)
|
|||||||
if self.debug then
|
if self.debug then
|
||||||
env.info(RAT.id..text)
|
env.info(RAT.id..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- define waypoint
|
-- define waypoint
|
||||||
local RoutePoint = {}
|
local RoutePoint = {}
|
||||||
-- coordinates and altitude
|
-- coordinates and altitude
|
||||||
@ -2238,9 +2238,23 @@ function RAT:_Waypoint(Type, Coord, Speed, Altitude, Airport)
|
|||||||
RoutePoint.ETA_locked = false
|
RoutePoint.ETA_locked = false
|
||||||
-- waypoint name (only for the mission editor)
|
-- waypoint name (only for the mission editor)
|
||||||
RoutePoint.name="RAT waypoint"
|
RoutePoint.name="RAT waypoint"
|
||||||
if _AID then
|
|
||||||
RoutePoint.airdromeId=_AID
|
if Airport and not Type==RAT.wp.air then
|
||||||
|
local AirbaseID = Airport:GetID()
|
||||||
|
local AirbaseCategory = Airport:GetDesc().category
|
||||||
|
if AirbaseCategory == Airbase.Category.SHIP then
|
||||||
|
RoutePoint.linkUnit = AirbaseID
|
||||||
|
RoutePoint.helipadId = AirbaseID
|
||||||
|
elseif AirbaseCategory == Airbase.Category.HELIPAD then
|
||||||
|
RoutePoint.linkUnit = AirbaseID
|
||||||
|
RoutePoint.helipadId = AirbaseID
|
||||||
|
elseif AirbaseCategory == Airbase.Category.AIRDROME then
|
||||||
|
RoutePoint.airdromeId = AirbaseID
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
-- if _AID then
|
||||||
|
-- RoutePoint.airdromeId=_AID
|
||||||
|
-- end
|
||||||
-- properties
|
-- properties
|
||||||
RoutePoint.properties = {
|
RoutePoint.properties = {
|
||||||
["vnav"] = 1,
|
["vnav"] = 1,
|
||||||
@ -2550,6 +2564,31 @@ function RAT:_Random_Gaussian(x0, sigma, xmin, xmax)
|
|||||||
|
|
||||||
-- Standard deviation. Default 10 if not given.
|
-- Standard deviation. Default 10 if not given.
|
||||||
sigma=sigma or 10
|
sigma=sigma or 10
|
||||||
|
|
||||||
|
local r
|
||||||
|
local gotit=false
|
||||||
|
local i=0
|
||||||
|
while not gotit do
|
||||||
|
|
||||||
|
-- Uniform numbers in [0,1). We need two.
|
||||||
|
local x1=math.random()
|
||||||
|
local x2=math.random()
|
||||||
|
|
||||||
|
-- Transform to Gaussian exp(-(x-x0)²/(2*sigma²).
|
||||||
|
r = math.sqrt(-2*sigma*sigma * math.log(x1)) * math.cos(2*math.pi * x2) + x0
|
||||||
|
|
||||||
|
i=i+1
|
||||||
|
if (r>=xmin and r<=xmax) or i>100 then
|
||||||
|
gotit=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return r
|
||||||
|
|
||||||
|
--old version
|
||||||
|
--[[
|
||||||
|
-- Standard deviation. Default 10 if not given.
|
||||||
|
sigma=sigma or 10
|
||||||
|
|
||||||
-- Uniform numbers in [0,1). We need two.
|
-- Uniform numbers in [0,1). We need two.
|
||||||
local x1=math.random()
|
local x1=math.random()
|
||||||
@ -2581,6 +2620,7 @@ function RAT:_Random_Gaussian(x0, sigma, xmin, xmax)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Place markers of the waypoints. Note we assume a very specific number and type of waypoints here.
|
--- Place markers of the waypoints. Note we assume a very specific number and type of waypoints here.
|
||||||
@ -2695,7 +2735,12 @@ function RAT:_ModifySpawnTemplate(waypoints)
|
|||||||
SpawnTemplate.units[UnitID]["onboard_num"] = self.SpawnIndex
|
SpawnTemplate.units[UnitID]["onboard_num"] = self.SpawnIndex
|
||||||
|
|
||||||
-- Parking spot.
|
-- Parking spot.
|
||||||
--SpawnTemplate.units[UnitID]["parking"]=19
|
UnitTemplate.parking = nil
|
||||||
|
UnitTemplate.parking_id = nil
|
||||||
|
|
||||||
|
-- Initial altitude
|
||||||
|
UnitTemplate.alt=PointVec3.y
|
||||||
|
|
||||||
self:T('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
self:T('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user