Jump to content

Autonomous CAP and GCI AI fighter script


SNAFU

Recommended Posts

Good news!

 

No a lot of the time that sort of thing like a missing airport zone or misspelt airbase name will just kill that bit of the script when it tries to use it without an obvious error - you might be able to trap one using pcall on the suspect function but I don't know for sure.

Link to comment
Share on other sites

  • Replies 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Quick question Is it possible to only set, as in my case, only 2 red AF and 3 blue AF ?

 

--names of red interceptorbases
local redAF = {}
redAF[1] = {name = 'Sukhumi-Babushara'}						--Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[2] = {name = 'Gudauta'} 								--Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[3] = {name = ''}								--Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[4] = {name = ''}								--XX4 Exact name of airfield with the trigger zone of the same name between 'xxx'
--names of blue interceptorbases
local blueAF = {}
blueAF[1] = {name = 'Batumi'} 								--Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[2]= {name = 'Senaki-Kolkhi'}								--Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[3]= {name = 'Tbilisi-Lochini'}						--Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[4]= {name = ''}                      			--Exact name of airfield with the trigger zone of the same name between 'xxx'

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

The way it works now you'll get holes in the spawn patterns for CAP and GCI ie something will be triggered to spawn but it won't happen. I'm guessing that the function involved will return at that point without executing the code past the point of failure - so short answer it may kind of work but I think it will give you pain.

 

If you want to do that at the moment and have it work you would need to not load the table with blank entries but set it up properly and then modify wherever it tries to reference the table to pick an airbase so that the limits were correct for how you have loaded the table. Probably a good thing to add to the next lot of changes for a future version if we can figure out how to do it.

 

eg snip of code loading an table of airfields for which you would need to comment out lines to fit what you have set up:

 

 

 

if airfieldside == 'red'

then

--airspaceviolation('red')

AF = {}

AF[1] = {name = redAF[1].name} --Exact name of airfield with the triggerzone of the same name between 'xxx'

AF[2] = {name = redAF[2].name} --Exact name of airfield with the triggerzone of the same name between 'xxx'

AF[3] = {name = redAF[3].name}

AF[4] = {name = redAF[4].name} --XX4

elseif airfieldside == 'blue'

then

--airspaceviolation('blue')

AF = {}

AF[1] = {name = blueAF[1].name} --Exact name of airfield with the triggerzone of the same name between 'xxx'

AF[2] = {name = blueAF[2].name} --Exact name of airfield with the triggerzone of the same name between 'xxx'

AF[3] = {name = blueAF[3].name}

AF[4] = {name = blueAF[4].name} --XX4

end

 

 

 

another snip of things to change, where it is trying to pick the closest base to an intruder. Looks like you need to have the same number of bases on each side as it is now:

 

 

 

for n = 1, 4 --XX4

do

closestairfieldname = AF[n].name

actualairfield = trigger.misc.getZone(closestairfieldname)

actualairfieldpos = {}

actualairfieldposx = actualairfield.point.x

actualairfieldposz = actualairfield.point.z

actualdistancetoairfield = math.sqrt((actualairfieldposx - actualintruderpos.x)*(actualairfieldposx - actualintruderpos.x) + (actualairfieldposz - actualintruderpos.z)*(actualairfieldposz - actualintruderpos.z))

closestairfield = Airbase.getByName(closestairfieldname)

closestairfieldID = closestairfield:getID()

if n == 1

then

 

 

 

So possible but requires a custom version, the edits above are not all of them


Edited by Stonehouse
Link to comment
Share on other sites

Quick question Is it possible to only set, as in my case, only 2 red AF and 3 blue AF ?

 

I've been starting to look at how we might be able to remove the base hardcoding and just pick it up from the map and in the process of identifying the bits to change have created a "One Base" version which might be useful to people while the next version is worked on. Be warned though that while I don't think there are bugs there may be some as it's really WIP. Same as prior version except you nominate a single red and single blue base.

GCICAPonebase.lua

Link to comment
Share on other sites

