Official Fulqrum Publishing forum

Official Fulqrum Publishing forum (http://forum.fulqrumpublishing.com/index.php)
-   FMB, Mission & Campaign builder Discussions (http://forum.fulqrumpublishing.com/forumdisplay.php?f=203)
-   -   Online War - FMB scripting (http://forum.fulqrumpublishing.com/showthread.php?t=21518)

Ataros 04-16-2011 07:56 AM

Online War - FMB scripting
 
1 Attachment(s)
I'll just copy my post from Syndicate forums:

Please have a look at post #73 from a developer here.
http://translate.google.com/translat...964%26page%3D3

Corrected translation:
Quote:

In the enclosure there is simple example of a mission with a script - run mission 1.mis (in 2 pieces), it executes the script 1.cs - every 1200 ticks of game (~ 30 ticks a second, iirc) which loads the mission 2.mis (1 Spitfire) - this is the answer to how to create a group of aircraft every N minutes.

When a player leaves the plane - an event triggered OnPlaceLeave and a second later the plane is killed - this is the answer on how to get rid of bots. Naturally, for your specific conditions, all this can be reconfigured.
I think using these scripts we can
1) kill all bots after a player exits an aircraft for better stability

and much more important(!)

2) create any submissions for current mission loading every 10, 15, 20 and 30 minutes, including

- programmed bombing runs on England (and France )
- tank battles
- armored cars attacking airfields
- ship convoys (bombing/intercepting submissions)
- free hunters surprisingly attacking on takeoff
- submarines sinking convoys (with 3rd party addons :grin: )
- etc, etc.

Basically any mission from Offline Campaign can be taken online.

Another useful thread on scripting and triggers.
http://translate.google.com/translat...hp%3Ft%3D68369

upd. New forum section on FMB and scripting http://translate.google.com/translat....php%3Ff%3D234

Lets make some small missions consisting of 3-4 submissions first to simulate what we had in IL-2 online wars like VEF or ADW.

File with sample mission from developer attached. Let the full-scale war begin!

doghous3 04-16-2011 09:09 AM

had a look at that this morning.

1. works a treat. spawn, respawn, first spawn plane immediately gone.

2. didn't work. From what I could see, it actually tries to load a new mission. Perhaps it is possible to load a mission into a mission, doesn't seem desirable, but then maybe i need more coffee.

Great finds again though Ataros. :)

Ataros 04-16-2011 01:35 PM

Quote:

Originally Posted by doghous3 (Post 264834)
From what I could see, it actually tries to load a new mission. Perhaps it is possible to load a mission into a mission, doesn't seem desirable, but then maybe i need more coffee.

Oleg mentioned long time ago that this is their idea for multiplayer i.e. continuous non-stop war. Server does not have to stop the mission and put all connected players into waiting interface screen when server is changing mission objectives as it was in original IL-2.

In original Il-2 when mission objectives are met you server had to stop the mission to load a new one. If you were flying in the air at this moment you would have to start again on the ground.

Now in CoD you can continue flying when "mission is changing".

Say you have a mission to stop enemy tanks from taking an airfield.
Then you have options
1) If you are successful this triggers loading next objectives:
- for your tanks advance to next city and for your aircraft to cover them.
- for enemy to bomb your airfield

2) If you fail to protect your airfield the objectives will be different:
- for you to cover bomber strike on enemy tank factory
- for enemy to escort transport aircraft to the newly taken airfield.

New objectives (together with new aircraft, tanks, ships, etc.) will be loaded into current mission while you are still flying in the air. You can prepare say 20-50 such small sub-missions and they will rotate on your server depending on results of previous missions set as triggers. Several sub-missions may overlap in time.
And this is just one possibility, there are much more of them.

Atm you may wish to try adding sub-missions of Stukas attacking shipping in the channel loading into your current mission every 20 minutes. ...and Beaufighters attacking blue airfields every 30 minutes, and... the possibilities are endless.

I will try to do it myself on Monday probably as i am currently away from my gaming PC.

doghous3 04-16-2011 02:30 PM

Ah, thanks for explaining the concept.

Part of the confusion was that in 2.mis, it contained information for [PARTS], [MAIN] etc.. (set as a full mission) also, and call me a doughnut, I had the tmp file in multi folder, not just missions. *facepalm*

So most the fluff can be removed and in that instance just have the airgroup/waypoints.

It does work. I need that caffiene in the morning.

baffa 04-16-2011 03:36 PM

These things looks really promising!

Jwam 04-16-2011 03:45 PM

Thank you very much for sharing.

I'm using it on my server, and it's really cool not to see thousands of IAs flying without ammo or standing on the taxiway.

Thee_oddball 04-16-2011 04:00 PM

Great find!!!

now if i can only script the dog to walk himself in the morning and not pester me :)

S!

Thee_oddball 04-16-2011 11:08 PM

Quote:

The name of the offending applications: Launcher.exe_Launcher, version: 1.0.0.0, time stamp: 0x4d6e3d08
0x4ce7ba58 Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp 0x4ce7ba58
Exception Code: 0xc0000005 Exception Code: 0xc0000005
An access violation is a serious problem: it is an unexpected attempt to write to an invalid memory address. As John already clarified, the unmanaged DLL might already have corrupted the process memory before the access violation has been raised. This can have unpredicted effects on any part of the current process

The original poster of the error also noted it happend after the Chanel map has been running for a while.

S!

Thee_oddball 04-17-2011 01:34 AM

I must be doing something wrong...i have added the script to one of my maps and there is even a .cs file of the same name but when i tested it and spwned four planes they just took off like they always do :( is the file below correct?
Quote:

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

public class Mission : AMission
{


public override void OnTickGame()
{
{
if (Time.tickCounter() % 1200 == 0)
{

GamePlay.gpPostMissionLoad("missions\Multi\Dogfigh t\basic40c.mis");
}
}
}

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceLeave(player, actor, placeIndex);
Timeout(1, () =>
{
AiAircraft CurAircraft = player.Place() as AiAircraft;
AiAircraft PrevAircraft = actor as AiAircraft;
if (CurAircraft != PrevAircraft)
{ (actor as AiAircraft).Destroy(); }
});
}

}

Ataros 04-17-2011 10:55 AM

Quote:

Originally Posted by Thee_oddball (Post 265583)
when i tested it and spwned four planes they just took off like they always do :( is the file below correct?

I can not say if something is wrong as I do not know C# myself.
Why do you expect the AI aircraft not to take off? If basic40c.mis tells them to take off, they will.


upd. All events you can use in a mission script. Sorry for jpg format.
http://www.sukhoi.ru/forum/attachmen...9&d=1303038770

upd.2 And a good thread on triggers here http://forum.1cpublishing.eu/showthr...builder&page=2

Thee_oddball 04-17-2011 08:09 PM

Quote:

Originally Posted by Ataros (Post 265842)
I can not say if something is wrong as I do not know C# myself.
Why do you expect the AI aircraft not to take off? If basic40c.mis tells them to take off, they will.

you misunderstand me..the AI i am talking about are player abandoned air craft not scripted AI

Ataros 04-18-2011 08:12 AM

1 Attachment(s)
Sample use of triggers to load a new mission into current one.

Quote:

110s attack convoy of static objects. When it is killed trigger loads a new mission where 110s attack just one car. When it is killed OnActorDead does not work unfortunately...
http://www.sukhoi.ru/forum/showthrea...=1#post1599354

It does not work on static objects completely as intended but works for aircraft I think.

File attached

ZaltysZ 04-19-2011 05:22 AM

Spawn/despawn script is kinda "incomplete" and causes unwanted behavior: plane instantly disappearing on bail out or plane disappearing when single member of crew leaves the plane (i.e. one of bomber gunners leaves the plane) while other members are still inside.

Additionally checking if plane is manned before "killing" it should help with multicrew plane despawns. Bail out despawns probably will be a lot tricker.

Ataros 04-19-2011 02:19 PM

Attention mission makers! A person from dev team told we can put AA guns on oil tankers at other forums. This means we can have some sea battles going on in the channel )) or coastal airfields attacked from sea.

Can not try it myself yet.

Ataros 04-19-2011 02:20 PM

Quote:

Originally Posted by ZaltysZ (Post 267608)
Spawn/despawn script is kinda "incomplete" and causes unwanted behavior: plane instantly disappearing on bail out or plane disappearing when single member of crew leaves the plane (i.e. one of bomber gunners leaves the plane) while other members are still inside.

Additionally checking if plane is manned before "killing" it should help with multicrew plane despawns. Bail out despawns probably will be a lot tricker.

