Damaging a Specific Sensor

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Kushan04
Posts: 1239
Joined: Tue Jun 28, 2005 9:27 pm
Location: USA
Contact:

Damaging a Specific Sensor

Post by Kushan04 »

I'm trying to destroy a specific sensor on an aircraft. The following bit of code will damage a sensor, but instead of damaging the one specified its damaging a random sensor.

Code: Select all

ScenEdit_SetUnitDamage({side='Good Guys', unitname='F-111F Aardvark', components={{'type',type='sensor',comp_name='AN/AVQ-26 [Laser Designator',2}}})

Can anyone please tell me what I'm doing wrong? Thank you in advance!
User avatar
stilesw
Posts: 1572
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: Damaging a Specific Sensor

Post by stilesw »

ScenEdit_SetUnitDamage({side='Good Guys', unitname='F-111F Aardvark', components={{'type',type='sensor',comp_name='AN/AVQ-26 [Laser Designator',2}}})
Brandon,

I could be wrong but I "think" the online reference may be incorrect. My suggestion would be to remove 'type', as typically it should be just type='sensor'. So I would try removing the highlighted word:

ScenEdit_SetUnitDamage({side='Good Guys', unitname='F-111F Aardvark', components={{'type',type='sensor',comp_name='AN/AVQ-26 [Laser Designator',2}}})

-Wayne
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Damaging a Specific Sensor

Post by michaelm75au »

{'type',type='sensor',1}
means change the damage level of a 'sensor' on the unit to 1

