Skip to content

Commit

Permalink
[F16] Fix HARM tables not being set if missiles on inboard stations
Browse files Browse the repository at this point in the history
  • Loading branch information
the-paid-actor committed Jan 18, 2024
1 parent 0b1dd4b commit 9e194e1
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 24 deletions.
79 changes: 55 additions & 24 deletions dcs-dtc/DCS/DCSDTC/f16Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,34 @@ function DTC_F16C_GetPage(page, mfd, data)
end
end

function DTC_F16C_ExecCmd_SelectMFDPage(page, data)
local leftMFDPage = DTC_F16C_GetPage(page, DTC_F16C_GetLeftMFD(), data)
local rightMFDPage = DTC_F16C_GetPage(page, DTC_F16C_GetRightMFD(), data)

if leftMFDPage == false and rightMFDPage == false then
return
end

local deviceID = 0
local mfd = ""

if leftMFDPage ~= false then
deviceID = data.leftMFDDeviceID
mfd = "left"
if leftMFDPage ~= true then
DTC_ExecCommand(deviceID, leftMFDPage, data.delay, data.activation)
end
elseif rightMFDPage ~= false then
deviceID = data.rightMFDDeviceID
mfd = "right"
if rightMFDPage ~= true then
DTC_ExecCommand(deviceID, rightMFDPage, data.delay, data.activation)
end
end

return mfd, deviceID
end

-- # Shared #

function DTC_F16C_CheckCondition_NAVMode()
Expand Down Expand Up @@ -92,35 +120,15 @@ function DTC_F16C_CheckCondition_TDOA(position, status)
end

function DTC_F16C_ExecCmd_EnableXMIT(data)
local leftMFDPage = DTC_F16C_GetPage("HSD", DTC_F16C_GetLeftMFD(), data)
local rightMFDPage = DTC_F16C_GetPage("HSD", DTC_F16C_GetRightMFD(), data)

if leftMFDPage == false and rightMFDPage == false then
return
end

local deviceID = 0
local mfd = ""

if leftMFDPage ~= false then
deviceID = data.leftMFDDeviceID
mfd = "left"
if leftMFDPage ~= true then
DTC_ExecCommand(deviceID, leftMFDPage, data.delay, data.activation)
end
elseif rightMFDPage ~= false then
deviceID = data.rightMFDDeviceID
mfd = "right"
if rightMFDPage ~= true then
DTC_ExecCommand(deviceID, rightMFDPage, data.delay, data.activation)
end
end
local mfd, deviceID = DTC_F16C_ExecCmd_SelectMFDPage("HSD", data)

local table = {}
if mfd == "left" then
table = DTC_LinesToList(list_indication(4))
else
elseif mfd == "right" then
table = DTC_LinesToList(list_indication(5))
else
return
end

local i = 1
Expand Down Expand Up @@ -177,6 +185,29 @@ function DTC_F16C_CheckCondition_HTSEnabled()
return false
end

function DTC_F16C_ExecCmd_SelectHARM(data)
local mfd, deviceID = DTC_F16C_ExecCmd_SelectMFDPage("SMS", data)
local strSearch = "AG88";

for i = 1, 5, 1 do
local table = {}
if mfd == "left" then
table = DTC_F16C_GetLeftMFD()
elseif mfd == "right" then
table = DTC_F16C_GetRightMFD()
else
return
end

local str = table["Table. Root. Unic ID: _id:1321.2.Table. Root. Unic ID: _id:1321. Text.1"];
if str == nil or str:sub(-#strSearch) == strSearch then
return
end

DTC_ExecCommand(deviceID, data.weaponStep, data.delay, data.activation)
end
end

function DTC_F16C_CheckCondition_HTSAllNotSelected(mfd)
local mfdTable;

Expand Down
19 changes: 19 additions & 0 deletions dcs-dtc/New/Uploader/Aircrafts/F16/Systems/HARMHTS.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

using DTC.New.Uploader.Base;
using DTC.Utilities;
using static DTC.Utilities.DataReceiver;

namespace DTC.New.Uploader.Aircrafts.F16;

Expand Down Expand Up @@ -107,6 +108,8 @@ private void BuildHARM()
Cmd(UFC.LIST);
Cmd(UFC.D0);
Cmd(Wait());
IfNot(HARMEnabled(), SelectHARM());
Cmd(Wait());
If(HARMEnabled(), cmds.ToArray());
Cmd(UFC.RTN);
}
Expand All @@ -121,6 +124,22 @@ private Condition HTSEnabled()
return new Condition("HTSEnabled()");
}

private CustomCommand SelectHARM()
{
var data = "{" +
$"firstPageId = {LMFD.OSB14.Id}, " +
$"secondPageId = {LMFD.OSB13.Id}, " +
$"thirdPageId = {LMFD.OSB12.Id}, " +
$"leftMFDDeviceID = {LMFD.Id}, " +
$"rightMFDDeviceID = {RMFD.Id}, " +
$"weaponStep = {LMFD.OSB06.Id}, " +
$"delay = {Settings.ViperCommandDelayMs * LMFD.OSB06.DelayFactor}, " +
$"activation = {LMFD.OSB06.Activation}" +
"}";

return new CustomCommand("SelectHARM(" + data + ")");
}

private CustomCommand BuildHTSMFD(string data)
{
return new CustomCommand("BuildHTSMFD(" + data + ")");
Expand Down

0 comments on commit 9e194e1

Please sign in to comment.