PDA

View Full Version : [Tutorial] Simple Scripting Lessons - Trigger Part 1 (Basics)


FG28_Kodiak
12-13-2011, 08:42 PM
In the old IL-2 1946, one can control the success of the mission with the help of the target object. The options are destroy, destroy ground, destroy bridge, recon, escort, defence, defence ground and defence bridge. Additionaly, it is possible to set a time limit, to make the target a primary, secondary or a hidden objective.

http://img600.imageshack.us/img600/8174/il2fb1.jpg
http://img685.imageshack.us/img685/5253/il2fb2.jpg


In IL-2 Cliffs of Dover, these target objects are replaced by triggers. However, the ambitious mission builder will soon realise that, without scripting abilities, one can only spawn aircrafts. The aim of the next lessons will be to achieve the same as in 1946 with the help of scripts.

In this lesson let's first take a look at the possibilities of Cliffs of Dover without scripting.

We start the full mission builder and make some preparations.
At first, we place a "observer plane" at an airfield, which can be manned by a player. It's only use is to observe the passing of the events.
http://img64.imageshack.us/img64/7119/tutles0101.jpg

Now, place a group of Bf110s on the map, which are supposed to spawn later by means of the trigger. It's very important to select "Script Spawn C", because otherwise the Bf110s spawn at the beginning of the mission and a second time when the trigger is activated.
http://img220.imageshack.us/img220/4846/tutles0102.jpg

After this, we call up the script and trigger menu.
http://img259.imageshack.us/img259/6585/tutles0103.jpg

Under trigger, we set up a new one by clicking "add".
http://img38.imageshack.us/img38/4934/tutles0104.jpg

At first, we change the standard term "trigger" into the more meaningful name "Bf110Spawn".
http://img534.imageshack.us/img534/7900/tutles0105.jpg

Now we have the option to select the type of the trigger. At the moment, Cliffs of Dover supports 4 different types:

-TTime: This trigger is activated after a specified amount of time (set in seconds). However, CloDo isn't very precise with this.
-TGroupDestroyed: This one is activated, after a certain percentage of planes or vehicles (tanks, ships etc.) from a group have been destroyed.
-TGroundDestroyed: This one is activated, after a certain percentage of ground targets has been destroyed at the position XY with the radius R.
-TPassThrough: This trigger is activated twice. The first time, when something (player, AI-plane, ground units etc.) enters an area and the second time when it leaves the area.
http://img543.imageshack.us/img543/2467/tutles0106.jpg

For the first test, let's choose TTime, as it is the simplest one, and set the time to 30 seconds.
http://img259.imageshack.us/img259/2223/tutles0107.jpg

After this, we choose "Actions" and also click "add". The name of the action has to be the same as the name of the trigger, i.e. Bf110Spawn. Without using scripts, this is the only way to activate the action with the help of a trigger. If the names aren't exactly the same, nothing happens. The only type of action available is ASpawnGroup, with which one can spawn planes. Sadly, the aren't any other actions in Cliffs of Dover.
http://img830.imageshack.us/img830/5815/tutles0108.jpg

Next, we click the little button.
http://img828.imageshack.us/img828/6797/tutles0109.jpg

Now we choose our Bf110 group with the appearing crosshair.
http://img205.imageshack.us/img205/9061/tutles0110.jpg

Afterwards, everthing needs to be saved.
http://img818.imageshack.us/img818/3316/tutles0111.jpg

Now we can start the mission.
http://img840.imageshack.us/img840/740/tutles0112.jpg

At the beginning of the mission, we are a bit lonely.
http://img97.imageshack.us/img97/7830/tutles0113.jpg

But this changes after about 30 seconds.
http://img543.imageshack.us/img543/94/tutles0114.jpg


Basicly, we achieved the same in this example as in IL-2 1946, by entering a different time at the starting waypoint. From this perspective, it is rather complicated to spawn planes in Cliffs of Dover after a certain amout of time. The advantage is, however, that one can also use the other trigger types. One can also spawn planes when a certain area is entered or one can send "reinforcements" if to many planes of a group have been destroyed etc.

But to exploit these advantages, one has to use scripts. We will start with those in the next lesson.


Suggestions or criticism are always welcome.

Thanks to FG28_Elatan for the translation of the German lesson into English.

KG26_Alpha
12-13-2011, 09:59 PM
Thxz

Gamekeeper
12-13-2011, 10:01 PM
Thanks for posting and to FG28_Elatan for translation.

Bounder!
12-13-2011, 11:20 PM
Cheers for posting - very informative and clear to follow - looking forward to the next installment

