Building capture

This commit is contained in:
Paul Chote
2010-07-23 21:26:26 +12:00
parent fdf57b1e63
commit 05953d0d6b
3 changed files with 24 additions and 32 deletions

View File

@@ -23,10 +23,7 @@ namespace OpenRA.Mods.RA.Activities
public IActivity Tick(Actor self) public IActivity Tick(Actor self)
{ {
if (target == null || target.IsDead) return NextActivity; if (target == null || target.IsDead) return NextActivity;
var damage = self.Info.Traits.Get<EngineerCaptureInfo>().EngineerDamage;
if (target.Health - damage <= 0)
{
target.World.AddFrameEndTask(w => target.World.AddFrameEndTask(w =>
{ {
// momentarily remove from world so the ownership queries don't get confused // momentarily remove from world so the ownership queries don't get confused
@@ -38,11 +35,6 @@ namespace OpenRA.Mods.RA.Activities
t.OnCapture(target, self); t.OnCapture(target, self);
}); });
target.InflictDamage(self, target.Health - damage, null);
}
else
target.InflictDamage(self, damage, null);
// the engineer is sacrificed. // the engineer is sacrificed.
self.World.AddFrameEndTask(w => w.Remove(self)); self.World.AddFrameEndTask(w => w.Remove(self));

View File

@@ -9,43 +9,44 @@
#endregion #endregion
using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Activities;
using OpenRA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities; using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class EngineerCaptureInfo : TraitInfo<EngineerCapture> class EngineerCaptureInfo : TraitInfo<EngineerCapture> {}
class EngineerCapture : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
{ {
public readonly int EngineerDamage = 300;
}
class EngineerCapture : IIssueOrder, IResolveOrder, IOrderCursor
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{ {
if (mi.Button != MouseButton.Right) return null; if (mi.Button != MouseButton.Right) return null;
if (underCursor == null) return null; if (underCursor == null) return null;
if (self.Owner.Stances[underCursor.Owner] != Stance.Enemy) return null; if (self.Owner.Stances[underCursor.Owner] != Stance.Enemy) return null;
if (!underCursor.traits.Contains<Building>()) return null; if (!underCursor.traits.Contains<Building>()) return null;
var isCapture = underCursor.Health <= self.Info.Traits.Get<EngineerCaptureInfo>().EngineerDamage;
return new Order(isCapture ? "Capture" : "Infiltrate", return new Order("CaptureBuilding", self, underCursor);
self, underCursor);
} }
public string CursorForOrder(Actor self, Order order) public string CursorForOrder(Actor self, Order order)
{ {
return (order.OrderString == "Infiltrate") ? "enter" : return (order.OrderString == "CaptureBuilding") ? "capture" : null;
(order.OrderString == "Capture") ? "capture" : null; }
public string VoicePhraseForOrder(Actor self, Order order)
{
return (order.OrderString == "CaptureBuilding") ? "Attack" : null;
} }
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Infiltrate" || order.OrderString == "Capture") if (order.OrderString == "CaptureBuilding")
{ {
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor, 1)); self.QueueActivity(new Move(order.TargetActor.Location, order.TargetActor));
self.QueueActivity(new CaptureBuilding(order.TargetActor)); self.QueueActivity(new CaptureBuilding(order.TargetActor));
} }
} }

View File

@@ -125,7 +125,6 @@ E6:
ColorOfCargoPip: Yellow ColorOfCargoPip: Yellow
EngineerRepair: EngineerRepair:
EngineerCapture: EngineerCapture:
EngineerDamage: 9999999
-AutoTarget: -AutoTarget:
RMBO: RMBO: