PDA

View Full Version : A Sample Mission for Serie B mission builders



No601_Swallow
May-12-2014, 05:57
To use an English footballing analogy, there are obviously Premier League mission builders, who are writing great missions, often absolutely epic in scope, and who are often pushing scripting where No Man Has Gone Before. This mission is not for them, or for the good jobbing Championship mission builders.

But it might be of interest to mission builders in my league - possibly League One or Two, possibly Vauxhall Conference (Southern).

My squadron flew a coop-style ops mission (of course in our own dogfight server) last night, and most of the bells and whistles worked! In an effort to drag my fellow squadron mission builders out of the non-league rankings so they can gain a foothold in League Two, I thought I'd explain what I'd tried to do and how I did it. A couple of them thought others in the wider CloD world might be interested. Obviously, comments and suggestions and corrections (!!!) would be welcome. (Already I can think of several better ways of doing things, but anyway...)

The Mission was called BoB50. The idea behind the mission was that three squadrons would fly out from Croydon, Kenley and Biggin, engage a largish group of bombers over Maidstone, return to base, respawn and wait for a just-in-time scramble to fight off a low level Jabo attack. Normally as a squadron we'd do something like this as two short missions, but with triggers we found we could do it in one (aiming for that feeling of a chaotic return to base, only to be sent out tired and stressed to face the enemy again straight away.)

There was one main mission (BoB50.mis iteslf, with a script file and a briefing file), which had the spawning locations and airfields and the scenery. That's all it had, plus one trigger (made in the FMB/Edit/Script/"trigger" tab), called "pass_malling". This was tripped when the first red aircraft entered a circle based around Maidstone/West Malling airfield.

The "pass_malling" trigger launched sub-mission 1, which had the bombers and their waypoints and some more triggers. One trigger for each of the three formations launched three new submissions to spawn in snappers and their waypoints (I cut down on the numbers of escort - mistake!).

The "pass_malling" trigger also launched the smoke submission (submission 6) with a 240 second delay. So, 4 minutes after the first red aircraft arrived at West Malling, pillars of smoke at the three starting airfields started up, so they'd be good and ready when we got back to the Biggin/Kenley area. This was to try to simulate the airfields already having been hit, basically to add atmosphere and eye-candy. (Not to be underestimated in a coop mission!)

Sub-mission 1 had one more trigger, which I erroneously called "return_gatwick" (it should obviously have been "return_croydon". Ah well.). This was to be triggered when the first red aircraft returned to Croydon, and this launched the last submission (submission 2, I think) with the second 110 Jabo wave (after a 240 second delay). The idea was that four minutes after the 1st aircaft got back to Croydon (and presumably after players at the nearer airfields were already landing) the new wave would spawn in, together with the message to scramble, leaving a further three minutes' flying time for the wave to get to target.

So, the main mission had just the spawn points, the scenery and the trigger for the first submission, which had the bombers and triggers for everything else, more or less. But the main mission of course had the .cs script that made all the triggers from all the missions work.

Here's the text of the .cs script (the stuff after the onTrigger section is just a bog standard despawn script,):


using System;
using System.Collections;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;




public class Mission : AMission
{


public override void OnBattleStarted()
{
base.OnBattleStarted();
MissionNumberListener = -1; // listen for events from this mission & all submissions
}


public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);


if ("pass_malling".Equals(shortName) && active)
{
GamePlay.gpHUDLogCenter("The enemy formation is now east of Maidstone, heading roughly 270, Angels 10!");
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub1.mis");
Timeout(240, () =>
{
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub6.mis");
GamePlay.gpHUDLogCenter("Airfields already under attack: Eastchurch, Rochford, Detling, Biggin");
});
GamePlay.gpGetTrigger(shortName).Enable = false;
};


if ("escort_01".Equals(shortName) && active)
{
GamePlay.gpHUDLogCenter("No escort so far?");
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub3.mis");
GamePlay.gpGetTrigger(shortName).Enable = false;
};


