Dangerzone Posted May 8, 2021 Share Posted May 8, 2021 (edited) I was just wondering if it's possible to use script to set attributes of units as opposed to having to use the mission editor? I'm thinking of things such as: Assigning Radio Frequency, TACAN, ICLS, Heading and Speed for Supercarriers Activating TACAN and tasking KC135 for Tanker action Changing speed and heading for Supercarrier and fleet. My reason being - one of the problems I keep hitting is when I do up small missions - I keep forgetting to set something in the mission editor. This is frustrating when I've got friends on, we're an hour into the mission and then I'm like "Oh no - I forgot to set and turn on the ICLS for the carrier", or "I forgot to task the Tanker to Tanker refueling", and it spoils the mission. I figure by having a script file - I can see 2 benefits: I could quickly change/update the script file if I forget something in mission while the mission is running, and then re-run the script using assert radio option while in-game (saving me having to kill the mission and go back to the mission editor and/or end the evening's mission). It also means when creating new missions I can copy scripts instead of having to do monotonous tasking in the mission editor from one to another. (And it's easier for me to see if I've missed something in a text editor than having to click through all units in the ME) Looking through some examples I can see how this is done in some scenario's (such as spawning in a tanker for instance using MOOSE) - but haven't been able to find any successful instances of commands that can be applied to already in-game units such as the supercarriers, and attempts I've done todate have failed - which makes me think that it may not be possible. Just wanted to see if anyone else has successfully implemented a similar feature before. I did try using moose with the following script... local CARRIER = UNIT:FindByName("CARRIER") local CARRIERRAD = CARRIER:GetRadio() CARRIERRAD:SetFrequency(262) local CARRIERTCN = CARRIER:GetBeacon() CARRIERTCN.ActivateTACAN(15, "X", "TED", true) But setting tacan fails for me with "attempt to index local 'self' (a number value)" Edited May 8, 2021 by Dangerzone Link to comment Share on other sites More sharing options...
Dangerzone Posted May 8, 2021 Author Share Posted May 8, 2021 (edited) I haven't been able to achieve this using GetBeacon() - but through another tip I have been able to successfully implement this through AIRBOSS. The following gets me around the problem of setting TACAN on a carrier - but I still have the problem with setting it on a tanker such as Texaco because AIRBOSS is not designed for Texaco. local CVN71 = UNIT:FindByName("CARRIER") local AirbossCVN71 = AIRBOSS:New("CARRIER") local TANKER = UNIT:FindByName("Texaco11") CVN71RAD = CVN71:GetRadio() CVN71RAD:SetFrequency(262) AirbossCVN71:SetICLS(5, "TDY") AirbossCVN71:SetTACAN(3, "X", "TDY") AirbossCVN71:Start() rad = TANKER:GetRadio() rad:SetFrequency(241) bcn = TANKER:GetBeacon() -- <<<< STILL BREAKS HERE. :-( bcn:SetTACAN(10, "TKR") Does anyone know if GetBeacon is actually broken in Moose, or what I'm doing wrong? Edited May 8, 2021 by Dangerzone Link to comment Share on other sites More sharing options...
Balion Posted May 8, 2021 Share Posted May 8, 2021 (edited) 6 hours ago, Dangerzone said: Assigning Radio Frequency, TACAN, ICLS, Heading and Speed for Supercarriers local carrier = Unit.getByName("Naval-1-1") local ActivateBeacon = { id = 'ActivateBeacon', params = { ["type"] = 4, ["AA"] = false, ["unitId"] = carrier:getID(), ["modeChannel"] = "X", ["channel"] = 1, ["system"] = 3, ["callsign"] = "CVN", ["bearing"] = true, ["frequency"] = 962000000 } } carrier:getController():setCommand(ActivateBeacon) local ActivateICLS = { ["id"] = "ActivateICLS", ["params"] = { ["type"] = 131584, ["channel"] = 1, ["unitId"] = carrier:getID(), }, -- end of ["params"] } carrier:getController():setCommand(ActivateICLS) local SetFrequency = { id = 'SetFrequency', params = { frequency = 126300000, modulation = 0, } } carrier:getController():setCommand(SetFrequency) 6 hours ago, Dangerzone said: Activating TACAN and tasking KC135 for Tanker action local tanker = Unit.getByName("Aerial-2-1") local ActivateBeacon = { id = 'ActivateBeacon', params = { ["type"] = 4, ["AA"] = true, ["unitId"] = tanker:getID(), ["modeChannel"] = "Y", ["channel"] = 10, ["system"] = 4, ["callsign"] = "TKR", ["bearing"] = true, ["frequency"] = 1097000000, } } tanker:getController():setCommand(ActivateBeacon) local SetFrequency = { id = 'SetFrequency', params = { frequency = 256000000, modulation = 0, } } tanker:getController():setCommand(SetFrequency) local Tanker = { id = 'Tanker', params = { } } tanker:getController():pushTask(Tanker) 6 hours ago, Dangerzone said: Changing speed and heading for Supercarrier and fleet. You need to assign a new route to supercarrier or fleet unit. See next post. All info i've got from https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation and from "mission" file inside ".miz" archive when you first try to do something in mission editor before creating a script. Edited May 8, 2021 by Balion 1 Link to comment Share on other sites More sharing options...
Balion Posted May 8, 2021 Share Posted May 8, 2021 (edited) 9 hours ago, Dangerzone said: Changing speed and heading for Supercarrier and fleet. Here is a function which sets true heading and speed for a unit: local carrier = Unit.getByName("Naval-1-1") local function headTo(unitDCS, trueHeadingDegrees, speedMetersPerSecond, timeSeconds) local distance = timeSeconds * speedMetersPerSecond local delta = { z = distance * math.sin(trueHeadingDegrees * math.pi / 180), x = distance * math.cos(trueHeadingDegrees * math.pi / 180), } local position = unitDCS:getPoint() -- env.info(string.format("p x: %d, p z: %d", position.x, position.z)) -- env.info(string.format("d x: %d, d z: %d", delta.x, delta.z)) local Mission = { id = 'Mission', params = { ["route"] = { ["points"] = { [1] = { ["alt"] = -0, ["type"] = "Turning Point", ["ETA"] = 0, ["alt_type"] = "BARO", ["formation_template"] = "", ["y"] = position.z + delta.z, ["x"] = position.x + delta.x, ["ETA_locked"] = true, ["speed"] = speedMetersPerSecond, ["action"] = "Turning Point", ["task"] = { ["id"] = "ComboTask", ["params"] = { ["tasks"] = { }, -- end of ["tasks"] }, -- end of ["params"] }, -- end of ["task"] ["speed_locked"] = true, }, -- end of [1] }, -- end of ["points"] }, -- end of ["route"] } } unitDCS:getController():pushTask(Mission) end headTo(carrier, 100, 10, 600) -- set true heading 100 degrees and speed 10 m/s for 600 seconds. After 600 seconds carrier will stop. Edited May 8, 2021 by Balion 1 Link to comment Share on other sites More sharing options...
Dangerzone Posted May 9, 2021 Author Share Posted May 9, 2021 Aah - so it's not possible to do via MOOSE. Thanks for the work around! Link to comment Share on other sites More sharing options...
Recommended Posts