From 62337f445a84fd3d73f8a42c62cc79840e091793 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 31 Dec 2024 14:04:46 +0100 Subject: [PATCH 1/2] #CTLD - Save and load special static shapes, if they are set --- Moose Development/Moose/Ops/CTLD.lua | 65 ++++++++----------- .../Moose/Ops/RecoveryTanker.lua | 2 + Moose Development/Moose/Ops/RescueHelo.lua | 2 + 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 9b6c0ead1..bde535a5d 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -1351,7 +1351,7 @@ CTLD.UnitTypeCapabilities = { --- CTLD class version. -- @field #string version -CTLD.version="1.1.21" +CTLD.version="1.1.22" --- Instantiate a new CTLD. -- @param #CTLD self @@ -2686,27 +2686,6 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop, pack) row = 1 startpos:Translate(6,heading,nil,true) end - --[[ - local initialSpacing = IsHerc and 16 or (capabilities.length+2) -- initial spacing of the first crates - local crateSpacing = 4 -- further spacing of remaining crates - local lateralSpacing = 4 -- lateral spacing of crates - local nrSideBySideCrates = 4 -- number of crates that are placed side-by-side - - if cratesneeded == 1 then - -- single crate needed spawns straight ahead - cratedistance = initialSpacing - rheading = math.fmod((heading + addon), 360) - else - --if (i - 1) % nrSideBySideCrates == 0 then - cratedistance = i == 1 and initialSpacing or (cratedistance + crateSpacing) - angleOffNose = math.ceil(math.deg(math.atan(lateralSpacing / cratedistance))) - self:I("angleOffNose = "..angleOffNose) - rheading = heading + addon - angleOffNose - --else - -- rheading = heading + addon + angleOffNose - --end - end - --]] end --local cratevec2 = cratecoord:GetVec2() @@ -4277,7 +4256,7 @@ end -- @param #number PerTroopMass Mass in kg of each soldier -- @param #number Stock Number of groups in stock. Nil for unlimited. -- @param #string SubCategory Name of sub-category (optional). -function CTLD:AddTroopsCargo(Name,Templates,Type,NoTroops,PerTroopMass,Stock,SubCategory) +function CTLD:AddTroopsCargo(Name,Templates,Type,NoTroops,PerTroopMass,Stock,SubCategory) self:T(self.lid .. " AddTroopsCargo") self:T({Name,Templates,Type,NoTroops,PerTroopMass,Stock}) if not self:_CheckTemplates(Templates) then @@ -4288,6 +4267,7 @@ function CTLD:AddTroopsCargo(Name,Templates,Type,NoTroops,PerTroopMass,Stock,Sub -- Troops are directly loadable local cargo = CTLD_CARGO:New(self.CargoCounter,Name,Templates,Type,false,true,NoTroops,nil,nil,PerTroopMass,Stock, SubCategory) table.insert(self.Cargo_Troops,cargo) + if SubCategory and self.usesubcats ~= true then self.usesubcats=true end return self end @@ -4324,6 +4304,7 @@ function CTLD:AddCratesCargo(Name,Templates,Type,NoCrates,PerCrateMass,Stock,Sub cargo:SetStaticTypeAndShape(Category,TypeName,ShapeName) end table.insert(self.Cargo_Crates,cargo) + if SubCategory and self.usesubcats ~= true then self.usesubcats=true end return self end @@ -4350,6 +4331,7 @@ function CTLD:AddStaticsCargo(Name,Mass,Stock,SubCategory,DontShowInMenu,Locatio local cargo = CTLD_CARGO:New(self.CargoCounter,Name,template,type,false,false,1,nil,nil,Mass,Stock,SubCategory,DontShowInMenu,Location) cargo:SetStaticResourceMap(ResourceMap) table.insert(self.Cargo_Statics,cargo) + if SubCategory and self.usesubcats ~= true then self.usesubcats=true end return cargo end @@ -6127,7 +6109,7 @@ end local statics = nil local statics = {} - self:T(self.lid.."Bulding Statics Table for Saving") + self:T(self.lid.."Building Statics Table for Saving") for _,_cargo in pairs (stcstable) do local cargo = _cargo -- #CTLD_CARGO local object = cargo:GetPositionable() -- Wrapper.Static#STATIC @@ -6162,7 +6144,7 @@ end --local data = "LoadedData = {\n" - local data = "Group,x,y,z,CargoName,CargoTemplates,CargoType,CratesNeeded,CrateMass,Structure\n" + local data = "Group,x,y,z,CargoName,CargoTemplates,CargoType,CratesNeeded,CrateMass,Structure,StaticCategory,StaticType,StaticShape\n" local n = 0 for _,_grp in pairs(grouptable) do local group = _grp -- Wrapper.Group#GROUP @@ -6189,6 +6171,7 @@ end local cgotype = cargo.CargoType local cgoneed = cargo.CratesNeeded local cgomass = cargo.PerCrateMass + local scat,stype,sshape = cargo:GetStaticTypeAndShape() local structure = UTILS.GetCountPerTypeName(group) local strucdata = "" for typen,anzahl in pairs (structure) do @@ -6205,8 +6188,8 @@ end end local location = group:GetVec3() - local txt = string.format("%s,%d,%d,%d,%s,%s,%s,%d,%d,%s\n" - ,template,location.x,location.y,location.z,cgoname,cgotemp,cgotype,cgoneed,cgomass,strucdata) + local txt = string.format("%s,%d,%d,%d,%s,%s,%s,%d,%d,%s,%s,%s,%s\n" + ,template,location.x,location.y,location.z,cgoname,cgotemp,cgotype,cgoneed,cgomass,strucdata,scat,stype,sshape or "none") data = data .. txt end end @@ -6231,8 +6214,9 @@ end local cgomass = object.PerCrateMass local crateobj = object.Positionable local location = crateobj:GetVec3() - local txt = string.format("%s,%d,%d,%d,%s,%s,%s,%d,%d\n" - ,"STATIC",location.x,location.y,location.z,cgoname,cgotemp,cgotype,cgoneed,cgomass) + local scat,stype,sshape = object:GetStaticTypeAndShape() + local txt = string.format("%s,%d,%d,%d,%s,%s,%s,%d,%d,'none',%s,%s,%s\n" + ,"STATIC",location.x,location.y,location.z,cgoname,cgotemp,cgotype,cgoneed,cgomass,scat,stype,sshape or "none") data = data .. txt end @@ -6361,47 +6345,50 @@ end for _id,_entry in pairs (loadeddata) do local dataset = UTILS.Split(_entry,",") - -- 1=Group,2=x,3=y,4=z,5=CargoName,6=CargoTemplates,7=CargoType,8=CratesNeeded,9=CrateMass,10=Structure + -- 1=Group,2=x,3=y,4=z,5=CargoName,6=CargoTemplates,7=CargoType,8=CratesNeeded,9=CrateMass,10=Structure,11=StaticCategory,12=StaticType,13=StaticShape local groupname = dataset[1] local vec2 = {} vec2.x = tonumber(dataset[2]) vec2.y = tonumber(dataset[4]) local cargoname = dataset[5] + local cargotemplates = dataset[6] local cargotype = dataset[7] + local size = tonumber(dataset[8]) + local mass = tonumber(dataset[9]) + local StaticCategory = dataset[11] + local StaticType = dataset[12] + local StaticShape = dataset[13] if type(groupname) == "string" and groupname ~= "STATIC" then - local cargotemplates = dataset[6] cargotemplates = string.gsub(cargotemplates,"{","") cargotemplates = string.gsub(cargotemplates,"}","") cargotemplates = UTILS.Split(cargotemplates,";") - local size = tonumber(dataset[8]) - local mass = tonumber(dataset[9]) local structure = nil - if dataset[10] then + if dataset[10] and dataset[10] ~= "none" then structure = dataset[10] structure = string.gsub(structure,",","") end -- inject at Vec2 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) + local injectvehicle = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) + injectvehicle:SetStaticTypeAndShape(StaticCategory,StaticType,StaticShape) self:InjectVehicles(dropzone,injectvehicle,self.surfacetypes,self.useprecisecoordloads,structure) 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.useprecisecoordloads,structure) end elseif (type(groupname) == "string" and groupname == "STATIC") or cargotype == CTLD_CARGO.Enum.REPAIR then - local cargotemplates = dataset[6] - local size = tonumber(dataset[8]) - local mass = tonumber(dataset[9]) local dropzone = ZONE_RADIUS:New("DropZone",vec2,20) local injectstatic = nil if cargotype == CTLD_CARGO.Enum.VEHICLE or cargotype == CTLD_CARGO.Enum.FOB then cargotemplates = string.gsub(cargotemplates,"{","") cargotemplates = string.gsub(cargotemplates,"}","") cargotemplates = UTILS.Split(cargotemplates,";") - injectstatic = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) + injectstatic = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) + injectstatic:SetStaticTypeAndShape(StaticCategory,StaticType,StaticShape) elseif cargotype == CTLD_CARGO.Enum.STATIC or cargotype == CTLD_CARGO.Enum.REPAIR then injectstatic = CTLD_CARGO:New(nil,cargoname,cargotemplates,cargotype,true,true,size,nil,true,mass) + injectstatic:SetStaticTypeAndShape(StaticCategory,StaticType,StaticShape) local map=cargotype:GetStaticResourceMap() injectstatic:SetStaticResourceMap(map) end diff --git a/Moose Development/Moose/Ops/RecoveryTanker.lua b/Moose Development/Moose/Ops/RecoveryTanker.lua index fd567c5fe..02e0828a7 100644 --- a/Moose Development/Moose/Ops/RecoveryTanker.lua +++ b/Moose Development/Moose/Ops/RecoveryTanker.lua @@ -997,6 +997,8 @@ function RECOVERYTANKER:onafterStart(From, Event, To) -- Init status updates in 10 seconds. self:__Status(10) + + return self end diff --git a/Moose Development/Moose/Ops/RescueHelo.lua b/Moose Development/Moose/Ops/RescueHelo.lua index 65f1e57c5..70a1e95f4 100644 --- a/Moose Development/Moose/Ops/RescueHelo.lua +++ b/Moose Development/Moose/Ops/RescueHelo.lua @@ -963,6 +963,8 @@ function RESCUEHELO:onafterStart(From, Event, To) -- Init status check self:__Status(1) + + return self end --- On after Status event. Checks player status. From 5d192abd259ef768e8833fe8400df4b0140de7ab Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 31 Dec 2024 15:34:46 +0100 Subject: [PATCH 2/2] #SEAD - Add AGM_65 --- Moose Development/Moose/Functional/Sead.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/Sead.lua b/Moose Development/Moose/Functional/Sead.lua index ac89dddb4..34b5e7d13 100644 --- a/Moose Development/Moose/Functional/Sead.lua +++ b/Moose Development/Moose/Functional/Sead.lua @@ -19,7 +19,7 @@ -- -- ### Authors: **applevangelist**, **FlightControl** -- --- Last Update: Oct 2024 +-- Last Update: Dec 2024 -- -- === -- @@ -80,6 +80,7 @@ SEAD = { ["AGM_122"] = "AGM_122", ["AGM_84"] = "AGM_84", ["AGM_45"] = "AGM_45", + ["AGM_65"] = "AGM_65", ["ALARM"] = "ALARM", ["LD-10"] = "LD-10", ["X_58"] = "X_58", @@ -99,6 +100,7 @@ SEAD = { -- km and mach ["AGM_88"] = { 150, 3}, ["AGM_45"] = { 12, 2}, + ["AGM_65"] = { 16, 0.9}, ["AGM_122"] = { 16.5, 2.3}, ["AGM_84"] = { 280, 0.8}, ["ALARM"] = { 45, 2}, @@ -155,7 +157,7 @@ function SEAD:New( SEADGroupPrefixes, Padding ) self:AddTransition("*", "ManageEvasion", "*") self:AddTransition("*", "CalculateHitZone", "*") - self:I("*** SEAD - Started Version 0.4.8") + self:I("*** SEAD - Started Version 0.4.9") return self end @@ -468,6 +470,7 @@ function SEAD:HandleEventShot( EventData ) local SEADWeaponName = EventData.WeaponName or "None" -- return weapon type if self:_CheckHarms(SEADWeaponName) then + --UTILS.PrintTableToLog(EventData) local SEADPlane = EventData.IniUnit -- Wrapper.Unit#UNIT if not SEADPlane then return self end -- case IniUnit is empty @@ -493,7 +496,7 @@ function SEAD:HandleEventShot( EventData ) if not _target or self.debug then -- AGM-88 or 154 w/o target data self:E("***** SEAD - No target data for " .. (SEADWeaponName or "None")) if string.find(SEADWeaponName,"AGM_88",1,true) or string.find(SEADWeaponName,"AGM_154",1,true) then - self:I("**** Tracking AGM-88/154 with no target data.") + self:T("**** Tracking AGM-88/154 with no target data.") local pos0 = SEADPlane:GetCoordinate() local fheight = SEADPlane:GetHeight() self:__CalculateHitZone(20,SEADWeapon,pos0,fheight,SEADGroup,SEADWeaponName)