Merge pull request #9174 from reaperrr/radius-explode
Customizable impact victim scan radius
This commit is contained in:
@@ -166,8 +166,14 @@ namespace OpenRA.Mods.Common.Effects
|
||||
if (info.ContrailLength > 0)
|
||||
contrail.Update(pos);
|
||||
|
||||
if (ticks++ >= length || (info.Blockable && world.ActorMap
|
||||
.GetUnitsAt(world.Map.CellContaining(pos)).Any(a => a.Info.HasTraitInfo<IBlocksProjectilesInfo>())))
|
||||
var cell = world.Map.CellContaining(pos);
|
||||
var height = world.Map.DistanceAboveTerrain(pos);
|
||||
|
||||
var shouldExplode = height.Length <= 0 // Hit the ground
|
||||
|| ticks++ >= length // Flight length reached/exceeded
|
||||
|| (info.Blockable && world.ActorMap.GetUnitsAt(cell).Any(a => a.Info.HasTraitInfo<IBlocksProjectilesInfo>())); // Hit a wall or other blocking obstacle
|
||||
|
||||
if (shouldExplode)
|
||||
Explode(world);
|
||||
}
|
||||
|
||||
|
||||
55
OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs
Normal file
55
OpenRA.Mods.Common/Lint/CheckTargetHealthRadius.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.Common.Warheads;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
class CheckTargetHealthRadius : ILintRulesPass
|
||||
{
|
||||
public void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
|
||||
{
|
||||
foreach (var actorInfo in rules.Actors)
|
||||
{
|
||||
var healthTraits = actorInfo.Value.TraitInfos<HealthInfo>().ToList();
|
||||
if (!healthTraits.Any())
|
||||
continue;
|
||||
|
||||
var targetable = actorInfo.Value.TraitInfos<ITargetableInfo>().SelectMany(x => x.GetTargetTypes()).ToList();
|
||||
if (!targetable.Any())
|
||||
continue;
|
||||
|
||||
foreach (var weaponInfo in rules.Weapons)
|
||||
{
|
||||
var warheads = weaponInfo.Value.Warheads.OfType<SpreadDamageWarhead>().Where(dw => dw.Damage > 0);
|
||||
|
||||
foreach (var warhead in warheads)
|
||||
{
|
||||
// This is a special warhead, like the one on `weathering` in D2k.
|
||||
if (!warhead.DamageTypes.Any())
|
||||
continue;
|
||||
|
||||
// This warhead cannot affect this actor.
|
||||
if (!warhead.ValidTargets.Overlaps(targetable))
|
||||
continue;
|
||||
|
||||
if (healthTraits.Where(x => x.Radius.Length > warhead.TargetExtraSearchRadius.Length).Any())
|
||||
emitError("Actor type `{0}` has a health radius exceeding the victim scan radius of a warhead on `{1}`!"
|
||||
.F(actorInfo.Key, weaponInfo.Key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,6 +191,7 @@
|
||||
<Compile Include="Lint\CheckDeathTypes.cs" />
|
||||
<Compile Include="Lint\CheckVoiceReferences.cs" />
|
||||
<Compile Include="Lint\CheckUpgrades.cs" />
|
||||
<Compile Include="Lint\CheckTargetHealthRadius.cs" />
|
||||
<Compile Include="Lint\LintBuildablePrerequisites.cs" />
|
||||
<Compile Include="Lint\LintExts.cs" />
|
||||
<Compile Include="LoadScreens\ModChooserLoadScreen.cs" />
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
[Desc("Range between falloff steps.")]
|
||||
public readonly WDist Spread = new WDist(43);
|
||||
|
||||
[Desc("Extra search radius beyond maximum spread. Required to ensure damage to actors with large health radius.")]
|
||||
public readonly WDist TargetExtraSearchRadius = new WDist(2048);
|
||||
|
||||
[Desc("Damage percentage at each range step")]
|
||||
public readonly int[] Falloff = { 100, 37, 14, 5, 2, 1, 0 };
|
||||
|
||||
@@ -46,7 +49,10 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
InitializeRange();
|
||||
|
||||
var world = firedBy.World;
|
||||
var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1]);
|
||||
|
||||
// This only finds actors where the center is within the search radius,
|
||||
// so we need to search beyond the maximum spread to account for actors with large health radius
|
||||
var hitActors = world.FindActorsInCircle(pos, Range[Range.Length - 1] + TargetExtraSearchRadius);
|
||||
|
||||
foreach (var victim in hitActors)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user