Code:
public class Mission : maddox.game.campaign.Mission
{
AiActor a1;
AiAircraft airc1;
int r = 1;
bool cmpl = false;
int cEnemy = 0;
int cFriendly = 0;
int cPlayer = 0;
int MySquad = 0;
string b, tx1;
string[] br = new string[100];
int cEnemyS,cFriendlyS, cPlayerS, MySquadS;
public override void OnActorDead(int missionNumber, string shortName, AiActor actor, List<DamagerScore> initiatorList)
{
if (actor is AiAircraft)
{
if (!(actor is AiAircraft))
return;
if (shortName.IndexOf("219Sqn",0) > 0) MySquad++;
if (actor.Army() == 2) cEnemy++;
if (actor.Army() == 1) cFriendly++;
if (actor.Army() == 2)
{
if (GamePlay.gpPlayer().Place() != null)
{
bool playerWin = false;
foreach (DamagerScore i in initiatorList)
{
if (i.initiator != null && i.initiator.Actor == GamePlay.gpPlayer().Place())
{
playerWin = true;
}
}
if (playerWin) cPlayer++;
}
}
SaveRezult (cmpl);
}
}
public static string USER_DOC_PATH = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
public static string FILE_PATH = USER_DOC_PATH + "../1C SoftClub/il-2 sturmovik cliffs of dover/mission/campaign/custom/campaign_Bristol_Beaufighter/";
private void SaveRezult (bool CComplite)
{
int n1 = 1;
int j = 0;
StreamReader f2 = new StreamReader(@USER_DOC_PATH + "../1C SoftClub/il-2 sturmovik cliffs of dover/mission/campaign/custom/campaign_Bristol_Beaufighter/m4.txt");
b = f2.ReadLine();
cEnemyS = Int32.Parse(b) + cEnemy;
b = f2.ReadLine();
cFriendlyS = Int32.Parse(b) + cFriendly;
b = f2.ReadLine();
MySquadS = Int32.Parse(b) + MySquad;
b = f2.ReadLine();
cPlayerS = Int32.Parse(b) + cPlayer;
f2.Close();
StreamWriter f3 = new StreamWriter(@USER_DOC_PATH + "../1C SoftClub/il-2 sturmovik cliffs of dover/mission/campaign/custom/campaign_Bristol_Beaufighter/m5.txt");
f3.WriteLine(String.Format("{0}", cEnemyS));
f3.WriteLine(String.Format("{0}", cFriendlyS));
f3.WriteLine(String.Format("{0}", MySquadS));
f3.WriteLine(String.Format("{0}", cPlayerS));
f3.Close();
StreamReader f1 = new StreamReader(@USER_DOC_PATH + "../1C SoftClub/il-2 sturmovik cliffs of dover/mission/campaign/custom/campaign_Bristol_Beaufighter/Bristol_Beaufighter_05.briefing");
do
{
b = f1.ReadLine();
br[n1++] = b;
}
while (b != "[2]") ;
f1.Close();
StreamWriter f = new StreamWriter(@USER_DOC_PATH + "../1C SoftClub/il-2 sturmovik cliffs of dover/mission/campaign/custom/campaign_Bristol_Beaufighter/Bristol_Beaufighter_05.briefing");
while (++j<n1) f.WriteLine(br[j]);
if (CComplite)
f.WriteLine("<Name>");
f.WriteLine("Success");
f.WriteLine("<Description>");
if (CComplite) f.WriteLine("mission tasks have been accomplished!");
else f.WriteLine("Mission tasks have not been completed!");
if (MySquad >0) f.WriteLine("RESULTS OF THE LAST MISSION:");
else f.WriteLine("Overal the RAF had good performance in the last mission.");
f.WriteLine(String.Format("RAF claims - {0} ", cEnemy));
f.WriteLine(String.Format("RAF losses - {0} ", cFriendly));
f.WriteLine(String.Format("Squadron losses - {0} ", MySquad));
f.WriteLine(String.Format("Personal claims - {0} ", cPlayer));
j = (cEnemy - cFriendly);
if (j<0) f.WriteLine("The RAF's performance in the battle has been unsatisfactory, losing more aircraft than the enemy.");
if (j==0)
{
if (cEnemy > 0) f.WriteLine("The losses of the RAF in the last battle were lower than those of the enemy, but the performance of our squadrons needs to improve, the friction battle favors the Luftwaffe, which has more aircraft.");
else f.WriteLine("The squad performed well." );
}
if (j > 0) f.WriteLine("The squadron's performance was not remarkable, review your tactics, gentlemen.");
f.WriteLine(tx1);
f.WriteLine(" ");
f.WriteLine("CAMPAIGN PROGRESS:");
f.WriteLine(String.Format("Luftwaffe losses - {0} ", cEnemyS));
f.WriteLine(String.Format("RAF losses - {0} ", cFriendlyS));
f.WriteLine(String.Format("Squadron losses - {0} ", MySquadS));
f.WriteLine(String.Format("Personal score - {0} ", cPlayerS));
f.WriteLine("[3]");
f.WriteLine("<Name>");
f.WriteLine("Failure");
f.WriteLine("<Description>");
if (CComplite) f.WriteLine("Mission tasks have been accomplished!");
else f.WriteLine("Mission tasks have not been completed!");
if (MySquad >0) f.WriteLine("RESULTS OF THE LAST MISSION:");
else f.WriteLine("Squadron perform well in the last mission. Keep going, gentlemen.");
f.WriteLine(String.Format("RAF claims - {0} ", cEnemy));
f.WriteLine(String.Format("RAF losses - {0} ", cFriendly));
f.WriteLine(String.Format("Squadron losses - {0} ", MySquad));
f.WriteLine(String.Format("Personal claims - {0} ", cPlayer));
j = (cEnemy - cFriendly);
if (j<0) f.WriteLine("The RAF's performance in the battle has been unsatisfactory, losing more aircraft than the enemy.");
if (j==0)
{
if (cEnemy > 0) f.WriteLine("The losses of the RAF in the last battle were lower than those of the enemy, but the performance of our squadrons needs to improve, the friction battle favors the Luftwaffe, which has more aircraft.");
else f.WriteLine("The squadron's performance was not remarkable, review your tactics, gentlemen.");
}
if (j > 0) f.WriteLine("The RAF has performed well, causing losses to the enemy in greater numbers than its own.");
f.WriteLine(tx1);
f.WriteLine(" ");
f.WriteLine("CAMPAIGN PROGRESS:");
f.WriteLine(String.Format("Luftwaffe losses - {0} ", cEnemyS));
f.WriteLine(String.Format("RAF losses - {0} ", cFriendlyS));
f.WriteLine(String.Format("Squadron losses - {0} ", MySquadS));
f.WriteLine(String.Format("Personal score - {0} ", cPlayerS));
f.WriteLine("<Slide>");
if (CComplite)
f.WriteLine("CampaignSuccess.jpg");
else f.WriteLine("CampaignFailure.jpg");
f.WriteLine("<Caption>");
f.Close();
}
Bookmarks