PDA

View Full Version : Script assistance needed


ATAG_Bliss
09-09-2011, 10:02 PM
I'm trying to find a way to limit human controlled plane types (spit, hurri, 109 etc.) to a certain amount. Say I only want to have 4 spitIIa's or 4 110C7's, would anyone know how to do this?

I know with FBDj of old, it was simple. Say a map that had a 262 in it, you could limit them to 2 (for example) and only 2 could ever be spawned in game at once (aka - only 2 possible at all times throughout the mission). Any more than 2 and the selection would simply be greyed out or not selectable.

Any chance someone has found a way to do this with IL2COD yet?

Would be much appreciated.

Thanks!

Ataros
09-10-2011, 09:28 AM
This mission has a script limiting number of aircraft by type. http://forum.1cpublishing.eu/showthread.php?t=23579&highlight=operation+dynamo
If you make it working please share the final script to add to community knowledge base. I asked several times but never have seen scripts Syndicate or ATAG is running :) C'mon you are nice guys :) Let's make the CloD world better by sharing knowledge.

ATAG_Bliss
09-10-2011, 03:28 PM
Hi Ataros - Thanks :)

I'll take a look at that and see if I can't get something to work. As far as the scripts are concerned, there's nothing special lol. The knowledge all came from you guys. I just know how to copy/paste to fine tune!

But I use a combination of .cmd files (using f to load and timeout command to recycle the mission) and C# to be able to make the scripts work 24/7.

Here's the scripts for the main and submission:

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

public class Mission : AMission
{
public override void OnBattleStarted()
{
base.OnBattleStarted();

//listen to events from all missions.
MissionNumberListener = -1;
}

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

public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}
public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft)
{
base.OnAircraftLanded(missionNumber, shortName, aircraft);
Timeout(300, () =>
{ destroyPlane(aircraft); }
);
}

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

//check if a player is in any of the "places"
for (int i = 0; i < aircraft.Places(); i++)
if (aircraft.Player(i) != null)
return false;

return true;
}

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

private void damageAiControlledPlane(AiActor actorMain)
{
foreach (AiActor actor in actorMain.Group().GetItems())
{
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);
int iNumOfEngines = (aircraft.Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
aircraft.hitNamed((part.NamedDamageTypes)Enum.Pars e(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}


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

}

}

submissions

using System;
using maddox.game;
using maddox.game.world;

public class Mission : maddox.game.AMission
{

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

if ("SpawnAirgroup1".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup1");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("BR.20M's enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup5".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup5");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Blenheims enroute to Coquelles");
GamePlay.gpGetTrigger(shortName).Enable = false;
}



if ("SpawnAirgroup2".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup2");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Stukas enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup6".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup6");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to Caffiers");
GamePlay.gpGetTrigger(shortName).Enable = false;
}

if ("SpawnAirgroup3".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup3");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("He 111s enroute to Lympne");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup7".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup7");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to Pihen Airfield");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup4".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup4");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Ju 88's enroute to Hawkinge");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
if ("SpawnAirgroup8".Equals(shortName) && active)
{
AiAction action = GamePlay.gpGetAction("Airgroup8");
if (action != null)
{
action.Do();
}
GamePlay.gpHUDLogCenter("Wellingtons enroute to St. Inglevert");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}


As you can see there's nothing special ;)

Ataros
09-10-2011, 07:49 PM
Thank you very much for sharing! I hope many new servers which want to be as popular as ATAG can benefit from this to the benefit of CloD community in general.

S!

ATAG_Bliss
09-10-2011, 09:43 PM
No problem Ataros!

Question (maybe for another topic) but how do you have 3 servers all running off of the same machine? We are using about 10% of the power of our machine with only running one server, and we'd like to have 3 different servers up as well.

Thanks,
Bliss

Ataros
09-11-2011, 09:19 AM
No problem Ataros!

Question (maybe for another topic) but how do you have 3 servers all running off of the same machine? We are using about 10% of the power of our machine with only running one server, and we'd like to have 3 different servers up as well.

Thanks,
Bliss

BigRepa, server owner, runs 3 virtual PCs on one hardware using VMWare i believe. There was a screenshot of VMWare settings in Repka thread. Now he switched to desktop OS like Win7 or Vista for compatibility with some missions and the limitation is each OS can use only 2 cores of his 6-core AMD. With server OS there is no such a limitation probably.
Virtual machines are needed because you can not run 3 Steam accounts in one OS at the same time.

I think you can easily run 4 or 6 servers on your hardware. Also have a look at server automation link in my sig to make running several servers easier.

Ze-Jamz
09-11-2011, 12:11 PM
~S~ Bliss

Have you seen the script being wrote for the bailout/Ai/create situation, everyone shooting down AI which is getting irritating?

ATAG_Bliss
09-13-2011, 10:36 PM
BigRepa, server owner, runs 3 virtual PCs on one hardware using VMWare i believe. There was a screenshot of VMWare settings in Repka thread. Now he switched to desktop OS like Win7 or Vista for compatibility with some missions and the limitation is each OS can use only 2 cores of his 6-core AMD. With server OS there is no such a limitation probably.
Virtual machines are needed because you can not run 3 Steam accounts in one OS at the same time.

I think you can easily run 4 or 6 servers on your hardware. Also have a look at server automation link in my sig to make running several servers easier.

Thanks :)

I'll try to see what I can come up with.

~S~ Bliss

Have you seen the script being wrote for the bailout/Ai/create situation, everyone shooting down AI which is getting irritating?

Yeah.. It's a good idea. Hopefully, when I get some time, I'll try to incorporate in.

klem
09-21-2011, 09:05 AM
This mission has a script limiting number of aircraft by type. http://forum.1cpublishing.eu/showthread.php?t=23579&highlight=operation+dynamo
If you make it working please share the final script to add to community knowledge base. I asked several times but never have seen scripts Syndicate or ATAG is running :) C'mon you are nice guys :) Let's make the CloD world better by sharing knowledge.

Thats what I said. We could do with our own Library. Might help those of us struggling to build missions:-

http://forum.1cpublishing.eu/showthread.php?t=26292

Gamekeeper
09-21-2011, 11:41 PM
Thats what I said. We could do with our own Library. Might help those of us struggling to build missions:-

http://forum.1cpublishing.eu/showthread.php?t=26292

My offer to assist and host as mentioned in the above thread is still open. Unfortunately there seems to be little interest so far.

Vyper
09-22-2011, 12:32 AM
My offer to assist and host as mentioned in the above thread is still open. Unfortunately there seems to be little interest so far.

Maybe so far, but I think you have an amazing collection so far Gamekeeper. With time it'll flush out.

klem
09-22-2011, 07:45 AM
My offer to assist and host as mentioned in the above thread is still open. Unfortunately there seems to be little interest so far.

With the greatest respect Gamekeeper and please don't take offence, your website is one example of "scripting examples scattered across this and other forums". No-one coming to the 1C forum for help is going to know its there unless they trawl the forums or hear about it from someone else. It may be just that that discourages peoples interest in contributing to your website.

I just think it would be better if it was all held here at the home of Cliffs of Dover under a clear sub-forum which people would easily recognise when they come here for help.

Of course, what would be better is a GUI that does all this for us, most of us are not coders and those of us with a little experience in similar/other coding are still in the dark over many of the objects, methods etc.. A fundamental point is that the average gamer should be able to create quite sophisticated missions from in-game tools.

Mington
09-22-2011, 11:41 AM
those of us with a little experience in similar/other coding are still in the dark over many of the objects, methods etc.. A fundamental point is that the average gamer should be able to create quite sophisticated missions from in-game tools

Amen klem, we are looking forward to English-localised FMB documentation and maybe Scripting Tutorials where specific examples are discussed in depth in baby steps.

At present we are only seeing the fin of the shark. Colliding with the tip of the iceberg :)

Ming

