Adding Groups to a Mission

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
ProdigyofMilitaryPride
Posts: 106
Joined: Thu Apr 16, 2015 11:54 pm

Adding Groups to a Mission

Post by ProdigyofMilitaryPride »

I'm planning to use LUA for a Soviet bomber raid on a US carrier group [that's defending the western Iceland from Soviet aggression] after being detected by patrol aircraft near Iceland.
How is it supposed to be done? What strings do I need? What specialized lines of code might be required?
"The courageous must protect freedom." - Dwight D. Eisenhower
"Anything built by human hands can be destroyed. This is no exception." - Kei "Edge" Nagase, Ace Combat 5: The Unsung War
boogabooga
Posts: 988
Joined: Wed Jul 18, 2018 12:05 am

RE: Adding Groups to a Mission

Post by boogabooga »

Greetings.

You really should read the manual and practice mission building a little. Experiment.

But to answer your question-

You may not even need Lua at all, or even a scripted event. Is that carrier group the Soviets' only possible target? If so, you could just assign the bombers to an ASuW Strike mission with no specific target. The strike will launch as soon as suitable targets are detected.

Try to get familiar with the C:MO mission system before anything else.
The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Adding Groups to a Mission

Post by KnightHawk75 »

If it's basic you don't need much, maybe 3 lines, the rest you can do with events, depends on how dynamic you need it to be and how dynamic the scene will be though, the more complex and dynamic the more code, but you can cover a lot ground with just a couple lines.

Attached a simple little sample that highlights a basic detection and mission activation, along with a two line action that adds the detected things to premade missions targetlist as it detects each at a certain level. It's just meant to show you what's already built in with nearly no LUA, recon detects ships, ships get added, strike mission begins while more are still being detected.

db488 required v1147.20+
TesRig-AddTargetsToMissionOnDetection-SampleMinimalLua2_posted5009303.zip

As for the specific question of how to add a group to a mission, simple way is a one-liner.

Code: Select all

 ScenEdit_AssignUnitToMission("SomeUniqueGroupNameHere","TheUniqueStrikeMissionName");
 -- If one or neither 'names' are unique in the total scene, but are at least on the side then:
 local g = ScenEdit_GetUnit({side="USSR",name="TheGroupNameHere"});
 local m = ScenEdit_GetMission('USSR','TheMissionName');
 ScenEdit_AssignUnitToMission(g.guid,m.guid)
Attachments
TesRigAdd..d5009303.zip
(91.67 KiB) Downloaded 12 times
Post Reply

Return to “Lua Legion”