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
  #11  
Old 10-20-2011, 09:49 AM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

I have a more general question which I hope someone can answer:

My mission loads submission with some parameters (attacker army, mission type, attack sector, etc), then gets trigger status, calculates mission results and shows results messages using the same parameters. It goes fine when submissions are loaded one by one.

I want to add different types of submissions and make them overlap in time. Naturally I have to store parameters of every submissions as different variables to prevent them mixing up.

How can I do this? Should I create a list for each parameter and send it to array when each new submission loads or there is a more elegant way to do this. I will not have more then 10 submissions going on simultaneously and do not have to create arrays with the length of total past submissions quantity.
Reply With Quote
  #12  
Old 10-20-2011, 01:56 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Make a class with all infos you need and then store the objects in a list.

For example :
Code:
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;

public class Mission : AMission
{
    public static string SubMissionsPath = @"missions\Multi\Dogfight\test\subs\";
    
    
    public class Mis
    {
        public string Missionfilename {get; set;}
        public string PathToMission { get; set; }
        public DateTime MissionBegin{get; set;}
        public DateTime MissionEnd{get; set;}
        public double MissionLengh{get; set;}
        public bool IsMissionRunning { get; set; }
    
        public Mis(string Filename, string Path, double Lengh)
        {
            this.Missionfilename = Filename;
            this.PathToMission = Path;
            this.MissionLengh = Lengh;
        }
    
    }

    public List<Mis> MissionPool = new List<Mis>()
    {
        new Mis ("Mission1.mis",SubMissionsPath ,1000.0),
        new Mis ("Mission2.mis",SubMissionsPath ,1000.0),
    };


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


        MissionNumberListener = -1;

        try
        {
            foreach (Mis mi in MissionPool)
                GamePlay.gpPostMissionLoad(mi.PathToMission + mi.Missionfilename);

        }
        catch
        {

            GamePlay.gpLogServer(null, "File not found", null);
        }
    }


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

    }
}

Last edited by FG28_Kodiak; 10-20-2011 at 02:13 PM.
Reply With Quote
  #13  
Old 10-20-2011, 04:40 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Thank yoг for a good example. I will try creating a class for my needs and will come back with more questions if any.

S!
Reply With Quote
  #14  
Old 10-21-2011, 02:41 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

I did the exercise, sure with many mistakes but will do some reading on classes creation to correct them.

However I am stuck in OnTrigger method completely.

I have several submissions running at the same time with the same filenames and the same trigger names. This happens because they are randomly loaded and the same submission can be loaded 2-4 times within an hour.

How can I identify which trigger of which submission is triggered OnTrigger? I number my missions as "mi.MisMissionNumber" but their numbers are different from OnTrigger "missionNumber".

The file is renamed to a .txt.

If you have time to answer other questions I will appreciate it.
Attached Files
File Type: txt class example2.cs.txt (7.7 KB, 4 views)

Last edited by Ataros; 10-21-2011 at 02:44 PM.
Reply With Quote
  #15  
Old 10-21-2011, 04:43 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Will take a look at it.

Short answers:
Code:
 public static string SubMissionsPath = @"missions\Multi\Dogfight\r_steppe\subs\";
    // is @ necessary here? did not use it in other missions.
With @ at the beginning you must not write \\ every time. The \ is a special character in C# (C, C++) and normaly for escape sequences \n newline for example. If you want to use \ in your string you must write \\ and to avoid the double use you can set a @ at the beginning of your string so \ is a normal character.

Code:
// what does this block do?
        public Mis(string Filename, string misType, int Lengh) // should I include all the above variables here?      
        {
            this.Missionfilename = Filename;  // You use mi.Missionfilename instead of mi.Filename in your example when load missions. Why?
            this.MissionLengh = Lengh;
            this.MissionType = misType;
            this.TrgWasTriggered = wasTriggered;
        }
this is a constructor of the class (you can also use more of them overloaded). It's usefull if you like to initialize more variables or making calculations etc.

So i can use
Code:
    public List<Mis> MissionPool = new List<Mis>()
    {
        new Mis ("Mission1.mis",SubMissionsPath ,1000.0),
        new Mis ("Mission2.mis",SubMissionsPath ,1000.0),
    };
to create several entries at one time.

// You use mi.Missionfilename instead of mi.Filename in your example when load missions. Why?
I use the public method Missionfilename to get access to the variable in the object. Filename is only used in the constructor to give the value to the variable Missionfilename.

More to come, must take a deeper look at it, but no time at the moment.
But it seems you think a bit too complicated
Reply With Quote
  #16  
Old 10-21-2011, 05:09 PM
Ataros Ataros is offline
Approved Member
 
Join Date: Jun 2010
Location: USSR
Posts: 2,439
Default

Quote:
Originally Posted by FG28_Kodiak View Post
Filename is only used in the constructor to give the value to the variable Missionfilename.
Does it mean I can initialize variables in this block, replacing e.g. Length with a value I want to assign?
this.MissionLengh = 30;

