prevent allied units from autoattack building which is being captured. resolves #6170.
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -90,6 +90,7 @@ Also thanks to:
|
||||
* Matthijs Benschop (Nerdie)
|
||||
* Max621
|
||||
* Max Ugrumov (katzsmile)
|
||||
* Michael Rätzel
|
||||
* Michael Sztolcman (s1w_)
|
||||
* Mustafa Alperen Seki (MustaphaTR)
|
||||
* Neil Shivkar (havok13888)
|
||||
|
||||
@@ -168,7 +168,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Actor ChooseTarget(Actor self, WDist range, bool allowMove)
|
||||
{
|
||||
var inRange = self.World.FindActorsInCircle(self.CenterPosition, range)
|
||||
.Where(a => !a.Info.HasTraitInfo<AutoTargetIgnoreInfo>());
|
||||
.Where(a =>
|
||||
!a.TraitsImplementing<IPreventsAutoTarget>().Any(t => t.PreventsAutoTarget(a, self)));
|
||||
|
||||
// Armaments are enumerated in attack.Armaments in construct order
|
||||
// When autotargeting, first choose targets according to the used armament construct order
|
||||
@@ -207,7 +208,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
[Desc("Will not get automatically targeted by enemy (like walls)")]
|
||||
class AutoTargetIgnoreInfo : TraitInfo<AutoTargetIgnore> { }
|
||||
class AutoTargetIgnore { }
|
||||
class AutoTargetIgnore : IPreventsAutoTarget
|
||||
{
|
||||
public bool PreventsAutoTarget(Actor self, Actor attacker)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class StanceInit : IActorInit<UnitStance>
|
||||
{
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Seconds it takes to change the owner.", "You might want to add a ExternalCapturableBar: trait, too.")]
|
||||
public readonly int CaptureCompleteTime = 15;
|
||||
|
||||
[Desc("Whether to prevent autotargeting this actor while it is being captured by an ally.")]
|
||||
public readonly bool PreventsAutoTarget = true;
|
||||
|
||||
public bool CanBeTargetedBy(Actor captor, Player owner)
|
||||
{
|
||||
var c = captor.Info.TraitInfoOrDefault<ExternalCapturesInfo>();
|
||||
@@ -49,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public object Create(ActorInitializer init) { return new ExternalCapturable(init.Self, this); }
|
||||
}
|
||||
|
||||
public class ExternalCapturable : ITick, ISync
|
||||
public class ExternalCapturable : ITick, ISync, IPreventsAutoTarget
|
||||
{
|
||||
[Sync] public int CaptureProgressTime = 0;
|
||||
[Sync] public Actor Captor;
|
||||
@@ -91,5 +94,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
CaptureProgressTime++;
|
||||
}
|
||||
|
||||
public bool PreventsAutoTarget(Actor self, Actor attacker)
|
||||
{
|
||||
return Info.PreventsAutoTarget && Captor != null && attacker.AppearsFriendlyTo(Captor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,4 +121,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
void ModifyDeathActorInit(Actor self, TypeDictionary init);
|
||||
}
|
||||
|
||||
public interface IPreventsAutoTarget
|
||||
{
|
||||
bool PreventsAutoTarget(Actor self, Actor attacker);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user