PDA

View Full Version : DCG + QBasic



Ettico
November 3rd, 2008, 05:47
Some of you may have noticed the conversation I was having earlier with Pen32win. I've been working on a QBasic program intended to kick up Lowengrin's Dynamic Campaign Generator a couple of notches by editing the DCG "Mission" file after a mission is generated. As far as I can tell, the program is now successfully performing the following tasks:

1. changes fighter formations from echelon left to finger four, which is more realistic and appears to greatly reduce collisions.

2. spreads bomber formations vertically, greatly reducing collisions.

3. changes mechanized ground formations to column formations so they will stay on the roads and railroad tracks.

4. allows the player to quickly and easily change the payloads of every plane in the player formation.

5. re-assigns spare CAP's as escorts when strike missions originate from their airfields or carriers, thereby better protecting bombers and facilitating long range strategic bombing missions. Both bombers and fighter strikes will get escorts when spare CAP's are available. When no targets are within fighter range but long range bombers are present at an airfield, all the fighters, including the player squadron, will accompany the bombers as escorts/fighter sweeps, excepting one fighter squadron, which will CAP the airfield.

6. finds and fixes two DCG bugs.

The program is very BETA at the moment. I haven't had time to test it in different kinds of campaigns and situations yet. I flew a test mission in Europe as soon as I got the program working right. It was a long range strategic boming scenario, focused on the Hamburg area, flying out of Bodney. At Bodney were 5 squadrons of B-24's and 6 squadrons of P-51's. 6 squadrons of 190's and 109's were defending. The primary targets were the Salsbergen refinery, the Harburg refinery, and the Kiel shipyard. Two airfields were secondary targets. All the German targets and airfields were out of DCG fighter range. Here's what happened:

At mission start, 5 squadrons of B-24's were airborne over Bodney, lined up abreast, south to north. 2000 feet above each bomber squadron was a squadron of P-51's, including the player squadron. All 10 squadrons began lumbering toward Hamburg. There was one collision between 2 fighters just after mission start, but that was the only collision in the mission. I noticed the fighters couldn't fly slow enough to stay with the bombers, so I warped through the first 2 waypoints to keep the strike together. I arrived at the marshalling point, 15 miles west of the Harburg refinery. 3 squadrons of B-24's bombed the refinery without opposition except for heavy flak. One B-24 shot down another B-24 for some crazy reason. I took a flak hit which seemed to knock out my radio. I couldn't communicate with my flight. Then a squadron of 190's appeared. They didn't seem much interested in attacking the retreating bombers. 2 of the 190's made a half-hearted lunge toward the big flock of bombers, then turned away. I tried to engage my flight, but couldn't communicate. I engaged one of the 190's. Before long I noticed my flight had mysteriously disappeared, leaving me alone against 2 190's, both apparently aces. When I would get on one's tail, the other would get on my tail and start shooting. I traded shots with them, giving and taking damage, then decided the better part of valor was to book. The 190's didn't chase me very far. as I neared Salsbergen I saw a squadron of 109's in the distance, but they soon disappeared. I hit the "B" key, got a vector for home, and warped.

It wasn't the most exciting mission I've ever flown, but escort missions aren't supposed to be all that exciting. The Germans had several targets to defend, which probably explains the lone squadron of 190's. I don't know why the 190's weren't more agressive. They were agressive as hell in the other campaign I tested which was focused on western France and Belgium. They may have been low on fuel.

Mission results: some of the Harburg refinery got knocked out. 2 P-51's and 1 B-24 were lost, all as a result of mishaps. Basically a milk run.

But the point is, this has never happened before in the history of CFS2. There has never been a DCG-generated escorted strategic bombing raid into Germany. Never happened. Never could have happened until now.

Well, OK...some guy may have hand-edited a DCG mission file to make it happen. But it's never happened without hand-editing before. I clicked two buttons.:d

Ettico
November 3rd, 2008, 06:14
Don't try this at home, kids. If you set up a DCG campaign so that all the targets are out of fighter range, the fighters will attack their own airfields(!) and the player squadron will be assigned a CAP, presumably to observe the ridiculous proceedings. My program fixes that. Reassigns the stupid fighters as escorts/ sweeps and takes their loads off.

P.S. DCG limits fighters to a 200 nm radius in the ETO for some unknown reason. Now they can go deep.

P.P.S changed the program to put drop tanks on all re-assigned escorts and also all the defending CAP's. Flew a second test mission. This time my squadron stayed with me. We shot down 3 190's. The German fighters were considerably more hostile too. One of my squad was shot down.

Ettico
November 3rd, 2008, 08:49
This guy was sho hard to handle.

Ettico
November 3rd, 2008, 08:58
Typical Akemi catfish...slippery. Hit him 3 times. He didn't go down.

Ettico
November 3rd, 2008, 09:01
But my wingman got him.

Ettico
November 3rd, 2008, 09:11
He kept out-turning me and making head-on gun runs. Couldn't get a screenie of the head-on passes. Happened too quickly, and I was too busy dodging bullets.

