Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

Reply
 
Thread Tools Display Modes
  #81  
Old 04-30-2011, 04:30 PM
ZaltysZ's Avatar
ZaltysZ ZaltysZ is offline
Approved Member
 
Join Date: Sep 2008
Location: Lithuania
Posts: 426
Default

I am not sure it is possible to overload ABattle without creating your own add-in.
Reply With Quote
  #82  
Old 04-30-2011, 05:15 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

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.
Reply With Quote
  #83  
Old 05-01-2011, 03:14 PM
No457_Squog No457_Squog is offline
Registered Member
 
Join Date: Mar 2010
Location: Melbourne, Australia
Posts: 10
Default

Quote:
Originally Posted by ZaltysZ View Post
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);
		});
    }
}
Reply With Quote
  #84  
Old 05-01-2011, 05:00 PM
Flashman Flashman is offline
Approved Member
 
Join Date: May 2010
Posts: 109
Default

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!
Reply With Quote
  #85  
Old 05-01-2011, 09:26 PM
No457_Squog No457_Squog is offline
Registered Member
 
Join Date: Mar 2010
Location: Melbourne, Australia
Posts: 10
Default

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...
Reply With Quote
  #86  
Old 05-02-2011, 11:47 AM
SC/JG Matoni SC/JG Matoni is offline
Approved Member
 
Join Date: Apr 2011
Posts: 29
Default

Quote:
Originally Posted by No457_Squog View Post
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

Last edited by SC/JG Matoni; 05-02-2011 at 02:03 PM.
Reply With Quote
  #87  
Old 05-02-2011, 05:16 PM
Flashman Flashman is offline
Approved Member
 
Join Date: May 2010
Posts: 109
Default

Quote:
Originally Posted by No457_Squog View Post
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.
Reply With Quote
  #88  
Old 05-03-2011, 08:01 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

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.

Last edited by Ataros; 05-03-2011 at 08:03 AM.
Reply With Quote
  #89  
Old 05-05-2011, 09:16 AM
SC/JG Matoni SC/JG Matoni is offline
Approved Member
 
Join Date: Apr 2011
Posts: 29
Default

~S

I would appear Beta 4 breaks all of these kill actor scripts... well it does 4 me
Reply With Quote
  #90  
Old 05-05-2011, 09:59 AM
Blackrat Blackrat is offline
Approved Member
 
Join Date: Apr 2011
Posts: 133
Default

Quote:
Originally Posted by SC/JG Matoni View Post
~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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:42 PM.


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