Someone who knows C# can change it hopefully. I do not see much interest from community to this topic unfortunately. Hopefully when bugs are fixed and we have a stable dedi server things change.

ZaltysZ 04-19-2011 06:35 PM

Script for despawning planes without humans inside. Multicrew friendly.

Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                                        if (actor == null)
                                                { return;}

                                        Player[] Players = GamePlay.gpRemotePlayers();
                                       
                                        bool PlaneIsEmpty = true;
                                       
                                        foreach (Player i in Players)
                                        {       
                                                if ((i.Place() as AiAircraft) == (actor as AiAircraft))
                                                        {
                                                                PlaneIsEmpty = false;
                                                                break;
                                                        }
                                        }
                                       
                                        if (PlaneIsEmpty)
                                                { (actor as AiAircraft).Destroy(); }
        }

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


Ataros 04-19-2011 09:48 PM

WOW! Thanks a lot!!!

Thee_oddball 04-19-2011 09:48 PM

Quote:

Originally Posted by Ataros (Post 267990)
Attention mission makers! A person from dev team told we can put AA guns on oil tankers at other forums. This means we can have some sea battles going on in the channel )) or coastal airfields attacked from sea.

Can not try it myself yet.

oops I thought you guys knew that...my first map has 8 tankers and 3 with bofars :)

the selection will be under cargo :)

Thee_oddball 04-19-2011 09:49 PM

thank you Zalty does this replace the original script?

Ataros 04-19-2011 10:08 PM

Quote:

Originally Posted by Thee_oddball (Post 268370)
oops I thought you guys knew that...my first map has 8 tankers and 3 with bofars :)

the selection will be under cargo :)

Did you upload your mission somewhere? Could I have a look at it in FMB?

ZaltysZ 04-20-2011 05:02 AM

Quote:

Originally Posted by Thee_oddball (Post 268371)
thank you Zalty does this replace the original script?

Yes, if previous one handled only despawning.

ZaltysZ 04-20-2011 06:27 PM

I have edited my despawn script post and added additional "null" check to prevent some possible error.

Jwam 04-20-2011 07:23 PM

Quote:

Originally Posted by ZaltysZ (Post 269094)
I have edited my despawn script post and added additional "null" check to prevent some possible error.

Cool thank you very much ! I'll use it :)

edit : It seems there is one more "}" than needed, but works flawlessly :)

Ataros 04-25-2011 09:52 PM

More experiments with scripting. New version of Battle of France mission here http://forum.1cpublishing.eu/showpos...1&postcount=12

LeadFarmer 04-26-2011 01:58 AM

bottom of that script says timeout 1 which is one sec. set that to 60 and your planes will despawn after 60 sec which is enough time for an aircraft to hit the ground when you bail and despwan ;)

Ralith 04-26-2011 05:29 AM

Won't that leave the AI in control for 60 seconds, rather than having it glide into the ground? Really, the code should be ran instantly, and it should disable AI control instead of simply removing the aircraft--assuming that's currently possible.

Ataros 04-26-2011 07:12 AM

This sample script made for fun disables player controls. Maybe someone can use it to disable AI controls for say 10 minutes before destroying AI

Code:

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

    public class Mission: maddox.game.AMission
    {
          / / Override the method that is invoked when some of the planes will take off ...
        public override void OnAircraftTookOff (int missionNumber, string shortName, AiAircraft aircraft)
        {
            base.OnAircraftTookOff (missionNumber, shortName, aircraft); / / call the base method (you never know ...)
            if (GamePlay.gpPlayer ()! = null) / / check if we have a player.
            {
                if (GamePlay.gpPlayer (). Place ()! = null) / / check that the player is sitting somewhere and not hanging out on the rag.
                {
                    if (aircraft.Name (). Equals (GamePlay.gpPlayer (). Place (). Name ())) / / if the plane took off - a player, then ...
                    {
                        aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled); / / ... disables  elevators ...
                        aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled); / / ...  aileron ...
                        aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled); / / ...  rudder.
                                                / / Have a nice flight!
                    }
                }
            }
        }     
    }

More scripts here http://translate.google.com/translat...hp%3Ft%3D68369

ZaltysZ 04-26-2011 08:09 AM

Quote:

Originally Posted by Ralith (Post 273490)
Won't that leave the AI in control for 60 seconds, rather than having it glide into the ground? Really, the code should be ran instantly, and it should disable AI control instead of simply removing the aircraft--assuming that's currently possible.

The aim is not to make how it should look in real life. The aim is to remove clutter at first and then make the best you can with realism, because piles of planes have huge impact on playability.

Yes, you can disable the controls, but trimmed plane can happily fly even without working controls. What I want to say: disabling the controls does not guarantee a quick crash.

Extending despawn timeout can lead to great clutter, i.e. when player presses "Create" multiple times.

robtek 04-26-2011 08:38 AM

The aim should be, imho, when a player bails from a working plane and he tries to create a new plane, he find himself in that "abandoned" plane, as long as it is still flying :-D
And from a realism point of view, it is realistic that planes with dead crews were hunted and so live planes could escape.
I dont think that happens so often to have a felt influence on playability.

ZaltysZ 04-26-2011 09:11 AM

Quote:

Originally Posted by robtek (Post 273561)
The aim should be, imho, when a player bails from a working plane and he tries to create a new plane, he find himself in that "abandoned" plane, as long as it is still flying :-D

You mean injection after ejection? :o I don't think game engine allows you to teleport a crew member into plane. You can force a player posses a virtual crew member, but at first there should be something to posses in cockpit.

Quote:

Originally Posted by robtek (Post 273561)
And from a realism point of view, it is realistic that planes with dead crews were hunted and so live planes could escape.
I dont think that happens so often to have a felt influence on playability.

In fact, the problem isn't flying Dutchmen alone. The problem is bigger. All despawning logic isn't so trivial and implementation can become very complex. The more I play in MP, the more pitfalls I see. :mad:

robtek 04-26-2011 10:06 AM

Thanks for the answer ZaltysZ,

the first part of my post was just wishful thinking, pointed at players which abandon a working plane so they dont have to fly home and land.

And for your second point, i think i saw part of the problems in form of fata-morgana-bomber-raids, which disappear as you come closer to them, on the syn-server.

Ataros 04-26-2011 10:02 PM

Quote:

Originally Posted by ZaltysZ (Post 273545)
Yes, you can disable the controls, but trimmed plane can happily fly even without working controls. What I want to say: disabling the controls does not guarantee a quick crash.

Can a script apply say full aileron before disabling controls or set engine on fire?

Ataros 04-27-2011 07:50 AM

In my opinion this is what we need:

Quote:

Originally Posted by Ataros (Post 274214)

There are 2 issues with online currently:

1) when a player exits a plane AI takes control resulting in too many AI flying around at a server. There is a script to destroy AI after player exit http://forum.1cpublishing.eu/showpos...5&postcount=16
the problem with this script is that if a player exits while under attack his plane would disappear making the attacker very disappointed. Discussion is here http://forum.1cpublishing.eu/showthr...t=21518&page=3

Possible solution: damage an aircraft upon player exit to make it fall down and destroy it later in 10 minutes after it hits the ground.

2) When AI bombers are scripted to reappear on a server as time goes by the server can become very crowded with AI bombers making it unplayable. Mission example http://forum.1cpublishing.eu/showpos...8&postcount=24

The solution would be to damage AI bombers one by one (with 1-2 min intervals) in 15-25 minutes after their last waypoint. OnTaskCompleted()? Then when they fall down destroy them in 10 minutes.

Ideally damage applied to aircraft should be different (say 10 different types of damage in rotation) but deadly enough to make aircraft fall down in 1-3 minutes.

CoD possible Damage Types http://forum.1cpublishing.eu/showthread.php?t=22184 Thanks to FG28_Kodiak.

ZaltysZ 04-27-2011 08:02 AM

About bombers. Doesn't the problem dissappear if their last waypoint is "landing"?

mcler002 04-27-2011 08:22 AM

yes, but...
 
I would think so... But landing takes time ...

I just want them to disappear once they get back over 'friendly' areas

ZaltysZ 04-27-2011 08:32 AM

Quote:

Originally Posted by mcler002 (Post 274248)
I just want them to disappear once they get back over 'friendly' areas

Destroy() method of AiAircraft inside OnTaskCompleted().

Ataros 04-27-2011 09:08 AM

Quote:

Originally Posted by ZaltysZ (Post 274254)
Destroy() method of AiAircraft inside OnTaskCompleted().

