Page 1 of 1

How to obtain the actual GUID?

Posted: Sun Nov 26, 2023 3:45 am
by hanzawa1991
I would like to inquire about implementing a Lua script in a scenario where a blue faction aircraft (e.g., E-2D) detects a red faction target (e.g., HIMARS rocket) and then guides a blue faction suicide drone to attack the HIMARS (to be placed in a special action). I am facing two challenges in Lua programming: 1) How to obtain the actual GUID of the enemy's HIMARS from the perspective of the blue faction, so I can use commands like ScenEdit_KillUnit({guid = unit.guid}); 2) How to write a script for the drone to rapidly fly towards the target. :(

Re: How to obtain the actual GUID?

Posted: Sun Nov 26, 2023 11:37 am
by KLAB
Select the unit, in editor scroll down into the unit options or and amongst those menus there is copy GUID or from memory press Ctrl X and it should have copied the GUID for you to then paste wherever Text file etc.

I will check when I am near a machine but from memory getting GUID is straightforward.
K

Re: How to obtain the actual GUID?

Posted: Sun Nov 26, 2023 12:20 pm
by blu3s
You can obtain the guid for attacking a contact from its Contact Wrapper

Note that for AttackContact function you must use the Contact GUID and not the Unit GUID.

You can create an event with a trigger on UnitDetected, use the filters on TargetFilter to only triggers the HIMARS detection, and then with ScenEdit_UnitC() that gives you the contact wrapper of the unit that fires the event, use ScenEdit_AttackContact() or create a mission to attack the contact using your drones. More info about creating triggers and events here: https://commandlua.github.io/index2.html#EventHandling


Attached a Lua example, the first part it's the setup of the scenario, and the second part it's the logic for the Event Creation and a the function to attack the contact. Create a new scenario, open the lua console and copy paste the script.