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)

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)


All times are GMT. The time now is 05:37 AM.

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