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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #17  
Old 10-05-2011, 05:32 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Script corrected:
Code:
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

using System.Diagnostics;

/**
 * Parts of the script were taken from:
 * 
 * Operation Dynamo v2.0 
 * A multiplayer mission for IL-2 Sturmovik: Cliffs of Dover
 * @author TheEnlightenedFlorist
 * http://forum.1cpublishing.eu/showthread.php?t=23579&highlight=operation+dynamo
 * */

public class Mission : AMission
{

    //allowed and currently flying aircraft
    int allowed109s = 12;
    int current109s = 0;

    int allowedSpit2s = 7;
    int currentSpit2s = 0;

    int allowed110s = 4;
    int current110s = 0;


    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        //listen to events from all missions.
        MissionNumberListener = -1;

    }

    // Makes any FMB trigger/action pair work if they have the same name.
    //public override void OnTrigger(int missionNumber, string shortName, bool active)
    //{
    //    base.OnTrigger(missionNumber, shortName, active);
    //    AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
    //    if (action != null)
    //        action.Do();
    //}


    public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        // test
        // notAvailableMsg();

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    {
                        current109s++;
                        if (current109s > allowed109s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.SpitfireMkIIa":
                    {
                        currentSpit2s++;
                        if (currentSpit2s > allowedSpit2s)
                        {
                            (actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure);
                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
                case "bob:Aircraft.Bf-110C-7":
                    {
                        current110s++;
                        if (current110s > allowed110s)
                        {
                            //(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0TotalFailure); // Is this line for single-engined only? только для одномоторных?

                            // Will this do for multi-engine?
                            int iNumOfEngines = ((actor as AiAircraft).Group() as AiAirGroup).aircraftEnginesNum();
                            for (int i = 0; i < iNumOfEngines; i++)
                            {
                                (actor as AiAircraft).hitNamed((part.NamedDamageTypes)Enum.Parse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
                            }

                            notAvailableMsg(player);
                            //GamePlay.gpHUDLogCenter(new Player[] { player }, "Aircraft not available! Choose another aircraft.");
                        }
                        break;
                    }
            }
        }
    }

    
    public void notAvailableMsg(Player player)
    {
        switch (player.LanguageName())
        {
            case "de":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Limit für diesen Flugzeugtyp erreicht! Wähle ein anderes Muster!");
                break; 
            case "ru":
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Слишком много самолетов данного типа! Выберите другой самолет.");
                break;
            default:
                GamePlay.gpHUDLogCenter(new Player[] { player }, "Too many aircrafts of this type! Choose another aircraft.");
                break;
        }
    }

    public override void OnPlaceLeave(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceLeave(player, actor, placeIndex);

        if (actor != null && actor is AiAircraft)
        {
            //check limited aircraft
            switch ((actor as AiAircraft).InternalTypeName())
            {
                case "bob:Aircraft.Bf-109E-4":
                    current109s--;
                    break;
                case "bob:Aircraft.SpitfireMkIIa":
                    currentSpit2s--;
                    break;
                case "bob:Aircraft.Bf-110C-7":
                    current110s--;
                    break;
            }
        }
    }
changed:
notAvailableMsg(new Player[] { player }); -to-> notAvailableMsg(player);
notAvailableMsg needs a argument from type Player not an array of it.

aircraft.hitNamed(...); -to-> (actor as AiAircraft).hitNamed(...)
aircraft was not declared - as alternative you can declare AiAircraft aircraft = actor as AiAircraft;

----
//(actor as AiAircraft).hitNamed(part.NamedDamageTypes.Eng0Tot alFailure); // Is this line for single-engined only?
Yes, you kill the first engine with it.

// Will this do for multi-engine?
int iNumOfEngines = ((actor as AiAircraft).Group() as AiAirGroup).aircraftEnginesNum();
for (int i = 0; i < iNumOfEngines; i++)
{
(actor as AiAircraft).hitNamed((part.NamedDamageTypes)Enum.P arse(typeof(part.NamedDamageTypes), "Eng" + i.ToString() + "TotalFailure"));
}
Yes its correct.

"Too many aircrafts of this type! Choose another aircraft."
translated into german:
"Limit für diesen Flugzeugtyp erreicht! Wähle ein anderes Muster!"

Last edited by FG28_Kodiak; 10-05-2011 at 06:04 AM.
Reply With Quote
 


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 06:31 PM.


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