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 12-15-2011, 02:32 PM
41Sqn_Banks 41Sqn_Banks is offline
Approved Member
 
Join Date: Oct 2007
Posts: 644
Default

Just a guess: gpPlayer() returns null if you are hosting it on a dedicated server and gpPlayer().Place() returns null if the player is not within an vehicle.

Code:
private void DoDamage()
{   // Script that triggered an accidental damage to the player plane
    // Author: FG28_Kodiak   Modified by: Salmo
    // Ref: http://forum.1cpublishing.eu/showthread.php?t=22184

    if(GamePlay.gpPlayer() != null && GamePlay.gpPlayer().Place() != null && GamePlay.gpPlayer().Place() is AiAircraft)
    {
        PlayerPlane = (AiAircraft)GamePlay.gpPlayer().Place();
        ...
    }
}
Reply With Quote
  #2  
Old 12-16-2011, 12:52 AM
salmo salmo is offline
Approved Member
 
Join Date: Mar 2011
Posts: 632
Default

Thanks Banks, I thought the same, so I've played with removing the Dodamage() call etc but it did not fix the error. So while your code suggestion is more elegant (& I've implimented it), it doesnt fix the NullReferenceException error
__________________
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
  #3  
Old 12-16-2011, 12:58 AM
ATAG_Bliss ATAG_Bliss is offline
Approved Member
 
Join Date: Mar 2010
Posts: 1,156
Default

Hi Salmo,

I've been seeing this error through the dedi box since the game was released (scripts or not). There's still a huge disconnect between running missions through the in-game GUI and running them through the -server.

Nice stuff you've done with scripting btw!
__________________

ATAG Forums + Stats
Reply With Quote
  #4  
Old 12-16-2011, 04:35 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

@salmo:

Modified:

Code:
    public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
    {
        if (m_random.Next(1, 200 + 1) != 67)   // 0.5% chance of takeoff failure
        {
            DoDamage(aircraft);
        }
    }


    private void DoDamage(AiAircraft aircraft)
    {   // Script that triggered an accidental damage to the player plane
        // Author: FG28_Kodiak   Modified by: Salmo
        // Ref: http://forum.1cpublishing.eu/showthread.php?t=22184


        if (aircraft.Player(0) == null) return; // If no human pilot leave

        switch (m_random.Next(1, 7 + 1))
        {
            // ===================================
            // ---- Engine(s) failures ----
            // ===================================
            case 1:
                aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                //sendScreenMessageToPilot(PlayerPlane, "Engine Failure", null);
                //GamePlay.gpHUDLogCenter("Engine Failure");
                break;

            case 2:
                aircraft.hitNamed(part.NamedDamageTypes.Eng0OilSecondariesFire);
                //sendScreenMessageToPilot(aircraft, "Oil is on fire");
                GamePlay.gpHUDLogCenter("Oil is on fire");
                break;

            // ===================================
            // ---- Hydrolicss & cables failures ----
            // ===================================
            case 3:
                if (m_random.Next(1, 2) == 1)
                {
                    aircraft.hitNamed(part.NamedDamageTypes.UndercarriageUpLockFailureL);
                    //sendScreenMessageToPilot(aircraft, "Undercarriage failure");
                    GamePlay.gpHUDLogCenter("Undercarriage failure");
                }
                else
                {
                    aircraft.hitNamed(part.NamedDamageTypes.UndercarriageUpLockFailureR);
                    //sendScreenMessageToPilot(aircraft, "Undercarriage failure");
                    GamePlay.gpHUDLogCenter("Undercarriage failure");
                }
                break;

            case 4:
                aircraft.hitNamed(part.NamedDamageTypes.Eng0ThrottleControlBroken);
                //sendScreenMessageToPilot(aircraft, "Broken throttle cable");
                GamePlay.gpHUDLogCenter("Broken throttle cable");
                break;

            // ===================================
            // ---- Flight surfaces failures ----
            // ===================================
            case 5:
                aircraft.hitNamed(part.NamedDamageTypes.ControlsElevatorDisabled);
                //sendScreenMessageToPilot(aircraft, "Elevator jammed");
                GamePlay.gpHUDLogCenter("Elevator jammed");
                break;

            case 6:
                aircraft.hitNamed(part.NamedDamageTypes.ControlsAileronsDisabled);
                //sendScreenMessageToPilot(aircraft, "Ailerons jammed");
                GamePlay.gpHUDLogCenter("Ailerons jammed");
                break;

            case 7:
                aircraft.hitNamed(part.NamedDamageTypes.ControlsRudderDisabled);
                //sendScreenMessageToPilot(aircraft, "Rudder jammed");
                GamePlay.gpHUDLogCenter("Rudder jammed");
                break;

            default:
                aircraft.hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                //sendScreenMessageToPilot(aircraft, "Engine Failure");
                GamePlay.gpHUDLogCenter("Engine Failure");
                break;

        }

    }
Reply With Quote
  #5  
Old 12-16-2011, 05:17 AM
Octocat Octocat is offline
Approved Member
 
Join Date: Dec 2011
Posts: 22
Default

Cool. Simple modification, to add a random delay before failure:

Code:
    public override void OnAircraftTookOff(int missionNumber, string shortName, AiAircraft aircraft)
    {
        if (m_random.Next(1, 200 + 1) != 67)   // 0.5% chance of takeoff failure
        {            
           Timeout(m_random.Next(1, 60), ()=>  DoDamage(aircraft));
        }
    }
Also, in dynamic campaign, the chance of failure may depend on the aircraft aging, and damages in previous missions.

Last edited by Octocat; 12-16-2011 at 05:21 AM.
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 01:05 AM.


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