mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
f43dd389e2
@ -1054,6 +1054,7 @@ end
|
||||
--- NOTE: This is not a spawn randomizer.
|
||||
--- It will try to find clear ground locations avoiding trees, water, roads, runways, map scenery, statics and other units in the area.
|
||||
--- Maintains the original layout and unit positions as close as possible by searching for the next closest valid position to each unit.
|
||||
-- @param #SPAWN self
|
||||
-- @param #boolean OnOff Enable/disable the feature.
|
||||
-- @param #number MaxRadius (Optional) Max radius to search for valid ground locations in meters. Default is double the max radius of the units.
|
||||
-- @param #number Spacing (Optional) Minimum spacing between units in meters. Default is 5% of the search radius or 5 meters, whichever is larger.
|
||||
|
||||
@ -378,6 +378,20 @@ function SPAWNSTATIC:InitLinkToUnit(Unit, OffsetX, OffsetY, OffsetAngle)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Uses Disposition and other fallback logic to find a better and valid ground spawn position.
|
||||
--- NOTE: This is not a spawn randomizer.
|
||||
--- It will try to a find clear ground location avoiding trees, water, roads, runways, map scenery, other statics and other units in the area.
|
||||
--- Uses the initial position if it's a valid location.
|
||||
-- @param #SPAWNSTATIC self
|
||||
-- @param #boolean OnOff Enable/disable the feature.
|
||||
-- @param #number MaxRadius (Optional) Max radius to search for a valid ground location in meters. Default is 10 times the max radius of the static.
|
||||
-- @return #SPAWNSTATIC self
|
||||
function SPAWNSTATIC:InitValidateAndRepositionStatic(OnOff, MaxRadius)
|
||||
self.ValidateAndRepositionStatic = OnOff
|
||||
self.ValidateAndRepositionStaticMaxRadius = MaxRadius
|
||||
return self
|
||||
end
|
||||
|
||||
--- Allows to place a CallFunction hook when a new static spawns.
|
||||
-- The provided method will be called when a new group is spawned, including its given parameters.
|
||||
-- The first parameter of the SpawnFunction is the @{Wrapper.Static#STATIC} that was spawned.
|
||||
@ -544,6 +558,14 @@ function SPAWNSTATIC:_SpawnStatic(Template, CountryID)
|
||||
-- Add static to the game.
|
||||
local Static=nil --DCS#StaticObject
|
||||
|
||||
if self.ValidateAndRepositionStatic then
|
||||
local validPos = UTILS.ValidateAndRepositionStatic(CountryID, Template.category, Template.type, Template, Template.shape_name, self.ValidateAndRepositionStaticMaxRadius)
|
||||
if validPos then
|
||||
Template.x = validPos.x
|
||||
Template.y = validPos.y
|
||||
end
|
||||
end
|
||||
|
||||
if self.InitFarp then
|
||||
|
||||
local TemplateGroup={}
|
||||
|
||||
@ -4981,3 +4981,51 @@ function UTILS.ValidateAndRepositionGroundUnits(Positions, Anchor, MaxRadius, Sp
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- This function uses Disposition and other fallback logic to find better ground positions for ground units.
|
||||
--- NOTE: This is not a spawn randomizer.
|
||||
--- It will try to find clear ground locations avoiding trees, water, roads, runways, map scenery, statics and other units in the area and modifies the provided positions table.
|
||||
--- Maintains the original layout and unit positions as close as possible by searching for the next closest valid position to each unit.
|
||||
-- @param #table Positions A table of DCS#Vec2 or DCS#Vec3, can be a units table from the group template.
|
||||
-- @param DCS#Vec2 Position DCS#Vec2 or DCS#Vec3 initial spawn location.
|
||||
-- @param #number MaxRadius (Optional) Max radius to search for valid ground locations in meters. Default is double the max radius of the static.
|
||||
-- @return DCS#Vec2 Initial Position if it's valid, else a valid spawn position. nil if no valid position found.
|
||||
function UTILS.ValidateAndRepositionStatic(Country, Category, Type, Position, ShapeName, MaxRadius)
|
||||
local coord = COORDINATE:NewFromVec2(Position)
|
||||
local st = SPAWNSTATIC:NewFromType(Type, Category, Country)
|
||||
if ShapeName then
|
||||
st:InitShape(ShapeName)
|
||||
end
|
||||
local sName = "s-"..timer.getTime().."-"..math.random(1,10000)
|
||||
local tempStatic = st:SpawnFromCoordinate(coord, 0, sName)
|
||||
if tempStatic then
|
||||
local sRadius = tempStatic:GetBoundingRadius(2) or 3
|
||||
tempStatic:Destroy()
|
||||
sRadius = sRadius * 0.5
|
||||
MaxRadius = MaxRadius or math.max(sRadius * 10, 100)
|
||||
local positions = UTILS.GetSimpleZones(coord:GetVec3(), MaxRadius, sRadius, 20)
|
||||
if positions and #positions > 0 then
|
||||
local closestSpot
|
||||
local closestDist = math.huge
|
||||
for _, spot in pairs(positions) do -- Disposition sometimes returns points on roads, hence this filter.
|
||||
if land.getSurfaceType(spot) == land.SurfaceType.LAND then
|
||||
local dist = UTILS.VecDist2D(Position, spot)
|
||||
if dist < closestDist then
|
||||
closestDist = dist
|
||||
closestSpot = spot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if closestSpot then
|
||||
if closestDist >= sRadius then
|
||||
return closestSpot
|
||||
else
|
||||
return Position
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
@ -703,55 +703,56 @@ AIRBASE.SouthAtlantic={
|
||||
|
||||
--- Airbases of the Sinai map:
|
||||
--
|
||||
-- * AIRBASE.Sinai.Abu_Rudeis
|
||||
-- * AIRBASE.Sinai.Abu_Suwayr
|
||||
-- * AIRBASE.Sinai.Al_Bahr_al_Ahmar
|
||||
-- * AIRBASE.Sinai.Al_Ismailiyah
|
||||
-- * AIRBASE.Sinai.Al_Khatatbah
|
||||
-- * AIRBASE.Sinai.Al_Mansurah
|
||||
-- * AIRBASE.Sinai.Al_Rahmaniyah_Air_Base
|
||||
-- * AIRBASE.Sinai.As_Salihiyah
|
||||
-- * AIRBASE.Sinai.AzZaqaziq
|
||||
-- * AIRBASE.Sinai.Baluza
|
||||
-- * AIRBASE.Sinai.Ben_Gurion
|
||||
-- * AIRBASE.Sinai.Beni_Suef
|
||||
-- * AIRBASE.Sinai.Bilbeis_Air_Base
|
||||
-- * AIRBASE.Sinai.Bir_Hasanah
|
||||
-- * AIRBASE.Sinai.Birma_Air_Base
|
||||
-- * AIRBASE.Sinai.Borg_El_Arab_International_Airport
|
||||
-- * AIRBASE.Sinai.Cairo_International_Airport
|
||||
-- * AIRBASE.Sinai.Cairo_West
|
||||
-- * AIRBASE.Sinai.Difarsuwar_Airfield
|
||||
-- * AIRBASE.Sinai.El_Arish
|
||||
-- * AIRBASE.Sinai.El_Gora
|
||||
-- * AIRBASE.Sinai.El_Minya
|
||||
-- * AIRBASE.Sinai.Fayed
|
||||
-- * AIRBASE.Sinai.Gebel_El_Basur_Air_Base
|
||||
-- * AIRBASE.Sinai.Hatzerim
|
||||
-- * AIRBASE.Sinai.Hatzor
|
||||
-- * AIRBASE.Sinai.Hurghada_International_Airport
|
||||
-- * AIRBASE.Sinai.Inshas_Airbase
|
||||
-- * AIRBASE.Sinai.Jiyanklis_Air_Base
|
||||
-- * AIRBASE.Sinai.Kedem
|
||||
-- * AIRBASE.Sinai.Kibrit_Air_Base
|
||||
-- * AIRBASE.Sinai.Kom_Awshim
|
||||
-- * AIRBASE.Sinai.Melez
|
||||
-- * AIRBASE.Sinai.Mezzeh_Air_Base
|
||||
-- * AIRBASE.Sinai.Nevatim
|
||||
-- * AIRBASE.Sinai.Ovda
|
||||
-- * AIRBASE.Sinai.Palmachim
|
||||
-- * AIRBASE.Sinai.Quwaysina
|
||||
-- * AIRBASE.Sinai.Rafic_Hariri_Intl
|
||||
-- * AIRBASE.Sinai.Ramat_David
|
||||
-- * AIRBASE.Sinai.Ramon_Airbase
|
||||
-- * AIRBASE.Sinai.Ramon_International_Airport
|
||||
-- * AIRBASE.Sinai.Sde_Dov
|
||||
-- * AIRBASE.Sinai.Sharm_El_Sheikh_International_Airport
|
||||
-- * AIRBASE.Sinai.St_Catherine
|
||||
-- * AIRBASE.Sinai.Tabuk
|
||||
-- * AIRBASE.Sinai.Tel_Nof
|
||||
-- * AIRBASE.Sinai.Wadi_Abu_Rish
|
||||
-- * AIRBASE.Sinai.Wadi_al_Jandali
|
||||
-- * AIRBASE.SinaiMap.Abu_Rudeis
|
||||
-- * AIRBASE.SinaiMap.Abu_Suwayr
|
||||
-- * AIRBASE.SinaiMap.Al_Bahr_al_Ahmar
|
||||
-- * AIRBASE.SinaiMap.Al_Ismailiyah
|
||||
-- * AIRBASE.SinaiMap.Al_Khatatbah
|
||||
-- * AIRBASE.SinaiMap.Al_Mansurah
|
||||
-- * AIRBASE.SinaiMap.Al_Rahmaniyah_Air_Base
|
||||
-- * AIRBASE.SinaiMap.As_Salihiyah
|
||||
-- * AIRBASE.SinaiMap.AzZaqaziq
|
||||
-- * AIRBASE.SinaiMap.Baluza
|
||||
-- * AIRBASE.SinaiMap.Ben_Gurion
|
||||
-- * AIRBASE.SinaiMap.Beni_Suef
|
||||
-- * AIRBASE.SinaiMap.Bilbeis_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Bir_Hasanah
|
||||
-- * AIRBASE.SinaiMap.Birma_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Borg_El_Arab_International_Airport
|
||||
-- * AIRBASE.SinaiMap.Cairo_International_Airport
|
||||
-- * AIRBASE.SinaiMap.Cairo_West
|
||||
-- * AIRBASE.SinaiMap.Damascus_Intl
|
||||
-- * AIRBASE.SinaiMap.Difarsuwar_Airfield
|
||||
-- * AIRBASE.SinaiMap.El_Arish
|
||||
-- * AIRBASE.SinaiMap.El_Gora
|
||||
-- * AIRBASE.SinaiMap.El_Minya
|
||||
-- * AIRBASE.SinaiMap.Fayed
|
||||
-- * AIRBASE.SinaiMap.Gebel_El_Basur_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Hatzerim
|
||||
-- * AIRBASE.SinaiMap.Hatzor
|
||||
-- * AIRBASE.SinaiMap.Hurghada_International_Airport
|
||||
-- * AIRBASE.SinaiMap.Inshas_Airbase
|
||||
-- * AIRBASE.SinaiMap.Jiyanklis_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Kedem
|
||||
-- * AIRBASE.SinaiMap.Kibrit_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Kom_Awshim
|
||||
-- * AIRBASE.SinaiMap.Melez
|
||||
-- * AIRBASE.SinaiMap.Mezzeh_Air_Base
|
||||
-- * AIRBASE.SinaiMap.Nevatim
|
||||
-- * AIRBASE.SinaiMap.Ovda
|
||||
-- * AIRBASE.SinaiMap.Palmachim
|
||||
-- * AIRBASE.SinaiMap.Quwaysina
|
||||
-- * AIRBASE.SinaiMap.Rafic_Hariri_Intl
|
||||
-- * AIRBASE.SinaiMap.Ramat_David
|
||||
-- * AIRBASE.SinaiMap.Ramon_Airbase
|
||||
-- * AIRBASE.SinaiMap.Ramon_International_Airport
|
||||
-- * AIRBASE.SinaiMap.Sde_Dov
|
||||
-- * AIRBASE.SinaiMap.Sharm_El_Sheikh_International_Airport
|
||||
-- * AIRBASE.SinaiMap.St_Catherine
|
||||
-- * AIRBASE.SinaiMap.Tabuk
|
||||
-- * AIRBASE.SinaiMap.Tel_Nof
|
||||
-- * AIRBASE.SinaiMap.Wadi_Abu_Rish
|
||||
-- * AIRBASE.SinaiMap.Wadi_al_Jandali
|
||||
--
|
||||
-- @field Sinai
|
||||
AIRBASE.Sinai = {
|
||||
@ -773,6 +774,7 @@ AIRBASE.Sinai = {
|
||||
["Borg_El_Arab_International_Airport"] = "Borg El Arab International Airport",
|
||||
["Cairo_International_Airport"] = "Cairo International Airport",
|
||||
["Cairo_West"] = "Cairo West",
|
||||
["Damascus_Intl"] = "Damascus Intl",
|
||||
["Difarsuwar_Airfield"] = "Difarsuwar Airfield",
|
||||
["El_Arish"] = "El Arish",
|
||||
["El_Gora"] = "El Gora",
|
||||
|
||||
@ -3202,6 +3202,7 @@ end
|
||||
--- It will try to find clear ground locations avoiding trees, water, roads, runways, map scenery, statics and other units in the area and modifies the provided positions table.
|
||||
--- Maintains the original layout and unit positions as close as possible by searching for the next closest valid position to each unit.
|
||||
--- Uses UTILS.ValidateAndRepositionGroundUnits.
|
||||
-- @param #UNIT self
|
||||
-- @param #boolean Enabled Enable/disable the feature.
|
||||
function GROUP:SetValidateAndRepositionGroundUnits(Enabled)
|
||||
self.ValidateAndRepositionGroundUnits = Enabled
|
||||
|
||||
@ -1948,6 +1948,7 @@ end
|
||||
--- It will try to find clear ground locations avoiding trees, water, roads, runways, map scenery, statics and other units in the area and modifies the provided positions table.
|
||||
--- Maintains the original layout and unit positions as close as possible by searching for the next closest valid position to each unit.
|
||||
--- Uses UTILS.ValidateAndRepositionGroundUnits.
|
||||
-- @param #UNIT self
|
||||
-- @param #boolean Enabled Enable/disable the feature.
|
||||
function UNIT:SetValidateAndRepositionGroundUnits(Enabled)
|
||||
self.ValidateAndRepositionGroundUnits = Enabled
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user