Jump to content

Autonomous CAP and GCI AI fighter script


SNAFU

Recommended Posts

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

If no CAP flight or fighter flight without task is airborne and available, the script spawns a random interceptor flight on one of the 3 airfields, which is closest to the detected enemy aircraft and orders this interceptor flight to intercept the intruder.

 

This works but need some tweaking.

 

Today we simulated an airbase attack. We were 3 F-15 trying to sneak attack the enemy airfield. As soon as the EWR spotted us it spawned in 6 Intercept aircrafts + the nearby CAP flight. I was a real mess!

 

Is it possible to limit the amount of intercept flights? Or set it so it doesnt spawn 1 flight per client aircraft.

 

Thank you for making this script!

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

The easiest approach would be limit the number of active intercepts, so that if f.e. only 2 intercepts are active at the same time. The limit would be a simple variable which has to be set by the user. This is something I actually wanted to do since the beginning, and it should be fairly easy.

 

More complicated would be to check, if the intruder group has a playername and is therefore a client and then to only spawn one interceptor, or to create a "bubble" (sphere) around the intruder and check the number of intruders inside this "bubble" and then to intercept only this "bubble"...

 

Well, I think I will go with the first... :P

  • Like 1

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Thanks SNAFU.

 

I need to host the mission this thursday. Can you tell me the easiest way to disable the intercept flights for now?

 

EDIT: Quick question. The EWR:s. Can i also add units to these groups, like adding SAM units?

Optimal would be if the IADS script would automaticly add these in some way.

 

EDIT2: Sorry for spamming.. Doing some extensive testing right now. :)

The CAP flights dont seem to do anything right know. They dont engage enemy intruders they just fly to their assigned waypoints. Something wrong?


Edited by Rivvern

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Updated 1st post with new version b5.

 

Changes:

-added option for CAP and interceptors to take off from runway, suggested by "Quip", or spawn in the air, but I didn´t test the air spawn option, since they spawn with speed 0, this might not work

 

-added option to limit number of interceptors spawned, if a certain amount of intercepts are ongoing

 

-added function which shall remove AI plane/helicopter groups, which have a damaged unit on the ground in the triggerzones created around the airfields

 

General Note:

 

If tested the script with airfields lacking the right planes as rescources and experienced some really weird behavior of endless fighter spawns in the air around the airfield, so I would suggest to set the airfield resources to unlimited for starters.

 

 

@Rivvern:

 

The script only considers the following radar types as EWR system:

-55G6 EWR, 1L13 EWR for red

-Hawk sr, Patriot str on blue side

 

If you want to include more radar types into the script you have to add

 

or possibleEWRunittype == "insert name of unit"

to line 266 for red and line 286 for blue.

 

I checked the your miz file, but couldn´t find anything wrong. I just changed the the borderline unit to invisble and set them to hold, so they don´t move all over the map and exchanged the b2 version with the actual b5 version and tested it. In my testing the CAP flights engaged intruder after being engaged, so the 'generatetask' function has an issue there, if you watched the CAP not engaging actively. That is my next point of testing, I didn´t have the time for further testing yesterday.

 

If you want to disable the GCI the easiest way would be do comment the line 3840 (b5) so it looks like

 

--spawninterceptor(side)

Attached you find you miz file with the latest script version. Let me know if the CAP still does not intercept.

MA_BASE v0.108_CAP_mod.miz


Edited by SNAFU

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

EDIT: Quick question. The EWR:s. Can i also add units to these groups, like adding SAM units?

 

I was more thinking if the EWR unit also can have other units in the same group.

Lets say i place a Hawk sr and in the same group have the Hawk TR and LN. Will that mess up the script in some way?

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

No, doesn´t matter what you do with the group. The script goes through every unit on the map and checks if it is of certain type, than it is checked if this unit detects any aircraft inside the borderline assigned to the side.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

PS: Also note that the CAP flights will not be considered for an interception job by script, if they are not on sation - inside the triggerzone defining the CAP zone. If an intruder enters the other airspace before the CAP flight is "on station", an GCI will be triggered and interceptors should spawn at the airfield closest to the intruder.

 

In my testing I had this case a few times.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Done some testing.

Even if i set "Intercept to = 1", 2 groups were spawned.

 

local numberofspawnedandactiveinterceptorgroupsRED = 1

 

http://forums.eagle.ru/attachment.php?attachmentid=95604&stc=1&d=1395260175

Tacview = https://dl.dropboxusercontent.com/u/16996823/2014/Tacview-20140319-203445.acmi

 

Having some trouble with dropbox. It should come online later. :joystick:

 

 

 