Ettico
November 3rd, 2008, 09:20
Pulled a lot of G's, and all I got out of it was a headache...

Ettico
November 3rd, 2008, 09:29
Anyhow, that big swarm of bombers innacurately bombed the Harburg refinery.

Ettico
November 3rd, 2008, 09:44
And I high-tailed it in my pretty P-51c Malcolm hood with the pretty 354th markings, still in one piece. I was low, slow, and sluggish when the ref stepped in.

Ettico
November 3rd, 2008, 09:51
Forgot to mention - there were no collisions in this mission.:d

I think I messed up these two test missions by warping to the second waypoint. I still had 187 miles to go from the first waypoint, and didn't have the patience to fly it out. Ended up 15 miles from the target, and caught the German defenders flat-footed, out of position to intercept. By the time some of them got there, the bombers and their escorts were headed home.

Pen32Win
November 3rd, 2008, 13:02
"I noticed the fighters couldn't fly slow enough to stay with the bombers, so I warped through the first 2 waypoints to keep the strike together. "

Just one Word - Altitude - In CFS2 AI's at 200Knts at 4000' is not the same as 6000'. Take the A/C of your choice and create two AI formations. Set two WP's 20 miles apart. Set the speed for both formations the same but make one formation 2000' higher. Spawn both formations at the same time and trigger a sound or a message when each flight reaches the 2nd WP. The higher formation will always win.

Posting as I'm reading E...

Ettico
November 3rd, 2008, 15:01
"I noticed the fighters couldn't fly slow enough to stay with the bombers, so I warped through the first 2 waypoints to keep the strike together. "

Just one Word - Altitude - In CFS2 AI's at 200Knts at 4000' is not the same as 6000'. Take the A/C of your choice and create two AI formations. Set two WP's 20 miles apart. Set the speed for both formations the same but make one formation 2000' higher. Spawn both formations at the same time and trigger a sound or a message when each flight reaches the 2nd WP. The higher formation will always win.

Posting as I'm reading E...
Hi Pen,

I can change the cruising speeds in the escorts' waypoint paths. It won't be easy. Nothing has been so far. I just need to figure out how much to slow them down.

I don't think I care much if the fighters sweep ahead of the bombers. They'll get to the target areas first and should engage any defenders. But I'll go ahead and try to get them to stay with the bombers.

