Jump to content

Air-Ground Attack Script


MBot

Recommended Posts

The purpose of this script is to enable the AI to perform efficient air-ground attacks using level, dive, pop-up and offset pop-up tactics. The general idea is that the AI flights must be able to ingress and egress smoothly, when needed adjust altitude quickly, attack multiple targets simultaneously and not do any unnecessary maneuvering in the target area. Get in, strike and get out quickly, especially in a high threat environment.

Many elements of this script are not new and as various Custom Attack scripts have been part of my Dynamic Campaign Engine for a long time. Some weeks ago, I realized that it is possible to script advanced offset pop-up attacks tactics. The general idea is that by using Aerobatics tasks it is possible to maneuver the AI from low level through the pop-up and put it into a position from where it can perform the native DCS AI dive attack. While this new offset pop-up attack tactic is the main attraction, I decided that it would be worthwhile to clean up my older attack scrips, condense everything into a single multi-purpose script and release it to the public.

 

(all scenes show a single AI-flight)

 

Features:

  • Realistic offset pop-up attacks from low level which have not previously been possible using default DCS AI behavior. This allows AI aircraft to approach targets at low level in cover from high/medium range SAMs, then pop-up to attack from above the AAA threat, thus greatly increasing AI survivability in high-threat environments.
  • Ability to set-up various traditional level and dive attack profiles.
  • Depending on ingress-egress geometry, aircraft in a flight can perform offset pop-up attacks from one or two sides.
  • Each aircraft is able to attack its own sub-target element independently, allowing simultaneous attacks of all aircraft in a flight against multiple vehicles, ships, static objects or scenery objects. With default DCS AI behavior this has not been possible for static or scenery objects.
  • After weapons release, all aircraft in a flight will perform a hard turn towards the egress direction and proceed towards the egress point individually, where the flight will form up again. This eliminates standard DCS AI behavior where flights will try to reform directly after weapon release, leading to unnecessary maneuvering in the target area. This also means that all aircraft are free to immediately climb/descend back to safe altitude after weapon release (default DCS AI behavior means that the flight leader is unable to change altitude until all wingmen have rejoined, leading to lingering at weapon release altitude over the target area).
  • Works for full AI flights and for AI wingmen of human players.

 

Mission Editor Instructions:

  • Include the “AirGroundAttackScript.lua” with a "Do Script File" trigger in your mission.
  • At the waypoint where you want your flight start the attack, under Advanced Waypoint Actions, add a Run Script action. Insert the following code to this action:

 

AirGroundAttackTask(FlightName, Target, WeaponType, ExpendQty, Dive, OffsetAngle, ClimbAngle, PopAlt, AttackDist, Reattack)

Function argument description:

FlightName "Aerial-1" Group name of flight that is tasked to attack

Target

-Option 1

-Option 2

-Option 3

-Option 4

 

"Ground-1"

{"StaticName-1", StaticName-2", StaticName-N"}

{{x = 123, y = 123}, {x = 456, y = 456}}

{x = 123, y = 123}

Four types of ground targets can be attacked (vehicles/ships, static objects, scenery objects, parked aircraft/helicopters)

Vehicles/Ships: Group name of vehicle or ship group

Static Objects: Object name of static object, listed in {} (a single static objects also needs {} ).

Scenery Objects: x-/y-coordinate of scenery object in {}, listed in {} (a single scenery objects needs double {{}} ).

Parked aircraft or helicopters: x-/y-coordinate in {}. Stationary aircraft or helicopters within 5000 m of this coordinate will be attacked.

WeaponType

-Option 1

-Option 2

-Option 3

-Option 4

-Option 5

-Option 6

-Option 7

 

"Auto"

"Cannon"

"Rockets" 

"Bombs"

"Guided bombs"

"ASM"

number

Weapon type for the attack

Automatic weapon type selection (note: might lead to gun strafing)

Attack with gun

Attack with unguided rockets

Attack with unguided bombs

Attack with guided bombs

Attack with guided missiles

Alternatively, the internal DCS code for certain weapon types or combinations of weapon types may be entered as a number

ExpendQty

-Option 1

-Option 2

-Option 3

-Option 4

-Option 5

-Option 6

-Option 7

 