local numberofredcapzones = 2							--input of numbers of defined CAP zones for Red side
local numberofbluecapzones = 2						--input of numbers of defined CAP zones for Blue side
local numberofredCAPgroups = 1						--input of numbers of defined CAPs for red side
local numberofblueCAPgroups = 1						--input of numbers of defined CAPs blue red side
local numberofspawnedandactiveinterceptorgroupsRED = 1				--maximum number of at the same time ongoing active intercepts for Red side, NOTE: The counter will be resetted with the "taskingintervall" and each time the airspace is clear
local numberofspawnedandactiveinterceptorgroupsBLUE = 1				--maximum number of at the same time ongoing active intercepts for blue side, NOTE: The counter will be resetted with the "taskingintervall" and each time the airspace is clear
local redCAPzone = 'redcapzone'						--Triggerzones defining the Red CAP area have to be name according to 'redCAPzone1', 'redCAPzone2',...'redCAPzone[numberofredcapzones]
local blueCAPzone = 'bluecapzone'						--Triggerzones defining the Blue CAP area have to be name according to 'blueCAPzone1', 'blueCAPzone2',...'blueCAPzone[numberofbluecapzones]
local redborderlineunitname = 'redborder' 		-- Name of group which waypoints define the red border
local blueborderlineunitname = 'blueborder' 	-- Name of group which waypoints define the blue border
taskingintervall = 300 							-- Time intervall in which ongoing intercepts are renewed, NOTE: fine tuneing requires testing, do not use to small intervalls since it interrupts the intercept procedure

--names of red interceptorbases
local redAF = {}	
redAF[1] = {name = 'Beslan'}					--Exact name of airfield with the triggerzone of the same name between 'xxx'
redAF[2] = {name = 'Nalchik'} 					--Exact name of airfield with the triggerzone of the same name between 'xxx'
redAF[3] = {name = 'Sochi-Adler'}					--Exact name of airfield with the triggerzone of the same name between 'xxx' 
--names of blue interceptorbases
local blueAF = {}	
blueAF[1] = {name = 'Batumi'} 					--Exact name of airfield with the triggerzone of the same name between 'xxx' 
blueAF[2]= {name = 'Vaziani'}					--Exact name of airfield with the triggerzone of the same name between 'xxx' 
blueAF[3]= {name = 'Kutaisi'}					--Exact name of airfield with the triggerzone of the same name between 'xxx' 
--option to define AI spawn situation
local RNW_fromRunway = false			 -- set to true if you want the AI flights to spawn on the runway, or set to nil for airstarts of AI flight

--DEBUGGING options
local debuggingmessages = false						-- set to true if tracking messages shall be printed
env.setErrorMessageBoxEnabled(true)			--set to false if debugging message box, shall not be shown in game
local debuggingside = 'blue'							-- set side for which tracking messages shall be printed

MA_BASE v0.116_CAP_EDIT.miz

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Ah, Thanks for the feedback Rivvern.

 

There I had an error in the logic, basically like:

 

1. check if acitve number below/equal limit

2. if ok, spawn fighter

3. add one to counter, start at 1

 

So you see the smaller/equal (<=) was wrong at this place, should have be simply a samller check.

 

Should be corrected now in version b5_1, see first post.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Great script!!! Been having a blast with it.

 

Loaded up the new b5_1 and I get this error when the script tries to load

 

00057.071 ERROR DCS: Mission script error: : [string "C:\Users\Eric\AppData\Local\Temp\DCS\/~mis00003D88"]:1105: ')' expected (to close '(' at line 1104) near 'then'

 

