Begin building basic Allies 02 framework
This commit is contained in:
@@ -57,13 +57,13 @@ namespace OpenRA.Mods.RA.Missions
|
||||
static readonly string[] lastAttackWaveAddition = { "3tnk", "e1", "e1", "e1", "e1", "e2", "e2", "e2", "e2" };
|
||||
int currentAttackWaveFrameNumber;
|
||||
int currentAttackWave;
|
||||
const int einsteinChinookArrivesAtAttackWave = 5;
|
||||
const int EinsteinChinookAttackWave = 5;
|
||||
|
||||
const int labRange = 5;
|
||||
const string einsteinName = "einstein";
|
||||
const string tanyaName = "e7";
|
||||
const string chinookName = "tran";
|
||||
const string signalFlareName = "flare";
|
||||
const int LabClearRange = 5;
|
||||
const string EinsteinName = "einstein";
|
||||
const string TanyaName = "e7";
|
||||
const string ChinookName = "tran";
|
||||
const string SignalFlareName = "flare";
|
||||
|
||||
void DisplayObjective()
|
||||
{
|
||||
@@ -79,7 +79,6 @@ namespace OpenRA.Mods.RA.Missions
|
||||
}
|
||||
allies.WinState = WinState.Lost;
|
||||
Game.AddChatLine(Color.Red, "Mission failed", text);
|
||||
self.World.LocalShroud.Disabled = true;
|
||||
Sound.Play("misnlst1.aud", 5);
|
||||
}
|
||||
|
||||
@@ -91,7 +90,6 @@ namespace OpenRA.Mods.RA.Missions
|
||||
}
|
||||
allies.WinState = WinState.Won;
|
||||
Game.AddChatLine(Color.Blue, "Mission accomplished", text);
|
||||
self.World.LocalShroud.Disabled = true;
|
||||
Sound.Play("misnwon1.aud", 5);
|
||||
}
|
||||
|
||||
@@ -144,11 +142,11 @@ namespace OpenRA.Mods.RA.Missions
|
||||
SendAttackWave(self, attackWave);
|
||||
currentAttackWave++;
|
||||
currentAttackWaveFrameNumber = self.World.FrameNumber;
|
||||
if (currentAttackWave >= einsteinChinookArrivesAtAttackWave)
|
||||
if (currentAttackWave >= EinsteinChinookAttackWave)
|
||||
{
|
||||
SendAttackWave(self, lastAttackWaveAddition);
|
||||
}
|
||||
if (currentAttackWave == einsteinChinookArrivesAtAttackWave)
|
||||
if (currentAttackWave == EinsteinChinookAttackWave)
|
||||
{
|
||||
FlyEinsteinFromExtractionLZ(self);
|
||||
}
|
||||
@@ -178,7 +176,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
void SpawnSignalFlare(Actor self)
|
||||
{
|
||||
self.World.CreateActor(signalFlareName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZ.Location) });
|
||||
self.World.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZ.Location) });
|
||||
}
|
||||
|
||||
void SendAttackWave(Actor self, IEnumerable<string> wave)
|
||||
@@ -217,13 +215,13 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
bool AlliesControlLab(Actor self)
|
||||
{
|
||||
var units = UnitsNearActor(self, lab, labRange);
|
||||
var units = UnitsNearActor(self, lab, LabClearRange);
|
||||
return units.Any() && units.All(a => a.Owner == allies);
|
||||
}
|
||||
|
||||
void SpawnEinsteinAtLab(Actor self)
|
||||
{
|
||||
einstein = self.World.CreateActor(einsteinName, new TypeDictionary { new OwnerInit(allies), new LocationInit(lab.Location) });
|
||||
einstein = self.World.CreateActor(EinsteinName, new TypeDictionary { new OwnerInit(allies), new LocationInit(lab.Location) });
|
||||
einstein.QueueActivity(new Move.Move(lab.Location - new CVec(0, 2)));
|
||||
}
|
||||
|
||||
@@ -239,7 +237,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
void FlyEinsteinFromExtractionLZ(Actor self)
|
||||
{
|
||||
einsteinChinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZEntryPoint.Location) });
|
||||
einsteinChinook = self.World.CreateActor(ChinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZEntryPoint.Location) });
|
||||
einsteinChinook.QueueActivity(new HeliFly(extractionLZ.CenterLocation));
|
||||
einsteinChinook.QueueActivity(new Turn(0));
|
||||
einsteinChinook.QueueActivity(new HeliLand(true));
|
||||
@@ -251,8 +249,8 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
void FlyTanyaToInsertionLZ(Actor self)
|
||||
{
|
||||
tanya = self.World.CreateActor(false, tanyaName, new TypeDictionary { new OwnerInit(allies) });
|
||||
var chinook = self.World.CreateActor(chinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) });
|
||||
tanya = self.World.CreateActor(false, TanyaName, new TypeDictionary { new OwnerInit(allies) });
|
||||
var chinook = self.World.CreateActor(ChinookName, new TypeDictionary { new OwnerInit(allies), new LocationInit(insertionLZEntryPoint.Location) });
|
||||
chinook.Trait<Cargo>().Load(chinook, tanya);
|
||||
chinook.QueueActivity(new HeliFly(insertionLZ.CenterLocation));
|
||||
chinook.QueueActivity(new Turn(0));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -17,23 +18,87 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
class Allies02Script : IWorldLoaded, ITick
|
||||
{
|
||||
static readonly string[] objectives =
|
||||
{
|
||||
"Destroy the SAM sites. Tanya and Einstein must survive.",
|
||||
"Wait for the helicopter and extract Einstein. Tanya and Einstein must survive."
|
||||
};
|
||||
|
||||
int currentObjective;
|
||||
|
||||
Actor chinookHusk;
|
||||
Actor sam1;
|
||||
Actor sam2;
|
||||
Actor sam3;
|
||||
Actor sam4;
|
||||
Actor tanya;
|
||||
Actor einstein;
|
||||
|
||||
Player allies;
|
||||
Player allies1;
|
||||
Player allies2;
|
||||
Player soviets;
|
||||
|
||||
void DisplayObjective()
|
||||
{
|
||||
Game.AddChatLine(Color.LimeGreen, "Objective", objectives[currentObjective]);
|
||||
Sound.Play("bleep6.aud", 5);
|
||||
}
|
||||
|
||||
void MissionFailed(Actor self, string text)
|
||||
{
|
||||
if (allies1.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
allies1.WinState = allies2.WinState = WinState.Lost;
|
||||
Game.AddChatLine(Color.Red, "Mission failed", text);
|
||||
Sound.Play("misnlst1.aud", 5);
|
||||
}
|
||||
|
||||
void MissionAccomplished(Actor self, string text)
|
||||
{
|
||||
if (allies1.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
allies1.WinState = allies2.WinState = WinState.Won;
|
||||
Game.AddChatLine(Color.Blue, "Mission accomplished", text);
|
||||
Sound.Play("misnwon1.aud", 5);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
|
||||
// display current objective every so often
|
||||
if (self.World.FrameNumber % 1500 == 1)
|
||||
{
|
||||
DisplayObjective();
|
||||
}
|
||||
if (currentObjective == 0)
|
||||
{
|
||||
if (sam1.Destroyed && sam2.Destroyed && sam3.Destroyed && sam4.Destroyed)
|
||||
{
|
||||
currentObjective++;
|
||||
DisplayObjective();
|
||||
}
|
||||
}
|
||||
else if (currentObjective == 1)
|
||||
{
|
||||
|
||||
}
|
||||
if (tanya.Destroyed)
|
||||
{
|
||||
MissionFailed(self, "Tanya was killed.");
|
||||
}
|
||||
if (einstein.Destroyed)
|
||||
{
|
||||
MissionFailed(self, "Einstein was killed.");
|
||||
}
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
allies = w.Players.Single(p => p.InternalName == "Allies");
|
||||
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
||||
allies2 = w.Players.Single(p => p.InternalName == "Allies2");
|
||||
soviets = w.Players.Single(p => p.InternalName == "Soviets");
|
||||
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
chinookHusk = actors["ChinookHusk"];
|
||||
@@ -41,10 +106,13 @@ namespace OpenRA.Mods.RA.Missions
|
||||
sam2 = actors["SAM2"];
|
||||
sam3 = actors["SAM3"];
|
||||
sam4 = actors["SAM4"];
|
||||
tanya = actors["Tanya"];
|
||||
einstein = actors["Einstein"];
|
||||
w.WorldActor.Trait<Shroud>().Explore(w, sam1.Location, 2);
|
||||
w.WorldActor.Trait<Shroud>().Explore(w, sam2.Location, 2);
|
||||
w.WorldActor.Trait<Shroud>().Explore(w, sam3.Location, 2);
|
||||
w.WorldActor.Trait<Shroud>().Explore(w, sam4.Location, 2);
|
||||
Game.MoveViewport(chinookHusk.Location.ToFloat2());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user