David198502
09-22-2011, 12:24 PM
+1 to the last two posts.
i would really like to use the FMBs full potential.hell i would be happy if i could use the half of it.
but up till now, im not even able to start flights at different times.
and i really want to avoid to just copy and paste scripts....i want to understand them,..but i really would need step by step instructions for abslolute dummies like me.

FG28_Kodiak
09-22-2011, 12:48 PM
@David198502
You are from vienna, so i think you can speak german.
I've made step by step tutorials in german:
http://forum.sturmovik.de/index.php/board,17.0.html ;)

SNAFU
09-22-2011, 01:27 PM
Gamekeepers AirforceWar.com is in my opinion the best place to gather script-parts. Here in the forum they are simply lost between all the posts and spam.

Ataros` attempt to gather them, is more or less succesful, but on the long run, simply lost. ;)

I consider AirforceWar as the best side, to collect files CoD related, especially FMB related stuff. It just has to be known and used. ;)

Ze-Jamz
09-22-2011, 01:33 PM
Gamekeepers AirforceWar.com is in my opinion the best place to gather script-parts. Here in the forum they are simply lost between all the posts and spam.

Ataros` attempt to gather them, is more or less succesful, but on the long run, simply lost. ;)

I consider AirforceWar as the best side, to collect files CoD related, especially FMB related stuff. It just has to be known and used. ;)

Agreed, too many Spam posts in here, and that happens with pretty much every thread started, Anything like that would just become a pain to read and would be lost imo

Gamekeeper
09-22-2011, 05:43 PM
@David198502
I've made step by step tutorials in german:
http://forum.sturmovik.de/index.php/board,17.0.html ;)

Thanks Kodiak your posts at airwarfare are an example of what we need. I have a google translated copy of your tutorial and will try and rework it in English. Hopefully I will learn something along the way.

I know that in time airwarfare will be considered a primary source for information about the new IL-2 series in the same way that M4T is for IL-2 1946. It just needs a handful of people to help get things going. I experienced the same start with the original IL-2 where everyone was rooted in UBI forums time is the only barrier right now.

klem
09-22-2011, 08:41 PM
Gamekeepers AirforceWar.com is in my opinion the best place to gather script-parts. Here in the forum they are simply lost between all the posts and spam.

