Tidy campaign stuff

This commit is contained in:
Scott_NZ
2013-01-21 20:05:08 +13:00
parent 32830da3c2
commit 12e1a531fe
8 changed files with 186 additions and 255 deletions

View File

@@ -9,13 +9,11 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Air; using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using OpenRA.Network;
using OpenRA.Scripting; using OpenRA.Scripting;
using OpenRA.Traits; using OpenRA.Traits;
@@ -90,31 +88,16 @@ namespace OpenRA.Mods.RA.Missions
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (allies.WinState != WinState.Undefined) if (allies.WinState != WinState.Undefined) return;
{
return;
}
if (world.FrameNumber % 1000 == 0) if (world.FrameNumber % 1000 == 0)
{
Sound.Play(Taunts[world.SharedRandom.Next(Taunts.Length)]); Sound.Play(Taunts[world.SharedRandom.Next(Taunts.Length)]);
}
if (objectives[FindEinsteinID].Status == ObjectiveStatus.InProgress) if (objectives[FindEinsteinID].Status == ObjectiveStatus.InProgress)
{ {
if (AlliesControlLab()) if (AlliesControlLab())
{ LabSecured();
SpawnSignalFlare();
Sound.Play("flaren1.aud");
SpawnEinsteinAtLab();
SendShips();
objectives[FindEinsteinID].Status = ObjectiveStatus.Completed;
objectives[ExtractEinsteinID].Status = ObjectiveStatus.InProgress;
if (difficulty == "Easy")
{
ExtractEinsteinAtLZ();
}
OnObjectivesUpdated(true);
currentAttackWaveFrameNumber = world.FrameNumber;
}
if (lab.Destroyed) if (lab.Destroyed)
{ {
objectives[FindEinsteinID].Status = ObjectiveStatus.Failed; objectives[FindEinsteinID].Status = ObjectiveStatus.Failed;
@@ -126,21 +109,19 @@ namespace OpenRA.Mods.RA.Missions
{ {
if (difficulty != "Easy") if (difficulty != "Easy")
{ {
SendAttackWave(); ManageSovietUnits();
if (world.FrameNumber >= currentAttackWaveFrameNumber + 600) if (world.FrameNumber >= currentAttackWaveFrameNumber + 600)
{ {
Sound.Play("enmyapp1.aud"); Sound.Play("enmyapp1.aud");
SpawnAttackWave(AttackWave); SpawnSovietUnits(AttackWave);
currentAttackWave++; currentAttackWave++;
currentAttackWaveFrameNumber = world.FrameNumber; currentAttackWaveFrameNumber = world.FrameNumber;
if (currentAttackWave >= EinsteinChinookAttackWave) if (currentAttackWave >= EinsteinChinookAttackWave)
{ SpawnSovietUnits(LastAttackWaveAddition);
SpawnAttackWave(LastAttackWaveAddition);
}
if (currentAttackWave == EinsteinChinookAttackWave) if (currentAttackWave == EinsteinChinookAttackWave)
{
ExtractEinsteinAtLZ(); ExtractEinsteinAtLZ();
}
} }
} }
if (einsteinChinook != null) if (einsteinChinook != null)
@@ -159,24 +140,38 @@ namespace OpenRA.Mods.RA.Missions
} }
} }
} }
if (tanya != null && tanya.Destroyed) if (tanya != null && tanya.Destroyed)
{
MissionFailed("Tanya was killed."); MissionFailed("Tanya was killed.");
}
else if (einstein != null && einstein.Destroyed) else if (einstein != null && einstein.Destroyed)
{
MissionFailed("Einstein was killed."); MissionFailed("Einstein was killed.");
}
ManageSovietOre(); ManageSovietOre();
} }
void LabSecured()
{
SpawnSignalFlare();
Sound.Play("flaren1.aud");
SpawnEinsteinAtLab();
SendShips();
objectives[FindEinsteinID].Status = ObjectiveStatus.Completed;
objectives[ExtractEinsteinID].Status = ObjectiveStatus.InProgress;
if (difficulty == "Easy")
ExtractEinsteinAtLZ();
OnObjectivesUpdated(true);
currentAttackWaveFrameNumber = world.FrameNumber;
}
void ManageSovietOre() void ManageSovietOre()
{ {
var res = soviets.PlayerActor.Trait<PlayerResources>(); var res = soviets.PlayerActor.Trait<PlayerResources>();
if (res.Ore > res.OreCapacity * 0.8) if (res.Ore > res.OreCapacity * 0.8)
{
res.TakeOre(res.OreCapacity / 10); res.TakeOre(res.OreCapacity / 10);
}
} }
void SpawnSignalFlare() void SpawnSignalFlare()
@@ -184,7 +179,7 @@ namespace OpenRA.Mods.RA.Missions
world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZ.Location) }); world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies), new LocationInit(extractionLZ.Location) });
} }
void SpawnAttackWave(IEnumerable<string> wave) void SpawnSovietUnits(IEnumerable<string> wave)
{ {
foreach (var unit in wave) foreach (var unit in wave)
{ {
@@ -193,7 +188,7 @@ namespace OpenRA.Mods.RA.Missions
} }
} }
void SendAttackWave() void ManageSovietUnits()
{ {
foreach (var unit in world.Actors.Where(a => a != world.WorldActor && a.IsInWorld && a.Owner == soviets && !a.IsDead() && a.IsIdle foreach (var unit in world.Actors.Where(a => a != world.WorldActor && a.IsInWorld && a.Owner == soviets && !a.IsDead() && a.IsIdle
&& a.HasTrait<Mobile>() && a.HasTrait<AttackBase>())) && a.HasTrait<Mobile>() && a.HasTrait<AttackBase>()))
@@ -202,20 +197,17 @@ namespace OpenRA.Mods.RA.Missions
if (einstein != null) if (einstein != null)
{ {
if (einstein.IsInWorld) if (einstein.IsInWorld)
{
innerActivity = new Attack(Target.FromActor(einstein), 3); innerActivity = new Attack(Target.FromActor(einstein), 3);
}
else else
{ {
var container = world.UnitContaining(einstein); var container = world.UnitContaining(einstein);
if (container != null && !container.HasTrait<Aircraft>() && container.HasTrait<Mobile>()) if (container != null && !container.HasTrait<Aircraft>() && container.HasTrait<Mobile>())
{
innerActivity = new Attack(Target.FromActor(container), 3); innerActivity = new Attack(Target.FromActor(container), 3);
}
else else
{
innerActivity = new Move.Move(extractionLZ.Location, 3); innerActivity = new Move.Move(extractionLZ.Location, 3);
}
} }
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, innerActivity)); unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, innerActivity));
} }
@@ -225,10 +217,12 @@ namespace OpenRA.Mods.RA.Missions
void SendPatrol() void SendPatrol()
{ {
for (int i = 0; i < Patrol.Length; i++) for (int i = 0; i < Patrol.Length; i++)
{ world.CreateActor(Patrol[i], new TypeDictionary
var actor = world.CreateActor(Patrol[i], new TypeDictionary { new OwnerInit(soviets), new LocationInit(insertionLZ.Location + new CVec(-1 + i, 10 + i * 2)) }); {
actor.QueueActivity(new Move.Move(insertionLZ.Location)); new OwnerInit(soviets),
} new LocationInit(insertionLZ.Location + new CVec(-1 + i, 10 + i * 2))
})
.QueueActivity(new Move.Move(insertionLZ.Location));
} }
bool AlliesControlLab() bool AlliesControlLab()
@@ -245,11 +239,12 @@ namespace OpenRA.Mods.RA.Missions
void SendShips() void SendShips()
{ {
for (int i = 0; i < Ships.Length; i++) for (int i = 0; i < Ships.Length; i++)
{ world.CreateActor(Ships[i], new TypeDictionary
var actor = world.CreateActor(Ships[i], {
new TypeDictionary { new OwnerInit(allies), new LocationInit(shipSpawnPoint.Location + new CVec(i * 2, 0)) }); new OwnerInit(allies),
actor.QueueActivity(new Move.Move(shipMovePoint.Location + new CVec(i * 4, 0))); new LocationInit(shipSpawnPoint.Location + new CVec(i * 2, 0))
} })
.QueueActivity(new Move.Move(shipMovePoint.Location + new CVec(i * 4, 0)));
} }
void ExtractEinsteinAtLZ() void ExtractEinsteinAtLZ()
@@ -282,9 +277,7 @@ namespace OpenRA.Mods.RA.Missions
void SetAlliedUnitsToDefensiveStance() void SetAlliedUnitsToDefensiveStance()
{ {
foreach (var actor in world.Actors.Where(a => a.IsInWorld && a.Owner == allies && !a.IsDead() && a.HasTrait<AutoTarget>())) foreach (var actor in world.Actors.Where(a => a.IsInWorld && a.Owner == allies && !a.IsDead() && a.HasTrait<AutoTarget>()))
{
actor.Trait<AutoTarget>().stance = UnitStance.Defend; actor.Trait<AutoTarget>().stance = UnitStance.Defend;
}
} }
public void WorldLoaded(World w) public void WorldLoaded(World w)
@@ -317,17 +310,14 @@ namespace OpenRA.Mods.RA.Missions
Game.MoveViewport(insertionLZ.Location.ToFloat2()); Game.MoveViewport(insertionLZ.Location.ToFloat2());
if (MissionUtils.IsSingleClient(world)) if (MissionUtils.IsSingleClient(world))
{
Media.PlayFMVFullscreen(w, "ally1.vqa", () => Media.PlayFMVFullscreen(w, "ally1.vqa", () =>
{
Media.PlayFMVFullscreen(w, "landing.vqa", () => Media.PlayFMVFullscreen(w, "landing.vqa", () =>
{ {
InsertTanyaAtLZ(); InsertTanyaAtLZ();
SendPatrol(); SendPatrol();
MissionUtils.PlayMissionMusic(); MissionUtils.PlayMissionMusic();
}); })
}); );
}
else else
{ {
InsertTanyaAtLZ(); InsertTanyaAtLZ();

View File

@@ -9,7 +9,6 @@
#endregion #endregion
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
@@ -17,7 +16,6 @@ using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using OpenRA.Network;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -144,9 +142,7 @@ namespace OpenRA.Mods.RA.Missions
{ {
MissionUtils.CoopMissionFailed(world, text, allies1, allies2); MissionUtils.CoopMissionFailed(world, text, allies1, allies2);
if (reinforcementsTimer != null) if (reinforcementsTimer != null)
{
reinforcementsTimerWidget.Visible = false; reinforcementsTimerWidget.Visible = false;
}
} }
void MissionAccomplished(string text) void MissionAccomplished(string text)
@@ -156,20 +152,19 @@ namespace OpenRA.Mods.RA.Missions
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (allies1.WinState != WinState.Undefined) if (allies1.WinState != WinState.Undefined) return;
{
return;
}
if (world.FrameNumber % 50 == 1 && chinookHusk.IsInWorld) if (world.FrameNumber % 50 == 1 && chinookHusk.IsInWorld)
{
world.Add(new Smoke(world, chinookHusk.CenterLocation, "smoke_m")); world.Add(new Smoke(world, chinookHusk.CenterLocation, "smoke_m"));
}
if (world.FrameNumber == 1) if (world.FrameNumber == 1)
{ {
InitializeSovietFactories(); InitializeSovietFactories();
StartReinforcementsTimer(); StartReinforcementsTimer();
} }
reinforcementsTimer.Tick(); reinforcementsTimer.Tick();
if (world.FrameNumber == ParatroopersTicks) if (world.FrameNumber == ParatroopersTicks)
{ {
MissionUtils.Paradrop(world, soviets, Badger1Passengers, badgerEntryPoint1.Location, badgerDropPoint1.Location); MissionUtils.Paradrop(world, soviets, Badger1Passengers, badgerEntryPoint1.Location, badgerDropPoint1.Location);
@@ -181,36 +176,35 @@ namespace OpenRA.Mods.RA.Missions
MissionUtils.Parabomb(world, soviets, badgerEntryPoint2.Location, parabombPoint1.Location); MissionUtils.Parabomb(world, soviets, badgerEntryPoint2.Location, parabombPoint1.Location);
MissionUtils.Parabomb(world, soviets, badgerEntryPoint2.Location + new CVec(0, 3), parabombPoint2.Location); MissionUtils.Parabomb(world, soviets, badgerEntryPoint2.Location + new CVec(0, 3), parabombPoint2.Location);
} }
if (allies1 != allies2) if (allies1 != allies2)
{ {
if (world.FrameNumber == TanksTicks) if (world.FrameNumber == TanksTicks)
{
RushSovietUnits(); RushSovietUnits();
}
if (world.FrameNumber == FlamersTicks) if (world.FrameNumber == FlamersTicks)
{
RushSovietFlamers(); RushSovietFlamers();
}
if (yak == null || (yak != null && !yak.IsDead() && (yak.GetCurrentActivity() is FlyCircle || yak.IsIdle))) if (yak == null || (yak != null && !yak.IsDead() && (yak.GetCurrentActivity() is FlyCircle || yak.IsIdle)))
{ {
var alliedUnitsNearYakPoint = world.FindAliveCombatantActorsInCircle(yakAttackPoint.CenterLocation, 10) var alliedUnitsNearYakPoint = world.FindAliveCombatantActorsInCircle(yakAttackPoint.CenterLocation, 10)
.Where(a => a.Owner != soviets && a.HasTrait<IMove>() && a != tanya && a != einstein && a != engineer); .Where(a => a.Owner != soviets && a.HasTrait<IMove>() && a != tanya && a != einstein && a != engineer);
if (alliedUnitsNearYakPoint.Any()) if (alliedUnitsNearYakPoint.Any())
{
YakStrafe(alliedUnitsNearYakPoint); YakStrafe(alliedUnitsNearYakPoint);
}
} }
} }
if (currentReinforcement > -1 && currentReinforcement < Reinforcements.Length && world.FrameNumber % 25 == 0) if (currentReinforcement > -1 && currentReinforcement < Reinforcements.Length && world.FrameNumber % 25 == 0)
{
SpawnAlliedUnit(Reinforcements[currentReinforcement++]); SpawnAlliedUnit(Reinforcements[currentReinforcement++]);
}
if (world.FrameNumber % 25 == 0) if (world.FrameNumber % 25 == 0)
{ {
BuildSovietUnits(); BuildSovietUnits();
ManageSovietUnits(); ManageSovietUnits();
} }
UpdateDeaths(); UpdateDeaths();
if (objectives[FindEinsteinID].Status == ObjectiveStatus.InProgress) if (objectives[FindEinsteinID].Status == ObjectiveStatus.InProgress)
{ {
if (AlliesNearTown()) if (AlliesNearTown())
@@ -249,22 +243,21 @@ namespace OpenRA.Mods.RA.Missions
{ {
objectives[ExtractEinsteinID].Status = ObjectiveStatus.Completed; objectives[ExtractEinsteinID].Status = ObjectiveStatus.Completed;
objectives[MaintainPresenceID].Status = ObjectiveStatus.Completed; objectives[MaintainPresenceID].Status = ObjectiveStatus.Completed;
if (objectives[FewDeathsID].Status == ObjectiveStatus.InProgress) if (objectives[FewDeathsID].Status == ObjectiveStatus.InProgress)
{
objectives[FewDeathsID].Status = ObjectiveStatus.Completed; objectives[FewDeathsID].Status = ObjectiveStatus.Completed;
}
OnObjectivesUpdated(true); OnObjectivesUpdated(true);
MissionAccomplished("Einstein was rescued."); MissionAccomplished("Einstein was rescued.");
} }
} }
if (tanya.Destroyed) if (tanya.Destroyed)
{
MissionFailed("Tanya was killed."); MissionFailed("Tanya was killed.");
}
else if (einstein.Destroyed) else if (einstein.Destroyed)
{
MissionFailed("Einstein was killed."); MissionFailed("Einstein was killed.");
}
world.AddFrameEndTask(w => world.AddFrameEndTask(w =>
{ {
if (!world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20) if (!world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20)
@@ -301,10 +294,10 @@ namespace OpenRA.Mods.RA.Missions
new AltitudeInit(Rules.Info[YakName].Traits.Get<PlaneInfo>().CruiseAltitude) new AltitudeInit(Rules.Info[YakName].Traits.Get<PlaneInfo>().CruiseAltitude)
}); });
} }
if (yak.Trait<LimitedAmmo>().HasAmmo()) if (yak.Trait<LimitedAmmo>().HasAmmo())
{
yak.QueueActivity(new FlyAttack(Target.FromActor(candidates.Random(world.SharedRandom)))); yak.QueueActivity(new FlyAttack(Target.FromActor(candidates.Random(world.SharedRandom))));
}
else else
{ {
yak.QueueActivity(new FlyOffMap()); yak.QueueActivity(new FlyOffMap());
@@ -315,9 +308,8 @@ namespace OpenRA.Mods.RA.Missions
void BuildSovietUnits() void BuildSovietUnits()
{ {
if (!sovietBarracks.Destroyed) if (!sovietBarracks.Destroyed)
{
BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom)); BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom));
}
if (!sovietWarFactory.Destroyed) if (!sovietWarFactory.Destroyed)
{ {
var vehicles = world.FrameNumber >= SovietVehiclesUpgradeTicks ? SovietVehicles2 : SovietVehicles1; var vehicles = world.FrameNumber >= SovietVehiclesUpgradeTicks ? SovietVehicles2 : SovietVehicles1;
@@ -327,7 +319,9 @@ namespace OpenRA.Mods.RA.Missions
void ManageSovietUnits() void ManageSovietUnits()
{ {
var idleSovietUnitsAtRP = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 3).Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>()); var idleSovietUnitsAtRP = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 3)
.Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>());
if (idleSovietUnitsAtRP.Count() >= SovietGroupSize) if (idleSovietUnitsAtRP.Count() >= SovietGroupSize)
{ {
var firstUnit = idleSovietUnitsAtRP.FirstOrDefault(); var firstUnit = idleSovietUnitsAtRP.FirstOrDefault();
@@ -335,23 +329,23 @@ namespace OpenRA.Mods.RA.Missions
{ {
var closestAlliedBuilding = ClosestAlliedBuilding(firstUnit, 40); var closestAlliedBuilding = ClosestAlliedBuilding(firstUnit, 40);
if (closestAlliedBuilding != null) if (closestAlliedBuilding != null)
{
foreach (var unit in idleSovietUnitsAtRP) foreach (var unit in idleSovietUnitsAtRP)
{ {
unit.Trait<Mobile>().Nudge(unit, unit, true); unit.Trait<Mobile>().Nudge(unit, unit, true);
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3))); unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3)));
} }
}
} }
} }
var idleSovietUnits = world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20).Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>());
var idleSovietUnits = world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20)
.Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>());
foreach (var unit in idleSovietUnits) foreach (var unit in idleSovietUnits)
{ {
var closestAlliedBuilding = ClosestAlliedBuilding(unit, 40); var closestAlliedBuilding = ClosestAlliedBuilding(unit, 40);
if (closestAlliedBuilding != null) if (closestAlliedBuilding != null)
{
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3))); unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3)));
}
} }
} }
@@ -378,10 +372,8 @@ namespace OpenRA.Mods.RA.Missions
void BuildSovietUnit(string category, string unit) void BuildSovietUnit(string category, string unit)
{ {
var queue = MissionUtils.FindQueues(world, soviets, category).FirstOrDefault(q => q.CurrentItem() == null); var queue = MissionUtils.FindQueues(world, soviets, category).FirstOrDefault(q => q.CurrentItem() == null);
if (queue == null) if (queue == null) return;
{
return;
}
queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, unit, 1)); queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, unit, 1));
} }
@@ -407,22 +399,20 @@ namespace OpenRA.Mods.RA.Missions
void SpawnAlliedUnit(string unit) void SpawnAlliedUnit(string unit)
{ {
var u = world.CreateActor(unit, new TypeDictionary world.CreateActor(unit, new TypeDictionary
{ {
new LocationInit(reinforcementsEntryPoint.Location), new LocationInit(reinforcementsEntryPoint.Location),
new FacingInit(0), new FacingInit(0),
new OwnerInit(allies2) new OwnerInit(allies2)
}); })
u.QueueActivity(new Move.Move(allies2BasePoint.Location)); .QueueActivity(new Move.Move(allies2BasePoint.Location));
} }
void RushSovietUnits() void RushSovietUnits()
{ {
var closestAlliedBuildings = ClosestAlliedBuildings(badgerDropPoint1, 40); var closestAlliedBuildings = ClosestAlliedBuildings(badgerDropPoint1, 40);
if (!closestAlliedBuildings.Any()) if (!closestAlliedBuildings.Any()) return;
{
return;
}
foreach (var tank in Tanks) foreach (var tank in Tanks)
{ {
var unit = world.CreateActor(tank, new TypeDictionary var unit = world.CreateActor(tank, new TypeDictionary
@@ -431,19 +421,15 @@ namespace OpenRA.Mods.RA.Missions
new LocationInit(tanksEntryPoint.Location) new LocationInit(tanksEntryPoint.Location)
}); });
foreach (var building in closestAlliedBuildings) foreach (var building in closestAlliedBuildings)
{
unit.QueueActivity(new Attack(Target.FromActor(building), 3)); unit.QueueActivity(new Attack(Target.FromActor(building), 3));
}
} }
} }
void RushSovietFlamers() void RushSovietFlamers()
{ {
var closestAlliedBuilding = ClosestAlliedBuilding(badgerDropPoint1, 40); var closestAlliedBuilding = ClosestAlliedBuilding(badgerDropPoint1, 40);
if (closestAlliedBuilding == null) if (closestAlliedBuilding == null) return;
{
return;
}
var apc = world.CreateActor(ApcName, new TypeDictionary { new OwnerInit(soviets), new LocationInit(flamersEntryPoint.Location) }); var apc = world.CreateActor(ApcName, new TypeDictionary { new OwnerInit(soviets), new LocationInit(flamersEntryPoint.Location) });
foreach (var flamer in Flamers) foreach (var flamer in Flamers)
{ {
@@ -474,9 +460,7 @@ namespace OpenRA.Mods.RA.Missions
void TransferTownUnitsToAllies() void TransferTownUnitsToAllies()
{ {
foreach (var unit in world.FindAliveNonCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange).Where(a => a.HasTrait<IMove>())) foreach (var unit in world.FindAliveNonCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange).Where(a => a.HasTrait<IMove>()))
{
unit.ChangeOwner(allies1); unit.ChangeOwner(allies1);
}
} }
void SovietsAttackTown() void SovietsAttackTown()
@@ -485,10 +469,9 @@ namespace OpenRA.Mods.RA.Missions
.Union(world.FindAliveCombatantActorsInCircle(sovietTownAttackPoint2.CenterLocation, SovietTownAttackGroupRange)) .Union(world.FindAliveCombatantActorsInCircle(sovietTownAttackPoint2.CenterLocation, SovietTownAttackGroupRange))
.Union(world.FindAliveCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange)) .Union(world.FindAliveCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange))
.Where(a => a.HasTrait<IMove>() && a.Owner == soviets); .Where(a => a.HasTrait<IMove>() && a.Owner == soviets);
foreach (var unit in sovietAttackUnits) foreach (var unit in sovietAttackUnits)
{
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(townPoint.Location, SovietTownMoveNearEnough))); unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(townPoint.Location, SovietTownMoveNearEnough)));
}
} }
public void WorldLoaded(World w) public void WorldLoaded(World w)
@@ -544,13 +527,10 @@ namespace OpenRA.Mods.RA.Missions
shroud.Explore(w, sam4.Location, 2); shroud.Explore(w, sam4.Location, 2);
if (w.LocalPlayer == null || w.LocalPlayer == allies1) if (w.LocalPlayer == null || w.LocalPlayer == allies1)
{
Game.MoveViewport(chinookHusk.Location.ToFloat2()); Game.MoveViewport(chinookHusk.Location.ToFloat2());
}
else else
{
Game.MoveViewport(allies2BasePoint.Location.ToFloat2()); Game.MoveViewport(allies2BasePoint.Location.ToFloat2());
}
MissionUtils.PlayMissionMusic(); MissionUtils.PlayMissionMusic();
} }
@@ -560,9 +540,8 @@ namespace OpenRA.Mods.RA.Missions
world.AddFrameEndTask(w => world.AddFrameEndTask(w =>
{ {
foreach (var actor in actors.Where(a => a.Value.Owner == allies)) foreach (var actor in actors.Where(a => a.Value.Owner == allies))
{
actor.Value.ChangeOwner(allies2); actor.Value.ChangeOwner(allies2);
}
world.CreateActor("proc", new TypeDictionary world.CreateActor("proc", new TypeDictionary
{ {
new LocationInit(actors["Allies2ProcPoint"].Location), new LocationInit(actors["Allies2ProcPoint"].Location),

View File

@@ -132,10 +132,8 @@ namespace OpenRA.Mods.RA.Missions
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (allies1.WinState != WinState.Undefined) if (allies1.WinState != WinState.Undefined) return;
{
return;
}
if (world.FrameNumber == 1) if (world.FrameNumber == 1)
{ {
SpawnAlliedUnit(McvName); SpawnAlliedUnit(McvName);
@@ -149,22 +147,25 @@ namespace OpenRA.Mods.RA.Missions
attackAtFrame += attackAtFrameIncrement; attackAtFrame += attackAtFrameIncrement;
attackAtFrameIncrement = Math.Max(attackAtFrameIncrement - 5, minAttackAtFrame); attackAtFrameIncrement = Math.Max(attackAtFrameIncrement - 5, minAttackAtFrame);
} }
if (world.FrameNumber >= ReinforcementsTicks1 && currentReinforcement1 < Reinforcements1.Length)
if (world.FrameNumber == ReinforcementsTicks1 || world.FrameNumber == ReinforcementsTicks2)
Sound.Play("reinfor1.aud");
if (world.FrameNumber % 25 == 0)
{ {
if (world.FrameNumber == ReinforcementsTicks1) Sound.Play("reinfor1.aud"); if (world.FrameNumber >= ReinforcementsTicks1 && currentReinforcement1 < Reinforcements1.Length)
if (world.FrameNumber % 25 == 0) SpawnAlliedUnit(Reinforcements1[currentReinforcement1++]); SpawnAlliedUnit(Reinforcements1[currentReinforcement1++]);
}
if (world.FrameNumber >= ReinforcementsTicks2 && currentReinforcement2 < Reinforcements2.Length) if (world.FrameNumber >= ReinforcementsTicks2 && currentReinforcement2 < Reinforcements2.Length)
{ SpawnAlliedUnit(Reinforcements2[currentReinforcement2++]);
if (world.FrameNumber == ReinforcementsTicks2) Sound.Play("reinfor1.aud");
if (world.FrameNumber % 25 == 0) SpawnAlliedUnit(Reinforcements2[currentReinforcement2++]);
} }
if (sovietParadrops > 0) if (sovietParadrops > 0)
{ {
if (world.FrameNumber == sovietParadropTicks) if (world.FrameNumber == sovietParadropTicks)
{
Sound.Play("sovfapp1.aud"); Sound.Play("sovfapp1.aud");
}
if (world.FrameNumber >= sovietParadropTicks && world.FrameNumber % ParadropIncrement == 0) if (world.FrameNumber >= sovietParadropTicks && world.FrameNumber % ParadropIncrement == 0)
{ {
CPos lz; CPos lz;
@@ -182,20 +183,21 @@ namespace OpenRA.Mods.RA.Missions
} }
} }
if (world.FrameNumber % 25 == 0) if (world.FrameNumber % 25 == 0)
{
ManageSovietUnits(); ManageSovietUnits();
}
if (objectives[AirbaseID].Status != ObjectiveStatus.Completed) if (objectives[AirbaseID].Status != ObjectiveStatus.Completed)
{ {
if (world.FrameNumber % 25 == 0) if (world.FrameNumber % 25 == 0)
{
BuildSovietAircraft(); BuildSovietAircraft();
}
ManageSovietAircraft(); ManageSovietAircraft();
} }
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(); CheckSovietAirbase();
if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && a.IsInWorld && !a.IsDead() if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && a.IsInWorld && !a.IsDead()
&& ((a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))) && ((a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>())))
{ {
@@ -227,13 +229,11 @@ namespace OpenRA.Mods.RA.Missions
if (enemy != null) if (enemy != null)
{ {
if (!aircraft.IsIdle && aircraft.GetCurrentActivity().GetType() != typeof(FlyAttack)) if (!aircraft.IsIdle && aircraft.GetCurrentActivity().GetType() != typeof(FlyAttack))
{
aircraft.CancelActivity(); aircraft.CancelActivity();
}
if (plane.Altitude == 0) if (plane.Altitude == 0)
{
plane.UnReserve(); plane.UnReserve();
}
aircraft.QueueActivity(new FlyAttack(Target.FromActor(enemy))); aircraft.QueueActivity(new FlyAttack(Target.FromActor(enemy)));
} }
} }
@@ -249,19 +249,15 @@ namespace OpenRA.Mods.RA.Missions
bool LandIsQueued(Actor actor) bool LandIsQueued(Actor actor)
{ {
for (var a = actor.GetCurrentActivity(); a != null; a = a.NextActivity) for (var a = actor.GetCurrentActivity(); a != null; a = a.NextActivity)
{ if (a is ReturnToBase || a is Land) return true;
if (a is ReturnToBase || a is Land) { return true; }
}
return false; return false;
} }
void BuildSovietAircraft() void BuildSovietAircraft()
{ {
var queue = MissionUtils.FindQueues(world, soviets, "Plane").FirstOrDefault(q => q.CurrentItem() == null); var queue = MissionUtils.FindQueues(world, soviets, "Plane").FirstOrDefault(q => q.CurrentItem() == null);
if (queue == null || SovietAircraft().Count() >= maxSovietYaks) if (queue == null || SovietAircraft().Count() >= maxSovietYaks) return;
{
return;
}
queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, YakName, 1)); queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, YakName, 1));
} }
@@ -284,16 +280,19 @@ namespace OpenRA.Mods.RA.Missions
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];
IEnumerable<string> units; IEnumerable<string> units;
if (world.FrameNumber >= sovietUnits2Ticks) if (world.FrameNumber >= sovietUnits2Ticks)
{
units = SovietUnits2; units = SovietUnits2;
}
else else
{
units = SovietUnits1; units = SovietUnits1;
}
var unit = world.CreateActor(units.Random(world.SharedRandom), new TypeDictionary { new LocationInit(spawnPoint), new OwnerInit(soviets) }); var unit = world.CreateActor(units.Random(world.SharedRandom),
new TypeDictionary
{
new LocationInit(spawnPoint),
new OwnerInit(soviets)
});
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(rallyPoint, 3))); unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(rallyPoint, 3)));
} }
@@ -303,11 +302,10 @@ namespace OpenRA.Mods.RA.Missions
.Where(u => (u.Owner == allies1 || u.Owner == allies2) .Where(u => (u.Owner == allies1 || u.Owner == allies2)
&& ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>()) && u.IsInWorld && !u.IsDead() && ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>()) && u.IsInWorld && !u.IsDead()
&& (!u.HasTrait<Spy>() || !u.Trait<Spy>().Disguised || (u.Trait<Spy>().Disguised && u.Trait<Spy>().disguisedAsPlayer != soviets))); && (!u.HasTrait<Spy>() || !u.Trait<Spy>().Disguised || (u.Trait<Spy>().Disguised && u.Trait<Spy>().disguisedAsPlayer != soviets)));
var enemy = FirstUnshroudedOrDefault(enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared), world, 10); var enemy = FirstUnshroudedOrDefault(enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared), world, 10);
if (enemy != null) if (enemy != null)
{
self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Attack(Target.FromActor(enemy), 3))); self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Attack(Target.FromActor(enemy), 3)));
}
} }
void ManageSovietUnits() void ManageSovietUnits()
@@ -319,27 +317,23 @@ namespace OpenRA.Mods.RA.Missions
if (units.Count() >= SovietGroupSize) if (units.Count() >= SovietGroupSize)
{ {
foreach (var unit in units) foreach (var unit in units)
{
AttackNearestAlliedActor(unit); AttackNearestAlliedActor(unit);
}
} }
} }
var scatteredUnits = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && u.HasTrait<Mobile>() && u.IsIdle && u.Owner == soviets) var scatteredUnits = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && u.HasTrait<Mobile>() && u.IsIdle && u.Owner == soviets)
.Except(world.WorldActor.Trait<SpawnMapActors>().Actors.Values) .Except(world.WorldActor.Trait<SpawnMapActors>().Actors.Values)
.Except(sovietRallyPoints.SelectMany(rp => world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(rp), 10))); .Except(sovietRallyPoints.SelectMany(rp => world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(rp), 10)));
foreach (var unit in scatteredUnits) foreach (var unit in scatteredUnits)
{
AttackNearestAlliedActor(unit); AttackNearestAlliedActor(unit);
}
} }
void SpawnAlliedUnit(string actor) void SpawnAlliedUnit(string actor)
{ {
SpawnAndMove(actor, allies1, allies1EntryPoint.Location, allies1MovePoint.Location); SpawnAndMove(actor, allies1, allies1EntryPoint.Location, allies1MovePoint.Location);
if (allies2 != allies1) if (allies1 != allies2)
{
SpawnAndMove(actor, allies2, allies2EntryPoint.Location, allies2MovePoint.Location); SpawnAndMove(actor, allies2, allies2EntryPoint.Location, allies2MovePoint.Location);
}
} }
Actor SpawnAndMove(string actor, Player owner, CPos entry, CPos to) Actor SpawnAndMove(string actor, Player owner, CPos entry, CPos to)
@@ -369,22 +363,24 @@ namespace OpenRA.Mods.RA.Missions
{ {
var units = world.FindAliveCombatantActorsInBox(a, b) var units = world.FindAliveCombatantActorsInBox(a, b)
.Where(u => u.HasTrait<Mobile>() && !u.HasTrait<Aircraft>() && (u.Owner == allies1 || u.Owner == allies2)); .Where(u => u.HasTrait<Mobile>() && !u.HasTrait<Aircraft>() && (u.Owner == allies1 || u.Owner == allies2));
foreach (var unit in units) foreach (var unit in units)
{ {
unit.CancelActivity(); unit.CancelActivity();
unit.ChangeOwner(allies); unit.ChangeOwner(allies);
unitsEvacuated++; unitsEvacuated++;
var createsShroud = unit.TraitOrDefault<CreatesShroud>(); var createsShroud = unit.TraitOrDefault<CreatesShroud>();
if (createsShroud != null && objectives[GapGeneratorID].Status == ObjectiveStatus.InProgress) if (createsShroud != null && objectives[GapGeneratorID].Status == ObjectiveStatus.InProgress)
{ {
objectives[GapGeneratorID].Status = ObjectiveStatus.Completed; objectives[GapGeneratorID].Status = ObjectiveStatus.Completed;
OnObjectivesUpdated(true); OnObjectivesUpdated(true);
} }
var cargo = unit.TraitOrDefault<Cargo>(); var cargo = unit.TraitOrDefault<Cargo>();
if (cargo != null) if (cargo != null)
{
unitsEvacuated += cargo.Passengers.Count(); unitsEvacuated += cargo.Passengers.Count();
}
UpdateUnitsEvacuated(); UpdateUnitsEvacuated();
unit.QueueActivity(new Move.Move(exit)); unit.QueueActivity(new Move.Move(exit));
unit.QueueActivity(new RemoveSelf()); unit.QueueActivity(new RemoveSelf());
@@ -449,13 +445,10 @@ namespace OpenRA.Mods.RA.Missions
paradropBox = new Rectangle(topLeft.Location.X, topLeft.Location.Y, bottomRight.Location.X - topLeft.Location.X, bottomRight.Location.Y - topLeft.Location.Y); paradropBox = new Rectangle(topLeft.Location.X, topLeft.Location.Y, bottomRight.Location.X - topLeft.Location.X, bottomRight.Location.Y - topLeft.Location.Y);
if (w.LocalPlayer == null || w.LocalPlayer == allies1) if (w.LocalPlayer == null || w.LocalPlayer == allies1)
{
Game.MoveViewport(allies1EntryPoint.Location.ToFloat2()); Game.MoveViewport(allies1EntryPoint.Location.ToFloat2());
}
else else
{
Game.MoveViewport(allies2EntryPoint.Location.ToFloat2()); Game.MoveViewport(allies2EntryPoint.Location.ToFloat2());
}
OnObjectivesUpdated(false); OnObjectivesUpdated(false);
MissionUtils.PlayMissionMusic(); MissionUtils.PlayMissionMusic();

View File

@@ -104,18 +104,14 @@ namespace OpenRA.Mods.RA.Missions
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (allies1.WinState != WinState.Undefined) if (allies1.WinState != WinState.Undefined) return;
{
return;
}
if (world.FrameNumber == 1) if (world.FrameNumber == 1)
{
InsertSpies(); InsertSpies();
}
if (world.FrameNumber == 25 * 25) if (world.FrameNumber == 25 * 25)
{
SendHind(hind1EntryPoint, hind1Points, hind1ExitPoint); SendHind(hind1EntryPoint, hind1Points, hind1ExitPoint);
}
if (frameInfiltrated != -1) if (frameInfiltrated != -1)
{ {
if (world.FrameNumber == frameInfiltrated + 100) if (world.FrameNumber == frameInfiltrated + 100)
@@ -131,10 +127,10 @@ namespace OpenRA.Mods.RA.Missions
destroyBaseTimerWidget = new CountdownTimerWidget(destroyBaseTimer, "Secure lab in: {0}"); destroyBaseTimerWidget = new CountdownTimerWidget(destroyBaseTimer, "Secure lab in: {0}");
Ui.Root.AddChild(destroyBaseTimerWidget); Ui.Root.AddChild(destroyBaseTimerWidget);
} }
if (world.FrameNumber >= frameInfiltrated + 200) if (world.FrameNumber >= frameInfiltrated + 200)
{
destroyBaseTimer.Tick(); destroyBaseTimer.Tick();
}
if (world.FrameNumber == frameInfiltrated + 1500 * 12 && !bridgeTank.IsDead() && bridgeTank.IsInWorld && !bridge.IsDead()) if (world.FrameNumber == frameInfiltrated + 1500 * 12 && !bridgeTank.IsDead() && bridgeTank.IsInWorld && !bridge.IsDead())
{ {
bridgeTank.QueueActivity(new Attack(Target.FromPos(bridge.CenterLocation), 4)); bridgeTank.QueueActivity(new Attack(Target.FromPos(bridge.CenterLocation), 4));
@@ -149,12 +145,14 @@ namespace OpenRA.Mods.RA.Missions
attackingBridge = false; attackingBridge = false;
} }
} }
foreach (var patrol in patrols) foreach (var patrol in patrols)
{
patrol.DoPatrol(); patrol.DoPatrol();
}
ManageSovietOre(); ManageSovietOre();
BaseGuardTick(); BaseGuardTick();
if (allies1Spy.IsDead() || (allies2Spy != null && allies2Spy.IsDead())) if (allies1Spy.IsDead() || (allies2Spy != null && allies2Spy.IsDead()))
{ {
objectives[InfiltrateID].Status = ObjectiveStatus.Failed; objectives[InfiltrateID].Status = ObjectiveStatus.Failed;
@@ -162,9 +160,8 @@ namespace OpenRA.Mods.RA.Missions
MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The")); MissionFailed("{0} spy was killed.".F(allies1 != allies2 ? "A" : "The"));
} }
else if (lab.Destroyed) else if (lab.Destroyed)
{
MissionFailed("The Soviet research laboratory was destroyed."); MissionFailed("The Soviet research laboratory was destroyed.");
}
else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead() else if (!world.Actors.Any(a => (a.Owner == allies1 || a.Owner == allies2) && !a.IsDead()
&& (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>())) && (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))
{ {
@@ -198,10 +195,7 @@ namespace OpenRA.Mods.RA.Missions
void OnDestroyBaseTimerExpired(CountdownTimer t) void OnDestroyBaseTimerExpired(CountdownTimer t)
{ {
if (SovietBaseDestroyed() && objectives[InfiltrateID].Status == ObjectiveStatus.Completed) if (SovietBaseDestroyed() && objectives[InfiltrateID].Status == ObjectiveStatus.Completed) return;
{
return;
}
objectives[DestroyID].Status = ObjectiveStatus.Failed; objectives[DestroyID].Status = ObjectiveStatus.Failed;
OnObjectivesUpdated(true); OnObjectivesUpdated(true);
MissionFailed("The Soviet research laboratory was not secured in time."); MissionFailed("The Soviet research laboratory was not secured in time.");
@@ -211,34 +205,27 @@ namespace OpenRA.Mods.RA.Missions
{ {
var res = soviets.PlayerActor.Trait<PlayerResources>(); var res = soviets.PlayerActor.Trait<PlayerResources>();
if (res.Ore > res.OreCapacity * 0.8) if (res.Ore > res.OreCapacity * 0.8)
{
res.TakeOre(res.OreCapacity / 10); res.TakeOre(res.OreCapacity / 10);
}
} }
void BaseGuardTick() void BaseGuardTick()
{ {
if (baseGuardTicks <= 0 || baseGuard.IsDead() || !baseGuard.IsInWorld) if (baseGuardTicks <= 0 || baseGuard.IsDead() || !baseGuard.IsInWorld) return;
{
return;
}
if (hijackTruck.Location == baseGuardTruckPos.Location) if (hijackTruck.Location == baseGuardTruckPos.Location)
{ {
if (--baseGuardTicks <= 0) if (--baseGuardTicks <= 0)
{
baseGuard.QueueActivity(new Move.Move(baseGuardMovePos.Location)); baseGuard.QueueActivity(new Move.Move(baseGuardMovePos.Location));
}
} }
else else
{
baseGuardTicks = 100; baseGuardTicks = 100;
}
} }
void OnLabInfiltrated(Actor spy) void OnLabInfiltrated(Actor spy)
{ {
if (spy == allies1Spy) allies1SpyInfiltratedLab = true; if (spy == allies1Spy) allies1SpyInfiltratedLab = true;
else if (spy == allies2Spy) allies2SpyInfiltratedLab = true; else if (spy == allies2Spy) allies2SpyInfiltratedLab = true;
if (allies1SpyInfiltratedLab && (allies2SpyInfiltratedLab || allies2Spy == null)) if (allies1SpyInfiltratedLab && (allies2SpyInfiltratedLab || allies2Spy == null))
{ {
objectives[InfiltrateID].Status = ObjectiveStatus.Completed; objectives[InfiltrateID].Status = ObjectiveStatus.Completed;
@@ -260,6 +247,7 @@ namespace OpenRA.Mods.RA.Missions
{ {
lst.Trait<Cargo>().Load(lst, world.CreateActor(false, "mcv", new TypeDictionary { new OwnerInit(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 Move.Move(reinforcementsUnloadPoint.Location));
lst.QueueActivity(new Wait(10)); lst.QueueActivity(new Wait(10));
lst.QueueActivity(new CallFunc(() => lst.QueueActivity(new CallFunc(() =>
@@ -294,10 +282,8 @@ namespace OpenRA.Mods.RA.Missions
public void DoPatrol() public void DoPatrol()
{ {
if (actors.Any(a => a.IsDead() || !a.IsIdle || !a.IsInWorld)) if (actors.Any(a => a.IsDead() || !a.IsIdle || !a.IsInWorld)) return;
{
return;
}
pointIndex = (pointIndex + 1) % points.Length; pointIndex = (pointIndex + 1) % points.Length;
foreach (var actor in actors.Where(a => !a.IsDead() && a.IsInWorld)) foreach (var actor in actors.Where(a => !a.IsDead() && a.IsInWorld))
{ {
@@ -316,10 +302,10 @@ namespace OpenRA.Mods.RA.Missions
new FacingInit(Util.GetFacing(points.First().ToCPos() - start, 0)), new FacingInit(Util.GetFacing(points.First().ToCPos() - start, 0)),
new AltitudeInit(Rules.Info["hind.autotarget"].Traits.Get<HelicopterInfo>().CruiseAltitude), new AltitudeInit(Rules.Info["hind.autotarget"].Traits.Get<HelicopterInfo>().CruiseAltitude),
}); });
foreach (var point in points.Concat(new[] { Util.CenterOfCell(exit) })) foreach (var point in points.Concat(new[] { Util.CenterOfCell(exit) }))
{
hind.QueueActivity(new AttackMove.AttackMoveActivity(hind, new HeliFly(point))); hind.QueueActivity(new AttackMove.AttackMoveActivity(hind, new HeliFly(point)));
}
hind.QueueActivity(new RemoveSelf()); hind.QueueActivity(new RemoveSelf());
} }
@@ -330,6 +316,7 @@ namespace OpenRA.Mods.RA.Missions
new OwnerInit(allies1), new OwnerInit(allies1),
new LocationInit(lstEntryPoint.Location) new LocationInit(lstEntryPoint.Location)
}); });
allies1Spy = world.CreateActor(false, "spy.strong", new TypeDictionary { new OwnerInit(allies1) }); allies1Spy = world.CreateActor(false, "spy.strong", new TypeDictionary { new OwnerInit(allies1) });
lst.Trait<Cargo>().Load(lst, allies1Spy); lst.Trait<Cargo>().Load(lst, allies1Spy);
if (allies1 != allies2) if (allies1 != allies2)
@@ -337,6 +324,7 @@ namespace OpenRA.Mods.RA.Missions
allies2Spy = world.CreateActor(false, "spy.strong", new TypeDictionary { new OwnerInit(allies2) }); allies2Spy = world.CreateActor(false, "spy.strong", new TypeDictionary { new OwnerInit(allies2) });
lst.Trait<Cargo>().Load(lst, allies2Spy); lst.Trait<Cargo>().Load(lst, allies2Spy);
} }
lst.QueueActivity(new Move.Move(lstUnloadPoint.Location)); lst.QueueActivity(new Move.Move(lstUnloadPoint.Location));
lst.QueueActivity(new Wait(10)); lst.QueueActivity(new Wait(10));
lst.QueueActivity(new UnloadCargo(true)); lst.QueueActivity(new UnloadCargo(true));
@@ -348,9 +336,7 @@ namespace OpenRA.Mods.RA.Missions
void SetupSubStances() void SetupSubStances()
{ {
foreach (var actor in world.Actors.Where(a => a.IsInWorld && a.Owner == soviets && !a.IsDead() && a.HasTrait<TargetableSubmarine>())) foreach (var actor in world.Actors.Where(a => a.IsInWorld && a.Owner == soviets && !a.IsDead() && a.HasTrait<TargetableSubmarine>()))
{
actor.Trait<AutoTarget>().stance = UnitStance.Defend; actor.Trait<AutoTarget>().stance = UnitStance.Defend;
}
} }
public void WorldLoaded(World w) public void WorldLoaded(World w)
@@ -366,6 +352,7 @@ namespace OpenRA.Mods.RA.Missions
{ {
allies2 = allies1; allies2 = allies1;
} }
soviets = w.Players.Single(p => p.InternalName == "Soviets"); soviets = w.Players.Single(p => p.InternalName == "Soviets");
neutral = w.Players.Single(p => p.InternalName == "Neutral"); neutral = w.Players.Single(p => p.InternalName == "Neutral");
objectives[InfiltrateID].Text = Infiltrate.F(allies1 != allies2 ? "spies" : "spy"); objectives[InfiltrateID].Text = Infiltrate.F(allies1 != allies2 ? "spies" : "spy");
@@ -423,6 +410,7 @@ namespace OpenRA.Mods.RA.Missions
hind1ExitPoint = actors["Hind1ExitPoint"].Location; hind1ExitPoint = actors["Hind1ExitPoint"].Location;
reinforcementsEntryPoint = actors["ReinforcementsEntryPoint"]; reinforcementsEntryPoint = actors["ReinforcementsEntryPoint"];
reinforcementsUnloadPoint = actors["ReinforcementsUnloadPoint"]; reinforcementsUnloadPoint = actors["ReinforcementsUnloadPoint"];
patrols = new[] patrols = new[]
{ {
new Patrol(world, new[] { "e1", "e1", "e1", "e1", "e1" }, soviets, patrolPoints1, 0), new Patrol(world, new[] { "e1", "e1", "e1", "e1", "e1" }, soviets, patrolPoints1, 0),
@@ -474,9 +462,8 @@ namespace OpenRA.Mods.RA.Missions
public void OnInfiltrate(Actor self, Actor spy) public void OnInfiltrate(Actor self, Actor spy)
{ {
if (self.Trait<Cargo>().IsEmpty(self)) if (self.Trait<Cargo>().IsEmpty(self))
{
self.ChangeOwner(spy.Owner); self.ChangeOwner(spy.Owner);
}
self.Trait<Cargo>().Load(self, spy); self.Trait<Cargo>().Load(self, spy);
} }
@@ -488,9 +475,7 @@ namespace OpenRA.Mods.RA.Missions
self.ChangeOwner(OldOwner); self.ChangeOwner(OldOwner);
} }
else if (self.Owner == passenger.Owner) else if (self.Owner == passenger.Owner)
{
self.ChangeOwner(self.Trait<Cargo>().Passengers.First().Owner); self.ChangeOwner(self.Trait<Cargo>().Passengers.First().Owner);
}
} }
} }
@@ -534,25 +519,16 @@ namespace OpenRA.Mods.RA.Missions
class Allies04TrivialBuilding { } class Allies04TrivialBuilding { }
class Allies04MaintainBuildingInfo : ITraitInfo class Allies04MaintainBuildingInfo : TraitInfo<Allies04MaintainBuilding>
{ {
public readonly string Player = null; public readonly string Player = null;
public object Create(ActorInitializer init) { return new Allies04MaintainBuilding(this); }
} }
class Allies04MaintainBuilding : INotifyDamageStateChanged class Allies04MaintainBuilding : INotifyDamageStateChanged
{ {
Allies04MaintainBuildingInfo info;
public Allies04MaintainBuilding(Allies04MaintainBuildingInfo info)
{
this.info = info;
}
public void DamageStateChanged(Actor self, AttackInfo e) public void DamageStateChanged(Actor self, AttackInfo e)
{ {
if (self.Owner.InternalName != info.Player) return; if (self.Owner.InternalName != self.Info.Traits.Get<Allies04MaintainBuildingInfo>().Player) return;
if (self.HasTrait<Sellable>() && e.DamageState == DamageState.Critical && e.PreviousDamageState < DamageState.Critical) if (self.HasTrait<Sellable>() && e.DamageState == DamageState.Critical && e.PreviousDamageState < DamageState.Critical)
self.Trait<Sellable>().Sell(self); self.Trait<Sellable>().Sell(self);

View File

@@ -14,7 +14,7 @@ namespace OpenRA.Mods.RA.Missions
{ {
public class CountdownTimer public class CountdownTimer
{ {
public int TicksLeft { get; set; } public int TicksLeft;
public event Action<CountdownTimer> OnExpired = t => { }; public event Action<CountdownTimer> OnExpired = t => { };
public event Action<CountdownTimer> OnOneMinuteRemaining = t => { }; public event Action<CountdownTimer> OnOneMinuteRemaining = t => { };
@@ -47,22 +47,21 @@ namespace OpenRA.Mods.RA.Missions
public void Tick() public void Tick()
{ {
if (TicksLeft > 0) if (TicksLeft <= 0) return;
TicksLeft--;
switch (TicksLeft)
{ {
TicksLeft--; case 1500 * 00: OnExpired(this); break;
switch (TicksLeft) case 1500 * 01: OnOneMinuteRemaining(this); break;
{ case 1500 * 02: OnTwoMinutesRemaining(this); break;
case 1500 * 00: OnExpired(this); break; case 1500 * 03: OnThreeMinutesRemaining(this); break;
case 1500 * 01: OnOneMinuteRemaining(this); break; case 1500 * 04: OnFourMinutesRemaining(this); break;
case 1500 * 02: OnTwoMinutesRemaining(this); break; case 1500 * 05: OnFiveMinutesRemaining(this); break;
case 1500 * 03: OnThreeMinutesRemaining(this); break; case 1500 * 10: OnTenMinutesRemaining(this); break;
case 1500 * 04: OnFourMinutesRemaining(this); break; case 1500 * 20: OnTwentyMinutesRemaining(this); break;
case 1500 * 05: OnFiveMinutesRemaining(this); break; case 1500 * 30: OnThirtyMinutesRemaining(this); break;
case 1500 * 10: OnTenMinutesRemaining(this); break; case 1500 * 40: OnFortyMinutesRemaining(this); break;
case 1500 * 20: OnTwentyMinutesRemaining(this); break;
case 1500 * 30: OnThirtyMinutesRemaining(this); break;
case 1500 * 40: OnFortyMinutesRemaining(this); break;
}
} }
} }
} }

View File

@@ -15,8 +15,8 @@ namespace OpenRA.Mods.RA.Missions
{ {
public class CountdownTimerWidget : Widget public class CountdownTimerWidget : Widget
{ {
public CountdownTimer Timer { get; set; } public CountdownTimer Timer;
public string Format { get; set; } public string Format;
public CountdownTimerWidget(CountdownTimer timer, string format) public CountdownTimerWidget(CountdownTimer timer, string format)
{ {
@@ -26,10 +26,8 @@ namespace OpenRA.Mods.RA.Missions
public override void Draw() public override void Draw()
{ {
if (!IsVisible()) if (!IsVisible()) return;
{
return;
}
var font = Game.Renderer.Fonts["Bold"]; var font = Game.Renderer.Fonts["Bold"];
var text = Format.F(WidgetUtils.FormatTime(Timer.TicksLeft)); var text = Format.F(WidgetUtils.FormatTime(Timer.TicksLeft));
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(text).X / 2, Game.viewport.Height * 0.1f); var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(text).X / 2, Game.viewport.Height * 0.1f);
@@ -39,19 +37,14 @@ namespace OpenRA.Mods.RA.Missions
public class InfoWidget : Widget public class InfoWidget : Widget
{ {
public string Text { get; set; } public string Text;
public InfoWidget(string text) public InfoWidget(string text) { Text = text; }
{
Text = text;
}
public override void Draw() public override void Draw()
{ {
if (!IsVisible()) if (!IsVisible()) return;
{
return;
}
var font = Game.Renderer.Fonts["Bold"]; var font = Game.Renderer.Fonts["Bold"];
var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(Text).X / 2, Game.viewport.Height * 0.1f); var pos = new float2(Game.viewport.Width * 0.5f - font.Measure(Text).X / 2, Game.viewport.Height * 0.1f);
font.DrawTextWithContrast(Text, pos, Color.White, Color.Black, 1); font.DrawTextWithContrast(Text, pos, Color.White, Color.Black, 1);

View File

@@ -8,7 +8,6 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Traits; using OpenRA.Traits;
@@ -16,9 +15,9 @@ namespace OpenRA.Mods.RA.Missions
{ {
public class Objective public class Objective
{ {
public ObjectiveType Type { get; set; } public ObjectiveType Type;
public string Text { get; set; } public string Text;
public ObjectiveStatus Status { get; set; } public ObjectiveStatus Status;
public Objective(ObjectiveType type, string text, ObjectiveStatus status) public Objective(ObjectiveType type, string text, ObjectiveStatus status)
{ {

View File

@@ -111,7 +111,9 @@ namespace OpenRA.Mods.RA.Missions
new FacingInit(Util.GetFacing(airfield.Location - entry, 0)), new FacingInit(Util.GetFacing(airfield.Location - entry, 0)),
new AltitudeInit(Rules.Info["yak"].Traits.Get<PlaneInfo>().CruiseAltitude) new AltitudeInit(Rules.Info["yak"].Traits.Get<PlaneInfo>().CruiseAltitude)
}); });
while (yak.Trait<LimitedAmmo>().TakeAmmo()) { } while (yak.Trait<LimitedAmmo>().TakeAmmo()) { }
yak.QueueActivity(new ReturnToBase(yak, airfield)); yak.QueueActivity(new ReturnToBase(yak, airfield));
yak.QueueActivity(new ResupplyAircraft()); yak.QueueActivity(new ResupplyAircraft());
} }