Scriptable chronosphere + desaturate effect
This commit is contained in:
@@ -27,7 +27,7 @@ using OpenRA.FileFormats.Graphics;
|
|||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
static class Util
|
public static class Util
|
||||||
{
|
{
|
||||||
public static string[] ReadAllLines(Stream s)
|
public static string[] ReadAllLines(Stream s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Effects
|
|||||||
public IEnumerable<Renderable> Render()
|
public IEnumerable<Renderable> Render()
|
||||||
{
|
{
|
||||||
yield return new Renderable(anim.Image,
|
yield return new Renderable(anim.Image,
|
||||||
Util.CenterOfCell(Target) - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
Traits.Util.CenterOfCell(Target) - new float2(.5f * anim.Image.size.X, anim.Image.size.Y - Game.CellSize),
|
||||||
"effect");
|
"effect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -45,17 +46,18 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (remainingFrames == 0)
|
if (remainingFrames == 0)
|
||||||
return;
|
return;
|
||||||
/* TODO: FIX ME
|
|
||||||
var frac = (float)remainingFrames / chronoEffectLength;
|
var frac = (float)remainingFrames / chronoEffectLength;
|
||||||
for( var y = 0; y < (int)PaletteType.Chrome; y++ )
|
|
||||||
|
// TODO: Fix me to only affect "world" palettes
|
||||||
|
for( var y = 0; y < b.Height; y++ )
|
||||||
for (var x = 0; x < 256; x++)
|
for (var x = 0; x < 256; x++)
|
||||||
{
|
{
|
||||||
var orig = b.GetPixel(x, y);
|
var orig = b.GetPixel(x, y);
|
||||||
var lum = (int)(255 * orig.GetBrightness());
|
var lum = (int)(255 * orig.GetBrightness());
|
||||||
var desat = Color.FromArgb(orig.A, lum, lum, lum);
|
var desat = Color.FromArgb(orig.A, lum, lum, lum);
|
||||||
b.SetPixel(x, y, Graphics.Util.Lerp(frac, orig, desat));
|
b.SetPixel(x, y, OpenRA.Graphics.Util.Lerp(frac, orig, desat));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -27,8 +27,6 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class ChronoshiftPowerInfo : SupportPowerInfo
|
class ChronoshiftPowerInfo : SupportPowerInfo
|
||||||
{
|
{
|
||||||
public readonly float Duration = 0f;
|
|
||||||
public readonly bool KillCargo = true;
|
|
||||||
public override object Create(Actor self) { return new ChronoshiftPower(self,this); }
|
public override object Create(Actor self) { return new ChronoshiftPower(self,this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,23 +59,7 @@ namespace OpenRA.Mods.RA
|
|||||||
.WithTrait<Chronosphere>()
|
.WithTrait<Chronosphere>()
|
||||||
.Select(x => x.Actor).FirstOrDefault();
|
.Select(x => x.Actor).FirstOrDefault();
|
||||||
|
|
||||||
bool success = order.TargetActor.traits.Get<Chronoshiftable>().Activate(order.TargetActor,
|
chronosphere.traits.Get<Chronosphere>().Teleport(order.TargetActor, order.TargetLocation);
|
||||||
order.TargetLocation,
|
|
||||||
(int)((Info as ChronoshiftPowerInfo).Duration * 25 * 60),
|
|
||||||
(Info as ChronoshiftPowerInfo).KillCargo,
|
|
||||||
chronosphere);
|
|
||||||
|
|
||||||
if (success)
|
|
||||||
{
|
|
||||||
Sound.Play("chrono2.aud", chronosphere.CenterLocation);
|
|
||||||
|
|
||||||
// Trigger screen desaturate effect
|
|
||||||
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
|
||||||
a.Trait.DoChronoshift();
|
|
||||||
|
|
||||||
if (chronosphere != null)
|
|
||||||
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
|
|
||||||
}
|
|
||||||
|
|
||||||
FinishActivate();
|
FinishActivate();
|
||||||
}
|
}
|
||||||
@@ -176,7 +158,37 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tag trait to identify the building
|
// tag trait for the building
|
||||||
class ChronosphereInfo : TraitInfo<Chronosphere> { }
|
class ChronosphereInfo : ITraitInfo
|
||||||
public class Chronosphere { }
|
{
|
||||||
|
public readonly int Duration = 30;
|
||||||
|
public readonly bool KillCargo = true;
|
||||||
|
public object Create(Actor self) { return new Chronosphere(self); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class Chronosphere
|
||||||
|
{
|
||||||
|
Actor self;
|
||||||
|
public Chronosphere(Actor self)
|
||||||
|
{
|
||||||
|
this.self = self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Teleport(Actor targetActor, int2 targetLocation)
|
||||||
|
{
|
||||||
|
var info = self.Info.Traits.Get<ChronosphereInfo>();
|
||||||
|
bool success = targetActor.traits.Get<Chronoshiftable>().Activate(targetActor, targetLocation, info.Duration * 25, info.KillCargo, self);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
Sound.Play("chrono2.aud", self.CenterLocation);
|
||||||
|
Sound.Play("chrono2.aud", targetActor.CenterLocation);
|
||||||
|
// Trigger screen desaturate effect
|
||||||
|
foreach (var a in self.World.Queries.WithTrait<ChronoshiftPaletteEffect>())
|
||||||
|
a.Trait.DoChronoshift();
|
||||||
|
|
||||||
|
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ namespace OpenRA.Mods.RA
|
|||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (ticks == 250)
|
||||||
|
MapActors["pdox"].traits.Get<Chronosphere>().Teleport(MapActors["ca1"], new int2(90,70));
|
||||||
if (ticks == 100)
|
if (ticks == 100)
|
||||||
MapActors["mslo1"].traits.Get<NukeSilo>().Attack(new int2(96,53));
|
MapActors["mslo1"].traits.Get<NukeSilo>().Attack(new int2(96,53));
|
||||||
if (ticks == 110)
|
if (ticks == 110)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cargo.Location = loc;
|
cargo.Location = loc;
|
||||||
cargo.CenterLocation = Util.CenterOfCell(loc);
|
cargo.CenterLocation = Traits.Util.CenterOfCell(loc);
|
||||||
|
|
||||||
if (cargo.traits.Contains<IOccupySpace>())
|
if (cargo.traits.Contains<IOccupySpace>())
|
||||||
world.WorldActor.traits.Get<UnitInfluence>().Add(cargo, cargo.traits.Get<IOccupySpace>());
|
world.WorldActor.traits.Get<UnitInfluence>().Add(cargo, cargo.traits.Get<IOccupySpace>());
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
rotorAnim.PlayRepeating("rotor");
|
rotorAnim.PlayRepeating("rotor");
|
||||||
anims.Add( "rotor_1", new AnimationWithOffset(
|
anims.Add( "rotor_1", new AnimationWithOffset(
|
||||||
rotorAnim,
|
rotorAnim,
|
||||||
() => Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
|
() => Traits.Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
|
||||||
null ) { ZOffset = 1 } );
|
null ) { ZOffset = 1 } );
|
||||||
|
|
||||||
if (info.SecondaryOffset == null) return;
|
if (info.SecondaryOffset == null) return;
|
||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
|
|||||||
secondRotorAnim.PlayRepeating( "rotor2" );
|
secondRotorAnim.PlayRepeating( "rotor2" );
|
||||||
anims.Add( "rotor_2", new AnimationWithOffset(
|
anims.Add( "rotor_2", new AnimationWithOffset(
|
||||||
secondRotorAnim,
|
secondRotorAnim,
|
||||||
() => Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
|
() => Traits.Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
|
||||||
null) { ZOffset = 1 });
|
null) { ZOffset = 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
|
|||||||
spinnerAnim.PlayRepeating( "spinner" );
|
spinnerAnim.PlayRepeating( "spinner" );
|
||||||
anims.Add( "spinner", new AnimationWithOffset(
|
anims.Add( "spinner", new AnimationWithOffset(
|
||||||
spinnerAnim,
|
spinnerAnim,
|
||||||
() => Util.GetTurretPosition( self, unit, info.Offset, 0 ),
|
() => Traits.Util.GetTurretPosition( self, unit, info.Offset, 0 ),
|
||||||
null ) { ZOffset = 1 } );
|
null ) { ZOffset = 1 } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
alt = 0;
|
alt = 0;
|
||||||
pos = Util.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
|
pos = Traits.Util.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
|
||||||
var ru = self.traits.Get<RenderUnit>();
|
var ru = self.traits.Get<RenderUnit>();
|
||||||
|
|
||||||
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();
|
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();
|
||||||
|
|||||||
@@ -1963,12 +1963,12 @@ Actors:
|
|||||||
Location: 89,84
|
Location: 89,84
|
||||||
Owner: Greece
|
Owner: Greece
|
||||||
ActorReference@Actor385:
|
ActorReference@Actor385:
|
||||||
Id: Actor385
|
Id: ca1
|
||||||
Type: ca
|
Type: ca
|
||||||
Location: 119,66
|
Location: 119,66
|
||||||
Owner: GoodGuy
|
Owner: GoodGuy
|
||||||
ActorReference@Actor386:
|
ActorReference@Actor386:
|
||||||
Id: Actor386
|
Id: ca2
|
||||||
Type: ca
|
Type: ca
|
||||||
Location: 120,66
|
Location: 120,66
|
||||||
Owner: GoodGuy
|
Owner: GoodGuy
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ PDOX:
|
|||||||
Sight: 10
|
Sight: 10
|
||||||
Bib:
|
Bib:
|
||||||
Chronosphere:
|
Chronosphere:
|
||||||
|
Duration: 180
|
||||||
|
KillCargo: yes
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
|
||||||
TSLA:
|
TSLA:
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ Player:
|
|||||||
LongDesc: Temporarily teleports a vehicle across \nthe map.
|
LongDesc: Temporarily teleports a vehicle across \nthe map.
|
||||||
Prerequisites: PDOX
|
Prerequisites: PDOX
|
||||||
TechLevel: 12
|
TechLevel: 12
|
||||||
Duration: 3
|
|
||||||
KillCargo: yes
|
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
BeginChargeSound: chrochr1.aud
|
BeginChargeSound: chrochr1.aud
|
||||||
EndChargeSound: chrordy1.aud
|
EndChargeSound: chrordy1.aud
|
||||||
|
|||||||
Reference in New Issue
Block a user