private async Task <bool> MainCoroutine()
        {
            if (IsDone)
            {
                return(false);
            }

            if (!Query.IsInVehicle())
            {
                return(await UtilityCoroutine.MountVehicle((int)KovokId, _kovokLoc));
            }

            var ct        = Me.CurrentTarget;
            var transport = (WoWUnit)Me.Transport;

            if (transport == null)
            {
                return(false);
            }

            if (ct == null)
            {
                var newTarget = GetNearestAttacker() ?? GetNearestTarget();
                if (newTarget != null)
                {
                    newTarget.Target();
                    _targetTimer.Reset();
                    return(true);
                }
                // move to waypoints searching for targets.
                if (transport.Location.DistanceSqr(_path.Peek()) < 15 * 15)
                {
                    _path.Dequeue();
                }
                return((await CommonCoroutines.MoveTo(_path.Peek())).IsSuccessful());
            }

            if (ct.IsDead)
            {
                Me.ClearTarget();
                return(true);
            }

            // blacklist target if it's taking too long to kill.
            if (_targetTimer.IsFinished)
            {
                Blacklist.Add(ct, BlacklistFlags.Combat, TimeSpan.FromMinutes(3));
                Me.ClearTarget();
            }


            if (transport.Location.DistanceSqr(ct.Location) > 35 * 35)
            {
                return((await CommonCoroutines.MoveTo(ct.Location)).IsSuccessful());
            }

            if (!transport.IsSafelyFacing(ct, 40))
            {
                ct.Face();
                return(true);
            }

            if (transport.IsMoving)
            {
                //WoWMovement.MoveStop();
                // WoWMovement.MoveStop doesn't seem to work...
                WoWMovement.ClickToMove(transport.Location);
                return(true);
            }

            var actionButton = ActionBar.Active.Buttons.FirstOrDefault(b => b.Index != 2 && b.CanUse);

            if (actionButton != null)
            {
                actionButton.Use();
                await Coroutine.Sleep(Delay.AfterWeaponFire);

                return(true);
            }

            return(false);
        }
예제 #2
0
        private async Task <bool> MainCoroutine()
        {
            if (IsDone)
            {
                return(false);
            }

            // move to cannon.
            if (!Query.IsInVehicle())
            {
                if (VehicleId == 0)
                {
                    BehaviorDone("Not in a vehicle and no VehicleId is specified");
                    return(false);
                }

                // enable combat while not in a vehicle
                if ((LevelBot.BehaviorFlags & BehaviorFlags.Combat) == 0)
                {
                    LevelBot.BehaviorFlags |= BehaviorFlags.Combat;
                }

                return(await UtilityCoroutine.MountVehicle(
                           VehicleSearchLocation,
                           MovementBy,
                           u => !Query.IsInCompetition(u, NonCompeteDistance),
                           VehicleId));
            }

            // Disable combat while in a vehicle
            if ((LevelBot.BehaviorFlags & BehaviorFlags.Combat) != 0)
            {
                LevelBot.BehaviorFlags &= ~BehaviorFlags.Combat;
            }

            while (!IsDone && Query.IsInVehicle())
            {
                // find the first weapon that is ready.
                var weapon = Weapons.FirstOrDefault(w => w.IsWeaponReady());
                if (weapon != null)
                {
                    //_target = StyxWoW.Me.CurrentTarget;
                    if (!Query.IsViable(_target) || _target.IsDead ||
                        !weapon.WeaponAim(_target))
                    {
                        // acquire a target that is within shooting range
                        _target = Npcs.FirstOrDefault(n => weapon.WeaponAim(n));
                        await Coroutine.Sleep((int)Delay.BeforeButtonClick.TotalMilliseconds);

                        return(true);
                    }
                    // fire away.
                    if (Query.IsViable(_target) && weapon.WeaponAim(_target) && weapon.WeaponFire())
                    {
                        await Coroutine.Sleep((int)Delay.AfterWeaponFire.TotalMilliseconds);
                    }
                }
                await Coroutine.Yield();
            }
            return(false);
        }