Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using OpenRA.Traits;
- namespace OpenRA.Mods.RA
- {
- public class UnitStanceReturnFireInfo : ITraitInfo
- {
- public readonly bool Default = false;
- public object Create(ActorInitializer init) { return new UnitStanceReturnFire(init.self, this); }
- }
- public class UnitStanceReturnFire : UnitStance, INotifyDamage
- {
- public readonly UnitStanceReturnFireInfo Info;
- public UnitStanceReturnFire(Actor self, UnitStanceReturnFireInfo info)
- {
- Info = info;
- Active = Info.Default;
- }
- public virtual void Damaged(Actor self, AttackInfo e)
- {
- if (!Active) return;
- if (!self.IsIdle) return;
- if (e.Attacker.Destroyed) return;
- var attack = self.TraitOrDefault<AttackBase>();
- // this unit cannot fight back at all (no guns)
- if (attack == null) return;
- // don't fight back if we dont have the guns to do so
- if (!attack.HasAnyValidWeapons(Target.FromActor(e.Attacker))) return;
- // don't retaliate against allies
- if (self.Owner.Stances[e.Attacker.Owner] == Stance.Ally) return;
- // don't retaliate against healers
- if (e.Damage < 0) return;
- // perform the attack, the 'true' makes sure it sends out the Attack order
- self.Trait<AttackBase>().AttackTarget(self, e.Attacker, true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement