Remove AttackBase.IgnoresVisibility.
This was a workaround for D2K sandworms, which is now implemented using a custom attack activity.
This commit is contained in:
committed by
Oliver Brakmann
parent
8eeb6d68e7
commit
2ac7e451b4
@@ -74,6 +74,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
protected virtual bool IgnoresVisibility { get { return false; } }
|
||||
|
||||
protected virtual AttackStatus TickAttack(Actor self, AttackBase attack)
|
||||
{
|
||||
if (IsCanceled)
|
||||
@@ -90,7 +92,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// HACK: This would otherwise break targeting frozen actors
|
||||
// The problem is that Shroud.IsTargetable returns false (as it should) for
|
||||
// frozen actors, but we do want to explicitly target the underlying actor here.
|
||||
if (!attack.Info.IgnoresVisibility && type == TargetType.Actor
|
||||
if (!IgnoresVisibility && type == TargetType.Actor
|
||||
&& !Target.Actor.Info.HasTraitInfo<FrozenUnderFogInfo>()
|
||||
&& !Target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
return AttackStatus.UnableToAttack;
|
||||
|
||||
@@ -592,6 +592,7 @@
|
||||
<Compile Include="Traits\World\WeatherOverlay.cs" />
|
||||
<Compile Include="Traits\World\ActorSpawnManager.cs" />
|
||||
<Compile Include="Traits\ActorSpawner.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\RemoveAttackIgnoresVisibility.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\RemovedDemolishLocking.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\RemoveNegativeDamageFullHealthCheck.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20180923\RemoveResourceExplodeModifier.cs" />
|
||||
|
||||
@@ -31,9 +31,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Does the attack type require the attacker to enter the target's cell?")]
|
||||
public readonly bool AttackRequiresEnteringCell = false;
|
||||
|
||||
[Desc("Does not care about shroud or fog. Enables the actor to launch an attack against a target even if he has no visibility of it.")]
|
||||
public readonly bool IgnoresVisibility = false;
|
||||
|
||||
[VoiceReference] public readonly string Voice = "Action";
|
||||
|
||||
public override abstract object Create(ActorInitializer init);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2018 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class RemoveAttackIgnoresVisibility : UpdateRule
|
||||
{
|
||||
public override string Name { get { return "IgnoresVisibility has been removed from Attack* traits."; } }
|
||||
public override string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return "The IgnoresVisibility flag has been removed from the Attack* traits as part of a\n" +
|
||||
"wider rework of the fog-targeting behaviour. Mods that rely on this logic must\n" +
|
||||
"implement their own Attack* trait, similar to the AttackSwallow trait.";
|
||||
}
|
||||
}
|
||||
|
||||
static readonly string[] Traits =
|
||||
{
|
||||
"AttackFrontal",
|
||||
"AttackFollow",
|
||||
"AttackTurreted",
|
||||
"AttackOmni",
|
||||
"AttackBomber",
|
||||
"AttackPopupTurreted",
|
||||
"AttackTesla",
|
||||
"AttackSwallow"
|
||||
};
|
||||
|
||||
readonly List<string> locations = new List<string>();
|
||||
|
||||
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||
{
|
||||
if (locations.Any())
|
||||
yield return "The IgnoresVisibility flag has been removed from the targeting logic on the following actors:\n" +
|
||||
UpdateUtils.FormatMessageList(locations) + "\n\n" +
|
||||
"You may wish to enable TargetFrozenActors, or implement a custom Attack* trait like AttackSwallow\n" +
|
||||
"if you require visibility to be completely ignored.";
|
||||
|
||||
locations.Clear();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
foreach (var trait in Traits)
|
||||
foreach (var t in actorNode.ChildrenMatching(trait))
|
||||
if (t.RemoveNodes("IgnoresVisibility") > 0)
|
||||
locations.Add("{0} ({1})".F(actorNode.Key, actorNode.Location.Filename));
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
new RemoveResourceExplodeModifier(),
|
||||
new DefineLevelUpImageDefault(),
|
||||
new RemovedAutoCarryallCircleTurnSpeed(),
|
||||
new RemoveAttackIgnoresVisibility(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.D2k.Activities;
|
||||
using OpenRA.Traits;
|
||||
@@ -67,5 +69,19 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new SwallowActor(self, target, a, facing));
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
||||
{
|
||||
return new SwallowTarget(self, newTarget, allowMove, forceAttack, Info.FacingTolerance);
|
||||
}
|
||||
|
||||
public class SwallowTarget : Attack
|
||||
{
|
||||
public SwallowTarget(Actor self, Target target, bool allowMovement, bool forceAttack, int facingTolerance)
|
||||
: base(self, target, allowMovement, forceAttack, facingTolerance) { }
|
||||
|
||||
// Worms ignore visibility, so don't need to recalculate targets
|
||||
protected override bool IgnoresVisibility { get { return true; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,6 @@ sandworm:
|
||||
UseLocation: true
|
||||
AttackSwallow:
|
||||
AttackRequiresEnteringCell: true
|
||||
IgnoresVisibility: true
|
||||
AttackingCondition: attacking
|
||||
Armament:
|
||||
Weapon: WormJaw
|
||||
|
||||
Reference in New Issue
Block a user