Octocat
12-14-2011, 12:37 AM
Cool, where can I enroll as a student? :cool:

Pato Salvaje
12-14-2011, 06:37 AM
WOW! great tutorial!
Thank you for your work Kodiak & Elatan.
And... we are waiting for more! keep it coming!! ;)

335th_GRAthos
12-14-2011, 06:47 AM
Cool, where can I enroll as a student? :cool:
+1

Much appreciated Kodiak! Great work and very nice formulation, easily understandable!!!!
(for one moment I panicked looking at the German titles of the IL2FB screenshots, good that you have no Russian CoD :D )

WarFox101
12-14-2011, 07:51 AM
WOW! great tutorial!
Thank you for your work Kodiak & Elatan.
And... we are waiting for more! keep it coming!! ;)

x2

Ataros
12-14-2011, 07:54 AM
Thank you very much, Sir!

No1 Cheese
12-17-2011, 04:42 PM
Thanks a lot for that,ive been trying to work the basics out for awhile now.Very easy to follow(even for me:rolleyes:)
Thank you very much

Cheese

Stiboo
12-18-2011, 08:48 AM
Yes - very easy to follow and interesting

Can't wait for the next lesson!

Thank you so much for the time and effort put into this...

Cheers


Simon

xpupx
03-01-2012, 12:00 AM
Lesson 2 please lol

ajay
03-20-2012, 02:12 AM
Kodiak, i reposted the tutorial on my Clod page here http://jimeez.weebly.com/ . I am trying to make sure basic and well done tutorials like this do not get lost and buried in the forums over time :)

Cheers

major_setback
11-21-2012, 02:10 PM
For me the image below just shows as a red cross. All others in the tutorial are fine.
I expect it is an essential one too.:-(




....Now, place a group of Bf110s on the map, which are supposed to spawn later by means of the trigger. It's very important to select "Script Spawn C", because otherwise the Bf110s spawn at the beginning of the mission and a second time when the trigger is activated.
http://img220.imageshack.us/img220/4846/tutles0102.jpg

After this, we call up the script and trigger menu....

Punch_145
12-12-2012, 05:13 PM
Must say Kodiak these tutorials here and on forum.sturmovik.de are a great help :)
Is it possible to have more than 1 parameter effect the mission success hud message?
i.e. a % of an air group destroyed plus complete a landing at home base both influence whether you see a Mission Success message...........

Regards

Punch.

bolox
12-12-2012, 05:35 PM
something like that is possible- something very like that is used in the Redux campaign for the 'help in combat' mission

private void checkLanded(AiAircraft aircraft) {
if (GamePlay.gpPlayer().Place() != aircraft)
return;
if (end != true) {
Campaign.battleSuccess = false;
GamePlay.gpHUDLogCenter("YOU FAILED! DISMISSED."); //STD
Timeout(5.0, () => { ShowResult(true); }); // STD
return;
}
if ((end = true) && (safe = true)) // check reached mission objective

{
Campaign.battleSuccess = true;

writeScore(cPlayer + readScore()); // STD : increase campaign kills


GamePlay.gpHUDLogCenter("GOOD SHOW! Less than 4 of 111Sqn shot down." );
Timeout(5.0, () => { ShowResult(true); });//STD


Timeout(15.0, () => { GamePlay.gpHUDLogCenter("Your campaign kills : " + readScore()); });//STD

}




}
gives a success message if the bool 'end' is satisfied when the player lands. There is some extraneous stuff in there relating to the campaign scoring system.

A 'TGroup Destroyed ' trigger could make bool end = true to make it run?

Punch_145
12-13-2012, 04:56 PM
Cheers m8 ................will try it :)

Punch_145
12-21-2012, 07:54 AM
Regarding "triggers" , I tried to create a spawn group of 8 110's triggered when a red air group passed through an area. This worked but every time the pass through was entered another 110 group was created, ended up with about 60 110's
Is this correct and if so is there any script to close the trigger once it has been triggered?

Punch

FG28_Kodiak
12-21-2012, 09:33 AM
You can deaktivate the trigger with:

GamePlay.gpGetTrigger("Triggername").Enable = false;


See also this thread:
http://forum.1cpublishing.eu/showthread.php?t=35685

Punch_145
12-21-2012, 12:38 PM
Thanx m8 ;)

So like so yes?

} AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
if (action != null)
{
action.Do();

}
GamePlay.gpGetTrigger(shortName).Enable = false;

}
}

FG28_Kodiak
12-21-2012, 02:30 PM
Yes ;)