Yes, we need someone to make this script to allow just copy-and-paste for those who does not know C# or any other language at all but makes missions in FMB like myself. Please... :grin:

This is an example of my mission that runs on Repka server atm. http://forum.1cpublishing.eu/showpos...8&postcount=24
I have no idea what I should put in the .cs file to make "Destroy() method of AiAircraft inside OnTaskCompleted(). " work. Another thing is that aircraft should fall to ground before it is destroyed with some timeout ideally as described here http://forum.1cpublishing.eu/showpos...1&postcount=33.

FG28_Kodiak 04-27-2011 01:26 PM

So have modified ZaltysZ script, with some damage ;), fastes way to ground is to disable all controlls and the engines.

Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                                        if (actor == null)
                                                { return;}

                                        Player[] Players = GamePlay.gpRemotePlayers();
                                       
                                        bool PlaneIsEmpty = true;
                                       
                                        foreach (Player i in Players)
                                        {       
                                                if ((i.Place() as AiAircraft) == (actor as AiAircraft))
                                                        {
                                                                PlaneIsEmpty = false;
                                                                break;
                                                        }
                                        }
                                       
                                        if (PlaneIsEmpty)
                                                {
                                                         
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                //for 2mots
                (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);
               
                                                    //wait 10min
                Timeout(600.0, () => {       
                                                        (actor as AiAircraft).Destroy();
                                                    });       
                                                       
                                          }
        }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
                _DespawnEmptyPlane(actor);
    }
}


Ataros 04-27-2011 01:35 PM

FG28_Kodiak, thank you so much! i will try it tonight.

ZaltysZ 04-27-2011 02:05 PM

Guys, don't bother with engines, kill fuel pump instead (all engines should stop). :-P

By the way, what will happen if player presses "Create" multiple time? There will probably be lots of planes on ground without working controls and engines. There is handy method IsAirborne(). If it returns false, plane should be destroyed immediately; if it returns true, only then disabling of controls should commence.

FG28_Kodiak 04-27-2011 02:11 PM

Disable fuel pump doesn't help, the engines wouldn't stop. Fuel pump is only nessesary at altitudes above 2500m.

You are right IsAirborne() can be very usefull in this script.

Corrected Version ;)

Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                                        if (actor == null)
                                                { return;}

                                        Player[] Players = GamePlay.gpRemotePlayers();
                                       
                                        bool PlaneIsEmpty = true;
                                       
                                        foreach (Player i in Players)
                                        {       
                                                if ((i.Place() as AiAircraft) == (actor as AiAircraft))
                                                        {
                                                                PlaneIsEmpty = false;
                                                                break;
                                                        }
                                        }
                                       
                                        if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
                                                {
                                                         
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
                                                          (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                //for 2mots
                (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);
               
                                                    //then wait 10min
                Timeout(600.0, () => {       
                                                        (actor as AiAircraft).Destroy();
                                                    });       
                                                       
                                          }
                                          else if (PlaneIsEmpty)
                                          {
                                                    (actor as AiAircraft).Destroy();
                                          }
        }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
                _DespawnEmptyPlane(actor);
    }
}


Ataros 04-27-2011 02:56 PM

Thanks again!
Copied to my mission script. Is it OK?

Code:

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

public class Mission : AMission
{


    public override void OnTickGame()
    {

            if (Time.tickCounter() % 90000 == 18000) // 50-10 60-10 108000 == 18000
            {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmGroundv1_0.mis");
            GamePlay.gpHUDLogCenter("Protect friendly shipping in the channel near France!");
            }

            if (Time.tickCounter() % 72000 == 72000) // 40-40 45-35 81000 == 63000
            {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0.mis");
                                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to blue airfields!");
                        }
       
            if (Time.tickCounter() % 72000 == 45000) // 40-25 45-45 81000 == 81000
                        {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0a.mis");
                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to red airfields in France!");
                        }

       
    }

    public void _DespawnEmptyPlane(AiActor actor)
    {
        if (actor == null)
        { return; }

        Player[] Players = GamePlay.gpRemotePlayers();

        bool PlaneIsEmpty = true;

        foreach (Player i in Players)
        {
            if ((i.Place() as AiAircraft) == (actor as AiAircraft))
            {
                PlaneIsEmpty = false;
                break;
            }
        }

        if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
        {

            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
            //for 2mots
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);

            //then wait 10min
            Timeout(600.0, () =>
            {
                (actor as AiAircraft).Destroy();
            });

        }
        else if (PlaneIsEmpty)
        {
            (actor as AiAircraft).Destroy();
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        _DespawnEmptyPlane(actor);
    }

}


mcler002 04-27-2011 03:22 PM

More to learn...
 
Quote:

Originally Posted by Ataros (Post 274454)


if (Time.tickCounter() % 72000 == 45000) // 40-25 45-45 81000 == 81000

[/CODE]

Dude, what do those numbers do?

I have noticed that the time counter isnt 100% accurate - the planes appears a couple of minutes soon than what they should... bug?

Ross

Ataros 04-27-2011 03:32 PM

Destroys crashlanded aircraft in 5 seconds ))
Code:

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

Have to figure out how to use it though.

Quote:

Originally Posted by mcler002 (Post 274460)
Dude, what do those numbers do?

Just notes for myself on timing. Not processed by program.

if (Time.tickCounter() % 72000 == 72000) is wrong probably.

mcler002 04-27-2011 04:15 PM

What the?
 
someone help me here :S
Main map starts at 05:00 - like the rest of the "sub" maps


Code:

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

public class Mission : AMission
{


    public override void OnTickGame()
    {

            if (Time.tickCounter() %  54000 == 18000)
            {
               
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBb1.mis");
                                GamePlay.gpHUDLogCenter("Intel: 4x He115's, Heading for Convoy!");
                        }
                       
            if (Time.tickCounter() %  99000 == 36000)
            {
               
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBb2.mis");
                                GamePlay.gpHUDLogCenter("Intel: 8x He111's, Heading for Lympne!");
                        }

            if (Time.tickCounter() %  108000 == 27000)
            {
               
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/Ross/OnlineBOBr1.mis");
                                GamePlay.gpHUDLogCenter("Intel: 12xBlenheim, Heading for Calais Marck!");
                        }

    }

  public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        Timeout(1, () =>
        {
            AiAircraft CurAircraft = player.Place() as AiAircraft;
            AiAircraft PrevAircraft = actor as AiAircraft;
            if (CurAircraft != PrevAircraft) 
                { (actor as AiAircraft).Destroy(); }
        });
    }

}

But actual results...

He 115 starts at 05:09 - 1 min fast
Blenheim starts at 05:13 - 7 min fast!!
He 111 starts at 05:18 - 3 min late?!

Whats going on :S :S :S

ZaltysZ 04-27-2011 04:18 PM

Quote:

Originally Posted by Ataros (Post 274469)
if (Time.tickCounter() % 72000 == 72000) is wrong probably.

This will always result in FALSE. % gives you a remainder of division (Остаток от деления), so this operation will always give result greater or equal to 0 and less than divisor (assuming positive numbers).

Code:

if (Time.tickCounter() % 72000 == 0)
Will be TRUE every time tickCounter() returns multiple of 72000 (i.e. every time 72000 ticks pass, when counted from 0: 72000, 2*72000, 3*72000 and so on).

mcler002 04-27-2011 04:20 PM

Some timings ive got
 
1 Attachment(s)
Check attachment...

Is the last comment for me or :S

Ataros 04-27-2011 04:30 PM

Quote:

Originally Posted by ZaltysZ (Post 274492)
Code:

if (Time.tickCounter() % 72000 == 0)
Will be TRUE every time tickCounter() returns multiple of 72000 (i.e. every time 72000 ticks pass, when counted from 0: 72000, 2*72000, 3*72000 and so on).

And if I want to delay the first execution by 71999 ticks it should be like follows?
Code:

if (Time.tickCounter() % 72000 == 71999)
Thanks a lot for your help.

FG28_Kodiak 04-27-2011 04:52 PM

The % is the modulus operator in C# (C, C++ and others)
http://en.wikipedia.org/wiki/Modulo_operation

ZaltysZ 04-27-2011 04:53 PM

Quote:

Originally Posted by Ataros (Post 274501)
And if I want to delay the first execution by 71999 ticks it should be like follows?
Code:

if (Time.tickCounter() % 72000 == 71999)

Yes. The general formula is:

Code:

if (Time.tickCounter() % A == B)
where:

A = 30 * amount second of seconds you want to repeat something
B = 30 * amount second you want to offset (delay) from beginning of mission

