From 9573d92cc043083c12555511ce25d9019c250818 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Sun, 22 Nov 2020 12:07:49 +0100 Subject: [PATCH 1/2] Update Controllable.lua Add option to control a2a attack ranges for AIR fighter units. See https://wiki.hoggitworld.com/view/DCS_option_missileAttack --- .../Moose/Wrapper/Controllable.lua | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 7332271ab..8705f9fbe 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -173,6 +173,9 @@ -- * @{#CONTROLLABLE.OptionAllowJettisonWeaponsOnThreat} -- * @{#CONTROLLABLE.OptionKeepWeaponsOnThreat} -- +-- ## 5.5) Air-2-Air missile attack range: +-- * @{#CONTROLLABLE.OptionAAAttackRange}(): Defines the usage of A2A missiles against possible targets . +-- -- @field #CONTROLLABLE CONTROLLABLE = { ClassName = "CONTROLLABLE", @@ -3659,3 +3662,23 @@ function CONTROLLABLE:OptionRestrictBurner(RestrictBurner) end end + +--- Sets Controllable Option for A2A attack range for AIR FIGHTER units. +-- @param #CONTROLLABLE self +-- @param #number Defines the range: MAX_RANGE = 0, NEZ_RANGE = 1, HALF_WAY_RMAX_NEZ = 2, TARGET_THREAT_EST = 3, RANDOM_RANGE = 4. Defaults to 3. See: https://wiki.hoggitworld.com/view/DCS_option_missileAttack +function CONTROLLABLE:OptionAAAttackRange(range) + self:F2( { self.ControllableName } ) + -- defaults to 3 + local range = range or 3 + local DCSControllable = self:GetDCSObject() + if DCSControllable then + local Controller = self:_GetController() + if Controller then + if self:IsAir() then + self:SetOption(AI.Option.Air.val.MISSILE_ATTACK, range) + end + end + return self + end + return nil +end From 3e0db056649b58f9c411457fb304bf82652593e6 Mon Sep 17 00:00:00 2001 From: Applevangelist <72444570+Applevangelist@users.noreply.github.com> Date: Sun, 22 Nov 2020 13:01:26 +0100 Subject: [PATCH 2/2] Update Controllable.lua Added control to keep within limits of the options --- Moose Development/Moose/Wrapper/Controllable.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 8705f9fbe..1d31fe206 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -3669,7 +3669,10 @@ end function CONTROLLABLE:OptionAAAttackRange(range) self:F2( { self.ControllableName } ) -- defaults to 3 - local range = range or 3 + local range = range or 3 + if range < 0 or range > 4 then + range = 3 + end local DCSControllable = self:GetDCSObject() if DCSControllable then local Controller = self:_GetController()