Ah, it looks like the only purpose of it is to allow data input like here:
Code:
  public List<Mis> MissionPool = new List<Mis>()
    {
        new Mis ("Mission1.mis",SubMissionsPath ,1000.0),
        new Mis ("Mission2.mis",SubMissionsPath ,1000.0),
    };
So when I create a new Mis I can enter data there from e.g. parsed filename in one line only, not having to use 3 lines like
mi.Missionfilename = ...;
mi.SubMissionsPath = ...;
mi.MissionLengh = ...;

Instead after parsing a file name I can:
Code:
string[] MisParams;
MisParams = (mi.Missionfilename).Split('_');

Mis mi = new Mis (MisParams[1], MisParams[2],MisParams[3]);
Thanks a lot!

Last edited by Ataros; 10-21-2011 at 05:30 PM.
Reply With Quote
  #17  
Old 05-20-2012, 03:45 PM
pupo162 pupo162 is offline
Approved Member
 
Join Date: Feb 2010
Posts: 1,188
Default

first sorry for bumping an old thread.

im facing an issue implementing a "similar" (based) on this method script.

my issue is, with multi-sit aircriaft. when you spawn in one of those and change seats with will result in decrease of 1 to the pool by each seat.


much of the following CODE is not mine (around 90%) so no credit for it. Credit goes for Ataros, Kodiak, and some other guys, i cant recall everyone i steal from


Quote:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using maddox.GP;
using maddox.game;
using maddox.game.world;
using part;
using System.Diagnostics;
using System.Collections;


public class Mission : AMission
{

//-------------SCORE---------------------------------------
int redscore = 0;
int bluescore = 0;
//-------------TEAMS--------------------------------------
const int ArmyRed = 1;
const int ArmyBlue = 2;
//-------------TIME----------------------------------------
private double timeValue = 60;
private double time;
private double timeValue2 = 600;
//----------------------------------------------


Dictionary<string, int> lwa = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.Bf-109E-3",6},
{"bob:Aircraft.Bf-109E-3B",2},
{"bob:Aircraft.Bf-109E-1",9999},
// {"bob:Aircraft.Bf-109E-4",0},
{"bob:Aircraft.Bf-109E-4B",0},
//{"bob:Aircraft.Bf-110C-4",0},
{"bob:Aircraft.Bf-110C-7",4},
{"bob:Aircraft.Ju-87B-2",9999},
{"bob:Aircraft.Ju-88A-1",4},
//{"bob:Aircraft.He-111H-2",0},
//{"bob:Aircraft.He-111P-2",0},
};


Dictionary<string, int> lwv = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.Bf-109E-3",60},
{"bob:Aircraft.Bf-109E-3B",24},
{"bob:Aircraft.Bf-109E-1",40},
{"bob:Aircraft.Bf-109E-4",50},
{"bob:Aircraft.Bf-109E-4B",24},
{"bob:Aircraft.Bf-110C-4",24},
{"bob:Aircraft.Bf-110C-7",24},
{"bob:Aircraft.Ju-87B-2",60},
{"bob:Aircraft.Ju-88A-1",40},
{"bob:Aircraft.He-111H-2",60},
{"bob:Aircraft.He-111P-2",20},
};


Dictionary<string, int> rafa = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.SpitfireMkI",6},
{"bob:Aircraft.SpitfireMkIa",4},
//{"bob:Aircraft.SpitfireMkIIa",0},
{"bob:Aircraft.HurricaneMkI",9999},
{"bob:Aircraft.HurricaneMkI_dH5-20",9999},
//{"bob:Aircraft.BlenheimMkIV",0},
//{"bob:Aircraft.SpitfireMkIIa",0},
};


Dictionary<string, int> rafv = new Dictionary<string, int>()
{
//Internaltypename, Startcount
{"bob:Aircraft.SpitfireMkIa",30},
{"bob:Aircraft.SpitfireMkI",60},
{"bob:Aircraft.HurricaneMkI",50},
{"bob:Aircraft.HurricaneMkI_dH5-20",50},
{"bob:Aircraft.BlenheimMkIV",40},
{"bob:Aircraft.SpitfireMkIIa",120},
};