I suppose you want to delay something by 72000 and not by 71999 (although the difference is only 1/30s). So:

Code:

if (Time.tickCounter() % 72000 == 0 &&  Time.tickCounter()-72000==0)

mcler002 04-27-2011 04:53 PM

Quote:

Originally Posted by FG28_Kodiak (Post 274516)
The % is the modulus operator in C# (C, C++ and others)
http://en.wikipedia.org/wiki/Modulo_operation

You trying to blow my brains out haha?

ZaltysZ 04-27-2011 05:21 PM

Regarding ticks.

1) naryv (dev) said that 30 ticks are around 1 second. Because of that "around", you can get errors. :)

2) No one said that single tick always takes the same amount of time (if so, lag can screw your timing badly).

mcler002 04-27-2011 07:09 PM

Quote:

Originally Posted by ZaltysZ (Post 274533)
Regarding ticks.

1) naryv (dev) said that 30 ticks are around 1 second. Because of that "around", you can get errors. :)

2) No one said that single tick always takes the same amount of time (if so, lag can screw your timing badly).

Wants 30 ticks to equal 1 seconds on the dot :(! or 1 tick to equal one second!

please ;)

Ataros 04-27-2011 09:36 PM

30 ticks ~ 1 sec

Tested this. Works most of the time I think ))

Thanks to all for scripts!

Code:

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

public class Mission : AMission
{

    // loads my sub-missions
    public override void OnTickGame()
    {

            if (Time.tickCounter() % 72000 == 18000) // 40-10
            {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmGroundv1_0.mis");
            GamePlay.gpHUDLogCenter("Protect friendly shipping in the channel near France!");
            }

            if (Time.tickCounter() % 72000 == 71999) // 40-40
            {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0.mis");
                                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to blue airfields!");
                        }
       
            if (Time.tickCounter() % 72000 == 45000) // 40-25
                        {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFsmBombersv1_0a.mis");
                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to red airfields in France!");
                        }

       
    }

    // destroys aircraft abandoned by a player
    public void _DespawnEmptyPlane(AiActor actor)
    {
        if (actor == null)
        { return; }

        Player[] Players = GamePlay.gpRemotePlayers();

        bool PlaneIsEmpty = true;

        foreach (Player i in Players)
        {
            if ((i.Place() as AiAircraft) == (actor as AiAircraft))
            {
                PlaneIsEmpty = false;
                break;
            }
        }

        if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
        {

            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
            //for 2mots
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);

            //then wait 10min
            Timeout(600.0, () =>
            {
                (actor as AiAircraft).Destroy();
            });

        }
        else if (PlaneIsEmpty)
        {
            (actor as AiAircraft).Destroy();
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        _DespawnEmptyPlane(actor);
    }
    // destroys crushlanded aircraft in 10 minutes
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(600, () =>
        {
            aircraft.Destroy();
        });
    }
}

Runs at Repka server.

Ataros 04-28-2011 08:13 AM

Valuable note from a developer here

Quote:

Originally Posted by MuxaHuk (Post 274979)
With new engine you can create your own game inside our game, for example: you connect to server, and server sends to you completly new user interface (no restriction, but protected by sandbox, no one can read, write or modify your data that out border of game).
New GUI, new rules of game, new score system with ranks and etc.
It can do right now, anyone for their game server.
Of course you need some knowledge of scripting and design. We will assist wherever possible to all comers.
We are working to create examples.

Imagine in the future, each server will be unique, different battles on land, in air or under water, or global war :)

Anyone wants to write an interface for an online war?

ATM we have some knowledge on the following:
- triggers to check if mission objectives are complete
- scripts to load new mission objectives into a current mission based on triggers
- simple interface to give players new objectives GamePlay.gpHUDLogCenter

Say if enemy tanks are destroyed in a mission, we can move frontline, change one airfield spawnpoint from blue to red and load next mission objectives. But a good interface mod would be extremely useful to show different briefings based on airfields selected, to allow relocating airgroups from airfield to airfield, manage fuel resources, routes of supply convoys, voting for a commander, etc.
There is a great game-mode mod called "Warfare" in ArmA2. I hope we can create something similar and better.

MuxaHuk 04-28-2011 08:34 AM

This sample to use Time.current()
count in seconds from started battle.
Code:

private double nextMsgTime = 0;
 public override void OnTickGame() {
    base.OnTickGame();
    // Time. current() in seconds from Battle Start
    if ( Time.current() > nextMsgTime ) {
      nextMsgTime = Time.current() + 10.0; // 10 seconds to next message
      GamePlay.gpHUDLogCenter( "Time elapsed (in seconds) = " + Time.current() + ", next message will be at "+nextMsgTime);
    }
  }


Flashman 04-28-2011 03:09 PM

These all are very useful posts, in fact I have borrowed a bit of the script for my own mission that I hope will appear on the Syndicate Server soon.

I have a few questions as I know nothing about these scripts

1) If I want the text that comes up with the 'GamePlay.gpHUDLogCenter' command to show to only one team, can this be done and if so how?

2) I have noriced that using these scripts with the spawn removal stops the in game action and trigger events working where it spawns an aircraft. Is there a way of using both?

Keep up the good work, and thanks for your help in advance.

Ataros 04-28-2011 04:24 PM

Quote:

Originally Posted by Flashman (Post 275202)
These all are very useful posts, in fact I have borrowed a bit of the script for my own mission that I hope will appear on the Syndicate Server soon.

I have a few questions as I know nothing about these scripts

1) If I want the text that comes up with the 'GamePlay.gpHUDLogCenter' command to show to only one team, can this be done and if so how?

2) I have noriced that using these scripts with the spawn removal stops the in game action and trigger events working where it spawns an aircraft. Is there a way of using both?

Keep up the good work, and thanks for your help in advance.

1) I asked devs the same question at Sukhoi.ru.

2) Did not quite get what you mean by "spawn removal" and "trigger events working where it spawns an aircraft". Could you clarify please.

Ataros 04-28-2011 05:00 PM

New bits of code from devs.

Shows mission objectives to players depending on side and aircraft type (fighter/bomber).

"hitler caput" lol

Code:

public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);
        AiAircraft aircraft = actor as AiAircraft;
       
        if (aircraft != null)
        switch (aircraft.Army())
        {               
            case 1:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] {player},"Red Bomber, Bomb it all, hitler caput"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Red Fighter, fight them all"); }
                break;
            case 2:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { player }, "Das bomber!"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Das jager!"); }
                break;

        }
    }

    public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftTookOff(missionNumber, shortName, aircraft);

        if (GamePlay.gpPlayer().Place() != aircraft)
            return;
       
        switch (aircraft.Army())
        {
            case 1:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber, Bomb it all, hitler caput"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Fighter, fight them all"); }
              break;
            case 2:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Das bomber!"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Das jager!"); }
              break;

        }
    }


Flashman 04-28-2011 05:18 PM

Hi Ataros,

Hopefully I will be a little more clear this time!

I used the in-game script system using a Trigger to cause an Action to happen. Eg in my missions if a plane I select is shot down, it triggers the spawn of another plane.

EDIT>Script

Trigger: Walrus 1= Target Group destroyed (Walrus flying boat selected)
Action: Walrus 1= Air spawn group (second walrus selected)

This system works in single player, so that when the first walrus is shot down a second spawns at a preselected place. However, when I include the scripts you guys have been developing to despawn empty aircraft (for use online) the ingame script above does not work in either single or multiplayer.

Any ideas what i am doing wrong?

mcler002 04-28-2011 05:31 PM

I was just looking at the .mis files in notepad...


Example
Code:

[PARTS]
  core.100
  bob.100
[MAIN]
  MAP Land$English_Channel_1940
  BattleArea 200000 160000 120000 100000 9000
  TIME 5
  WeatherIndex 0
  CloudsHeight 1000
  BreezeActivity 1
  ThermalActivity 1
[GlobalWind_0]
  Power 3.000 0.000 0.000
  BottomBound 0.00
  TopBound 1500.00
  GustPower 5
  GustAngle 45
[splines]
[AirGroups]
  gb02.0F
[gb02.0F]
  Flight0  1 2 3
  Flight1  11 12 13
  Flight2  21 22 23
  Flight3  31 32 33
  Class Aircraft.BlenheimMkIV
  Formation VIC
  CallSign 31
  Fuel 86
  Weapons 1 1 2 1 1
  Detonator Bomb.Bomb_GP_250lb_MkIV 2 130 11
  Skill 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3
