DCS Mission Editing Tools and Discussion

With a Mist script you can also set the interval so it can test the condition at less than a second. I use that feature to detect planes going through spherical zones, like in Jumeirah Keyhole when they fly through the hotel.
It would be nice if a spherical zone could have an altitude setting, but I do not see a way for it.

1 Like

Hmmm…less that a second intervals…definitely some possibilities there…could really tweak my “Bomb Counter” routines to better handle ripple drops…right now I know I am double counting some bombs and try to allow for it. 1 sec seems too short and 2 sec too long.

I’ve been trying to develop missions without using Mist or other Lua scripting foundation constructs (for lack of a better term).

I fully realize that some things are impossible to do without them (especially Mist) and some things, like troops transport, can be done without them but are much easier and realistic with using them.

That said, I do feel it sort of limits the demographic of who can run my missions to the more than just the “casual user”. I think this is especially so when I am doing a simple mission.

Plus, the DCS Lua scripts should work for many things–simple things like above. I just want to trigger a Flag when one specific radar sees one specific airplane.

My work around with triggers is acceptable if not totally accurate. That said, once I can figure this out (my work for today) it will have application to something much nearer to my heart–Over the Horizon Targeting (OTHT) for naval combatants with long range ASCMs.

Currently, the AI naval combatants can “see” all hostile naval forces no matter how far away (score a point for the “Flat Earthers” I guess). So they shoot their missiles at near max range; well beyond what their radars can detect.

The OTHT idea would be to put a up helo (Ka-27 or SH-60) or aircraft (Tu-142 or S-3) “down range” from the naval combatant (ASCM shooter). Then use a Lua Predicate to determine when the helo/aircraft can detect the enemy combatant.

The DCS func isTargetDetected (DCS func isTargetDetected - DCS World Wiki - Hoggitworld.com) is pretty cool because it offers several detection types such as visual, optic, RWR, etc. I’m imagining ASW patrols (sub sighted then the sub goes “sinker”; submerges), WWII Coast Watchers with the Mariana’s map and the ability to do a limited kind of JFAC vs ships on the PG map. Again, with simple missions.

Anyway…much thanks to @WreckingCrew for adding so much to the thread and my understanding. :slightly_smiling_face:

1 Like

Where would a complete noob start looking for tutorials for mission building?

1 Like

Check out my site link above. There you can dl my recent v2.5 missions to see how they work. There is also a resources page with a script examples file and my flag scheme.

I pretty much stick to regular DCS type of events to make things work, with Mist to do the special stuff.

Thanks WreckingCrew!

1 Like

Also, all the missions that come with DCS and its add on aircraft / helicopters are visible by the ME. When opening a mission, just navigate over to the other missions and one one of them. This is a good way to see how the “pros” do Triggers. You may be surprised at the simplicity of the most things. :slightly_smiling_face:

1 Like

Just double checking…when using Group Alive Less Than condition, that means the Sum Total damage of the entire Group, yes?

So if I had 2 aircraft in a Group and one was destroyed, the Group would be at 50%.

Thus if I used a trigger condition of Group Alive Less Than 60% it would trigger.

But, might it also trigger if both aircraft were still alive but one was at 25% and the other at 31%?…not good but…still, combined to less that 60%…

So if I want a straight “If your wingman is shot down” trigger I have to use Unit is Dead condition? I think so but could use confirmation. :slightly_smiling_face:

1 Like

Correct; “group alive” is used exclusively in alive/dead situations. Damage doesn’t count. There’s a separate trigger if you want to detect damage/life %, but it is based exclusively on units and not groups.

A group of 4 aircraft means that if one is destroyed, group alive is now 75%; two destroyed is 50%; and so on.

1 Like

From page 125 of the DCS World manual 2020 ed. Its the example of a LUA predicate…has anybody gotten this to work?

Example code:
local _group = Group.getByName(‘your_group_name’);
if not (_group and _group:isExist()) then return false; end
local _controller = _group:getController();
local _targets = _controller:getDetectedTargets();
for _index, _target in ipairs(_targets) do
if _target.visible then return true; end – I see the enemy!!!
end
return false; – I don’t see the enemy…

  • If you type this text into the condition, the trigger will be triggered each time the
    specified group sees an adversary.

It would be a nice trigger condition for a JTAC mission - get a message when the enemy tanks finally drive into view so you don’t have to keep checking in and being told, “No. Nothing here.” or whatever he says.

I keep getting errors.

I know there is a JTAC script out there that passes coordinates and may even laze targets, some of the MP servers run it.

Thanks. I’ll look for that.

EDIT: Got it working…@#$! syntax error…they get me every time.

It’ll work but it’s a bit more complex than it should be. Also, no semicolons; LUA doesn’t need a line end notation.

For example, this is a simple fuel state and aerial state check that returns true if any units in the group have landed and have less than half fuel:

-- use double dash for comments in LUA - we don't need to attach anything to the group, just getting by their name which returns nil if they're nonexistent
if(Group.getByName("R_F403")) then
for i, unitObject in pairs(Group.getByName("R_F403"):getUnits()) do
    if(Unit.getFuel(unitObject) < 0.5 and Unit.inAir(unitObject) == false) then
        return true
    end
end
end
return false

For your script:

if(Group.getByName(‘your_group_name’)) then
local _controller = _group:getController()
local _targets = _controller:getDetectedTargets()
for _index, _target in ipairs(_targets) do
if _target.visible then return true end -- I see the enemy!!!
end
end
return false
1 Like