Removing the ( seems to fix the error.

Link to comment
Share on other sites

Uff, thanks for the heads up.

 

That`s what happens, when you quickly try to fix an issue by just reading a script... :cry:

 

Uploaded the fixed version b5_2 in first post.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Ok. The CAP flights dont do anything at all. The Intercept flights are just mean. :)

 

I got two Tacview files for you if you are interested.

TACVIEW 1: https://dl.dropboxusercontent.com/u/16996823/2014/Tacview-20140320-195221.acmi

TACVIEW 2: https://dl.dropboxusercontent.com/u/16996823/2014/Tacview-20140320-204508.acmi

Mission: https://dl.dropboxusercontent.com/u/16996823/2014/MA_BASE%20v0.121_CAP_EDIT.miz

 

EDIT: Disregard that the entire BOAR flight made contact with a mountain side...


Edited by Rivvern

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Thanks guys for the feedback. I wish I had more time and could do longer testing and fine tuning of the waypoint actions.

I do not have TACVIEW, thinking about getting it, but on the other hand, I doubt I have the chance to use it properly...

 

Looks like the new ROE settings in the CAP waypoints are overruling the taskgeneration somehow.

 

Did you by any chance know, if the first intruder was detected before the CAP reached the CAP triggerzone? In this case the CAP is not flagged as "on station" and therefore not available for intercept tasking and a GCI is ordered.

Or was the CAP already on station in the triggerzone, when you entered the hostile airspace?

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Ill check that later.

 

If you focus on the hard part, scripting i can continue to do some extensive testing if you like.

I have no scripting knowledge whatsoever.

 

This script must live on and continue to be developed as it is a great tool to make interesting dynamic missions.

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Yes, I could do a little testing too on this weekend. The CAP is set to ROE "Return Fire" and that is basically what they do, as it seems.

 

I had the impression that they are not controlled by the "generateTask" function as they should be. I have to investigate into the function in detail.

 

So far I have changed and tested, the take off option ramp/runway/air, in the new version this should work. I have implemted an option to set the strength of the CAP and GCI flight to 2/4/random/dynamic. Dynamic means that the GCI flight should consist of the same number of planes, as the flight the GCI shall intercept.

 

But I must still solve the CAP issue...

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Uploaded new version in the first post.

 

It is now easier to observe to behavior of the CAPs since the first CAP is already on station with mission start.

 

Changelog updated with:

 

b6:

-changed waypoint alt type from BARO to RADIO

-first CAPs in mission will spawn in air in the CAP zone

-randomized flightsize of the CAP and interceptor fligths, they will now consist randomly either of 4 or of 2 planes or of choice, GCI might also spawn in the same size as the interuder group

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Probably a characteristically stupid question- but I know you say we need 3 airbases per side... Will it work differently if I only use 2?

 

 

A couple more:

 

In my mission- russia is blue... so I'm wondering if you meant by "major coalitions US and Russia" that they're equipment is used red / blue. So long as those randomly spawned units exist on red side and blue side, will all be okay? Can I change those random aircraft?

 

I can initiate your script via trigger?


Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

For the GCI the script checks a table of triggerzone centrepositions and gets the closest one relative to the intruder. It than gets the airdrome ID of the airfield with the same name as the triggerzone and spawns a GCI flight on that airdrome.

 

For the CAP the spawn airfield is choosen randomly.

 

If you choose to just use 2 airfields or 1, you have to slightly modify the script by commenting lines in a table of the airfields you don´t want to use.

 


--names of red interceptorbases
local redAF = {}    
redAF[1] = {name = 'Beslan'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx'
redAF[2] = {name = 'Nalchik'}                     --Exact name of airfield with the triggerzone of the same name between 'xxx'
--redAF[3] = {name = 'Sochi-Adler'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx' 
--names of blue interceptorbases
local blueAF = {}    
blueAF[1] = {name = 'Batumi'}                     --Exact name of airfield with the triggerzone of the same name between 'xxx' 
--blueAF[2]= {name = 'Kobuleti'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx' 
blueAF[3]= {name = 'Kutaisi'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx' 

This should work anyhow

 

The safest approach would be, to just use 2 triggerzones with the corresponding airfield names in ME and just repeat the name in the script lines like f.e.

 

 


--names of red interceptorbases
local redAF = {}    
redAF[1] = {name = 'Beslan'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx'
redAF[2] = {name = 'Sochi-Adler'}                     --Exact name of airfield with the triggerzone of the same name between 'xxx'
redAF[3]  = {name = 'Sochi-Adler'}                    --Exact name of airfield  with the triggerzone of the same name between 'xxx' 
--names of blue interceptorbases
local blueAF = {}    
blueAF[1] = {name = 'Batumi'}                     --Exact name of airfield with the triggerzone of the same name between 'xxx' 
blueAF[2]=  {name = 'Kobuleti'}                    --Exact name of airfield with  the triggerzone of the same name between 'xxx' 
blueAF[3]= {name ='Kobuleti'}                    --Exact name of airfield with the triggerzone of the same name between 'xxx' 

This would double the chance of a CAP spawn at Kobuleti or Sochi as a side effect, but this should be all...

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

Thanks! Looking forward to giving this a try. I'm starting to try my hand at F-15C missions.

 

 

 

I've looked into the script a bit to see how hard it would be to swap the red side country from Russia to Ukraine.

 

I noticed the SU30 is in there- so I've removed it and reduced the variable math from 4 aircraft to 3.

 

I'm currently getting this error even though I have an A10 fly right through two different cap areas.

 

00033.275 INFO SCRIPTING: debuggingmessage interceptmain 1 stuck at airspaceviolation: counter:0/ side: blue

00033.275 INFO SCRIPTING: blue intruder: {

}-counter: 0

00033.275 INFO SCRIPTING: debuggingmessage interceptmain 2 stuck at CAPStatusCheck: counter:0/ side: blue

00033.275 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X0: counter:0

00033.275 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X01: counter:0

00033.275 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X02t: counter:0blue

00033.417 INFO SCRIPTING: debuggingmessage interceptmain 1 stuck at airspaceviolation: counter:0/ side: red

00033.417 INFO SCRIPTING: red intruder: {

}-counter: 0

00033.417 INFO SCRIPTING: debuggingmessage interceptmain 2 stuck at CAPStatusCheck: counter:0/ side: red

00033.417 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X0: counter:0

00033.417 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X01: counter:0

00033.417 INFO SCRIPTING: debuggingmessage CAPStatusCheck: script hung A-X02t: counter:0red

 

 

Current version of mission attached:

High Speed Highway.miz


Edited by ENO

"ENO"

Type in anger and you will make the greatest post you will ever regret.

 

"Sweetest's" Military Aviation Art

Link to comment
Share on other sites

  • Recently Browsing   0 members

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