public override int GetSelectionShares(Actor collector)
        {
            if (collector.GetPrimaryWeapon() == null && collector.GetSecondaryWeapon() == null)
                return 0;

            return base.GetSelectionShares(collector);
        }
Exemple #2
0
        public IActivity Tick(Actor self)
        {
            if (target == null || target.IsDead)
                return NextActivity;

            var limitedAmmo = self.traits.GetOrDefault<LimitedAmmo>();
            if (limitedAmmo != null && !limitedAmmo.HasAmmo())
                return NextActivity;

            var unit = self.traits.Get<Unit>();

            if (unit.Altitude != CruiseAltitude)
            {
                unit.Altitude += Math.Sign(CruiseAltitude - unit.Altitude);
                return this;
            }

            var range = self.GetPrimaryWeapon().Range - 1;
            var dist = target.CenterLocation - self.CenterLocation;

            var desiredFacing = Util.GetFacing(dist, unit.Facing);
            Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get<UnitInfo>().ROT);

            if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
            {
                var rawSpeed = .2f * Util.GetEffectiveSpeed(self);
                self.CenterLocation += (rawSpeed / dist.Length) * dist;
                self.Location = ((1 / 24f) * self.CenterLocation).ToInt2();
            }

            /* todo: maintain seperation wrt other helis */
            return this;
        }
Exemple #3
0
        public AttackBase(Actor self)
        {
            var primaryWeapon = self.GetPrimaryWeapon();
            var secondaryWeapon = self.GetSecondaryWeapon();

            primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1;
            secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1;
        }
Exemple #4
0
        public override int FireDelay( Actor self, AttackBaseInfo info )
        {
            primaryFireDelay = 8;
            timeToRecharge = self.GetPrimaryWeapon().ROF;
            --charges;

            if( target != sameTarget )
            {
                sameTarget = target;
                self.traits.Get<RenderBuildingCharge>().PlayCharge( self );
                return base.FireDelay( self, info );
            }
            else
                return 3;
        }
Exemple #5
0
        public void Detonate(Actor self, Actor detonatedBy)
        {
            var unit = self.traits.GetOrDefault<Unit>();
            var info = self.Info.Traits.Get<AttackBaseInfo>();
            var altitude = unit != null ? unit.Altitude : 0;
            int2 detonateLocation = self.CenterLocation.ToInt2();

            self.World.AddFrameEndTask( w =>
            {
                Combat.DoExplosion(self, info.PrimaryWeapon, detonateLocation, altitude);
                var report = self.GetPrimaryWeapon().Report;
                if (report != null)
                    Sound.Play(report + ".aud");

                // Remove from world
                self.Health = 0;
                detonatedBy.Owner.Kills++;
                w.Remove(self);
            } );
        }
Exemple #6
0
 public static float GetMaximumRange(Actor self)
 {
     return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
         .Where(w => w != null).Max(w => w.Range);
 }
Exemple #7
0
        protected virtual void QueueAttack(Actor self, Order order)
        {
            /* todo: choose the appropriate weapon, when only one works against this target */
            var weapon = self.GetPrimaryWeapon() ?? self.GetSecondaryWeapon();

            self.QueueActivity(new Activities.Attack(order.TargetActor,
                    Math.Max(0, (int)weapon.Range)));
        }
Exemple #8
0
        public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
        {
            if (mi.Button == MouseButton.Left || underCursor == null || underCursor.Owner == null) return null;
            if (self == underCursor) return null;

            var isHeal = self.GetPrimaryWeapon().Warheads.First().Damage < 0;
            var forceFire = mi.Modifiers.HasModifier(Modifiers.Ctrl);

            if (isHeal)
            {
                if (underCursor.Owner == null)
                    return null;
                if (self.Owner.Stances[ underCursor.Owner ] != Stance.Ally && !forceFire)
                    return null;
                if (underCursor.Health >= underCursor.GetMaxHP())
                    return null;	// don't allow healing of fully-healed stuff!
            }
            else
                if ((self.Owner.Stances[ underCursor.Owner ] != Stance.Enemy) && !forceFire)
                    return null;

            if (!Combat.HasAnyValidWeapons(self, underCursor)) return null;

            return new Order(isHeal ? "Heal" : "Attack", self, underCursor);
        }