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
  #1  
Old 04-23-2012, 05:48 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default OnAircraftCrashLanded trying to subtract flyable planes

I am having a bit of trouble getting this to subtract from the allowable flying planes on Crash land. It is usually easy when Actor is present. But how do I do it when player is null.

Below if a spitIIa crashlands then it should subtract 1 and the int allowedSpitIIas = 9;

The rest of the code works but it does not subtract from the allowedSpitIIas

Any idea?

Code:
    int allowedSpitIIas = 10;
    int currentSpitIIas = 0;
    int allowed109s = 10;
    int current109s = 0;



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

        Player player = null;
        if (player != null && player is AiAircraft)
        {
            
            switch ((player as AiAircraft).InternalTypeName())
            {

                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpitIIas--;
                    allowedSpitIIas -= 1;
                    break;
                case "bob:Aircraft.Bf-109E-4":
                    currentSpitIIas--;
                    allowed109s -= 1;
                    break;

            }
        }

        if (aircraft.Player(0) != null)
        {
            for (int i = 0; i < aircraft.Places(); i++)
            {
                if (aircraft.Player(i) != null)
                {
                    player = aircraft.Player(i);
                    break;
                }
            }
            if (player != null)
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Looks like you are walking home...", new object[] { });

        }

    }
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
Reply With Quote
  #2  
Old 04-23-2012, 06:02 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

You dont need a player in this case, you get a AiAircraft via OnAircraftCrashLanded. So you don't need a Player. The most of your player code make no sense
corrected:
Code:
    public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft)
    {
        base.OnAircraftCrashLanded(missionNumber, shortName, aircraft);
       
            switch ((aircraft).InternalTypeName())
            {
                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpitIIas--;
                    allowedSpitIIas -= 1;
                    break;
                case "bob:Aircraft.Bf-109E-4":
                    currentSpitIIas--;  // <---- Attention wrong variable 
                    allowed109s -= 1;
                    break;
            }
        

        List<Player> playersInPlane = new List<Player>();

        for (int i = 0; i < aircraft.Places(); i++)
        {
            if (aircraft.Player(i) != null)
            {
                playersInPlane.Add(aircraft.Player(i));
            }
        }
        
        if (playersInPlane.Count > 0)
            GamePlay.gpHUDLogCenter(playersInPlane.ToArray(), "Looks like you are walking home...", new object[] { });

        Timeout(120, () =>
            { destroyPlane(aircraft); });
    }
Reply With Quote
  #3  
Old 04-23-2012, 06:55 AM
hc_wolf hc_wolf is offline
Approved Member
 
Join Date: Jul 2010
Posts: 439
Default

Oh. Using PplayersInplane so much neater. thanks kodiak.
__________________
__________________
Win7, 64bit Ultra
Asus P8P67Pro MB
Intel i7-2600K
Coursair 16GB (4x 4GB), DDR3-1600MHz
Gainward Nvidia 580GTX 3GB DDR5
850-Watt Modular Power Supply
WIN7 and COD on Gskill SSD 240GB
40" Panasonic LCD
TrackIR5 +
Thrustmaster Warthog stick, throttle & pedals
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 09:40 PM.


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