if ("escort_02".Equals(shortName) && active)
{
//GamePlay.gpHUDLogCenter("Bugger! Escort! sub4");
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub4.mis");
GamePlay.gpGetTrigger(shortName).Enable = false;
};


if ("escort_03".Equals(shortName) && active)
{
//GamePlay.gpHUDLogCenter("Bugger! Escort! sub5");
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub5.mis");
GamePlay.gpGetTrigger(shortName).Enable = false;
};


if ("return_gatwick".Equals(shortName) && active)
{
GamePlay.gpHUDLogCenter("Spitfire returns to Croydon");
Timeout(240, () =>
{
GamePlay.gpPostMissionLoad("missions\\Multi\\Dogfight\\all_submissions\\BoB50\ \BoB50_sub2.mis");
GamePlay.gpHUDLogCenter("SCRAMBLE! Incoming now! 3 or 4 minutes out to the south! Don't just sit there!...");
});
GamePlay.gpGetTrigger(shortName).Enable = false;
};


}




private bool isAiControlledPlane(AiAircraft aircraft)
{
if (aircraft == null)
{
return false;
}


Player[] players = GamePlay.gpRemotePlayers();
foreach (Player p in players)
{
if (p != null && (p.Place() is AiAircraft) && (p.Place() as AiAircraft) == aircraft)
{
return false;
}
}
return true;
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{ damageAiControlledPlane(actor); }
);
}

private void damageAiControlledPlane(AiActor actor)
{
if (actor == null || !(actor is AiAircraft))
{
return;
}


AiAircraft aircraft = (actor as AiAircraft);


if (!isAiControlledPlane(aircraft))
{
return;
}


if (aircraft == null)
{
return;
}


aircraft.hitNamed(part.NamedDamageTypes.ControlsEl evatorDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsAi leronsDisabled);
aircraft.hitNamed(part.NamedDamageTypes.ControlsRu dderDisabled);
aircraft.hitNamed(part.NamedDamageTypes.FuelPumpFa ilure);
aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalF ailure);
aircraft.hitNamed(part.NamedDamageTypes.Eng1TotalF ailure);


Timeout(2, () =>
{ destroyPlane(aircraft); }
);
}

private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.Destroy();
}
}
}

For people like me who are baffled by things like this, I've tried to explain a few lines (and lots of stuff is wrong or missing, but honestly, I'm not a programmer and don't understand the hows or the whys, and I wish I could add more detailed explanations):

9591

To reiterate, the punctuation in scripts (all the semi-colons and the brackets - ah the brackets!!!) are all crucial. I don't trust myself to get it right, so I cut and paste (and gingerly edit) lines others have written.

Anyway, if people want to have a fiddle, the mission (and its submissions) can be downloaded here: https://app.box.com/s/vcqh6u2lf49hgthhzhg6.

Unzip it into your 1C SoftClub...il2-Mod...missions/Multi/Dogfight folder. The .mis & .cs & .briefing files will be in the Dogfight folder as per normal. You'll find the submissions in the .../all_submissions/BoB50 folder. (Of course, the file structure can be changed to anything you want (more or less), but then you'll have to edit the script, so it can find the right files.)

Hope this helps any non-league mission builders dreaming of one day reaching top flight excellence!


Edit: a couple of extra things...

The main advantage in using submissions is that each submission can have its own triggers. This really increases the scope and complexity of what you can do in a mission. Funnily enough, though, the map for most of these submissions is - of course -very empty, just the waypoints (or objects - or even just another set of triggers!) for a group or two of aircraft!

