Refactor cash code in Allies campaign. Adjust starting cash to 10000 in SP Allies 03
This commit is contained in:
@@ -190,27 +190,15 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
void ManageSovietUnits()
|
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.IsInWorld && a.Owner == soviets && !a.IsDead() && a.IsIdle
|
||||||
&& a.HasTrait<Mobile>() && a.HasTrait<AttackBase>()))
|
&& a.HasTrait<Mobile>() && a.HasTrait<AttackBase>()))
|
||||||
{
|
{
|
||||||
Activity innerActivity;
|
Activity inner;
|
||||||
if (einstein != null)
|
if (einstein != null && einstein.IsInWorld)
|
||||||
{
|
inner = new Attack(Target.FromActor(einstein), 3);
|
||||||
if (einstein.IsInWorld)
|
|
||||||
innerActivity = new Attack(Target.FromActor(einstein), 3);
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
inner = new Move.Move(extractionLZ.Location, 3);
|
||||||
var container = world.UnitContaining(einstein);
|
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, inner));
|
||||||
|
|
||||||
if (container != null && !container.HasTrait<Aircraft>() && container.HasTrait<Mobile>())
|
|
||||||
innerActivity = new Attack(Target.FromActor(container), 3);
|
|
||||||
|
|
||||||
else
|
|
||||||
innerActivity = new Move.Move(extractionLZ.Location, 3);
|
|
||||||
}
|
|
||||||
unit.QueueActivity(new AttackMove.AttackMoveActivity(unit, innerActivity));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +278,8 @@ 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");
|
||||||
|
|
||||||
|
allies.PlayerActor.Trait<PlayerResources>().Cash = 0;
|
||||||
|
|
||||||
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
var actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||||
insertionLZ = actors["InsertionLZ"];
|
insertionLZ = actors["InsertionLZ"];
|
||||||
extractionLZ = actors["ExtractionLZ"];
|
extractionLZ = actors["ExtractionLZ"];
|
||||||
@@ -303,10 +293,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
attackEntryPoint2 = actors["SovietAttackEntryPoint2"];
|
attackEntryPoint2 = actors["SovietAttackEntryPoint2"];
|
||||||
SetAlliedUnitsToDefensiveStance();
|
SetAlliedUnitsToDefensiveStance();
|
||||||
|
|
||||||
var alliesRes = allies.PlayerActor.Trait<PlayerResources>();
|
|
||||||
alliesRes.TakeCash(alliesRes.Cash);
|
|
||||||
alliesRes.TakeOre(alliesRes.Ore);
|
|
||||||
|
|
||||||
Game.MoveViewport(insertionLZ.Location.ToFloat2());
|
Game.MoveViewport(insertionLZ.Location.ToFloat2());
|
||||||
|
|
||||||
if (MissionUtils.IsSingleClient(world))
|
if (MissionUtils.IsSingleClient(world))
|
||||||
|
|||||||
@@ -459,7 +459,8 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,8 +481,14 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
||||||
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
||||||
|
|
||||||
|
var res = allies1.PlayerActor.Trait<PlayerResources>().Cash = 5000;
|
||||||
if (allies2 == null)
|
if (allies2 == null)
|
||||||
allies2 = allies1;
|
allies2 = allies1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allies2.PlayerActor.Trait<PlayerResources>().Cash = 5000;
|
||||||
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|||||||
@@ -298,10 +298,8 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
void AttackNearestAlliedActor(Actor self)
|
void AttackNearestAlliedActor(Actor self)
|
||||||
{
|
{
|
||||||
var enemies = world.Actors
|
var enemies = world.Actors.Where(u => u.AppearsHostileTo(self) && (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)));
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -396,8 +394,19 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
||||||
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
||||||
|
|
||||||
|
var res = allies1.PlayerActor.Trait<PlayerResources>();
|
||||||
if (allies2 == null)
|
if (allies2 == null)
|
||||||
|
{
|
||||||
|
res.Cash = 10000;
|
||||||
allies2 = allies1;
|
allies2 = allies1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.Cash = 5000;
|
||||||
|
res = allies2.PlayerActor.Trait<PlayerResources>();
|
||||||
|
res.Cash = 5000;
|
||||||
|
}
|
||||||
|
|
||||||
attackAtFrame = attackAtFrameIncrement = difficulty == "Hard" || difficulty == "Normal" ? 500 : 600;
|
attackAtFrame = attackAtFrameIncrement = difficulty == "Hard" || difficulty == "Normal" ? 500 : 600;
|
||||||
minAttackAtFrame = difficulty == "Hard" || difficulty == "Normal" ? 100 : 150;
|
minAttackAtFrame = difficulty == "Hard" || difficulty == "Normal" ? 100 : 150;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ using System.Collections.Generic;
|
|||||||
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.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
using OpenRA.Mods.RA.Move;
|
using OpenRA.Mods.RA.Move;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
@@ -360,8 +359,14 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
|
|
||||||
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
allies1 = w.Players.Single(p => p.InternalName == "Allies1");
|
||||||
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
allies2 = w.Players.SingleOrDefault(p => p.InternalName == "Allies2");
|
||||||
|
|
||||||
|
allies1.PlayerActor.Trait<PlayerResources>().Cash = 0;
|
||||||
if (allies2 == null)
|
if (allies2 == null)
|
||||||
allies2 = allies1;
|
allies2 = allies1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allies2.PlayerActor.Trait<PlayerResources>().Cash = 0;
|
||||||
|
}
|
||||||
|
|
||||||
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");
|
||||||
@@ -447,16 +452,6 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
OnObjectivesUpdated(false);
|
OnObjectivesUpdated(false);
|
||||||
SetupSubStances();
|
SetupSubStances();
|
||||||
|
|
||||||
var res = allies1.PlayerActor.Trait<PlayerResources>();
|
|
||||||
res.TakeOre(res.Ore);
|
|
||||||
res.TakeCash(res.Cash);
|
|
||||||
if (allies1 != allies2)
|
|
||||||
{
|
|
||||||
res = allies2.PlayerActor.Trait<PlayerResources>();
|
|
||||||
res.TakeOre(res.Ore);
|
|
||||||
res.TakeCash(res.Cash);
|
|
||||||
}
|
|
||||||
|
|
||||||
Game.MoveViewport(spyReinforcementsEntryPoint.Location.ToFloat2());
|
Game.MoveViewport(spyReinforcementsEntryPoint.Location.ToFloat2());
|
||||||
MissionUtils.PlayMissionMusic();
|
MissionUtils.PlayMissionMusic();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user