Wow! Thanks!

I like the fuel check - I assume I could set that to a Radio Command, set the inAir to True and get a wingman (or other aircraft) to report when they are less that 50% or some other percentage - much better than the current Wingman AI shouting “Bingo” and then ejecting.

I think I’m starting to understand it better - thanks to you.

Trying to get the AI to properly respect a bingo setting can be difficult, but it’s handy for certain assets like tactical tankers and AWACS. The above is another condition that can be used for a LUA predicate when another flight needs to start, like successive CAP coverage, fuelers, or AWACS.

If you give an aircraft the refuel task, they will either return to base or find a compatible refueling aircraft and get gas. I experimented with a custom bingo setting, but it gets complicated as every situation is different: I’d have to make sure the flight in question isn’t doing something critical before telling them they’re past bingo. End result was I’d have some Iranian F-14s heading out to intercept, then suddenly turning cold to go get gas as I set their bingo to 70% to cover the relatively large territory they had to patrol (as well as the long flight to the tanker). This meant I only used it for tactical tankers as they had a bad habit of giving away all their gas and then crashing in the pattern while waiting to land.

The other problem is AI burn rates don’t always reflect player burn rates and the AI is more willing to go burner and eject than the player is. It’s sadly hilarious to see a pair of Bugs set to escort an E-2 holding a stall state at 25,000ft in full burner because that’s how they interpret their escort task.

Long story short: Scripting AI is hard.

1 Like

LOL…that is way beyond the things I’ trying to do…I was thinking more of just setting it up so I can get my Wingman to tell me when he has something like 45% left so I can tell him to RTB before he flames out.

I’m also looking for something simple that will trigger a couple of SAM sites to go to ROE Weapons Free and maybe launch a pair of strip alert fighters.

Nothing fancy that ties everything together like the scripts I’ve tried (and failed) to understand. Just if Radar A detects Fighter B (the Player) then SAM C goes to WEAPONS FREE and Mig D is activated. It seems like such a waste that DCS has all this terrain masking modeled but there is no quick way to implement it with simple ME triggers.

Now that is funny! :slightly_smiling_face:

The triggers are good for simple things, less good for more nuanced tasks. It can be done, but usually it’s very clunky vice a script and all the triggers are doing is scripted actions anyways.

1 Like

Well…I think I am just trying to do something simple…maybe I’m in over my head. :hushed:

So…with that in mind…I’m looking at the Hoggit World site and I caught this on that last bit of Lua code you helped me with.

getDetectedTargets( Class self , enum detectionType1 , enum detectionType2 , enum detectionType3 … )
Description: Returns a table of detected targets that are detected by the different detection methods. If not detection method is specified, then all forms of detection will be used.

and a bit later on the page…

Detection Types
Conroller.Detection = {
VISUAL,
OPTIC,
RADAR,
IRST,
RWR,
DLINK
}

I am particularly interested in the statement "If not detection method is specified, then all forms of detection will be used.

So…if I applied that same bit of code as a LUA Predicate condition, to a radar…a land based EW or Search radar (or a ship?), shouldn’t it perform the same but trip the trigger when it detects a contact on radar?

Or would I have to specify “RADAR” inside the () as a detection type?

getDetectedTargets can be filtered to all the detection types listed above or just one, or even three from that list. In your script, it doesn’t specify; it just states whenever it finds a target on any of its available detection mechanisms/sensors, it’ll populate the detected target table. Not all units have the same sensors, so something like an EWR might only have its own radar and visual means. If you try to filter its targets to DLINK then you would (probably) always return no targets as the EWR doesn’t have a datalink.

local _targets = _controller:getDetectedTargets("RADAR","IRST")

This would specify that the detected targets returned must be in the RADAR and/or the IRST list. Without those modifiers, the entire spectrum is used – from a unit’s available sensors. Two useful functions in that regard:

https://wiki.hoggitworld.com/view/DCS_func_hasSensors

https://wiki.hoggitworld.com/view/DCS_func_getSensors

2 Likes

Wow oh Wow! That is very useful! …I never thought of IRST…and DLINK!!! I can definitely see some possibilities there!

…I want to start singing “A Whole New World” …but that would just be embarrassing…for everyone. :grimacing:

Thank you for taking the time to explain this to me. :grin:

EDIT: Plus, if I understand this correctly, it is applied to a group so that opens up a couple of possibilities.

1 - For a FAC I can place 2-3 units of the FAC group (e.g. TOW HUMVEES) where they have more LOSs and get triggered when one of the units sees an enemy.

2 - I can group together a couple of different sensor platforms, i.e. a BMP with a EW radar -and set the sensor list to “RADAR” and “VISUAL”. So while the radar will alert if it sees an enemy aircraft, the BMP will alert if it sees ground forces about to attack. Sure it will be an ambiguous warning but it will be a warning none the less…

Thanks again! You Rock!

2 Likes

Um…so I thought I might make a nice CSAR mission. I was adding some airplanes, some helos, some bad guys…the typical CSAR stuff; Then I realized, “I don’t have a downed pilot.”

Kind of came as a surprise since I know that both Russian and USAF pilots exist. I have jumped out of enough Viggens and MiGs to know that for a hard fact.

Is there any way to make one appear and maybe walk around a bit? Don’t need him to shoot anything just kind of run towards the CSAR helicopter when it lands.