Display an "outside range" cursor for attacks.

This commit is contained in:
Pizzaoverhead
2014-03-06 19:15:00 +00:00
committed by Paul Chote
parent 2fd47ee743
commit ce49d5df5e
4 changed files with 35 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA
public abstract class AttackBaseInfo : ITraitInfo
{
public readonly string Cursor = "attack";
public readonly string OutsideRangeCursor = "attackoutsiderange";
public abstract object Create(ActorInitializer init);
}
@@ -188,7 +189,10 @@ namespace OpenRA.Mods.RA
{
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = ab.info.Cursor;
var a = ab.ChooseArmamentForTarget(target);
cursor = a != null && !target.IsInRange(self.CenterPosition, a.Weapon.Range)
? ab.info.OutsideRangeCursor
: ab.info.Cursor;
if (target.Type == TargetType.Actor && target.Actor == self)
return false;
@@ -220,11 +224,18 @@ namespace OpenRA.Mods.RA
if (negativeDamage)
return false;
if (!self.Trait<AttackBase>().HasAnyValidWeapons(Target.FromCell(location)))
if (!ab.HasAnyValidWeapons(Target.FromCell(location)))
return false;
if (modifiers.HasModifier(TargetModifiers.ForceAttack))
{
var maxRange = ab.GetMaximumRange().Range;
var targetRange = (location.CenterPosition - self.CenterPosition).HorizontalLengthSquared;
if (targetRange > maxRange * maxRange)
cursor = ab.info.OutsideRangeCursor;
return true;
}
return false;
}

View File

@@ -119,6 +119,16 @@ Cursors:
length: 8
x: 24
y: 24
attackoutsiderange:
start:16
length: 8
x: 24
y: 24
attackoutsiderange-minimap:
start:16
length: 8
x: 24
y: 24
attackmove:
start:16
length: 8

View File

@@ -70,6 +70,12 @@ Cursors:
attack-minimap:
start:203
length: 8
attackoutsiderange:
start:21
length: 8
attackoutsiderange-minimap:
start:134
length: 8
harvest:
start:21
length: 8

View File

@@ -72,6 +72,12 @@ Cursors:
attack-minimap:
start: 63
length: 5
attackoutsiderange:
start: 58
length: 5
attackoutsiderange-minimap:
start: 63
length: 5
attackmove: #TODO
start: 58
length: 5