Added New Missions
Added New Single-player Survival Map - Survival02 Added New 4 Player Co-op Survival Minigame - Fort LoneStar
This commit is contained in:
409
OpenRA.Mods.RA/Missions/FortScript.cs
Normal file
409
OpenRA.Mods.RA/Missions/FortScript.cs
Normal file
@@ -0,0 +1,409 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
class FortScriptInfo : TraitInfo<FortScript>, Requires<SpawnMapActorsInfo> { }
|
||||
|
||||
class FortScript : IWorldLoaded, ITick
|
||||
{
|
||||
Player multi0;
|
||||
Player soviets;
|
||||
|
||||
Actor entry1;
|
||||
Actor entry2;
|
||||
Actor entry3;
|
||||
Actor entry4;
|
||||
Actor entry5;
|
||||
Actor entry6;
|
||||
Actor entry7;
|
||||
Actor entry8;
|
||||
CPos[] sovietEntryPoints;
|
||||
Actor paradrop1;
|
||||
Actor paradrop2;
|
||||
Actor paradrop3;
|
||||
Actor paradrop4;
|
||||
|
||||
Actor baseA;
|
||||
Actor baseB;
|
||||
|
||||
World world;
|
||||
|
||||
int WaveNumber = 0;
|
||||
InfoWidget evacuateWidget;
|
||||
const string ShortEvacuateTemplate = "Wave {0}";
|
||||
static readonly string[] PatrolA = { "e1", "e2", "e1" };
|
||||
static readonly string[] Infantry = { "e4", "e1", "e1", "e2", "e1", "e2" };
|
||||
static readonly string[] InfantryAdvanced = { "e4", "e1", "e1", "shok", "e1", "e2", "e4" };
|
||||
static readonly string[] Vehicles = { "arty", "ftrk", "ftrk", "jeep", "jeep", "jeep", "apc", "apc", };
|
||||
static readonly string[] Volkov = { "e8" };
|
||||
const string boss = "4tnk";
|
||||
const int TimerTicks = 1;
|
||||
const int PatrolTicks = 1500;
|
||||
|
||||
int AttackSquad = 6;
|
||||
int AttackSquadCount = 1;
|
||||
int VehicleSquad = 2;
|
||||
int VehicleSquadCount = 1;
|
||||
|
||||
int patrolAttackFrame;
|
||||
int patrolattackAtFrameIncrement;
|
||||
int WaveAttackFrame;
|
||||
int WaveAttackAtFrameIncrement;
|
||||
int VehicleAttackFrame;
|
||||
int VehicleAttackAtFrameIncrement;
|
||||
|
||||
void MissionAccomplished(string text)
|
||||
{
|
||||
MissionUtils.CoopMissionAccomplished(world, text, multi0);
|
||||
}
|
||||
|
||||
void AttackNearestAlliedActor(Actor self)
|
||||
{
|
||||
var enemies = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && (u.Owner == multi0)
|
||||
&& ((u.HasTrait<Building>() && !u.HasTrait<Mobile>())));
|
||||
var targetEnemy = enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared).FirstOrDefault();
|
||||
if (targetEnemy != null)
|
||||
{
|
||||
self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Attack(Target.FromActor(targetEnemy), 6)));
|
||||
}
|
||||
}
|
||||
|
||||
void SendVehicles()
|
||||
{
|
||||
if (SpawnVehicles == true)
|
||||
{
|
||||
for (int i = 1; i <= VehicleSquadCount; i++)
|
||||
{
|
||||
var enemies = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && (u.Owner == soviets)
|
||||
&& !u.HasTrait<Mobile>());
|
||||
var route = world.SharedRandom.Next(sovietEntryPoints.Length);
|
||||
var spawnPoint = sovietEntryPoints[route];
|
||||
for (int r = 1; r <= VehicleSquad; r++)
|
||||
{
|
||||
var squad = world.CreateActor(Vehicles.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(spawnPoint), new OwnerInit(soviets) });
|
||||
squad.QueueActivity(new AttackMove.AttackMoveActivity(squad, new Move.Move(paradrop1.Location, 3)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SendWave()
|
||||
{
|
||||
if (SpawnWave == true)
|
||||
{
|
||||
for (int i = 1; i <= AttackSquadCount; i++)
|
||||
{
|
||||
var enemies = world.Actors.Where(u => u.IsInWorld && !u.IsDead() && (u.Owner == soviets)
|
||||
&& !u.HasTrait<Mobile>());
|
||||
var route = world.SharedRandom.Next(sovietEntryPoints.Length);
|
||||
var spawnPoint = sovietEntryPoints[route];
|
||||
IEnumerable<string> units;
|
||||
if (world.FrameNumber >= 1500 * 10)
|
||||
{
|
||||
units = InfantryAdvanced;
|
||||
}
|
||||
else
|
||||
{
|
||||
units = Infantry;
|
||||
}
|
||||
for (int r = 1; r < AttackSquad; r++)
|
||||
{
|
||||
var squad = world.CreateActor(Infantry.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(spawnPoint), new OwnerInit(soviets) });
|
||||
squad.QueueActivity(new AttackMove.AttackMoveActivity(squad, new Move.Move(paradrop1.Location, 3)));
|
||||
var scatteredUnits = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location), 15)
|
||||
.Where(unit => unit.IsIdle && unit.HasTrait<Mobile>() && unit.Owner == soviets);
|
||||
foreach (var unit in scatteredUnits)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SendPatrol()
|
||||
{
|
||||
if (SpawnPatrol == true)
|
||||
{
|
||||
for (int i = 0; i < PatrolA.Length; i++)
|
||||
{
|
||||
var inf = world.CreateActor(PatrolA.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(paradrop1.Location + new CVec(0, -10)), new OwnerInit(soviets) });
|
||||
inf.QueueActivity(new AttackMove.AttackMoveActivity(inf, new Move.Move(paradrop1.Location + new CVec(0, 0))));
|
||||
var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location), 20)
|
||||
.Where(u => u.Owner == soviets);
|
||||
foreach (var unit in units)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PatrolA.Length; i++)
|
||||
{
|
||||
var inf = world.CreateActor(PatrolA.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(paradrop4.Location + new CVec(10, 0)), new OwnerInit(soviets) });
|
||||
inf.QueueActivity(new AttackMove.AttackMoveActivity(inf, new Move.Move(paradrop4.Location + new CVec(0, 0))));
|
||||
var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location), 20)
|
||||
.Where(u => u.Owner == soviets);
|
||||
foreach (var unit in units)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PatrolA.Length; i++)
|
||||
{
|
||||
var inf = world.CreateActor(PatrolA.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(paradrop3.Location + new CVec(0, 10)), new OwnerInit(soviets) });
|
||||
inf.QueueActivity(new AttackMove.AttackMoveActivity(inf, new Move.Move(paradrop3.Location + new CVec(0, 0))));
|
||||
var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location), 20)
|
||||
.Where(u => u.Owner == soviets);
|
||||
foreach (var unit in units)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < PatrolA.Length; i++)
|
||||
{
|
||||
var inf = world.CreateActor(PatrolA.Random(world.SharedRandom),
|
||||
new TypeDictionary { new LocationInit(paradrop2.Location + new CVec(-10, 0)), new OwnerInit(soviets) });
|
||||
inf.QueueActivity(new AttackMove.AttackMoveActivity(inf, new Move.Move(paradrop2.Location + new CVec(0, 0))));
|
||||
var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location), 20)
|
||||
.Where(u => u.Owner == soviets);
|
||||
foreach (var unit in units)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SendVolkov()
|
||||
{
|
||||
for (int i = 0; i < Volkov.Length; i++)
|
||||
{
|
||||
var route = world.SharedRandom.Next(sovietEntryPoints.Length);
|
||||
var spawnPoint = sovietEntryPoints[route];
|
||||
var actor = world.CreateActor(Volkov[i], new TypeDictionary { new OwnerInit(soviets), new LocationInit(spawnPoint) });
|
||||
actor.QueueActivity(new Move.Move(paradrop1.Location + new CVec(4, -11)));
|
||||
var scatteredUnits = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(paradrop1.Location + new CVec(4, -11)), 4)
|
||||
.Where(unit => unit.IsIdle && unit.HasTrait<Mobile>() && unit.Owner == soviets);
|
||||
foreach (var unit in scatteredUnits)
|
||||
{
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Wave(string text)
|
||||
{
|
||||
Game.AddChatLine(Color.Cyan, "Wave Sequence", text);
|
||||
}
|
||||
|
||||
void FinalWave(string text)
|
||||
{
|
||||
Game.AddChatLine(Color.DarkRed, "Boss Wave Sequence Initializing", text);
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var unitsAndBuildings = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && (a.HasTrait<Mobile>() && a.HasTrait<IMove>()));
|
||||
if (!unitsAndBuildings.Any(a => a.Owner == soviets))
|
||||
{
|
||||
MissionAccomplished("You and your mates have survived the onslaught!");
|
||||
}
|
||||
if (world.FrameNumber == patrolAttackFrame)
|
||||
{
|
||||
patrolAttackFrame += patrolattackAtFrameIncrement;
|
||||
patrolattackAtFrameIncrement = Math.Max(patrolattackAtFrameIncrement - 5, 100);
|
||||
SendPatrol();
|
||||
}
|
||||
if (world.FrameNumber == WaveAttackFrame)
|
||||
{
|
||||
WaveAttackFrame += WaveAttackAtFrameIncrement;
|
||||
WaveAttackAtFrameIncrement = Math.Max(WaveAttackAtFrameIncrement - 5, 100);
|
||||
SendWave();
|
||||
}
|
||||
if (world.FrameNumber == VehicleAttackFrame)
|
||||
{
|
||||
VehicleAttackFrame += VehicleAttackAtFrameIncrement;
|
||||
VehicleAttackAtFrameIncrement = Math.Max(VehicleAttackAtFrameIncrement - 5, 100);
|
||||
SendVehicles();
|
||||
}
|
||||
if (world.FrameNumber == TimerTicks)
|
||||
{
|
||||
evacuateWidget = new InfoWidget("");
|
||||
Ui.Root.AddChild(evacuateWidget);
|
||||
WaveNumber++;
|
||||
Wave("One Initializing");
|
||||
UpdateWaveSequence();
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 2)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Two Initializing");
|
||||
SpawnPatrol = false;
|
||||
AttackSquad = 7;
|
||||
AttackSquadCount = 2;
|
||||
UpdateWaveSequence();
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location + new CVec(0, -2));
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 4)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Three Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 8;
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 6)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Four Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 9;
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry2.Location, paradrop3.Location);
|
||||
AttackSquadCount = 3;
|
||||
VehicleSquad = 3;
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 8)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Five Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 10;
|
||||
SendVolkov();
|
||||
VehicleSquad = 4;
|
||||
VehicleSquadCount = 2;
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 10)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Six Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 11;
|
||||
AttackSquadCount = 4;
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry4.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry6.Location, paradrop3.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry5.Location, paradrop3.Location);
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 12)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Seven Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 12;
|
||||
VehicleSquad = 5;
|
||||
VehicleSquadCount = 3;
|
||||
SendVolkov();
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 14)
|
||||
{
|
||||
SpawnVehicles = true;
|
||||
WaveNumber++;
|
||||
Wave("Eight Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 13;
|
||||
AttackSquadCount = 5;
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry4.Location, paradrop1.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry6.Location, paradrop3.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry5.Location, paradrop3.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry2.Location, paradrop2.Location);
|
||||
MissionUtils.Parabomb(world, soviets, entry3.Location, paradrop2.Location);
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 16)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Nine Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 14;
|
||||
VehicleSquad = 6;
|
||||
VehicleSquadCount = 4;
|
||||
SendVolkov();
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 18)
|
||||
{
|
||||
WaveNumber++;
|
||||
Wave("Ten Initializing");
|
||||
UpdateWaveSequence();
|
||||
AttackSquad = 15;
|
||||
AttackSquadCount = 6;
|
||||
MissionUtils.Parabomb(world, soviets, entry1.Location, paradrop1.Location + new CVec(0, -2));
|
||||
MissionUtils.Parabomb(world, soviets, entry2.Location, paradrop3.Location + new CVec(0, -2));
|
||||
MissionUtils.Parabomb(world, soviets, entry4.Location, paradrop2.Location + new CVec(0, -2));
|
||||
MissionUtils.Parabomb(world, soviets, entry5.Location, paradrop4.Location + new CVec(0, -2));
|
||||
MissionUtils.Parabomb(world, soviets, entry2.Location, paradrop1.Location + new CVec(0, 2));
|
||||
MissionUtils.Parabomb(world, soviets, entry4.Location, paradrop3.Location + new CVec(0, 2));
|
||||
MissionUtils.Parabomb(world, soviets, entry3.Location, paradrop2.Location + new CVec(0, 2));
|
||||
MissionUtils.Parabomb(world, soviets, entry5.Location, paradrop4.Location + new CVec(0, 2));
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 19)
|
||||
{
|
||||
SpawnWave = false;
|
||||
SpawnVehicles = false;
|
||||
}
|
||||
if (world.FrameNumber == 1500 * 20)
|
||||
{
|
||||
MissionAccomplished("You and your mates have Survived the Onslaught!");
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWaveSequence()
|
||||
{
|
||||
evacuateWidget.Text = ShortEvacuateTemplate.F(WaveNumber);
|
||||
}
|
||||
|
||||
bool SpawnPatrol = true;
|
||||
|
||||
bool SpawnWave = true;
|
||||
|
||||
bool SpawnVehicles = true;
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
world = w;
|
||||
soviets = w.Players.Single(p => p.InternalName == "Soviets");
|
||||
multi0 = w.Players.Single(p => p.InternalName == "Multi0");
|
||||
patrolAttackFrame = 750;
|
||||
patrolattackAtFrameIncrement = 750;
|
||||
WaveAttackFrame = 500;
|
||||
WaveAttackAtFrameIncrement = 500;
|
||||
VehicleAttackFrame = 2000;
|
||||
VehicleAttackAtFrameIncrement = 2000;
|
||||
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
entry1 = actors["Entry1"];
|
||||
entry2 = actors["Entry2"];
|
||||
entry3 = actors["Entry3"];
|
||||
entry4 = actors["Entry4"];
|
||||
entry5 = actors["Entry5"];
|
||||
entry6 = actors["Entry6"];
|
||||
entry7 = actors["Entry7"];
|
||||
entry8 = actors["Entry8"];
|
||||
sovietEntryPoints = new[] { entry1, entry2, entry3, entry4, entry5, entry6, entry7, entry8 }.Select(p => p.Location).ToArray();
|
||||
paradrop1 = actors["Paradrop1"];
|
||||
paradrop2 = actors["Paradrop2"];
|
||||
paradrop3 = actors["Paradrop3"];
|
||||
paradrop4 = actors["Paradrop4"];
|
||||
baseA = actors["BaseA"];
|
||||
baseB = actors["BaseB"];
|
||||
MissionUtils.PlayMissionMusic();
|
||||
Game.AddChatLine(Color.Cyan, "Mission", "Defend Fort LoneStar At All costs!");
|
||||
}
|
||||
}
|
||||
}
|
||||
417
OpenRA.Mods.RA/Missions/Survival02Script.cs
Normal file
417
OpenRA.Mods.RA/Missions/Survival02Script.cs
Normal file
@@ -0,0 +1,417 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Mods.RA.Air;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.RA.Missions
|
||||
{
|
||||
class Survival02ScriptInfo : TraitInfo<Survival02Script>, Requires<SpawnMapActorsInfo> { }
|
||||
|
||||
class Survival02Script : IHasObjectives, IWorldLoaded, ITick
|
||||
{
|
||||
public event Action<bool> OnObjectivesUpdated = notify => { };
|
||||
|
||||
public IEnumerable<Objective> Objectives { get { return objectives.Values; } }
|
||||
|
||||
Dictionary<int, Objective> objectives = new Dictionary<int, Objective>
|
||||
{
|
||||
{ maintainPresenceID, new Objective(ObjectiveType.Primary, maintainPresence, ObjectiveStatus.InProgress) },
|
||||
{ destroySovietsID, new Objective(ObjectiveType.Primary, destroySoviets, ObjectiveStatus.Inactive) },
|
||||
};
|
||||
const int destroySovietsID = 0;
|
||||
const string destroySoviets = "Excellent work Commander! We have reinforced our position enough to initiate a counter-attack. Destroy the remaining Soviet forces in the area!";
|
||||
const int maintainPresenceID = 1;
|
||||
const string maintainPresence = "Commander! The Soviets have rendered us useless... Reports indicate Soviet reinforcements are coming to finish us off... the situation looks bleak...";
|
||||
|
||||
Player allies;
|
||||
Player soviets;
|
||||
|
||||
Actor sovietEntry1;
|
||||
Actor sovietEntry2;
|
||||
Actor sovietEntry3;
|
||||
CPos[] sovietentrypoints;
|
||||
CPos[] newsovietentrypoints;
|
||||
|
||||
Actor sovietrally;
|
||||
Actor sovietrally1;
|
||||
Actor sovietrally2;
|
||||
Actor sovietrally3;
|
||||
Actor sovietrally4;
|
||||
Actor sovietrally5;
|
||||
Actor sovietrally6;
|
||||
Actor sovietrally7;
|
||||
Actor sovietrally8;
|
||||
CPos[] sovietrallypoints;
|
||||
CPos[] newsovietrallypoints;
|
||||
|
||||
Actor sovietparadrop1;
|
||||
Actor sovietparadrop2;
|
||||
Actor sovietparadrop3;
|
||||
Actor sovietparadropEntry;
|
||||
|
||||
Actor alliesbase;
|
||||
Actor factory;
|
||||
Actor barrack1;
|
||||
|
||||
Actor boom1;
|
||||
Actor boom2;
|
||||
Actor boom3;
|
||||
Actor drum1;
|
||||
Actor drum2;
|
||||
Actor drum3;
|
||||
Actor FranceEntry;
|
||||
Actor FranceRally;
|
||||
Actor FranceparaEntry1;
|
||||
Actor FranceparaEntry2;
|
||||
Actor FranceparaEntry3;
|
||||
|
||||
|
||||
World world;
|
||||
|
||||
CountdownTimer survivalTimer;
|
||||
CountdownTimerWidget survivalTimerWidget;
|
||||
|
||||
const int timerTicks = 1500 * 10;
|
||||
const int attackTicks = 1500 * 1;
|
||||
const int sovietAttackGroupSize = 7;
|
||||
const int SovietGroupSize = 4;
|
||||
|
||||
const string Camera = "Camera";
|
||||
const string InfantryQueueName = "Infantry";
|
||||
const string Flare = "flare";
|
||||
|
||||
static readonly string[] FrenchSquad = { "2tnk", "2tnk", "mcv" };
|
||||
static readonly string[] SovietInfantry = { "e1", "e4", "e2" };
|
||||
static readonly string[] SovietVehicles = { "3tnk", "3tnk", "v2rl" };
|
||||
static readonly string[] SovietTanks = { "3tnk", "3tnk", "3tnk" };
|
||||
static readonly string[] squad = { "e1", "e1", "e2", "e4", "e4" };
|
||||
static readonly string[] platoon = { "e1", "e1", "e2", "e4", "e4", "e1", "e1", "e2", "e4", "e4" };
|
||||
|
||||
int ProduceAtFrame;
|
||||
int ProduceAtFrameIncrement;
|
||||
int attackAtFrame;
|
||||
int attackAtFrameIncrement;
|
||||
|
||||
void MissionAccomplished(string text)
|
||||
{
|
||||
MissionUtils.CoopMissionAccomplished(world, text, allies);
|
||||
}
|
||||
|
||||
void MissionFailed(string text)
|
||||
{
|
||||
MissionUtils.CoopMissionFailed(world, text, allies);
|
||||
}
|
||||
|
||||
void Message(string text)
|
||||
{
|
||||
Game.AddChatLine(Color.Aqua, "Incoming Report", text);
|
||||
}
|
||||
|
||||
void SetSovietUnitsToDefensiveStance()
|
||||
{
|
||||
foreach (var actor in world.Actors.Where(a => a.IsInWorld && a.Owner == soviets && !a.IsDead() && a.HasTrait<AutoTarget>()))
|
||||
actor.Trait<AutoTarget>().stance = UnitStance.Defend;
|
||||
}
|
||||
|
||||
Actor FirstUnshroudedOrDefault(IEnumerable<Actor> actors, World world, int shroudRange)
|
||||
{
|
||||
return actors.FirstOrDefault(u => world.FindAliveCombatantActorsInCircle(u.CenterLocation, shroudRange).All(a => !a.HasTrait<CreatesShroud>()));
|
||||
}
|
||||
|
||||
void AttackNearestAlliedActor(Actor self)
|
||||
{
|
||||
var enemies = world.Actors.Where(u => u.AppearsHostileTo(self) && (u.Owner == allies)
|
||||
&& ((u.HasTrait<Building>() && !u.HasTrait<Wall>()) || u.HasTrait<Mobile>()) && u.IsInWorld && !u.IsDead());
|
||||
|
||||
var enemy = FirstUnshroudedOrDefault(enemies.OrderBy(u => (self.CenterLocation - u.CenterLocation).LengthSquared), world, 20);
|
||||
if (enemy != null)
|
||||
self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Attack(Target.FromActor(enemy), 3)));
|
||||
}
|
||||
|
||||
void SpawnAndAttack(string[] squad, Player owner, CPos location)
|
||||
{
|
||||
for (int i = 0; i < squad.Length; i++)
|
||||
{
|
||||
var actor = world.CreateActor(squad[i], new TypeDictionary { new OwnerInit(owner), new LocationInit(location) });
|
||||
AttackNearestAlliedActor(actor);
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnFlare(Player owner, Actor location)
|
||||
{
|
||||
world.CreateActor(Flare, new TypeDictionary { new OwnerInit(owner), new LocationInit(location.Location) });
|
||||
}
|
||||
|
||||
void FinalAttack()
|
||||
{
|
||||
SpawnAndAttack(SovietTanks, soviets, sovietEntry1.Location);
|
||||
SpawnAndAttack(SovietTanks, soviets, sovietEntry1.Location);
|
||||
SpawnAndAttack(SovietTanks, soviets, sovietEntry2.Location);
|
||||
SpawnAndAttack(platoon, soviets, sovietEntry1.Location);
|
||||
SpawnAndAttack(platoon, soviets, sovietEntry2.Location);
|
||||
}
|
||||
|
||||
void FrenchReinforcements()
|
||||
{
|
||||
Game.MoveViewport(sovietrally1.Location.ToFloat2());
|
||||
MissionUtils.Parabomb(world, allies, FranceparaEntry1.Location, drum3.Location);
|
||||
MissionUtils.Parabomb(world, allies, FranceparaEntry3.Location, drum2.Location);
|
||||
MissionUtils.Parabomb(world, allies, FranceparaEntry2.Location, drum1.Location);
|
||||
for (int i = 0; i < FrenchSquad.Length; i++)
|
||||
{
|
||||
var actor = world.CreateActor(FrenchSquad[i], new TypeDictionary { new OwnerInit(allies), new LocationInit(FranceEntry.Location) });
|
||||
actor.QueueActivity(new Move.Move(FranceRally.Location));
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (allies.WinState != WinState.Undefined)
|
||||
return;
|
||||
|
||||
survivalTimer.Tick();
|
||||
if (allies != null)
|
||||
{
|
||||
ManageSovietUnits();
|
||||
}
|
||||
|
||||
var unitsAndBuildings = world.Actors.Where(a => !a.IsDead() && a.IsInWorld && (a.HasTrait<Mobile>() || (a.HasTrait<Building>() && !a.HasTrait<Wall>())));
|
||||
if (!unitsAndBuildings.Any(a => a.Owner == soviets))
|
||||
{
|
||||
objectives[destroySovietsID].Status = ObjectiveStatus.Completed;
|
||||
MissionAccomplished("We have destroyed the remaining Soviet presence!");
|
||||
}
|
||||
|
||||
if (world.FrameNumber == ProduceAtFrame)
|
||||
{
|
||||
ProduceAtFrame += ProduceAtFrameIncrement;
|
||||
ProduceAtFrameIncrement = Math.Max(ProduceAtFrameIncrement - 5, 100);
|
||||
InitializeSovietFactories(barrack1, sovietrally.Location);
|
||||
BuildSovietUnits(factory, barrack1);
|
||||
}
|
||||
if (world.FrameNumber == attackAtFrame)
|
||||
{
|
||||
attackAtFrame += attackAtFrameIncrement;
|
||||
attackAtFrameIncrement = Math.Max(attackAtFrameIncrement - 5, 100);
|
||||
ManageSovietVehicles();
|
||||
if (producing)
|
||||
{
|
||||
BuildSovietVehicles(sovietentrypoints, sovietrallypoints);
|
||||
}
|
||||
else
|
||||
BuildSovietVehicles(newsovietentrypoints, newsovietrallypoints);
|
||||
}
|
||||
if (world.FrameNumber == attackTicks)
|
||||
{
|
||||
SpawnAndAttack(squad, soviets, sovietrally5.Location);
|
||||
SpawnAndAttack(squad, soviets, sovietrally6.Location);
|
||||
}
|
||||
if (world.FrameNumber == attackTicks * 3)
|
||||
{
|
||||
SpawnFlare(soviets, sovietparadrop3);
|
||||
MissionUtils.Paradrop(world, soviets, squad, sovietparadropEntry.Location, sovietparadrop3.Location);
|
||||
SpawnAndAttack(squad, soviets, sovietrally2.Location);
|
||||
SpawnAndAttack(platoon, soviets, sovietrally5.Location);
|
||||
SpawnAndAttack(platoon, soviets, sovietrally6.Location);
|
||||
}
|
||||
if (world.FrameNumber == attackTicks * 5)
|
||||
{
|
||||
SpawnFlare(soviets, sovietparadrop2);
|
||||
MissionUtils.Paradrop(world, soviets, squad, sovietparadropEntry.Location, sovietparadrop2.Location);
|
||||
}
|
||||
if (world.FrameNumber == attackTicks * 7)
|
||||
{
|
||||
SpawnFlare(soviets, sovietparadrop1);
|
||||
MissionUtils.Paradrop(world, soviets, squad, sovietparadropEntry.Location, sovietparadrop1.Location);
|
||||
}
|
||||
if (world.FrameNumber == attackTicks * 10)
|
||||
{
|
||||
SpawnFlare(soviets, sovietparadrop1);
|
||||
MissionUtils.Paradrop(world, soviets, squad, sovietparadropEntry.Location, sovietparadrop1.Location);
|
||||
ManageSovietUnits();
|
||||
}
|
||||
if (world.FrameNumber == attackTicks * 12)
|
||||
{
|
||||
Sound.Play("reinfor1.aud");
|
||||
FrenchReinforcements();
|
||||
}
|
||||
}
|
||||
|
||||
void StartCountDownTimer()
|
||||
{
|
||||
Sound.Play("timergo1.aud");
|
||||
survivalTimer = new CountdownTimer(timerTicks, CountDownTimerExpired, true);
|
||||
survivalTimerWidget = new CountdownTimerWidget(survivalTimer, "Time Until Soviet Reinforcements Arrive: {0}");
|
||||
Ui.Root.AddChild(survivalTimerWidget);
|
||||
}
|
||||
|
||||
void CountDownTimerExpired(CountdownTimer countDownTimer)
|
||||
{
|
||||
survivalTimerWidget.Visible = false;
|
||||
Message("The Soviet reinforcements are approuching!");
|
||||
BuildSovietVehicles(newsovietentrypoints, newsovietrallypoints);
|
||||
FinalAttack();
|
||||
producing = false;
|
||||
objectives[maintainPresenceID].Status = ObjectiveStatus.Completed;
|
||||
objectives[destroySovietsID].Status = ObjectiveStatus.InProgress;
|
||||
OnObjectivesUpdated(true);
|
||||
}
|
||||
|
||||
void InitializeSovietFactories(Actor tent, CPos rally)
|
||||
{
|
||||
if (tent.IsInWorld && !tent.IsDead())
|
||||
{
|
||||
var sbrp = tent.Trait<RallyPoint>();
|
||||
sbrp.rallyPoint = rally;
|
||||
sbrp.nearEnough = 6;
|
||||
}
|
||||
}
|
||||
|
||||
void BuildSovietUnit(string category, string unit)
|
||||
{
|
||||
var queueTent = MissionUtils.FindQueues(world, soviets, category).FirstOrDefault(q => q.CurrentItem() == null);
|
||||
if (queueTent == null) return;
|
||||
queueTent.ResolveOrder(queueTent.self, Order.StartProduction(queueTent.self, unit, 1));
|
||||
}
|
||||
|
||||
void BuildSovietUnits(Actor factory, Actor tent)
|
||||
{
|
||||
if (barrack1.IsInWorld && !barrack1.IsDead())
|
||||
{
|
||||
BuildSovietUnit(InfantryQueueName, SovietInfantry.Random(world.SharedRandom));
|
||||
}
|
||||
}
|
||||
|
||||
void ManageSovietUnits()
|
||||
{
|
||||
var units = world.FindAliveCombatantActorsInCircle(sovietrally.CenterLocation, 3)
|
||||
.Where(u => u.IsIdle && u.HasTrait<IMove>() && u.HasTrait<AttackBase>() && u.Owner == soviets);
|
||||
if (units.Count() >= sovietAttackGroupSize)
|
||||
{
|
||||
foreach (var unit in units)
|
||||
{
|
||||
var route = world.SharedRandom.Next(sovietrallypoints.Length);
|
||||
unit.QueueActivity(new Move.Move(sovietrally3.Location));
|
||||
unit.QueueActivity(new Wait(300));
|
||||
unit.QueueActivity(new Move.Move(sovietrallypoints[route]));
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BuildSovietVehicles(CPos[] spawnpoints, CPos[] rallypoints)
|
||||
{
|
||||
var route = world.SharedRandom.Next(spawnpoints.Length);
|
||||
var spawnPoint = spawnpoints[route];
|
||||
var rally = world.SharedRandom.Next(rallypoints.Length);
|
||||
var rallyPoint = rallypoints[rally];
|
||||
var unit = world.CreateActor(SovietVehicles.Random(world.SharedRandom),
|
||||
new TypeDictionary
|
||||
{
|
||||
new LocationInit(spawnPoint),
|
||||
new OwnerInit(soviets)
|
||||
});
|
||||
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, new Move.Move(rallyPoint, 3)));
|
||||
}
|
||||
|
||||
void ManageSovietVehicles()
|
||||
{
|
||||
foreach (var rallyPoint in sovietrallypoints)
|
||||
{
|
||||
var units = world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(rallyPoint), 10)
|
||||
.Where(u => u.IsIdle && u.HasTrait<Mobile>() && u.HasTrait<AttackBase>() && u.Owner == soviets);
|
||||
if (units.Count() >= SovietGroupSize)
|
||||
{
|
||||
foreach (var unit in units)
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
}
|
||||
|
||||
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(sovietrallypoints.SelectMany(rp => world.FindAliveCombatantActorsInCircle(Util.CenterOfCell(rp), 10)));
|
||||
|
||||
foreach (var unit in scatteredUnits)
|
||||
AttackNearestAlliedActor(unit);
|
||||
}
|
||||
|
||||
bool producing = true;
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
world = w;
|
||||
allies = w.Players.SingleOrDefault(p => p.InternalName == "Allies");
|
||||
if (allies != null)
|
||||
{
|
||||
ProduceAtFrame = 300;
|
||||
ProduceAtFrameIncrement = 300;
|
||||
attackAtFrame = 450;
|
||||
attackAtFrameIncrement = 450;
|
||||
}
|
||||
soviets = w.Players.Single(p => p.InternalName == "Soviets");
|
||||
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
sovietEntry1 = actors["SovietEntry1"];
|
||||
sovietEntry2 = actors["SovietEntry2"];
|
||||
sovietEntry3 = actors["SovietEntry3"];
|
||||
sovietentrypoints = new[] { sovietEntry1, sovietEntry2, sovietEntry3 }.Select(p => p.Location).ToArray();
|
||||
sovietrally = actors["SovietRally"];
|
||||
sovietrally1 = actors["SovietRally1"];
|
||||
sovietrally2 = actors["SovietRally2"];
|
||||
sovietrally3 = actors["SovietRally3"];
|
||||
sovietrally4 = actors["SovietRally4"];
|
||||
sovietrally5 = actors["SovietRally5"];
|
||||
sovietrally6 = actors["SovietRally6"];
|
||||
sovietrally7 = actors["SovietRally7"];
|
||||
sovietrally8 = actors["SovietRally8"];
|
||||
sovietrallypoints = new[] { sovietrally2, sovietrally4, sovietrally5, sovietrally6 }.Select(p => p.Location).ToArray();
|
||||
alliesbase = actors["AlliesBase"];
|
||||
sovietparadropEntry = actors["SovietParaDropEntry"];
|
||||
sovietparadrop1 = actors["SovietParaDrop1"];
|
||||
sovietparadrop2 = actors["SovietParaDrop2"];
|
||||
sovietparadrop3 = actors["SovietParaDrop3"];
|
||||
barrack1 = actors["barrack1"];
|
||||
factory = actors["Factory"];
|
||||
boom1 = actors["boom1"];
|
||||
boom2 = actors["boom2"];
|
||||
boom3 = actors["boom3"];
|
||||
drum1 = actors["drum1"];
|
||||
drum2 = actors["drum2"];
|
||||
drum3 = actors["drum3"];
|
||||
FranceEntry = actors["FranceEntry"];
|
||||
FranceRally = actors["FranceRally"];
|
||||
FranceparaEntry1 = actors["FranceparaEntry1"];
|
||||
FranceparaEntry2 = actors["FranceparaEntry2"];
|
||||
FranceparaEntry3 = actors["FranceparaEntry3"];
|
||||
newsovietentrypoints = new[] { sovietparadropEntry, sovietEntry3 }.Select(p => p.Location).ToArray();
|
||||
newsovietrallypoints = new[] { sovietrally3, sovietrally4, sovietrally8 }.Select(p => p.Location).ToArray();
|
||||
Game.MoveViewport(alliesbase.Location.ToFloat2());
|
||||
StartCountDownTimer();
|
||||
SetSovietUnitsToDefensiveStance();
|
||||
var Camera1 = world.CreateActor(Camera, new TypeDictionary
|
||||
{
|
||||
new OwnerInit(allies),
|
||||
new LocationInit(sovietrally1.Location),
|
||||
});
|
||||
//MissionUtils.PlayMissionMusic();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
mods/ra/maps/Fort-Lonestar/map.bin
Normal file
BIN
mods/ra/maps/Fort-Lonestar/map.bin
Normal file
Binary file not shown.
1110
mods/ra/maps/Fort-Lonestar/map.yaml
Normal file
1110
mods/ra/maps/Fort-Lonestar/map.yaml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
mods/ra/maps/Survival02/map.bin
Normal file
BIN
mods/ra/maps/Survival02/map.bin
Normal file
Binary file not shown.
1134
mods/ra/maps/Survival02/map.yaml
Normal file
1134
mods/ra/maps/Survival02/map.yaml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user