[gb02.0F_Way]
  NORMFLY 224480.60 255230.91 500.00 230.00
  NORMFLY 254029.14 255139.99 1000.00 230.00
  NORMFLY 274678.41 250003.49 1500.00 230.00
  NORMFLY 290803.61 240345.28 1500.00 230.00
  GATTACK_POINT 290788.83 215917.45 1500.00 230.00
  NORMFLY 290883.76 208132.47 1500.00 230.00
  NORMFLY 265387.72 208373.88 1500.00 230.00
  NORMFLY 246038.12 228039.38 1500.00 230.00
  NORMFLY 224003.28 252601.51 1500.00 230.00
[CustomChiefs]
[Stationary]
[Buildings]
[BuildingsLinks]
[Trigger]
  trigger TTime 1200

Is there any way of adding a line to prompt "end mission" at time #### ???

Also looks like we can edit aircraft here much "easier"... if you know what your doing! :D

NOTE - not at home to test it myself lol

Ross

Flashman 04-28-2011 05:31 PM

Quote:

Originally Posted by Ataros (Post 275269)
New bits of code from devs.

Shows mission objectives to players depending on side and aircraft type (fighter/bomber).

"hitler caput" lol

Code:

public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);
        AiAircraft aircraft = actor as AiAircraft;
       
        if (aircraft != null)
        switch (aircraft.Army())
        {               
            case 1:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] {player},"Red Bomber, Bomb it all, hitler caput"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Red Fighter, fight them all"); }
                break;
            case 2:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { player }, "Das bomber!"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { player }, "Das jager!"); }
                break;

        }
    }

    public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftTookOff(missionNumber, shortName, aircraft);

        if (GamePlay.gpPlayer().Place() != aircraft)
            return;
       
        switch (aircraft.Army())
        {
            case 1:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Bomber, Bomb it all, hitler caput"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Red Fighter, fight them all"); }
              break;
            case 2:
                if (aircraft.Type() == AircraftType.Bomber)
                { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Das bomber!"); }
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Das jager!"); }
              break;

        }
    }


THis is an interesting one, just tried it! The only thing is that for me the german one says 'Das jager' even when I am in a bomber such as the Ju87 or Ju88. Is there any setting I need to apply?

FG28_Kodiak 04-28-2011 06:28 PM

Argh german language:

Das bomber! -> (singular) Der Bomber! (plural) Die Bomber!
Das jager! -> (singular) Der Jäger! (plural) Die Jäger!

Next time i fly a bombing raid over the translator. :grin:

AircraftType could be:
AmphibiousPlane
BNZFighter
Bomber
DiveBomber
Fighter
Glider
HeavyFighter
JaBo
SailPlane
Scout
Sturmovik
TNBFighter
TorpedoBomber
Transport
UNKNOWN

So if you are in a Ju87 or Ju88 there should be Bomber or DiveBomber to Show that you are in a Bomber
Code:

      if ((aircraft.Type() == AircraftType.Bomber) || (aircraft.Type() == AircraftType.DiveBomber))  // if Bomber or Divebomber
              { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Der Bomber!"); } // show Der Bomber!
                else { GamePlay.gpHUDLogCenter(new Player[] { GamePlay.gpPlayer() }, "Der Jäger!"); } //in all other cases show Der Jäger!


Ataros 04-28-2011 08:08 PM

Quote:

Originally Posted by Flashman (Post 275280)
Any ideas what i am doing wrong?

I did not learn how to use triggers yet but if you paste here a complete script I am sure someone would help.

Ataros 04-28-2011 08:13 PM

Quote:

Originally Posted by mcler002 (Post 275287)

Is there any way of adding a line to prompt "end mission" at time #### ???

Depends on what you mean by end mission. It is like in real life when one mission is over you have another one if you are alive or if you have none you have a vacation.

I think you can shut server down with .cmd file.

mcler002 04-28-2011 08:47 PM

Start mission... plays... End mission... Start mission again... etc etc
 
Well as you know we both start a mission through the script, but i want to know if we can stop it... as we had already discused :S

But as we dont know how to do this via scipt, i was woundering is we could do it through the .mis file...

ATAG_Bliss 04-28-2011 09:12 PM

Yeah, I would like to know this as well. The way the MP missions are designed are amazing (with missions able to be loaded into missions etc.) but, for instance, lets say you want an ongoing war, how are you going to stop it from going into the night?

Or could you just load a mission and make the sun appear again out of nowhere, without missing a beat, while others are playing at the same time?

More testing I guess :)

Ataros 04-28-2011 09:25 PM

I wish I were a part of the dev team and know all the answers :grin:

Meanwhile another script destroying abandoned planes from ru forums. Tell me what you think of it.

Code:

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

public class Mission : AMission
{
        private bool isAiControlledPlane (AiAircraft aircraft)
        {
                if (aircraft == null)
            {
                        return false;
                    }

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

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

        private void explodeFuelTank (AiAircraft aircraft)
    {
                if (aircraft != null)
        {
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Exploded);
                        /***
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank1Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank2Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank3Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank4Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank5Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank6Exploded);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank7Exploded);
                        ***/
                }
        }

        private void fuelTankFire (AiAircraft aircraft)
    {
                if (aircraft != null)
        {
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Fire);
                        /***
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank1Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank2Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank3Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank4Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank5Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank6Fire);
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank7Fire);
                        ***/
                }
        }

        private void destroyAiControlledPlane (AiAircraft aircraft)
    {
                if (isAiControlledPlane (aircraft))
        {
                        destroyPlane (aircraft);
                }
        }

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

                AiAircraft aircraft = (actor as AiAircraft);

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

                if (aircraft == null)
        {
                        return;
                }

                aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled);
                aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled);
                aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled);

                aircraft.hitNamed (part.NamedDamageTypes.FuelPumpFailure);
                // aircraft.hitNamed (part.NamedDamageTypes.Eng0TotalFailure);
                // aircraft.hitNamed (part.NamedDamageTypes.Eng1TotalFailure);

                /*** Tank fire doesn't work after engine total failure - ???
                Timeout (15, () =>
                                {fuelTankFire (aircraft);}
                        );
                ***/

                /*** Cool, but kills fps
                Timeout (25, () =>
                                {explodeFuelTank (aircraft);}
                        );
                ***/

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

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

        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 (30, () =>
                                {destroyAiControlledPlane (aircraft);}
                        );
        }
       
        /**
        public override void OnAircraftTookOff (int missionNumber, string shortName, AiAircraft aircraft) {
            base.OnAircraftTookOff (missionNumber, shortName, aircraft);
            ...
        }
        **/       
}

Quote:

Originally Posted by SYN_Bliss (Post 275443)
for instance, lets say you want an ongoing war, how are you going to stop it from going into the night?

I think just like in real life you order (with a script) your units to rtb when it is getting dark. Then they have a rest till early morning.

Quote:

Originally Posted by mcler002 (Post 275427)
But as we dont know how to do this via scipt, i was woundering is we could do it through the .mis file...

I think you can stop mission with a script like you can stop real life: kill all units, stop time and that's it.

Quote a Dev:
Quote:

Выгрузить - это сложно, миссия же может по скрипту кого-то нарожать, что-то в себя подгрузить и т.д
"To unload (a mission) - it is difficult, because a mission can give birth to something using scripts, upload smth into itself, etc."

My guess is you can switch server off, but you can not unload a mission as you can not unload life as it gives birth to smth :grin: This is not a game this is real life simulator.

FG28_Kodiak 04-28-2011 09:35 PM

Problem with exploding fuel tanks could be that other players also get damaged.

Flashman 04-29-2011 08:42 AM

Hi Guys, im having some fun with this scripting business and have finally got a script that works, however I could do with some help with the timing commands:

I know that 1800 ticks = 1 minute but im not entirely sure what these two number cause to happen. From my script file:

if (Time.tickCounter() % 126000 == 18000)

When this counts down a mission is launched but im unsure as to the significane of the two timings:

does the 126000 give the time between each repeat operation of the operation?

I have found the second number, 18000 in this case appears to set the time for the first operation. Is this correct?

SO, if i want the operation (in this case a mission starts within themain mission and planes spawn) to repeat every 2 hours, but the first operation is 10 minutes after the main mission begins would this be correct?

if (Time.tickCounter() % 216000 == 18000)

Thanks!

mcler002 04-29-2011 08:49 AM

1st number = repeat i.e if it was 108000 - the map/ mission should load every 1hour...

2nd number = start time i.e. if it was 18000 = the map/mission should start within 10 minutes of the game start, or repeat interval...

But i dont think it works 100%... but as i have been told 1800 ticks "roughly" equals a minute...