Quick question Is it possible to only set, as in my case, only 2 red AF and 3 blue AF ?

 

I think this will work Rivern :smartass:

--names of red interceptorbases
local redAF = {}
redAF[1] = {name = 'Gudauta'}                        --Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[2] = {name = 'Gudauta'}                                 --Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[3] = {name = 'Gudauta'}                                --Exact name of airfield with the trigger zone of the same name between 'xxx'
redAF[4] = {name = 'Gudauta'}                                --XX4 Exact name of airfield with the trigger zone of the same name between 'xxx'
--names of blue interceptorbases
local blueAF = {}
blueAF[1] = {name = 'Batumi'}                                 --Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[2]= {name = 'Batumi'}                                --Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[3]= {name = 'Batumi'}                        --Exact name of airfield with the trigger zone of the same name between 'xxx'
blueAF[4]= {name = 'Batumi'}                                  --Exact name of airfield with the trigger zone of the same name between 'xxx'

Or any other combination just fill in an valid airport. :)

Link to comment
Share on other sites

Really clever Hijack, should have seen that as it's pretty much what you do if you want all your CAPs and GCIs the same - make the template aircraft identical. I'll still keep on looking at picking it all up from the map if I can as really we want to minimise the script editing required by making it smarter.

Link to comment
Share on other sites

Really clever Hijack, should have seen that as it's pretty much what you do if you want all your CAPs and GCIs the same - make the template aircraft identical. I'll still keep on looking at picking it all up from the map if I can as really we want to minimise the script editing required by making it smarter.

Yes I have only F-15C's and Su-27's spawning on my missions and it seems to work fine. Also different loadouts on all ;)

 

EDIT! And dont forget to change the COUNTRY code for GCI flights to USA, Stonehouse have set it default to UK :)


Edited by HiJack
Link to comment
Share on other sites

Hey there, I'm a complete idiot when it comes to scripts but I'm trying to learn how to use them. I have the latest edit of the GCI/CAP script running perfectly in the editor, but whenever I bring it into multiplayer it doesn't work as it should (like in the editor).

 

It will endlessly spam CAP flights instead of using the limit that I've set, which is 5. Could this just be a bug with the way DCS spawns in the units?

Link to comment
Share on other sites

Not sure and it sounds really odd that it works offline but doesn't in online. Last time I saw something like that it was a bug in the interceptor code which held up releasing the last version for a long time. I guess something to confirm is that it is definitely cap flights spawning? that is their group name is CAPsomething and not GCI something. The reason I ask is that cap flights should only spawn if there is no cap flight "on station". Reasons for not being classed as on station are things like being enroute to the cap zone, rtbing or tasked with an intercept.

 

I guess other than that perhaps post up the mission file here so we can try to see what the issue is. It may well be that you found a bug in the script or it's something simple in the way the mission is built that is making the script work differently than expected.

Link to comment
Share on other sites

Ok I've only just seen your post and d/l'd your attachments but won't be able to do much on it as for me it's close to 11pm and I need to be up at 5:30am tomorrow. I did see one thing however looking at the script - you commented out one of the blue and red airbase each at the start. The script in it's current form doesn't allow this and you must have 4 entries for red and blue in the table. Hijack and Rivvern discovered a work around however where you can set entries to the same value. So if you only want 3 bases then make two have the same airbase name.

 

eg from your attached script

 

 