(One way to do sub-missions with various groups of aircraft meeting and interacting is to compile all the flights as normal on a master map and then cut and paste the aircraft group and waypoint information (i.e. the text) from the master .mis file into a new but empty .mis file. Easy, after you've looked at the text of a few .mis files.)

(By the way, the smoke submission was a bit tricky to do because I had to paste the static and buildings sections - from the main mission's .mis file - into a new mission, add the smoke and then go back to the text of that new .mis file and delete the scenery again. Luckily Notepad++ (http://notepad-plus-plus.org/) has a very handy find/replace function, so it was in the end a piece of peess.)

ATAG_Freya
May-12-2014, 09:06
Wow thank you Swallow! The explanation of the script alone is valuable info, and helps make a bit of sense to what already looks like some long lost ancient dialect from god knows when... I would love to see more mission builders do scripting tutorials in such fashion. I'll be D/L ing this and putting it under the knife to learn more from it! THX

:salute:
Freya

69th_Spiritus_Mortem
May-13-2014, 00:15
Submissions are a really interesting aspect in CloD. I remember either being told or read that certain buildings or static objects reappear if destroyed or something? Not really sure.

Good stuff though, I think there is a lot of creativity out there for mission building but it is overwhelming and daunting when you first start, this is another helpful post!

:salute:

No601_Swallow
May-13-2014, 01:11
We think (that is, mission building boffins think) that the game will not load "Buildings" (the category in the FMB object browser) in submissions. It'll load them in the main mission, but not in submissions. Why? Who knows. It's a CloD thing.

Pretty much everything else loads as a submission, I think.

(Some objects - I think some hangars - seem to appear in the "statics" category and the "Buildings" category! My own speculation is that the "Buildings" may have originally been meant as map-building objects rather than mission buildling objects, but who really knows?)

[One other thing about submissions that I sometimes wonder about is the .mis file. Obviously, submissions shouldn't really have their own script (aspects of a submission's script don't seem to work, so it's safer to put all the scripting shenanigans in the main mission's script), but they all need their own .mis file, obviously. But I don't know which bits of the .mis file the game will use. For instance, the map and weather sections would cause conflicts if they were different from the main .mis file, so presumably the game disregards them? Anyway, questions, questions...]

By the way, I'm going to amend this mission to add a proper briefing. My squadron doesn't really put briefings into coop-style missions, because players spend their time before the mission is launched staring at the "Waiting for Battle" message, waiting for the host to press the "Start Battle" button - yet another bafflingly bad design choice by the game designers!!

AKA_Recon
May-14-2014, 08:50
Outstanding I wish more developers/mission designers would share here. The more sharing, the better for the community.

Would be nice to have a public github repo where we can put this code for others.

Very good stuff!

(I am C# developer but just a newbie in terms of the API for CloD)

=FI=Murph
May-29-2014, 12:07
Thank you, we have been having a lot of fun playing this mission. Nice how it seems to play out a little differently each time.

Cruzz 88
May-30-2014, 04:34
Hallo !
I installed this and checked through the .mis files. In 6 and 7 there is no plane count ?

No601_Swallow
May-30-2014, 06:07
Can't remember! I think submissions 6 and 7 generate smoke to simulate attacks having happened on Kenley and Biggin. Or something like that. Stick 'em in the FMB and have a look (although the black squiggles for smoke objects are hard to see sometimes!).

But that's the advantage of submissions - with the annoying exception of "Buildings" they can load anything in for you, not just flights of aircraft, including further triggers (which is pretty cool).

So, I suppose a seriously ambitious mission builder could perhaps put all of his airport eye candy in a separate mission to launch immediately (in the OnMissionLoaded section of the script), and then have another mission with the eyecandy replaced by the "damaged" statics in the FMB - although this would, I presume, a need to simultaneously despawn all the eye candy from the previous mission - and for that you'd need to write the instructions into the script - which, of course, I can't do.

Actually - that would be a useful script - not just despawn aircraft but static objects and buildings - perhaps within a radius of a given point. Useful script ([I]hint, hint... suggestive eyebrow wiggle...), useful... :D

Another question is if there'd be any way to "spawn in" weather from the first part of the .mis file. As far as I know, submissions totally ignore that part (which also gives map information and time of day). Would be nice to have a change of weather, though. But I doubt the game'll let you.

=FI=Murph
May-30-2014, 11:22
So, how did you create this mission? Some sort of step-by-step would be most helpful. The notes on the script are very informative, but like you I have no code writing talents. I could use some help understanding how you got to that point.

No601_Swallow
May-30-2014, 12:42
Arrrr, me Hearties, he says as he hitches his wooden leg closer to the hearth, the livid scars on his weather-beaten face vivid in the firelight. Arrr, 'tis a long and treacherous road, the road of the FMB, full of woe and frustration, and cats being kicked, and monitors running moist with the spittle from curses screamed hysterically into the ether...

OK, breaking character: as we mostly know, the FMB can create missions just like in IL2 '46. If you can do a mission in '46, you can do the same one in CloD. More or less. But - and others are much more up on this than me - I think the CloD FMB offers a couple of quantum leaps in terms of what you can do.

The first is triggers. You can get the game to do things ("actions") after a trigger is, erm, triggered. There are four types of trigger. You can access the trigger dialogue box through the Edit/"Scripts" (I know, don't ask) menu. So you can have stuff spawn in after your (or your side's) aircraft have passed as certain point, or after a percentage of enemy have been destroyed, or after a certain time. Already this is pretty cool stuff. But you can only get aircraft to spawn in. This is, sadly, the only "action" available in the FMB for your triggers. In addition, triggers only work in SP (why oh why oh why? Great monstrous BoB-elzebub?). Unless... It's a big unless...

We turn to the second quantum leap: scripts. A script can enable your triggers in MP. But a script can do more. A whole lot more.

CloD scripts are written, correct me if I'm wrong in a programming language thingy called C#. Which anyone can learn. Yeah right. You lost me at #. To get your triggers to work you have to have a script. Which I can't write. Which I can't do.

What I can do is cut and paste bits of scripts that other people have done. There are lots of intros and lists and groups of scripts knocking around, and there are some genius scripters knocking around here, on the little ol' ATAG FMB forum. Obviously the boffins have foreheads the size of The Mekon, making them instantly recognizable. But scripts are cool, a Maddox Games guy gave us a script that automatically spawns in ambulances and fuel bowers when you land - thrilling if, like me, you think that the height of FS2004 was moving airbridges. But basically, scripts can do all sorts of stuff.

For the mission above, all the script does is 1) listen for triggers I put into the mission(s) in the FMB, 2) enable the triggers to work, 3) display a HUD message when the trigger is triggered, 4) launch a submission when the trigger is triggered. Oh and 5) despawn squad-mate morons who've spawned in the wrong aircraft. So the script is extremely basic, as these things go.

