From 830dd05514b7d8d9a5bf6e0fc2decf57d72c5eac Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 16 May 2024 11:50:20 +0200 Subject: [PATCH 1/4] fix --- Moose Development/Moose/Ops/PlayerTask.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/PlayerTask.lua b/Moose Development/Moose/Ops/PlayerTask.lua index 0964d7f9a..8140be16d 100644 --- a/Moose Development/Moose/Ops/PlayerTask.lua +++ b/Moose Development/Moose/Ops/PlayerTask.lua @@ -21,7 +21,7 @@ -- === -- @module Ops.PlayerTask -- @image OPS_PlayerTask.jpg --- @date Last Update Feb 2024 +-- @date Last Update May 2024 do @@ -1370,7 +1370,7 @@ PLAYERTASKCONTROLLER.Type = { AUFTRAG.Type.PRECISIONBOMBING = "Precision Bombing" AUFTRAG.Type.CTLD = "Combat Transport" AUFTRAG.Type.CSAR = "Combat Rescue" - +AUFTRAG.Type.CONQUER = "Conquer" --- -- @type Scores PLAYERTASKCONTROLLER.Scores = { @@ -1383,7 +1383,8 @@ PLAYERTASKCONTROLLER.Scores = { [AUFTRAG.Type.BAI] = 100, [AUFTRAG.Type.SEAD] = 100, [AUFTRAG.Type.BOMBING] = 100, - [AUFTRAG.Type.BOMBRUNWAY] = 100, + [AUFTRAG.Type.BOMBRUNWAY] = 100, + [AUFTRAG.Type.CONQUER] = 100, } --- @@ -3218,9 +3219,11 @@ function PLAYERTASKCONTROLLER:_ActiveTaskInfo(Task, Group, Client) local ThreatLocaleText = self.gettext:GetEntry("THREATTEXT",self.locale) text = string.format(ThreatLocaleText, taskname, ThreatGraph, targets, CoordText) local settings = _DATABASE:GetPlayerSettings(playername) or _SETTINGS -- Core.Settings#SETTINGS - local elevationmeasure = self.gettext:GetEntry("METER",self.locale) - if settings:IsMetric()() then + local elevationmeasure = self.gettext:GetEntry("FEET",self.locale) + if settings:IsMetric() then elevationmeasure = self.gettext:GetEntry("METER",self.locale) + --Elevation = math.floor(UTILS.MetersToFeet(Elevation)) + else Elevation = math.floor(UTILS.MetersToFeet(Elevation)) end -- ELEVATION = "\nTarget Elevation: %s %s", From aec65209d04fb7147febdc0556af8cd93e928b2a Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 19 May 2024 12:47:31 +0200 Subject: [PATCH 2/4] #STRATEGO --- .../Moose/Functional/Stratego.lua | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/Moose Development/Moose/Functional/Stratego.lua b/Moose Development/Moose/Functional/Stratego.lua index 74caf5cc7..e1187c07a 100644 --- a/Moose Development/Moose/Functional/Stratego.lua +++ b/Moose Development/Moose/Functional/Stratego.lua @@ -594,7 +594,7 @@ end -- @param #STRATEGO self -- @return #STRATEGO self function STRATEGO:GetToFrom(StartPoint,EndPoint) - self:T(self.lid.."GetToFrom") + self:T(self.lid.."GetToFrom "..tostring(StartPoint).." "..tostring(EndPoint)) local pstart = string.gsub(StartPoint,"[%p%s]",".") local pend = string.gsub(EndPoint,"[%p%s]",".") local fromto = pstart..";"..pend @@ -630,7 +630,7 @@ end -- @param #STRATEGO self -- @param #string Startpoint Starting Point, e.g. AIRBASE.Syria.Hatay -- @param #string Endpoint End Point, e.g. AIRBASE.Syria.H4 --- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to lila. +-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to violet. -- @param #number Linetype (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 5. -- @param #boolean Draw (Optional) If true, draw route on the F10 map. Defaukt false. -- @return #STRATEGO self @@ -1241,6 +1241,33 @@ function STRATEGO:FindNeighborNodes(Name,Enemies,Friends) return neighbors, nearest, shortestdist end +--- [INTERNAL] Route Finding - Find the next hop towards an end node from a start node +-- @param #STRATEGO self +-- @param #string Start The name of the start node. +-- @param #string End The name of the end node. +-- @param #table InRoute Table of node names making up the route so far. +-- @return #string Name of the next closest node +function STRATEGO:_GetNextClosest(Start,End,InRoute) + local ecoord = self.airbasetable[End].coord + local nodes,nearest = self:FindNeighborNodes(Start) + --self:I(tostring(nearest)) + local closest = nil + local closedist = 1000*1000 + for _name,_dist in pairs(nodes) do + local kcoord = self.airbasetable[_name].coord + local nnodes = self.airbasetable[_name].connections > 2 and true or false + if _name == End then nnodes = true end + if kcoord ~= nil and ecoord ~= nil and nnodes == true then + local dist = math.floor((kcoord:Get2DDistance(ecoord)/1000)+0.5) + if (dist < closedist and InRoute[_name] ~= true) then + closedist = dist + closest = _name + end + end + end + return closest +end + --- [USER] Find a route between two nodes. -- @param #STRATEGO self -- @param #string Start The name of the start node. @@ -1271,29 +1298,7 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType) end return nil end - - local function NextClosest(Start,End) - local ecoord = self.airbasetable[End].coord - local nodes,nearest = self:FindNeighborNodes(Start) - --self:I(tostring(nearest)) - local closest = nil - local closedist = 1000*1000 - for _name,_dist in pairs(nodes) do - local kcoord = self.airbasetable[_name].coord - local nnodes = self.airbasetable[_name].connections > 2 and true or false - if _name == End then nnodes = true end - local dist = math.floor((kcoord:Get2DDistance(ecoord)/1000)+0.5) - if (dist < closedist and nnodes and InRoute[_name] ~= true) then - closedist = dist - closest = _name - end - end - if closest then - --MESSAGE:New(string.format("Start %s | End %s | Nextclosest %s",Start,End,closest),10,"STRATEGO"):ToLog():ToAll() - return closest - end - end - + local function DrawRoute(Route) for i=1,#Route-1 do local p1=Route[i] @@ -1319,8 +1324,8 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType) local spoint = Start for i=1,hops do --self:I("Start="..tostring(spoint)) - local Next = NextClosest(spoint,End) - if Next then + local Next = self:_GetNextClosest(spoint,End,InRoute) + if Next ~= nil then Route[#Route+1] = Next InRoute[Next] = true local nodes = self:FindNeighborNodes(Next) @@ -1332,7 +1337,9 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType) else spoint = Next end - end + else + break + end end end From 9815216bd58514084953f73b23d9b1a7f8f335a9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 19 May 2024 13:12:09 +0200 Subject: [PATCH 3/4] xx --- Moose Development/Moose/Functional/Stratego.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/Stratego.lua b/Moose Development/Moose/Functional/Stratego.lua index e1187c07a..0ea7c2095 100644 --- a/Moose Development/Moose/Functional/Stratego.lua +++ b/Moose Development/Moose/Functional/Stratego.lua @@ -181,7 +181,7 @@ STRATEGO = { debug = false, drawzone = false, markzone = false, - version = "0.2.9", + version = "0.2.10", portweight = 3, POIweight = 1, maxrunways = 3, @@ -1257,9 +1257,9 @@ function STRATEGO:_GetNextClosest(Start,End,InRoute) local kcoord = self.airbasetable[_name].coord local nnodes = self.airbasetable[_name].connections > 2 and true or false if _name == End then nnodes = true end - if kcoord ~= nil and ecoord ~= nil and nnodes == true then + if kcoord ~= nil and ecoord ~= nil and nnodes == true and InRoute[_name] ~= true then local dist = math.floor((kcoord:Get2DDistance(ecoord)/1000)+0.5) - if (dist < closedist and InRoute[_name] ~= true) then + if (dist < closedist ) then closedist = dist closest = _name end From 399f9883a9d2c6f74d66c3deb4e8f896692a4d64 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Mon, 20 May 2024 11:16:16 +0200 Subject: [PATCH 4/4] #STRATEGO, option in FindRoute to not optimize the route --- Moose Development/Moose/Functional/Stratego.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/Stratego.lua b/Moose Development/Moose/Functional/Stratego.lua index 0ea7c2095..81fe4c80d 100644 --- a/Moose Development/Moose/Functional/Stratego.lua +++ b/Moose Development/Moose/Functional/Stratego.lua @@ -181,7 +181,7 @@ STRATEGO = { debug = false, drawzone = false, markzone = false, - version = "0.2.10", + version = "0.2.11", portweight = 3, POIweight = 1, maxrunways = 3, @@ -1276,10 +1276,11 @@ end -- @param #boolean Draw If true, draw the route on the map. -- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1,0,0} for red. Defaults to black. -- @param #number LineType (Optional) Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 6. +-- @param #boolean NoOptimize If set to true, do not optimize (shorten) the resulting route if possible. -- @return #table Route Table of #string name entries of the route -- @return #boolean Complete If true, the route was found end-to-end. -- @return #boolean Reverse If true, the route was found with a reverse search, the route table will be from sorted from end point to start point. -function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType) +function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType,NoOptimize) self:T(self.lid.."FindRoute") --self:I({Start,End,Hops}) --local bases = UTILS.DeepCopy(self.airbasetable) @@ -1376,7 +1377,7 @@ function STRATEGO:FindRoute(Start,End,Hops,Draw,Color,LineType) return Route, foundcut end - if routecomplete == true then + if routecomplete == true and NoOptimize ~= true then local foundcut = true while foundcut ~= false do Route, foundcut = OptimizeRoute(Route)