redAF[1] = {name = 'Mozdok'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

redAF[2] = {name = 'Sochi-Adler'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

--redAF[3] = {name = 'Gudauta'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

redAF[4] = {name = 'Nalchik'}

 

 

should be something like

 

 

 

redAF[1] = {name = 'Mozdok'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

redAF[2] = {name = 'Sochi-Adler'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

redAF[3] = {name = 'Sochi-Adler'} --Exact name of airfield with the trigger zone of the same name between 'xxx'

redAF[4] = {name = 'Nalchik'}

 

 

 

and of course you need the 3 trigger zones one for each airbase. Ditto for blue.

 

I will have a better look tomorrow after work but the above may solve your main issue re CAPs spawning madly.

Link to comment
Share on other sites

I looked at your mission and script version last night Urban and think I've sorted out most of the issues you reported. The main problem was the commented out redAF and blue AF statement as I thought. It was getting very late by the time I finished and the ED forum tends to get very slow for me around that time so I didn't get to upload an updated version but will do so this evening.

 

On the runway v's parking observation - yes I have noticed that as well lately and as far as I can see so far it is not the script but something different in the way DCS does things for offline and online. My unconfirmed guess is that online, if the designated parking bay is already taken when AI are spawning in they are moved to a new one (I think this also happens if a human has your parking bay too) but possibly the single player code doesn't do this and instead moves the spawning AI to the runway particularly if the plane already in the bay is a human one. That is just a guess and I really don't know but will continue to look into it as time permits.

 

 

<edit> Files now attached. The main issue was the commenting out of the airbase setup lines of the script. The other things I saw which I changed were that you had not used a mission start trigger but two separate once triggers - one for mist and one for the CAPGCI script. I strongly suggest that you use the mission start trigger to load things like mist and other critical scripts and that you set up several DO SCRIPT FILE actions on a single mission start trigger so that the scripts run in the required order of dependency. This ensures that the scripts will run before anything occurs in the mission. The only other things I noticed were very minor and I'm not sure if they would cause you problems or not. You had not quite joined up the border waypoint path for both sides and you had some radars outside the borders of their owning side. I also had to change your F16s set up as client slots to F15s as I don't have that mod installed.

GCICAPurban.lua

GCICAPtestmission.miz


Edited by Stonehouse
added attachments
Link to comment
Share on other sites

There is a problem.

 

After GCI or CAP flights have shot down an enemy intruder they marsh straight over enemy borders engaging their CAP flights and mostly starting a WWIII. I would like them to only engage targets within the own borders.


Edited by Rivvern

[sIGPIC][/sIGPIC]

 

We are looking for Swedish members!

http://www.masterarms.se

Link to comment
Share on other sites

Sorry guys things have stalled in the last week or so as I've been having system problems. Finally have identified the issue as memory intermittently failing and am in the process of getting things back up and running but need to replace the memory as well as sort out any data corruptions it's caused. It'll be a few days yet as I need to order some more memory to take over from the placeholder spares I've been using for the last day to get things running.

 

Real life work of course very inconveniently interjects for 8 or so hours a day lol making it take longer.

Link to comment
Share on other sites

Hmm funny you should mention that, was kind of trying to find a way to tell my wife that lol ;D

 

Looks like replacement DDR3 is going to take a few days to get from the distributor to the vendor and then probably another day or so to get shipped out to me. So I reckon it will be next week before I can do too much. Having some Mig21 activation issues too So may have to do another reinstall of the whole of DCS - I'd had some Zweiblau.dll crashes early last week so just done a reinstall. With 20/20 hindsight I'd guess the whole thing was an early symptom of the memory dying.

 

That new system is looking better all the time :D

Link to comment
Share on other sites

I wish I could find the energy to work on this script some more but I just got so burnt out with scripting and with MiG-21 out just enjoying it so much.

 

Burnt is good word for this. Eventhough I had a 5 months break from internet and PC and I am trying to upgrade my desktop PC at the moment with SSD, new graphik card and RAM, reinstalling Windows etc I am a little afraid to get back into scripting and burning hours of lifetime, just to find out that DCS 2.0 doesn´t know LUA... :cry:

 

I guess there comes the moment for volunteer amateur scripter, where he gets tired of the retesteing and reworking everthing after every new patch. :music_whistling:

 

At the moment I am still checking my AFAC script, and adding SEAD to the AFAC options, when I was overtaken by a new patch again...

 

At the end I just do this for my own fun of tinkering around with something similar to modelling, the results just doesn´t take up as much space as the real thing.

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • Recently Browsing   0 members

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