To damage a specific component, you need to supply the actual component GUID (you can't go by name as there could be multiple sensors with same name).
{'16a883a2-8e7f-4313-aae7-0af644c16337',1}
means change the damage level of the component '16a883a2-8e7f-4313-aae7-0af644c16337' on the unit to 1

Sample
specific SRBOC showing light damage
Line 38: { [1] = { type = 'Mount', damage = Light, guid = 'ddbe1ca7-c298-45f9-b1f3-ade1d4d1f45c', status = Damaged, name = 'Mk36 SRBOC', dbid = 565 }, [2] = { status = Damaged, damage = Light, name = 'CIC' } }

Set damage for specific SRBOC to medium
Line 60: local a = ScenEdit_SetUnitDamage({name='AOE 421 Sagami', guid='004aa55d-d553-428d-a727-26853737c8f4',components={ {'ddbe1ca7-c298-45f9-b1f3-ade1d4d1f45c','Medium'},{'CIC','Light'} },flood=1})

Results in damage to specific component only
Line 64: { [1] = { comp_status = Operational, comp_dbid = 1175, comp_guid = '04beaf43-9750-41f9-aa20-13f3d23c5cb1', comp_type = 'Sensor', comp_name = 'J/OPS-16C' }, [2] = { comp_status = Operational, comp_dbid = 0, comp_guid = '73121410-96b8-40ad-a555-5c3346ef723e', comp_type = 'Sensor', comp_name = 'Mk1 Eyeball' }, [3] = { comp_status = Operational, comp_dbid = 565, comp_guid = '4e0c45b0-2ebf-4244-8b32-fabedb359a7d', comp_type = 'Mount', comp_name = 'Mk36 SRBOC' }, [4] = { comp_status = Damaged, comp_damage = Medium, comp_dbid = 565, comp_guid = 'ddbe1ca7-c298-45f9-b1f3-ade1d4d1f45c', comp_type = 'Mount', comp_name = 'Mk36 SRBOC' }, [5] = { comp_status = Operational, comp_dbid = 565, comp_guid = 'bca76fa9-a511-41ec-a410-a07014d9d393', comp_type = 'Mount', comp_name = 'Mk36 SRBOC' }, [6] = { comp_status = Operational, comp_dbid = 565, comp_guid = '864d0d3f-a11e-4f5d-a22a-65771d38c5d1', comp_type = 'Mount', comp_name = 'Mk36 SRBOC' }, [7] = { comp_status = Operational, comp_dbid = 72, comp_guid = '248b48...
Line 65: { [1] = { type = 'Mount', damage = Medium, guid = 'ddbe1ca7-c298-45f9-b1f3-ade1d4d1f45c', status = Damaged, name = 'Mk36 SRBOC', dbid = 565 }, [2] = { status = Damaged, damage = Light, name = 'CIC' } }
Michael
Bashkire
Posts: 81
Joined: Mon Feb 23, 2015 6:28 pm

RE: Damaging a Specific Sensor

Post by Bashkire »

Sorry to necro a thread, but could you help me with the syntax for damaging some components? I'm trying to use GUIDs, but it doess't seem to be working as intended.

Currently I have tried the following 2 types of code:

Code: Select all

 ScenEdit_SetUnitDamage({side="NATO", unitname="[L 14] HMS Albion [LPD]", fires=1, components={{"6G4KQB-0HM16BU5RNE4P", 2}}});
 
 ScenEdit_SetUnitDamage({side="NATO", unitname="[L 14] HMS Albion [LPD]", fires=1, components={{"6G4KQB-0HM16BU5RNE4Q", 2}}});
 
 ScenEdit_SetUnitDamage({side="NATO", unitname="[L 14] HMS Albion [LPD]", fires=1, components={{"6G4KQB-0HM16BU5RNE4R", 2}}});
 
and

Code: Select all

ScenEdit_SetUnitDamage({side = "NATO", unitname='[L 14] HMS Albion [LPD]', components={ {'6G4KQB-0HM16BU5RNE4P','Medium'}},fires=1})
 
 ScenEdit_SetUnitDamage({side = "NATO", unitname='[L 14] HMS Albion [LPD]', components={ {'6G4KQB-0HM16BU5RNE4Q','Medium'}},fires=1})
 
 ScenEdit_SetUnitDamage({side = "NATO", unitname='[L 14] HMS Albion [LPD]', components={ {'6G4KQB-0HM16BU5RNE4R','Medium'}},fires=1})

Both methods cause fires, but the landing pads stay mysteriously undamaged
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Damaging a Specific Sensor

Post by KnightHawk75 »

@Bashkire

ScenEdit_SetUnitDamage({unitname='6g4kqb-0hlt9ge7br1es', fires=1,components={ {'6g4kqb-0hlv7lnpvs53a','Medium'}}})
ScenEdit_SetUnitDamage({unitname='6g4kqb-0hlt9ge7br1es', fires=1,components={ {'6g4kqb-0hlv7lnpvs53b','Medium'}}})

Worked fine on the sample scene you posted, damaged both pads and put the ship on fire.
Bashkire
Posts: 81
Joined: Mon Feb 23, 2015 6:28 pm

RE: Damaging a Specific Sensor

Post by Bashkire »

You again! People are going to start talking!

Cheers. That's working wonderfully. Where are you getting the references for those components, though? If I "print (unit.components)" then I get a lot of GUIDs but none of them are the strings you've mentioned above.

It would just be good to know so I can use this code for future reference.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Damaging a Specific Sensor

Post by KnightHawk75 »

I pulled them from the same list of unit.components from the ship in the scene you posted in the other thread.
Obviously if you're not using that scene the guids are likely different but I used it as a sample available to both of us for demonstration purposes.

The following may help you narrow down the 'printed' list to just the helicopter pads though, instead of just dumping everything.

Code: Select all

local unit = SE_GetUnit({side="NATO", name="[L 14] HMS Albion [LPD]"});
 for k,v in pairs(unit.components) do
   if v.comp_name:find('Pad') ~=nil then  --if the name includes the string 'Pad' do the following..
     print(v.comp_name .. ':  ' .. v.comp_guid)  -- dump just the name and the guid to output
     -- could just optionally do the damage right now too...
     --ScenEdit_SetUnitDamage({unitname=unit.guid, fires=1,components={ {v.comp_guid,'Medium'}}}) 
   end
 end
 

Bashkire
Posts: 81
Joined: Mon Feb 23, 2015 6:28 pm

RE: Damaging a Specific Sensor

Post by Bashkire »

Ah, no I see what I was doing. I was referencing an HMS Albion from my test mission rather than the actual one I'm working on so the GUIDs were different.

Cheers for showing me where I was going wrong! :D
Post Reply

Return to “Lua Legion”