Flashman 04-29-2011 09:24 AM

Quote:

Originally Posted by mcler002 (Post 275689)
1st number = repeat i.e if it was 108000 - the map/ mission should load every 1hour...

2nd number = start time i.e. if it was 18000 = the map/mission should start within 10 minutes of the game start, or repeat interval...

But i dont think it works 100%... but as i have been told 1800 ticks "roughly" equals a minute...

Cool, thanks.

I actually did some offline testing and set the timings to minutes adn sped things up! It appears to work roughly as you say... it will do for now!

mcler002 04-29-2011 09:30 AM

Quote:

Originally Posted by Flashman (Post 275705)
Cool, thanks.

I actually did some offline testing and set the timings to minutes adn sped things up! It appears to work roughly as you say... it will do for now!

Yea i did offline testin as well... but x16 is just not fast enough lol! only went a couple of hours in...

mcler002 04-29-2011 11:15 AM

AI damage & destory
 
Ive tested and tested... its not working :S

Help !

Ataros 04-30-2011 12:58 AM

Just to have it all in one thread

Quote:

Originally Posted by MuxaHuk (Post 274954)
Code:

public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        Timeout(1, () =>
        {
            AiAircraft CurAircraft = player.Place() as AiAircraft;
            AiAircraft PrevAircraft = actor as AiAircraft;
            if (CurAircraft != PrevAircraft) 
                { (actor as AiAircraft).Destroy(); }
        });
    }



Ataros 04-30-2011 01:09 AM

Quote:

Originally Posted by Flashman (Post 275280)
Hi Ataros,

Hopefully I will be a little more clear this time!

I used the in-game script system using a Trigger to cause an Action to happen. Eg in my missions if a plane I select is shot down, it triggers the spawn of another plane.

EDIT>Script

Trigger: Walrus 1= Target Group destroyed (Walrus flying boat selected)
Action: Walrus 1= Air spawn group (second walrus selected)

This system works in single player, so that when the first walrus is shot down a second spawns at a preselected place. However, when I include the scripts you guys have been developing to despawn empty aircraft (for use online) the ingame script above does not work in either single or multiplayer.

Any ideas what i am doing wrong?

Checked ingame trigger system. Did not work with external scrips but it is by itself just fantastic! I think it is possible to achieve what I tried to do loading sub-missions into a mission with this trigger system only. I'll switch to it for a while from scripting as I do not know C#. Very helpful thread on this http://forum.1cpublishing.eu/showthr...builder&page=2

However we should try:

1) make a mission with internal triggers without script
2) make a mission with script that loads the first mission in.
3) load more missions when needed.
I will not have time to try this for a couple of days however ((

Alternatively you can program all the triggers in a script by hand. Check links in the 1st message of this thread for examples.

e.g.
Code:

  / / $ Reference Campaign.dll
 / / - $ Debug
 using System;
 using maddox.game;
 using maddox.game.world;

 public class Mission: maddox.game.campaign.Mission {

        public override void OnTrigger (int missionNumber, string shortName, bool active)
        {
            if ("trigger". Equals (shortName) & & active)
            {
                GamePlay.gpHUDLogCenter ("Triggers trigger");
            } 
        }
 
 }

Code:

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


 class Mission: maddox.game.AMission
 {
        public override void OnActorDead (int missionNumber, string shortName, AiActor actor, System.Collections.Generic.List <DamagerScore> damages)
        {
                base.OnActorDead (missionNumber, shortName, actor, damages);
                AiAction action = GamePlay.gpGetAction ("TestAction");
                if (action! = null)
                {
                        action.Do ();
                }
        }
 }

Code:

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

    public class Mission : maddox.game.AMission
    {
        private List<AiAction> actions = new List<AiAction>();
        private int round = 1;
        private bool completed = false;
       
        public override void OnBattleStarted()
        {
            AiAction action = GamePlay.gpGetAction("startGroup2");
            if (action != null) actions.Add(action);
            action = GamePlay.gpGetAction("startGroup3");
            if (action != null) actions.Add(action);
            GamePlay.gpHUDLogCenter(String.Format("Раунд {0}", round));
        }

        public override void OnActorDead(int missionNumber, string shortName, AiActor actor, System.Collections.Generic.List<DamagerScore> damages)
        {
            base.OnActorDead(missionNumber, shortName, actor, damages);
            if (!(actor is AiAircraft))
                return; // Не самолет

            int army = (actor as AiAircraft).Group().Army();
            if (army == 1)
            {
                if (!completed)
                {
                    bool fail = (actor as AiAircraft).AirGroup().DiedAircrafts >= (actor as AiAircraft).AirGroup().InitNOfAirc;
                    if (fail)
                    {
                        GamePlay.gpHUDLogCenter("Миссия провалена.");
                    }
                }
            }
            else
            {
                bool next = (actor as AiAircraft).AirGroup().DiedAircrafts >= (actor as AiAircraft).AirGroup().InitNOfAirc;
                if (next)
                {
                    if (round == 3)
                    {
                        completed = true;
                        GamePlay.gpHUDLogCenter("Поздравляем, миссия пройдена!");
                    }
                    else
                    {
                        round++;
                        startNewRound();
                    }
                }
            }
        }

        private void startNewRound()
        {
            GamePlay.gpHUDLogCenter(String.Format("Раунд {0}", round));
            if (actions.Count > 0)
            {
                actions[0].Do();
                actions.RemoveAt(0);
            }
        }
    }


http://translate.google.com/translat...hp%3Ft%3D68369

Quote:

Originally Posted by mcler002 (Post 275763)
Ive tested and tested... its not working :S

Help !


Would you tell us what exactly you are trying to do and what does not work. Run my script it loads missions on timing more or less. Does not always destroy planes on the server however.

mcler002 04-30-2011 05:17 AM

I have pretty much copied and pasted your scripting ...

I always right click and compile to see if the script is OK, which it is ... So when ever I try and test it ... My ai bots are still flying

At the current time I am in the middle of making a new online map with less 'repeat mission' loading, and more internal triggers

But as you have posted above, I will need script for 'triggers' to flash messages on the screen about incoming planes etc ...

I shall give the above a try when I'm on my pc later!

Ataros 04-30-2011 02:25 PM

Quote:

Originally Posted by mcler002 (Post 276219)
So when ever I try and test it ... My ai bots are still flying

Ahh, if you mean bot removal script, it works on my PC when I create a server, but does not work on a dedi server somehow ((
The issue reported to the devs already.

Try the second script I copied from sukhoi.ru.

Just uploaded a new mission into missions thread. http://forum.1cpublishing.eu/showpos...3&postcount=31

FG28_Kodiak 04-30-2011 03:10 PM

Do you try ABattle and not AMission?

Ataros 04-30-2011 04:19 PM

Quote:

Originally Posted by FG28_Kodiak (Post 276418)
Do you try ABattle and not AMission?

This is the latest script I used. Do you mean I should change
public class Mission : AMission
to
public class Mission : ABattle
Should I?
Every script I have seen uses AMission I think.

Code:

// v.1.6.14

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

public class Mission : AMission
{

    // loads my sub-missions
    public override void OnTickGame()
    {

            if (Time.tickCounter() % 72000 == 18000) // 40-10
            {
            GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFv1_6Ground1.mis");
            GamePlay.gpHUDLogCenter("Protect friendly shipping in the channel near France!");
            }

            if (Time.tickCounter() % 72000 == 71999) // 40-40
            {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFv1_6Bombers1.mis");
                                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to blue airfields!");
                        }
       
            if (Time.tickCounter() % 72000 == 45000) // 40-25
                        {
                GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/128BoF/128BoFv1_6Bombers2.mis");
                GamePlay.gpHUDLogCenter("Intel: Enemy bombers are heading to red airfields in France!");
                        }

       
    }

    // destroys aircraft abandoned by a player
    public void _DespawnEmptyPlane(AiActor actor)
    {
        if (actor == null)
        { return; }

        Player[] Players = GamePlay.gpRemotePlayers();

        bool PlaneIsEmpty = true;

        foreach (Player i in Players)
        {
            if ((i.Place() as AiAircraft) == (actor as AiAircraft))
            {
                PlaneIsEmpty = false;
                break;
            }
        }

        if ((PlaneIsEmpty) && (actor as AiAircraft).IsAirborne())
        {

            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
            //for 2mots
            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng1TotalFailure);

            //then wait 10min
            Timeout(600.0, () =>
            {
                if (actor is AiAircraft)
                {
                    (actor as AiAircraft).Destroy();
                }
            });

        }
        else if (PlaneIsEmpty)
        {
                if (actor is AiAircraft)
                {
                  (actor as AiAircraft).Destroy();
                }
        };
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);
        _DespawnEmptyPlane(actor);
    }
    // destroys crushlanded aircraft in 10 minutes
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
        Timeout(600, () =>

        {
            if (aircraft != null)
            {
            aircraft.Destroy();
            }
        });
    }
}


ZaltysZ 04-30-2011 04:30 PM

I am not sure it is possible to overload ABattle without creating your own add-in.

FG28_Kodiak 04-30-2011 05:15 PM

Hm just try and error and see what happen, ABattle has mostly the same methods than AMission. The only examples i know are from the campaign directory and are only single missions.
I wish there where a documentation about scripting. :rolleyes:

No457_Squog 05-01-2011 03:14 PM

Quote:

Originally Posted by ZaltysZ (Post 268215)
Script for despawning planes without humans inside. Multicrew friendly.

Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                                        if (actor == null)
                                                { return;}

                                        Player[] Players = GamePlay.gpRemotePlayers();
                                       
                                        bool PlaneIsEmpty = true;
                                       
                                        foreach (Player i in Players)
                                        {       
                                                if ((i.Place() as AiAircraft) == (actor as AiAircraft))
                                                        {
                                                                PlaneIsEmpty = false;
                                                                break;
                                                        }
                                        }
                                       
                                        if (PlaneIsEmpty)
                                                { (actor as AiAircraft).Destroy(); }
        }

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