Ataros` attempt to gather them, is more or less succesful, but on the long run, simply lost. ;)

I consider AirforceWar as the best side, to collect files CoD related, especially FMB related stuff. It just has to be known and used. ;)

Well, if thats the way it turns out we need a locked sticky in here pointing to it or most people will never find it. This is where most CoD buyers will come to find out about CoD, otherwise AirforceWar.com is really only going to be found by those 'in the know'.

IMHO you'll also have to work out how you are going to invite Library submissions and hopefully Requests** or it may suffer the same problems as in here which is why I suggested heavily moderated Library and Requests threads and a more 'open' Discussion thread.
**hope you're prepared for some pretty dweeby requests, from me at least :)

Still, its nice to know someone is prepared to take on this black hole.

adonys
09-22-2011, 10:12 PM
I do propose something else:

Let's make a mother of all scripts, including everything, and have it as free code on a public svn (google code for example)

The best things to do (while the IL2DCE next beta is in work) is a in-(online)missions code, containing everything needed in a mission (kill tracks for all aircrafts no matter if AI/player(s), the emergency land crew code, radar, etc..),except spawning flights, so that this code could be included in any mission/campaign.

I also think that, as the online(pure multiplayer)/online with AI/AI only (pure singleplayer) barriers are kinda foggy in IL2CoD (which is a good thing), this code should be made to work for all of them

Gamekeeper
09-23-2011, 12:00 AM
Sorry chaps but finding the site will be even harder if the correct name isn't used. Should be airwarfare.com

If there are any concerns about how information will be found consider M4T, airwarfare is following the same development path, just think where we could be in a year or two...

klem
09-23-2011, 12:17 AM
I do propose something else:

Let's make a mother of all scripts, including everything, and have it as free code on a public svn (google code for example)

The best things to do (while the IL2DCE next beta is in work) is a in-(online)missions code, containing everything needed in a mission (kill tracks for all aircrafts no matter if AI/player(s), the emergency land crew code, radar, etc..),except spawning flights, so that this code could be included in any mission/campaign.

I also think that, as the online(pure multiplayer)/online with AI/AI only (pure singleplayer) barriers are kinda foggy in IL2CoD (which is a good thing), this code should be made to work for all of them

That might be a lot to interpret and digest.

I was hoping for a series of example modules, say one per post, titled for what they do. Like "Message players" with several examples including All, Red, Blue or player Group(based on the aircraft/Squadron they selected before flying). How to use the .ogg files to speak to real players or groups of players instead of texting them. How to detect a PlayerKilled with examples of how to delay (in-game deathkick), can he be limited/sent to certain fields/aircraft. "Remove and Create objects/objectives" such as a convoy achieves a TargetPassThrough ('arrived safe') what the code is for removing the convoy, creating a new one somewhere else, launching enemy bomber Groups at it. On enemy bombers detected (a Passthrough?) how to message a 'scramble' and location etc to "AllRed" or "AllGroup" (as selected at base) or even "AllRedsOnGround"(?). A set of examples on how to identify real players/groups would be very useful. How to set objectives and collect successes for starting a new phase of the Battle, perhaps without sub-missions due to the phantom dots bug (can a mission be 'cleaned' and new objectives generated without loading a new map/mission?). How to move players to a new start location when objectives are reached or have them land within X minutes or be removed/destroyed, etc., and be given new assignments for the new objectives. Direct forces to a specific task rather than just advise what's happening and leave it to chance that the players might actually work out what to do.

I suppose what I am trying to achieve is semi-automated objective based missions with some success/failure criteria leading on to a new phase of battle depending on the outcome and the direction of forces rather than players randomly flying on a hit and miss basis trying to find something to attack. Even with 60-80 players the Channel map is quite large and it would be easy to fly around and still not see anyone without positive direction.

Some of these things I have seen in .cs files or been given examples of but when I try to bend them to suit mine I go off track because I don't fully understand the code and may need to 'adjust' it.

Perhaps its too tall an order, I don't know. I wish we had better tools.

klem
09-23-2011, 12:23 AM
Sorry chaps but finding the site will be even harder if the correct name isn't used. Should be airwarfare.com

If there are any concerns about how information will be found consider M4T, airwarfare is following the same development path, just think where we could be in a year or two...

My Bad. Go on, put up a sticky :)

Mington
09-23-2011, 12:26 PM
If information is good it does not matter where it is found, we will find it and pass on the word :)

A worked example may be the best way to start a tutorial for people like me who are interested in scripting (having recognised its power) and who know something about programming generally

We want to create the fire engine and ambulance and emergency equipment at an airfield

We want to detect a damaged plane incoming to land. Using an airfield radius perhaps, and as a damaged plane crosses the radius there is a trigger generated for our emergency vehicles to move from their parked positions to the runway to meet the plane

Not to start moving when a plane crash-lands, but to behave like real-world airfield emergency vehicles - preparing to meet any plane that seems as if it will need emergency vehicles

Now in any mission when any damaged plane crosses the AirfieldEmergency radius, emergency vehicles are sent to near the active runway. Mechanics swarm over the planes repairing re-fuelling and re-arming in future versions :)

Over at SimHQ I am attempting to coax a tutorial from people who have FMB information to share - the best information (for learners) will be found in step-by-little-step tutorials starting from the top

http://simhq.com/forum/ubbthreads.php/topics/3387619/Ambulance_Station_notes_from_t.html#Post3387619

Here's how I would share info if I had any :)

I will make small test-stub scripts, there's a command to display onscreen

GamePlay.gpHUDLogCenter("Hello from Ming's world. Traditionally.");

-and if a trigger worked (here just a timer completing) I print onscreen

GamePlay.gpHUDLogCenter("Yes Ming that worked");

Now we can get feedback simply, just like in the old days :)

This helps enormously, to get a feel for the mission as a program with inputs and outputs - with hard-copy output

A Single mission with four planes, takeoff and land. As the second plane in the flight takes off print 'Second plane in the flight takes off' Wave(bye bye)

As the third plane is on finals print 'Third plane in flight now landing'

It's very difficult to explain to FMB-savvy people how they can help because they are interested in designing applications, while we of the Hood are interested in first-principles FMB - starting from the most basic 'Is It A Plane?' testing-scripts

Ming

klem
09-23-2011, 05:32 PM
If information is good it does not matter where it is found, we will find it and pass on the word :).....................
Over at SimHQ I am attempting to coax a tutorial from people who have FMB information to share - the best information (for learners) will be found in step-by-little-step tutorials starting from the top

http://simhq.com/forum/ubbthreads.php/topics/3387619/Ambulance_Station_notes_from_t.html#Post3387619

.....................
Ming

<sigh>

another example of "scripting examples scattered across this and other forums".

This is exactly what I mean. Everyone has their favourite website. How is anyone, coming to the home forum of CoD, supposed to learn anything if he first has to learn about all of the web based sim community and where/what all their websites might be? And whether there may be answers on them?

I know its well meant but it just doesn't help focus on the issue.
"If information is good it does not matter where it is found, we will find it and pass on the word " Are you really going to trawl even this forum website, pick up on all the questions and answer them somewhere else and post links to those answers? There's no point in trying to assemble a 'library' if its spread across five websites.

Mington
09-23-2011, 06:18 PM
<sigh>

another example of "scripting examples scattered across this and other forums".

Sigh yourself and read more carefully please, you asked for a more central place. Ideas are the central places, we lure them in with challenges :)

Everyone has their favourite website

Yes and SimHQ is the premier site for combat flight-sim fans for many years since CombatSim went commando :)

Are you really going to trawl even this forum website, pick up on all the questions and answer them somewhere else and post links to those answers?

Of course. I don't expect it to be easy going in the early days. We've already done this with RoF and we got there eventually didn't we :)

I know next-to-nothing but I know enough to spot forums where good information is being posted, Kodiak here and FearlessFrog over there. I can spot talent :)

I do not call it trawling that's disrespectful, these are good friendly and informative sites. I call it gathering intel. See cast your bread upon the waters mentioned earlier. I've scattered a breadcrumb trail from here to SimHQ, that'll do for a start what's the rush :)

Ming

klem
09-23-2011, 06:43 PM
<sigh>

another example of "scripting examples scattered across this and other forums".

Sigh yourself and read more carefully please, you asked for a more central place. Ideas are the central places, we lure them in with challenges :)

Everyone has their favourite website

Yes and SimHQ is the premier site for combat flight-sim fans for many years since CombatSim went commando :)

Are you really going to trawl even this forum website, pick up on all the questions and answer them somewhere else and post links to those answers?

Of course. I don't expect it to be easy going in the early days. We've already done this with RoF and we got there eventually didn't we :)

I know next-to-nothing but I know enough to spot forums where good information is being posted, Kodiak here and FearlessFrog over there. I can spot talent :)

I do not call it trawling that's disrespectful, these are good friendly and informative sites. I call it gathering intel. See cast your bread upon the waters mentioned earlier. I've scattered a breadcrumb trail from here to SimHQ, that'll do for a start what's the rush :)

Ming

Ming,

A central place is singular - ONE place not several places.

My point about code being "spread around" is just that. You think SimHQ is the place, Gamekeeper thinks airwarfare.com is the place. We haven't heard from fans of all the other places yet! I happen to think the home of CoD is the place but I'd accept any one place. That calls for agreement, co-operation and leaving the egos at the door when you enter.

By the way Trawling means "go through and search" and is not disrepectful. It doesn't mean Trolling which may be the way you read it.

Ataros
09-23-2011, 08:18 PM
airwarfare.com kindly offers convenient file storage and we can ask the mods to make a sticky with this link.

1C is the most popular site so far with the most developed subsection structure even compared to excellent simhq (which I learned about upcoming original IL-2 beta from btw :) ) and Sukhoi.ru which is my favorite site because the devs post there in Russian sometimes.

We can ask mods to make another subsection for sample scripts in this section. However people will want to discuss them. And people will post their requests for new scripts in that section. And people will ask questions about not working triggers, etc. in that section. Thus that section would eventually duplicate this one.

The most interesting samples are the ones that are included inside the missions and campaigns posted here in the FMB section. For instance most of the functionality mentioned above can be found in the 1st stillborn's mission running on Repka #3 and posted here. The best way to learn is to download all the missions from this section and study how they work from the inside. Many scripts have comments in them.

To make step by step instructions even for basic C# operations/methods usable in CloD would be a full-time job for a small team of programmers because there is literally no borders or limits to what can be done. (Don't you want to fly a recon mission and actually report enemy units pos to your bombers for instance? Or ... etc. etc. etc... ?)

IMO the issue is not lack of samples (there are plenty of them posted here) but the fact that it is not enough to just copy-paste them to make them work. Some basic knowledge of C# in needed. In April-May I asked the devs and C# experts to make a script library myself but after reading naryv's samples (reposted here, you should find all of them) ended up buying the shortest book on the subject I could find called "C# beginners' course" which allows to understand how to make various scripts work together. I highly recommend starting with a similar book or a free Internet course and use it as a dictionary while studying stillborn's, naryv's and all other scripts posted here. Samples or even the FMB manual would not help without understanding C# basics unfortunately. ...and visa versa if you understand C# basics than neither samples nor the manual would be needed, just some help and advice on particular issues which can be easily obtained on these forums.

Blackdog_kt
09-23-2011, 09:27 PM
Ataros is right on the money.

C# is a programming language that many people use to earn a living, it's not a gaming tool. There's no way around it, until someone codes a graphical front-end for the most basic stuff(and even that would be limited to the most commonly used functions) it's going to take investment of personal time and learning how to code to do things.

Mington
09-24-2011, 01:16 AM
To make step by step instructions even for basic C# operations/methods usable in CloD would be a full-time job for a small team of programmers

I'm not sure that you're getting it. The subtle counter-intelligence thing I mean :)

Cards on the table then.

We know that Kodiak can do all this stuff we need to find out about, if we're gentle and coaxing we might get a tutorial, just one person with knowledge and prepared to share can make a big difference

For example many of us have used 3D tutorials to learn 3D work from online tutorials it's our heritage - people in the communities helping others. We worked out how the RoF FMB worked and shared/pooled our knowledge...

http://riseofflight.com/forum/viewtopic.php?f=64&t=348

We don't need a team of professionals, we already have enough savvy people around to create tutorials - look at Vanderstok's RoF FMB-tutorial videos

http://riseofflight.com/forum/viewtopic.php?f=353&t=10145&hilit=vanders+vanderstok

Can everybody please concentrate and allow Kodiak to find out that he is needed and there is an international audience waiting to buy cold beers for him :)

It's not the C# that's the problem, that's simple because all the unknowns are known, we just read a book and Hello World arrange the parts. It's the not-knowing how most of the CoD FMB pieces fit together because we have no documentation. If CoD documentation is going to be RoF all over again then someone needs to ask the wise man for help while trying not to actually grovel :)

We're not wanting to make any conditions or to be too demanding, just chatting on a user forum where the Great Bear is prowling...

Do I make myself clear without belabouring it :)

if you understand C# basics than neither samples nor the manual would be needed, just some help and advice on particular issues which can be easily obtained on these forums

How can I detect that a damaged plane in an RTB-ing four-flight is inbound to the airfield to possibly make a crash landing?

Detect the plane passing some distance-radius from the runway let's focus on that

I'm taking you at your word as I know enough about C# to type in the solution. When you've found it and I quote easily :)

We don't know "It's what we don't know we don't know..." exactly what we need to know to master the CoD FMB but - don't ask, don't get. But on the other hand we must always be making concrete cases and asking for worked examples to make life easier for our tutors, focus.

Being Russian or German first-language is of course making distribution of information difficult for us all in the beginning, we must encourage our German and Russian friends to help English-localise posted German and Russian FMB tutorials. They're ahead of the game and why not :)

Ming

Ataros
09-24-2011, 09:32 AM
How can I detect that a damaged plane in an RTB-ing four-flight is inbound to the airfield to possibly make a crash landing?

Detect the plane passing some distance-radius from the runway let's focus on that


Here is list of methods published here before which are quite self-explanatory (more methods were added in recent beta patch)

protected AMission ()
public virtual void Init (maddox.game.ABattle battle, int missionNumber)
public virtual void Inited ()
public virtual bool IsMissionListener (int missionNumber)
public virtual void OnActorCreated (int missionNumber, string shortName, maddox.game.world.AiActor actor)
public virtual void OnActorDamaged (int missionNumber, string shortName, maddox.game.world.AiActor actor, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
public virtual void OnActorDead (int missionNumber, string shortName, maddox.game.world.AiActor actor, System.Collections.Generic.List <DamagerScore> damages)
public virtual void OnActorDestroyed (int missionNumber, string shortName, maddox.game.world.AiActor actor)
public virtual void OnActorTaskCompleted (int missionNumber, string shortName, maddox.game.world.AiActor actor)
public virtual void OnAiAirNewEnemy (maddox.game.world.AiAirEnemyElement element, int army)
public virtual void OnAircraftCrashLanded (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft)
public virtual void OnAircraftCutLimb (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.LimbNames limbName)
public virtual void OnAircraftDamaged (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiDamageInitiator initiator, part.NamedDamageTypes damageType)
public virtual void OnAircraftKilled (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft)
public virtual void OnAircraftLanded (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft)
public virtual void OnAircraftLimbDamaged (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft, maddox.game.world.AiLimbDamage limbDamage)
public virtual void OnAircraftTookOff (int missionNumber, string shortName, maddox.game.world.AiAircraft aircraft)
public virtual void OnAutopilotOff (maddox.game.world.AiActor actor, int placeIndex)
public virtual void OnAutopilotOn (maddox.game.world.AiActor actor, int placeIndex)
public virtual void OnBattleInit ()
public virtual void OnBattleStarted ()
public virtual void OnBattleStoped ()
public virtual void OnCarter (maddox.game.world.AiActor actor, int placeIndex)
public virtual void OnMissionLoaded (int missionNumber)
public virtual void OnPersonHealth (maddox.game.world.AiPerson person, maddox.game.world.AiDamageInitiator initiator, float deltaHealth)
public virtual void OnPersonMoved (maddox.game.world.AiPerson person, maddox.game.world.AiActor fromCart, int fromPlaceIndex)
public virtual void OnPersonParachuteFailed (maddox.game.world.AiPerson person)
public virtual void OnPersonParachuteLanded (maddox.game.world.AiPerson person)
public virtual void OnPlaceEnter (maddox.game.Player player, maddox.game.world.AiActor actor, int placeIndex)
public virtual void OnPlaceLeave (maddox.game.Player player, maddox.game.world.AiActor actor, int placeIndex)
public virtual void OnPlayerArmy (maddox.game.Player player, int army)
public virtual void OnPlayerConnected (maddox.game.Player player)
public virtual void OnPlayerDisconnected (maddox.game.Player player, string diagnostic)
public virtual void OnSingleBattleSuccess (bool success)
public virtual void OnTickGame ()
public virtual void OnTickReal ()
public virtual void OnTrigger (int missionNumber, string shortName, bool active)
public virtual void Timeout (double sec, maddox.game.DoTimeout doTimeout)

public maddox.game.ABattle Battle {get;}
public maddox.game.IGamePlay GamePlay {get;}
public int MissionNumber {get;}
public int MissionNumberListener {set; get;}
public maddox.game.world.ITime Time {get;}

Not being a C# expert but just having read 80% of samples posted here I guess you can use OnAircraftDamaged and OnAircraftLimbDamaged and OnAircraftCutLimb to start calculating distance from the damaged aircraft to the closest airfield. Then you can generate a new landing waypoint for the damaged group at this airfield. There is a "distance" function used in naryv examples and in vetochka campaign. Waypoint generation is also used in naryv examples. When the distance is appropriate you let an ambulance to start its way to a runway.

Another way is to use onTrigger method with really big trigger radius around an airfield and check what aircraft parts are damaged. There was a sample script posted in the main section that prints out damaged parts to a chat window. Therefore I guess it is possible to do this.

The 3rd alternative could be to combine both of the above ways and flag a damaged group OnAircraftDamaged and then onTrigger check if the incoming group is flagged as damaged. Again I do not know C# and can be wrong. It is better to start a new thread with these particular questions where real experts will offer their solutions.

hc_wolf combined several naryv examples and others' scripts into one mission. You can have a look at how he did this and do the same if you know C#. If no one can answer questions on this forums you can ask naryv directly as adonys did in this thread http://www.sukhoi.ru/forum/showthread.php?t=68629&page=9&p=1647624&viewfull=1#post1647624
Sometimes naryv does not answer if the functionality requested is not ready yet or does not work properly or is changing at the moment. All script methods are WIP I think ATM.

We will not see the manual till engine functionality and script methods are 90% finalized imho because there is no point to spend time on a manual that will not be valid in 2 months. I expect it to come with Battle for Moscow at the earliest. But again if you know C# you can find all necessary information on this forums in naryv, adonys, Kodiak, Wolf, TheEnlightenedFlorist, vetochka, stillborn, etc. examples.

Scripting discussion was started 5 months ago in this thread (Yes, I know it is hard for the first 6-8 weeks till you learn some basics :) ) http://forum.1cpublishing.eu/showthread.php?t=21518
Many of my noob's questions were answered there by С# programmers. Again this forum section has more then enough information to start programming for CloD if you know C# basics at least. Guys and a lady mentioned above have proved it many times already. This forum section is only 9 pages long not too much to look though to get all the information needed to be able do the same imho.

ps. Of cause I would be more than happy if Kodiak or other C# programmers agree to publish some tutorials but for me it is not clear if the tutorials should be about C# basics or about CloD methods and functions.

klem
09-24-2011, 10:12 AM
Ataros is right on the money.

C# is a programming language that many people use to earn a living, it's not a gaming tool. There's no way around it, until someone codes a graphical front-end for the most basic stuff(and even that would be limited to the most commonly used functions) it's going to take investment of personal time and learning how to code to do things.

Blackdog_kt, I think Ming's post that follows yours sums it up quite well.

I am familiar with the basic principles of coding even though it is from years of Visual Basic and VBS not C#.

We can see from the .cs files that they are fundamentally modular leading to the possibility of module examples in response to requests and other examples simply posted by people who have already developed them. Yes, that calls for the patience and good will of the knowledgeable guys who would essentially be filling a void left in the game application. What I had hoped for was a bank of these modules with a basic very brief explanation of their purpose so that we could interpret, learn to understand and use. Studying existing modules is one way but is long and laborious as you first have find one that may contain what you want, understand what the script module is trying to do and you still may not find what you are looking for.

There are many methods and objects etc created in the Maddox game that are unknown to many of us. Some are confusing such as 'Actor' meaning Aircraft (as far as I can make out) not 'Player'. Some of our 1C friends know these and are in a position to help and advise. I spent a lot of time in my career teaching people various subjects at various levels from electronic maintenance to business management. One of the dangers of those doing the teaching, or presenting examples/guides, is that they see things from 'the inside looking out' instead of where their pupils are, 'on the outside looking in' and often into a dark black box of a world they just don't know about yet. We tend to assume that if we are familiar with a concept or a detail which is so basic to us, we take it for granted that our 'pupils' will already have that knowledge. So jargon, assumed knowledge etc lead to a gulf between what is being presented and what is being received. Some my my maintenance pupils didn't need to be electronics experts to understand and fault find modular equipment on an oil rig in the middle of the Gulf, they just needed to know how to piece information and blocks together to fix and get something working. We don't all need to be top-level C# programmers for CoD, we do need to understand basic principles (which can be read up or learned) and then have the support of those around us on the Maddox game-specific aspects and how they are used.

My hope was to open up the Maddox coding world to semi-laymen like myself. It may not reach all players but I think it would open up mission coding for quite a few.

Of course I could study C# in great depth, then find and study all the aspects of the Maddox game but frankly I'm not willing to spend that much time on it. If the FMB didn't give us a graphical means of creating very basic missions I wouldn't be bothering with making them as I'd no doubt have to study even more. Its not that I want an easy path, just an easier path than we have at the moment. No, wait, I do want an easy path, I didn't buy this game to have to study programming in order to use it! I wonder what level the SDK will be pitched at, whether there will be graphical interfaces and whether it will be for maps, for aircraft or even mission building. Lets face it, these things will fall on a very few shoulders if its all bare coding and will deny the rest of us those opportunities which I see as a fundamental part of what I have bought.

Anyway, a 1C-forum coding library isn't going to happen. Getting people to agree on a single solution is harder than learning C#. I guess I am just over-optimistic, after all if I wasn't I'd have dumped CoD and followed the majority of my Squadmates who have given up on CoD and bogged off into RoF.

Ataros
09-24-2011, 10:36 AM
What I had hoped for was a bank of these modules with a basic very brief explanation of their purpose so that we could interpret, learn to understand and use. Studying existing modules is one way but is long and laborious as you first have find one that may contain what you want, understand what the script module is trying to do and you still may not find what you are looking for.

I was as frustrated as you are when I tried to make a mission for Repka #1 back in April. It was even worse because there were no examples available.

Now there are plenty of examples and missions posted in this section. Of cause it is not easy to find them if you did not follow the discussion from April. It takes time, weeks and months, to learn something new.

If you tell what modules you would like to use in your mission I will try to tell you in which threads/examples they are available.

It is better to start a new thread for each new module you need. Kodiak and other people knowing C# are very helpful and helped me a lot even back in April not having any manual (they just looked up lists of methods, etc. from .dll files in Visual Studio):
Visual Studio will let you see all of the methods in roundabout way. Try this:

1. File >> New >> Project Type in a name and solution name at the bottom. Don't worry about what kind of project you create.

2. On the right side under "Solution Explorer", right click on "References", "Add Reference..."

3. Click on the "Browse" tab, navigate to "Steam/steamapps/common/il-2 sturmovik cliffs of dover/parts/core"

4. Go through each .dll file in that list and try to add it. Some will give you an error, just skip those.

After you've added all the .dll files, right click on the name of your project and do "Add Existing Item". Find one of your script files and add it. Now Visual Studio will show you all the possible methods as you're typing your code. You can also go to View >> Object Browser and have a look in there.

Important: When you import an existing item, Visual Studio makes a copy of the file so any changes you make won't be reflected in the original file, you'll have to copy the new one over it. If anybody knows how to change this, I'd be quite grateful.

Sorry, do not remember who posted this :( This shows that for people who know C# it is really easy to learn everything needed from game dll-s themselves.

Ataros
09-24-2011, 10:59 AM
Please find my script library attached. It includes script collections from this forum section sorted by topic as well as some mission examples.

Please feel free to ask questions on particular scripts but it is better to start new threads for each topic.

Not all scripts are working and 100% correct. I am not a C# expert and will not be able to answer all questions but others who helped me with writing scripts will help I am sure.

Mington
09-24-2011, 12:42 PM
Lovely to see things looking up :)

How to construct an AirfieldEmergency script from first principles while explaining the steps, that's what I'd like to see. A concrete example with commentary that's fairly simple (if the detecting of the damaged plane crossing the AlarmRadius can be done)

There's almost 800 references to Maddox functions, classes, methods and wotnot so I'm imagining that it's on

There's the introductory part to a script, where databases of functions, subroutines (BASIC/Visual Basic) we will need access to in the running script, these might be-

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

The script then begins and it's at this point that we pupils need statements commented please. We can figure out what each line of code means but it's like examining atoms without knowing about the Table of Elements. We can see that they're all different and they all must mean something, there must be some rhyme to it, we are not idiots :)

'We need this line to see if any planes are already in the mission' (the mission designer created an unknown number of planes)

'We need this line to step through each plane to see if it is damaged' (all planes in all running missions can be checked)

'This line instantiates/spawns a plane/vehicle at this XYZ position' (if the position is clear)

This scripter's commentary gives us a chance to ask the scriptwriter a sensible question... it's very difficult to ask sensible questions without a handle to hang the question on. For example how can you tell if a possible spawning position is clear of obstructions. But that's another story probably :)

Ming

Mington
09-24-2011, 01:07 PM
Wow thanks very much for your collection Ataros!

It is better to start a new thread for each new module you need

Wiil do, thanks

they just looked [FMB stuff] up

Kodiak works/worked for Maddox perhaps - this is a compliment btw. He/she definitely knows his stuff. Let's face it somebody has to :)

onTrigger method with really big trigger radius around an airfield

A trigger radius hmm - thanks :) (I'll see if I can trigger a message 'We see your plane incoming, it looks damaged...' to 'Crossed the airfield EmergencyAlertRadius')

Thinking out loud then- two airfields say Croydon and Biggin Hill and my single plane taking off at one airfield. Testing the other airfield's EmergencyAlert (procedure) - with a simple onscreen message if my plane trips the second airfield's trigger. Baby steps.

Adding the trigger in a script rather than via the FMB, to make it universal. Does the FMB write trigger code into the dot cs I wonder. I know that airfields have one radius and then another radius

Ming

Ataros
09-24-2011, 01:24 PM
Adding the trigger in a script rather than via the FMB, to make it universal. Does the FMB write trigger code into the dot cs I wonder. I know that airfields have one radius and then another radius



Trigger has its own radius. It is set in FMB and is stored in a mission file, not in script file.

According to the devs to make FMB triggers work together with any script you can add this code to script. Action and trigger must have the same name in this case.

public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);
AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
if (action != null)
action.Do();
}


There are other more advanced and complex possibilities. Check out the _Triggers and actions folder in my archive or search forums for trigger script.

ps. BTW are you one of simhq admins by chance? I have trouble registering at simhq forums somehow. Same nickname.

Mington
09-25-2011, 12:39 PM
Very nice thanks Ataros!

Trigger has its own radius. It is set in FMB and is stored in a mission file, not in script file

I am trying to think universally, where scripts are independent of missions, so setting the radius in the FMB (while working perfectly yes) is not what I'm after

An airfield built by construction engineers (looking forward to D-Day) would not have a radius but it would be an Airfield object and a script could (hopefully) read and return the AirfieldEmergency distance. That could be a constant couple of miles perhaps and would apply to all airfields, permanent or temporary. We often create small airfields fairly close together for multiplayer dogfights - created in Il-2 I mean

Thanks for that info mate, no I'm not an admin over there but I will advise admin Dart that you're having problems and get back to you

Ming

Ataros
09-25-2011, 09:51 PM
In this example naryv creates a mission file by script. http://forum.1cpublishing.eu/showthread.php?t=23493

The file is called triggersFile. Actually it is a "section" file, i.e. a segment of a mission file.
public ISectionFile triggersFile

Then script writes triggers into this file at the locations of frontline markers placed in the original mission manually.

keyTr = "changeArmy" + i.ToString()+"_1"; // попутно на маркере делаем два триггера - для каждой стороны
valueTr = " TPassThrough 3 1 " + strs[0] + " " + strs[1] + " 500"; // "TPassThrough 3" - триггер сработает при заезде в него наземки, "1" красной, strs[0] + " " + strs[1] координаты, "500"- радиус триггера
triggersFile.add(sectionTr, keyTr, valueTr); // сохраняем триггер в файле триггерной миссии
keyTr = "changeArmy" + i.ToString() + "_2"; // то же самое для синей стороны
valueTr = " TPassThrough 3 2 " + strs[0] + " " + strs[1] + " 500";
triggersFile.add(sectionTr, keyTr, valueTr); // сохраняем триггер в файле триггерной миссии

500 - is radius of the trigger

Mington
09-26-2011, 01:00 PM
Thanks Ataros, hugely interesting

The clue that 500 is the radius no wait it's a radius- is that an airfield radius I wonder?

There are two radii for each airfield

This is a command to assemble a string, can you decode the string please? Something like-

TPassThrough

Ahah :) pass through, passes through, crosses a radius...

Decoding, building a string-

TPassThrough 3 1

strs[0] (red or blue maybe, 'red' from Babelfish)

strs[1] appears to be a 'coordinate' from Babelfish

-it gets quite complicated eg-

double y; double.TryParse( strs[1], out y);

500

Maybe the whole assembled string is a coordinate somewhere on the map, with a radius around the coordinate of 500m

Yes that sounds reasonable, if we can now work out a test value for the cryptic strs[1]

valueTr = " TPassThrough 3 1 " + strs[0] + " " + strs[1] + " 500";

Maybe the TPassThrough trigger is documented somewhere, I'll see what I can find, the mysterious (without C# string-operation knowledge) coordinate bit is interesting

'TPassThrough: gets active' - does this mean that some Boolean variable is set to True or False? How to link to the emergency ambulance method I wonder, If NoBellsAreRinging CarryOn = True :)

Working left for inspection :)

Ming

TPassThrough: gets active after a GroundGroup or Airgroup or Player entering the Area

http://forum.1cpublishing.eu/showthread.php?p=339413#post339413

Ataros
09-26-2011, 02:54 PM
500 is trigger radius, not airfield.

TPassThrough 3 - is type of trigger, 3 is for ground units pass through.

1 or 2 is army (red/blue)

For airgroup passthrough the type of trigger will be different iirc. If you place various triggers in FMB and then save and open the mission file in notepad you will see how different triggers are recorded into a mission file: name of trigger type of trigger side coordinates radius. E.g.
[Trigger]
110_down TGroupDestroyed BoB_LW_LG2_I.01 49
bauf_down TGroupDestroyed BoB_RAF_F_FatCat_Early.01 46
blu_bomb1 TPassThrough 1 BoB_RAF_B_218Sqn.07 275948 207553 2800
bauf_up TPassThrough 3 1 271200 153942 300
110_up TPassThrough 3 1 269976 153045 300
red_bomb1 TPassThrough 3 1 270836 152088 300


strs[0] + " " + strs[1] - coordinates of the frontline marker parsed from the main mission file earlier.


Then script writes triggers into this file at the locations of frontline markers placed in the original mission manually.

Then in onTrigger method you check if the trigger is active, e.g.
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("your_trigger_name".Equals(shortName) && active)
{
// optional if you have an action set in the mission file
AiAction action = GamePlay.gpGetAction("your_action_name");
if (action != null)
{
action.Do();
}
// include other operations here, e.g. loading submissions
GamePlay.gpHUDLogCenter("your onscreen message");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}

David198502
09-26-2011, 03:21 PM
@David198502
You are from vienna, so i think you can speak german.
I've made step by step tutorials in german:
http://forum.sturmovik.de/index.php/board,17.0.html ;)

ja ich sprech Deutsch.hey danke! werd mir mal das genauer anschauen!!
Edit: sehr gute Artikel hast du da zusammengestellt!und das schöne daran, sie sind wirklich stepbystep Instruktionen die jeder verstehen kann!danke nochmals!!!

Mington
09-26-2011, 06:41 PM
red_bomb1 TPassThrough 3 1 270836 152088 300

Very good thanks Ataros!

To Ming-parse then:-

If a Red bomber crosses a radius of 300m from a point X = 270836, Y = 152088
Then a trigger is generated

So str[0] and str[1] are XY coordinates?

Ahah yes they are, I tested this by dropping numbers in from known object positions and that looks good

TPassThrough 3 - is type of trigger, 3 is for ground units pass through.

1 or 2 is army (red/blue)

Ground unit red = 3 1
Ground unit blue = 3 2

Is that ok?

I will need to find out the first TPassThrough parameter, I can't see TPassThrough in the dlls

Ataros please is it possible for you to build a small test script with a simple "Plane crossed radius" message when triggered?

This now is where we (learners) all run into problems, we can see what needs to be done but it is at the end of a long lonely corridor :)

The usual links to the needed dlls then and the script begins, I will already be in flight some miles from the trigger zone at Biggin Hill for this test, I will be in a Single mission with an airstart, I will be in an RAF SPitfire

I will not be using a Trigger built in the FMB, not to complicate things with simpler ways :) (for bolting-on universal use later) - I will get Biggin's coordinates for the needed str[0] and str[1]

First call could be 'Are there any planes in the mission?' and the first message could be the type of plane I am flying

(That will be useful for people to play with, by modifying for 'Are there any trains...' '...ships in the mission' and so on, for a toe-in-the-water)

If there are planes in the mission, set up the test-trigger radius and get the message ready

This is the tricky bit Mayday Mayday :)

If you are busy, no worries and thanks again for the great info

Ming

Ataros
09-26-2011, 08:09 PM
red_bomb1 - is just a name I gave to my trigger in FMB. It is not related to bombers, it can be any name.

Ground unit red = 3 1
Ground unit blue = 3 2
Is that ok?

Sorry, I do not remember, maybe it is army pass through. Try setting a desired trigger in FMB and then open mis file in notepad to see how to name the trigger correctly.

I do not know C# syntax and grammar good enough to write scripts myself. I can only read and copy-paste them and advise where you can find appropriate examples.

If you paste the below code into a script and make an "army passthrough" trigger in FMB called "incoming" (no quotes) at desired location, the script would print a message for you.

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

if ("incoming".Equals(shortName) && active)
{

// include other operations here, e.g. loading submissions with ambulance, etc.
GamePlay.gpHUDLogCenter("Airgroup incoming");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}

If you want to generate triggers via script you should study all naryv's examples more carefully as this way needs some advanced knowledge of C# which I do not have to the degree allowing to reproduce the script for a different mission. You as a C# programmer should better understand this deep-level programming (e.g. dynamic segment file generation, string operations, etc). For me it is really advanced stuff that I can only understand 70% at best but not to reproduce.

Try studying this improved version of naryv's mission http://forum.1cpublishing.eu/showpost.php?p=307600&postcount=9 My description explains what the script does.

hc_wolf's missions based on these examples has comments in English. I think he learned how they work very well and can provide some help as well. His recent mission was posted in the main section yesterday http://forum.1cpublishing.eu/showthread.php?t=26464

upd. Looks like
Ships "TPassThrough 4"
Ground "TPassThrough 3"
Army "TPassThrough 2"

Mington
09-27-2011, 01:37 PM
Thank you very much Ataros, much appreciated mate

I only know Basic and assembly language :) but we only need to know enough of C# to build scripts, we're using a very small subset of C# because we are running code in some sort of C# emulator. Maddox takes care of all the really difficult stuff thank goodness or there would be error-crashes galore

Doing the practical work you have set me :) - I realise that I have done no work on FMB triggers (as opposed to scripting triggers) and I must get your example to work... thanks again, the FMB panel of triggers/actions etc looks very interesting

Ming

Ataros
09-27-2011, 02:02 PM
I think Basic is not object-oriented. If this is the case make sure to read a couple of very short articles about classes
here http://www.aspfree.com/c/a/C-Sharp/C-Sharp-Classes-Explained/
or here http://www.csharp-station.com/Tutorials/Lesson07.aspx#
or http://csharp.net-tutorials.com/classes/introduction/

It helped me to understand C# scripts a lot.

klem
09-27-2011, 05:55 PM
I was as frustrated as you are when I tried to make a mission for Repka #1 back in April. It was even worse because there were no examples available.

Now there are plenty of examples and missions posted in this section. Of cause it is not easy to find them if you did not follow the discussion from April. It takes time, weeks and months, to learn something new.

If you tell what modules you would like to use in your mission I will try to tell you in which threads/examples they are available.

It is better to start a new thread for each new module you need. Kodiak and other people knowing C# are very helpful and helped me a lot even back in April not having any manual (they just looked up lists of methods, etc. from .dll files in Visual Studio):

(Quoted.....)

Sorry, do not remember who posted this :( This shows that for people who know C# it is really easy to learn everything needed from game dll-s themselves.

Hi Ataros

many thanks for the piece on Visual Studio. I have it now and been looking at the methods etc. It is starting to make some sense but I am still grappling with it.

I have succeeded in one test module to determine the sector I am in and report it to myself, just a test to help me get to grips with how it all goes together. Now working on SayToGroup which Kodiak put me on to as I'd like to avoid those banner messages if I can.

Anyway, still early days but thanks and special thanks for that library zip.

Mington
09-27-2011, 06:56 PM
many thanks for the piece on Visual Studio

Yes thanks Ataros, that's very useful

I have succeeded in one test module to determine the sector I am in and report it to myself

Nice one, and any code you're working on would be valuable for inspection klem, this sounds the way to go, to get feedback from small test sections, what plane we're in, small steps

I wonder if the 'get' command/method can be used to get at variables and display info

http://msdn.microsoft.com/en-us/library/w86s7x04(v=vs.80).aspx

C# is a bit flash. For example get is an 'accessor' apparently. Who writes this stuff :)

When you reference the property, except as the target of an assignment, the get accessor is invoked to read the value of the property

That's what we're after for testing, ways to get and set properties. Or variables as we used to call them <runs away> :)

Ming

FG28_Kodiak
09-27-2011, 07:42 PM
simply said get; and set; are short versions for class design.

example:

public class test()
{
public string Name {get; set;}
}

so you can use:
test newobject = new test();

newobject.Name = "test1"; // this is the set
string test2 = newobject.Name; // this is the get


the long version

public class test()
{
private string name;

public void SetName (string newname)
{
name = newname;
}

public string GetName ()
{
return name;
}
}
so you must use:
test newobject = new test();

newobject.SetName("test1");
string test2 = newobject.GetName();

only a simple example.

Mington
09-27-2011, 08:23 PM
Thanks Kodiak!

Kodiak can you tell us how to get at variables in the maddox dlls please?

I use pseudo-code to give an example-

I imagine something like Airfield.FlakCannon.Temperature

Airfield.FlakCannon.Temperature is a variable and it is 200 (Centigrade)

If Airfield.FlakCannon.Temperature > 199 Then-

HoseDownCannon()

This means- if an airfield flak cannon is getting hot, pour cold water on to the barrel

Can we use get to return the temperature of the flak cannon barrel? Can we use get to return values of variables deep inside the Maddox dlls in running missions?


Coincidentally Kodiak - I am coming here now to say that I have my Hello World thanks to you :)

And now I can see a trigger working, and I understand that everything will work. I think I am in love with Maddox team :)

For FMB-nuts

For the script code-

using System;
using maddox.game;
using maddox.game.world;

public class Mission : maddox.game.AMission
{
public override void OnTrigger(int missionNumber, string shortName, bool active)
{
base.OnTrigger(missionNumber, shortName, active);

if ("CrossLake".Equals(shortName) && active)
{
GamePlay.gpHUDLogCenter("Now crossing the lake");
GamePlay.gpGetTrigger(shortName).Enable = false;
}
}
}

This above is Kodiak's code with an identifiable (to me) object to get near, the lake north of Sandwich on the 1940 map. Nothing is happening but if you make small stubs like this you can see things like-

For at least singleplayer missions, missionNumber and shortName do not need to be known... I look at variables and wonder where they are, but for testing purposes some things can remain unknown
____________________________

For the mission text after including Kodiak's script and setting the trigger-

[PARTS]
core.100
bob.100
[MAIN]
MAP Land$English_Channel_1940
BattleArea 150000 100000 100000 150000 1000
TIME 12
WeatherIndex 0
CloudsHeight 1000
BreezeActivity 10
ThermalActivity 10
player BoB_RAF_F_19Sqn_Early.000
[GlobalWind_0]
Power 3.000 0.000 0.000
BottomBound 0.00
TopBound 1500.00
GustPower 5
GustAngle 45
[splines]
[AirGroups]
BoB_RAF_F_19Sqn_Early.01
[BoB_RAF_F_19Sqn_Early.01]
Flight0 1
Class Aircraft.SpitfireMkI
Formation VIC3
CallSign 31
Fuel 100
Weapons 1
Scramble 1
Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[BoB_RAF_F_19Sqn_Early.01_Way]
NORMFLY 248451.23 259151.63 500.00 300.00
NORMFLY 246594.30 247927.34 1000.00 300.00
[CustomChiefs]
[Stationary]
[Buildings]
[BuildingsLinks]
[Trigger]
CrossLake TPassThrough 0 247385 252352 1900
________________________________

Observe dear learner-comrade that making an entry in the Edit/script/Triggers code-box creates the [Trigger] entry at the end there ^. The trigger is your Player plane crossing the radius around the lake

For the universal AirfieldEmergency script version, all airfields in the mission must be known, and all must have a detection-radius

Sometimes we RTB, but sometimes we need to land at an Alternate airfield. Sometimes we do not know what airfield we must land at - we only care that we can land our plane and maybe stay alive too

To be more efficient we do not need to cover all airfields, we can emergency-cover airfields in the immediate area - not the area west of London when we are defending ships in the Channel area for example

In Il-2 online campaigns (SEOW) we often land damaged at the nearest airfield and we pray it's a friendly airfield. Imagine if fire engines had come out to meet us. But wait- imagine if it's an enemy airfield and flak-defence spawns... :)

Ming

Ataros
09-27-2011, 08:48 PM
many thanks for the piece on Visual Studio

Yes thanks Ataros, that's very useful

We should thank TheEnlightenedFlorist actually :) http://forum.1cpublishing.eu/showpost.php?p=288472&postcount=164

ps. Updated my collection. Hope it is more readable now. http://forum.1cpublishing.eu/showthread.php?t=26523

klem
09-27-2011, 10:59 PM
....................

I have succeeded in one test module to determine the sector I am in and report it to myself

Nice one, and any code you're working on would be valuable for inspection klem, this ..................

Ming

ok at the risk of being the blind leading the blind (I'm sure Ataros/Kodiak will shout if I am)....

I wanted to find out what sector a Tanker group is in (when I say 'group' I can't find a way to identify a few tankers as a Group, they are just a group to me because thay travel together waiting to be sunk or arrive at their destination). Now, bear in mind I'm new to all this and I'm feeling my way forward with my fingers so there may be better ways of doing it but if any of my Tanker group arrives in a certain "destination" sector it has "arived safely". I want to announce that but I also wanted to call up the grid it is in and Remove all objects in that sector as they are no longer relevant. Of course I know what that sector is but coding actual data like sector numbers into a module is anathema to me so I want the code to find out so that I can re-use the module whenever I like. I haven't got this far yet, I have only just worked out how to use GamePlay.gpSectorName(actor.Pos().x, actor.Pos().y).ToString() :surprise:
For testing I set it in the context of the player entering the cockpit and being told where he is:

public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);
AiAircraft aircraft = actor as AiAircraft;
string sectors = "";
sectors += ' ' + GamePlay.gpSectorName(actor.Pos().x, actor.Pos().y).ToString() + ";";
GamePlay.gpHUDLogCenter(new Player[] { player }, "You are in Sector " + sectors);
}

So now I have to find out how to 'group' the Tankers or maybe work through all Tankers for those in the sector and then how to remove them.

The big plan is to create a mission that runs for a long time, measuring objectives (Tankers home safe or not etc) then start a new phase of the battle without loading a sub-mission (sub-missions cause the phantom dots problem), just send the pilots to rtb within a certain timeframe (or be destroyed), clear all old objects, create new ones and carry on from there.

Its a big project and probably causing the mission experts to wince but its all good learning stuff and if it nevers comes to fruition at least I'll have had an interesting time.

Mington
09-28-2011, 01:09 PM
For testing I set it in the context of the player entering the cockpit and being told where he is

Good work klem that works first time :)

It's amazing that one can simply add your routine to my original lake-trigger and both my trigger and your location-indicator work without problems. I'd have bet that something would go wrong

You've got 'sectors' so I imagine that you can create a 1940 War Room map table one day, with the Toblerone bars and the pretty WAAFs :)

A group of oilers, are you thinking of Malta <dreaming, more 'one day, one day' stuff> - I'm not sure that they'd figured out efficient convoys in 1940. Oh U-Boats yes and rendezvous for re-fuelling. We're sending in the Sunderlands :) (just chatting, not entirely serious)

Ming

SNAFU
09-28-2011, 01:55 PM
Nice script lines, Klem. Very usefull, while mission testing. Could also be used for OnPilotBailedOut to direct SAR operations to the pilot. ;)

(sub-missions cause the phantom dots problem),

How do you know that? I also have experienced phatoms, while simply testing missions. In observation, this is a lag problem, because only objects are rendered in your viewing distance (you can see this while switching through external view, that only the objects are rendered, which are somewhat close to you). At some point the game stopped rendering an object, because a player left or got out of sight. Another player gets in range of the drawing distance of the object and the game starts calculating the new position of the object, but lost it somewhere, because of high work load in the net transmission. I think that is hard to explain for me, but easily observed with AI travelling tankers. Put enough of them in a group and start out of sight, get close to them and they will appear as ghostships, fist the dot, then grwoing but then suddenly gone and only the smoke of the funnel is still there.

PS: I think Blis removed all submissions from ATAG Server and only loads AI via CMD - and he still has the Ghost-Syndrom on the server.

klem
09-28-2011, 08:36 PM
Nice script lines, Klem. Very usefull, while mission testing. Could also be used for OnPilotBailedOut to direct SAR operations to the pilot. ;)



How do you know that? I also have experienced phatoms, while simply testing missions. In observation, this is a lag problem, because only objects are rendered in your viewing distance (you can see this while switching through external view, that only the objects are rendered, which are somewhat close to you). At some point the game stopped rendering an object, because a player left or got out of sight. Another player gets in range of the drawing distance of the object and the game starts calculating the new position of the object, but lost it somewhere, because of high work load in the net transmission. I think that is hard to explain for me, but easily observed with AI travelling tankers. Put enough of them in a group and start out of sight, get close to them and they will appear as ghostships, fist the dot, then grwoing but then suddenly gone and only the smoke of the funnel is still there.

PS: I think Blis removed all submissions from ATAG Server and only loads AI via CMD - and he still has the Ghost-Syndrom on the server.

Fair comment SNAFU. I was told that by someone several weeks ago (was it one of the ATAG guys? Can't remember). It could be wrong. Anyway they are still around :(

We seem to be short of objective-based missions and my main idea was to have a rolling battle without stopping/loading missions but 'clean out' and 'create new' objectives. I know its a tall order especially for someone who doesn't know how to do all that yet. Lets just call it 'optimistic vision' ;) The general idea is a 'phase' of say 3 hours during which perhaps convoys try to reach objectives (sector x,y). The phase ends when either all/75%(?) convoys have been sunk or have reached their destination sector = win/lose for one side or other or a stalemate at mission timeout. Includes say a 10 minute end period for all players to rtb or be destroyed, followed by a period of cleanout/rebuild while they wait in the briefing room and then a call to re-enter the mission. A 'new day' if you like. Could be a couple of phases of convoys then a couple on coastal airfields/radar then on inland airfields then London all with 'countable' objectives. Victory would go to the LW if they achieved enough objectives or to the RAF if during the whole Battle they prevented the LW from achiewvinbg their goals. Of course if the LW succeed/fail at a phase it calls for different next-phase objectives. I am assuming different .cs scripts can be 'called' depending on results or just a massive multi-branch script.

OK so I am still at the bottom of the ladder, perhaps dreaming and it would need a lot of help but... just maybe....

...and of course, if it can't work, I know ATAG have found a way to automate mission changeovers by loading new missions. I think they could add the 10 minute rtb period though :)

SNAFU
09-28-2011, 09:22 PM
I hear you klem. I started with the same idea more or less. But I also wanted to rebuild history as far as possible.

But then I hit the reality and the limitation of performance. If you want to have it all on one map at the same time, the loading time raises immense. I for example put on every historically used airfield of a single given day of July AA emplacements, AA and tents and added a tower. Loading time was ok, as long as there is no plane on the map. But as soon as you have objects and planes, it took 20 minutes to connect to the server. I started with 16.000 objects I ended up with 1.200 objcts and now I have connecting times below 20 sec if there are less than 16 planes in the air, and 4 minutes as soon as I have 36 planes in the air, which is ridicoulus for rebuilding something which should simulate the battles of August, well, for July it is somewhat ok. :rolleyes:

We now have 11 objective orientated missions (rebuild from the daily reports of the days around the mid of July) in the loop and the player has the option to start a mission via the menu, when ever he likes, with the restriction of 1 mission per hour. The instrucitons are quite clear and simple and there is only one objective per mission, so all players focus on that one, if the want :rolleyes: . The teams get points for success and points for air kills and ground kills, these points can trigger other events or can be used as win conditions (thats what we are working on at the moment). I found that is the best compromise, between rebuilding history and playability. The main restriction we have is the performance and the connecting time, that`s a pitty, because the scripting opens so many options and ideas. :cool:

