1C Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2012, 06:59 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default Getting aircraft/airgroup home airfield

Dumb questiion alert ! How do I get an aircraft and/or airgroup's home airfield name?

ie. AiBirthPlace.Name();
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
Reply With Quote
  #2  
Old 05-24-2012, 07:04 AM
FG28_Kodiak FG28_Kodiak is offline
Senior Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

In AiAirport no name is present (maybe a bug, normally it should be possible), so I created this class:
Code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using maddox.game;
using maddox.game.world;
using maddox.GP;

namespace CloDo
{
    namespace helpers
    {
        public class Airfields
        {

            IGamePlay gamePlay = Strategy.THIS.GamePlay;

            List<Tuple<string, double, double, string>> AirfieldNames = new List<Tuple<string, double, double, string>>{
                {new Tuple<string, double, double, string>("Abbeville", 284007.30, 124840.50, "English_Channel_1940")}, // Tuple<Airfieldname, X-Coord, Y-Coord, MapName>
                {new Tuple<string, double, double, string>("Hawkinge", 234930.60, 232459.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Lympne", 225174.10, 228785.40, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Manston", 248248.30, 258983.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Tangmere", 104593.50, 199293.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Calais Marck", 291178.60, 216286.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Biggin Hill", 155403.50, 253686.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Caen carpiquet", 117911.00, 18146.35, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Gravesend", 180346.70, 264835.40, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Amiens Allonville", 321977.80, 101320.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Carquebut", 52601.16, 39782.83, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Ford", 112848.40, 195780.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Kenley", 146689.70, 251072.40, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Hornchurch", 166766.40, 277772.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("St Omer Wizernes", 311564.30, 190353.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Upavon", 28778.20, 247273.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Montdidier", 335376.20, 72793.08, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Le Havre Octeville", 157374.10, 57869.54, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Ramsgate", 251184.80, 260927.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Canterbury", 234568.40, 248429.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Littlestone", 221950.50, 221332.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Eastchurch", 212285.50, 262830.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Sounthend", 200959.90, 282782.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Rochester", 188229.80, 257808.20, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Maidstone", 181260.70, 248833.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Wilmington", 167682.80 ,198386.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Gatwick", 141685.50, 234076.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Redhill", 143424.10, 241162.20, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Shoreham", 133698.40, 198565.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Croydon", 144258.80, 256424.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Brooklands", 120333.30, 255377.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Feltham", 125306.40, 265580.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Heathrow", 121346.10, 269212.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Heston", 125379.90, 271489.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Hendon", 135473.90, 283727.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Northolt", 123413.20, 278194.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("White Waltham", 98892.02, 272114.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Reading", 90946.03, 266311.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Farnborough", 100060.20, 247376.40, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Odiham(Oldham)", 86982.81, 242034.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Harwell", 61265.06, 280192.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Watchfield", 37948.03, 284823.40, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Yatesbury", 18618.82, 264227.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Netheravon", 29865.94, 242135.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Larkhill", 22426.97, 238675.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Boscombe Down", 31456.89, 233239.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Salisbury", 27946.91, 230224.20, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Old Sarum", 28764.03, 226253.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Andover", 46142.30, 238991.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Worthydown", 60583.92, 228112.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Southampton", 58765.93, 209960.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Hamble", 61264.09, 201022.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Gosport", 72435.07, 194011.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Lee on Solent", 69155.01, 195373.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Portsmouth", 80117.35, 196482.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Ryde", 74252.00, 183309.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Bembridge", 76324.13, 180178.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Sandown", 71245.69, 177136.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Thorney Island", 89632.63, 196176.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Achiet-Grevillers", 350150.10, 121130.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Amiens Glisy", 322075.10, 95307.58, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Arras", 351330.70, 145343.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Arras Saint Liger", 355623.30, 128799.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Audembert", 272013.60, 205320.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Barly", 314851.30, 130755.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Beaumont Le Roger", 208122.30, 10022.63, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Beauvais Nivillers", 307577.70, 50024.67, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Berk", 265712.40, 156097.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Boisjean Ecuires", 278725.20, 157067.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Boulogne Alprech", 264387.00, 186323.60, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Brias", 321117.60, 153653.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Brombos", 285450.70, 70129.75, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Caffiers", 281868.50, 203450.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Campagne Les Guines", 287169.30, 202045.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Colembert", 284920.90, 193001.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Coquelles", 281202.60, 212948.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Cramont/Yvrench", 298439.90, 127466.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Crecy", 304944.60, 38421.05, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Crepon", 111526.80, 33307.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Deauville Saint Gatien", 162575.40, 38819.22, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Desvres", 285042.30, 182696.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Dieppe Saint Aubin", 229199.30, 96278.02, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Estree", 280257.20, 164215.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Beauvais Tille", 303216.70, 48623.19, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Bernay Saint Martin", 191769.90, 10254.25, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Creil", 331579.80, 26699.74, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Haute-Fontaine", 293360.80, 64646.63, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Grandvilliers", 291085.50, 73515.41, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Guines", 284085.80, 205076.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Hermelinghen", 285740.80, 199982.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Hydrequent", 276190.60, 200785.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Le Touquet", 267738.80, 166723.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Ligescourt", 285109.90, 139909.10, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Marquise West", 272460.20, 200326.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Merville Calonne", 340749.00, 178426.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Monchy-Breton", 325708.30, 152724.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Oye-Plage", 296378.20, 217322.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Persan Beaumont", 317533.60, 17080.86, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Saint Inglevert", 275941.60, 207456.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Peuplingues", 277055.50, 209352.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Pihen", 278920.10, 207297.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Plumetot", 124247.80, 28435.88, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Poix Nord", 292756.40, 88726.35, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Pontoise/Cormeilles", 296969.90, 9149.86, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Querqueville", 27835.34, 72604.56, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Rely Norrent Fontes", 321400.10, 172372.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Rosieres en Santerre", 346178.20, 87489.65, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Rouen Boos",236496.90, 41402.81, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Roye Amy", 353042.60, 70057.92, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("St-Omer-Arques", 317659.50, 190565.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("St-Omer-Clairmarais", 317864.60, 195075.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Theville", 43818.77, 70627.06, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Tramecourt", 306422.90, 160671.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Wailly-Beaucamp", 275846.00, 156103.50, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Wissant", 269735.00, 207212.00, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Yvrench", 295249.40, 130393.30, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Zutkerque", 299432.00, 203047.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Sempy", 287389.80, 163213.70, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Samer", 278083.50, 182132.90, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("North weald", 162440.10, 297791.80, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Westhampnett", 101418.80, 199773.20, "English_Channel_1940")},
                {new Tuple<string, double, double, string>("Bomber 1", 15540.99, 13752.77, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Bomber 2", 67244.05, 14831.46, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Bomber 3", 67318.89, 68887.89, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Bomber 4", 14305.56, 67286.91, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Central Base", 41736.31, 64988.54, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Fighter 1", 40114.09, 20730.89, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Fighter 2", 53062.68, 33423.27, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Fighter 4", 29149.74, 55143.82, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Fighter 3", 52624.94, 52751.54, "Online_Cobra_(8x8)")},
                {new Tuple<string, double, double, string>("Bomber 2", 29122.25, 22263.88, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Fighter 1", 12792, 16054.43, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Fighter 2", 17324.57, 11052.77, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Bomber 1", 10670.67, 10846.81, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Fighter 3", 29281.22, 16081.01, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Fighter 4", 23373.91, 22906.53, "Online_Isles_of_Doom")},
                {new Tuple<string, double, double, string>("Bomber 1", 18708.06, 9858.24, "Online_Volcanic_Island")},
                {new Tuple<string, double, double, string>("Bomber 2", 18060.83, 30679.96, "Online_Volcanic_Island")},
                {new Tuple<string, double, double, string>("Fighter 2", 13901.69, 30877.23, "Online_Volcanic_Island")},
                {new Tuple<string, double, double, string>("Fighter 1", 12253.48, 10590.46, "Online_Volcanic_Island")},
                {new Tuple<string, double, double, string>("Bomber", 11664.05, 10960.92, "Online_Map2")},
                {new Tuple<string, double, double, string>("Axis Fighter 1", 30426.23, 22278.16, "Online_Map2")},
                {new Tuple<string, double, double, string>("Axis Bomber", 30671.99, 30692.52, "Online_Map2")},
                {new Tuple<string, double, double, string>("Axis Fighter 2", 22685.31, 30551.1, "Online_Map2")},
                {new Tuple<string, double, double, string>("Allied Fighter 2", 10342.1, 21820.05, "Online_Map2")},
                {new Tuple<string, double, double, string>("Allied Fighter 1", 20468.24, 10585.68, "Online_Map2")},
                {new Tuple<string, double, double, string>("RAF Fighter", 12644.3, 17490.32, "Online_Cross_v_Roundel")},
                {new Tuple<string, double, double, string>("RAF Bomber", 11925.07, 21522.77, "Online_Cross_v_Roundel")},
                {new Tuple<string, double, double, string>("LW Fighter", 17056.56, 14538.03, "Online_Cross_v_Roundel")},
                {new Tuple<string, double, double, string>("LW Bomber", 20491.69, 8916.6, "Online_Cross_v_Roundel")},
                {new Tuple<string, double, double, string>("Bomber 1", 15388.03, 13967.85, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Fighter 1", 20091.73, 19281.11, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Fighter 2", 29919.6, 20218.83, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Fighter 3", 27740.99, 29359.83, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Fighter 4", 19773.08, 29495.89, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Bomber 3", 30707.91, 34548.2, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Bomber 2", 33961.1, 15011.61, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Bomber 4", 15358.27, 32930.73, "Online_Carrier_War")},
                {new Tuple<string, double, double, string>("Allied Forward Field", 16555.28, 17128.55, "Online_Map")},
                {new Tuple<string, double, double, string>("Bomber", 14099.6, 10710.41, "Online_Map")},
                {new Tuple<string, double, double, string>("Fighter 1", 10814.07, 15622.57, "Online_Map")},
                {new Tuple<string, double, double, string>("Axis Forward Field", 24102.95, 24736.46, "Online_Map")},
                {new Tuple<string, double, double, string>("Axis Bomber", 26489.2, 30421.71, "Online_Map")},
                {new Tuple<string, double, double, string>("Axis Field", 29907.05, 26096.06, "Online_Map")}
            };



            public AiAirport GetStartAirfield(AiActor actor)
            {
                AiAirport NearestAirfield = null;
                AiAirport[] airports = gamePlay.gpAirports();
                Point3d StartPos = actor.Pos();

                if (airports != null)
                {
                    foreach (AiAirport airport in airports)
                    {
                        if (NearestAirfield != null)
                        {
                            if (NearestAirfield != null)
                                if (NearestAirfield.Pos().distance(ref StartPos) > airport.Pos().distance(ref StartPos))
                                    NearestAirfield = airport;
                        }
                        else NearestAirfield = airport;
                    }
                }
                return NearestAirfield;
            }

            public AiAirport GetDestinationAirfield(AiActor actor)
            {
                AiAirport NearestAirfield = null;
                AiAirport[] airports = gamePlay.gpAirports();
                List<AiWayPoint> WpList = new List<AiWayPoint>();

                if ((actor as AiAircraft).Group().GetWay() != null)
                    WpList.AddRange((actor as AiAircraft).Group().GetWay());

                Point3d WaypointPos = WpList[WpList.Count - 1].P;


                if (airports != null)
                {
                    foreach (AiAirport airport in airports)
                    {
                        if (NearestAirfield != null)
                        {
                            if (NearestAirfield != null)
                                if (NearestAirfield.Pos().distance(ref WaypointPos) > airport.Pos().distance(ref WaypointPos))
                                    NearestAirfield = airport;
                        }
                        else NearestAirfield = airport;
                    }
                }
                return NearestAirfield;
            }


            public AiAirport GetNearestAirfield(AiActor actor)
            {
                AiAirport NearestAirfield = null;
                AiAirport[] airports = gamePlay.gpAirports();

                Point3d actorPos = actor.Pos();

                if (airports != null)
                {
                    foreach (AiAirport airport in airports)
                    {
                        if (NearestAirfield != null)
                        {
                            if (NearestAirfield != null)
                                if (NearestAirfield.Pos().distance(ref actorPos) > airport.Pos().distance(ref actorPos))
                                    NearestAirfield = airport;
                        }
                        else NearestAirfield = airport;
                    }
                }
                return NearestAirfield;
            }



            public AiAirport GetCurrentAirfield(AiActor actor, double maxdistance)
            {
                AiAirport NearestAirfield = null;
                AiAirport[] airports = gamePlay.gpAirports();
                List<AiWayPoint> WpList = new List<AiWayPoint>();

                Point3d actorPos = actor.Pos();

                if (airports != null)
                {
                    foreach (AiAirport airport in airports)
                    {
                        if (NearestAirfield != null)
                        {
                            if (NearestAirfield != null)
                                if (NearestAirfield.Pos().distance(ref actorPos) > airport.Pos().distance(ref actorPos))
                                    NearestAirfield = airport;
                        }
                        else NearestAirfield = airport;
                    }
                }

                if (NearestAirfield.Pos().distance(ref actorPos) < maxdistance)
                    return NearestAirfield;
                else
                    return null;
            }


            public AiAirport GetAirfield(string airportName)
            {
                AiAirport tmpAirport = null;

                var FoundAirfield = AirfieldNames.Find(item => item.Item1.Equals(airportName));

                if (FoundAirfield != null)
                {
                    foreach (AiAirport ap in gamePlay.gpAirports())
                    {
                        if (ap.Pos().x == FoundAirfield.Item2 && ap.Pos().y == FoundAirfield.Item3)
                        {
                            tmpAirport = ap;
                            break;
                        }
                    }
                }

                return tmpAirport;
            }


            public string GetAirfieldName(AiAirport airport)
            {

                string airfieldName = "";

                if (airport != null)
                {

                    var Airfield = AirfieldNames.Find(item => item.Item2 == airport.Pos().x && item.Item3 == airport.Pos().y);

                    airfieldName = Airfield.Item1;
                }
                return airfieldName;
            }


            public bool checkAirfield(AiActor actor, AiAirport airport, double maxdistance)
            {
                Point3d ActorPos = actor.Pos();

                if (airport.Pos().distance(ref ActorPos) < maxdistance)
                    return true;
                else return false;
            }



            public List<AiActor> GetAvailableActors(AiAirport airport, double maxdistance)
            {
                List<AiActor> actors = new List<AiActor>();
                List<AiActor> availableActors = new List<AiActor>();

                if (gamePlay.gpAirGroups(1) != null)
                    foreach (AiAirGroup ag in gamePlay.gpAirGroups(1))
                    {
                        if (ag.GetItems() != null)
                            actors.AddRange(ag.GetItems());

                    }
                if (gamePlay.gpAirGroups(2) != null)
                    foreach (AiAirGroup ag in gamePlay.gpAirGroups(2))
                    {
                        if (ag.GetItems() != null)
                            actors.AddRange(ag.GetItems());

                    }

                actors.ForEach(item =>
                {
                    Point3d planePos = item.Pos();

                    if (airport.Pos().distance(ref planePos) < maxdistance && isActorAvaiable(item))
                        availableActors.Add(item);
                });

                return availableActors;

            }


            private bool isActorAvaiable(AiActor actor)
            {
                bool placesAvailable = false;
                bool actorIdle = false;


                for (int i = 0; i < (actor as AiAircraft).Places(); i++)
                {
                    if ((actor as AiAircraft).ExistCabin(i))
                        if ((actor as AiAircraft).Player(i) == null)
                            placesAvailable = true;
                }

                if ((actor as AiAircraft).getParameter(part.ParameterTypes.Z_VelocityTAS, -1) <= 1.0)
                    actorIdle = true;
                else
                    actorIdle = false;

                if (placesAvailable && actorIdle)
                    return true;
                else
                    return false;
            }
        }
    }
}
Reply With Quote
  #3  
Old 05-24-2012, 07:25 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

I'm indebted to you again Kodiak, Thankyou.
__________________
When one engine fails on a two engine bomber, you will always have enough power left to get to the scene of the crash.

Get the latest COD Team Fusion patch info HERE
Reply With Quote
Reply

Thread Tools
Display Modes

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 08:42 AM.

Based on a design by: Miner Skinz.com

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2007 1C Company. All rights reserved.