Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist 2024-10-29 13:19:40 +01:00
commit bb5c044a25
2 changed files with 29 additions and 15 deletions

View File

@ -24,7 +24,7 @@
-- @module Ops.CTLD -- @module Ops.CTLD
-- @image OPS_CTLD.jpg -- @image OPS_CTLD.jpg
-- Last Update Sep 2024 -- Last Update Oct 2024
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -1343,7 +1343,7 @@ CTLD.UnitTypeCapabilities = {
--- CTLD class version. --- CTLD class version.
-- @field #string version -- @field #string version
CTLD.version="1.1.17" CTLD.version="1.1.18"
--- Instantiate a new CTLD. --- Instantiate a new CTLD.
-- @param #CTLD self -- @param #CTLD self
@ -2429,6 +2429,7 @@ end
local nearestGroup = nil local nearestGroup = nil
local nearestGroupIndex = -1 local nearestGroupIndex = -1
local nearestDistance = 10000000 local nearestDistance = 10000000
local maxdistance = 0
local nearestList = {} local nearestList = {}
local distancekeys = {} local distancekeys = {}
local extractdistance = self.CrateDistance * self.ExtractFactor local extractdistance = self.CrateDistance * self.ExtractFactor
@ -2440,8 +2441,14 @@ end
nearestGroup = v nearestGroup = v
nearestGroupIndex = k nearestGroupIndex = k
nearestDistance = distance nearestDistance = distance
if math.floor(distance) > maxdistance then maxdistance = math.floor(distance) end
if nearestList[math.floor(distance)] then
distance = maxdistance+1
maxdistance = distance
end
table.insert(nearestList, math.floor(distance), v) table.insert(nearestList, math.floor(distance), v)
distancekeys[#distancekeys+1] = math.floor(distance) distancekeys[#distancekeys+1] = math.floor(distance)
--self:I(string.format("Adding group %s distance %dm",nearestGroup:GetName(),distance))
end end
end end
@ -2494,7 +2501,7 @@ end
nearestGroup.ExtractTime = timer.getTime() nearestGroup.ExtractTime = timer.getTime()
local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass) local loadcargotype = CTLD_CARGO:New(self.CargoCounter, Cargotype.Name, Cargotype.Templates, Cargotype.CargoType, true, true, Cargotype.CratesNeeded,nil,nil,Cargotype.PerCrateMass)
self:T({cargotype=loadcargotype}) self:T({cargotype=loadcargotype})
local running = math.floor(nearestDistance / 4)+10 -- time run to helo plus boarding local running = math.floor(nearestDistance / 4)+20 -- time run to helo plus boarding
loaded.Troopsloaded = loaded.Troopsloaded + troopsize loaded.Troopsloaded = loaded.Troopsloaded + troopsize
table.insert(loaded.Cargo,loadcargotype) table.insert(loaded.Cargo,loadcargotype)
self.Loaded_Cargo[unitname] = loaded self.Loaded_Cargo[unitname] = loaded
@ -2509,26 +2516,32 @@ end
local Angle = math.floor((heading+160)%360) local Angle = math.floor((heading+160)%360)
Point = coord:Translate(8,Angle):GetVec2() Point = coord:Translate(8,Angle):GetVec2()
if Point then if Point then
nearestGroup:RouteToVec2(Point,4) nearestGroup:RouteToVec2(Point,5)
end end
end end
-- clean up: -- clean up:
if type(Cargotype.Templates) == "table" and Cargotype.Templates[2] then local hassecondaries = false
if type(Cargotype.Templates) == "table" and Cargotype.Templates[2] then
for _,_key in pairs (Cargotype.Templates) do for _,_key in pairs (Cargotype.Templates) do
table.insert(secondarygroups,_key) table.insert(secondarygroups,_key)
hassecondaries = true
end end
end end
nearestGroup:Destroy(false,running) local destroytimer = math.random(10,20)
--self:I("Destroying Group "..nearestGroup:GetName().." in "..destroytimer.." seconds!")
nearestGroup:Destroy(false,destroytimer)
end end
end end
end end
-- clean up secondary groups -- clean up secondary groups
for _,_name in pairs(secondarygroups) do if hassecondaries == true then
for _,_group in pairs(nearestList) do for _,_name in pairs(secondarygroups) do
if _group and _group:IsAlive() then for _,_group in pairs(nearestList) do
local groupname = string.match(_group:GetName(), "(.+)-(.+)$") if _group and _group:IsAlive() then
if _name == groupname then local groupname = string.match(_group:GetName(), "(.+)-(.+)$")
_group:Destroy(false,15) if _name == groupname then
_group:Destroy(false,15)
end
end end
end end
end end
@ -3412,8 +3425,8 @@ function CTLD:_GetUnitPositions(Coordinate,Radius,Heading,Template)
local template = _DATABASE:GetGroupTemplate(Template) local template = _DATABASE:GetGroupTemplate(Template)
--UTILS.PrintTableToLog(template) --UTILS.PrintTableToLog(template)
local numbertroops = #template.units local numbertroops = #template.units
local slightshift = math.abs(math.random(0,200)/100) local slightshift = math.abs(math.random(1,500)/100)
local newcenter = Coordinate:Translate(Radius+slightshift,((Heading+270)%360)) local newcenter = Coordinate:Translate(Radius+slightshift,((Heading+270+math.random(1,10))%360))
for i=1,360,math.floor(360/numbertroops) do for i=1,360,math.floor(360/numbertroops) do
local phead = ((Heading+270+i)%360) local phead = ((Heading+270+i)%360)
local post = newcenter:Translate(Radius,phead) local post = newcenter:Translate(Radius,phead)

View File

@ -485,7 +485,8 @@ function GROUP:Destroy( GenerateEvent, delay )
self:ScheduleOnce(delay, GROUP.Destroy, self, GenerateEvent) self:ScheduleOnce(delay, GROUP.Destroy, self, GenerateEvent)
else else
local DCSGroup = self:GetDCSObject() --local DCSGroup = self:GetDCSObject()
local DCSGroup = Group.getByName( self.GroupName )
if DCSGroup then if DCSGroup then
for Index, UnitData in pairs( DCSGroup:getUnits() ) do for Index, UnitData in pairs( DCSGroup:getUnits() ) do