From 54e799d3f64b22d84ddbd5a1ece780b80f64186c Mon Sep 17 00:00:00 2001 From: Frank Date: Sat, 18 Apr 2020 12:58:29 +0200 Subject: [PATCH] Ops --- .../Moose/Functional/Warehouse.lua | 2 +- Moose Development/Moose/Ops/AirWing.lua | 9 +- Moose Development/Moose/Ops/Auftrag.lua | 39 ++++++- Moose Development/Moose/Utilities/Enums.lua | 109 +++++++++++------- .../Moose/Wrapper/Controllable.lua | 2 +- Moose Development/Moose/Wrapper/Marker.lua | 4 + 6 files changed, 111 insertions(+), 54 deletions(-) diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index ff67bb9e7..b9b3b139f 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -5167,7 +5167,7 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request) local text=string.format("Asset %s from request id=%d was spawned!", asset.spawngroupname, request.uid) self:I(self.lid..text) - -- Sete asset state to spawned. + -- Set asset state to spawned. asset.spawned=true -- Check if all assets groups are spawned and trigger events. diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index e0b750708..f3eabf346 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -723,7 +723,7 @@ function AIRWING:onafterStatus(From, Event, To) text=text..string.format("\n* %s %s: %s*%d, Callsign=%s, Modex=%d, Skill=%s", squadron.name, squadron:GetState(), squadron.aircrafttype, #squadron.assets, callsign, modex, skill) -- Loop over all assets. - if self.verbose>1 then + if self.verbose>0 then for j,_asset in pairs(squadron.assets) do local asset=_asset --#AIRWING.SquadronAsset local assignment=asset.assignment or "none" @@ -742,8 +742,8 @@ function AIRWING:onafterStatus(From, Event, To) text=text..string.format("\n -[%d] %s*%d \"%s\": spawned=%s, mission=%s%s", j, typename, asset.nunits, asset.spawngroupname, spawned, tostring(self:IsAssetOnMission(asset)), missiontext) --TODO - --local payload=asset.payload and table.concat(asset.payload.missiontypes, ", ") or "None" - --text=text.." payload="..payload + local payload=asset.payload and table.concat(self:GetPayloadMissionTypes(asset.payload, MissionType), ", ") or "None" + text=text.." payload="..payload text=text..", flight: " if asset.flightgroup and asset.flightgroup:IsAlive() then @@ -1941,8 +1941,7 @@ end --- Get mission types a payload can perform. -- @param #AIRWING self -- @param #AIRWING.Payload Payload The payload table. --- @param #string MissionType Type of mission. --- @return #number Performance or -1. +-- @return #table Mission types. function AIRWING:GetPayloadMissionTypes(Payload) local missiontypes={} diff --git a/Moose Development/Moose/Ops/Auftrag.lua b/Moose Development/Moose/Ops/Auftrag.lua index a7eb5f27f..12c850d90 100644 --- a/Moose Development/Moose/Ops/Auftrag.lua +++ b/Moose Development/Moose/Ops/Auftrag.lua @@ -286,6 +286,7 @@ AUFTRAG.TargetType={ -- @field #string Name Target name. -- @field #number Ninital Number of initial targets. -- @field #number Lifepoints Total life points. +-- @field #number Lifepoints0 Inital life points. --- Mission capability. -- @type AUFTRAG.Capability @@ -783,15 +784,16 @@ function AUFTRAG:NewSEAD(Target) mission:_TargetFromObject(Target) - mission.engageWeaponType=ENUMS.WeaponFlag.AnyAG + mission.engageWeaponType=ENUMS.WeaponFlag.AnyAG --ENUMS.WeaponFlag.Cannons mission.engageWeaponExpend=AI.Task.WeaponExpend.ALL mission.engageAsGroup=true mission.missionTask=ENUMS.MissionTask.SEAD mission.missionAltitude=nil - mission.missionFraction=0.25 + mission.missionFraction=0.2 mission.optionROE=ENUMS.ROE.OpenFire - mission.optionROT=ENUMS.ROT.AllowAbortMission + mission.optionROT=ENUMS.ROT.EvadeFire + --mission.optionROT=ENUMS.ROT.AllowAbortMission mission.DCStask=mission:GetDCSMissionTask() @@ -2146,10 +2148,27 @@ function AUFTRAG:CountMissionTargets(Target) return N end +--- Get target life points. +-- @param #AUFTRAG self +-- @return #number Number of initial life points when mission was planned. +function AUFTRAG:GetTargetInitialLife() + return self:GetTargetData().Lifepoints +end + +--- Get target damage. +-- @param #AUFTRAG self +-- @return #number Percent. +function AUFTRAG:GetTargetDamage() + local target=self:GetTargetData() + local life=self:GetTargetLife()/self:GetTargetData().Lifepoints + local damage=1-life + return damage*100 +end + --- Get target life points. -- @param #AUFTRAG self -- @param #AUFTRAG.TargetData Target (Optional) The target object. --- @return #number Number of alive target units. +-- @return #number Life points of target. function AUFTRAG:GetTargetLife(Target) local N=0 @@ -2192,10 +2211,12 @@ function AUFTRAG:GetTargetLife(Target) elseif Target.Type==AUFTRAG.TargetType.AIRBASE then -- TODO: any (good) way to tell whether an airbase was "destroyed" or at least damaged? Is :GetLive() working? + N=N+1 elseif Target.Type==AUFTRAG.TargetType.COORDINATE then -- A coordinate does not live. + N=N+1 elseif Target.Type==AUFTRAG.TargetType.SETGROUP then @@ -2371,7 +2392,7 @@ function AUFTRAG:UpdateMarker() -- Marker text. local text=string.format("%s %s: %s", self.name, self.type:upper(), self.status:upper()) text=text..string.format("\n%s", self:GetTargetName()) - text=text..string.format("\nTargets %d/%d, Life Points=%d", self:CountMissionTargets(), self.Ntargets, self:GetTargetLife()) + text=text..string.format("\nTargets %d/%d, Life Points=%d/%d", self:CountMissionTargets(), self.Ntargets, self:GetTargetLife(), self:GetTargetInitialLife()) text=text..string.format("\nFlights %d/%d", self:CountFlightGroups(), self.nassets) if not self.marker then @@ -2547,6 +2568,12 @@ function AUFTRAG:GetDCSMissionTask() -- SEAD Mission -- ------------------ + --[[ + local DCStask=CONTROLLABLE.EnRouteTaskEngageTargets(nil, nil ,{"Air Defence"} , 0) + table.insert(self.enrouteTasks, DCStask) + DCStask.key="SEAD" + ]] + self:_GetDCSAttackTask(self.engageTarget, DCStasks) elseif self.type==AUFTRAG.Type.STRIKE then @@ -2633,7 +2660,7 @@ function AUFTRAG:GetDCSMissionTask() end - self:T({missiontask=DCStasks}) + self:I({missiontask=DCStasks}) -- Return the task. if #DCStasks==1 then diff --git a/Moose Development/Moose/Utilities/Enums.lua b/Moose Development/Moose/Utilities/Enums.lua index 6cfc5112d..5a868d928 100644 --- a/Moose Development/Moose/Utilities/Enums.lua +++ b/Moose Development/Moose/Utilities/Enums.lua @@ -1,5 +1,9 @@ --- **Utilities** Enumerators. -- +-- An enumerator is a variable that holds a constant value. Enumerators are very useful because +-- +-- https://wiki.hoggitworld.com/view/Category:Enumerators +-- -- See the [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) on Hoggit for further explanation and examples. -- -- @module ENUMS @@ -12,7 +16,7 @@ -- * Events and event handlers are all governed within world. -- * A number of functions to get information about the game world. -- --- See [https://wiki.hoggitworld.com/view/DCS_singleton_world](https://wiki.hoggitworld.com/view/DCS_singleton_world) +-- Enumerator -- @field #ENUMS ENUMS = {} @@ -46,50 +50,73 @@ ENUMS.ROT = { AllowAbortMission=4, } ---- Weapon types. +--- Weapon types. See https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag -- @type ENUMS.WeaponFlag ENUMS.WeaponFlag={ - -- Combinations - Auto=3221225470, --AnyWeapon (AnyBomb + AnyRocket + AnyMissile + Cannons) - AnyAG=2956984318, - AnyAA=264241152, - AnyUnguided=2952822768, - AnyGuided=268402702, - -- Bombs - LGB=2, - TvGB=4, - SNSGB=8, - HEBomb=16, - Penetrator=32, - NapalmBomb=64, - FAEBomb=128, - ClusterBomb=256, - Dispencer=512, - CandleBomb=1024, - ParachuteBomb=2147483648, - GuidedBomb=14, -- (LGB + TvGB + SNSGB) - AnyUnguidedBomb=2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb) - AnyBomb=2147485694, -- (GuidedBomb + AnyUnguidedBomb) - -- Rockets - LightRocket=2048, - MarkerRocket=4096, - CandleRocket=8192, - HeavyRocket=16384, - AnyRocket=30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket + --- Bombs + LGB = 2, + TvGB = 4, + SNSGB = 8, + HEBomb = 16, + Penetrator = 32, + NapalmBomb = 64, + FAEBomb = 128, + ClusterBomb = 256, + Dispencer = 512, + CandleBomb = 1024, + ParachuteBomb = 2147483648, + --- Rockets + LightRocket = 2048, + MarkerRocket = 4096, + CandleRocket = 8192, + HeavyRocket = 16384, + --- Air-To-Surface Missiles + AntiRadarMissile = 32768, + AntiShipMissile = 65536, + AntiTankMissile = 131072, + FireAndForgetASM = 262144, + LaserASM = 524288, + TeleASM = 1048576, + CruiseMissile = 2097152, + AntiRadarMissile2 = 1073741824, --- Air-To-Air Missiles - SRAM=4194304, - MRAAM=8388608, - LRAaM=16777216, - IR_AAM=33554432, - SAR_AAM=67108864, - AR_AAM=134217728, - AnyAAM=264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM - AnyMissile=268402688, -- ASM + AnyAAM - AnyAutonomousMissile=36012032, --IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile + SRAM = 4194304, + MRAAM = 8388608, + LRAAM = 16777216, + IR_AAM = 33554432, + SAR_AAM = 67108864, + AR_AAM = 134217728, --- Guns - GUN_POD=268435456, - BuiltInCannon=536870912, - Cannos=805306368, --GUN_POD + BuiltInCannon) + GUN_POD = 268435456, + BuiltInCannon = 536870912, + --- + -- Combinations + -- + -- Bombs + GuidedBomb = 14, -- (LGB + TvGB + SNSGB) + AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb) + AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb) + --- Rockets + AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket + --- Air-To-Surface Missiles + GuidedASM = 1572864, -- (LaserASM + TeleASM) + TacticalASM = 1835008, -- (GuidedASM + FireAndForgetASM) + AnyASM = 4161536, -- (AntiRadarMissile + AntiShipMissile + AntiTankMissile + FireAndForgetASM + GuidedASM + CruiseMissile) + AnyASM2 = 1077903360, -- 4161536+1073741824, + --- Air-To-Air Missiles + AnyAAM = 264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM + AnyAutonomousMissile = 36012032, -- IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile + AnyMissile = 268402688, -- AnyASM + AnyAAM + --- Guns + Cannons = 805306368, -- GUN_POD + BuiltInCannon + --- + -- Even More Genral + Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons) + AutoDCS = 1073741822, -- Something if often see + AnyAG = 2956984318, -- Any Air-To-Ground Weapon + AnyAA = 264241152, -- Any Air-To-Air Weapon + AnyUnguided = 2952822768, -- Any Unguided Weapon + AnyGuided = 268402702, -- Any Guided Weapon } --- Mission tasks. diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 408650b47..825d6f347 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -880,7 +880,7 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At weaponType = WeaponType or 1073741822, expend = WeaponExpend or "Auto", attackQtyLimit = AttackQty and true or false, - attackQty = AttackQty, + attackQty = AttackQty or 1, directionEnabled = Direction and true or false, direction = Direction and math.rad(Direction) or 0, altitudeEnabled = Altitude and true or false, diff --git a/Moose Development/Moose/Wrapper/Marker.lua b/Moose Development/Moose/Wrapper/Marker.lua index 44a367337..20e3348df 100644 --- a/Moose Development/Moose/Wrapper/Marker.lua +++ b/Moose Development/Moose/Wrapper/Marker.lua @@ -70,6 +70,10 @@ -- -- ## Removed -- +-- ## TextUpdate +-- +-- ## CoordUpdate +-- -- -- # Examples --