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;
}
}
|
|