Add airbase and airbase secondary objective. Improve Soviet attacks. Enable players to capture sam sites as well as destroy them to complete the objective in Allies 02

This commit is contained in:
Scott_NZ
2012-11-03 21:41:46 +13:00
parent b2c5f488a7
commit 9238de6a47
4 changed files with 454 additions and 62 deletions

View File

@@ -236,7 +236,10 @@ namespace OpenRA.Mods.RA.Missions
} }
if (objectives[DestroySamSitesID].Status == ObjectiveStatus.InProgress) if (objectives[DestroySamSitesID].Status == ObjectiveStatus.InProgress)
{ {
if (sam1.Destroyed && sam2.Destroyed && sam3.Destroyed && sam4.Destroyed) if ((sam1.Destroyed || sam1.Owner != soviets) &&
(sam2.Destroyed || sam2.Owner != soviets) &&
(sam3.Destroyed || sam3.Owner != soviets) &&
(sam4.Destroyed || sam4.Owner != soviets))
{ {
objectives[DestroySamSitesID].Status = ObjectiveStatus.Completed; objectives[DestroySamSitesID].Status = ObjectiveStatus.Completed;
objectives[ExtractEinsteinID].Status = ObjectiveStatus.InProgress; objectives[ExtractEinsteinID].Status = ObjectiveStatus.InProgress;

View File

@@ -34,9 +34,12 @@ namespace OpenRA.Mods.RA.Missions
Dictionary<int, Objective> objectives = new Dictionary<int, Objective> Dictionary<int, Objective> objectives = new Dictionary<int, Objective>
{ {
{ EvacuateID, new Objective(ObjectiveType.Primary, "Following the rescue of Einstein, the Allies are now being flanked from both sides. Evacuate {0} units before the remaining Allied forces in the area are wiped out.".F(UnitsEvacuatedThreshold), ObjectiveStatus.InProgress) }, { EvacuateID, new Objective(ObjectiveType.Primary, "Following the rescue of Einstein, the Allies are now being flanked from both sides. Evacuate {0} units before the remaining Allied forces in the area are wiped out.".F(UnitsEvacuatedThreshold), ObjectiveStatus.InProgress) },
{ AirbaseID, new Objective(ObjectiveType.Secondary, "Destroy the nearby Soviet airbase.", ObjectiveStatus.InProgress) }
}; };
const int EvacuateID = 0; const int EvacuateID = 0;
const int AirbaseID = 1;
const int UnitsEvacuatedThreshold = 50; const int UnitsEvacuatedThreshold = 50;
int unitsEvacuated; int unitsEvacuated;
InfoWidget evacuateWidget; InfoWidget evacuateWidget;
@@ -69,13 +72,17 @@ namespace OpenRA.Mods.RA.Missions
Actor sovietRallyPoint5; Actor sovietRallyPoint5;
CPos[] sovietRallyPoints; CPos[] sovietRallyPoints;
static readonly string[] SovietVehicles = { "3tnk", "3tnk", "3tnk", "3tnk", "v2rl", "v2rl", "ftrk", "apc" }; Actor sovietAirfield1;
static readonly string[] SovietInfantry = { "e1", "e1", "e1", "e2", "e2", "e3", "e4" }; Actor sovietAirfield2;
Actor sovietAirfield3;
Actor sovietAirfield4;
static readonly string[] SovietVehicles = { "3tnk", "3tnk", "3tnk", "3tnk", "3tnk", "3tnk", "v2rl", "v2rl", "ftrk", "ftrk", "apc", "apc", "apc" };
const int SovietAttackGroupSize = 5;
const int YakTicks = 2000; const int YakTicks = 2000;
int attackAtFrame = 300; int attackAtFrame;
int attackAtFrameIncrement = 300; int attackAtFrameIncrement;
Actor allies1EntryPoint; Actor allies1EntryPoint;
Actor allies1MovePoint; Actor allies1MovePoint;
@@ -131,33 +138,48 @@ namespace OpenRA.Mods.RA.Missions
attackAtFrame += attackAtFrameIncrement; attackAtFrame += attackAtFrameIncrement;
attackAtFrameIncrement = Math.Max(attackAtFrameIncrement - 5, 100); attackAtFrameIncrement = Math.Max(attackAtFrameIncrement - 5, 100);
} }
if (world.FrameNumber % YakTicks == 1) if (world.FrameNumber % YakTicks == 1 && objectives[AirbaseID].Status != ObjectiveStatus.Completed)
{ {
AirStrafe(YakName); AirStrafe(YakName);
if (world.SharedRandom.Next(3) == 2)
{
AirStrafe(YakName);
}
} }
ManageSovietUnits(); ManageSovietUnits();
ManageSovietOre();
EvacuateAlliedUnits(exit1TopLeft.CenterLocation, exit1BottomRight.CenterLocation, exit1ExitPoint.Location); EvacuateAlliedUnits(exit1TopLeft.CenterLocation, exit1BottomRight.CenterLocation, exit1ExitPoint.Location);
EvacuateAlliedUnits(exit2TopLeft.CenterLocation, exit2BottomRight.CenterLocation, exit2ExitPoint.Location); EvacuateAlliedUnits(exit2TopLeft.CenterLocation, exit2BottomRight.CenterLocation, exit2ExitPoint.Location);
CheckSovietAirbase();
if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && a.IsInWorld && !a.IsDead() && ((a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))) if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && a.IsInWorld && !a.IsDead() && ((a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>())))
{ {
MissionFailed("The remaining Allied forces in the area have been wiped out."); MissionFailed("The remaining Allied forces in the area have been wiped out.");
} }
} }
void ManageSovietOre()
{
var res = soviets.PlayerActor.Trait<PlayerResources>();
res.TakeOre(res.Ore);
res.TakeCash(res.Cash);
}
void AirStrafe(string actor) void AirStrafe(string actor)
{ {
var spawnPoint = world.ChooseRandomEdgeCell(); var spawnPoint = world.ChooseRandomEdgeCell();
var aircraft = world.CreateActor(actor, new TypeDictionary var aircraft = world.Actors.Where(
{ a => a.HasTrait<AttackPlane>() && a.Trait<LimitedAmmo>().FullAmmo() && a.Trait<Plane>().Altitude == 0
new LocationInit(spawnPoint), && a.Owner == soviets && a.IsIdle && a.IsInWorld);
new OwnerInit(soviets), if (aircraft.Count() < 4)
new AltitudeInit(Rules.Info[actor].Traits.Get<PlaneInfo>().CruiseAltitude) {
}); var a = world.CreateActor(actor, new TypeDictionary
AirStrafe(aircraft); {
new LocationInit(spawnPoint),
new OwnerInit(soviets),
new AltitudeInit(Rules.Info[actor].Traits.Get<PlaneInfo>().CruiseAltitude)
});
aircraft = aircraft.Concat(new[] { a });
}
foreach (var a in aircraft)
{
AirStrafe(a);
}
} }
void AirStrafe(Actor aircraft) void AirStrafe(Actor aircraft)
@@ -176,25 +198,47 @@ namespace OpenRA.Mods.RA.Missions
} }
} }
void CheckSovietAirbase()
{
if (objectives[AirbaseID].Status != ObjectiveStatus.Completed &&
(sovietAirfield1.Destroyed || sovietAirfield1.Owner != soviets) &&
(sovietAirfield2.Destroyed || sovietAirfield2.Owner != soviets) &&
(sovietAirfield3.Destroyed || sovietAirfield3.Owner != soviets) &&
(sovietAirfield4.Destroyed || sovietAirfield4.Owner != soviets))
{
objectives[AirbaseID].Status = ObjectiveStatus.Completed;
OnObjectivesUpdated(true);
}
}
void SpawnSovietUnits() void SpawnSovietUnits()
{ {
var route = world.SharedRandom.Next(sovietEntryPoints.Length); var route = world.SharedRandom.Next(sovietEntryPoints.Length);
var spawnPoint = sovietEntryPoints[route]; var spawnPoint = sovietEntryPoints[route];
var rallyPoint = sovietRallyPoints[route]; var rallyPoint = sovietRallyPoints[route];
var unit = world.CreateActor(SovietVehicles.Concat(SovietInfantry).Random(world.SharedRandom), new TypeDictionary { new LocationInit(spawnPoint), new OwnerInit(soviets) }); var unit = world.CreateActor(SovietVehicles.Random(world.SharedRandom),
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(rallyPoint, 5))); new TypeDictionary { new LocationInit(spawnPoint), new OwnerInit(soviets) });
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(rallyPoint, 3)));
} }
void ManageSovietUnits() void ManageSovietUnits()
{ {
var units = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && u.IsIdle && u.HasTrait<Mobile>() && u.Owner == soviets); foreach (var rallyPoint in sovietRallyPoints)
foreach (var unit in units)
{ {
var enemies = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && (u.Owner == allies1 || u.Owner == allies2) && ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>())); var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(rallyPoint), 10)
var targetEnemy = enemies.OrderBy(u => (unit.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault(); .Where(u => u.IsIdle && u.HasTrait<Mobile>() && u.Owner == soviets);
if (targetEnemy != null) if (units.Count() >= SovietAttackGroupSize)
{ {
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(targetEnemy), 3))); foreach (var unit in units)
{
var enemies = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && (u.Owner == allies1 || u.Owner == allies2)
&& ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>()));
var targetEnemy = enemies.OrderBy(u => (unit.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault();
if (targetEnemy != null)
{
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(targetEnemy), 3)));
}
}
} }
} }
} }
@@ -240,7 +284,16 @@ namespace OpenRA.Mods.RA.Missions
unit.CancelActivity(); unit.CancelActivity();
unit.ChangeOwner(allies); unit.ChangeOwner(allies);
unit.QueueActivity(new Move.Move(exit)); unit.QueueActivity(new Move.Move(exit));
unit.QueueActivity(new CallFunc(() => { unitsEvacuated++; UpdateUnitsEvacuated(); })); unit.QueueActivity(new CallFunc(() =>
{
unitsEvacuated++;
var cargo = unit.TraitOrDefault<Cargo>();
if (cargo != null)
{
unitsEvacuated += cargo.Passengers.Count();
}
UpdateUnitsEvacuated();
}));
unit.QueueActivity(new RemoveSelf()); unit.QueueActivity(new RemoveSelf());
} }
} }
@@ -250,7 +303,12 @@ namespace OpenRA.Mods.RA.Missions
world = w; world = w;
allies1 = w.Players.Single(p => p.InternalName == "Allies1"); allies1 = w.Players.Single(p => p.InternalName == "Allies1");
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2"); allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
if (allies2 == null) if (allies2 != null)
{
attackAtFrame = 400;
attackAtFrameIncrement = 400;
}
else
{ {
allies2 = allies1; allies2 = allies1;
attackAtFrame = 500; attackAtFrame = 500;
@@ -281,6 +339,10 @@ namespace OpenRA.Mods.RA.Missions
sovietRallyPoint4 = actors["SovietRallyPoint4"]; sovietRallyPoint4 = actors["SovietRallyPoint4"];
sovietRallyPoint5 = actors["SovietRallyPoint5"]; sovietRallyPoint5 = actors["SovietRallyPoint5"];
sovietRallyPoints = new[] { sovietRallyPoint1, sovietRallyPoint2, sovietRallyPoint3, sovietRallyPoint4, sovietRallyPoint5 }.Select(p => p.Location).ToArray(); sovietRallyPoints = new[] { sovietRallyPoint1, sovietRallyPoint2, sovietRallyPoint3, sovietRallyPoint4, sovietRallyPoint5 }.Select(p => p.Location).ToArray();
sovietAirfield1 = actors["SovietAirfield1"];
sovietAirfield2 = actors["SovietAirfield2"];
sovietAirfield3 = actors["SovietAirfield3"];
sovietAirfield4 = actors["SovietAirfield4"];
if (w.LocalPlayer == null || w.LocalPlayer == allies1) if (w.LocalPlayer == null || w.LocalPlayer == allies1)
{ {
Game.MoveViewport(allies1EntryPoint.Location.ToFloat2()); Game.MoveViewport(allies1EntryPoint.Location.ToFloat2());

Binary file not shown.

View File

@@ -63,9 +63,9 @@ Players:
Enemies: Allies1,Allies2,Allies Enemies: Allies1,Allies2,Allies
Actors: Actors:
Actor11: t05 Actor239: dog
Location: 150,54 Location: 169,60
Owner: Neutral Owner: Soviets
Actor12: t08 Actor12: t08
Location: 163,57 Location: 163,57
Owner: Neutral Owner: Neutral
@@ -321,9 +321,9 @@ Actors:
Exit1BottomLeft: waypoint Exit1BottomLeft: waypoint
Location: 16,50 Location: 16,50
Owner: Neutral Owner: Neutral
Actor3: mine SovietAirfield4: afld
Location: 167,70 Location: 151,67
Owner: Neutral Owner: Soviets
Actor127: t05 Actor127: t05
Location: 17,21 Location: 17,21
Owner: Neutral Owner: Neutral
@@ -579,9 +579,9 @@ Actors:
Actor350: t10 Actor350: t10
Location: 87,22 Location: 87,22
Owner: Neutral Owner: Neutral
Actor299: t06 Actor17: proc
Location: 104,50 Location: 168,62
Owner: Neutral Owner: Soviets
Actor170: oilb Actor170: oilb
Location: 72,58 Location: 72,58
Owner: Neutral Owner: Neutral
@@ -756,9 +756,6 @@ Actors:
Actor390: t07 Actor390: t07
Location: 18,72 Location: 18,72
Owner: Neutral Owner: Neutral
Actor18: mine
Location: 100,48
Owner: Neutral
Actor767: t10 Actor767: t10
Location: 158,15 Location: 158,15
Owner: Neutral Owner: Neutral
@@ -789,9 +786,9 @@ Actors:
Actor796: t02 Actor796: t02
Location: 154,40 Location: 154,40
Owner: Neutral Owner: Neutral
Actor33: t05 SovietAirfield3: afld
Location: 156,67 Location: 154,67
Owner: Neutral Owner: Soviets
Actor383: t16 Actor383: t16
Location: 22,52 Location: 22,52
Owner: Neutral Owner: Neutral
@@ -804,9 +801,6 @@ Actors:
SovietEntryPoint5: waypoint SovietEntryPoint5: waypoint
Location: 130,79 Location: 130,79
Owner: Neutral Owner: Neutral
Actor17: mine
Location: 99,46
Owner: Neutral
Actor804: t13 Actor804: t13
Location: 125,68 Location: 125,68
Owner: Neutral Owner: Neutral
@@ -984,9 +978,6 @@ Actors:
Allies1MovePoint: waypoint Allies1MovePoint: waypoint
Location: 149,24 Location: 149,24
Owner: Neutral Owner: Neutral
Allies2MovePoint: waypoint
Location: 167,38
Owner: Neutral
Allies1EntryPoint: waypoint Allies1EntryPoint: waypoint
Location: 149,16 Location: 149,16
Owner: Neutral Owner: Neutral
@@ -1053,24 +1044,24 @@ Actors:
SovietRallyPoint5: waypoint SovietRallyPoint5: waypoint
Location: 131,63 Location: 131,63
Owner: Neutral Owner: Neutral
Actor19: oilb Actor152: brl3
Location: 154,59 Location: 157,66
Owner: Neutral Owner: Soviets
Actor22: oilb Actor151: barl
Location: 158,57 Location: 159,58
Owner: Neutral Owner: Soviets
Actor138: brl3 Actor138: brl3
Location: 154,58 Location: 154,58
Owner: Neutral Owner: Soviets
Actor144: brl3 Actor144: brl3
Location: 158,59
Owner: Neutral
Actor151: barl
Location: 159,59 Location: 159,59
Owner: Neutral Owner: Soviets
Actor152: barl Actor19: oilb
Location: 153,61 Location: 154,59
Owner: Neutral Owner: Soviets
Actor22: oilb
Location: 157,57
Owner: Soviets
Actor154: oilb Actor154: oilb
Location: 169,18 Location: 169,18
Owner: Neutral Owner: Neutral
@@ -1089,6 +1080,342 @@ Actors:
Actor183: powr Actor183: powr
Location: 3,34 Location: 3,34
Owner: Allies Owner: Allies
Actor185: e1
Location: 150,72
Owner: Soviets
Actor190: ftur
Location: 160,53
Owner: Soviets
Actor227: e3
Location: 157,54
Owner: Soviets
Actor225: e3
Location: 148,68
Owner: Soviets
Actor223: e1
Location: 163,55
Owner: Soviets
Actor209: fenc
Location: 156,52
Owner: Soviets
Actor200: e1
Location: 171,61
Owner: Soviets
Actor201: e2
Location: 165,64
Owner: Soviets
Actor222: e2
Location: 154,53
Owner: Soviets
Actor216: fenc
Location: 154,52
Owner: Soviets
Actor217: fenc
Location: 153,52
Owner: Soviets
Actor219: fenc
Location: 152,52
Owner: Soviets
Actor210: fenc
Location: 155,52
Owner: Soviets
Actor188: brl3
Location: 160,54
Owner: Soviets
Actor189: ftur
Location: 147,64
Owner: Soviets
Actor191: barl
Location: 160,55
Owner: Soviets
SovietAirfield1: afld
Location: 151,69
Owner: Soviets
SovietAirfield2: afld
Location: 154,69
Owner: Soviets
Actor228: e3
Location: 158,66
Owner: Soviets
Actor241: barl
Location: 157,67
Owner: Soviets
Actor242: barr
Location: 159,61
Owner: Soviets
Actor18: apwr
Location: 154,73
Owner: Soviets
Actor237: dog
Location: 151,62
Owner: Soviets
Actor11: e1
Location: 149,64
Owner: Soviets
Actor192: fenc
Location: 147,65
Owner: Soviets
Actor244: e1
Location: 160,60
Owner: Soviets
Actor245: fenc
Location: 63,33
Owner: Soviets
Actor206: fenc
Location: 158,53
Owner: Soviets
Actor229: apwr
Location: 150,73
Owner: Soviets
Actor230: 3tnk
Location: 157,60
Owner: Soviets
Actor231: dome
Location: 162,74
Owner: Soviets
Actor235: waypoint
Location: 147,51
Owner: Neutral
Actor205: fenc
Location: 159,53
Owner: Soviets
Actor207: fenc
Location: 158,52
Owner: Soviets
Actor208: fenc
Location: 157,52
Owner: Soviets
Actor204: fenc
Location: 147,70
Owner: Soviets
Actor193: fenc
Location: 147,66
Owner: Soviets
Actor195: fenc
Location: 147,67
Owner: Soviets
Actor197: fenc
Location: 146,67
Owner: Soviets
Actor199: fenc
Location: 146,69
Owner: Soviets
Actor198: fenc
Location: 146,68
Owner: Soviets
Actor202: fenc
Location: 147,69
Owner: Soviets
Actor258: fenc
Location: 63,34
Owner: Soviets
Actor259: fenc
Location: 63,35
Owner: Soviets
Actor260: fenc
Location: 63,36
Owner: Soviets
Actor261: fenc
Location: 64,36
Owner: Soviets
Actor262: fenc
Location: 64,37
Owner: Soviets
Actor263: fenc
Location: 65,37
Owner: Soviets
Actor265: fenc
Location: 66,37
Owner: Soviets
Actor266: fenc
Location: 66,38
Owner: Soviets
Actor270: fenc
Location: 66,39
Owner: Soviets
Actor272: fenc
Location: 66,40
Owner: Soviets
Actor275: fenc
Location: 66,41
Owner: Soviets
Actor276: fenc
Location: 65,41
Owner: Soviets
Actor277: fenc
Location: 64,41
Owner: Soviets
Actor281: fenc
Location: 64,42
Owner: Soviets
Actor282: ftur
Location: 68,38
Owner: Soviets
Actor285: e1
Location: 67,41
Owner: Soviets
Actor286: e1
Location: 68,35
Owner: Soviets
Actor288: e2
Location: 64,34
Owner: Soviets
Actor290: dog
Location: 67,42
Owner: Soviets
Actor292: e2
Location: 165,59
Owner: Soviets
Actor293: fenc
Location: 61,63
Owner: Soviets
Actor297: fenc
Location: 61,65
Owner: Soviets
Actor299: fenc
Location: 62,65
Owner: Soviets
Actor300: fenc
Location: 62,66
Owner: Soviets
Actor294: fenc
Location: 61,64
Owner: Soviets
Actor308: dog
Location: 61,67
Owner: Soviets
Actor304: fenc
Location: 62,70
Owner: Soviets
Actor305: fenc
Location: 62,71
Owner: Soviets
Actor306: fenc
Location: 62,72
Owner: Soviets
Actor301: ftur
Location: 64,66
Owner: Soviets
Actor309: e1
Location: 63,69
Owner: Soviets
Actor311: e1
Location: 62,67
Owner: Soviets
Actor313: ftur
Location: 130,29
Owner: Soviets
Actor318: v02
Location: 91,54
Owner: Neutral
Actor317: v01.sniper
Location: 96,54
Owner: Soviets
Actor316: e1
Location: 130,31
Owner: Soviets
Actor319: fenc
Location: 127,27
Owner: Soviets
Actor324: fenc
Location: 127,28
Owner: Soviets
Actor325: fenc
Location: 127,29
Owner: Soviets
Actor328: fenc
Location: 127,30
Owner: Soviets
Actor330: v04
Location: 101,54
Owner: Neutral
Actor332: v05
Location: 102,51
Owner: Neutral
Actor334: v06
Location: 91,60
Owner: Neutral
Actor336: v04
Location: 87,56
Owner: Neutral
Actor337: v07
Location: 106,55
Owner: Neutral
Actor339: v09
Location: 92,53
Owner: Neutral
Actor340: v10
Location: 94,53
Owner: Neutral
Actor341: wood
Location: 100,49
Owner: Neutral
Actor342: wood
Location: 99,49
Owner: Neutral
Actor343: wood
Location: 98,49
Owner: Neutral
Actor344: wood
Location: 97,49
Owner: Neutral
Actor347: wood
Location: 96,49
Owner: Neutral
Actor348: wood
Location: 95,49
Owner: Neutral
Actor349: wood
Location: 94,49
Owner: Neutral
Actor351: wood
Location: 93,49
Owner: Neutral
Actor353: wood
Location: 92,49
Owner: Neutral
Actor355: wood
Location: 91,49
Owner: Neutral
Actor358: v17
Location: 91,62
Owner: Neutral
Actor357: tc05
Location: 88,48
Owner: Neutral
Allies2MovePoint: waypoint
Location: 167,38
Owner: Neutral
Actor359: powr
Location: 104,4
Owner: Soviets
Actor361: powr
Location: 106,4
Owner: Soviets
Actor362: powr
Location: 104,7
Owner: Soviets
Actor413: powr
Location: 106,7
Owner: Soviets
Actor414: e1
Location: 98,58
Owner: Soviets
Actor415: e1
Location: 90,56
Owner: Soviets
Actor416: dog
Location: 97,57
Owner: Soviets
Actor417: e1
Location: 98,52
Owner: Soviets
Actor3: silo
Location: 172,59
Owner: Soviets
Actor33: kenn
Location: 162,67
Owner: Soviets
Smudges: Smudges: