Allies 02 code maintenance. Add FreeActorInit so free harvesters with procs can be disabled etc
This commit is contained in:
@@ -21,20 +21,22 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int2 SpawnOffset = int2.Zero;
|
public readonly int2 SpawnOffset = int2.Zero;
|
||||||
public readonly int Facing = 0;
|
public readonly int Facing = 0;
|
||||||
|
|
||||||
public object Create( ActorInitializer init ) { return new FreeActor(init.self, this); }
|
public object Create( ActorInitializer init ) { return new FreeActor(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FreeActor
|
public class FreeActor
|
||||||
{
|
{
|
||||||
public FreeActor(Actor self, FreeActorInfo info)
|
public FreeActor(ActorInitializer init, FreeActorInfo info)
|
||||||
{
|
{
|
||||||
self.World.AddFrameEndTask(
|
if (init.Contains<FreeActorInit>() && !init.Get<FreeActorInit>().value) return;
|
||||||
|
|
||||||
|
init.self.World.AddFrameEndTask(
|
||||||
w =>
|
w =>
|
||||||
{
|
{
|
||||||
var a = w.CreateActor(info.Actor, new TypeDictionary
|
var a = w.CreateActor(info.Actor, new TypeDictionary
|
||||||
{
|
{
|
||||||
new LocationInit( self.Location + (CVec)info.SpawnOffset ),
|
new LocationInit( init.self.Location + (CVec)info.SpawnOffset ),
|
||||||
new OwnerInit( self.Owner ),
|
new OwnerInit( init.self.Owner ),
|
||||||
new FacingInit( info.Facing ),
|
new FacingInit( info.Facing ),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -43,4 +45,13 @@ namespace OpenRA.Mods.RA
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FreeActorInit : IActorInit<bool>
|
||||||
|
{
|
||||||
|
[FieldFromYamlKey]
|
||||||
|
public readonly bool value = true;
|
||||||
|
public FreeActorInit() { }
|
||||||
|
public FreeActorInit(bool init) { value = init; }
|
||||||
|
public bool Value(World world) { return value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
Actor sam2;
|
Actor sam2;
|
||||||
Actor sam3;
|
Actor sam3;
|
||||||
Actor sam4;
|
Actor sam4;
|
||||||
|
Actor[] sams;
|
||||||
Actor tanya;
|
Actor tanya;
|
||||||
Actor einstein;
|
Actor einstein;
|
||||||
Actor engineer;
|
Actor engineer;
|
||||||
@@ -74,8 +75,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
Actor parabombPoint1;
|
Actor parabombPoint1;
|
||||||
Actor parabombPoint2;
|
Actor parabombPoint2;
|
||||||
Actor sovietRallyPoint;
|
Actor sovietRallyPoint;
|
||||||
Actor flamersEntryPoint;
|
|
||||||
Actor tanksEntryPoint;
|
|
||||||
Actor townPoint;
|
Actor townPoint;
|
||||||
Actor sovietTownAttackPoint1;
|
Actor sovietTownAttackPoint1;
|
||||||
Actor sovietTownAttackPoint2;
|
Actor sovietTownAttackPoint2;
|
||||||
@@ -103,7 +102,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
static readonly string[] SovietVehicles1 = { "3tnk" };
|
static readonly string[] SovietVehicles1 = { "3tnk" };
|
||||||
static readonly string[] SovietVehicles2 = { "3tnk", "v2rl" };
|
static readonly string[] SovietVehicles2 = { "3tnk", "v2rl" };
|
||||||
const int SovietVehiclesUpgradeTicks = 1500 * 4;
|
const int SovietVehiclesUpgradeTicks = 1500 * 4;
|
||||||
const int SovietGroupSize = 20;
|
const int SovietGroupSize = 5;
|
||||||
|
|
||||||
const int ReinforcementsTicks = 1500 * 12;
|
const int ReinforcementsTicks = 1500 * 12;
|
||||||
static readonly string[] Reinforcements =
|
static readonly string[] Reinforcements =
|
||||||
@@ -180,12 +179,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
if (allies1 != allies2)
|
if (allies1 != allies2)
|
||||||
{
|
{
|
||||||
if (world.FrameNumber == TanksTicks)
|
|
||||||
RushSovietUnits();
|
|
||||||
|
|
||||||
if (world.FrameNumber == FlamersTicks)
|
|
||||||
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)
|
||||||
@@ -218,22 +211,19 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
}
|
}
|
||||||
if (objectives[DestroySamSitesID].Status == ObjectiveStatus.InProgress)
|
if (objectives[DestroySamSitesID].Status == ObjectiveStatus.InProgress)
|
||||||
{
|
{
|
||||||
if ((sam1.Destroyed || sam1.Owner != soviets)
|
if (sams.All(s => s.IsDead() || s.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;
|
||||||
OnObjectivesUpdated(true);
|
OnObjectivesUpdated(true);
|
||||||
SpawnSignalFlare();
|
world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies1), new LocationInit(extractionLZ.Location) });
|
||||||
Sound.Play("flaren1.aud");
|
Sound.Play("flaren1.aud");
|
||||||
ExtractEinsteinAtLZ();
|
ExtractEinsteinAtLZ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (objectives[ExtractEinsteinID].Status == ObjectiveStatus.InProgress && einsteinChinook != null)
|
if (objectives[ExtractEinsteinID].Status == ObjectiveStatus.InProgress && einsteinChinook != null)
|
||||||
{
|
{
|
||||||
if (einsteinChinook.Destroyed)
|
if (einsteinChinook.IsDead())
|
||||||
{
|
{
|
||||||
objectives[ExtractEinsteinID].Status = ObjectiveStatus.Failed;
|
objectives[ExtractEinsteinID].Status = ObjectiveStatus.Failed;
|
||||||
objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed;
|
objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed;
|
||||||
@@ -253,22 +243,19 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tanya.Destroyed)
|
if (tanya.IsDead())
|
||||||
MissionFailed("Tanya was killed.");
|
MissionFailed("Tanya was killed.");
|
||||||
|
|
||||||
else if (einstein.Destroyed)
|
else if (einstein.IsDead())
|
||||||
MissionFailed("Einstein was killed.");
|
MissionFailed("Einstein was killed.");
|
||||||
|
|
||||||
world.AddFrameEndTask(w =>
|
else if (!world.Actors.Any(a => (a.Owner == allies || a.Owner == allies2) && !a.IsDead()
|
||||||
{
|
&& (a.HasTrait<Building>() && !a.HasTrait<Wall>()) || a.HasTrait<BaseBuilding>()))
|
||||||
if (!world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20)
|
|
||||||
.Any(a => a.HasTrait<Building>() && !a.HasTrait<Wall>() && (a.Owner == allies || a.Owner == allies2)))
|
|
||||||
{
|
{
|
||||||
objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed;
|
objectives[MaintainPresenceID].Status = ObjectiveStatus.Failed;
|
||||||
OnObjectivesUpdated(true);
|
OnObjectivesUpdated(true);
|
||||||
MissionFailed("The Allied reinforcements have been defeated.");
|
MissionFailed("The Allied reinforcements have been defeated.");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateDeaths()
|
void UpdateDeaths()
|
||||||
@@ -308,10 +295,10 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
void BuildSovietUnits()
|
void BuildSovietUnits()
|
||||||
{
|
{
|
||||||
if (!sovietBarracks.Destroyed)
|
if (!sovietBarracks.IsDead())
|
||||||
BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom));
|
BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom));
|
||||||
|
|
||||||
if (!sovietWarFactory.Destroyed)
|
if (!sovietWarFactory.IsDead())
|
||||||
{
|
{
|
||||||
var vehicles = world.FrameNumber >= SovietVehiclesUpgradeTicks ? SovietVehicles2 : SovietVehicles1;
|
var vehicles = world.FrameNumber >= SovietVehiclesUpgradeTicks ? SovietVehicles2 : SovietVehicles1;
|
||||||
BuildSovietUnit(VehicleQueueName, vehicles.Random(world.SharedRandom));
|
BuildSovietUnit(VehicleQueueName, vehicles.Random(world.SharedRandom));
|
||||||
@@ -320,44 +307,39 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
void ManageSovietUnits()
|
void ManageSovietUnits()
|
||||||
{
|
{
|
||||||
var idleSovietUnitsAtRP = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 3)
|
var units = world.FindAliveCombatantActorsInCircle(sovietRallyPoint.CenterLocation, 10)
|
||||||
.Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>());
|
.Where(u => u.IsIdle && u.HasTrait<Mobile>() && u.HasTrait<AttackBase>() && u.Owner == soviets)
|
||||||
|
.Except(world.WorldActor.Trait<SpawnMapActors>().Actors.Values);
|
||||||
if (idleSovietUnitsAtRP.Count() >= SovietGroupSize)
|
if (units.Count() >= SovietGroupSize)
|
||||||
{
|
{
|
||||||
var firstUnit = idleSovietUnitsAtRP.FirstOrDefault();
|
foreach (var unit in units)
|
||||||
if (firstUnit != null)
|
MissionUtils.AttackNearestLandActor(true, unit, allies2);
|
||||||
{
|
|
||||||
var closestAlliedBuilding = ClosestAlliedBuilding(firstUnit, 40);
|
|
||||||
if (closestAlliedBuilding != null)
|
|
||||||
foreach (var unit in idleSovietUnitsAtRP)
|
|
||||||
{
|
|
||||||
unit.Trait<Mobile>().Nudge(unit, unit, true);
|
|
||||||
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var idleSovietUnits = world.FindAliveCombatantActorsInCircle(allies2BasePoint.CenterLocation, 20)
|
var scatteredUnits = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && u.IsIdle
|
||||||
.Where(a => a.Owner == soviets && a.IsIdle && a.HasTrait<IMove>());
|
&& u.HasTrait<Mobile>() && u.HasTrait<AttackBase>() && u.Owner == soviets)
|
||||||
|
.Except(world.WorldActor.Trait<SpawnMapActors>().Actors.Values)
|
||||||
|
.Except(units);
|
||||||
|
|
||||||
foreach (var unit in idleSovietUnits)
|
foreach (var unit in scatteredUnits)
|
||||||
{
|
MissionUtils.AttackNearestLandActor(true, unit, allies2);
|
||||||
var closestAlliedBuilding = ClosestAlliedBuilding(unit, 40);
|
|
||||||
|
|
||||||
if (closestAlliedBuilding != null)
|
|
||||||
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Attack(Target.FromActor(closestAlliedBuilding), 3)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor ClosestAlliedBuilding(Actor actor, int range)
|
void SetupAlliedBase()
|
||||||
{
|
{
|
||||||
return MissionUtils.ClosestPlayerBuilding(world, allies2, actor.CenterLocation, range);
|
foreach (var actor in world.Actors.Where(a => a.Owner == allies && a != allies.PlayerActor))
|
||||||
|
{
|
||||||
|
actor.ChangeOwner(allies2);
|
||||||
|
if (actor.Info.Name == "pbox")
|
||||||
|
{
|
||||||
|
actor.AddTrait(new TransformedAction(s => s.Trait<Cargo>().Load(s, world.CreateActor(false, "e1", allies2, null, null))));
|
||||||
|
actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true });
|
||||||
|
}
|
||||||
|
if (actor.Info.Name == "proc")
|
||||||
|
actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true });
|
||||||
|
foreach (var c in actor.TraitsImplementing<INotifyCapture>())
|
||||||
|
c.OnCapture(actor, actor, allies, allies2);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<Actor> ClosestAlliedBuildings(Actor actor, int range)
|
|
||||||
{
|
|
||||||
return MissionUtils.ClosestPlayerBuildings(world, allies2, actor.CenterLocation, range);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitializeSovietFactories()
|
void InitializeSovietFactories()
|
||||||
@@ -365,7 +347,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
var sbrp = sovietBarracks.Trait<RallyPoint>();
|
var sbrp = sovietBarracks.Trait<RallyPoint>();
|
||||||
var swrp = sovietWarFactory.Trait<RallyPoint>();
|
var swrp = sovietWarFactory.Trait<RallyPoint>();
|
||||||
sbrp.rallyPoint = swrp.rallyPoint = sovietRallyPoint.Location;
|
sbrp.rallyPoint = swrp.rallyPoint = sovietRallyPoint.Location;
|
||||||
sbrp.nearEnough = swrp.nearEnough = 3;
|
sbrp.nearEnough = swrp.nearEnough = 6;
|
||||||
sovietBarracks.Trait<PrimaryBuilding>().SetPrimaryProducer(sovietBarracks, true);
|
sovietBarracks.Trait<PrimaryBuilding>().SetPrimaryProducer(sovietBarracks, true);
|
||||||
sovietWarFactory.Trait<PrimaryBuilding>().SetPrimaryProducer(sovietWarFactory, true);
|
sovietWarFactory.Trait<PrimaryBuilding>().SetPrimaryProducer(sovietWarFactory, true);
|
||||||
}
|
}
|
||||||
@@ -378,11 +360,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, unit, 1));
|
queue.ResolveOrder(queue.self, Order.StartProduction(queue.self, unit, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnSignalFlare()
|
|
||||||
{
|
|
||||||
world.CreateActor(SignalFlareName, new TypeDictionary { new OwnerInit(allies1), new LocationInit(extractionLZ.Location) });
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartReinforcementsTimer()
|
void StartReinforcementsTimer()
|
||||||
{
|
{
|
||||||
Sound.Play("timergo1.aud");
|
Sound.Play("timergo1.aud");
|
||||||
@@ -409,38 +386,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
.QueueActivity(new Move.Move(allies2BasePoint.Location));
|
.QueueActivity(new Move.Move(allies2BasePoint.Location));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RushSovietUnits()
|
|
||||||
{
|
|
||||||
var closestAlliedBuildings = ClosestAlliedBuildings(badgerDropPoint1, 40);
|
|
||||||
if (!closestAlliedBuildings.Any()) return;
|
|
||||||
|
|
||||||
foreach (var tank in Tanks)
|
|
||||||
{
|
|
||||||
var unit = world.CreateActor(tank, new TypeDictionary
|
|
||||||
{
|
|
||||||
new OwnerInit(soviets),
|
|
||||||
new LocationInit(tanksEntryPoint.Location)
|
|
||||||
});
|
|
||||||
foreach (var building in closestAlliedBuildings)
|
|
||||||
unit.QueueActivity(new Attack(Target.FromActor(building), 3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RushSovietFlamers()
|
|
||||||
{
|
|
||||||
var closestAlliedBuilding = ClosestAlliedBuilding(badgerDropPoint1, 40);
|
|
||||||
if (closestAlliedBuilding == null) return;
|
|
||||||
|
|
||||||
var apc = world.CreateActor(ApcName, new TypeDictionary { new OwnerInit(soviets), new LocationInit(flamersEntryPoint.Location) });
|
|
||||||
foreach (var flamer in Flamers)
|
|
||||||
{
|
|
||||||
var unit = world.CreateActor(false, flamer, new TypeDictionary { new OwnerInit(soviets) });
|
|
||||||
apc.Trait<Cargo>().Load(apc, unit);
|
|
||||||
}
|
|
||||||
apc.QueueActivity(new MoveAdjacentTo(Target.FromActor(closestAlliedBuilding)));
|
|
||||||
apc.QueueActivity(new UnloadCargo(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtractEinsteinAtLZ()
|
void ExtractEinsteinAtLZ()
|
||||||
{
|
{
|
||||||
einsteinChinook = MissionUtils.ExtractUnitWithChinook(
|
einsteinChinook = MissionUtils.ExtractUnitWithChinook(
|
||||||
@@ -461,7 +406,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
void TransferTownUnitsToAllies()
|
void TransferTownUnitsToAllies()
|
||||||
{
|
{
|
||||||
foreach (var unit in world.FindAliveNonCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange)
|
foreach (var unit in world.FindAliveNonCombatantActorsInCircle(townPoint.CenterLocation, AlliedTownTransferRange)
|
||||||
.Where(a => a.HasTrait<IMove>()))
|
.Where(a => a.HasTrait<Mobile>()))
|
||||||
unit.ChangeOwner(allies1);
|
unit.ChangeOwner(allies1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,11 +437,14 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
allies = w.Players.Single(p => p.InternalName == "Allies");
|
allies = w.Players.Single(p => p.InternalName == "Allies");
|
||||||
soviets = w.Players.Single(p => p.InternalName == "Soviets");
|
soviets = w.Players.Single(p => p.InternalName == "Soviets");
|
||||||
|
|
||||||
|
soviets.PlayerActor.Trait<PlayerResources>().Cash = 1000;
|
||||||
|
|
||||||
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
sam1 = actors["SAM1"];
|
sam1 = actors["SAM1"];
|
||||||
sam2 = actors["SAM2"];
|
sam2 = actors["SAM2"];
|
||||||
sam3 = actors["SAM3"];
|
sam3 = actors["SAM3"];
|
||||||
sam4 = actors["SAM4"];
|
sam4 = actors["SAM4"];
|
||||||
|
sams = new[] { sam1, sam2, sam3, sam4 };
|
||||||
tanya = actors["Tanya"];
|
tanya = actors["Tanya"];
|
||||||
einstein = actors["Einstein"];
|
einstein = actors["Einstein"];
|
||||||
engineer = actors["Engineer"];
|
engineer = actors["Engineer"];
|
||||||
@@ -515,17 +463,15 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
sovietBarracks = actors["SovietBarracks"];
|
sovietBarracks = actors["SovietBarracks"];
|
||||||
sovietWarFactory = actors["SovietWarFactory"];
|
sovietWarFactory = actors["SovietWarFactory"];
|
||||||
sovietRallyPoint = actors["SovietRallyPoint"];
|
sovietRallyPoint = actors["SovietRallyPoint"];
|
||||||
flamersEntryPoint = actors["FlamersEntryPoint"];
|
|
||||||
tanksEntryPoint = actors["TanksEntryPoint"];
|
|
||||||
townPoint = actors["TownPoint"];
|
townPoint = actors["TownPoint"];
|
||||||
sovietTownAttackPoint1 = actors["SovietTownAttackPoint1"];
|
sovietTownAttackPoint1 = actors["SovietTownAttackPoint1"];
|
||||||
sovietTownAttackPoint2 = actors["SovietTownAttackPoint2"];
|
sovietTownAttackPoint2 = actors["SovietTownAttackPoint2"];
|
||||||
yakEntryPoint = actors["YakEntryPoint"];
|
yakEntryPoint = actors["YakEntryPoint"];
|
||||||
yakAttackPoint = actors["YakAttackPoint"];
|
yakAttackPoint = actors["YakAttackPoint"];
|
||||||
|
|
||||||
SetupAlliedBase(actors);
|
SetupAlliedBase();
|
||||||
|
|
||||||
var shroud = w.WorldActor.Trait<Shroud>();
|
var shroud = allies1.Shroud;
|
||||||
shroud.Explore(w, sam1.Location, 2);
|
shroud.Explore(w, sam1.Location, 2);
|
||||||
shroud.Explore(w, sam2.Location, 2);
|
shroud.Explore(w, sam2.Location, 2);
|
||||||
shroud.Explore(w, sam3.Location, 2);
|
shroud.Explore(w, sam3.Location, 2);
|
||||||
@@ -539,20 +485,5 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
MissionUtils.PlayMissionMusic();
|
MissionUtils.PlayMissionMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupAlliedBase(Dictionary<string, Actor> actors)
|
|
||||||
{
|
|
||||||
world.AddFrameEndTask(w =>
|
|
||||||
{
|
|
||||||
foreach (var actor in actors.Where(a => a.Value.Owner == allies))
|
|
||||||
actor.Value.ChangeOwner(allies2);
|
|
||||||
|
|
||||||
world.CreateActor("proc", new TypeDictionary
|
|
||||||
{
|
|
||||||
new LocationInit(actors["Allies2ProcPoint"].Location),
|
|
||||||
new OwnerInit(allies2)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,30 +109,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
return units.Any() && units.All(a => a.Owner == player);
|
return units.Any() && units.All(a => a.Owner == player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Actor ClosestPlayerUnit(World world, Player player, PPos location, int range)
|
|
||||||
{
|
|
||||||
return ClosestPlayerUnits(world, player, location, range).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<Actor> ClosestPlayerUnits(World world, Player player, PPos location, int range)
|
|
||||||
{
|
|
||||||
return world.FindAliveCombatantActorsInCircle(location, range)
|
|
||||||
.Where(a => a.Owner == player && a.HasTrait<IMove>())
|
|
||||||
.OrderBy(a => (location - a.CenterLocation).LengthSquared);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Actor ClosestPlayerBuilding(World world, Player player, PPos location, int range)
|
|
||||||
{
|
|
||||||
return ClosestPlayerBuildings(world, player, location, range).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<Actor> ClosestPlayerBuildings(World world, Player player, PPos location, int range)
|
|
||||||
{
|
|
||||||
return world.FindAliveCombatantActorsInCircle(location, range)
|
|
||||||
.Where(a => a.Owner == player && a.HasTrait<Building>() && !a.HasTrait<Wall>())
|
|
||||||
.OrderBy(a => (location - a.CenterLocation).LengthSquared);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<ProductionQueue> FindQueues(World world, Player player, string category)
|
public static IEnumerable<ProductionQueue> FindQueues(World world, Player player, string category)
|
||||||
{
|
{
|
||||||
return world.ActorsWithTrait<ProductionQueue>()
|
return world.ActorsWithTrait<ProductionQueue>()
|
||||||
@@ -231,7 +207,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
public static void AttackNearestLandActor(bool queued, Actor self, Player enemyPlayer)
|
public static void AttackNearestLandActor(bool queued, Actor self, Player enemyPlayer)
|
||||||
{
|
{
|
||||||
var enemies = self.World.Actors.Where(u => u.AppearsHostileTo(self) && u.Owner == enemyPlayer
|
var enemies = self.World.Actors.Where(u => u.AppearsHostileTo(self) && u.Owner == enemyPlayer
|
||||||
&& ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>()) && u.IsInWorld && !u.IsDead());
|
&& ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || (u.HasTrait<Mobile>() && !u.HasTrait<Aircraft>())) && u.IsInWorld && !u.IsDead());
|
||||||
|
|
||||||
var enemy = enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault();
|
var enemy = enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault();
|
||||||
if (enemy != null)
|
if (enemy != null)
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
using OpenRA.Mods.RA.Move;
|
using OpenRA.Mods.RA.Move;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Missions
|
namespace OpenRA.Mods.RA.Missions
|
||||||
{
|
{
|
||||||
@@ -137,11 +137,10 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
if (baseTransferredTick == -1)
|
if (baseTransferredTick == -1)
|
||||||
{
|
{
|
||||||
var actorsInBase = world.FindUnits(alliedBaseTopLeft.CenterLocation, alliedBaseBottomRight.CenterLocation).Where(a => !a.IsDead() && a.IsInWorld);
|
var actorsInBase = world.FindUnits(alliedBaseTopLeft.CenterLocation, alliedBaseBottomRight.CenterLocation).Where(a => a != a.Owner.PlayerActor);
|
||||||
if (actorsInBase.Any(a => a.Owner == greece))
|
if (actorsInBase.Any(a => a.Owner == greece))
|
||||||
{
|
{
|
||||||
foreach (var actor in actorsInBase)
|
SetupAlliedBase(actorsInBase);
|
||||||
TransferActorToAllies(actor);
|
|
||||||
baseTransferredTick = world.FrameNumber;
|
baseTransferredTick = world.FrameNumber;
|
||||||
objectives[FindOutpostID].Status = ObjectiveStatus.Completed;
|
objectives[FindOutpostID].Status = ObjectiveStatus.Completed;
|
||||||
OnObjectivesUpdated(true);
|
OnObjectivesUpdated(true);
|
||||||
@@ -234,7 +233,9 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferActorToAllies(Actor actor)
|
void SetupAlliedBase(IEnumerable<Actor> actors)
|
||||||
|
{
|
||||||
|
foreach (var actor in actors)
|
||||||
{
|
{
|
||||||
// hack hack hack
|
// hack hack hack
|
||||||
actor.ChangeOwner(greece);
|
actor.ChangeOwner(greece);
|
||||||
@@ -243,11 +244,11 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
actor.AddTrait(new TransformedAction(s => s.Trait<Cargo>().Load(s, world.CreateActor(false, "e1", greece, null, null))));
|
actor.AddTrait(new TransformedAction(s => s.Trait<Cargo>().Load(s, world.CreateActor(false, "e1", greece, null, null))));
|
||||||
actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true });
|
actor.QueueActivity(new Transform(actor, "hbox.e1") { SkipMakeAnims = true });
|
||||||
}
|
}
|
||||||
else if (actor.Info.Name == "proc.nofreeactor")
|
else if (actor.Info.Name == "proc")
|
||||||
actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true });
|
actor.QueueActivity(new Transform(actor, "proc") { SkipMakeAnims = true });
|
||||||
var building = actor.TraitOrDefault<Building>();
|
foreach (var c in actor.TraitsImplementing<INotifyCapture>())
|
||||||
if (building != null)
|
c.OnCapture(actor, actor, neutral, greece);
|
||||||
building.OnCapture(actor, actor, neutral, greece);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvacuateCivilians()
|
void EvacuateCivilians()
|
||||||
|
|||||||
@@ -852,9 +852,6 @@ Actors:
|
|||||||
Actor301: tc04
|
Actor301: tc04
|
||||||
Location: 27,33
|
Location: 27,33
|
||||||
Owner: Neutral
|
Owner: Neutral
|
||||||
Actor265: miss
|
|
||||||
Location: 27,23
|
|
||||||
Owner: Soviets
|
|
||||||
Actor402: brik
|
Actor402: brik
|
||||||
Location: 22,67
|
Location: 22,67
|
||||||
Owner: Soviets
|
Owner: Soviets
|
||||||
@@ -1481,9 +1478,10 @@ Actors:
|
|||||||
Actor290: apwr
|
Actor290: apwr
|
||||||
Location: 52,42
|
Location: 52,42
|
||||||
Owner: Soviets
|
Owner: Soviets
|
||||||
Allies2ProcPoint: waypoint
|
Actor875: proc
|
||||||
Location: 25,95
|
Location: 25,95
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
|
FreeActor: False
|
||||||
Actor455: fenc
|
Actor455: fenc
|
||||||
Location: 31,93
|
Location: 31,93
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
@@ -1517,13 +1515,13 @@ Actors:
|
|||||||
Actor470: fenc
|
Actor470: fenc
|
||||||
Location: 26,93
|
Location: 26,93
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
Actor454: pbox.e1
|
Actor454: pbox
|
||||||
Location: 32,93
|
Location: 32,93
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
Actor465: fenc
|
Actor465: fenc
|
||||||
Location: 30,93
|
Location: 30,93
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
Actor473: pbox.e1
|
Actor473: pbox
|
||||||
Location: 40,93
|
Location: 40,93
|
||||||
Owner: Allies
|
Owner: Allies
|
||||||
Actor472: gun
|
Actor472: gun
|
||||||
@@ -3006,6 +3004,9 @@ Rules:
|
|||||||
CTNK:
|
CTNK:
|
||||||
Buildable:
|
Buildable:
|
||||||
Owner: None
|
Owner: None
|
||||||
|
MGG:
|
||||||
|
Buildable:
|
||||||
|
Owner: None
|
||||||
CRATE:
|
CRATE:
|
||||||
GiveCashCrateAction:
|
GiveCashCrateAction:
|
||||||
SelectionShares: 0
|
SelectionShares: 0
|
||||||
|
|||||||
@@ -1754,11 +1754,12 @@ Actors:
|
|||||||
Owner: BadGuy
|
Owner: BadGuy
|
||||||
Health: 1
|
Health: 1
|
||||||
Facing: 0
|
Facing: 0
|
||||||
AlliedBaseProc: proc.nofreeactor
|
AlliedBaseProc: proc
|
||||||
Location: 27,25
|
Location: 27,25
|
||||||
Owner: Neutral
|
Owner: Neutral
|
||||||
Health: 0.3476563
|
Health: 0.3476563
|
||||||
Facing: 0
|
Facing: 0
|
||||||
|
FreeActor: False
|
||||||
Actor508: silo
|
Actor508: silo
|
||||||
Location: 36,18
|
Location: 36,18
|
||||||
Owner: Neutral
|
Owner: Neutral
|
||||||
@@ -2609,14 +2610,6 @@ Rules:
|
|||||||
RenderBuilding:
|
RenderBuilding:
|
||||||
Image: DOME
|
Image: DOME
|
||||||
-InfiltrateForExploration:
|
-InfiltrateForExploration:
|
||||||
PROC.NoFreeActor:
|
|
||||||
Inherits: PROC
|
|
||||||
-Buildable:
|
|
||||||
RenderBuilding:
|
|
||||||
Image: PROC
|
|
||||||
Tooltip:
|
|
||||||
Icon: procicon
|
|
||||||
-FreeActor:
|
|
||||||
V19:
|
V19:
|
||||||
AutoTargetIgnore:
|
AutoTargetIgnore:
|
||||||
TRAN:
|
TRAN:
|
||||||
|
|||||||
Reference in New Issue
Block a user