From 9d5da3388d4657b805f0229e11c1881517b8ec04 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 13 Apr 2023 15:28:41 +0200 Subject: [PATCH 1/3] smaller docu item --- Moose Development/Moose/Wrapper/Net.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Net.lua b/Moose Development/Moose/Wrapper/Net.lua index b9b587028..d8e36cbf3 100644 --- a/Moose Development/Moose/Wrapper/Net.lua +++ b/Moose Development/Moose/Wrapper/Net.lua @@ -4,8 +4,8 @@ -- -- === -- --- ### Author: **applevangelist** --- # Last Update Feb 2023 +-- ### Author: **Applevangelist** +-- # Last Update Apr 2023 -- -- === -- From ee409c45a0647df62d157bbd942ae42e07ae073c Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 13 Apr 2023 15:51:21 +0200 Subject: [PATCH 2/3] #CTLD * Allow save/loadback with precise(r) coordinates for vehicles and troops. --- Moose Development/Moose/Ops/CTLD.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 8da145b64..891afc964 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -987,6 +987,7 @@ do -- my_ctld.filename = "missionsave.csv" -- example filename -- my_ctld.filepath = "C:\\Users\\myname\\Saved Games\\DCS\Missions\\MyMission" -- example path -- my_ctld.eventoninject = true -- fire OnAfterCratesBuild and OnAfterTroopsDeployed events when loading (uses Inject functions) +-- my_ctld.useprecisecoordloads = true -- Instead if slightly varyiing the group position, try to maintain it as is -- -- Then use an initial load at the beginning of your mission: -- @@ -1219,7 +1220,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.32" +CTLD.version="1.0.33" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1312,6 +1313,7 @@ function CTLD:New(Coalition, Prefixes, Alias) self.droppedBeacons = {} self.droppedbeaconref = {} self.droppedbeacontimeout = 600 + self.useprecisecoordloads = true -- Cargo self.Cargo_Crates = {} @@ -4794,6 +4796,8 @@ end -- @param #CTLD self -- @param Core.Zone#ZONE Zone The zone where to drop the troops. -- @param Ops.CTLD#CTLD_CARGO Cargo The #CTLD_CARGO object to spawn. + -- @param #table Surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type! + -- @param #boolean PreciseLocation (Optional) Don't try to get a random position in the zone but use the dead center. Caution not to stack up stuff on another! -- @return #CTLD self -- @usage Use this function to pre-populate the field with Vehicles or FOB at a random coordinate in a zone: -- -- create a matching #CTLD_CARGO type @@ -4802,7 +4806,7 @@ end -- local dropzone = ZONE:New("InjectZone") -- Core.Zone#ZONE -- -- and go: -- my_ctld:InjectVehicles(dropzone,InjectVehicleType) - function CTLD:InjectVehicles(Zone,Cargo) + function CTLD:InjectVehicles(Zone,Cargo,Surfacetypes,PreciseLocation) self:T(self.lid.." InjectVehicles") local cargo = Cargo -- #CTLD_CARGO @@ -4834,7 +4838,10 @@ end local temptable = cargo:GetTemplates() or {} local factor = 1.5 local zone = Zone - local randomcoord = zone:GetRandomCoordinate(10,30*factor):GetVec2() + local randomcoord = zone:GetRandomCoordinate(10,30*factor,Surfacetypes):GetVec2() + if PreciseLocation then + randomcoord = zone:GetCoordinate():GetVec2() + end cargo:SetWasDropped(true) local canmove = false if type == CTLD_CARGO.Enum.VEHICLE then canmove = true end @@ -5463,10 +5470,10 @@ end local dropzone = ZONE_RADIUS:New("DropZone",vec2,20) if cargotype == CTLD_CARGO.Enum.VEHICLE or cargotype == CTLD_CARGO.Enum.FOB then local injectvehicle = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) - self:InjectVehicles(dropzone,injectvehicle) + self:InjectVehicles(dropzone,injectvehicle,self.surfacetypes,self.useprecisecoordloads) elseif cargotype == CTLD_CARGO.Enum.TROOPS or cargotype == CTLD_CARGO.Enum.ENGINEERS then local injecttroops = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) - self:InjectTroops(dropzone,injecttroops,self.surfacetypes) + self:InjectTroops(dropzone,injecttroops,self.surfacetypes,self.useprecisecoordloads) end elseif (type(groupname) == "string" and groupname == "STATIC") or cargotype == CTLD_CARGO.Enum.REPAIR then local cargotemplates = dataset[6] From ad8938cd7495113eeb8ef0ce1853e251988817cd Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 15 Apr 2023 16:17:01 +0200 Subject: [PATCH 3/3] #CTLD * Small fix allowing minus signs in template names for repairs --- Moose Development/Moose/Ops/CTLD.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 891afc964..de81e6604 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -22,7 +22,7 @@ -- @module Ops.CTLD -- @image OPS_CTLD.jpg --- Last Update Mar 2023 +-- Last Update Apr 2023 do @@ -1220,7 +1220,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.33" +CTLD.version="1.0.34" --- Instantiate a new CTLD. -- @param #CTLD self @@ -2007,6 +2007,7 @@ end function CTLD:_FindRepairNearby(Group, Unit, Repairtype) self:T(self.lid .. " _FindRepairNearby") + --self:I({Group:GetName(),Unit:GetName(),Repairtype}) local unitcoord = Unit:GetCoordinate() -- find nearest group of deployed groups @@ -2023,7 +2024,9 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype) nearestDistance = distance end end - + + --self:I("Distance: ".. nearestDistance) + -- found one and matching distance? if nearestGroup == nil or nearestDistance > self.EngineerSearch then self:_SendMessage("No unit close enough to repair!", 10, false, Group) @@ -2035,8 +2038,10 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype) -- helper to find matching template local function matchstring(String,Table) local match = false - if type(Table) == "table" then + String = string.gsub(String,"-"," ") + if type(Table) == "table" then for _,_name in pairs (Table) do + _name = string.gsub(_name,"-"," ") if string.find(String,_name) then match = true break @@ -2044,6 +2049,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype) end else if type(String) == "string" then + Table = string.gsub(Table,"-"," ") if string.find(String,Table) then match = true end end end @@ -2053,6 +2059,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype) -- walk through generics and find matching type local Cargotype = nil for k,v in pairs(self.Cargo_Crates) do + --self:I({groupname,v.Templates,Repairtype}) if matchstring(groupname,v.Templates) and matchstring(groupname,Repairtype) then Cargotype = v -- #CTLD_CARGO break @@ -2062,6 +2069,7 @@ function CTLD:_FindRepairNearby(Group, Unit, Repairtype) if Cargotype == nil then return nil, nil else + --self:I({groupname,Cargotype}) return nearestGroup, Cargotype end @@ -2076,7 +2084,7 @@ end -- @param #number Number Number of objects in Crates (found) to limit search. -- @param #boolean Engineering If true it is an Engineering repair. function CTLD:_RepairObjectFromCrates(Group,Unit,Crates,Build,Number,Engineering) - self:T(self.lid .. " _RepairObjectFromCrates") + self:T(self.lid .. " _RepairObjectFromCrates") local build = Build -- -- #CTLD.Buildable local Repairtype = build.Template -- #string local NearestGroup, CargoType = self:_FindRepairNearby(Group,Unit,Repairtype) -- Wrapper.Group#GROUP, #CTLD_CARGO