From 21c242ee058936561f354d38477ee1065bb11ff3 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sun, 13 Feb 2022 12:07:57 +0100 Subject: [PATCH 1/5] Added CTLD:SetTroopDropZoneRadius(Radius) --- Moose Development/Moose/Ops/CTLD.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 22de445b8..5742a6fc8 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -914,8 +914,8 @@ do -- @field #CTLD CTLD = { ClassName = "CTLD", - verbose = 0, - lid = "", + verbose = 0, + lid = "", coalition = 1, coalitiontxt = "blue", PilotGroups = {}, -- #GROUP_SET of heli pilots @@ -1021,7 +1021,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.6" +CTLD.version="1.0.7" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1149,6 +1149,7 @@ function CTLD:New(Coalition, Prefixes, Alias) self.smokedistance = 2000 self.movetroopstowpzone = true self.movetroopsdistance = 5000 + self.troopdropzoneradius = 100 -- added support Hercules Mod self.enableHercules = false @@ -1418,6 +1419,17 @@ function CTLD:_GenerateVHFrequencies() return self end +--- (User) Set drop zone radius for troop drops in meters. Minimum distance is 25m for security reasons. +-- @param #CTLD self +-- @param #number Radius The radius to use. +function CTLD:SetTroopDropZoneRadius(Radius) + self:T(self.lid .. " SetTroopDropZoneRadius") + local tradius = Radius or 100 + if tradius < 25 then tradius = 25 end + self.troopdropzoneradius = tradius + return self +end + --- (Internal) Event handler function -- @param #CTLD self -- @param Core.Event#EVENTDATA EventData @@ -2482,7 +2494,7 @@ function CTLD:_UnloadTroops(Group, Unit) local name = cargo:GetName() or "none" local temptable = cargo:GetTemplates() or {} local position = Group:GetCoordinate() - local zoneradius = 100 -- drop zone radius + local zoneradius = self.troopdropzoneradius or 100 -- drop zone radius local factor = 1 if IsHerc then factor = cargo:GetCratesNeeded() or 1 -- spread a bit more if airdropping From e46922d34109206397bf909cd936b8629a753230 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 15 Feb 2022 07:30:41 +0100 Subject: [PATCH 2/5] small correction --- Moose Development/Moose/Functional/Autolase.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Autolase.lua b/Moose Development/Moose/Functional/Autolase.lua index 1aa831114..606f9c94b 100644 --- a/Moose Development/Moose/Functional/Autolase.lua +++ b/Moose Development/Moose/Functional/Autolase.lua @@ -344,7 +344,7 @@ function AUTOLASE:GetSmokeColor(RecceName) if self.RecceSmokeColor[RecceName] == nil then self.RecceSmokeColor[RecceName] = color else - color = self.RecceLaserCode[RecceName] + color = self.RecceSmokeColor[RecceName] end return color end From 42e9cae87632d9897d2ae9cdf64c1df709d42c32 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 15 Feb 2022 14:41:45 +0100 Subject: [PATCH 3/5] added back GROUP:GetHighestThreat() --- Moose Development/Moose/Wrapper/Group.lua | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 4f653f6d5..3655729d1 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2609,6 +2609,41 @@ function GROUP:GetSkill() return skill end + +--- Get the unit in the group with the highest threat level, which is still alive. +-- @param #GROUP self +-- @return Wrapper.Unit#UNIT The most dangerous unit in the group. +-- @return #number Threat level of the unit. +function GROUP:GetHighestThreat() + + -- Get units of the group. + local units=self:GetUnits() + + if units then + + local threat=nil ; local maxtl=0 + for _,_unit in pairs(units or {}) do + local unit=_unit --Wrapper.Unit#UNIT + + if unit and unit:IsAlive() then + + -- Threat level of group. + local tl=unit:GetThreatLevel() + + -- Check if greater the current threat. + if tl>maxtl then + maxtl=tl + threat=unit + end + end + end + + return threat, maxtl + end + + return nil, nil +end + --do -- Smoke -- ----- Signal a flare at the position of the GROUP. From 53f45ace4c221726b87fd2c54e6eb655a62b9c6f Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 15 Feb 2022 18:07:14 +0100 Subject: [PATCH 4/5] CTLD - corrected default weight limits when using CTLD:UnitCapabilities() - was setting loadable weight to zero --- 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 5742a6fc8..baa437a5a 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -1021,7 +1021,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.7" +CTLD.version="1.0.8" --- Instantiate a new CTLD. -- @param #CTLD self @@ -3702,8 +3702,8 @@ end -- @param #boolean Cantroops Unit can load troops. Default false. -- @param #number Cratelimit Unit can carry number of crates. Default 0. -- @param #number Trooplimit Unit can carry number of troops. Default 0. - -- @param #number Length Unit lenght (in mteres) for the load radius. Default 20. - -- @param #number Maxcargoweight Maxmimum weight in kgs this helo can carry. Default 0. + -- @param #number Length Unit lenght (in metres) for the load radius. Default 20. + -- @param #number Maxcargoweight Maxmimum weight in kgs this helo can carry. Default 500. function CTLD:UnitCapabilities(Unittype, Cancrates, Cantroops, Cratelimit, Trooplimit, Length, Maxcargoweight) self:T(self.lid .. " UnitCapabilities") local unittype = nil @@ -3716,6 +3716,13 @@ end else return self end + local length = 20 + local maxcargo = 500 + local existingcaps = self.UnitTypes[unittype] -- #CTLD.UnitCapabilities + if existingcaps then + length = existingcaps.length or 20 + maxcargo = existingcaps.cargoweightlimit or 500 + end -- set capabilities local capabilities = {} -- #CTLD.UnitCapabilities capabilities.type = unittype @@ -3723,8 +3730,8 @@ end capabilities.troops = Cantroops or false capabilities.cratelimit = Cratelimit or 0 capabilities.trooplimit = Trooplimit or 0 - capabilities.length = Length or 20 - capabilities.cargoweightlimit = Maxcargoweight or 0 + capabilities.length = Length or length + capabilities.cargoweightlimit = Maxcargoweight or maxcargo self.UnitTypes[unittype] = capabilities return self end From 44ad841d05ae0b411f4f50538485177f84a86921 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Wed, 16 Feb 2022 10:02:44 +0100 Subject: [PATCH 5/5] CTLD - fix side effects in weight check - fixes #1688 (#1689) Fixed _FindCratesNearby() to optionally ignore the helo's max load capacity, which prevented CTLD from finding, listing, building crates is weights are used. Fixes #1688 --- Moose Development/Moose/Ops/CTLD.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index baa437a5a..251eb952f 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -1021,7 +1021,7 @@ CTLD.UnitTypes = { --- CTLD class version. -- @field #string version -CTLD.version="1.0.8" +CTLD.version="1.0.9" --- Instantiate a new CTLD. -- @param #CTLD self @@ -1844,7 +1844,7 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop) local capabilities = self:_GetUnitCapabilities(Unit) -- #CTLD.UnitCapabilities local canloadcratesno = capabilities.cratelimit local loaddist = self.CrateDistance or 35 - local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist) + local nearcrates, numbernearby = self:_FindCratesNearby(Group,Unit,loaddist,true) if numbernearby >= canloadcratesno and not drop then self:_SendMessage("There are enough crates nearby already! Take care of those first!", 10, false, Group) return self @@ -2027,7 +2027,7 @@ end function CTLD:_ListCratesNearby( _group, _unit) self:T(self.lid .. " _ListCratesNearby") local finddist = self.CrateDistance or 35 - local crates,number = self:_FindCratesNearby(_group,_unit, finddist) -- #table + local crates,number = self:_FindCratesNearby(_group,_unit, finddist,true) -- #table if number > 0 then local text = REPORT:New("Crates Found Nearby:") text:Add("------------------------------------------------------------") @@ -2084,9 +2084,10 @@ end -- @param Wrapper.Group#GROUP _group Group -- @param Wrapper.Unit#UNIT _unit Unit -- @param #number _dist Distance +-- @param #boolean _ignoreweight Find everything in range, ignore loadable weight -- @return #table Table of crates -- @return #number Number Number of crates found -function CTLD:_FindCratesNearby( _group, _unit, _dist) +function CTLD:_FindCratesNearby( _group, _unit, _dist, _ignoreweight) self:T(self.lid .. " _FindCratesNearby") local finddist = _dist local location = _group:GetCoordinate() @@ -2109,7 +2110,7 @@ function CTLD:_FindCratesNearby( _group, _unit, _dist) if static and static:IsAlive() then local staticpos = static:GetCoordinate() local distance = self:_GetDistance(location,staticpos) - if distance <= finddist and static and weight <= maxloadable then + if distance <= finddist and static and (weight <= maxloadable or _ignoreweight) then index = index + 1 table.insert(found, staticid, cargo) maxloadable = maxloadable - weight @@ -2167,7 +2168,7 @@ function CTLD:_LoadCratesNearby(Group, Unit) end -- get nearby crates local finddist = self.CrateDistance or 35 - local nearcrates,number = self:_FindCratesNearby(Group,Unit,finddist) -- #table + local nearcrates,number = self:_FindCratesNearby(Group,Unit,finddist,false) -- #table self:T(self.lid .. " Crates found: " .. number) if number == 0 and self.hoverautoloading then return self -- exit @@ -2663,7 +2664,7 @@ function CTLD:_BuildCrates(Group, Unit,Engineering) end -- get nearby crates local finddist = self.CrateDistance or 35 - local crates,number = self:_FindCratesNearby(Group,Unit, finddist) -- #table + local crates,number = self:_FindCratesNearby(Group,Unit, finddist,true) -- #table local buildables = {} local foundbuilds = false local canbuild = false @@ -2747,7 +2748,7 @@ function CTLD:_RepairCrates(Group, Unit, Engineering) self:T(self.lid .. " _RepairCrates") -- get nearby crates local finddist = self.CrateDistance or 35 - local crates,number = self:_FindCratesNearby(Group,Unit,finddist) -- #table + local crates,number = self:_FindCratesNearby(Group,Unit,finddist,true) -- #table local buildables = {} local foundbuilds = false local canbuild = false @@ -4023,7 +4024,7 @@ end self:T(_engineers.lid .. _engineers:GetStatus()) if wrenches and wrenches:IsAlive() then if engineers:IsStatus("Running") or engineers:IsStatus("Searching") then - local crates,number = self:_FindCratesNearby(wrenches,nil, self.EngineerSearch) -- #table + local crates,number = self:_FindCratesNearby(wrenches,nil, self.EngineerSearch,true) -- #table engineers:Search(crates,number) elseif engineers:IsStatus("Moving") then engineers:Move()