Log in

View Full Version : Setting waypoint/take off time


keinmann
03-08-2012, 11:47 PM
Hey guys,

I can't seem to figure out how to get planes to take off at a certain time. I have a huge wave of Luftwaffe planes flying from inland France, and I don't want the RAF to respond until the Germans are just off the coast. But it seems that FMB won't let me designate a time for the planes to take off -- it just forces them to take off at the start of the mission! :(

Any idea how I can accomplish this?

bolox
03-09-2012, 12:22 AM
http://forum.1cpublishing.eu/showthread.php?t=28487

this uses a pass thru trigger rather than 'setting a time'.

keinmann
03-09-2012, 04:10 AM
Hmm, this is new to me (never been into FMB too much) and looks quite useful.

However, it's a shame you can't just set the time... :(

FG28_Kodiak
03-09-2012, 04:42 AM
You can do this via script:

Set your Airgroups on Idle.


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


public class Mission : AMission
{

public void SetAirgroupActivAfter(Dictionary<string, double> StartAirgroupAfterTime)
{
List<AiAirGroup> allAirgroups = new List<AiAirGroup>();

if (gamePlay.gpAirGroups(1) != null)
allAirgroups.AddRange(gamePlay.gpAirGroups(1));
if (gamePlay.gpAirGroups(2) != null)
allAirgroups.AddRange(gamePlay.gpAirGroups(2));

allAirgroups.ForEach(item =>
{

foreach (KeyValuePair<string, double> kvp in StartAirgroupAfterTime)
{
if (item.Name().Contains(kvp.Key))
{
Timeout(kvp.Value, () =>
{
item.Idle = false;
});
}
}
});
}

public override void OnBattleStarted()
{
base.OnBattleStarted();

SetAirgroupActivAfter(new Dictionary<string, double>
{
{"BoB_RAF_F_64Sqn_Early", 120.0}, //2min
{"BoB_RAF_F_111Sqn_Early", 180.0}, //3min
{"BoB_LW_JG51_III", 900.0} //15min
});
}
}


With SetAirgroupActivAfter you can activate the Airgroup.
You can also use (for example)
SetAirgroupActivAfter(new Dictionary<string, double>
{
{"BoB_RAF_F", 900.0} //15min
});

to set all RAF Fighter units active after (in this case) 15min.

keinmann
03-11-2012, 02:37 AM
I have years of professional experience with C#, but I'm a n00b for FMB. I'm not quite sure how to even load/execute a C# module with the IL-2 engine/FMB! :confused:

Anyway... You got me wondering... If I set up some front markers for red and blue, is there a C# event/delegate I can subscribe to when aircraft cross the front? Something like:

void onFrontCrossed(params Plane[] planes) {
// ...blah blah blah ...
}

???

Where can I find documentation on this stuff? Is there any? :confused: If I had some comprehensive documentation I suspect I could get quite good with FMB fast, and be able to develop some interesting missions and content.

P.S. -- I also have VS Pro, and would much prefer using my own IDE. Is there any way to do it properly?

FG28_Kodiak
03-11-2012, 03:56 AM
First there is no documentation. If there is a cs file with the same name than the mission the Engine calls the .net csc and execute the file.
To get access to the "CloDo programming interface" add references to the assemblies "antlr.runtime.dll", "core.dll", "gamePages.dll", "gamePlay.dll", "gameWorld.dll", "HostView.dll", "maddox.dll", "part.dll", "sound.dll" and "Strategy.dll" in ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\core
and
to the files "partBob.dll" and "Campaign.dll" in ..\Steam\SteamApps\common\il-2 sturmovik cliffs of dover\parts\bob

Then you can examine the classes with the object explorer.
The importent classes for missions are AMission and IGamePlay (GamePlay Object).
There is many try and error expirience, some of the members not working proberly (or not fully implementet at time) or they work in single player and player hosted missions but not on Dedi Server. :rolleyes:

There is no event for crossing Front but you can use
GamePlay.gpFrontExist() // true if there is a front line
GamePlay.gpFrontDistance(int army, double x, double y) // double distance to front line < 0 if army == player.Army() > 0 if oposite
And with the OnTickGame() - Event (one Tick is 1/30sek) you can check by your own if a plane cross the line

keinmann
03-11-2012, 06:50 AM
THANK YOU!!!!!!! :shock: A post like that should be stickied!

I had no idea what references where needed, so thanks a LOT!

P.S. - Bist du Deutscher?

FG28_Kodiak
03-11-2012, 07:01 AM
Jawohl ;)

keinmann
03-11-2012, 07:32 PM
Ahhh, kühl... sehr gut! Ich dachte dass! Ich bin Amerikaner, aber ich kann Deutsch; nicht der best, obwohl gut genug, ich glaube! :)

Dein Englisch ist einwandfrei, aber die sehr kleine linguistische Feinheiten gibt mir das Andeutung. Zum Beispiel, du sagte "one Tick is 1/30sek", statt "1/30sec". :grin:

Smokeynz
03-11-2012, 08:10 PM
I spotted TOD (time of day) in the classes whilst searching for other stuff.

I suspect it would be possible to use that to spawn in aircraft or idle to a TOD setpoint.

Keinmann, personally I think it is just easier to spawn in aircraft via a separate mission from timer in a script, where you can choose to use a single time period or repeating spawn in cycles. (or any other trigger event you can load a mission containing items required)

Think of the base core mission as a clean "just the choosen map and battle area" , then the idea is you have a separate missions with just the items required.

Have a look through the sticky links of collections of scripts gathered already.
I'm only learning C# as far as application to CLOD so come unstuck with syntax at times, but if like Kodiak you have experience with C# it helps alot with exploring better methods and getting basic syntax correct.

keinmann
03-11-2012, 09:41 PM
Thanks, Smoke! I wasn't aware you could mold several missions together. That sounds like a clean and interesting approach.

Would any C# tutorials be of use to fellow FMBs/modders here? I'd be more than happy to write some in return for the generosity of the community. I have a way of teaching it which makes the language and OOP easy to understand, so I figured it may help the aspiring programmer or modder.

Smokeynz
03-11-2012, 10:13 PM
The more advanced C# programmers available to help guide non programmers the better.

Kodiak has started some turorials, however time for him and others to post lots of detailed guides is short. So I'm sure assistance with tutorials would be appreciated.

From my experience so far, I find getting basic syntax correct is the most difficult thing. For example taking methods outlined at microsoft and adapting the method for use.

However quite often the code is incomplete, missing some elements because there is asumptions that users know what they are doing.

For CLOD, I believe alot of users are not aware of the possibilties that scripting can achieve, sure there is bugs (what hasn't got bugs eh!)

btw I am working on a script(evolution of script and mission design in my scrimbase mission in collection downloads) which allows for real time sub mission updating without the need to reboot the main mission. The idea is for remote management ftp uploading a mission and mission list, it still works for local player hosting aswell.
Kodiak has been helping with code.....i say helping...he is writing main I adapt and drink lots of coffee trying to understand it :) , however generally he guides basic syntax method which intern guides correct logic in my adaption.