"Auto"

"One"

"Two"

"Four"

"Quarter"

"Half"

 "All"

Number of weapons to be expended per attack run

Automatic selection of number of weapons to be expended

Expend one weapon

Expend two weapons

Expend four weapons

Expend 1/4 of weapons carried per type

Expend 1/2 of weapons carried per type

Expend all weapons carried per type

Dive

-Option 1

-Option 2

-Option 3

 

true

false

nil

Whether a dive attack is performed

Perform a dive attack (when possible)

Perform a level attack (when possible)

Perform a level attack (when possible)

OffsetAngle

-Option 1

-Option 2

-Option 3

 

number

0

nil

Offset turn to side prior to pop-up maneuver

Angle in degrees of offset turn (enter positive number only, offset side is determined by egress geometry)

Do not perform an offset turn

Do not perform an offset turn

ClimbAngle number The climb angle in degrees for any pop-up climb (climb angles smaller than 15 are not possible)

PopAlt

-Option 1

-Option 2

-Option 3

 

number

0

nil

Pop-up maneuver prior to attack

Height in meters above target to which a pop-up shall be performed

Do not perform a pop-up maneuver

Do not perform a pop-up maneuver

AttackDist

-Option 1

-Option 2

-Option 3

 

number

nil

nil

Distance from target where a pop-up maneuver shall be completed (if no pop-up maneuver is performed, this is ignored and attacks will be initiated immediately)

Distance in meters (useful to set a specific distance for weapons with stand-off range such as missiles and heavy rockets)

When attacking with bombs, the distance will be calculated automatically in order to keep to pop-up as short as possible

When attacking with rockets, a generic distance is selected automatically that works with the most common rocket types

Reattack

-Option 1

-Option 2

-Option 3

 

true

false

nil

Whether aircraft egress after the first attack or return for subsequent attacks

Repeat attacks as long as weapons and targets remain

Egress after first attack

Egress after first attack

Several demo missions are attached for your convenience, where you can see how the script is used in practice.

 

Notes and known issues:

  • The offset pop-up attacks have been scripted to be as realistic and smooth as possible. You will note that when attacking with bombs, after climbing and rolling into the target, AI aircraft will fly level for 10+ seconds before starting to dive. This unfortunately is due to the way the DCS AI is set up and is unavoidable, as the AI needs a certain distance from the target to attack it. This level flight part has carefully been scripted to be as short as possible for any given speed and altitude (if it is made too short, the AI will turn around and return from a longer distance). You will notice that when attacking with rockets, the AI is able to dive on the target instantly.
  • Offset side for a pop-up attack is automatically selected based on egress direction. If the egress waypoint is in the right quarter of the target, aircraft will offset left and attack towards the right (and vice versa). If the egress direction is either in the quarter ahead or behind of the target (from where the flight came from), the flight will split and make a pincer attack from left and right simultaneously.
  • The next waypoint after the attack waypoint (where the attack is tasked) is automatically selected as the egress waypoint. Alternatively, if any waypoint is named “Egress”, it will be selected as egress waypoint instead (this way you can have the attack waypoint ahead of the target, a waypoint at the target itself and the next waypoint named “Egress” away from the target).
  • Aircraft in a flight will slightly modulate offset angle, climb angle and pop-up altitude in order to create timing separation over the target.
  • The script also works for AI wingman of a human player. Set up the task for the player flight in the Mission Editor exactly the same as for an AI flight. During the mission, before reaching the attack waypoint, order “Attack Mission Target and Rejoin” via the radio. Your AI wingmen will perform their attacks as set-up, proceed to the egress point and then form up with you again without any further commands required.
  • I made a very big effort to accurately calculate the maneuver geometry for pop-up attacks. As the execution of this maneuvers by the AI is highly depending on many factors (such as aircraft type, speed, altitude, weight, AOA, available Gs, turn radius as well as some DCS bugs), there might be cases where the AI will not be in the anticipated position when rolling out on the target and not initiate an attack. Hopefully it will be rare, but better first verify that any combination of aircraft type, weapons, offset angle, climb angle, pop-up altitude etc. works correctly.
  • Offset pop-up attacks over uneven terrain might be problematic. There seems to be a DCS bug that minimum attack distance is depending on aircraft height above terrain below the aircraft, instead of aircraft height above the target. This means that pop-up maneuvers may fail to lead to the AI initiating an attack if they are over higher terrain than the target elevation at that moment. Higher targets (such as on a hilltop) with pop-ups over lower ground are not affected by this problem. The attack geometry is actually always calculated correctly and takes target elevation into account.

 

