Improve the Soviet attack routines for Allies 01
This commit is contained in:
@@ -14,6 +14,8 @@ 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.Move;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Scripting;
|
using OpenRA.Scripting;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -134,15 +136,19 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
}
|
}
|
||||||
if (objectives[ExtractEinsteinID].Status == ObjectiveStatus.InProgress)
|
if (objectives[ExtractEinsteinID].Status == ObjectiveStatus.InProgress)
|
||||||
{
|
{
|
||||||
|
if (world.FrameNumber % 25 == 0)
|
||||||
|
{
|
||||||
|
SendAttackWave();
|
||||||
|
}
|
||||||
if (world.FrameNumber >= currentAttackWaveFrameNumber + 600)
|
if (world.FrameNumber >= currentAttackWaveFrameNumber + 600)
|
||||||
{
|
{
|
||||||
Sound.Play("enmyapp1.aud");
|
Sound.Play("enmyapp1.aud");
|
||||||
SendAttackWave(AttackWave);
|
SpawnAttackWave(AttackWave);
|
||||||
currentAttackWave++;
|
currentAttackWave++;
|
||||||
currentAttackWaveFrameNumber = world.FrameNumber;
|
currentAttackWaveFrameNumber = world.FrameNumber;
|
||||||
if (currentAttackWave >= EinsteinChinookAttackWave)
|
if (currentAttackWave >= EinsteinChinookAttackWave)
|
||||||
{
|
{
|
||||||
SendAttackWave(LastAttackWaveAddition);
|
SpawnAttackWave(LastAttackWaveAddition);
|
||||||
}
|
}
|
||||||
if (currentAttackWave == EinsteinChinookAttackWave)
|
if (currentAttackWave == EinsteinChinookAttackWave)
|
||||||
{
|
{
|
||||||
@@ -188,22 +194,47 @@ 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 SendAttackWave(IEnumerable<string> wave)
|
void SpawnAttackWave(IEnumerable<string> wave)
|
||||||
{
|
{
|
||||||
foreach (var unit in wave)
|
foreach (var unit in wave)
|
||||||
{
|
{
|
||||||
var spawnActor = world.SharedRandom.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2;
|
var spawnActor = world.SharedRandom.Next(2) == 0 ? attackEntryPoint1 : attackEntryPoint2;
|
||||||
var actor = world.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) });
|
var actor = world.CreateActor(unit, new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnActor.Location) });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendAttackWave()
|
||||||
|
{
|
||||||
|
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>()))
|
||||||
|
{
|
||||||
Activity innerActivity;
|
Activity innerActivity;
|
||||||
if (einstein != null && einstein.IsInWorld)
|
if (einstein != null)
|
||||||
|
{
|
||||||
|
if (einstein.IsInWorld)
|
||||||
{
|
{
|
||||||
innerActivity = new Attack(Target.FromActor(einstein), 3);
|
innerActivity = new Attack(Target.FromActor(einstein), 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
var container = world.UnitContaining(einstein);
|
||||||
|
if (container != null && !container.HasTrait<Aircraft>() && container.HasTrait<Mobile>())
|
||||||
|
{
|
||||||
|
innerActivity = new Attack(Target.FromActor(container), 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
innerActivity = new Move.Move(extractionLZ.Location, 3);
|
innerActivity = new Move.Move(extractionLZ.Location, 3);
|
||||||
}
|
}
|
||||||
actor.QueueActivity(new AttackMove.AttackMoveActivity(actor, innerActivity));
|
}
|
||||||
|
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, innerActivity));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
public static IEnumerable<Actor> FindAliveCombatantActorsInCircle(this World world, PPos location, int range)
|
public static IEnumerable<Actor> FindAliveCombatantActorsInCircle(this World world, PPos location, int range)
|
||||||
{
|
{
|
||||||
return world.FindUnitsInCircle(location, Game.CellSize * range)
|
return world.FindUnitsInCircle(location, Game.CellSize * range)
|
||||||
.Where(a => a.IsInWorld && a != world.WorldActor && !a.Destroyed && !a.Owner.NonCombatant);
|
.Where(a => a.IsInWorld && a != world.WorldActor && !a.IsDead() && !a.Owner.NonCombatant);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Actor> FindAliveNonCombatantActorsInCircle(this World world, PPos location, int range)
|
public static IEnumerable<Actor> FindAliveNonCombatantActorsInCircle(this World world, PPos location, int range)
|
||||||
{
|
{
|
||||||
return world.FindUnitsInCircle(location, Game.CellSize * range)
|
return world.FindUnitsInCircle(location, Game.CellSize * range)
|
||||||
.Where(a => a.IsInWorld && a != world.WorldActor && !a.Destroyed && a.Owner.NonCombatant);
|
.Where(a => a.IsInWorld && a != world.WorldActor && !a.IsDead() && a.Owner.NonCombatant);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Actor ExtractUnitWithChinook(World world, Player owner, Actor unit, CPos entry, CPos lz, CPos exit)
|
public static Actor ExtractUnitWithChinook(World world, Player owner, Actor unit, CPos entry, CPos lz, CPos exit)
|
||||||
@@ -90,5 +90,10 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
.Where(a => a.Actor.Owner == player && a.Trait.Info.Type == category)
|
.Where(a => a.Actor.Owner == player && a.Trait.Info.Type == category)
|
||||||
.Select(a => a.Trait);
|
.Select(a => a.Trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Actor UnitContaining(this World world, Actor actor)
|
||||||
|
{
|
||||||
|
return world.Actors.FirstOrDefault(a => a.HasTrait<Cargo>() && a.Trait<Cargo>().Passengers.Contains(actor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user