SNAFU
09-28-2011, 10:07 PM
I found this somewhere a while ago and just changed the timer for the AIAircraft:


public override void OnTickGame()
{
double initTime;

if (MissionTimer1M1.Elapsed.Minutes >= 59)
{
MissionTimer1M1.Restart();
foreach (int army in GamePlay.gpArmies())
{
foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
{
if (ActorName.MissionNumber(group.Name()).Equals(Miss ionNumber)) // Zeile L schen wenn auch AAA entfernt werden soll
{
AiActor[] members = group.GetItems();
for (int i = members.Length - 1; i > -1; i--)
{
(members[i] as AiAircraft).Destroy();
}
}
}


}
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////

//Ground objects (except AA Guns) will die after 55 min when counted from their birth
public override void OnActorCreated(int missionNumber, string shortName, AiActor actor)
{
base.OnActorCreated(missionNumber, shortName, actor);
if (actor is AiGroundActor)
if ((actor as AiGroundActor).Type() != maddox.game.world.AiGroundActorType.AAGun)
Timeout(3599, () =>
{
if (actor != null)
{ (actor as AiGroundActor).Destroy(); }
}
);
}


Note that you need to set the MissionTimer1M1 Stopwatch accordingly, f.e. in the OnBattleStarted-Section of you script:

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

public class Mission : AMission
{
Stopwatch MissionTimer1M1 = new Stopwatch();

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

MissionNumberListener = -1;
}
...
..
.


I found some issues with removing of the AI Airplanes, but these will be removed after landing by the standard remove-Ai-after-player-leaving script, so I left it that way. For ground units it works well.

_79_dev
09-29-2011, 12:47 AM
~S~

As far as I know all missions are looped even though if I want load that mission once and throw into it all the static objects and etc. just to avoid ghosts... so what will You have to do at the very end is...restart the server...and don't allow it to loop mission. This seems to be very complicated. Klem if You want to create very long scenario we gonna have to first find out what are this "ghosts"... at least few months (hope I'am wrong)...

How about to use Klems script to indicate sector, then check if there is any action or plane or whatever in that given sector and after all use trigger to spawn artillery for example or remove objects to minimise amount of statics on the server?