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 05-20-2012, 04: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
  #2  
Old 05-20-2012, 06: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 07:42 PM.
Reply With Quote
  #3  
Old 05-20-2012, 08: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
  #4  
Old 05-20-2012, 08: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
  #5  
Old 05-22-2012, 08:57 PM
pupo162 pupo162 is offline
Approved Member
 
Join Date: Feb 2010
Posts: 1,188
Default

Hi, still on the same topic, yet a differente type of code, im tryign to get a submenu to have an option to refly.

code

Quote:
public override void OnOrderMissionMenuSelected(Player player, int ID, int menuItemIndex)
{
base.OnOrderMissionMenuSelected(player, ID, menuItemIndex);

if (player != null)
{
if (menuItemIndex == 1)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, "Red - {0} blue - {1}", new object[] { redscore, bluescore });

}
if (menuItemIndex == 2)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, "Ainda nao funciona");
}
if (menuItemIndex == 3)
{
GamePlay.gpHUDLogCenter(new Player[] { player }, "You will refly in 5 seconds!");
Timeout(20, () =>
{ destroyPlane(aircraft); });
}
}
}
The clear problem is, aircraft used in destroy plane, does not exist i nthis function, pnly player. how do i get over this?

sorry, but im really noob in C#
Reply With Quote
  #6  
Old 05-23-2012, 08:02 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

you get the Aircraft via player.Place()

Code:
if (player.Place() != null && player.Place() is AiAircraft)
{
        AiAircraft aircraft = player.Place() as AiAircraft;

        
}
Reply With Quote
  #7  
Old 05-23-2012, 10:53 AM
pupo162 pupo162 is offline
Approved Member
 
Join Date: Feb 2010
Posts: 1,188
Default

Thnak you Kodiak, will try that when i get home.

Where do you get all of this info? of what info is stored in wich class? and wich classes can be converted to others?

from trial and error, and from seeing other people i get to learn some of them ( actor can be used as aircraft and such), but where does this knowledge comes from? trial and error?
Reply With Quote
  #8  
Old 05-23-2012, 11:04 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Object-Explorer in Visual Studio and try and error (sometimes Cliffs don't react as expected ).
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 06:43 AM.


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