diff --git a/OpenRA.Mods.RA/Activities/CaptureActor.cs b/OpenRA.Mods.RA/Activities/CaptureActor.cs index cef8d7ef96..ec9611a3f4 100644 --- a/OpenRA.Mods.RA/Activities/CaptureActor.cs +++ b/OpenRA.Mods.RA/Activities/CaptureActor.cs @@ -9,8 +9,8 @@ #endregion using System.Linq; -using OpenRA.Traits; using OpenRA.Mods.RA.Move; +using OpenRA.Traits; namespace OpenRA.Mods.RA.Activities { @@ -26,6 +26,12 @@ namespace OpenRA.Mods.RA.Activities if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; if (target.Owner == self.Owner) return NextActivity; + // Need to be next to building, TODO: stop capture when going away + var mobile = self.Trait(); + var nearest = target.OccupiesSpace.NearestCellTo(mobile.toCell); + if ((nearest - mobile.toCell).LengthSquared > 2) + return Util.SequenceActivities(new MoveAdjacentTo(Target.FromActor(target)), this); + var capturable = target.TraitOrDefault(); if (capturable != null && capturable.CaptureInProgress && capturable.Captor.Owner.Stances[self.Owner] == Stance.Ally) return NextActivity; @@ -34,12 +40,9 @@ namespace OpenRA.Mods.RA.Activities if (sellable != null && sellable.Selling) return NextActivity; - var captures = self.TraitOrDefault(); + target.Trait().BeginCapture(target, self); + var capturesInfo = self.Info.Traits.Get(); - if (captures != null && Combat.IsInRange(self.CenterLocation, capturesInfo.Range, target)) - target.Trait().BeginCapture(target, self); - else - return Util.SequenceActivities(self.Trait().MoveWithinRange(Target.FromActor(target), capturesInfo.Range), this); if (capturesInfo != null && capturesInfo.wastedAfterwards) self.World.AddFrameEndTask(w => self.Destroy()); diff --git a/OpenRA.Mods.RA/Captures.cs b/OpenRA.Mods.RA/Captures.cs index 67b5ab18d0..163452fdb0 100644 --- a/OpenRA.Mods.RA/Captures.cs +++ b/OpenRA.Mods.RA/Captures.cs @@ -22,7 +22,6 @@ namespace OpenRA.Mods.RA class CapturesInfo : ITraitInfo { public string[] CaptureTypes = {"building"}; - public int Range = 3; public bool wastedAfterwards = true; public object Create(ActorInitializer init) { return new Captures(init.self, this); } } diff --git a/OpenRA.Mods.RA/TransformOnCapture.cs b/OpenRA.Mods.RA/TransformOnCapture.cs index 5bae4e32f0..4a15bf4570 100644 --- a/OpenRA.Mods.RA/TransformOnCapture.cs +++ b/OpenRA.Mods.RA/TransformOnCapture.cs @@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA { [ActorReference] public readonly string IntoActor = null; public readonly int ForceHealthPercentage = 0; + public readonly bool SkipMakeAnims = true; public virtual object Create(ActorInitializer init) { return new TransformOnCapture(this); } } @@ -32,7 +33,7 @@ namespace OpenRA.Mods.RA var facing = self.TraitOrDefault(); var transform = new Transform(self, Info.IntoActor) { ForceHealthPercentage = Info.ForceHealthPercentage }; if (facing != null) transform.Facing = facing.Facing; - transform.SkipMakeAnims = true; + transform.SkipMakeAnims = Info.SkipMakeAnims; self.CancelActivity(); self.QueueActivity(transform); } diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index 7bac1ddc1f..1492c0f94b 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -32,6 +32,7 @@ V01: Range: 10 TransformOnCapture: IntoActor: v01.sniper + SkipMakeAnims: true Capturable: Type: civilianbuilding CaptureCompleteTime: 0