Getting back to actually putting mission together, once you're confident about having your triggers launch new submissions on the same map while the main mission is continuing, then you can do pretty much anything. So, for me it's easier to put the scenery/eye-candy/ground targets/spawning bits in the main mission and then have everything else in a new submission.

If you want to do this IL'46-style, you can build your mission as per normal, with friendly flights, ground objects, opposition, etc, but instead of worrying about timing so your flight has to be at grid-point such and such at altitude such and such, you can put in a trigger (in my case, just west of Maidstone) so that when we first get to Maidstone the enemy spawns in just a few miles away.

So, if you save your conventional mission, you can open the mission file (xxxxx.mis) in a text editor (Notepad++ (http://notepad-plus-plus.org/) is just great). Now Alt-tabbing back to the FMB, you can create a new empty mission and save it, generating a new mission file. (xxxxx_sub01.mis or whatever). Open that file in the text editor too. Now you can simply cut and paste the flights from one mission to the next. Here's a randomly picked .mis file, with just one flight:

9857

I suppose the only thing to watch out for is the usual .mis file style: the "airgroups" section begins with a list of all the airgroups in the mission (suddenly the names you've given the groups becomes important!!!), then, each group has its own separate section, so this means you have to cut and paste separately the list bits and the details bits, if you see what I mean.

I find I can't cut and paste the ground objects like this, because they're too confusing, so I use the FMB to delete what I don't want, etc, etc. But often I find it easier and faster to adjust the .mis text than the mission in the FMB.

Anyway, now you've got a main mission with your flight (or spawn areas) plus ground objects, plus the trigger (in the above .mis text, the trigger and spawning stuff is further down the .mis file) and another sub-mission with the enemy flight(s). So now you turn to the script, which you've already sourced (stolen! :D) from somewhere else. The one I included might be a good one to start. And you have to edit it (http://www.microsoft.com/en-gb/download/details.aspx?id=34673) - change the name of the trigger, change the path of the submission, change or delete the HUD message (but it's nice to keep some HUD message, at least when testing, so you know at least the trigger worked. If nothing spawns in, that means you've got the path or name of the submission wrong.)

And so it goes. I think the easiest way to learn this stuff is to look at examples, and ask questions in the forum. Most people are very very generous with info if they think the request is genuine and the requester (so to speak) is putting in a bit of effort and not just trying to freeload somehow. In my experience, anyway.

But this is just my personal experience. I'm trying to make things easier for my squad-mates.

I'm sure it would be possible to do more detailed guides, but others have already done more and better. Philstyle's tutorials (https://www.youtube.com/channel/UCaLiosPyg4O4UF3Kf1mB7LQ) are great, as are Flying Nutcase's IL2 '46 ones (https://www.youtube.com/channel/UC8nS0nVXPmVRfmNpTKFAobw). For more advanced google-translated stuff, Kodiak's the man (http://translate.google.com/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fforum.sturmovik.de%2Findex.php%2Fbo ard%2C17.0.html). There's an old but still useful library of scripts (allsamples2) is here (http://forum.1cpublishing.eu/showthread.php?t=26523), and miscellaneous banana stuff in that forum (http://forum.1cpublishing.eu/forumdisplay.php?f=203).

Hope this helps a little.

=FI=Murph
May-30-2014, 13:45
It helps a lot. I've built quite a few missions for il2 1946, so I'm pretty familiar with that FMB (always ready to learn something new though). This will give me a leg-up on how to create missions with triggers using the ClOD FMB. The missions I've built so far for ClOD (or, in a couple of cases, adapted from someone else's mission) have had to have extensive testing to get everything "timed" correctly, and then things will go awry when we actually fly it, due to stuff like people having to re-spawn because of a blown engine, for example, or other sorts of delays in taking off/forming up. Using triggers might not only solve a lot of this, it will allow replayability but having different sorts of events be triggered each time the mission is played- great stuff!

No601_Swallow
May-30-2014, 14:34
:D

Been there, done that, got the teeshirt.

A little bit off topic:

The whole timing thing (I can feel a lecture coming on about the "Start Battle" button and how it kicks coop missions right in the gonads - why can't we spawn in before the host clicks start battle?), the whole timing thing - it was poisoning my whole squadron, certainly their already rocky relationship with CloD.

It's why, honestly, I came up with the "pseudo-airfield spawning" thing. We were wasting so much time taxiing around, running into each other, forgetting the sodding radiator, not know where everyone was on the airfield...

It's not often you experience an honest to goodness Eureka moment, but I did, coming back from the pub! I had been trying to get some static hangars I'd put on the crest of a hill to open their doors as part of an obstacle course, so a squadron-mate suggested I put spawn points (he meant airdrome points) inside the hangars. [Edit: that's not quite it: he said he'd seen hangar doors slide open at the start of missions, and that got me thinking about the spawning locations inside the hangars. Anyway...] It worked. So the Eureka thing was wondering if I could put airdrome points in a line at the actual take-off airfield, so for our obstacle race we could all spawn in a row. Eventually it worked... so now for ops coops, we spawn on the runway in sections every time. And I've learnt a hell of a lot more about spawning and .mis files and the FMB! And I've got more grey hairs and wrinkles. So everyone's happy!

But triggers is a thing of beauty. I must say though, I always feel seriously humbled when the boffins say things like "Triggers? I don't bother with them any more... I just put it in the script..." Hopefully when my fourteen-year-old boy starts IT, I can get him coding like he's living in Bangalore!