@@ -99,7 +99,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
HackyAI bot;
|
||||
XRandom random;
|
||||
|
||||
Actor target;
|
||||
Target target;
|
||||
StateMachine fsm;
|
||||
|
||||
//fuzzy
|
||||
@@ -113,7 +113,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
this.world = bot.world;
|
||||
this.random = bot.random;
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
this.target = Traits.Target.FromActor(target);
|
||||
|
||||
fsm = new StateMachine(this);
|
||||
|
||||
switch (type)
|
||||
@@ -144,14 +145,13 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
public Actor Target
|
||||
{
|
||||
get { return target; }
|
||||
set { target = value; }
|
||||
get { return target.Actor; }
|
||||
set { target = Traits.Target.FromActor(value); }
|
||||
}
|
||||
|
||||
public bool TargetIsValid
|
||||
{
|
||||
get { return (target != null && !target.IsDead() && !target.Destroyed
|
||||
&& target.IsInWorld && !target.HasTrait<Husk>()); }
|
||||
get { return target.IsValidFor(units.FirstOrDefault()) && !target.Actor.HasTrait<Husk>(); }
|
||||
}
|
||||
|
||||
//**********************************************************************************
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public class Attack : Activity
|
||||
{
|
||||
protected Target Target;
|
||||
ITargetable targetable;
|
||||
WRange Range;
|
||||
bool AllowMovement;
|
||||
|
||||
@@ -33,9 +32,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public Attack(Target target, WRange range, bool allowMovement)
|
||||
{
|
||||
Target = target;
|
||||
if (target.Type == TargetType.Actor)
|
||||
targetable = target.Actor.TraitOrDefault<ITargetable>();
|
||||
|
||||
Range = range;
|
||||
AllowMovement = allowMovement;
|
||||
}
|
||||
@@ -54,13 +50,11 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
|
||||
var type = Target.Type;
|
||||
if (type != TargetType.Actor && type != TargetType.Terrain)
|
||||
return NextActivity;
|
||||
|
||||
if (type == TargetType.Actor && !self.Owner.HasFogVisibility() && Target.Actor.HasTrait<Mobile>() && !self.Owner.Shroud.IsTargetable(Target.Actor))
|
||||
if (!Target.IsValidFor(self) || type == TargetType.FrozenActor)
|
||||
return NextActivity;
|
||||
|
||||
if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
|
||||
// TODO: This is horrible, and probably wrong. Work out what it is trying to solve, then redo it properly.
|
||||
if (type == TargetType.Actor && !self.Owner.HasFogVisibility() && Target.Actor.HasTrait<Mobile>() && !self.Owner.Shroud.IsTargetable(Target.Actor))
|
||||
return NextActivity;
|
||||
|
||||
if (!Target.IsInRange(self.CenterPosition, Range))
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
var capturable = target.Actor.Trait<Capturable>();
|
||||
|
||||
if (IsCanceled || !self.IsInWorld || self.IsDead())
|
||||
if (IsCanceled || !self.IsInWorld || self.IsDead() || !target.IsValidFor(self))
|
||||
{
|
||||
if (capturable.CaptureInProgress)
|
||||
capturable.EndCapture();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || target.Type != TargetType.Actor)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
|
||||
|
||||
@@ -27,7 +27,10 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || target.Type != TargetType.Actor)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (target.Type != TargetType.Actor)
|
||||
return NextActivity;
|
||||
|
||||
var targetActor = target.Actor;
|
||||
|
||||
@@ -27,7 +27,10 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || target.Type != TargetType.Actor)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (target.Type != TargetType.Actor)
|
||||
return NextActivity;
|
||||
|
||||
if (!Util.AdjacentCells(target).Any(c => c == self.Location))
|
||||
|
||||
@@ -16,21 +16,23 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public class Follow : Activity
|
||||
{
|
||||
Target target;
|
||||
Mobile mobile;
|
||||
WRange range;
|
||||
int nextPathTime;
|
||||
|
||||
const int delayBetweenPathingAttempts = 20;
|
||||
const int delaySpread = 5;
|
||||
|
||||
public Follow(Target target, WRange range)
|
||||
public Follow(Actor self, Target target, WRange range)
|
||||
{
|
||||
this.target = target;
|
||||
mobile = self.Trait<Mobile>();
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !target.IsValid)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (target.IsInRange(self.CenterPosition, range) || --nextPathTime > 0)
|
||||
@@ -39,7 +41,6 @@ namespace OpenRA.Mods.RA.Activities
|
||||
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
|
||||
delayBetweenPathingAttempts + delaySpread);
|
||||
|
||||
var mobile = self.Trait<Mobile>();
|
||||
return Util.SequenceActivities(mobile.MoveWithinRange(target, range), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
protected override Activity InnerTick(Actor self, AttackBase attack)
|
||||
{
|
||||
if (!Target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (Target.Type == TargetType.Actor && Target.Actor.GetDamageState() == DamageState.Undamaged)
|
||||
return NextActivity;
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || target.Type != TargetType.Actor)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (target.Type != TargetType.Actor)
|
||||
return NextActivity;
|
||||
|
||||
var actor = target.Actor;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !target.IsValid)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var mobile = self.Trait<Mobile>();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
Cancel(self);
|
||||
|
||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !target.IsValid)
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
Cancel(self);
|
||||
|
||||
if (IsCanceled)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
||||
if (!self.IsInWorld)
|
||||
return false;
|
||||
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
return false;
|
||||
|
||||
if (Armaments.All(a => a.IsReloading))
|
||||
@@ -54,10 +54,6 @@ namespace OpenRA.Mods.RA
|
||||
if (self.IsDisabled())
|
||||
return false;
|
||||
|
||||
if (target.Type == TargetType.Actor && target.Actor.HasTrait<ITargetable>() &&
|
||||
!target.Actor.Trait<ITargetable>().TargetableBy(target.Actor, self))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -133,7 +129,7 @@ namespace OpenRA.Mods.RA
|
||||
if (order.OrderString == "Attack")
|
||||
{
|
||||
var target = self.ResolveFrozenActorOrder(order, Color.Red);
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
return;
|
||||
|
||||
self.SetTargetLine(target, Color.Red);
|
||||
@@ -155,7 +151,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void AttackTarget(Target target, bool queued, bool allowMove)
|
||||
{
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
return;
|
||||
|
||||
if (!queued)
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid )
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
self.Trait<AttackOmni>().DoAttack(self, target);
|
||||
|
||||
@@ -67,7 +67,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var attack = self.Trait<AttackTesla>();
|
||||
if( attack.charges == 0 || !attack.CanAttack( self, target ) )
|
||||
@@ -85,7 +86,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override Activity Tick( Actor self )
|
||||
{
|
||||
if( IsCanceled || !target.IsValid ) return NextActivity;
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var attack = self.Trait<AttackTesla>();
|
||||
if( attack.charges == 0 ) return NextActivity;
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace OpenRA.Mods.RA
|
||||
if (self.HasTrait<Building>() && !buildComplete)
|
||||
return false;
|
||||
|
||||
if (!target.IsValid) return false;
|
||||
if (!target.IsValidFor(self))
|
||||
return false;
|
||||
|
||||
bool canAttack = false;
|
||||
foreach (var t in turrets)
|
||||
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
base.Tick(self);
|
||||
DoAttack(self, Target);
|
||||
IsAttacking = Target.IsValid;
|
||||
IsAttacking = Target.IsValidFor(self);
|
||||
}
|
||||
|
||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove)
|
||||
@@ -84,7 +85,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || !target.IsValid) return NextActivity;
|
||||
if (IsCanceled || !target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (self.IsDisabled()) return this;
|
||||
|
||||
@@ -98,7 +100,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
attack.Target = target;
|
||||
if (allowMove && self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
|
||||
return Util.SequenceActivities(new Follow(target, range), this);
|
||||
return Util.SequenceActivities(new Follow(self, target, range), this);
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
|
||||
@@ -19,12 +19,14 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class CloakInfo : ITraitInfo
|
||||
{
|
||||
public int InitialDelay = 10; // Ticks
|
||||
public int CloakDelay = 30; // Ticks
|
||||
public string CloakSound = "subshow1.aud";
|
||||
public string UncloakSound = "subshow1.aud";
|
||||
public readonly string Palette = "cloak";
|
||||
public readonly int InitialDelay = 10; // Ticks
|
||||
public readonly int CloakDelay = 30; // Ticks
|
||||
public readonly bool UncloakOnMove = false;
|
||||
public readonly bool RequiresCrate = false;
|
||||
|
||||
public readonly string CloakSound = "subshow1.aud";
|
||||
public readonly string UncloakSound = "subshow1.aud";
|
||||
public readonly string Palette = "cloak";
|
||||
|
||||
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
|
||||
}
|
||||
@@ -32,7 +34,8 @@ namespace OpenRA.Mods.RA
|
||||
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
||||
{
|
||||
[Sync] int remainingTime;
|
||||
[Sync] bool canCloak = true;
|
||||
[Sync] bool damageDisabled;
|
||||
[Sync] bool crateDisabled;
|
||||
|
||||
Actor self;
|
||||
CloakInfo info;
|
||||
@@ -44,6 +47,7 @@ namespace OpenRA.Mods.RA
|
||||
this.self = self;
|
||||
|
||||
remainingTime = info.InitialDelay;
|
||||
crateDisabled = info.RequiresCrate;
|
||||
}
|
||||
|
||||
public void Uncloak() { Uncloak(info.CloakDelay); }
|
||||
@@ -62,8 +66,9 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
canCloak = (e.DamageState < DamageState.Critical);
|
||||
if (!canCloak) Uncloak();
|
||||
damageDisabled = e.DamageState >= DamageState.Critical;
|
||||
if (damageDisabled)
|
||||
Uncloak();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
@@ -82,9 +87,12 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (remainingTime > 0 && canCloak)
|
||||
if (--remainingTime <= 0)
|
||||
Sound.Play(info.CloakSound, self.CenterPosition);
|
||||
if (remainingTime > 0 && !crateDisabled && !damageDisabled && --remainingTime <= 0)
|
||||
{
|
||||
self.Generation++;
|
||||
Sound.Play(info.CloakSound, self.CenterPosition);
|
||||
}
|
||||
|
||||
if (self.IsDisabled())
|
||||
Uncloak();
|
||||
|
||||
@@ -95,15 +103,14 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible(Actor self, Player byPlayer)
|
||||
public bool IsVisible(Actor self, Player viewer)
|
||||
{
|
||||
if (!Cloaked || self.Owner.IsAlliedWith(byPlayer))
|
||||
if (!Cloaked || self.Owner.IsAlliedWith(viewer))
|
||||
return true;
|
||||
|
||||
// TODO: Change this to be per-player? A cloak detector revealing to everyone is dumb
|
||||
return self.World.ActorsWithTrait<DetectCloaked>().Any(a =>
|
||||
a.Actor.Owner.Stances[self.Owner] != Stance.Ally &&
|
||||
(self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||
var centerPosition = self.CenterPosition;
|
||||
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => a.Actor.Owner.IsAlliedWith(viewer) &&
|
||||
(centerPosition - a.Actor.CenterPosition).Length < WRange.FromCells(a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range).Range);
|
||||
}
|
||||
|
||||
public Color RadarColorOverride(Actor self)
|
||||
@@ -113,5 +120,12 @@ namespace OpenRA.Mods.RA
|
||||
c = Color.FromArgb(128, c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public bool AcceptsCloakCrate { get { return info.RequiresCrate && crateDisabled; } }
|
||||
|
||||
public void ReceivedCloakCrate(Actor self)
|
||||
{
|
||||
crateDisabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,52 +16,27 @@ namespace OpenRA.Mods.RA.Crates
|
||||
{
|
||||
public class CloakCrateActionInfo : CrateActionInfo
|
||||
{
|
||||
public readonly int InitialDelay = 10;
|
||||
public readonly int CloakDelay = 30;
|
||||
public readonly string CloakSound = "subshow1.aud";
|
||||
public readonly string UncloakSound = "subshow1.aud";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new CloakCrateAction(init.self, this); }
|
||||
}
|
||||
|
||||
public class CloakCrateAction : CrateAction
|
||||
{
|
||||
CloakCrateActionInfo Info;
|
||||
public CloakCrateAction(Actor self, CloakCrateActionInfo info)
|
||||
: base(self, info) { Info = info; }
|
||||
: base(self, info) { }
|
||||
|
||||
public override int GetSelectionShares(Actor collector)
|
||||
{
|
||||
return collector.HasTrait<AcceptsCloakCrate>() && !collector.HasTrait<Cloak>()
|
||||
? base.GetSelectionShares(collector) : 0;
|
||||
var cloak = collector.TraitOrDefault<Cloak>();
|
||||
if (cloak == null || !cloak.AcceptsCloakCrate)
|
||||
return 0;
|
||||
|
||||
return base.GetSelectionShares(collector);
|
||||
}
|
||||
|
||||
public override void Activate(Actor collector)
|
||||
{
|
||||
var cloakInfo = new CloakInfo()
|
||||
{
|
||||
InitialDelay = Info.InitialDelay,
|
||||
CloakDelay = Info.CloakDelay,
|
||||
CloakSound = Info.CloakSound,
|
||||
UncloakSound = Info.UncloakSound
|
||||
};
|
||||
var cloak = new Cloak(collector, cloakInfo);
|
||||
|
||||
collector.World.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(collector);
|
||||
|
||||
collector.AddTrait(cloak);
|
||||
var t = collector.TraitOrDefault<TargetableUnit>();
|
||||
if (t != null) t.ReceivedCloak(collector);
|
||||
|
||||
w.Add(collector);
|
||||
});
|
||||
|
||||
collector.Trait<Cloak>().ReceivedCloakCrate(collector);
|
||||
base.Activate(collector);
|
||||
}
|
||||
}
|
||||
|
||||
public class AcceptsCloakCrateInfo : TraitInfo<AcceptsCloakCrate> {}
|
||||
public class AcceptsCloakCrate {}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
Lazy<HiddenUnderFog> huf;
|
||||
Lazy<FrozenUnderFog> fuf;
|
||||
Lazy<Spy> spy;
|
||||
Lazy<Cloak> cloak;
|
||||
Cache<Player, GpsWatcher> watcher;
|
||||
Cache<Player, FrozenActorLayer> frozen;
|
||||
|
||||
@@ -53,15 +54,15 @@ namespace OpenRA.Mods.RA.Effects
|
||||
huf = Lazy.New(() => self.TraitOrDefault<HiddenUnderFog>());
|
||||
fuf = Lazy.New(() => self.TraitOrDefault<FrozenUnderFog>());
|
||||
spy = Lazy.New(() => self.TraitOrDefault<Spy>());
|
||||
cloak = Lazy.New(() => self.TraitOrDefault<Cloak>());
|
||||
|
||||
watcher = new Cache<Player, GpsWatcher>(p => p.PlayerActor.Trait<GpsWatcher>());
|
||||
frozen = new Cache<Player, FrozenActorLayer>(p => p.PlayerActor.Trait<FrozenActorLayer>());
|
||||
}
|
||||
|
||||
bool ShouldShowIndicator()
|
||||
{
|
||||
// Can be granted at runtime via a crate, so can't cache
|
||||
var cloak = self.TraitOrDefault<Cloak>();
|
||||
if (cloak != null && cloak.Cloaked)
|
||||
if (cloak.Value != null && cloak.Value.Cloaked)
|
||||
return false;
|
||||
|
||||
if (spy.Value != null && spy.Value.Disguised)
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
public void Tick(World world)
|
||||
{
|
||||
// Beam tracks target
|
||||
if (args.guidedTarget.IsValid)
|
||||
if (args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
target = args.guidedTarget.CenterPosition;
|
||||
|
||||
if (!doneDamage)
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
anim.Tick();
|
||||
|
||||
// Missile tracks target
|
||||
if (args.guidedTarget.IsValid)
|
||||
if (args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
target = args.guidedTarget.CenterPosition;
|
||||
|
||||
var dist = target + offset - pos;
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
desiredFacing = facing + world.SharedRandom.Next(-20, 21);
|
||||
desiredAltitude = world.SharedRandom.Next(-43, 86);
|
||||
}
|
||||
else if (!args.guidedTarget.IsValid)
|
||||
else if (!args.guidedTarget.IsValidFor(args.sourceActor))
|
||||
desiredFacing = facing;
|
||||
|
||||
facing = Traits.Util.TickFacing(facing, desiredFacing, info.ROT);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
var pos = Args.guidedTarget.IsValid ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
var pos = Args.guidedTarget.IsValidFor(Args.sourceActor) ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
Combat.DoImpacts(pos, Args.sourceActor, Args.weapon, Args.firepowerModifier);
|
||||
doneDamage = true;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
var pos = Args.guidedTarget.IsValid ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
var pos = Args.guidedTarget.IsValidFor(Args.sourceActor) ? Args.guidedTarget.CenterPosition : Args.passiveTarget;
|
||||
zap = new TeslaZapRenderable(Args.source, 0, pos - Args.source, Info.Image, Info.BrightZaps, Info.DimZaps);
|
||||
}
|
||||
yield return zap;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var range = WRange.FromCells(target.Actor.Info.Traits.Get<GuardableInfo>().Range);
|
||||
self.QueueActivity(false, new AttackMove.AttackMoveActivity(self,
|
||||
new Follow(target, range)));
|
||||
new Follow(self, target, range)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
return false;
|
||||
|
||||
var location = target.CenterPosition.ToCPos();
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
{
|
||||
this.getPath = (self, mobile) =>
|
||||
{
|
||||
if (!target.IsValid)
|
||||
if (!target.IsValidFor(self))
|
||||
return NoPath;
|
||||
|
||||
return self.World.WorldActor.Trait<PathFinder>().FindUnitPathToRange(
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA
|
||||
if (reservedFor == null)
|
||||
return; /* nothing to do */
|
||||
|
||||
if (!Target.FromActor( reservedFor ).IsValid)
|
||||
if (!Target.FromActor(reservedFor).IsValidFor(self))
|
||||
reservedFor = null; /* not likely to arrive now. */
|
||||
}
|
||||
|
||||
|
||||
@@ -30,24 +30,15 @@ namespace OpenRA.Mods.RA
|
||||
public TargetableUnit(Actor self, TargetableUnitInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
ReceivedCloak(self);
|
||||
}
|
||||
|
||||
// Arbitrary units can receive cloak via a crate during gameplay
|
||||
public void ReceivedCloak(Actor self)
|
||||
{
|
||||
cloak = self.TraitOrDefault<Cloak>();
|
||||
}
|
||||
|
||||
public virtual bool TargetableBy(Actor self, Actor byActor)
|
||||
public virtual bool TargetableBy(Actor self, Actor viewer)
|
||||
{
|
||||
if (cloak == null || !cloak.Cloaked)
|
||||
return true;
|
||||
|
||||
if (self.Owner.IsAlliedWith(byActor.Owner))
|
||||
return true;
|
||||
|
||||
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);
|
||||
return cloak.IsVisible(self, viewer.Owner);
|
||||
}
|
||||
|
||||
public virtual string[] TargetTypes { get { return info.TargetTypes; } }
|
||||
|
||||
Reference in New Issue
Block a user