//----------------------CLASS----------------------------
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
public override void OnBattleStarted()
{
base.OnBattleStarted();

//listen to events from all missions.
MissionNumberListener = -1;
}
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
public override void OnTickGame()
{
base.OnTickGame();




if (Time.current() >= time & Time.current() < 300)
{
GamePlay.gpHUDLogCenter("TIME UNTIL START: " + (5 - (time / 60)) + " minutes");
time = time + timeValue;
}




if (Time.current() > 300 & Time.current() < 310)
{
GamePlay.gpPostMissionLoad("missions/Multi/Dogfight/USL/mission1.mis");
GamePlay.gpHUDLogCenter("MISSION START! GO!");
//time = 300 + timeValue2;
time = 300 + 15;
}



if (Time.current() > time & Time.current() < 2400 & Time.current() > 300)
{
GamePlay.gpHUDLogCenter("Mission time: " + time / 60 + " minutes, score: reds-" + redscore + "blue-" + bluescore + "");
//time = time + timeValue2;
time = time + 30;
}



if (Time.current() >= time & Time.current() >= 3000 & Time.current() < 3600)
{
GamePlay.gpHUDLogCenter("TIME LEFT UNTILL MISSION END: " + (65 - (time / 60)) + " minutes, score: red- " + redscore + " blue- " + bluescore + "");
// time = time + 2 * timeValue;
time = time + 30;
}


if (Time.current() == 3600)
{
GamePlay.gpHUDLogCenter("MISSION IS OVER!");
}

}
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
private void destroyPlane(AiAircraft aircraft)
{
if (aircraft != null)
{
aircraft.Destroy();
}
}
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
private string SplitName(string tmpstring)
{

string[] temp = tmpstring.Split(':', '.', '_');

string lt = "";
string ausgabe = "";

ausgabe = temp[1] + ": ";

for (int i = 2; i < temp.Length; i++)
{
lt = temp[i] + " ";

ausgabe += lt;
}
return ausgabe;
}
//--------------------------------------------------------
//--------------------------------------------------------
//--------------------------------------------------------
public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
{
base.OnPlaceEnter(player, actor, placeIndex);

AiAircraft aircraft = actor as AiAircraft;

int value, CurrentCount = 0;

if (aircraft != null)


switch (aircraft.Army())
{
case 1:
if (rafa.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
CurrentCount = rafa[(actor as AiAircraft).InternalTypeName()];

if (CurrentCount <= 0)
{

GamePlay.gpHUDLogCenter(new Player[] { player }, "{0} not available", new object[] { SplitName((actor as AiAircraft).InternalTypeName()) });
Timeout(10, () =>
{ destroyPlane(actor as AiAircraft); });
}
else
{
rafa[(actor as AiAircraft).InternalTypeName()]--;
GamePlay.gpHUDLogCenter(new Player[] { player }, "{0} : " + CurrentCount + " left", new object[] { SplitName((actor as AiAircraft).InternalTypeName()) });
}
break;



case 2:
if (lwa.TryGetValue((actor as AiAircraft).InternalTypeName(), out value))
CurrentCount = lwa[(actor as AiAircraft).InternalTypeName()];

if (CurrentCount <= 0)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, " {0} not available", new object[] { SplitName((actor as AiAircraft).InternalTypeName()) });
Timeout(10, () =>
{ destroyPlane(actor as AiAircraft); });
}
else
{
lwa[(actor as AiAircraft).InternalTypeName()]--;
GamePlay.gpHUDLogCenter(new Player[] { player }, "{0} : " + CurrentCount + " left", new object[] { SplitName((actor as AiAircraft).InternalTypeName()) });
}
break;


}
}
Reply With Quote
  #18  
Old 05-20-2012, 05:50 PM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

You can check if a player is already in a plane

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

        int playercount = 0;
        
        if (actor != null && actor is AiAircraft)
        {
            AiAircraft aircraft = actor as AiAircraft;

            for (int i = 0; i < aircraft.Places(); i++)
            {
                if (aircraft.Player(i) != null)
                {
                    if (aircraft.Player(i) == player) playercount++;
                }
            }
        }


        if (playercount == 1) ..

    }
A Player can have two places in an aircraft (PlacePrimary() and PlaceSecondary()) so if playercount is > 1 (2 ) the player has changed his place in the aircraft.


or you check PlaceSecondary, PlaceSecondary is -1 if a player is 'new' in a plane, if not new PlaceSecondary gets the value of the last secondary place.
Code:
 if (player.PlaceSecondary() != -1)
            ..

Last edited by FG28_Kodiak; 05-20-2012 at 06:42 PM.
Reply With Quote
  #19  
Old 05-20-2012, 07:11 PM
Blackdog_kt Blackdog_kt is offline
Approved Member
 
Join Date: Jan 2008
Posts: 2,715
Default

A bit unrelated to the actual discussion, but what you say about primary and secondary places confirms my observations about AI gunners.

We all know that if you switch to a gunner position the AI no longer mans the turret. Flying a Blenheim on ATAG one night, i happened to find out completely by chance that if your aircraft has a bombardier position you can give back gun control to the AI: simply cycle between pilot and bombardier once and your gunners will revert to AI control.

This was also reflected on the net stats overlay, where next to my nickname i could see "pilot, gunner" initially and "pilot, bombardier" after cycling positions.

Thanks for confirming my suspicions
Reply With Quote
  #20  
Old 05-20-2012, 07:43 PM
pupo162 pupo162 is offline
Approved Member
 
Join Date: Feb 2010
Posts: 1,188
Default

thank you!

Worked like a charm!
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:15 AM.


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