@@ -41,8 +41,9 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
public readonly Color ContrailColor = Color.White;
|
public readonly Color ContrailColor = Color.White;
|
||||||
public readonly bool ContrailUsePlayerColor = false;
|
public readonly bool ContrailUsePlayerColor = false;
|
||||||
public readonly int ContrailDelay = 1;
|
public readonly int ContrailDelay = 1;
|
||||||
|
public readonly bool Jammable = true;
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
public IEffect Create(ProjectileArgs args) { return new Missile(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Missile : IEffect
|
class Missile : IEffect
|
||||||
@@ -90,27 +91,44 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
const int MissileCloseEnough = 7;
|
const int MissileCloseEnough = 7;
|
||||||
int ticksToNextSmoke;
|
int ticksToNextSmoke;
|
||||||
|
|
||||||
public void Tick( World world )
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
t += 40;
|
t += 40;
|
||||||
|
|
||||||
// In pixels
|
// In pixels
|
||||||
var dist = Args.target.CenterLocation + offset - PxPosition;
|
var dist = Args.target.CenterLocation + offset - PxPosition;
|
||||||
|
|
||||||
var targetAltitude = 0;
|
var targetAltitude = 0;
|
||||||
if (Args.target.IsValid && Args.target.IsActor && Args.target.Actor.HasTrait<IMove>())
|
if (Args.target.IsValid && Args.target.IsActor && Args.target.Actor.HasTrait<IMove>())
|
||||||
targetAltitude = Args.target.Actor.Trait<IMove>().Altitude;
|
targetAltitude = Args.target.Actor.Trait<IMove>().Altitude;
|
||||||
|
|
||||||
Altitude += Math.Sign(targetAltitude - Altitude);
|
var jammed = Info.Jammable && world.ActorsWithTrait<JamsMissiles>().Any(tp =>
|
||||||
|
(tp.Actor.CenterLocation - PxPosition).ToCVec().Length <= tp.Trait.Range
|
||||||
|
|
||||||
if (Args.target.IsValid)
|
&& (tp.Actor.Owner.Stances[Args.firedBy.Owner] != Stance.Ally
|
||||||
|
|| (tp.Actor.Owner.Stances[Args.firedBy.Owner] == Stance.Ally && tp.Trait.AlliedMissiles))
|
||||||
|
|
||||||
|
&& world.SharedRandom.Next(100 / tp.Trait.Chance) == 0);
|
||||||
|
|
||||||
|
if (!jammed)
|
||||||
|
{
|
||||||
|
Altitude += Math.Sign(targetAltitude - Altitude);
|
||||||
|
if (Args.target.IsValid)
|
||||||
|
Facing = Traits.Util.TickFacing(Facing,
|
||||||
|
Traits.Util.GetFacing(dist, Facing),
|
||||||
|
Info.ROT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Altitude += world.SharedRandom.Next(-1, 2);
|
||||||
Facing = Traits.Util.TickFacing(Facing,
|
Facing = Traits.Util.TickFacing(Facing,
|
||||||
Traits.Util.GetFacing(dist, Facing),
|
Facing + world.SharedRandom.Next(-20, 21),
|
||||||
Info.ROT);
|
Info.ROT);
|
||||||
|
}
|
||||||
|
|
||||||
anim.Tick();
|
anim.Tick();
|
||||||
|
|
||||||
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough && Args.target.IsValid )
|
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough && Args.target.IsValid)
|
||||||
Explode(world);
|
Explode(world);
|
||||||
|
|
||||||
// TODO: Replace this with a lookup table
|
// TODO: Replace this with a lookup table
|
||||||
|
|||||||
35
OpenRA.Mods.RA/JamsMissiles.cs
Normal file
35
OpenRA.Mods.RA/JamsMissiles.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#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 OpenRA;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA
|
||||||
|
{
|
||||||
|
class JamsMissilesInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly int Range = 0;
|
||||||
|
public readonly bool AlliedMissiles = true;
|
||||||
|
public readonly int Chance = 100;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new JamsMissiles(this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class JamsMissiles
|
||||||
|
{
|
||||||
|
readonly JamsMissilesInfo info;
|
||||||
|
|
||||||
|
public int Range { get { return info.Range; } }
|
||||||
|
public bool AlliedMissiles { get { return info.AlliedMissiles; } }
|
||||||
|
public int Chance { get { return info.Chance; } }
|
||||||
|
|
||||||
|
public JamsMissiles(JamsMissilesInfo info) { this.info = info; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@@ -233,6 +233,7 @@
|
|||||||
<Compile Include="InfiltrateForSupportPower.cs" />
|
<Compile Include="InfiltrateForSupportPower.cs" />
|
||||||
<Compile Include="Invulnerable.cs" />
|
<Compile Include="Invulnerable.cs" />
|
||||||
<Compile Include="IronCurtainable.cs" />
|
<Compile Include="IronCurtainable.cs" />
|
||||||
|
<Compile Include="JamsMissiles.cs" />
|
||||||
<Compile Include="LeavesHusk.cs" />
|
<Compile Include="LeavesHusk.cs" />
|
||||||
<Compile Include="LightPaletteRotator.cs" />
|
<Compile Include="LightPaletteRotator.cs" />
|
||||||
<Compile Include="LimitedAmmo.cs" />
|
<Compile Include="LimitedAmmo.cs" />
|
||||||
@@ -301,6 +302,7 @@
|
|||||||
<Compile Include="RallyPoint.cs" />
|
<Compile Include="RallyPoint.cs" />
|
||||||
<Compile Include="Reloads.cs" />
|
<Compile Include="Reloads.cs" />
|
||||||
<Compile Include="RenderDetectionCircle.cs" />
|
<Compile Include="RenderDetectionCircle.cs" />
|
||||||
|
<Compile Include="RenderJammerCircle.cs" />
|
||||||
<Compile Include="RenderRangeCircle.cs" />
|
<Compile Include="RenderRangeCircle.cs" />
|
||||||
<Compile Include="Render\RenderBuilding.cs" />
|
<Compile Include="Render\RenderBuilding.cs" />
|
||||||
<Compile Include="Render\RenderBuildingCharge.cs" />
|
<Compile Include="Render\RenderBuildingCharge.cs" />
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA
|
|||||||
// Check if powered
|
// Check if powered
|
||||||
if (self.IsDisabled()) return false;
|
if (self.IsDisabled()) return false;
|
||||||
|
|
||||||
var isJammed = self.World.ActorsWithTrait<JamsRadar>().Any(a => self.Owner != a.Actor.Owner
|
var isJammed = self.World.ActorsWithTrait<JamsRadar>().Any(a => a.Actor.Owner.Stances[self.Owner] != Stance.Ally
|
||||||
&& (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<JamsRadarInfo>().Range);
|
&& (self.Location - a.Actor.Location).Length <= a.Actor.Info.Traits.Get<JamsRadarInfo>().Range);
|
||||||
|
|
||||||
return !isJammed;
|
return !isJammed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JamsRadarInfo : TraitInfo<JamsRadar> { public readonly int Range = 0; }
|
class JamsRadarInfo : TraitInfo<JamsRadar> { public readonly int Range = 0; }
|
||||||
|
|
||||||
class JamsRadar { }
|
class JamsRadar { }
|
||||||
}
|
}
|
||||||
|
|||||||
63
OpenRA.Mods.RA/RenderJammerCircle.cs
Normal file
63
OpenRA.Mods.RA/RenderJammerCircle.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#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.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.RA
|
||||||
|
{
|
||||||
|
//todo: remove all the Render*Circle duplication
|
||||||
|
class RenderJammerCircleInfo : TraitInfo<RenderJammerCircle>, IPlaceBuildingDecoration
|
||||||
|
{
|
||||||
|
public void Render(WorldRenderer wr, World w, ActorInfo ai, PPos centerLocation)
|
||||||
|
{
|
||||||
|
var jamsMissiles = ai.Traits.GetOrDefault<JamsMissilesInfo>();
|
||||||
|
if (jamsMissiles != null)
|
||||||
|
RenderJammerCircle.DrawRangeCircle(wr, centerLocation.ToFloat2(), jamsMissiles.Range, Color.Red);
|
||||||
|
|
||||||
|
var jamsRadar = ai.Traits.GetOrDefault<JamsRadarInfo>();
|
||||||
|
if (jamsRadar != null)
|
||||||
|
RenderJammerCircle.DrawRangeCircle(wr, centerLocation.ToFloat2(), jamsRadar.Range, Color.Blue);
|
||||||
|
|
||||||
|
foreach (var a in w.ActorsWithTrait<RenderJammerCircle>())
|
||||||
|
if (a.Actor.Owner == a.Actor.World.LocalPlayer)
|
||||||
|
a.Trait.RenderBeforeWorld(wr, a.Actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RenderJammerCircle : IPreRenderSelection
|
||||||
|
{
|
||||||
|
public void RenderBeforeWorld(WorldRenderer wr, Actor self)
|
||||||
|
{
|
||||||
|
if (self.Owner != self.World.LocalPlayer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var jamsMissiles = self.Info.Traits.GetOrDefault<JamsMissilesInfo>();
|
||||||
|
if (jamsMissiles != null)
|
||||||
|
DrawRangeCircle(wr, self.CenterLocation.ToFloat2(), jamsMissiles.Range, Color.Red);
|
||||||
|
|
||||||
|
var jamsRadar = self.Info.Traits.GetOrDefault<JamsRadarInfo>();
|
||||||
|
if (jamsRadar != null)
|
||||||
|
DrawRangeCircle(wr, self.CenterLocation.ToFloat2(), jamsRadar.Range, Color.Blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawRangeCircle(WorldRenderer wr, float2 location, int range, Color color)
|
||||||
|
{
|
||||||
|
wr.DrawRangeCircleWithContrast(
|
||||||
|
Color.FromArgb(128, color),
|
||||||
|
location,
|
||||||
|
range,
|
||||||
|
Color.FromArgb(96, Color.Black),
|
||||||
|
1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ MGG:
|
|||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
Buildable:
|
Buildable:
|
||||||
Queue: Vehicle
|
Queue: Vehicle
|
||||||
BuildPaletteOrder: 150
|
BuildPaletteOrder: 160
|
||||||
Prerequisites: atek
|
Prerequisites: atek
|
||||||
Owner: allies
|
Owner: allies
|
||||||
Hotkey: y
|
Hotkey: y
|
||||||
@@ -537,11 +537,13 @@ MRJ:
|
|||||||
Cost: 1000
|
Cost: 1000
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Mobile Radar Jammer
|
Name: Mobile Radar Jammer
|
||||||
Description: Unarmed
|
Description: Jams nearby enemy radar domes\nand deflects incoming missiles.\n Unarmed
|
||||||
Buildable:
|
Buildable:
|
||||||
Queue: Vehicle
|
Queue: Vehicle
|
||||||
BuildPaletteOrder: 1000
|
BuildPaletteOrder: 150
|
||||||
Owner: None
|
Prerequisites: atek
|
||||||
|
Owner: allies
|
||||||
|
Hotkey: m
|
||||||
Health:
|
Health:
|
||||||
HP: 200
|
HP: 200
|
||||||
Armor:
|
Armor:
|
||||||
@@ -558,6 +560,11 @@ MRJ:
|
|||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
|
JamsRadar:
|
||||||
|
Range: 15
|
||||||
|
JamsMissiles:
|
||||||
|
Range: 3
|
||||||
|
RenderJammerCircle:
|
||||||
|
|
||||||
1TNK.Husk:
|
1TNK.Husk:
|
||||||
Inherits: ^Husk
|
Inherits: ^Husk
|
||||||
|
|||||||
Reference in New Issue
Block a user