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
  #20  
Old 05-06-2011, 07:46 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Sample shows moving frontline and changing spawnpoints from red to blue and vice versa based on trigger (flyby above an airfield).

Can someone program a small 3 airfields battle based on it? Say a middle airfield becomes red or blue based on which tanks remain alive after taking the airfield. Then spawn new groups of tanks in say 20 minutes for a new round.

Code:
using System;
using System.Collections;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{
    internal class MissionMarker
    {
        internal double x;
        internal double y;
        internal int army;
        internal MissionMarker(double x, double y, int army) { this.x = x; this.y = y; this.army = army; }
    }



    private MissionMarker[] MissionMarkers = new MissionMarker[]
    {   new MissionMarker(17100.80,14515.20,2),
        new MissionMarker(20428.80, 8934.40, 2),
        new MissionMarker(12492.80, 17203.20, 1),
        new MissionMarker(11801.60, 21555.20, 1)
    };
        

    internal ISectionFile CreateNewFrontLineMission(int markerNum, int newArmy)
    {
        MissionMarkers[markerNum].army = newArmy;
        foreach (AiBirthPlace bp in GamePlay.gpBirthPlaces())
        {
            if (bp != null)
                bp.destroy();
         
        }
        ISectionFile f = GamePlay.gpCreateSectionFile();
        string sect;
        string key;
        string value;
        sect = "FrontMarker";
        for (int i = 0; i < MissionMarkers.Length; i++)
        {            
            key = "FrontMarker" + i.ToString();
            value = MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].army.ToString();
            f.add(sect, key, value);  
        }
        sect = "BirthPlace";
        for (int i = 0; i < MissionMarkers.Length; i++)
        {            
            key = "BirthPlace_" + i.ToString();
            value = " " + MissionMarkers[i].army.ToString() + " " + MissionMarkers[i].x.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + MissionMarkers[i].y.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " 0 10 1 0 . . .";
            f.add(sect, key, value);
        }
        
        return f;
    }

    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);
        for (int i = 0; i < MissionMarkers.Length; i++)
            for (int j = 1; j < 3; j++)
            {
                string str = "changeArmy" + i.ToString() + "_" + (j).ToString();
                if (str.Equals(shortName))
                {
                    string armyOwner;
                    if (j == 1) { armyOwner = " Red army"; }
                    else { armyOwner = " Blue army"; }
                    GamePlay.gpHUDLogCenter("Airdrome: " + i.ToString() + " turn to " + armyOwner);
                    GamePlay.gpPostMissionLoad(CreateNewFrontLineMission(i, j));
                }
            }
        AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, shortName));
        if (action != null)
            action.Do();

    }
}

Last edited by Ataros; 05-06-2011 at 07:51 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 08:52 AM.


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