Merge pull request #12605 from reaperrr/ts-weapon-inheritance
Introduce TargetDamageWarhead + some TS weapon fixes
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" />
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -40,46 +41,42 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
readonly InstantHitInfo info;
|
readonly InstantHitInfo info;
|
||||||
|
|
||||||
bool doneDamage;
|
Target target;
|
||||||
WPos target;
|
|
||||||
WPos source;
|
WPos source;
|
||||||
|
|
||||||
public InstantHit(InstantHitInfo info, ProjectileArgs args)
|
public InstantHit(InstantHitInfo info, ProjectileArgs args)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
target = args.PassiveTarget;
|
|
||||||
source = args.Source;
|
source = args.Source;
|
||||||
|
|
||||||
|
if (info.Inaccuracy.Length > 0)
|
||||||
|
{
|
||||||
|
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||||
|
var maxOffset = inaccuracy * (args.PassiveTarget - source).Length / args.Weapon.Range.Length;
|
||||||
|
target = Target.FromPos(args.PassiveTarget + WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
target = args.GuidedTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
// Check for blocking actors
|
// Check for blocking actors
|
||||||
WPos blockedPos;
|
WPos blockedPos;
|
||||||
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target,
|
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target.CenterPosition,
|
||||||
info.Width, info.TargetExtraSearchRadius, out blockedPos))
|
info.Width, info.TargetExtraSearchRadius, out blockedPos))
|
||||||
{
|
{
|
||||||
target = blockedPos;
|
target = Target.FromPos(blockedPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.Inaccuracy.Length > 0)
|
args.Weapon.Impact(target, args.SourceActor, args.DamageModifiers);
|
||||||
{
|
|
||||||
var inaccuracy = OpenRA.Mods.Common.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
|
||||||
var maxOffset = inaccuracy * (target - source).Length / args.Weapon.Range.Length;
|
|
||||||
target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doneDamage)
|
|
||||||
{
|
|
||||||
args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers);
|
|
||||||
doneDamage = true;
|
|
||||||
world.AddFrameEndTask(w => w.Remove(this));
|
world.AddFrameEndTask(w => w.Remove(this));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
yield break;
|
return Enumerable.Empty<IRenderable>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,10 +60,8 @@ WormJaw:
|
|||||||
ReloadDelay: 10
|
ReloadDelay: 10
|
||||||
InvalidTargets: Structure, Infantry
|
InvalidTargets: Structure, Infantry
|
||||||
Range: 1c512
|
Range: 1c512
|
||||||
Warhead@1Dam: SpreadDamage # HACK: The warhead is needed for targeting
|
Warhead@1Dam: TargetDamage # HACK: The warhead is needed for targeting
|
||||||
InvalidTargets: Structure, Infantry
|
InvalidTargets: Structure, Infantry
|
||||||
Spread: 0
|
|
||||||
Falloff: 0,0
|
|
||||||
|
|
||||||
OrniBomb:
|
OrniBomb:
|
||||||
ReloadDelay: 25
|
ReloadDelay: 25
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
Heal:
|
^HealWeapon:
|
||||||
ReloadDelay: 80
|
ReloadDelay: 80
|
||||||
Range: 2c849
|
Range: 2c849
|
||||||
Report: healer1.aud
|
Report: healer1.aud
|
||||||
ValidTargets: Infantry
|
ValidTargets: Infantry
|
||||||
Projectile: Bullet
|
Projectile: InstantHit
|
||||||
Speed: 1c682
|
Warhead@1Dam: TargetDamage
|
||||||
Warhead@1Dam: SpreadDamage
|
|
||||||
DebugOverlayColor: 00FF00
|
DebugOverlayColor: 00FF00
|
||||||
Spread: 213
|
|
||||||
Damage: -50
|
Damage: -50
|
||||||
ValidTargets: Infantry
|
ValidTargets: Infantry
|
||||||
|
|
||||||
|
Heal:
|
||||||
|
Inherits: ^HealWeapon
|
||||||
|
|
||||||
Repair:
|
Repair:
|
||||||
ReloadDelay: 80
|
Inherits: ^HealWeapon
|
||||||
Range: 1c819
|
Range: 1c819
|
||||||
Report: repair11.aud
|
Report: repair11.aud
|
||||||
ValidTargets: Repair
|
ValidTargets: Repair
|
||||||
Projectile: Bullet
|
Warhead@1Dam: TargetDamage
|
||||||
Speed: 1c682
|
|
||||||
Warhead@1Dam: SpreadDamage
|
|
||||||
DebugOverlayColor: 00FF00
|
|
||||||
Spread: 213
|
|
||||||
Damage: -50
|
|
||||||
ValidTargets: Repair
|
ValidTargets: Repair
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ FireballLauncher:
|
|||||||
Burst: 5
|
Burst: 5
|
||||||
BurstDelay: 5
|
BurstDelay: 5
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: SpreadDamage
|
||||||
Spread: 341
|
Spread: 288
|
||||||
|
Falloff: 100, 50, 25, 12, 6, 3, 0
|
||||||
Damage: 25
|
Damage: 25
|
||||||
Versus:
|
Versus:
|
||||||
None: 600
|
None: 600
|
||||||
@@ -33,7 +34,8 @@ Bomb:
|
|||||||
Shadow: true
|
Shadow: true
|
||||||
Palette: ra
|
Palette: ra
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: SpreadDamage
|
||||||
Spread: 298
|
Spread: 512
|
||||||
|
Falloff: 100, 50, 25, 12, 6, 3, 0
|
||||||
Damage: 160
|
Damage: 160
|
||||||
Versus:
|
Versus:
|
||||||
None: 200
|
None: 200
|
||||||
@@ -55,6 +57,8 @@ Bomb:
|
|||||||
Warhead@4Smu: LeaveSmudge
|
Warhead@4Smu: LeaveSmudge
|
||||||
SmudgeType: MediumCrater
|
SmudgeType: MediumCrater
|
||||||
InvalidTargets: Vehicle, Building, Wall
|
InvalidTargets: Vehicle, Building, Wall
|
||||||
|
Warhead@5Res: DestroyResource
|
||||||
|
Size: 1
|
||||||
|
|
||||||
FiendShard:
|
FiendShard:
|
||||||
ReloadDelay: 30
|
ReloadDelay: 30
|
||||||
@@ -86,7 +90,7 @@ SlimeAttack:
|
|||||||
Range: 1c384
|
Range: 1c384
|
||||||
Report: vicer1.aud
|
Report: vicer1.aud
|
||||||
Projectile: InstantHit
|
Projectile: InstantHit
|
||||||
Warhead@1Dam: SpreadDamage
|
Warhead@1Dam: TargetDamage
|
||||||
Damage: 100
|
Damage: 100
|
||||||
Versus:
|
Versus:
|
||||||
Light: 60
|
Light: 60
|
||||||
@@ -96,8 +100,7 @@ SlimeAttack:
|
|||||||
|
|
||||||
Veins:
|
Veins:
|
||||||
ReloadDelay: 16
|
ReloadDelay: 16
|
||||||
Warhead@Damage: SpreadDamage
|
Warhead@Damage: TargetDamage
|
||||||
Spread: 42
|
|
||||||
Damage: 5
|
Damage: 5
|
||||||
DamageTypes: BulletDeath
|
DamageTypes: BulletDeath
|
||||||
Warhead@Effect: CreateEffect
|
Warhead@Effect: CreateEffect
|
||||||
|
|||||||
Reference in New Issue
Block a user