Accessing aircraft weapons loads..

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
SeaQueen
Posts: 1432
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

Accessing aircraft weapons loads..

Post by SeaQueen »

I'm trying to detect if an aircraft has dropped a mine or not. I figured that it might be possible to do that by determining its weapons load at scenario load, then testing periodically during the scenario load if it had changed. I'm not sure how to get at the current aircraft weapons load, though. Is there an undocumented object?
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Accessing aircraft weapons loads..

Post by KnightHawk75 »

ORIGINAL: SeaQueen

I'm trying to detect if an aircraft has dropped a mine or not. I figured that it might be possible to do that by determining its weapons load at scenario load, then testing periodically during the scenario load if it had changed. I'm not sure how to get at the current aircraft weapons load, though. Is there an undocumented object?

Short version: I don't know of way to access the loadout mount data (I'm just calling it a mount cause it sort of appears as one via the editor-weapons window).It would be really helpful if we could view\edit that 'loadout' mount no different than any other mount both query wise and update wise, for adding\removing weapons.

Long version:
A way around to what you want (and it may not work for your particular aircraft or circumstances) that works sometimes for me is to give it a true-loadout that doesn't include your mines, then add the mines to either an existing mount, or add a new mount and add the mine weapons (and others if needed) to that one. Should be usable for the aircraft, while also it gives you a weapon-store state you can actually query (and update if needed via UnitObj.mounts and updateunit).

For instance if I wanted to track if an f-18 had fired it's amraams I would give it a ferry loadout, and via lua or delta stick all the other gear on an extra mount (upon detecting a takeoff of said aircraft or aircraft type), the extra mounts get whatever the real loadout would usually have. Just make sure the mount you choose has a fire rate that roughly matches, Tomahawk vls's have worked well for me on aircraft and other things. Then I can query and update the mount tables as see fit. It's quite the workaround though, but it's all I've come up with thus far in my travels. *shug*.

There are two downsides to this workaround that I know of besides all the extra work involved. First is things on non-loadout mounts generally do not impact your aircraft's weight (as they probably shouldn't), so you lose decent amount of realism when it comes to fuel burn. Second while you can add droptanks\bladders to mounts other than 'loadout' they are effectively ignored (not counted toward fuel capacity like they are when on a loadout-mount).
User avatar
SeaQueen
Posts: 1432
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

RE: Accessing aircraft weapons loads..

Post by SeaQueen »

It seems like there needs to be LUA functions added to deal specifically with mines and mining. It makes for interesting scenarios involving bombers, naval aviation, and submarines, but right now, in many ways, mines are just another weapon. The thing is, since mines have value shaping the battlespace as well as in destroying things, it's completely possible for "victory" to be just planting the mines without killing anything.
Without a good way to detect mines in an area using LUA, there's not really a good way to write victory/scoring conditions dealing with mines, or maybe influence AI behavior by activating "No-Nav" zones in response to mine detection.

There really needs to be two functions, the first returns the number of mines in a given area (or even better, a list of guids), and the second returns the guids of the mines that are currently detected. I haven't experimented with it yet, but it seems like mine contacts are treated differently than ordinary sensor contacts. Is that true?
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Accessing aircraft weapons loads..

Post by michaelm75au »

Loadout details can be accessed by ScenEdit_GetLoadout().
However I just noticed that it doesn't show the current number of weapons left. I have corrected that so you can pull up any loadout details or the one for the requested aircraft.
local l = ScenEdit_GetLoadout({name='Hunter #6', guid='3e6aa437-329e-41bc-b476-db594b60b321'})
print(l.weapons) -- loaded onboard
--------------------
{ [1] = { wpn_default = 45, wpn_current = 20, wpn_type = 4004, wpn_dbid = 2086, wpn_name = 'Mk62 Quickstrike [Mk82]', wpn_maxcap = 45, wpn_guid = '03e87643-9d93-48c8-bfa4-cba13e03d029' } }

local l = ScenEdit_GetLoadout({name='Hunter #6', guid='3e6aa437-329e-41bc-b476-db594b60b321', LOADOUTID=15})
print(l.weapons) -- view what this loadout looks like; the loadout doesn't have to be valid for the aircraft
--------------------
{ [1] = { wpn_default = 10, wpn_name = 'Mk83 1000lb LDGP', wpn_maxcap = 10, wpn_current = 10, wpn_guid = '3092d82b-4aae-4532-bc02-f4580cb5f642', wpn_type = 2003, wpn_dbid = 1925 }, [2] = { wpn_default = 1, wpn_name = '300 USG Drop Tank', wpn_maxcap = 1, wpn_current = 1, wpn_guid = '015e18b3-b081-49e5-9044-04ec709148a5', wpn_type = 3002, wpn_dbid = 1523 } }
Michael
User avatar
SeaQueen
Posts: 1432
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

RE: Accessing aircraft weapons loads..

Post by SeaQueen »

Excellent...

Now at least I can tell if the mines are dropped. The interesting bit is whether they're in the right place or not...
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Accessing aircraft weapons loads..

Post by KnightHawk75 »

ORIGINAL: michaelm75au

Loadout details can be accessed by ScenEdit_GetLoadout().
However I just noticed that it doesn't show the current number of weapons left. I have corrected that so you can pull up any loadout details or the one for the requested aircraft.
local l = ScenEdit_GetLoadout({name='Hunter #6', guid='3e6aa437-329e-41bc-b476-db594b60b321'})
print(l.weapons) -- loaded onboard
--------------------
{ [1] = { wpn_default = 45, wpn_current = 20, wpn_type = 4004, wpn_dbid = 2086, wpn_name = 'Mk62 Quickstrike [Mk82]', wpn_maxcap = 45, wpn_guid = '03e87643-9d93-48c8-bfa4-cba13e03d029' } }

local l = ScenEdit_GetLoadout({name='Hunter #6', guid='3e6aa437-329e-41bc-b476-db594b60b321', LOADOUTID=15})
print(l.weapons) -- view what this loadout looks like; the loadout doesn't have to be valid for the aircraft
--------------------
{ [1] = { wpn_default = 10, wpn_name = 'Mk83 1000lb LDGP', wpn_maxcap = 10, wpn_current = 10, wpn_guid = '3092d82b-4aae-4532-bc02-f4580cb5f642', wpn_type = 2003, wpn_dbid = 1925 }, [2] = { wpn_default = 1, wpn_name = '300 USG Drop Tank', wpn_maxcap = 1, wpn_current = 1, wpn_guid = '015e18b3-b081-49e5-9044-04ec709148a5', wpn_type = 3002, wpn_dbid = 1523 } }

Thanks. wpn_current showing up in future is helpful
Post Reply

Return to “Lua Legion”