bobhegf
November 3rd, 2008, 16:09
I am having the same problem you are with my Cactus campain.The fighters out run the bombers everytime even though they are set at the same speed.The reason I don`t use the escort command is because if the lead bomber for the flight that the fighters are assigned to protect is shot down the escort fighters are going to continue to orbet the area where said bomber was lost.This is kind of a nutty idea but what if someone made an invisable bomber with guns that didn`t fire and had a DP that couldn`t be damaged.You could place the invisiable bomber in the center of the bomber box, that way if one of the visiable lead bombers was shot down the friendly fighters would continue to follow the box insted of orbet the area where the lead bomber that it was attached to was shot down.:d

Pen32Win
November 3rd, 2008, 21:38
Here's the really nasty part of this deal. If you warp they will move along their assigned route at the same speed regardless of altitude, if you/they fly it the difference in altitude will show up in the speed at which they fly... I ran into this when building the Midway mission and trying to pace AI SBD's at 18,000'. The formation was AI led and even though they were set to fly at 140knts they were going going something like 180knts at altitude. It really made things rough when you came out of warp. You'd come out of warp at the correct speed and the AI's would take off like a Bat out of Hades.

I don't know what to do about it because different A/C and different altitudes have different effects....????

Ettico
November 4th, 2008, 00:20
Thanx for the input, guys.

Hey, bob. Nothing is nutty if it works. You should try your idea out. If it works, you'll end up with the best escorts in the business.:d Hey, I've even gone so far as to create an invisible aircraft carrier to serve as a rendezvous point in enemy territory - just a starting point that's in range of a target. It worked, but it wasn't a very realistic fix.

You hit the nail on the head, Pen. They move at different speeds when warping than they do when flying. I hadn't thought of it, but the indicated airspeed would vary by altitude. At a given ground speed, indicated speed would be progressively slower as altitude increases. So if they're using indicated airspeed, they think they're going slower than they really are.

It is possible to change the horizontal coordinates instead of the altitude. But it is very tricky to write code to work with DMS coordinates within a program. You have to extract them, convert them to numbers, do the correct math, convert them back to DMS text format, and put them back in - all without a hitch, and no way to go wrong. Just about everything you do is ten times trickier to do with a program than it is to do manually. The difference is, the program can do it a million times faster.

I've already painted myself into several corners while constructing this program. So far I've managed to find a way out. If I had known when I started what I was going to run into I would have done the program differently. But now that it's done, anything that works stays put, no matter how clumsy it is.:d I know the thing is doing a lot of unnecessary repetitive stuff, but as long as it grinds to a proper conclusion, it doesn't matter. It's fast anyway.

I think I'll try the easy way out first. I'll try setting the escorts as nearly as possible to the same altitude as the bombers without risking collisions, and see how that works. I like the basic idea of having fighter sweeps double as escorts. Bob, you mentioned the problem with escorts. It's just a matter of keeping them all together.

I have a couple of other tinkering things I want to do, like changing the code to allow the player squadron to ground start when it's been re-assigned to escort duty. That should be simple enough. Just leave waypoint.0 in. Come to think of it, there may be no particular reason to change waypoint.0 for any of the re-assigned escorts. Making them catch up to the bombers will slow them down a bit. On the other hand, they'll be moving faster between waypoint o and waypoint 1. I'll try it and see how it works.

Ettico
November 4th, 2008, 16:58
:d

I gave in and wrote some more code to make the re-assigned fighters true escorts instead of fighter sweeps masquerading as escorts. I also corrected a mistake I made. The program now leaves the fighters' waypoint 0 as is. IOW, they now start where DCG puts them instead of 2000 feet above the bombers. So, if you have ground start selected and your squad gets re-assigned to escort duty, you still ground start.

It was another grim struggle between me and the code, but it worked. I have the test mission on pause right now, and I've verified that the re-assigned fighters know they're escorts and act accordingly. They attach at waypoint 1. Since I left the DCG waypoint 0 intact, they fly considerably faster than the bombers between waypoints 0 and 1 and get way out ahead of them. However, they turn around and come back like good little escorts, and attach dutifully.

Again, no collisions despite the large numbers of planes. I have to say it was a beautiful sight to watch the big ( DCG ) escorted strike form up smoothly at waypoint 1 and head for Hamburg, after all the work I put in on this, not knowing for certain if I'd ever get it right.

The code might suck in the esthetic sense. I'm not a real programmer, so I don't really know. But it works. that's what counts.:d

But it's not finished. I've yet to tackle the really hard part. Somehow, I have to produce code to re-write the mission briefing. I already know it's going to be a B***h, and I'm not sure it's even within my capability. I may have to fudge it some. The program tells me everything I need to know when it runs. It prints some cryptic info on all the squadrons - their directives, airfield ID's, formation ID's, and a couple of other numbers that only mean something to me.

Pen32Win
November 4th, 2008, 18:44
You Da' Man E!

Not a real programmer? Maybe not on paper but function is what really counts in the end. We Horse folks have an old saying. You Can't Ride Papers. :ernae:

Ettico
November 4th, 2008, 21:03
You Da' Man E!

Not a real programmer? Maybe not on paper but function is what really counts in the end. We Horse folks have an old saying. You Can't Ride Papers. :ernae:

Thanks, Pen. I have a feeling you DCG guys will like this. DCG works well enough for carrier ops, but strategic bombing is now within it's reach. The addition of AI escorts is a game changer in any type of campaign as far as DCG goes, and there was only one collision reported in this mission, which involved close quarters maneuvering and fighting among 13 squadrons of planes. The test mission went really well. I didn't warp to waypoint 2 this time, and the Germans were up in force. As 3 squadrons of them approached the bombers, the escorts engaged and a huge dogfight erupted. I didn't participate this time. I was tired and wanted to observe anyhow. The bombers did not escape unblemished. Several of them were shot down. I guess you'd call the bomber losses moderate. But they would have been slaughtered if the escorts hadn't been there.

The campaign I'm using for testing is specially designed for long range bombing. All the targets are out of DCG fighter range, and all the attackers are at one airfield. The fighters have nothing to do but attack their own airfield:confused: The bombers have nothing to do but attack the small selection of targets available. The primary targets have multiple location markers on them to exert more pull on the bombers. Typically you get 3 squadrons of bombers hitting a primary target with a couple of squads hitting secondary targets. My program looks for and detects the fact that the fighters are assigned to use their own airfield for target practice, and promptly disarms them and re-assigns them as escorts.:d

In a normal campaign with targets in fighter range, many of the fighters will get legitimate strike missions, so fewer of them will be available for escorts. However, long range escorted strikes can still happen. But you won't get big focused strikes.

So, in the ETO, we can have several focused campaigns for hitting deep targets, and a diffuse campaign or two for areas within fighter strike range - including a ground support campaign for post D-day action. Each campaign can have it's own set of infrastrucure and defending fighter groups. The player can hop around from one mini-campaign to another and get plenty of variety and see all the scenery. And the campaigns won't produce the same mission twice.

I also plan to have truck convoys and trains running, and some armor and mech moving around on the roads.

After I get some mini-campaigns put together, my plan is to do some campaign-management code to meld all the mini-campaigns into one big one.

And anyone else can do whatever they want with my program. QBasic is very open-source. QBasic doesn't hide the code, but keeps it in view on the screen, available for editing. After I do some more testing and tinkering, I'll post the code here for beta testing. The code can be copied and pasted into a notebook file with a xxx.BAS extension, and QBasic can load and run it. You hit the "run" button once after you generate a DCG mission. That's all there is to it. The QBasic program is freeware. It's a small download. I think I got my copy from Microsoft support.

There's only one problem with all this. I know how I am. After I've finished writing some code and haven't fooled with it for a while, I completely forget how it works. In fact, I'm lucky if I can remember how it works from day to day. So I may not be of much use to people asking questions about how it works and why. I'll forget the "how", and the "why" is usually because that's the only way I could think of to make it work after repeatedly painting myself into various corners. It's kind of like Darwinian evolution. I just keep trying stuff until something works. :d

Ettico
November 5th, 2008, 11:18
In addition, you can dedicate some of your fighters for escort duty by taking the strike loadouts out of their DP's. Without strike loadouts, these fighters will always be assigned as CAP's, and my program will re-assign them as escorts when they are stationed at an airfield with bombers.

Ettico
November 6th, 2008, 18:50
I've been laboriously working on the mission briefing problem. :isadizzy:
As predicted, I fudged. I'm leaving the original DCG mission briefing in and having my program screen print a cryptic briefing of sorts after it makes its' changes. That's OK, because the DCG mission briefing does provide some useful info on the strike missions. My program never changes the strike missions.

It's almost done. I just need to solve the riddle of getting the squadron names and hopefully the target names into the briefing. Currently the altered mission briefing is just giving the mission directives (in plain English) and the target coordinates. Then I need to put the "change player squadron payloads" option after the mission briefing printout so the player will know what the mission is before changing payloads.

Ettico
November 6th, 2008, 19:00
Aha! I finally got me one of those Akemi catfish that hang out around Hamburg. They burn just like anything else once you get them lit up.:costumes:

Ettico
November 7th, 2008, 07:08
OK. I've got this thing to the point where it can be beta tested. This may not be the final version, but it's close. I haven't had time to check it out in a lot of different scenarios. I've been testing it in Europe, and it does what I want it to do there. But I haven't tested it at all in the PTO yet. So if anyone wants to give it a test drive in the PTO, let me know how it comes out.

You can get your QBasic here:
http://www.petesqbsite.com/sections/introduction/intro.shtml

Drop the QBasic files into your CFS2 CAMPAIGNS folder and create a shortcut to QBasic.exe

If you have multiple installs, you'll need to drop copies of QBasic into all your CAMPAIGNS folders and create individually named shortcuts for each install. You can rename a shortcut by right clicking on it and selecting the rename option.

I'll post the code in the following post. You can copy it and paste it into a notpad file. Name the file DCGQB.BAS - or whatever else you want to name it, but it must have a ".BAS" extension. Drop it into your CAMPAIGNS folder. Then you can load the file with QBasic and run it after you generate a DCG mission. You can keep QBasic active on the toolbar while you're flying missions.

The program will do the following:

1. Changes the fighter formations to finger four. This is more realistic, and seems to reduce collisions.

2. Spreads the bomber formations vertically, which seems to reduce collisions.

3. Changes mechanized ground formations to a line astern formation so they will run on roads and railroads. When I get around to it, I'll try to space the formation elements the right distance apart to simulate moving trains.

4. Since DCG does not assign AI fighter squadrons to escort duty, the program re-assigns spare CAP's as escorts. CAP's will only be assigned to escort strikes originating from the same airfields or carriers. The player flight may be reassigned to escort duty if the player gets a CAP or sweep mission. The program will always leave a minimum number of CAP's at an airfield. This minimum number is determined interactively by the user. If DCG does not assign any CAP's to an airfield, the program will not add any. This feature also facilitates long range escorted strategic bombing. Escorts are assigned without regard to range limitations of the fighters, so for realism, only long range fighters should be stationed at bases with long range bombers.

5. Screen prints a cryptic mission briefing on all the flights originating from the player airfield or carrier. Displays squadron names, mission directives, and target coordinates. If you get reassigned to escort duty, you can figure out which strike(s) you're escorting by comparing target coordinates. Then you can look at the original DCG briefing to find the target name.

6. Provides long range loadouts to CAP's reassigned as escorts. For this purpose, the program assumes that payload (1) is Guns Only Long Range, which is the case with all stock fighters and most addons.

7. Offers the player the opportunity to change the payloads on all the player flight aircraft after displaying the mission briefing. DCG only loads out fighters with rockets for strike missions. This option allows the player to switch to bombs or whatever.

8. Searches for and fixes 3 known DCG bugs. There are 2 other intermittent bugs I know of that I haven't gotten around to addressing, but they're not in the Mission file. This program currently only edits the Mission file. There is a bug which sometimes occurs in the Squadrons file when a squadron is transferred to another airfield by DCG. It is also the case that DCG will continue to assign strikes against task forces after all the ships in the task force have been sunk.

Ettico
November 7th, 2008, 07:17
Here's the code.




' DCGQB by Ettico - QBasic for dummy DCG fans
CLEAR
CLS
PRINT "Welcome to the DCG Kicker."
PRINT "You must generate a DCG mission before running this program."
PRINT
PRINT "This program may re-assign some CAP's as escorts."
PRINT
PRINT "Please enter your recommended minimum number of CAP's you want the"
PRINT "program to keep at each carrier or airfield if possible."
PRINT "I recommend a minimum of (2) CAP's per carrier for carrier operations."
PRINT "I recommend (0) to (1) CAP per airfield for ground based operations."
PRINT "If you've already made your recommendation, just hit ENTER at the prompt."
q$ = ""
INPUT q$
IF q$ = "" THEN GOTO 5
x = VAL(q$) + 1
ON ERROR GOTO 3
KILL "capcfg"
3 OPEN "capcfg" FOR OUTPUT AS #1
PRINT #1, x
CLOSE

5 OPEN "capcfg" FOR INPUT AS #1
INPUT #1, mincap
CLOSE
line$ = "": load = 0: gcount = 0: ccount = 0: alt = 0: alt$ = ""
pcount = 0: rf = 0: airflag = 0: capflag = 0: pathflag = 0: pflag = 0: player = 0: wp0 = 0: rcount = 0: rflag = 0
gstart = 0: linecount = 0: gstart = 0: id = 0: name$ = ""
DIM groups$(52, 7)
DIM paths$(364)
DIM caps(52, 2)
DIM airfields$(50, 3)
OPEN "Mission.MIS" FOR INPUT AS #1
10 IF EOF(1) THEN 20
LINE INPUT #1, line$
IF LEFT$(line$, 8) = "[runway." THEN rcount = rcount + 1: rflag = 1
IF rflag = 0 THEN 10
IF LEFT$(line$, 3) = "id=" THEN airfields$(rcount, 1) = RIGHT$(line$, 4)
IF LEFT$(line$, 9) = "base_lat=" THEN airfields$(rcount, 2) = RIGHT$(line$, (LEN(line$) - 9))
IF LEFT$(line$, 9) = "base_lon=" THEN airfields$(rcount, 3) = RIGHT$(line$, (LEN(line$) - 9)): rflag = 0
GOTO 10
20 CLOSE
OPEN "Mission.MIS" FOR INPUT AS #1
OPEN "Missionx" FOR OUTPUT AS #2
400 IF EOF(1) THEN 1700
LINE INPUT #1, line$
linecount = linecount + 1
IF LEFT$(line$, 13) = "[unit.0]" THEN gstart = linecount
IF LEFT$(line$, 11) = "waypoint.6=" THEN gstart = linecount + 2
IF LEFT$(line$, 3) = "id=" THEN id$ = RIGHT$(line$, 4)
IF LEFT$(line$, 18) = "name=%name_string." THEN name$ = line$
430 IF LEFT$(line$, 8) = "[runway." THEN rf = 1
IF rf <> 1 THEN 520
IF LEFT$(line$, 3) <> "id=" THEN 520
rf = VAL(RIGHT$(line$, 4)): ccount = ccount + 1: caps(ccount, 1) = rf: rf = 0
520 IF line$ = "is_player_aircraft=1" THEN load = 1: count = 0
600 IF LEN(line$) < 13 THEN 1380
IF RIGHT$(line$, 9) = "0,300,0.0" THEN line$ = LEFT$(line$, 26) + "0,-150,0": GOTO 1380
IF RIGHT$(line$, 10) = "-300,0,0.0" THEN line$ = LEFT$(line$, 26) + "0,-300,0": GOTO 1380
IF RIGHT$(line$, 9) = "300,0,0.0" THEN line$ = LEFT$(line$, 26) + "0,-450,0": GOTO 1380
IF RIGHT$(line$, 10) = "0,-600,0.0" THEN line$ = LEFT$(line$, 26) + "0,-600,0": GOTO 1380
IF RIGHT$(line$, 13) = "-300,-300,0.0" THEN line$ = LEFT$(line$, 26) + "0,-750,0": GOTO 1380
IF RIGHT$(line$, 12) = "300,-300,0.0" THEN line$ = LEFT$(line$, 26) + "0,-900,0": GOTO 1380
IF RIGHT$(line$, 9) = "0,600,0.0" THEN line$ = LEFT$(line$, 26) + "0,-1050,0": GOTO 1380
IF RIGHT$(line$, 14) = "-500,-1000,-10" THEN line$ = LEFT$(line$, 26) + "-300,-600,0": GOTO 1380
IF RIGHT$(line$, 15) = "-1000,-2000,-20" THEN line$ = LEFT$(line$, 26) + "300,-600,150": GOTO 1380
IF RIGHT$(line$, 15) = "-1500,-3000,-30" THEN line$ = LEFT$(line$, 26) + "600,-1200,150": GOTO 1380
IF RIGHT$(line$, 15) = "-2000,-4000,-40" THEN line$ = LEFT$(line$, 26) + "1200,-1200,300": GOTO 1380
IF RIGHT$(line$, 15) = "-2500,-5000,-50" THEN line$ = LEFT$(line$, 26) + "900,-1800,300": GOTO 1380
IF RIGHT$(line$, 15) = "-3000,-6000,-60" THEN line$ = LEFT$(line$, 26) + "1500,-1800,450": GOTO 1380
IF RIGHT$(line$, 15) = "-3500,-7000,-70" THEN line$ = LEFT$(line$, 26) + "1800,-2400,450": GOTO 1380
IF RIGHT$(line$, 14) = "-1000,-500,-10" THEN line$ = LEFT$(line$, 37) + "-30": GOTO 1380
IF RIGHT$(line$, 13) = "1000,-500,-20" THEN line$ = LEFT$(line$, 36) + "-60": GOTO 1380
IF RIGHT$(line$, 13) = "200,-1000,-30" THEN line$ = LEFT$(line$, 36) + "-90": GOTO 1380
IF RIGHT$(line$, 15) = "-2000,-2000,-40" THEN line$ = LEFT$(line$, 38) + "-120": GOTO 1380
IF RIGHT$(line$, 15) = "-3000,-3000,-50" THEN line$ = LEFT$(line$, 38) + "-150": GOTO 1380
IF RIGHT$(line$, 15) = "-1000,-3000,-60" THEN line$ = LEFT$(line$, 38) + "-180": GOTO 1380
IF RIGHT$(line$, 15) = "-1800,-4000,-70" THEN line$ = LEFT$(line$, 38) + "-210"
1380 PRINT #2, line$
IF line$ = "type=air" THEN gcount = gcount + 1
IF gcount = 0 THEN 400
x = LEN(name$)
n$ = RIGHT$(name$, (x - 6)): x = x - 6
n$ = LEFT$(n$, (x - 1))
IF groups$(gcount, 3) = "" THEN groups$(gcount, 3) = LTRIM$(id$)
IF groups$(gcount, 6) = "" THEN groups$(gcount, 6) = STR$(gstart)
IF groups$(gcount, 7) = "" THEN groups$(gcount, 7) = n$
IF line$ = "players_formation=1" THEN player = gcount
IF LEFT$(line$, 9) = "directive" THEN groups$(gcount, 1) = line$
IF groups$(gcount, 7) = "" THEN 1382
FOR I = 1 TO gcount
x = LEN(groups$(I, 7))
IF MID$(line$, 2, x) = groups$(I, 7) THEN groups$(I, 7) = line$
NEXT I
1382 IF LEFT$(line$, 10) = "waypoint.6" THEN runway$ = RIGHT$(line$, 8): runway$ = LEFT$(runway$, 4)
IF gcount = player THEN 1620
groups$(gcount, 2) = runway$
FOR I = 1 TO rcount
IF groups$(gcount, 2) = airfields$(I, 1) THEN groups$(gcount, 4) = airfields$(I, 2): groups$(gcount, 5) = airfields$(I, 3)
NEXT I
IF LEFT$(line$, 11) <> "waypoint.3=" THEN 400
x = INSTR(1, line$, "N")
IF x = 0 THEN x = INSTR(1, line$, "S")
y = INSTR(1, line$, "E")
IF y = 0 THEN y = INSTR(1, line$, "W")
p = INSTR(1, line$, "+")
lat$ = MID$(line$, x, ((y - 2) - x))
lon$ = MID$(line$, y, ((p - 2) - y))
IF lat$ <> groups$(gcount, 4) THEN 400
IF lon$ <> groups$(gcount, 5) THEN 400
line$ = "waypoint.3=" + "1" + RIGHT$(line$, (LEN(line$) - 14))
groups$(gcount, 1) = "directive=32"
GOTO 400

1620 IF LEFT$(line$, 15) = "waypoint.1=4,1," THEN runway$ = RIGHT$(line$, 8): runway$ = LEFT$(runway$, 4)
IF LEFT$(line$, 12) = "waypoint.3=," THEN line$ = LEFT$(line$, 11) + "1" + RIGHT$(line$, (LEN(line$) - 11))
groups$(player, 2) = runway$
IF wp = 7 THEN 400
IF groups$(player, 1) <> "directive=128" AND groups$(player, 1) <> "directive=2048" THEN 400
IF LEFT$(line$, 9) <> "waypoint." THEN 400
IF LEFT$(line$, 10) = "waypoint.0" THEN pcount = pcount + 1: paths$(pcount) = runway$
pcount = pcount + 1
IF LEFT$(line$, 10) <> "waypoint.1" THEN 1630
x = LEN(line$) - 5
line$ = LEFT$(line$, x)
line$ = RIGHT$(line$, (x - 12))
line$ = "waypoint.1=32" + line$ + groups$(gcount, 3) + ",0,1"
1630 paths$(pcount) = line$: wp = wp + 1
GOTO 400
1700 CLOSE
FOR I = 1 TO gcount
name$ = groups$(I, 7)
x = LEN(name$)
name$ = LEFT$(name$, (x - 2)): x = x - 2
name$ = RIGHT$(name$, (x - 15)): x = x - 15
y = INSTR(name$, "=")
name$ = RIGHT$(name$, (x - y))
groups$(I, 7) = name$
NEXT I
gcount = 0
OPEN "Missionx" FOR INPUT AS #1
1710 IF EOF(1) THEN 1720
LINE INPUT #1, line$
IF line$ = "type=air" THEN gcount = gcount + 1
IF gcount = 0 THEN 1710
IF groups$(gcount, 1) <> "directive=128" AND groups$(gcount, 1) <> "directive=2048" THEN 1710
IF LEFT$(line$, 9) <> "waypoint." THEN 1710
IF LEFT$(line$, 10) = "waypoint.0" THEN pcount = pcount + 1: paths$(pcount) = runway$
pcount = pcount + 1
IF LEFT$(line$, 10) <> "waypoint.1" THEN 1715
x = LEN(line$) - 5
line$ = LEFT$(line$, x)
line$ = RIGHT$(line$, (x - 12))
line$ = "waypoint.1=32" + line$ + groups$(gcount, 3) + ",1,1"
1715 paths$(pcount) = line$

GOTO 1710
1720 CLOSE
FOR I = 1 TO ccount
FOR J = 1 TO gcount
vr = VAL(groups$(J, 2))
IF vr = caps(I, 1) AND groups$(J, 1) = "directive=32" THEN caps(I, 2) = caps(I, 2) + 1
NEXT J
NEXT I
FOR I = 1 TO pcount
p$ = paths$(I)
K = LEN(p$)
IF K < 5 THEN 1900
p1 = INSTR(p$, "+") + 1
p2 = INSTR(p1, p$, ","): p3 = p2 - p1
a$ = MID$(p$, p1, p3): a = VAL(a$) + 2000: a$ = LTRIM$(STR$(a))
n1$ = LEFT$(p$, (p1 - 1)): n2$ = RIGHT$(p$, (K - p2 + 1))
p$ = n1$ + a$ + n2$: K = LEN(p$)
IF LEFT$(p$, 10) = "waypoint.1" THEN p$ = LEFT$(p$, K)
IF LEFT$(p$, 10) = "waypoint.2" THEN p$ = LEFT$(p$, K)
IF LEFT$(p$, 10) = "waypoint.3" THEN p$ = LEFT$(p$, K)
IF LEFT$(p$, 10) = "waypoint.4" THEN p$ = LEFT$(p$, K)
IF LEFT$(p$, 10) = "waypoint.5" THEN p$ = LEFT$(p$, K)
IF LEFT$(p$, 10) = "waypoint.3" THEN p4 = INSTR(p$, ",")
IF LEFT$(p$, 10) = "waypoint.3" THEN p$ = "waypoint.3=1," + RIGHT$(p$, (K - p4))
paths$(I) = p$
1900 NEXT I
FOR I = 1 TO gcount
runway = VAL(groups$(I, 2))
FOR J = 1 TO ccount
IF groups$(I, 1) <> "directive=32" THEN 2080
IF runway <> caps(J, 1) THEN 2080
IF caps(J, 2) < mincap THEN 2080
groups$(I, 0) = "available": caps(J, 2) = caps(J, 2) - 1
IF groups$(player, 1) <> "directive=32" AND groups$(player, 1) <> "directive=8" THEN 2080
IF groups$(player, 0) = "available" THEN 2080
IF caps(J, 2) >= mincap THEN groups$(player, 0) = "available": groups$(I, 0) = ""
2080 NEXT J
NEXT I
FOR I = 1 TO (pcount - 7) STEP 8
FOR J = 1 TO gcount
IF groups$(J, 0) <> "available" THEN 3070
IF groups$(J, 2) <> paths$(I) THEN 3070
groups$(J, 0) = "assigned": groups$(J, 1) = "directive=16"
paths$(I) = STR$(J)
3070 NEXT J
NEXT I
G = 0
OPEN "Missionx" FOR INPUT AS #1
OPEN "Missionxx" FOR OUTPUT AS #2
4020 IF EOF(1) THEN 5000
LINE INPUT #1, line$
IF line$ <> "type=air" THEN 4200
PRINT #2, line$
G = G + 1
4030 LINE INPUT #1, line$
IF LEFT$(line$, 10) = "directive=" THEN line$ = groups$(G, 1)
PRINT #2, line$
IF LEFT$(line$, 3) <> "id=" THEN 4030

4050 FOR I = 1 TO (pcount - 7) STEP 8
p = VAL(paths$(I))
IF p <> G THEN 4160
FOR J = 1 TO 7
PRINT #2, paths$(I + J)
LINE INPUT #1, line$
NEXT J
4160 NEXT I
GOTO 4020
4200 PRINT #2, line$
GOTO 4020
5000 CLOSE
KILL "Missionx"
NAME "Missionxx" AS "Missionx"
G = 0: linecount = 0
OPEN "Missionx" FOR INPUT AS #1
OPEN "Missionxx" FOR OUTPUT AS #2
6020 IF EOF(1) THEN 6500
LINE INPUT #1, line$
linecount = linecount + 1
FOR I = 1 TO gcount
x = VAL(groups$(I, 6))
IF linecount <> x THEN 6022
G = G + 1
6022 NEXT I
IF G = 0 THEN 6200
IF LEFT$(line$, 8) <> "payload=" THEN 6025
IF groups$(G, 1) = "directive=32" THEN line$ = "payload=1"
IF groups$(G, 1) = "directive=16" THEN line$ = "payload=1"

6025 IF LEFT$(line$, 14) <> "waypoint.3=512" THEN 6200
IF groups$(G, 1) <> "directive=32" THEN 6200
line$ = "waypoint.3=" + "1" + RIGHT$(line$, (LEN(line$) - 14))
GOTO 6200
6030 IF LEFT$(line$, 9) <> "waypoint." THEN 6200
K = LEN(line$)
line$ = LEFT$(line$, (K - 3)) + "1,1"
IF LEFT$(line$, 10) = "waypoint.6" THEN line$ = LEFT$(line$, (K - 8)) + "0,0,1"
6200 PRINT #2, line$
GOTO 6020
6500 CLOSE
KILL "Missionx"
FOR I = 1 TO gcount
IF groups$(I, 1) = "directive=8" THEN groups$(I, 1) = ": armed recon at: "
IF groups$(I, 1) = "directive=16" THEN groups$(I, 1) = ": escort to: "
IF groups$(I, 1) = "directive=32" THEN groups$(I, 1) = ": combat air patrol at: "
IF groups$(I, 1) = "directive=128" THEN groups$(I, 1) = ": strike at: "
IF groups$(I, 1) = "directive=2048" THEN groups$(I, 1) = ": anti-ship strike at: "
IF I = player THEN groups$(I, 1) = ": YOUR SQUADRON " + groups$(I, 1)
NEXT I
OPEN "Mission.mis" FOR INPUT AS #1
OPEN "Missionxx" FOR INPUT AS #2
OPEN "Missionx" FOR OUTPUT AS #3
6510 IF EOF(1) THEN 6900
IF EOF(2) THEN 6900
LINE INPUT #1, line1$
LINE INPUT #2, line2$
line$ = line2$
IF LEFT$(line1$, 11) = "waypoint.0=" THEN line$ = line1$
PRINT #3, line$
GOTO 6510
6900 CLOSE
KILL "missionxx"
G = 0: linecount = 0
OPEN "Missionx" FOR INPUT AS #1
7000 IF EOF(1) THEN 7900
LINE INPUT #1, line$
linecount = linecount + 1
IF line$ = "type=air" THEN G = G + 1
IF G = 0 THEN 7000

IF LEFT$(line$, 11) <> "waypoint.3=" THEN 7000
x = INSTR(1, line$, "N")
IF x = 0 THEN x = INSTR(1, line$, "S")
y = INSTR(1, line$, "E")
IF y = 0 THEN y = INSTR(1, line$, "W")
p = INSTR(1, line$, "+")
lat$ = MID$(line$, x, ((y - 2) - x))
lon$ = MID$(line$, y, ((p - 2) - y))
groups$(G, 4) = lat$
groups$(G, 5) = lon$
GOTO 7000
7900 CLOSE
PRINT "Some of the fighter squadrons' missions may have been changed."
PRINT "The current mission plan for squadrons at your airfield follows:"
PRINT
FOR I = 1 TO gcount
IF groups$(I, 2) <> groups$(player, 2) THEN 7930
PRINT groups$(I, 7); " "; groups$(I, 1); " "; groups$(I, 4); " "; groups$(I, 5)
7930 NEXT I
PRINT
PRINT "hit ENTER to continue."
INPUT q$
' change player squad payloads
PRINT
PRINT "You can change your squadron's payloads now."
PRINT
PRINT "Enter only the number of the desired payload, as found in the aircraft DP file."
PRINT "Be careful! If you enter something invalid, you will corrupt the mission file."
PRINT
PRINT "If you accidentally corrupt the mission file, go to your 'MISSIONS' folder."
PRINT "Copy 'Mission' from the 'MISSIONS' folder, drop it into your 'CAMPAIGNS' folder,"
PRINT "and run DCGQB again."
PRINT
PRINT "Just keep hitting ENTER at the prompt if you don't want to change your payloads."
PRINT
G = 0: linecount = 0: count = 0
gstart = VAL(groups$(player, 6))
OPEN "Missionx" FOR INPUT AS #1
OPEN "Missionxx" FOR OUTPUT AS #2
8000 IF EOF(1) THEN 8900
LINE INPUT #1, line$
linecount = linecount + 1
IF linecount < gstart THEN 8880
IF LEFT$(line$, 8) <> "payload=" THEN 8880
count = count + 1
IF count = 1 THEN PRINT "player "; line$: GOTO 8010
PRINT "wingman "; count; " "; line$
8010 q$ = ""
INPUT "desired payload (hit ENTER for no change)"; q$
IF q$ = "" THEN 8880
PRINT "you entered "; q$
PRINT "hit ENTER if that is correct, or enter 'n' for 'no' if not"
r$ = ""
INPUT r$
IF r$ <> "" THEN 8010
line$ = LEFT$(line$, 8) + q$
8880 PRINT #2, line$
8890 GOTO 8000
8900 CLOSE
8910 KILL "Mission.mis"
KILL "Missionx"
NAME "Missionxx" AS "Mission.mis"
10000 CLEAR : END