From 0347e42fc7a509be814056dbc5f19172446937d0 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 30 Dec 2023 16:50:12 +0100 Subject: [PATCH 1/2] CARGO noise --- Moose Development/Moose/Cargo/CargoCrate.lua | 20 +++++++------- Moose Development/Moose/Cargo/CargoGroup.lua | 4 +-- .../Moose/Cargo/CargoSlingload.lua | 16 ++++++------ Moose Development/Moose/Cargo/CargoUnit.lua | 26 +++++++++---------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Moose Development/Moose/Cargo/CargoCrate.lua b/Moose Development/Moose/Cargo/CargoCrate.lua index 2abc9365b..c0fbdd631 100644 --- a/Moose Development/Moose/Cargo/CargoCrate.lua +++ b/Moose Development/Moose/Cargo/CargoCrate.lua @@ -59,7 +59,7 @@ do -- CARGO_CRATE -- @return #CARGO_CRATE function CARGO_CRATE:New( CargoStatic, Type, Name, LoadRadius, NearRadius ) local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_CRATE - self:F( { Type, Name, NearRadius } ) + self:T( { Type, Name, NearRadius } ) self.CargoObject = CargoStatic -- Wrapper.Static#STATIC @@ -116,7 +116,7 @@ do -- CARGO_CRATE -- @param #string To -- @param Core.Point#POINT_VEC2 function CARGO_CRATE:onenterUnLoaded( From, Event, To, ToPointVec2 ) - --self:F( { ToPointVec2, From, Event, To } ) + --self:T( { ToPointVec2, From, Event, To } ) local Angle = 180 local Speed = 10 @@ -153,7 +153,7 @@ do -- CARGO_CRATE -- @param #string To -- @param Wrapper.Unit#UNIT CargoCarrier function CARGO_CRATE:onenterLoaded( From, Event, To, CargoCarrier ) - --self:F( { From, Event, To, CargoCarrier } ) + --self:T( { From, Event, To, CargoCarrier } ) self.CargoCarrier = CargoCarrier @@ -190,7 +190,7 @@ do -- CARGO_CRATE -- @param Core.Point#COORDINATE Coordinate -- @return #boolean true if the Cargo Crate is within the report radius. function CARGO_CRATE:IsInReportRadius( Coordinate ) - --self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + --self:T( { Coordinate, LoadRadius = self.LoadRadius } ) local Distance = 0 if self:IsUnLoaded() then @@ -210,7 +210,7 @@ do -- CARGO_CRATE -- @param Core.Point#Coordinate Coordinate -- @return #boolean true if the Cargo Crate is within the loading radius. function CARGO_CRATE:IsInLoadRadius( Coordinate ) - --self:F( { Coordinate, LoadRadius = self.NearRadius } ) + --self:T( { Coordinate, LoadRadius = self.NearRadius } ) local Distance = 0 if self:IsUnLoaded() then @@ -231,7 +231,7 @@ do -- CARGO_CRATE -- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup. -- @return #nil There is no valid Cargo in the CargoGroup. function CARGO_CRATE:GetCoordinate() - --self:F() + --self:T() return self.CargoObject:GetCoordinate() end @@ -261,7 +261,7 @@ do -- CARGO_CRATE -- @param #CARGO_CRATE self -- @param Core.Point#COORDINATE Coordinate function CARGO_CRATE:RouteTo( Coordinate ) - self:F( {Coordinate = Coordinate } ) + self:T( {Coordinate = Coordinate } ) end @@ -274,7 +274,7 @@ do -- CARGO_CRATE -- @return #boolean The Cargo is near to the Carrier. -- @return #nil The Cargo is not near to the Carrier. function CARGO_CRATE:IsNear( CargoCarrier, NearRadius ) - self:F( {NearRadius = NearRadius } ) + self:T( {NearRadius = NearRadius } ) return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius ) end @@ -283,7 +283,7 @@ do -- CARGO_CRATE -- @param #CARGO_CRATE self function CARGO_CRATE:Respawn() - self:F( { "Respawning crate " .. self:GetName() } ) + self:T( { "Respawning crate " .. self:GetName() } ) -- Respawn the group... @@ -300,7 +300,7 @@ do -- CARGO_CRATE -- @param #CARGO_CRATE self function CARGO_CRATE:onafterReset() - self:F( { "Reset crate " .. self:GetName() } ) + self:T( { "Reset crate " .. self:GetName() } ) -- Respawn the group... diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index 0cb2f1d5b..ca6a96a69 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -271,7 +271,7 @@ do -- CARGO_GROUP -- @param Core.Event#EVENTDATA EventData function CARGO_GROUP:OnEventCargoDead( EventData ) - self:E(EventData) + self:T(EventData) local Destroyed = false @@ -296,7 +296,7 @@ do -- CARGO_GROUP if Destroyed then self:Destroyed() - self:E( { "Cargo group destroyed" } ) + self:T( { "Cargo group destroyed" } ) end end diff --git a/Moose Development/Moose/Cargo/CargoSlingload.lua b/Moose Development/Moose/Cargo/CargoSlingload.lua index ff6d81f17..ad26e8868 100644 --- a/Moose Development/Moose/Cargo/CargoSlingload.lua +++ b/Moose Development/Moose/Cargo/CargoSlingload.lua @@ -52,7 +52,7 @@ do -- CARGO_SLINGLOAD -- @return #CARGO_SLINGLOAD function CARGO_SLINGLOAD:New( CargoStatic, Type, Name, LoadRadius, NearRadius ) local self = BASE:Inherit( self, CARGO_REPRESENTABLE:New( CargoStatic, Type, Name, nil, LoadRadius, NearRadius ) ) -- #CARGO_SLINGLOAD - self:F( { Type, Name, NearRadius } ) + self:T( { Type, Name, NearRadius } ) self.CargoObject = CargoStatic @@ -130,7 +130,7 @@ do -- CARGO_SLINGLOAD -- @param Core.Point#COORDINATE Coordinate -- @return #boolean true if the Cargo Crate is within the report radius. function CARGO_SLINGLOAD:IsInReportRadius( Coordinate ) - --self:F( { Coordinate, LoadRadius = self.LoadRadius } ) + --self:T( { Coordinate, LoadRadius = self.LoadRadius } ) local Distance = 0 if self:IsUnLoaded() then @@ -149,7 +149,7 @@ do -- CARGO_SLINGLOAD -- @param Core.Point#COORDINATE Coordinate -- @return #boolean true if the Cargo Slingload is within the loading radius. function CARGO_SLINGLOAD:IsInLoadRadius( Coordinate ) - --self:F( { Coordinate } ) + --self:T( { Coordinate } ) local Distance = 0 if self:IsUnLoaded() then @@ -169,7 +169,7 @@ do -- CARGO_SLINGLOAD -- @return Core.Point#COORDINATE The current Coordinate of the first Cargo of the CargoGroup. -- @return #nil There is no valid Cargo in the CargoGroup. function CARGO_SLINGLOAD:GetCoordinate() - --self:F() + --self:T() return self.CargoObject:GetCoordinate() end @@ -199,7 +199,7 @@ do -- CARGO_SLINGLOAD -- @param #CARGO_SLINGLOAD self -- @param Core.Point#COORDINATE Coordinate function CARGO_SLINGLOAD:RouteTo( Coordinate ) - --self:F( {Coordinate = Coordinate } ) + --self:T( {Coordinate = Coordinate } ) end @@ -212,7 +212,7 @@ do -- CARGO_SLINGLOAD -- @return #boolean The Cargo is near to the Carrier. -- @return #nil The Cargo is not near to the Carrier. function CARGO_SLINGLOAD:IsNear( CargoCarrier, NearRadius ) - --self:F( {NearRadius = NearRadius } ) + --self:T( {NearRadius = NearRadius } ) return self:IsNear( CargoCarrier:GetCoordinate(), NearRadius ) end @@ -222,7 +222,7 @@ do -- CARGO_SLINGLOAD -- @param #CARGO_SLINGLOAD self function CARGO_SLINGLOAD:Respawn() - --self:F( { "Respawning slingload " .. self:GetName() } ) + --self:T( { "Respawning slingload " .. self:GetName() } ) -- Respawn the group... @@ -239,7 +239,7 @@ do -- CARGO_SLINGLOAD -- @param #CARGO_SLINGLOAD self function CARGO_SLINGLOAD:onafterReset() - --self:F( { "Reset slingload " .. self:GetName() } ) + --self:T( { "Reset slingload " .. self:GetName() } ) -- Respawn the group... diff --git a/Moose Development/Moose/Cargo/CargoUnit.lua b/Moose Development/Moose/Cargo/CargoUnit.lua index 830f02662..a1d86dd49 100644 --- a/Moose Development/Moose/Cargo/CargoUnit.lua +++ b/Moose Development/Moose/Cargo/CargoUnit.lua @@ -75,7 +75,7 @@ do -- CARGO_UNIT -- @param Core.Point#POINT_VEC2 ToPointVec2 -- @param #number NearRadius (optional) Defaut 25 m. function CARGO_UNIT:onenterUnBoarding( From, Event, To, ToPointVec2, NearRadius ) - self:F( { From, Event, To, ToPointVec2, NearRadius } ) + self:T( { From, Event, To, ToPointVec2, NearRadius } ) local Angle = 180 local Speed = 60 @@ -114,7 +114,7 @@ do -- CARGO_UNIT else self.CargoObject:ReSpawnAt( FromPointVec2, CargoDeployHeading ) end - self:F( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } ) + self:T( { "CargoUnits:", self.CargoObject:GetGroup():GetName() } ) self.CargoCarrier = nil local Points = {} @@ -148,7 +148,7 @@ do -- CARGO_UNIT -- @param Core.Point#POINT_VEC2 ToPointVec2 -- @param #number NearRadius (optional) Defaut 100 m. function CARGO_UNIT:onleaveUnBoarding( From, Event, To, ToPointVec2, NearRadius ) - self:F( { From, Event, To, ToPointVec2, NearRadius } ) + self:T( { From, Event, To, ToPointVec2, NearRadius } ) local Angle = 180 local Speed = 10 @@ -174,7 +174,7 @@ do -- CARGO_UNIT -- @param Core.Point#POINT_VEC2 ToPointVec2 -- @param #number NearRadius (optional) Defaut 100 m. function CARGO_UNIT:onafterUnBoarding( From, Event, To, ToPointVec2, NearRadius ) - self:F( { From, Event, To, ToPointVec2, NearRadius } ) + self:T( { From, Event, To, ToPointVec2, NearRadius } ) self.CargoInAir = self.CargoObject:InAir() @@ -199,7 +199,7 @@ do -- CARGO_UNIT -- @param #string To -- @param Core.Point#POINT_VEC2 function CARGO_UNIT:onenterUnLoaded( From, Event, To, ToPointVec2 ) - self:F( { ToPointVec2, From, Event, To } ) + self:T( { ToPointVec2, From, Event, To } ) local Angle = 180 local Speed = 10 @@ -236,7 +236,7 @@ do -- CARGO_UNIT -- @param Wrapper.Group#GROUP CargoCarrier -- @param #number NearRadius function CARGO_UNIT:onafterBoard( From, Event, To, CargoCarrier, NearRadius, ... ) - self:F( { From, Event, To, CargoCarrier, NearRadius = NearRadius } ) + self:T( { From, Event, To, CargoCarrier, NearRadius = NearRadius } ) self.CargoInAir = self.CargoObject:InAir() @@ -244,7 +244,7 @@ do -- CARGO_UNIT local MaxSpeed = Desc.speedMaxOffRoad local TypeName = Desc.typeName - --self:F({Unit=self.CargoObject:GetName()}) + --self:T({Unit=self.CargoObject:GetName()}) -- A cargo unit can only be boarded if it is not dead @@ -298,9 +298,9 @@ do -- CARGO_UNIT -- @param Wrapper.Client#CLIENT CargoCarrier -- @param #number NearRadius Default 25 m. function CARGO_UNIT:onafterBoarding( From, Event, To, CargoCarrier, NearRadius, ... ) - self:F( { From, Event, To, CargoCarrier:GetName(), NearRadius = NearRadius } ) + self:T( { From, Event, To, CargoCarrier:GetName(), NearRadius = NearRadius } ) - self:F( { IsAlive=self.CargoObject:IsAlive() } ) + self:T( { IsAlive=self.CargoObject:IsAlive() } ) if CargoCarrier and CargoCarrier:IsAlive() then -- and self.CargoObject and self.CargoObject:IsAlive() then if (CargoCarrier:IsAir() and not CargoCarrier:InAir()) or true then @@ -321,7 +321,7 @@ do -- CARGO_UNIT local Angle = 180 local Distance = 0 - --self:F({Unit=self.CargoObject:GetName()}) + --self:T({Unit=self.CargoObject:GetName()}) local CargoCarrierPointVec2 = CargoCarrier:GetPointVec2() local CargoCarrierHeading = CargoCarrier:GetHeading() -- Get Heading of object in degrees. @@ -348,7 +348,7 @@ do -- CARGO_UNIT self.CargoObject:SetCommand( self.CargoObject:CommandStopRoute( true ) ) end else - self:E("Something is wrong") + self:T("Something is wrong") end end @@ -361,11 +361,11 @@ do -- CARGO_UNIT -- @param #string To -- @param Wrapper.Unit#UNIT CargoCarrier function CARGO_UNIT:onenterLoaded( From, Event, To, CargoCarrier ) - self:F( { From, Event, To, CargoCarrier } ) + self:T( { From, Event, To, CargoCarrier } ) self.CargoCarrier = CargoCarrier - --self:F({Unit=self.CargoObject:GetName()}) + --self:T({Unit=self.CargoObject:GetName()}) -- Only destroy the CargoObject if there is a CargoObject (packages don't have CargoObjects). if self.CargoObject then From f3063613170216e92f21cdb309d5222bfd6dccf2 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Sat, 30 Dec 2023 16:51:45 +0100 Subject: [PATCH 2/2] #GROUP * Added IsSam and IsAAA #SET * Corrected EvalFilterFunctions - all must be true --- Moose Development/Moose/Core/Set.lua | 24 ++++++--------- Moose Development/Moose/Wrapper/Group.lua | 37 +++++++++++++++++++++-- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index d0670abd6..ba08c103b 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -171,25 +171,18 @@ do -- SET_BASE --- [Internal] Check if the condition functions returns true. -- @param #SET_BASE self -- @param Wrapper.Controllable#CONTROLLABLE Object The object to filter for - -- @return #boolean If true, at least one condition is true. - function SET_BASE:_EvalFilterFunctions(Object) - - -- Any one condition must be true. + -- @return #boolean If true, if **all** conditions are true + function SET_BASE:_EvalFilterFunctions(Object) + -- All conditions must be true. for _,_condition in pairs(self.Filter.Functions or {}) do local condition=_condition - -- Call function. - local istrue=condition.func(Object,unpack(condition.arg)) - - -- Any true will return true. - if istrue then - return true + if condition.func(Object,unpack(condition.arg)) == false then + return false end - - end - + end -- No condition was true. - return false + return true end --- Clear the Objects in the Set. @@ -2049,7 +2042,8 @@ do end if self.Filter.Functions then - local MGroupFunc = self:_EvalFilterFunctions(MGroup) + local MGroupFunc = false + MGroupFunc = self:_EvalFilterFunctions(MGroup) MGroupInclude = MGroupInclude and MGroupFunc end diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index fe0833189..046efe091 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2763,7 +2763,7 @@ end --- Switch on/off invisible flag for the group. -- @param #GROUP self --- @param #boolean switch If true, emission is enabled. If false, emission is disabled. +-- @param #boolean switch If true, Invisible is enabled. If false, Invisible is disabled. -- @return #GROUP self function GROUP:SetCommandInvisible(switch) self:F2( self.GroupName ) @@ -2777,7 +2777,7 @@ end --- Switch on/off immortal flag for the group. -- @param #GROUP self --- @param #boolean switch If true, emission is enabled. If false, emission is disabled. +-- @param #boolean switch If true, Immortal is enabled. If false, Immortal is disabled. -- @return #GROUP self function GROUP:SetCommandImmortal(switch) self:F2( self.GroupName ) @@ -2983,3 +2983,36 @@ function GROUP:GetGroupSTN() return tSTN,text end +--- [GROUND] Determine if a GROUP is a SAM unit, i.e. has radar or optical tracker and is no mobile AAA. +-- @param #GROUP self +-- @return #boolean IsSAM True if SAM, else false +function GROUP:IsSAM() + local issam = false + local units = self:GetUnits() + for _,_unit in pairs(units or {}) do + local unit = _unit -- Wrapper.Unit#UNIT + if unit:HasSEAD() and unit:IsGround() and (not unit:HasAttribute("Mobile AAA")) then + issam = true + break + end + end + return issam +end + +--- [GROUND] Determine if a GROUP is a AAA unit, i.e. has no radar or optical tracker but the AAA = true or the "Mobile AAA" = true attribute. +-- @param #GROUP self +-- @return #boolean IsSAM True if AAA, else false +function GROUP:IsAAA() + local issam = true + local units = self:GetUnits() + for _,_unit in pairs(units or {}) do + local unit = _unit -- Wrapper.Unit#UNIT + if unit:HasSEAD() or (not unit:IsGround()) then + issam = false + if unit:HasAttribute("Mobile AAA") then + issam = true + end + end + end + return issam +end