diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index bb450b5fd..a677f1135 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -2175,7 +2175,23 @@ do -- SET_UNIT return self end - + --- Iterate the SET_UNIT and count how many UNITs are alive. + -- @param #SET_UNIT self + -- @return #number The number of UNITs alive. + function SET_UNIT:CountAlive() + + local Set = self:GetSet() + + local CountU = 0 + for UnitID, UnitData in pairs(Set) do -- For each GROUP in SET_GROUP + if UnitData and UnitData:IsAlive() then + CountU = CountU + 1 + end + + end + + return CountU + end --- Starts the filtering. -- @param #SET_UNIT self @@ -3194,6 +3210,24 @@ do -- SET_STATIC return self end + --- Iterate the SET_STATIC and count how many STATICSs are alive. + -- @param #SET_STATIC self + -- @return #number The number of UNITs alive. + function SET_STATIC:CountAlive() + + local Set = self:GetSet() + + local CountU = 0 + for UnitID, UnitData in pairs(Set) do + if UnitData and UnitData:IsAlive() then + CountU = CountU + 1 + end + + end + + return CountU + end + --- Handles the Database to check on an event (birth) that the Object was added in the Database. -- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! -- @param #SET_STATIC self diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index c5ebdcce5..5856255ab 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -311,7 +311,7 @@ end --- Create an ANTI-SHIP mission. -- @param #AUFTRAG self --- @param Core.Set#SET_UNIT TargetGroupSet The set of target units. +-- @param Core.Set#SET_UNIT TargetUnitSet The set of target units. -- @return #AUFTRAG self function AUFTRAG:NewANTISHIP(TargetUnitSet) @@ -466,7 +466,7 @@ end --- Create a BAI mission. -- @param #AUFTRAG self --- @param Core.Set#SET_GROUP TargetGroupSet The set of target groups to attack. Instead of a SET an ordinary GROUP object can also be given if only a single group needs to be attacked. +-- @param Core.Set#SET_Unit TargetGroupSet The set of target groups to attack. Instead of a SET an ordinary GROUP object can also be given if only a single group needs to be attacked. -- @return #AUFTRAG self function AUFTRAG:NewBAI(TargetGroupSet) @@ -476,8 +476,8 @@ function AUFTRAG:NewBAI(TargetGroupSet) local mission=AUFTRAG:New(AUFTRAG.Type.BAI) - mission.engageTargetGroupset=TargetGroupSet - mission.engageTargetGroupset:FilterDeads():FilterCrashes() + mission.engageTargetUnitset=TargetGroupSet + mission.engageTargetUnitset:FilterDeads() mission.missionTask=ENUMS.MissionTask.GROUNDATTACK @@ -1397,7 +1397,7 @@ function AUFTRAG:CountMissionTargets() end if self.engageTargetUnitset then - local n=self.engageTargetUnitset:Count() + local n=self.engageTargetUnitset:CountAlive() N=N+n end @@ -1475,6 +1475,7 @@ function AUFTRAG:GetDCSMissionTask() local TargetUnit=_unit local DCStask=CONTROLLABLE.TaskAttackUnit(nil, TargetUnit, self.engageAltitude, self.WeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType) + local DCStask=CONTROLLABLE.TaskAttackUnit(self,AttackUnit,GroupAttack,WeaponExpend,AttackQty,Direction,Altitude,WeaponType) table.insert(DCStasks, DCStask) @@ -1496,13 +1497,25 @@ function AUFTRAG:GetDCSMissionTask() -- BAI Mission -- ----------------- + --[[ for _,_group in pairs(self.engageTargetGroupset:GetSet()) do local TargetGroup=_group local DCStask=CONTROLLABLE.TaskAttackGroup(nil, TargetGroup, self.engageWeaponType, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude) + local DCSTask= table.insert(DCStasks, DCStask) end + ]] + + for _,_unit in pairs(self.engageTargetUnitset:GetSet()) do + local TargetUnit=_unit + + local DCStask=CONTROLLABLE.TaskAttackUnit(self, TargetUnit, self.engageAsGroup, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType) + + table.insert(DCStasks, DCStask) + + end elseif self.type==AUFTRAG.Type.BOMBING then @@ -1512,7 +1525,7 @@ function AUFTRAG:GetDCSMissionTask() local Vec2=self.engageCoord:GetVec2() - local DCStask=CONTROLLABLE.TaskBombing(self, Vec2, self.engageAsGroup, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType, Divebomb) + local DCStask=CONTROLLABLE.TaskBombing(nil, Vec2, self.engageAsGroup, self.engageWeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType, Divebomb) table.insert(DCStasks, DCStask) @@ -1522,7 +1535,7 @@ function AUFTRAG:GetDCSMissionTask() -- CAP Mission -- ----------------- - local DCStask=CONTROLLABLE.EnRouteTaskEngageTargetsInZone(self.engageZone:GetVec2(), self.engageZone:GetRadius(), self.engageTargetTypes, Priority) + local DCStask=CONTROLLABLE.EnRouteTaskEngageTargetsInZone(nil, self.engageZone:GetVec2(), self.engageZone:GetRadius(), self.engageTargetTypes, Priority) table.insert(DCStasks, DCStask) @@ -1532,7 +1545,7 @@ function AUFTRAG:GetDCSMissionTask() -- CAS Mission -- ----------------- - local DCStask=CONTROLLABLE.EnRouteTaskEngageTargetsInZone(self.engageZone:GetVec2(), self.engageZone:GetRadius(), self.engageTargetTypes, Priority) + local DCStask=CONTROLLABLE.EnRouteTaskEngageTargetsInZone(nil, self.engageZone:GetVec2(), self.engageZone:GetRadius(), self.engageTargetTypes, Priority) table.insert(DCStasks, DCStask) diff --git a/Moose Development/Moose/Ops/Intelligence.lua b/Moose Development/Moose/Ops/Intelligence.lua index 645f20bf3..630c95e52 100644 --- a/Moose Development/Moose/Ops/Intelligence.lua +++ b/Moose Development/Moose/Ops/Intelligence.lua @@ -94,6 +94,10 @@ function INTEL:New(DetectionSet) -- Detection set. self.detectionset=DetectionSet + local alias="SPECTRE" + + --[[ + -- Determine coalition from first group in set. self.coalition=DetectionSet:GetFirst():GetCoalition() @@ -104,6 +108,8 @@ function INTEL:New(DetectionSet) alias="CIA" end + ]] + -- Set some string id for output to DCS.log file. self.lid=string.format("INTEL %s | ", alias) diff --git a/Moose Development/Moose/Utilities/Enums.lua b/Moose Development/Moose/Utilities/Enums.lua index 623b0f600..a7cb3b9b9 100644 --- a/Moose Development/Moose/Utilities/Enums.lua +++ b/Moose Development/Moose/Utilities/Enums.lua @@ -40,7 +40,11 @@ ENUMS.ROT = { --- Weapon types -- @type ENUMS.WeaponFlag ENUMS.WeaponFlag={ - Auto=1073741822, --Auto + Auto=3221225470, --AnyWeapon (AnyBomb + AnyRocket + AnyMissile + Cannons) + AnyAG=2956984318, + AnyAA=264241152, + AnyUnguided=2952822768, + AnyGuided=268402702, LGB=2, TvGB=4, SNSGB=8, diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 21c2d371e..7c140a1ea 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -1447,7 +1447,7 @@ end -- @param #CONTROLLABLE self -- @param DCS#Vec2 Vec2 2D-coordinates of the zone. -- @param DCS#Distance Radius Radius of the zone. --- @param DCS#AttributeNameArray (Optional) TargetTypes Array of target categories allowed to engage. Default {"Air"}. +-- @param DCS#AttributeNameArray TargetTypes (Optional) Array of target categories allowed to engage. Default {"Air"}. -- @param #number Priority (Optional) All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0. -- @return DCS#Task The DCS task structure. function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, Priority )