Add TargetDamageWarhead
Only deals damage to the actor that was targeted by the carrying projectile. Currently only supported by InstantHit projectile.
This commit is contained in:
@@ -574,6 +574,7 @@
|
|||||||
<Compile Include="Warheads\HealthPercentageDamageWarhead.cs" />
|
<Compile Include="Warheads\HealthPercentageDamageWarhead.cs" />
|
||||||
<Compile Include="Warheads\LeaveSmudgeWarhead.cs" />
|
<Compile Include="Warheads\LeaveSmudgeWarhead.cs" />
|
||||||
<Compile Include="Warheads\SpreadDamageWarhead.cs" />
|
<Compile Include="Warheads\SpreadDamageWarhead.cs" />
|
||||||
|
<Compile Include="Warheads\TargetDamageWarhead.cs" />
|
||||||
<Compile Include="Warheads\Warhead.cs" />
|
<Compile Include="Warheads\Warhead.cs" />
|
||||||
<Compile Include="Widgets\ActorPreviewWidget.cs" />
|
<Compile Include="Widgets\ActorPreviewWidget.cs" />
|
||||||
<Compile Include="Widgets\ColorMixerWidget.cs" />
|
<Compile Include="Widgets\ColorMixerWidget.cs" />
|
||||||
|
|||||||
62
OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs
Normal file
62
OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2017 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, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Warheads
|
||||||
|
{
|
||||||
|
public class TargetDamageWarhead : DamageWarhead
|
||||||
|
{
|
||||||
|
public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
|
||||||
|
{
|
||||||
|
// Damages a single actor, rather than a position. Only support by InstantHit for now.
|
||||||
|
// TODO: Add support for 'area of damage'
|
||||||
|
if (target.Type == TargetType.Actor)
|
||||||
|
DoImpact(target.Actor, firedBy, damageModifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DoImpact(WPos pos, Actor firedBy, IEnumerable<int> damageModifiers)
|
||||||
|
{
|
||||||
|
// For now this only displays debug overlay
|
||||||
|
// TODO: Add support for 'area of effect' / multiple targets
|
||||||
|
var world = firedBy.World;
|
||||||
|
var debugOverlayRange = new[] { WDist.Zero, new WDist(128) };
|
||||||
|
|
||||||
|
if (world.LocalPlayer != null)
|
||||||
|
{
|
||||||
|
var devMode = world.LocalPlayer.PlayerActor.TraitOrDefault<DeveloperMode>();
|
||||||
|
if (devMode != null && devMode.ShowCombatGeometry)
|
||||||
|
world.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(pos, debugOverlayRange, DebugOverlayColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DoImpact(Actor victim, Actor firedBy, IEnumerable<int> damageModifiers)
|
||||||
|
{
|
||||||
|
if (!IsValidAgainst(victim, firedBy))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim)));
|
||||||
|
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
|
||||||
|
|
||||||
|
var world = firedBy.World;
|
||||||
|
if (world.LocalPlayer != null)
|
||||||
|
{
|
||||||
|
var debugOverlayRange = new[] { WDist.Zero, new WDist(128) };
|
||||||
|
var devMode = world.LocalPlayer.PlayerActor.TraitOrDefault<DeveloperMode>();
|
||||||
|
if (devMode != null && devMode.ShowCombatGeometry)
|
||||||
|
world.WorldActor.Trait<WarheadDebugOverlay>().AddImpact(victim.CenterPosition, debugOverlayRange, DebugOverlayColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user