No457_Mako & myself tweaked this code so that the server is included in the workings. The Server isn't listed in the GamePlay.gpRemotePlayers() array.
Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                if (actor == null)
                        return;
                Player[] Players = GamePlay.gpRemotePlayers();
                bool PlaneIsEmpty = true;
                foreach (Player i in Players) {
                        if (((i.Place() as AiAircraft) == (actor as AiAircraft)) || ((GamePlay.gpPlayer().Place() as AiAircraft) == (actor as AiAircraft))) {
                                PlaneIsEmpty = false;
                                break;
                        }
                }
                if (PlaneIsEmpty) {
                        (actor as AiAircraft).Destroy();
                }
        }

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


Flashman 05-01-2011 05:00 PM

HI Squoag,

I tried your version in nthe post above and it despawned the plane if I changed from pilot to a gunners position.

I tested this on my own 'server' and in single player. Obviously in MP this would not be desireable!

No457_Squog 05-01-2011 09:26 PM

Hi Flashman,

Are you 100% sure that you used the second code block in my post and not the first? What you're seeing is very symptomatic of the first code block in my post. I put it there as a before/after for the original author but perhaps I should mark it more clearly...

SC/JG Matoni 05-02-2011 11:47 AM

Quote:

Originally Posted by No457_Squog (Post 276921)
No457_Mako & myself tweaked this code so that the server is included in the workings. The Server isn't listed in the GamePlay.gpRemotePlayers() array.
Code:

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

public class  Mission : AMission
{
        public void _DespawnEmptyPlane(AiActor actor)
        {
                if (actor == null)
                        return;
                Player[] Players = GamePlay.gpRemotePlayers();
                bool PlaneIsEmpty = true;
                foreach (Player i in Players) {
                        if (((i.Place() as AiAircraft) == (actor as AiAircraft)) || ((GamePlay.gpPlayer().Place() as AiAircraft) == (actor as AiAircraft))) {
                                PlaneIsEmpty = false;
                                break;
                        }
                }
                if (PlaneIsEmpty) {
                        (actor as AiAircraft).Destroy();
                }
        }

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


~S

Will test on Australian Skies tomorrow

EDIT: This works for me, thanks No457_Mako & No457_Squog, has helped with server stability. Ran 3 maps no worries, we were having issues with loading new maps before this

Worked with Position swap ONLINE in the bf 110 as well.

Matoni

Flashman 05-02-2011 05:16 PM

Quote:

Originally Posted by No457_Squog (Post 277070)
Hi Flashman,

Are you 100% sure that you used the second code block in my post and not the first? What you're seeing is very symptomatic of the first code block in my post. I put it there as a before/after for the original author but perhaps I should mark it more clearly...

Hi Sqouag,

Im pretty sure I tried both but truth be told you have me wondering now.... I will try this again when I get the time and see if it works for me.

Please note: i tried this on my own 'server' not on the Syndicate server.

Ataros 05-03-2011 08:01 AM

Script to destroy actors in a mission (e.g. before loading new one to server).

This kills mission (or submission) own actors. To kill all actors 'living' on a server (e.g. loaded by other missions) remove the lines put in blue color.
Code:

foreach (int army in GamePlay.gpArmies())
            {
                foreach (AiAirGroup group in GamePlay.gpAirGroups(army))
                {
                  if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber))
                    {
                        AiActor[] members = group.GetItems();
                        for (int i = members.Length - 1; i > -1; i--)
                        {
                            (members[i] as AiAircraft).Destroy();
                        }
                    }
                }
                foreach (AiGroundGroup group in GamePlay.gpGroundGroups(army))
                {
                  if (ActorName.MissionNumber(group.Name()).Equals(MissionNumber))
                    {
                        AiActor[] members = group.GetItems();
                        for (int i = members.Length - 1; i > -1; i--)
                        {
                            (members[i] as AiGroundActor).Destroy();
                        }
                    }
                }
            }

Should solve "actor not destroyed" problem.

May need some testing and fine-tuning.

SC/JG Matoni 05-05-2011 09:16 AM

~S

I would appear Beta 4 breaks all of these kill actor scripts... well it does 4 me

Blackrat 05-05-2011 09:59 AM

Quote:

Originally Posted by SC/JG Matoni (Post 278680)
~S

I would appear Beta 4 breaks all of these kill actor scripts... well it does 4 me

Phew its not just our server then, I rolled back to Beta 1 and the scripts work again.

Macka 05-05-2011 01:35 PM

And it reintroduces the stutters online which I kinda missed .....NOT!....lol. Rolled client back to 14305 will try on Matoni's OGN later. :)

Ataros 05-05-2011 09:38 PM

Quote:

Originally Posted by SC/JG Matoni (Post 278680)
~S

I would appear Beta 4 breaks all of these kill actor scripts... well it does 4 me

Try this one. I think it worked today on patched Repka. (5 min timeout)
Code:

// v.1.6.17 trig NEW

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

public class Mission : AMission
{
 
    // destroys aircraft abandoned by a player
    private bool isAiControlledPlane (AiAircraft aircraft)
    {
                if (aircraft == null)
        {
                        return false;
                }

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

                return true;
        }

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

        private void explodeFuelTank (AiAircraft aircraft)
    {
                if (aircraft != null)
        {
                        aircraft.hitNamed (part.NamedDamageTypes.FuelTank0Exploded);
                }
        }

        private void destroyAiControlledPlane (AiAircraft aircraft) {
                if (isAiControlledPlane (aircraft)) {
                        destroyPlane (aircraft);
                }
        }

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

                AiAircraft aircraft = (actor as AiAircraft);

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

                if (aircraft == null) {
                        return;
                }

                aircraft.hitNamed (part.NamedDamageTypes.ControlsElevatorDisabled);
                aircraft.hitNamed (part.NamedDamageTypes.ControlsAileronsDisabled);
                aircraft.hitNamed (part.NamedDamageTypes.ControlsRudderDisabled);
                aircraft.hitNamed (part.NamedDamageTypes.FuelPumpFailure);
                aircraft.hitNamed (part.NamedDamageTypes.Eng0TotalFailure);
                aircraft.hitNamed (part.NamedDamageTypes.Eng1TotalFailure);

        /***Timeout (240, () =>
                {explodeFuelTank (aircraft);}
            );
        * ***/

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

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

        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); }
            );
    }


}


Ataros 05-06-2011 07:46 AM

Sample shows moving frontline and changing spawnpoints from red to blue and vice versa based on trigger (flyby above an airfield).

Can someone program a small 3 airfields battle based on it? Say a middle airfield becomes red or blue based on which tanks remain alive after taking the airfield. Then spawn new groups of tanks in say 20 minutes for a new round.

Code:

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


public class Mission : AMission
{
    internal class MissionMarker
    {
        internal double x;
        internal double y;
        internal int army;
        internal MissionMarker(double x, double y, int army) { this.x = x; this.y = y; this.army = army; }
    }



    private MissionMarker[] MissionMarkers = new MissionMarker[]
    {  new MissionMarker(17100.80,14515.20,2),
        new MissionMarker(20428.80, 8934.40, 2),
        new MissionMarker(12492.80, 17203.20, 1),
        new MissionMarker(11801.60, 21555.20, 1)
    };
       

