Reimplemented chronoshift. (still has desync)
This commit is contained in:
@@ -58,6 +58,10 @@ namespace OpenRA
|
|||||||
this.ExtraLocation = extraLocation;
|
this.ExtraLocation = extraLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For scripting special powers
|
||||||
|
public Order()
|
||||||
|
: this(null, null, null, int2.Zero, null, false, int2.Zero) { }
|
||||||
|
|
||||||
public Order(string orderString, Actor subject, bool queued)
|
public Order(string orderString, Actor subject, bool queued)
|
||||||
: this(orderString, subject, null, int2.Zero, null, queued, int2.Zero) { }
|
: this(orderString, subject, null, int2.Zero, null, queued, int2.Zero) { }
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
|
|
||||||
if (ticks == 100)
|
if (ticks == 100)
|
||||||
Actors["mslo1"].Trait<NukePower>().Activate(Actors["mslo1"], new Order(null,null,false) { TargetLocation = new int2(98, 52) });
|
Actors["mslo1"].Trait<NukePower>().Activate(Actors["mslo1"], new Order(){ TargetLocation = new int2(98, 52) });
|
||||||
if (ticks == 140)
|
if (ticks == 140)
|
||||||
Actors["mslo2"].Trait<NukePower>().Activate(Actors["mslo2"], new Order(null,null,false) { TargetLocation = new int2(95, 54) });
|
Actors["mslo2"].Trait<NukePower>().Activate(Actors["mslo2"], new Order(){ TargetLocation = new int2(95, 54) });
|
||||||
if (ticks == 180)
|
if (ticks == 180)
|
||||||
Actors["mslo3"].Trait<NukePower>().Activate(Actors["mslo3"], new Order(null,null,false) { TargetLocation = new int2(95, 49) });
|
Actors["mslo3"].Trait<NukePower>().Activate(Actors["mslo3"], new Order(){ TargetLocation = new int2(95, 49) });
|
||||||
|
|
||||||
if (ticks == 430)
|
if (ticks == 430)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using OpenRA.Graphics;
|
|||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
/*
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class ChronoshiftPowerInfo : SupportPowerInfo
|
class ChronoshiftPowerInfo : SupportPowerInfo
|
||||||
@@ -27,55 +27,49 @@ namespace OpenRA.Mods.RA
|
|||||||
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
|
public override object Create(ActorInitializer init) { return new ChronoshiftPower(init.self,this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChronoshiftPower : SupportPower, IResolveOrder
|
class ChronoshiftPower : SupportPower
|
||||||
{
|
{
|
||||||
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
||||||
protected override void OnActivate() { Self.World.OrderGenerator = new SelectTarget(this); }
|
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public override IOrderGenerator OrderGenerator(string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
if (!IsReady) return;
|
Sound.PlayToPlayer(manager.self.Owner, Info.SelectTargetSound);
|
||||||
|
return new SelectTarget(order, manager, this);
|
||||||
|
}
|
||||||
|
|
||||||
if (order.OrderString == "Chronoshift")
|
public override void Activate(Actor self, Order order)
|
||||||
|
{
|
||||||
|
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
|
|
||||||
|
// Trigger screen desaturate effect
|
||||||
|
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
||||||
|
a.Trait.Enable();
|
||||||
|
|
||||||
|
Sound.Play("chrono2.aud", Game.CellSize * order.TargetLocation);
|
||||||
|
Sound.Play("chrono2.aud", Game.CellSize * order.ExtraLocation);
|
||||||
|
System.Console.WriteLine("Searching for units around {0}",order.ExtraLocation);
|
||||||
|
|
||||||
|
foreach (var target in UnitsInRange(order.ExtraLocation))
|
||||||
{
|
{
|
||||||
var chronosphere = self.World.Queries
|
System.Console.WriteLine("Found actor {0} at {1}",target.Info.Name, target.Location);
|
||||||
.OwnedBy[self.Owner]
|
|
||||||
.WithTrait<Chronosphere>()
|
|
||||||
.Select(x => x.Actor).FirstOrDefault();
|
|
||||||
|
|
||||||
if (chronosphere != null)
|
var cs = target.Trait<Chronoshiftable>();
|
||||||
chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
|
var targetCell = target.Location + order.TargetLocation - order.ExtraLocation;
|
||||||
|
// TODO: Fix CanChronoshiftTo desync
|
||||||
// Trigger screen desaturate effect
|
if (cs.CanChronoshiftTo(target, targetCell))
|
||||||
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
target.Trait<Chronoshiftable>().Teleport(target,
|
||||||
a.Trait.Enable();
|
targetCell,
|
||||||
|
(Info as ChronoshiftPowerInfo).Duration * 25,
|
||||||
Sound.Play("chrono2.aud", Game.CellSize * order.TargetLocation);
|
(Info as ChronoshiftPowerInfo).KillCargo,
|
||||||
Sound.Play("chrono2.aud", Game.CellSize * order.ExtraLocation);
|
self);
|
||||||
|
|
||||||
var targets = UnitsInRange(order.ExtraLocation);
|
|
||||||
foreach (var target in targets)
|
|
||||||
{
|
|
||||||
var cs = target.Trait<Chronoshiftable>();
|
|
||||||
var targetCell = target.Location + order.TargetLocation - order.ExtraLocation;
|
|
||||||
|
|
||||||
if (cs.CanChronoshiftTo(target, targetCell))
|
|
||||||
target.Trait<Chronoshiftable>().Teleport(target,
|
|
||||||
targetCell,
|
|
||||||
(Info as ChronoshiftPowerInfo).Duration * 25,
|
|
||||||
(Info as ChronoshiftPowerInfo).KillCargo,
|
|
||||||
chronosphere);
|
|
||||||
}
|
|
||||||
|
|
||||||
FinishActivate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> UnitsInRange(int2 xy)
|
public IEnumerable<Actor> UnitsInRange(int2 xy)
|
||||||
{
|
{
|
||||||
int range = (Info as ChronoshiftPowerInfo).Range;
|
int range = (Info as ChronoshiftPowerInfo).Range;
|
||||||
var uim = Self.World.WorldActor.Trait<UnitInfluence>();
|
var uim = self.World.WorldActor.Trait<UnitInfluence>();
|
||||||
var tiles = Self.World.FindTilesInCircle(xy, range);
|
var tiles = self.World.FindTilesInCircle(xy, range);
|
||||||
var units = new List<Actor>();
|
var units = new List<Actor>();
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
units.AddRange(uim.GetUnitsAt(t));
|
units.AddRange(uim.GetUnitsAt(t));
|
||||||
@@ -85,12 +79,16 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class SelectTarget : IOrderGenerator
|
class SelectTarget : IOrderGenerator
|
||||||
{
|
{
|
||||||
ChronoshiftPower power;
|
readonly ChronoshiftPower power;
|
||||||
int range;
|
readonly int range;
|
||||||
Sprite tile;
|
readonly Sprite tile;
|
||||||
|
readonly SupportPowerManager manager;
|
||||||
|
readonly string order;
|
||||||
|
|
||||||
public SelectTarget(ChronoshiftPower power)
|
public SelectTarget(string order, SupportPowerManager manager, ChronoshiftPower power)
|
||||||
{
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.order = order;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
||||||
tile = UiOverlay.SynthesizeTile(0x04);
|
tile = UiOverlay.SynthesizeTile(0x04);
|
||||||
@@ -98,21 +96,15 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
world.CancelInputMode();
|
||||||
world.CancelInputMode();
|
world.OrderGenerator = new SelectDestination(order, manager, power, xy);
|
||||||
else
|
|
||||||
world.OrderGenerator = new SelectDestination(power, xy);
|
|
||||||
|
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( World world )
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
var hasChronosphere = world.Queries.OwnedBy[world.LocalPlayer]
|
// Cancel the OG if we can't use the power
|
||||||
.WithTrait<Chronosphere>()
|
if (!manager.Powers.ContainsKey(order))
|
||||||
.Any();
|
|
||||||
|
|
||||||
if (!hasChronosphere)
|
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +132,17 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class SelectDestination : IOrderGenerator
|
class SelectDestination : IOrderGenerator
|
||||||
{
|
{
|
||||||
ChronoshiftPower power;
|
readonly ChronoshiftPower power;
|
||||||
int2 sourceLocation;
|
readonly int2 sourceLocation;
|
||||||
int range;
|
readonly int range;
|
||||||
Sprite validTile, invalidTile, sourceTile;
|
readonly Sprite validTile, invalidTile, sourceTile;
|
||||||
|
readonly SupportPowerManager manager;
|
||||||
|
readonly string order;
|
||||||
|
|
||||||
public SelectDestination(ChronoshiftPower power, int2 sourceLocation)
|
public SelectDestination(string order, SupportPowerManager manager, ChronoshiftPower power, int2 sourceLocation)
|
||||||
{
|
{
|
||||||
|
this.manager = manager;
|
||||||
|
this.order = order;
|
||||||
this.power = power;
|
this.power = power;
|
||||||
this.sourceLocation = sourceLocation;
|
this.sourceLocation = sourceLocation;
|
||||||
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
this.range = (power.Info as ChronoshiftPowerInfo).Range;
|
||||||
@@ -175,7 +171,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
// Cannot chronoshift into unexplored location
|
// Cannot chronoshift into unexplored location
|
||||||
if (isValidTarget(xy))
|
if (isValidTarget(xy))
|
||||||
yield return new Order("Chronoshift", world.LocalPlayer.PlayerActor, false)
|
yield return new Order(order, manager.self, false)
|
||||||
{
|
{
|
||||||
TargetLocation = xy,
|
TargetLocation = xy,
|
||||||
ExtraLocation = sourceLocation
|
ExtraLocation = sourceLocation
|
||||||
@@ -184,11 +180,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
var hasChronosphere = world.Queries.OwnedBy[world.LocalPlayer]
|
// Cancel the OG if we can't use the power
|
||||||
.WithTrait<Chronosphere>()
|
if (!manager.Powers.ContainsKey(order))
|
||||||
.Any();
|
|
||||||
|
|
||||||
if (!hasChronosphere)
|
|
||||||
world.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,15 +237,11 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
return canTeleport;
|
return canTeleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCursor(World world, int2 xy, MouseInput mi)
|
public string GetCursor(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
return isValidTarget(xy) ? "chrono-target" : "move-blocked";
|
return isValidTarget(xy) ? "chrono-target" : "move-blocked";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag trait for the building
|
|
||||||
class ChronosphereInfo : TraitInfo<Chronosphere> {}
|
|
||||||
class Chronosphere {}
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -24,7 +24,8 @@ MSLO:
|
|||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
NukePower:
|
NukePower:
|
||||||
Image: atomicon
|
Image: atomicon
|
||||||
ChargeTime: 540
|
# ChargeTime: 540
|
||||||
|
ChargeTime: 10
|
||||||
Description: Atom Bomb
|
Description: Atom Bomb
|
||||||
LongDesc: Launches a nuclear missile at a target location.
|
LongDesc: Launches a nuclear missile at a target location.
|
||||||
BeginChargeSound: aprep1.aud
|
BeginChargeSound: aprep1.aud
|
||||||
@@ -229,8 +230,18 @@ PDOX:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 10
|
Range: 10
|
||||||
Bib:
|
Bib:
|
||||||
# Chronosphere:
|
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
ChronoshiftPower:
|
||||||
|
Image: warpicon
|
||||||
|
# ChargeTime: 120
|
||||||
|
ChargeTime: 10
|
||||||
|
Description: Chronoshift
|
||||||
|
LongDesc: Teleport a group of vehicles across\nthe map for 30 seconds.
|
||||||
|
SelectTargetSound: slcttgt1.aud
|
||||||
|
BeginChargeSound: chrochr1.aud
|
||||||
|
EndChargeSound: chrordy1.aud
|
||||||
|
Duration: 30
|
||||||
|
KillCargo: yes
|
||||||
|
|
||||||
TSLA:
|
TSLA:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
|
|||||||
@@ -34,17 +34,6 @@ Player:
|
|||||||
# Prerequisites: ATEK
|
# Prerequisites: ATEK
|
||||||
# RevealDelay: 15
|
# RevealDelay: 15
|
||||||
# LaunchSound: satlnch1.aud
|
# LaunchSound: satlnch1.aud
|
||||||
# ChronoshiftPower:
|
|
||||||
# Image: warpicon
|
|
||||||
# ChargeTime: 2
|
|
||||||
# Description: Chronoshift
|
|
||||||
# LongDesc: Teleport a group of vehicles across\nthe map for 30 seconds.
|
|
||||||
# Prerequisites: PDOX
|
|
||||||
# SelectTargetSound: slcttgt1.aud
|
|
||||||
# BeginChargeSound: chrochr1.aud
|
|
||||||
# EndChargeSound: chrordy1.aud
|
|
||||||
# Duration: 30
|
|
||||||
# KillCargo: yes
|
|
||||||
# IronCurtainPower:
|
# IronCurtainPower:
|
||||||
# Image: infxicon
|
# Image: infxicon
|
||||||
# ChargeTime: 2
|
# ChargeTime: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user