I hope this script will help you to make the AI in your mission behave a little more realistic during air-ground attacks and be more survivable in high-threat environments.

AirGroundAttackScript.lua AirGroundAttackScript_Demo_OffsetPop_Static_Rockets.miz AirGroundAttackScript_Demo_Dive_Scenery_Bombs.miz AirGroundAttackScript_Demo_Pop_Scenery_Bombs.miz AirGroundAttackScript_Demo_Pop_Ship_ASM.miz AirGroundAttackScript_Demo_OffsetPop_Vehicle_Rockets.miz AirGroundAttackScript_Demo_OffsetPop_Airbase_Rockets.miz AirGroundAttackScript_Demo_OffsetPop_Vehicle_Bombs.miz AirGroundAttackScript_Demo_OffsetPop_Vehicle_ASM.miz AirGroundAttackScript_Demo_Level_Scenery_GuidedBombs_Repeat.miz

  • Like 9
  • Thanks 1
Link to comment
Share on other sites

13 hours ago, schurem said:

Wow! Would you have a problem with this stuff ( I watched all of the vid, and they look excellent) being incorporated into paid DLC content or mayhaps even the core game itself? Because that would be awesome 😄

If content creators would want to use this in paid DLC, I would be ok as long as I would be credited appropriately. Of course everybody can use the script for free missions.

I doubt that ED would incorporate this into the core game. There is a ton of workarounds for basic game limitations in the code, which would be better fixed on the game side instead. I hope (and expect) that ED at some point will properly add these capabilities on their own. We definitely need the minimum distances for dive bombing gone. The AI needs to be able to dive on the target right from rolling out of the apex of the pop-up maneuver.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Really cool to see this. Ive been tinkering with trying to make the AI do pop up stuff with the aerobatics a bit, but that was all thru triggers and was a bitch to setup and didnt work well. Seems doing it thru scripting gets you much better results.

 

Do you think something similar could work with AI for air to air attacks as well? Ive been playing with the idea of using the aerobatics to make the AI give different threat presentations. Its just an absolute cluster to try and setup with a bunch of triggers, I would think a script would likely simplify this?

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Hi MBot and everyone.

Thanks for a nice script. I am using it with MIST group respawn in a PvE scenario where AI attacks the same target over and over again. First attack works as a charm but then next ones do not work at all. I noticed two examples:

1) Group of statics is attacked and some of them are destroyed. The next attack (respawned group) ignores the remaining targets completely and just proceed to egress.

2) Same thing happens for a target group that was partially destroyed in the first attack. The second AirGroundAttackTask call (by respawned group) does not work and the STRIKE group just RTBs.

I checked that the attack function is properly called by respawned groups. Not sure where to look next. Any idea what might be wrong?

I attach the mission file with one strike group attacking statics. You can kill it after the strike is done with a radio command. It will be respawned and should attack remaining targets again.

PvE_battle_Caucasus-test.miz

Link to comment
Share on other sites

  • 3 months later...
On 9/5/2022 at 10:13 PM, bennyboy9800 said:

Hey mBot, is there a way to code this to create a LOFT profile for bombs and rockets?

I managed to get a decent loft profile for Walleyes by carefully tuning a ton of parameters. It basically also works for bombs but because they lack the glide range of the Walleye, the aircraft basically ends up over the target the same as with a level release. A steeper loft angle would be better for bombs, but the Walleye profile is the most that is possible with the AI. Keep in mind that this is not a native DCS feature but basically exploiting existing AI routines to the most extend possible.

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

What a great script idea, I was really hoping it would work for me... but can't figure out how to get it to work in any kind of hilly terrain. I have a target on a 5,000' hill and trying to do a level bombing run with an A-10 and unguided bombs. Straight in approach, level run. I thought that it just needed extra altitude, so started at 7,500 and went up in increments from there all the way to 20,000. All of them were the same, as soon as it hits the attack waypoint it turns off the direction of the target.

