diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs index 5f25dd682e..e85fc8aa5c 100644 --- a/OpenRA.Mods.RA/Attack/AttackBase.cs +++ b/OpenRA.Mods.RA/Attack/AttackBase.cs @@ -20,6 +20,7 @@ namespace OpenRA.Mods.RA public abstract class AttackBaseInfo : ITraitInfo { public readonly bool CanAttackGround = true; + public readonly string Cursor = "attack"; public abstract object Create(ActorInitializer init); } @@ -41,10 +42,17 @@ namespace OpenRA.Mods.RA protected virtual bool CanAttack(Actor self, Target target) { - if (!self.IsInWorld) return false; - if (!target.IsValid) return false; - if (Armaments.All(a => a.IsReloading)) return false; - if (self.IsDisabled()) return false; + if (!self.IsInWorld) + return false; + + if (!target.IsValid) + return false; + + if (Armaments.All(a => a.IsReloading)) + return false; + + if (self.IsDisabled()) + return false; if (target.IsActor && target.Actor.HasTrait() && !target.Actor.Trait().TargetableBy(target.Actor,self)) @@ -96,19 +104,20 @@ namespace OpenRA.Mods.RA if (Armaments.Count() == 0) yield break; - bool isHeal = Armaments.First().Weapon.Warheads[0].Damage < 0; - yield return new AttackOrderTargeter("Attack", 6, isHeal); + var negativeDamage = (Armaments.First().Weapon.Warheads[0].Damage < 0); + + yield return new AttackOrderTargeter("Attack", 6, negativeDamage); } } - public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) + public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { - if( order is AttackOrderTargeter ) + if (order is AttackOrderTargeter) { - if( target.IsActor ) + if (target.IsActor) return new Order("Attack", self, queued) { TargetActor = target.Actor }; else - return new Order( "Attack", self, queued ) { TargetLocation = target.CenterLocation.ToCPos() }; + return new Order("Attack", self, queued) { TargetLocation = target.CenterLocation.ToCPos() }; } return null; } @@ -135,22 +144,26 @@ namespace OpenRA.Mods.RA public Armament ChooseArmamentForTarget(Target t) { return Armaments.FirstOrDefault(a => a.IsValidAgainst(self.World, t)); } - public void AttackTarget( Target target, bool queued, bool allowMove ) + public void AttackTarget(Target target, bool queued, bool allowMove) { - if( !target.IsValid ) return; - if (!queued) self.CancelActivity(); + if (!target.IsValid) + return; + + if (!queued) + self.CancelActivity(); + self.QueueActivity(GetAttackActivity(self, target, allowMove)); } class AttackOrderTargeter : IOrderTargeter { - readonly bool isHeal; + readonly bool negativeDamage; - public AttackOrderTargeter( string order, int priority, bool isHeal ) + public AttackOrderTargeter(string order, int priority, bool negativeDamage) { this.OrderID = order; this.OrderPriority = priority; - this.isHeal = isHeal; + this.negativeDamage = negativeDamage; } public string OrderID { get; private set; } @@ -160,14 +173,20 @@ namespace OpenRA.Mods.RA { IsQueued = forceQueued; - cursor = isHeal ? "heal" : "attack"; - if( self == target ) return false; - if( !self.Trait().HasAnyValidWeapons( Target.FromActor( target ) ) ) return false; - if (forceAttack) return true; + cursor = self.Info.Traits.Get().Cursor; - var targetableRelationship = isHeal ? Stance.Ally : Stance.Enemy; + if (self == target) + return false; - return self.Owner.Stances[ target.Owner ] == targetableRelationship; + if (!self.Trait().HasAnyValidWeapons(Target.FromActor(target))) + return false; + + if (forceAttack) + return true; + + var targetableRelationship = negativeDamage ? Stance.Ally : Stance.Enemy; + + return self.Owner.Stances[target.Owner] == targetableRelationship; } public bool CanTargetLocation(Actor self, CPos location, List actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor) @@ -177,12 +196,16 @@ namespace OpenRA.Mods.RA IsQueued = forceQueued; - cursor = isHeal ? "heal" : "attack"; - if( isHeal ) return false; - if( !self.Trait().HasAnyValidWeapons( Target.FromCell( location ) ) ) return false; + cursor = self.Info.Traits.Get().Cursor; - if( forceAttack ) - if( self.Info.Traits.Get().CanAttackGround ) + if (negativeDamage) + return false; + + if (!self.Trait().HasAnyValidWeapons(Target.FromCell(location))) + return false; + + if (forceAttack) + if (self.Info.Traits.Get().CanAttackGround) return true; return false; diff --git a/mods/d2k/cursors.yaml b/mods/d2k/cursors.yaml index 41f6389331..f3081ee8d1 100644 --- a/mods/d2k/cursors.yaml +++ b/mods/d2k/cursors.yaml @@ -189,16 +189,6 @@ Cursors: length: 8 x: 12 y: 12 - heal: - start:72 - length: 8 - x: 12 - y: 12 - heal-minimap: - start:72 - length: 8 - x: 12 - y: 12 # Cursors that need minimap variants deploy: diff --git a/mods/d2k/rules/infantry.yaml b/mods/d2k/rules/infantry.yaml index 18ab40852c..47f853d217 100644 --- a/mods/d2k/rules/infantry.yaml +++ b/mods/d2k/rules/infantry.yaml @@ -106,6 +106,7 @@ MEDIC: Armament: Weapon: Heal AttackMedic: + Cursor: ability Passenger: PipType: Blue -AutoTarget: diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml index 8ff039a83b..bd14c84ece 100644 --- a/mods/ra/rules/infantry.yaml +++ b/mods/ra/rules/infantry.yaml @@ -327,6 +327,7 @@ MEDI: Armament: Weapon: Heal AttackMedic: + Cursor: heal TakeCover: -AutoTarget: -DebugRetiliateAgainstAggressor: @@ -365,6 +366,7 @@ MECH: Armament: Weapon: Repair AttackMedic: + Cursor: repair TakeCover: -AutoTarget: -DebugRetiliateAgainstAggressor: