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)

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.


All times are GMT. The time now is 10:44 AM.

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