So then I though, well maybe it needs extra distance to figure it out. So I moved the attack waypoint out from 10, to 15, 20 miles. All the same, it hits the attack waypoint and turns off the direction of the attack.

It will eventually figure it out and turn back and make the attack, but the AI pretty much does this on it's own without the script.

Any ideas? Is this for flat ground only? It does work nice on flat ground, I did get that to work.

Link to comment
Share on other sites

  I have included your AirGroundAttackScript.lua code into my mission project. I am testing out the script with two single unit SU-25 groups which are loaded with 2x air to ground missiles.  Both groups are late activated and their names get added a numbered extenstion  "SuMo24#001" in order to be recognized by lua code and moose engine.

When I run the mission I find sometimes ONLY the first bomber will drop bombs on the target . A lot of the times they both  just fly over it and go back home to land. 

And when it drops bombs it ignores the target and drops them on whatever tanks it can find in the vicinity .     I really need a script that will actually attack the group it is designated to attack ONLY.   Anyhow  included here is  a copy of the AirGroundAttackTask function and it args , and then my modified copy that I am using inside the mission

Quote

 

AirGroundAttackTask(FlightName, Target,        WeaponType, ExpendQty, Dive, OffsetAngle, ClimbAngle, PopAlt, AttackDist, Reattack)


AirGroundAttackTask("SuMo24#001", "TankGroupSH-24","ASM", "One", true,0, 0, nil, nil, true)

 

 

Link to comment
Share on other sites

  • 1 month later...

Thank you very much for your script!!!

Is awesome!

Finally I've been able to make the idiot AI to accurately bomb where ordered without roaming around in circles.

Is excellent.

Could it be possible to add some addtional features like being able to choose the delay of the bomb dropping sequence to spread them a bit more when launching all?

And also, would you have a similar script to enable proper runaway bombing runs.

 

Thanks again for your excellent contribution

Link to comment
Share on other sites

  • 4 months later...
On 9/10/2022 at 6:05 PM, MBot said:

I managed to get a decent loft profile for Walleyes by carefully tuning a ton of parameters. It basically also works for bombs but because they lack the glide range of the Walleye, the aircraft basically ends up over the target the same as with a level release. A steeper loft angle would be better for bombs, but the Walleye profile is the most that is possible with the AI. Keep in mind that this is not a native DCS feature but basically exploiting existing AI routines to the most extend possible.

 

Thank you for this script.

 

Can you pls share the parameters you used to enable the AI to loft bombs to the target?

Wishlist: Tornado ADV/IDS, Blackburn Buccaneer, Super Mystère B2, Saab J 35 Draken,

Link to comment
Share on other sites

  • 3 months later...
On 9/11/2022 at 8:05 AM, MBot said:

I managed to get a decent loft profile for Walleyes by carefully tuning a ton of parameters. It basically also works for bombs but because they lack the glide range of the Walleye, the aircraft basically ends up over the target the same as with a level release. A steeper loft angle would be better for bombs, but the Walleye profile is the most that is possible with the AI. Keep in mind that this is not a native DCS feature but basically exploiting existing AI routines to the most extend possible.

 

 

 

I am a bit off topic here but your script is not only amazing on its core function, it is also quite helpful on how to use aerobatics task - something I have been looking for doc on for quite some time. 

Since you seem to know what you are doing, I wondered if you have a method to retrieve the active task, either through a framework (Mist, MOOSE, whatever really) or directly? I mean you can setTask / pushTask, you can popTask and you can interrogate existence of one with getTask but I can't seem to find a way to retrieve all or at least the top task table. Any insight? Thanks in any case!

Link to comment
Share on other sites

  • 4 weeks later...
  • 5 months later...

Hi, this is great script - Thank you very much MBot! 

Is there any way to specify targets (units) within the group? For example - flight of two to drop GBUs on search and track radars of sam site rather than them choosing random units within the group - such as launchers. 

I suppose I could alternatively make drop on specified coordinates on the map hitting exactly where I want. I was thinking it should be possible to specify units same as you can specify static targets? 

Thank you in advance.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...