Add base guard, hind and second objective
This commit is contained in:
@@ -8,10 +8,14 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Traits;
|
||||
@@ -28,11 +32,13 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
Dictionary<int, Objective> objectives = new Dictionary<int, Objective>
|
||||
{
|
||||
{ InfilitrateID, new Objective(ObjectiveType.Primary, Infiltrate, ObjectiveStatus.InProgress) }
|
||||
{ InfiltrateID, new Objective(ObjectiveType.Primary, "", ObjectiveStatus.InProgress) },
|
||||
{ DestroyID, new Objective(ObjectiveType.Primary, "Secure the Soviet research laboratory and destroy the rest of the Soviet base.", ObjectiveStatus.Inactive) }
|
||||
};
|
||||
|
||||
const int InfilitrateID = 0;
|
||||
const string Infiltrate = "The Soviets are currently developing a new defensive system named the \"Iron Curtain\" at their main research laboratories. Get our Spy into their main research laboratories.";
|
||||
const int InfiltrateID = 0;
|
||||
const int DestroyID = 1;
|
||||
const string Infiltrate = "The Soviets are currently developing a new defensive system named the \"Iron Curtain\" at their main research laboratories. Get our {0} into the Soviet research laboratories undetected.";
|
||||
|
||||
Actor lstEntryPoint;
|
||||
Actor lstUnloadPoint;
|
||||
@@ -41,11 +47,14 @@ namespace OpenRA.Mods.RA.Missions
|
||||
Actor baseGuard;
|
||||
Actor baseGuardMovePos;
|
||||
Actor baseGuardTruckPos;
|
||||
int baseGuardWait = 100;
|
||||
bool baseGuardMoved;
|
||||
Actor lab;
|
||||
int baseGuardTicks = 100;
|
||||
|
||||
Actor allies1Spy;
|
||||
Actor allies2Spy;
|
||||
bool allies1SpyInfiltratedLab;
|
||||
bool allies2SpyInfiltratedLab;
|
||||
int frameInfiltrated = -1;
|
||||
|
||||
Player allies;
|
||||
Player allies1;
|
||||
@@ -72,12 +81,58 @@ namespace OpenRA.Mods.RA.Missions
|
||||
CPos[] patrolPoints5;
|
||||
int currentPatrolPoint5;
|
||||
|
||||
CPos hind1EntryPoint;
|
||||
PPos[] hind1Points;
|
||||
CPos hind1ExitPoint;
|
||||
|
||||
Actor reinforcementsEntryPoint;
|
||||
Actor reinforcementsUnloadPoint;
|
||||
|
||||
void MissionFailed(string text)
|
||||
{
|
||||
if (allies1.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
allies1.WinState = allies2.WinState = WinState.Lost;
|
||||
foreach (var actor in world.Actors.Where(a => a.IsInWorld && (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead()))
|
||||
{
|
||||
actor.Kill(actor);
|
||||
}
|
||||
Game.AddChatLine(Color.Red, "Mission failed", text);
|
||||
Sound.Play("misnlst1.aud");
|
||||
}
|
||||
|
||||
void MissionAccomplished(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");
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (allies1.WinState != WinState.Undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (world.FrameNumber == 1)
|
||||
{
|
||||
InsertSpies();
|
||||
}
|
||||
if (world.FrameNumber == 600)
|
||||
{
|
||||
SendHind(hind1EntryPoint, hind1Points, hind1ExitPoint);
|
||||
}
|
||||
if (frameInfiltrated != -1 && world.FrameNumber == frameInfiltrated + 100)
|
||||
{
|
||||
Sound.Play("aarrivs1.aud");
|
||||
world.AddFrameEndTask(w => SendReinforcements());
|
||||
}
|
||||
PatrolTick(ref patrol1, ref currentPatrolPoint1, soviets, DogPatrol, patrolPoints1);
|
||||
PatrolTick(ref patrol2, ref currentPatrolPoint2, soviets, InfantryPatrol, patrolPoints2);
|
||||
PatrolTick(ref patrol3, ref currentPatrolPoint3, soviets, DogPatrol, patrolPoints3);
|
||||
@@ -85,6 +140,29 @@ namespace OpenRA.Mods.RA.Missions
|
||||
PatrolTick(ref patrol5, ref currentPatrolPoint5, soviets, DogPatrol, patrolPoints5);
|
||||
ManageSovietOre();
|
||||
BaseGuardTick();
|
||||
if (allies1Spy.IsDead() || (allies2Spy != null && allies2Spy.IsDead()))
|
||||
{
|
||||
objectives[InfiltrateID].Status = ObjectiveStatus.Failed;
|
||||
OnObjectivesUpdated(true);
|
||||
MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The"));
|
||||
}
|
||||
else if (lab.Destroyed)
|
||||
{
|
||||
MissionFailed("The research laboratory was destroyed.");
|
||||
}
|
||||
else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead() && (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))
|
||||
{
|
||||
objectives[DestroyID].Status = ObjectiveStatus.Failed;
|
||||
OnObjectivesUpdated(true);
|
||||
MissionFailed("The remaining Allied forces in the area have been wiped out.");
|
||||
}
|
||||
else if (!world.Actors.Any(a => a.Owner == soviets && a.IsInWorld && !a.IsDead() && a.HasTrait<Building>() && !a.HasTrait<Wall>() && a != lab)
|
||||
&& objectives[InfiltrateID].Status == ObjectiveStatus.Completed)
|
||||
{
|
||||
objectives[DestroyID].Status = ObjectiveStatus.Completed;
|
||||
OnObjectivesUpdated(true);
|
||||
MissionAccomplished("The Soviet research laboratory has been secured successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
void ManageSovietOre()
|
||||
@@ -96,21 +174,54 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
void BaseGuardTick()
|
||||
{
|
||||
if (!baseGuardMoved && !baseGuard.IsDead() && baseGuard.IsInWorld)
|
||||
if (baseGuardTicks <= 0 || baseGuard.IsDead() || !baseGuard.IsInWorld)
|
||||
{
|
||||
if (hijackTruck.Location == baseGuardTruckPos.Location)
|
||||
return;
|
||||
}
|
||||
if (hijackTruck.Location == baseGuardTruckPos.Location)
|
||||
{
|
||||
if (--baseGuardTicks <= 0)
|
||||
{
|
||||
if (--baseGuardWait <= 0)
|
||||
{
|
||||
baseGuard.QueueActivity(new Move.Move(baseGuardMovePos.Location));
|
||||
baseGuardMoved = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
baseGuardWait = 100;
|
||||
baseGuard.QueueActivity(new Move.Move(baseGuardMovePos.Location));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
baseGuardTicks = 100;
|
||||
}
|
||||
}
|
||||
|
||||
void OnLabInfiltrated(Actor spy)
|
||||
{
|
||||
if (spy == allies1Spy) { allies1SpyInfiltratedLab = true; }
|
||||
else if (spy == allies2Spy) { allies2SpyInfiltratedLab = true; }
|
||||
if (allies1SpyInfiltratedLab && (allies2SpyInfiltratedLab || allies2Spy == null))
|
||||
{
|
||||
objectives[InfiltrateID].Status = ObjectiveStatus.Completed;
|
||||
objectives[DestroyID].Status = ObjectiveStatus.InProgress;
|
||||
OnObjectivesUpdated(true);
|
||||
frameInfiltrated = world.FrameNumber;
|
||||
}
|
||||
}
|
||||
|
||||
void SendReinforcements()
|
||||
{
|
||||
var lst = world.CreateActor("lst", new TypeDictionary
|
||||
{
|
||||
new OwnerInit(allies1),
|
||||
new LocationInit(reinforcementsEntryPoint.Location)
|
||||
});
|
||||
lst.Trait<Cargo>().Load(lst, world.CreateActor(false, "mcv", new TypeDictionary { new OwnerInit(allies1) } ));
|
||||
if (allies1 != allies2)
|
||||
{
|
||||
lst.Trait<Cargo>().Load(lst, world.CreateActor(false, "mcv", new TypeDictionary { new OwnerInit(allies2) }));
|
||||
}
|
||||
lst.QueueActivity(new Move.Move(reinforcementsUnloadPoint.Location));
|
||||
lst.QueueActivity(new Wait(10));
|
||||
lst.QueueActivity(new UnloadCargo(true));
|
||||
lst.QueueActivity(new Wait(10));
|
||||
lst.QueueActivity(new Move.Move(reinforcementsEntryPoint.Location));
|
||||
lst.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
|
||||
void PatrolTick(ref Actor[] patrolActors, ref int currentPoint, Player owner, string[] actorNames, CPos[] points)
|
||||
@@ -134,6 +245,22 @@ namespace OpenRA.Mods.RA.Missions
|
||||
}
|
||||
}
|
||||
|
||||
void SendHind(CPos start, IEnumerable<PPos> points, CPos exit)
|
||||
{
|
||||
var hind = world.CreateActor("hind", new TypeDictionary
|
||||
{
|
||||
new OwnerInit(soviets),
|
||||
new LocationInit(start),
|
||||
new FacingInit(Util.GetFacing(points.First().ToCPos() - start, 0)),
|
||||
new AltitudeInit(Rules.Info["hind"].Traits.Get<HelicopterInfo>().CruiseAltitude),
|
||||
});
|
||||
foreach (var point in points.Concat(new[] { Util.CenterOfCell(exit) }))
|
||||
{
|
||||
hind.QueueActivity(new AttackMove.AttackMoveActivity(hind, new HeliFly(point)));
|
||||
}
|
||||
hind.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
|
||||
void InsertSpies()
|
||||
{
|
||||
var lst = world.CreateActor("lst", new TypeDictionary
|
||||
@@ -190,7 +317,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
baseGuard = actors["BaseGuard"];
|
||||
baseGuardMovePos = actors["BaseGuardMovePos"];
|
||||
baseGuardTruckPos = actors["BaseGuardTruckPos"];
|
||||
patrolPoints1 = new[]
|
||||
patrolPoints1 = new[]
|
||||
{
|
||||
actors["PatrolPoint11"].Location,
|
||||
actors["PatrolPoint12"].Location,
|
||||
@@ -199,7 +326,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
actors["PatrolPoint15"].Location
|
||||
};
|
||||
patrolPoints2 = patrolPoints1;
|
||||
patrolPoints3 = new[]
|
||||
patrolPoints3 = new[]
|
||||
{
|
||||
actors["PatrolPoint21"].Location,
|
||||
actors["PatrolPoint22"].Location,
|
||||
@@ -207,14 +334,14 @@ namespace OpenRA.Mods.RA.Missions
|
||||
actors["PatrolPoint24"].Location,
|
||||
actors["PatrolPoint25"].Location
|
||||
};
|
||||
patrolPoints4 = new[]
|
||||
patrolPoints4 = new[]
|
||||
{
|
||||
actors["PatrolPoint31"].Location,
|
||||
actors["PatrolPoint32"].Location,
|
||||
actors["PatrolPoint33"].Location,
|
||||
actors["PatrolPoint34"].Location
|
||||
};
|
||||
patrolPoints5 = new[]
|
||||
patrolPoints5 = new[]
|
||||
{
|
||||
actors["PatrolPoint41"].Location,
|
||||
actors["PatrolPoint42"].Location,
|
||||
@@ -222,6 +349,19 @@ namespace OpenRA.Mods.RA.Missions
|
||||
actors["PatrolPoint44"].Location,
|
||||
actors["PatrolPoint45"].Location
|
||||
};
|
||||
lab = actors["Lab"];
|
||||
lab.AddTrait(new Allies04InfiltrateAction(OnLabInfiltrated));
|
||||
hind1EntryPoint = actors["Hind1EntryPoint"].Location;
|
||||
hind1Points = new[]
|
||||
{
|
||||
actors["Hind1Point1"].CenterLocation,
|
||||
actors["Hind1Point2"].CenterLocation
|
||||
};
|
||||
hind1ExitPoint = actors["Hind1ExitPoint"].Location;
|
||||
reinforcementsEntryPoint = actors["ReinforcementsEntryPoint"];
|
||||
reinforcementsUnloadPoint = actors["ReinforcementsUnloadPoint"];
|
||||
objectives[InfiltrateID].Text = Infiltrate.F(allies1 != allies2 ? "spies" : "spy");
|
||||
OnObjectivesUpdated(false);
|
||||
SetupSubStances();
|
||||
Game.MoveViewport(lstEntryPoint.Location.ToFloat2());
|
||||
PlayMusic();
|
||||
@@ -305,4 +445,19 @@ namespace OpenRA.Mods.RA.Missions
|
||||
return r.Select(a => a.WithPalette(Palette(hijackable.OldOwner)));
|
||||
}
|
||||
}
|
||||
|
||||
class Allies04InfiltrateAction : IAcceptSpy
|
||||
{
|
||||
Action<Actor> a;
|
||||
|
||||
public Allies04InfiltrateAction(Action<Actor> a)
|
||||
{
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public void OnInfiltrate(Actor self, Actor spy)
|
||||
{
|
||||
a(spy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user