Exemplo n.º 1
0
            public override Activity Tick(Actor self)
            {
                if (IsCanceled || !target.IsValidFor(self))
                {
                    return(NextActivity);
                }

                if (self.IsDisabled())
                {
                    return(this);
                }

                var weapon = attack.ChooseArmamentForTarget(target);

                if (weapon != null)
                {
                    var targetIsMobile = (target.Type == TargetType.Actor && target.Actor.HasTrait <IMove>()) ||
                                         (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.Traits.Contains <IMove>());

                    // Try and sit at least one cell closer than the max range to give some leeway if the target starts moving.
                    var maxRange = targetIsMobile ? new WRange(Math.Max(weapon.Weapon.MinRange.Range, weapon.Weapon.Range.Range - 1024))
                                                : weapon.Weapon.Range;

                    attack.Target = target;

                    if (move != null)
                    {
                        return(Util.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this));
                    }
                }

                return(NextActivity);
            }
Exemplo n.º 2
0
            public override Activity Tick(Actor self)
            {
                if (IsCanceled || !target.IsValidFor(self))
                {
                    return(NextActivity);
                }

                if (self.IsDisabled())
                {
                    return(this);
                }

                var weapon = attack.ChooseArmamentsForTarget(target, forceAttack).FirstOrDefault();

                if (weapon != null)
                {
                    var targetIsMobile = (target.Type == TargetType.Actor && target.Actor.Info.HasTraitInfo <IMoveInfo>()) ||
                                         (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.HasTraitInfo <IMoveInfo>());

                    // Try and sit at least one cell closer than the max range to give some leeway if the target starts moving.
                    var modifiedRange = weapon.MaxRange();
                    var maxRange      = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Length, modifiedRange.Length - 1024))
                                                : modifiedRange;

                    attack.Target = target;

                    if (move != null)
                    {
                        return(Util.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this));
                    }
                }

                return(NextActivity);
            }
Exemplo n.º 3
0
            public override Activity Tick(Actor self)
            {
                if (IsCanceled || !target.IsValidFor(self))
                {
                    return(NextActivity);
                }

                if (self.IsDisabled())
                {
                    return(this);
                }

                const int RangeTolerance = 1;                   /* how far inside our maximum range we should try to sit */
                var       weapon         = attack.ChooseArmamentForTarget(target);

                if (weapon != null)
                {
                    var range = WRange.FromCells(Math.Max(0, weapon.Weapon.Range.Range / 1024 - RangeTolerance));

                    attack.Target = target;

                    if (move != null)
                    {
                        return(Util.SequenceActivities(move.MoveFollow(self, target, range), this));
                    }
                }

                return(NextActivity);
            }
Exemplo n.º 4
0
        public void GuardTarget(Actor self, Target target)
        {
            self.SetTargetLine(target, Color.Yellow);

            var range = target.Actor.Info.TraitInfo <GuardableInfo>().Range;

            self.QueueActivity(false, new AttackMoveActivity(self, move.MoveFollow(self, target, WDist.Zero, range)));
        }
Exemplo n.º 5
0
            public override Activity Tick(Actor self)
            {
                if (IsCanceled || !target.IsValidFor(self))
                {
                    return(NextActivity);
                }

                if (self.IsDisabled())
                {
                    return(this);
                }

                var weapon = attack.ChooseArmamentsForTarget(target, forceAttack).FirstOrDefault();

                if (weapon != null)
                {
                    var targetIsMobile = (target.Type == TargetType.Actor && target.Actor.Info.HasTraitInfo <IMoveInfo>()) ||
                                         (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.HasTraitInfo <IMoveInfo>());

                    // Try and sit at least one cell closer than the max range to give some leeway if the target starts moving.
                    var modifiedRange = weapon.MaxRange();
                    var maxRange      = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Length, modifiedRange.Length - 1024))
                                                : modifiedRange;

                    // Check that AttackFollow hasn't cancelled the target by modifying attack.Target
                    // Having both this and AttackFollow modify that field is a horrible hack.
                    if (hasTicked && attack.Target.Type == TargetType.Invalid)
                    {
                        return(NextActivity);
                    }

                    attack.Target = target;
                    hasTicked     = true;

                    if (move != null)
                    {
                        return(ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this));
                    }
                    if (!onRailsHack &&
                        target.IsInRange(self.CenterPosition, weapon.MaxRange()) &&
                        !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
                    {
                        return(this);
                    }
                }

                if (!onRailsHack)
                {
                    attack.Target = Target.Invalid;
                }

                return(NextActivity);
            }
Exemplo n.º 6
0
        public void GuardTarget(Actor self, Target target, bool queued = false)
        {
            if (target.Type != TargetType.Actor)
            {
                return;
            }

            var range = target.Actor.Info.TraitInfo <GuardableInfo>().Range;

            self.QueueActivity(queued, new AttackMoveActivity(self, () => move.MoveFollow(self, target, WDist.Zero, range, targetLineColor: info.TargetLineColor)));
            self.ShowTargetLines();
        }
Exemplo n.º 7
0
            public override Activity Tick(Actor self)
            {
                if (IsCanceled || !target.IsValidFor(self))
                {
                    return(NextActivity);
                }

                if (attack.IsTraitPaused)
                {
                    return(this);
                }

                var weapon = attack.ChooseArmamentsForTarget(target, forceAttack).FirstEnabledTraitOrDefault();

                if (weapon != null)
                {
                    var targetIsMobile = (target.Type == TargetT.Actor && target.Actor.Info.HasTraitInfo <IMoveInfo>()) ||
                                         (target.Type == TargetT.FrozenActor && target.FrozenActor.Info.HasTraitInfo <IMoveInfo>());

                    var modifiedRange = weapon.MaxRange();
                    var maxRange      = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Length, modifiedRange.Length - 1024)) : modifiedRange;

                    if (hasTicked && attack.Target.Type == TargetT.Invalid)
                    {
                        return(NextActivity);
                    }

                    attack.Target = target;
                    hasTicked     = true;

                    if (move != null)
                    {
                        return(ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this));
                    }

                    if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) && !target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
                    {
                        return(this);
                    }
                }

                attack.Target = Target.Invalid;

                return(NextActivity);
            }
Exemplo n.º 8
0
        public void GuardTarget(Actor self, Target target, bool queued = false)
        {
            if (!queued)
            {
                self.CancelActivity();
            }

            if (target.Type != TargetType.Actor)
            {
                return;
            }

            self.SetTargetLine(target, Color.Yellow);

            var range = target.Actor.Info.TraitInfo <GuardableInfo>().Range;

            self.QueueActivity(new AttackMoveActivity(self, move.MoveFollow(self, target, WDist.Zero, range)));
        }