From 23ff128ac894447f96a3e1c647fc2fb96c524eae Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 25 Jul 2025 19:05:01 +0200 Subject: [PATCH 1/4] #ZONE added ZONE_BASE:FindNearestCoordinateOnRadius() --- Moose Development/Moose/Core/ScheduleDispatcher.lua | 2 +- Moose Development/Moose/Core/Zone.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Core/ScheduleDispatcher.lua b/Moose Development/Moose/Core/ScheduleDispatcher.lua index 023c20c95..8e062d82b 100644 --- a/Moose Development/Moose/Core/ScheduleDispatcher.lua +++ b/Moose Development/Moose/Core/ScheduleDispatcher.lua @@ -175,7 +175,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr local Name = Info.name or "?" local ErrorHandler = function( errmsg ) - env.info( "Error in timer function: " .. errmsg ) + env.info( "Error in timer function: " .. errmsg or "" ) if BASE.Debug ~= nil then env.info( BASE.Debug.traceback() ) end diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 7095d9f62..8cdafb401 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -534,6 +534,19 @@ function ZONE_BASE:GetZoneProbability() return self.ZoneProbability end +--- Get the coordinate on the radius of the zone nearest to Outsidecoordinate. Useto e.g. find an ingress point. +-- @param #ZONE_BASE self +-- @param Core.Point#COORDINATE Outsidecoordinate The coordinate outside of the zone from where to look. +-- @return Core.Point#COORDINATE CoordinateOnRadius +function ZONE_BASE:FindNearestCoordinateOnRadius(Outsidecoordinate) + local Vec1 = self:GetVec2() + local Radius = self:GetRadius() + local Vec2 = Outsidecoordinate:GetVec2() + local Point = UTILS.FindNearestPointOnCircle(Vec1,Radius,Vec2) + local rc = COORDINATE:NewFromVec2(Point) + return rc +end + --- Get the zone taking into account the randomization probability of a zone to be selected. -- @param #ZONE_BASE self -- @return #ZONE_BASE The zone is selected taking into account the randomization probability factor. From a5726c0ed81f16c9f34eae473358881ff6814fe2 Mon Sep 17 00:00:00 2001 From: smiki Date: Fri, 25 Jul 2025 23:27:01 +0200 Subject: [PATCH 2/4] [ADDED] `UTILS.ShowPicture`. Overlay pictures for players. Refactoring --- Moose Development/Moose/Core/Zone.lua | 4 +++ Moose Development/Moose/Utilities/Utils.lua | 27 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 7095d9f62..3e15506fb 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -1510,6 +1510,7 @@ function ZONE_RADIUS:IsVec3InZone( Vec3 ) end --- Search for clear ground spawn zones within this zone. A powerful and efficient function using Disposition to find clear areas for spawning ground units avoiding trees, water and map scenery. +-- @param #ZONE_RADIUS self -- @param #number PosRadius Required clear radius around each position. -- @param #number NumPositions Number of positions to find. -- @return #table A table of DCS#Vec2 positions that are clear of map objects within the given PosRadius. nil if no clear positions are found. @@ -1519,6 +1520,7 @@ end --- Search for a random clear ground spawn coordinate within this zone. A powerful and efficient function using Disposition to find clear areas for spawning ground units avoiding trees, water and map scenery. +-- @param #ZONE_RADIUS self -- @param #number PosRadius (Optional) Required clear radius around each position. (Default is math.min(Radius/10, 200)) -- @param #number NumPositions (Optional) Number of positions to find. (Default 50) -- @return Core.Point#COORDINATE A random coordinate for a clear zone. nil if no clear positions are found. @@ -2506,6 +2508,7 @@ function ZONE_POLYGON_BASE:Flush() end --- Search for clear ground spawn zones within this zone. A powerful and efficient function using Disposition to find clear areas for spawning ground units avoiding trees, water and map scenery. +-- @param #ZONE_POLYGON_BASE self -- @param #number PosRadius Required clear radius around each position. -- @param #number NumPositions Number of positions to find. -- @return #table A table of DCS#Vec2 positions that are clear of map objects within the given PosRadius. nil if no clear positions are found. @@ -2515,6 +2518,7 @@ end --- Search for a random clear ground spawn coordinate within this zone. A powerful and efficient function using Disposition to find clear areas for spawning ground units avoiding trees, water and map scenery. +-- @param #ZONE_POLYGON_BASE self -- @param #number PosRadius (Optional) Required clear radius around each position. (Default is math.min(Radius/10, 200)) -- @param #number NumPositions (Optional) Number of positions to find. (Default 50) -- @return Core.Point#COORDINATE A random coordinate for a clear zone. nil if no clear positions are found. diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index f1a4d3e6c..b69300f1a 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -4593,6 +4593,33 @@ function UTILS.GetEnvZone(name) end end +--- net.dostring_in +function UTILS.DoStringIn(State,DoString) + return net.dostring_in(State,DoString) +end + +--- Show a picture on the screen +-- @param #string FileName File name of the picture +-- @param #number Duration Duration in seconds, defaults to 10 +-- @param #boolean ClearView If true, clears the view before showing the picture, defaults to false +-- @param #number StartDelay Delay in seconds before showing the picture, defaults to 0 +-- @param #number HorizontalAlign Horizontal alignment of the picture, defaults to 1 (left), can be 0 (center) or 2 (right) +-- @param #number VerticalAlign Vertical alignment of the picture, defaults to 1 (top), can be 0 (center) or 2 (bottom) +-- @param #number Size Size of the picture in percent, defaults to 100 +-- @param #number SizeUnits Size units, defaults to 0 (percent), can be 1 (pixels) +function UTILS.ShowPicture(FileName, Duration, ClearView, StartDelay, HorizontalAlign, VerticalAlign, Size, SizeUnits) + ClearView = ClearView or false + StartDelay = StartDelay or 0 + HorizontalAlign = HorizontalAlign or 1 + VerticalAlign = VerticalAlign or 1 + Size = Size or 100 + SizeUnits = SizeUnits or 0 + + if ClearView then ClearView = "true" else ClearView = "false" end + + net.dostring_in("mission", string.format("a_out_picture(getValueResourceByKey(\"%s\"), %d, %s, %d, \"%d\", \"%d\", %d, \"%d\")", FileName, Duration or 10, ClearView, StartDelay, HorizontalAlign, VerticalAlign, Size, SizeUnits)) +end + --- Show a helper gate at a DCS#Vec3 position -- @param DCS#Vec3 pos The position -- @param number heading Heading in degrees, can be 0..359 degrees From 5e724e7a3fc4daa89422bcbcfe0850d43fa5ab79 Mon Sep 17 00:00:00 2001 From: smiki Date: Fri, 25 Jul 2025 23:39:53 +0200 Subject: [PATCH 3/4] [ADDED] `COORDINATE:GetLandProfile` --- Moose Development/Moose/Core/Point.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index fc77cdeb6..0d3c7f21d 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -837,6 +837,26 @@ do -- COORDINATE return land.getHeight( Vec2 ) end + --- Returns a table of `Vec3` points representing the terrain profile between two points. + -- @param #COORDINATE self + -- @param Destination DCS#Vec3 Ending point of the profile. + -- @return #table DCS#Vec3 table of the profile + function COORDINATE:GetLandProfileVec3(Destination) + return land.profile(self:GetVec3(), Destination) + end + + --- Returns a table of `Vec3` points representing the terrain profile between two points. + -- @param #COORDINATE self + -- @param Destination #COORDINATE Ending coordinate of the profile. + -- @return #table #COORDINATE table of the profile + function COORDINATE:GetLandProfileCoordinates(Destination) + local points = self:GetLandProfileVec3(Destination:GetVec3()) + local coords = {} + for _, point in ipairs(points) do + table.insert(coords, COORDINATE:NewFromVec3(point)) + end + return coords + end --- Set the heading of the coordinate, if applicable. -- @param #COORDINATE self From b6b668687354a2678df671d87e5f5d78e19d3a45 Mon Sep 17 00:00:00 2001 From: smiki Date: Fri, 25 Jul 2025 23:43:00 +0200 Subject: [PATCH 4/4] [ADDED] `COORDINATE:GetLandProfile` --- Moose Development/Moose/Core/Point.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 0d3c7f21d..09af3b47e 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -837,7 +837,7 @@ do -- COORDINATE return land.getHeight( Vec2 ) end - --- Returns a table of `Vec3` points representing the terrain profile between two points. + --- Returns a table of DCS#Vec3 points representing the terrain profile between two points. -- @param #COORDINATE self -- @param Destination DCS#Vec3 Ending point of the profile. -- @return #table DCS#Vec3 table of the profile @@ -845,7 +845,7 @@ do -- COORDINATE return land.profile(self:GetVec3(), Destination) end - --- Returns a table of `Vec3` points representing the terrain profile between two points. + --- Returns a table of #COORDINATE representing the terrain profile between two points. -- @param #COORDINATE self -- @param Destination #COORDINATE Ending coordinate of the profile. -- @return #table #COORDINATE table of the profile