Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Activate Mission Based on *Weapon* Detection?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Mods and Scenarios >> Lua Legion >> Activate Mission Based on *Weapon* Detection? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Activate Mission Based on *Weapon* Detection? - 4/14/2018 8:13:31 AM   
gpotter511

 

Posts: 11
Joined: 10/4/2017
Status: offline
Evening all -

I'm trying to create an event where the various Actions are triggered not by the detection of a unit, but by the detection of a certain type of ballistic missile. At scenario start, the platform carrying said weapon will be docked at a base.

I see the option exists to set a trigger based on a weapon, but the only option available under the dropdown reads, "None".

Any suggestions for how to go about this, or alternative paths that would achieve the same result?

Thanks!
Geoff
Post #: 1
RE: Activate Mission Based on *Weapon* Detection? - 4/14/2018 9:46:16 PM   
TitaniumTrout

 

Posts: 99
Joined: 10/20/2014
From: Michigan
Status: offline
You can use the weapon detected trigger and then a condition to check for altitude or speed. You could use this to differentiate from a SAM or AAM, or a cruise missile or dumb bomb.

local unit = ScenEdit_UnitX()
print(unit.speed)
local minSpeed = 350

if unit.speed <= minSpeed then
return true
else
return false
end


local unit = ScenEdit_UnitX()
print(unit.altitude)
local minAlt = 3000

if unit.altitude < minAlt then
return true
else
return false
end


I made a test scenario and fired a HARM into a zone. This is the function and the return :

>> local unit = ScenEdit_UnitX()
print(unit)
unit {
 type = 'Weapon', 
 subtype = '2001', 
 name = 'AGM-88C HARM #7', 
 side = 'OPFOR', 
 guid = 'cd94f9a5-b3d8-4cc8-b0d4-c08319d51b38', 
 proficiency = 'Regular', 
 latitude = '15.8438326179163', 
 longitude = '16.7833819762904', 
 altitude = '10469.97', 
 heading = '180.4915', 
 speed = '1964', 
 throttle = 'Cruise', 
 autodetectable = 'False', 
 mounts = '0', 
 unitstate = 'Unassigned', 
 fuelstate = 'None', 
 weaponstate = 'None', 
}


That's the variables you have to work with. Type won't change, you could compare subtypes if you know which to look for. Otherwise speed or altitude is a good one.


_____________________________


(in reply to gpotter511)
Post #: 2
RE: Activate Mission Based on *Weapon* Detection? - 4/15/2018 12:14:06 AM   
michaelm75au


Posts: 11895
Joined: 5/5/2001
From: Sydney, Australia
Status: offline
For more unit variables, look in the Command Lua wiki.

_____________________________

Michael

(in reply to TitaniumTrout)
Post #: 3
RE: Activate Mission Based on *Weapon* Detection? - 4/22/2018 5:18:23 PM   
gpotter511

 

Posts: 11
Joined: 10/4/2017
Status: offline
Thanks very much to both of you for this!

I started by attempting to replicate the outcome you described above, but I'm having trouble accomplishing that. I ran the script exactly as above while an F/A-18 fired an AGM-88E HARM into the zone, and the result was "ERROR: [string "Console"]:2: attempt to index local 'unit' (a nil value)". Efforts to replace "unit.speed" and "unit.altitude" with something else, e.g. the name of the weapon, were met with errors regarding a "malformed number". Can you advise?

Additionally - what is the expected sequence using the above script? Is this script what achieves the detection as part of the Event Condition, or does this script contribute to something else?

Thanks,
Geoff

(in reply to michaelm75au)
Post #: 4
RE: Activate Mission Based on *Weapon* Detection? - 4/22/2018 8:32:01 PM   
TitaniumTrout

 

Posts: 99
Joined: 10/20/2014
From: Michigan
Status: offline
So first you need to make the trigger. Nothing happens in regards to Lua (or any event) unless it's executed via a trigger or a special action. Once you have a trigger you need to associate with an event. Then once the trigger is actuated it will run whatever script or action you decide. I'll walk you through it.



I created two sides, OPFOR and BLUFOR. OPFOR has a radar and a bunker. The above trigger sets a detection zone, type.



I then create an action. All I want is a message box to pop up depending on what the altitude is. Then I make a message box to tell me what I'm seeing. You can also use the Lua Console after the trigger has fired and enter it there.



Finally I stick each into an event.



I fire a pair of Storm Shadows from a Tornado GR4. Once the radar detects them, and it's inside the set zone, I get the above info.


_____________________________


(in reply to gpotter511)
Post #: 5
RE: Activate Mission Based on *Weapon* Detection? - 4/22/2018 11:54:04 PM   
gpotter511

 

Posts: 11
Joined: 10/4/2017
Status: offline
Thanks for taking the time to lay this out, Titanium Trout. I was making the error of using this script as a Condition, on the premise that a detected weapon trigger, modified by the condition of this Lua script, would tell Command to trigger an "Activate Mission" action. The idea is to have the detection of an SLBM attack by OPFOR trigger an ICBM counterattack by BLUFOR.

In order to achieve that result - would it make the most sense to pair an action spitting out this message with a second action activating the counterattack mission?

Thanks,
Geoff

(in reply to TitaniumTrout)
Post #: 6
RE: Activate Mission Based on *Weapon* Detection? - 4/23/2018 11:24:32 AM   
TitaniumTrout

 

Posts: 99
Joined: 10/20/2014
From: Michigan
Status: offline
You could do it simply, without Lua, using the trigger above and a Mission Status Action. This changes a mission from passive to active or vice-versa. The problem is if an AAM missile overflew the trigger area it would fire and the ICBM's would launch. Whoops.

So then you need a way to compare name, or altitude, or speed, then use ScenEdit_SetMission to set it active.

_____________________________


(in reply to gpotter511)
Post #: 7
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Mods and Scenarios >> Lua Legion >> Activate Mission Based on *Weapon* Detection? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.102