From 888706befa306798d450cbec48f5ed810731eecb Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 6 May 2010 20:28:28 +1200 Subject: [PATCH] initial work on DOG attack --- OpenRA.Game/OpenRA.Game.csproj | 2 ++ OpenRA.Game/Traits/Activities/Leap.cs | 41 +++++++++++++++++++++ OpenRA.Game/Traits/Attack/AttackLeap.cs | 48 +++++++++++++++++++++++++ mods/ra/infantry.yaml | 3 +- mods/ra/sequences.xml | 17 ++++----- 5 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 OpenRA.Game/Traits/Activities/Leap.cs create mode 100644 OpenRA.Game/Traits/Attack/AttackLeap.cs diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 1d5a93602e..75a6c04b9f 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -80,8 +80,10 @@ + + diff --git a/OpenRA.Game/Traits/Activities/Leap.cs b/OpenRA.Game/Traits/Activities/Leap.cs new file mode 100644 index 0000000000..fdc3b4ecad --- /dev/null +++ b/OpenRA.Game/Traits/Activities/Leap.cs @@ -0,0 +1,41 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it 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. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +namespace OpenRA.Traits.Activities +{ + class Leap : IActivity + { + Actor target; + + public Leap(Actor target) { this.target = target; } + + public IActivity NextActivity { get; set; } + + public IActivity Tick(Actor self) + { + if (target == null || !target.IsInWorld) + return NextActivity; + + return this; + } + + public void Cancel(Actor self) { target = null; NextActivity = null; } + } +} diff --git a/OpenRA.Game/Traits/Attack/AttackLeap.cs b/OpenRA.Game/Traits/Attack/AttackLeap.cs new file mode 100644 index 0000000000..72abcc7b91 --- /dev/null +++ b/OpenRA.Game/Traits/Attack/AttackLeap.cs @@ -0,0 +1,48 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it 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. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using OpenRA.Traits.Activities; + +namespace OpenRA.Traits +{ + class AttackLeapInfo : AttackBaseInfo + { + public override object Create(Actor self) { return new AttackLeap(self); } + } + + class AttackLeap : AttackBase + { + public AttackLeap(Actor self) + : base(self) {} + + public override void Tick(Actor self) + { + base.Tick(self); + + if (target == null || !target.IsInWorld) return; + + var weapon = self.GetPrimaryWeapon(); + if (weapon.Range * weapon.Range < (target.Location - self.Location).LengthSquared) return; + + self.CancelActivity(); + self.QueueActivity(new Leap(target)); + } + } +} diff --git a/mods/ra/infantry.yaml b/mods/ra/infantry.yaml index a8986bb995..706c25aa39 100644 --- a/mods/ra/infantry.yaml +++ b/mods/ra/infantry.yaml @@ -15,7 +15,8 @@ DOG: HP: 12 Sight: 5 Speed: 4 - -AutoTarget: + AutoTarget: + AttackLeap: E1: Inherits: ^Infantry diff --git a/mods/ra/sequences.xml b/mods/ra/sequences.xml index cdb08d7baa..e20bbbc7e2 100644 --- a/mods/ra/sequences.xml +++ b/mods/ra/sequences.xml @@ -440,8 +440,8 @@ - - + + @@ -631,7 +631,7 @@ - + @@ -639,6 +639,7 @@ + @@ -899,8 +900,8 @@ - - + + @@ -911,7 +912,7 @@ - + @@ -920,7 +921,7 @@ - - + + \ No newline at end of file