Page 1 of 1

Removing Weapons from Aircraft in Air

Posted: Thu Mar 26, 2020 8:25 am
by TitaniumTrout
Is it possible to remove a weapon from an aircraft in the air?

I can iterate through the unit.mounts but I don't see the A2A (or any A2A) weapons I'd like to remove. I've tried both UpdateUnit and AddReloadsToUnit to remove weaponry but always get a mount not defined when I'm not sure which mount to reference.
Unit Mounts
{ [1] = { mount_dbid = 278, mount_weapons = { [1] = { wpn_maxcap = 6, wpn_current = 6, wpn_type = 2004, wpn_dbid = 1918, wpn_name = '20mm/85 M61A1 Vulcan Burst [100 rnds]', wpn_guid = 'demuu8-0hluhe5j50ab3', wpn_default = 6 } }, mount_status = 'Operational', mount_name = '20mm/85 M61A1 Vulcan [570 rnds]', mount_guid = 'demuu8-0hluhe5j50ab1' }, [2] = { mount_dbid = 1752, mount_weapons = { [1] = { wpn_maxcap = 12, wpn_current = 12, wpn_type = 2005, wpn_dbid = 564, wpn_name = 'Generic Chaff Salvo [5x Cartridges]', wpn_guid = 'demuu8-0hluhe5j50ab6', wpn_default = 12 }, [2] = { wpn_maxcap = 12, wpn_current = 12, wpn_type = 2005, wpn_dbid = 2051, wpn_name = 'Generic Flare Salvo [3x Cartridges, Dual Spectral]', wpn_guid = 'demuu8-0hluhe5j50ab7', wpn_default = 12 }, [3] = { wpn_maxcap = 8, wpn_current = 8, wpn_type = 2007, wpn_dbid = 3630, wpn_name = 'Perdix (Drone)', wpn_guid = 'demuu8-0hluhe5j50ab8', wpn_default = 8 } }, mount_status = 'Operational', mount_name = 'AN/ALE-47 CMDS x 4 [120 Cartridges]', mount_guid = 'demuu8-0hluhe5j50ab4' } }

Mount 1
{ mount_dbid = 278, mount_weapons = { [1] = { wpn_maxcap = 6, wpn_current = 6, wpn_type = 2004, wpn_dbid = 1918, wpn_name = '20mm/85 M61A1 Vulcan Burst [100 rnds]', wpn_guid = 'demuu8-0hluhe5j50ab3', wpn_default = 6 } }, mount_status = 'Operational', mount_name = '20mm/85 M61A1 Vulcan [570 rnds]', mount_guid = 'demuu8-0hluhe5j50ab1' }

Weapons 1
{ wpn_maxcap = 6, wpn_current = 6, wpn_type = 2004, wpn_dbid = 1918, wpn_name = '20mm/85 M61A1 Vulcan Burst [100 rnds]', wpn_guid = 'demuu8-0hluhe5j50ab3', wpn_default = 6 }
{ [1] = { mount_dbid = 278, mount_weapons = { [1] = { wpn_maxcap = 6, wpn_current = 6, wpn_type = 2004, wpn_dbid = 1918, wpn_name = '20mm/85 M61A1 Vulcan Burst [100 rnds]', wpn_guid = 'demuu8-0hluhe5j50ab3', wpn_default = 6 } }, mount_status = 'Operational', mount_name = '20mm/85 M61A1 Vulcan [570 rnds]', mount_guid = 'demuu8-0hluhe5j50ab1' }, [2] = { mount_dbid = 1752, mount_weapons = { [1] = { wpn_maxcap = 12, wpn_current = 12, wpn_type = 2005, wpn_dbid = 564, wpn_name = 'Generic Chaff Salvo [5x Cartridges]', wpn_guid = 'demuu8-0hluhe5j50ab6', wpn_default = 12 }, [2] = { wpn_maxcap = 12, wpn_current = 12, wpn_type = 2005, wpn_dbid = 2051, wpn_name = 'Generic Flare Salvo [3x Cartridges, Dual Spectral]', wpn_guid = 'demuu8-0hluhe5j50ab7', wpn_default = 12 }, [3] = { wpn_maxcap = 8, wpn_current = 8, wpn_type = 2007, wpn_dbid = 3630, wpn_name = 'Perdix (Drone)', wpn_guid = 'demuu8-0hluhe5j50ab8', wpn_default = 8 } }, mount_status = 'Operational', mount_name = 'AN/ALE-47 CMDS x 4 [120 Cartridges]', mount_guid = 'demuu8-0hluhe5j50ab4' } }

RE: Removing Weapons from Aircraft in Air

Posted: Thu Mar 26, 2020 9:41 am
by TitaniumTrout
Oops! Meant for this to go to the Lua Legion thread. Could a mod move it please?

RE: Removing Weapons from Aircraft in Air

Posted: Thu Mar 26, 2020 7:29 pm
by michaelm75au
I'll have to check but 'loadout' is additional to 'mounts' from memory. So it may not be included.
This shows you the load details
ScenEdit_GetLoadout (loadoutinfo)
but does not let you change it.

I'll see what would be needed to enable this.

RE: Removing Weapons from Aircraft in Air

Posted: Fri Mar 27, 2020 2:27 am
by KnightHawk75
ORIGINAL: michaelm75au

I'll have to check but 'loadout' is additional to 'mounts' from memory. So it may not be included.
This shows you the load details
ScenEdit_GetLoadout (loadoutinfo)
but does not let you change it.

I'll see what would be needed to enable this.

Pretty please with sprinkles on top. ;)
Ideally either added to normal mount list in first (or maybe last?) position, modifiable via usual add_\remove_ methods, or more ideally as separate table exposed for modification via a new func. This would greatly reduce the need to jump though other hoops when attempting certain customization.

BTW least in CMANO one could use the gui to add\remove weapons\fuel to a loadout that had an entry, which was handy and seems to have got removed in CMO, or at least the gui restricts it now, which is a bit of downgrade imho. Both the above and the return of the gui buttons would be helpful too.

RE: Removing Weapons from Aircraft in Air

Posted: Fri Mar 27, 2020 11:57 pm
by michaelm75au
I've update the 'SetLoadout' function so if you are not changing the loadout, you can affect the passed unit's weapons.
Include example where the first weapon of the load is being decreased by 1.
Note the 'ScenEdit_GetLoadout' currently will show you the loadout details. From this you can supply the wpn_dbid and/or the individual wpn_guid to the revised 'SetLoadout' (plus number to add/remove).
local unit = ScenEdit_GetUnit({name='fight #1'})
local lc = ScenEdit_GetLoadout({name='fight #1'})
print(lc.weapons)
print(ScenEdit_SetLoadout({name='fight #1', wpn_guid=lc.weapons[1].wpn_guid, number = 1, remove=true}))
print(ScenEdit_GetLoadout({name='fight #1'}).weapons)
{ [1] = { wpn_guid = '36a5589a-8f97-4d05-af44-654fc4e55f03', wpn_dbid = 446, wpn_name = 'AIM-120B AMRAAM', wpn_type = 2001, wpn_default = 1, wpn_maxcap = 1, wpn_current = 1 }, [2] = { wpn_guid = '86139529-4925-443d-a819-6e0b19374d3e', wpn_dbid = 1755, wpn_name = 'AIM-132A ASRAAM', wpn_type = 2001, wpn_default = 2, wpn_maxcap = 2, wpn_current = 2 }, [3] = { wpn_guid = '2ccf3830-cfd6-4504-b755-662bb4d69db9', wpn_dbid = 1814, wpn_name = 'Mk82 500lb LDGP', wpn_type = 2003, wpn_default = 8, wpn_maxcap = 8, wpn_current = 8 }, [4] = { wpn_guid = '3b5a5877-f302-48f2-bcbc-eff9f0bfe5c6', wpn_dbid = 544, wpn_name = 'AN/AAQ-28(V)4 Litening AT Pod [FLIR + LRMTS, 50k ft]', wpn_type = 3001, wpn_default = 1, wpn_maxcap = 1, wpn_current = 1 }, [5] = { wpn_guid = 'c688c672-9236-4783-b6d4-c6bb9c6376ec', wpn_dbid = 1522, wpn_name = '330 USG Drop Tank', wpn_type = 3002, wpn_default = 1, wpn_maxcap = 1, wpn_current = 1 } }
'Yes'
{ [1] = { wpn_guid = '36a5589a-8f97-4d05-af44-654fc4e55f03', wpn_dbid = 446, wpn_name = 'AIM-120B AMRAAM', wpn_type = 2001, wpn_default = 1, wpn_maxcap = 1, wpn_current = 0 }, [2] = { wpn_guid = '86139529-4925-443d-a819-6e0b19374d3e', wpn_dbid = 1755, wpn_name = 'AIM-132A ASRAAM', wpn_type = 2001, wpn_default = 2, wpn_maxcap = 2, wpn_current = 2 }, [3] = { wpn_guid = '2ccf3830-cfd6-4504-b755-662bb4d69db9', wpn_dbid = 1814, wpn_name = 'Mk82 500lb LDGP', wpn_type = 2003, wpn_default = 8, wpn_maxcap = 8, wpn_current = 8 }, [4] = { wpn_guid = '3b5a5877-f302-48f2-bcbc-eff9f0bfe5c6', wpn_dbid = 544, wpn_name = 'AN/AAQ-28(V)4 Litening AT Pod [FLIR + LRMTS, 50k ft]', wpn_type = 3001, wpn_default = 1, wpn_maxcap = 1, wpn_current = 1 }, [5] = { wpn_guid = 'c688c672-9236-4783-b6d4-c6bb9c6376ec', wpn_dbid = 1522, wpn_name = '330 USG Drop Tank', wpn_type = 3002, wpn_default = 1, wpn_maxcap = 1, wpn_current = 1 } }

This should come out in some future build[:D]

RE: Removing Weapons from Aircraft in Air

Posted: Sat Mar 28, 2020 7:05 am
by TitaniumTrout
That's great Michael, thanks!