    internal ISectionFile CreateNewFrontLineMission(int markerNum, int newArmy)
    {
        MissionMarkers[markerNum].army = newArmy;
        foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
        {
            if (bp != null)
                bp.destroy();
       
        }
        ISectionFile f = GamePlay.gpCreateSectionFile();
        string sect;
        string key;
        string value;
        sect = "FrontMarker";
        for (int i = 0; i < MissionMarkers.Length; i++)
        {           
            key = "FrontMarker" + i.ToString();
            value = MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].army.ToString();
            f.add(sect, key, value); 
        }
        sect = "BirthPlace";
        for (int i = 0; i < MissionMarkers.Length; i++)
        {           
            key = "BirthPlace_" + i.ToString();
            value = " " + MissionMarkers[i].army.ToString() + " " + MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " 0 10 1 0 . . .";
            f.add(sect, key, value);
        }
       
        return f;
    }

    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);
        for (int i = 0; i < MissionMarkers.Length; i++)
            for (int j = 1; j < 3; j++)
            {
                string str = "changeArmy" + i.ToString() + "_" + (j).ToString();
                if (str.Equals(shortName))
                {
                    string armyOwner;
                    if (j == 1) { armyOwner = " Red army"; }
                    else { armyOwner = " Blue army"; }
                    GamePlay.gpHUDLogCenter("Airdrome: " + i.ToString() + " turn to " + armyOwner);
                    GamePlay.gpPostMissionLoad(CreateNewFrontLineMission(i, j));
                }
            }
        AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
        if (action != null)
            action.Do();

    }
}


MadTommy 05-06-2011 09:02 AM

... my head hurts trying to understand this..:grin:

Does anyone fancy writing a fuckwits guide to all this, err sorry i mean a dummies guide? It would be very much appreciated, i'd buy the 1st round or virtual beers!

I'm keen to create MP missions but trying to gain the level of understanding needed from these forums and google translations is rather daunting. And i suspect waiting for an official manual would be foolish, considering the flight manual produced.

But thanks for all the help provided here, it is appreciated.. just a bit confusing for a new mission builder.

Ataros 05-06-2011 03:27 PM

Quote:

Originally Posted by MadTommy (Post 279248)
... my head hurts trying to understand this..:grin:

Does anyone fancy writing a fuckwits guide to all this, err sorry i mean a dummies guide?

The guide is called C# for Dummies but you can start with the following. I do not know C# but have a lot of fun with this simple script. It is a huge step forward from original IL-2 online.

This is a sample script to create a small 'campaign' containing a main mission and 3 sub-missions.

Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g.
C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
Scripts have to be saved with .cs extension and have the same name as the main mission.

Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs.
Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder):
C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\

Create and edit 3 missions you want to be loaded into the main mission with FMB.
Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis.
That's it.

In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , then edit 3 filepaths in this file.
e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission. *

Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map).
The text in this example is visible to both sides for simplicity.

You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand.
Download link http://www.microsoft.com/express/Dow...2010-Visual-CS

All text after // marks are comments describing what the script does.
You may play your mission in MP or as a SP mission if you create a passworded server.

I hope to put up some missions using this script to Repka server soon.

Code:

/****
 * Brief startup guide to scripting.
 * This is a sample script to create a small 'campaign' containing a main mission and 3 sub-missions.
 *
 * Copy this script to Notepad and save it as sample.cs into the same folder your mission will be located, e.g.
 * C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
 * Scripts have to be saved with .cs extension and have the same name as the main mission.
 * Create and edit your main mission in FMB. In this example the main mission name should be sample.mis because the script name is sample.cs.
 * Make sure you have both sample.mis and sample.cs in the following directory (on the drive you have your Documents folder):
 * C:\Users\%user%\Documents\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Multi\Dogfight\My_mis1\
 * Create and edit 3 missions you want to be loaded into the main mission with FMB.
 * Put these 3 missions in the same directory, name them as mission1.mis, mission2.mis and mission3.mis.
 * That's it.
 *
 * In case you saved your mission files into other directory than Multi/Dogfight/Dogfight/My_mis1/ , than edit 3 filepaths in the script file.
 * e.g. the line GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis" contains the path to the 1st sub-mission.  *
 *
 * Change message text after GamePlay.gpHUDLogCenter commands to whatever you like (usually mission objectives and their location on the map).
 * The text in this example is visible to both sides for simplicity.
 *
 * You may wish to download and use Microsoft Visual Studio 2010 Express to open and edit .cs files. It is free and makes .cs files easy to read and understand.
 * Download link http://www.microsoft.com/express/Downloads/#2010-Visual-CS
 *
 * All text after // marks are comments describing what the script does.
 * You may play your mission in MP or as a SP mission if you create a passworded server.
 * Have fun! and S! from 3GIAP
 *
 * Feel free to delete all the comments above and including this line from this file. ****/

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

public class Mission : AMission
{
 
public override void OnTickGame()
{

// loads the 1st sub-mission in 10 min and repeates it every 60 min.
    if (Time.tickCounter() % 108000 == 18000) // 108000 = 60 min repeat. 18000 = 10 min delay.
        // pls. note!!! the 1st figure above must be always larger than 2nd!
  {
      GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission1.mis");

      // prints message on screen after mission load
      GamePlay.gpHUDLogCenter("Hello, world! Mission1.mis loaded!");

      // prints message on screen in 10 minutes / 600 seconds
      double initTime = 0.0;
      Timeout(initTime += 600, () =>
      {
          GamePlay.gpHUDLogCenter("10 minutes into the 1st mission! Wow! It works!!!");
      });

      // prints message on screen in 5 minutes  / 300 seconds
      Timeout(initTime += 300, () =>
      {
          GamePlay.gpHUDLogCenter("Wholy s.. it works!!!");
      });

  }

// loads the 2nd sub-mission, etc. the same way
      if (Time.tickCounter() % 108000 == 54000) //  108000 = 60 min repeat, 54000 = 30 min delay.
    {
        GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission2.mis");
        GamePlay.gpHUDLogCenter("Mission2.mis loaded!");
      double initTime = 0.0;
      Timeout(initTime += 600, () =>
      {
          GamePlay.gpHUDLogCenter("Mission2 10 min message!");
      });
           
      Timeout(initTime += 300, () =>
        {
            GamePlay.gpHUDLogCenter("Mission2 15 min message!");
        });
    }

// loads the 3rd sub-mission
      if (Time.tickCounter() % 108000 == 90000) // 60 min repeat, 50 min delay
      {
          GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/My_mis1/mission3.mis");
          GamePlay.gpHUDLogCenter("Mission3.mis loaded!");

          double initTime = 0.0;
          Timeout(initTime += 600, () =>
          {
              GamePlay.gpHUDLogCenter("Mission3 10 min message!");
          });
          Timeout(initTime += 300, () =>
          {
              GamePlay.gpHUDLogCenter("Now it really works! You are a genius! Have fun!");
          });
      }
}


}

upd. Corrected an error, replaced 1800 ticks with 18000 for 10 minutes.

MadTommy 05-06-2011 04:55 PM

Ataros - http://www.barmans.co.uk/productimg/19450.jpg

Thanks for all the info here.. i'll try and get my head around this over the weekend, your help is very much appreciated.

Ataros 05-11-2011 07:36 AM

The above script runs on Repka DS #1 server ATM loading 5 smaller missions into main mission with various time-cycles. Check it out.

ATAG_Bliss 05-11-2011 08:58 AM

Ataros,

Thanks for all the info. We'll see if the latest kill actor script works with beta 1. We found the latest beta to be far to unstable for the server and have reverted back.

MadTommy 05-11-2011 09:13 AM

What is the best script to remove empty & crash landed planes.. there seem to be many versions knocking about.

I've heard there are issues with these scripts & the latest patch.. some enlightenment would be much appreciated.

Looking at bob & bof 1.6 neither seem to have these scripts added..:confused:

Ataros 05-11-2011 09:21 AM

Quote:

Originally Posted by MadTommy (Post 281611)
What is the best script to remove empty & crash landed planes.. there seem to be many versions knocking about.

I've heard there are issues with these scripts & the latest patch.. some enlightenment would be much appreciated.

Looking at bob & bof 1.6 neither seem to have these scripts added..:confused:

Did you try this one? http://forum.1cpublishing.eu/showpos...0&postcount=92

Runs on Repka server. I think it works (not 100% sure though of cause :grin: ) .


All times are GMT. The time now is 02:27 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.