Improve Leap behavior:

* Configurable jump speed.
* Configurable jump angle.
* Configurable attack sound (uses weapon report).
* Don't accidentally eat tanks.
This commit is contained in:
Paul Chote
2013-07-08 22:10:05 +12:00
parent 4fbed810dc
commit 2cff2d8bbe
2 changed files with 39 additions and 22 deletions

View File

@@ -10,6 +10,7 @@
using System;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
@@ -17,17 +18,26 @@ namespace OpenRA.Mods.RA
{
class AttackLeapInfo : AttackFrontalInfo
{
[Desc("Leap speed (in units/tick).")]
public readonly WRange Speed = new WRange(426);
public readonly WAngle Angle = WAngle.FromDegrees(20);
public override object Create(ActorInitializer init) { return new AttackLeap(init.self, this); }
}
class AttackLeap : AttackFrontal, ISync
{
AttackLeapInfo info;
public AttackLeap(Actor self, AttackLeapInfo info)
: base(self, info) {}
: base(self, info)
{
this.info = info;
}
public override void DoAttack(Actor self, Target target)
{
if (!CanAttack(self, target))
if (!CanAttack(self, target) || !target.IsActor)
return;
var a = ChooseArmamentForTarget(target);
@@ -40,7 +50,7 @@ namespace OpenRA.Mods.RA
return;
self.CancelActivity();
self.QueueActivity(new Leap(self, target));
self.QueueActivity(new Leap(self, target.Actor, a.Weapon, info.Speed, info.Angle));
}
}
}