Exemplo n.º 1
0
        public override void Execute()
        {
            if (WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }

            // add nearby Units to the loot List
            if (Config.LootUnits)
            {
                IEnumerable <WowUnit> wowUnits = StateMachine.GetNearLootableUnits();

                for (int i = 0; i < wowUnits.Count(); ++i)
                {
                    WowUnit lootableUnit = wowUnits.ElementAt(i);

                    if (!UnitLootQueue.Contains(lootableUnit.Guid))
                    {
                        UnitLootQueue.Enqueue(lootableUnit.Guid);
                    }
                }
            }

            if (UnitLootQueue.Count == 0)
            {
                StateMachine.SetState(BotState.Idle);
            }
            else
            {
                if (UnitsAlreadyLootedList.Contains(UnitLootQueue.Peek()))
                {
                    if (UnitLootQueue.Count > 0)
                    {
                        UnitLootQueue.Dequeue();
                    }

                    return;
                }

                WowUnit selectedUnit = WowInterface.ObjectManager.WowObjects.OfType <WowUnit>()
                                       .OrderBy(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position))
                                       .FirstOrDefault(e => e.Guid == UnitLootQueue.Peek());

                if (selectedUnit != null)
                {
                    WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, selectedUnit.Position);

                    if (LastOpenLootTry.Run())
                    {
                        if (WowInterface.MovementEngine.IsAtTargetPosition)
                        {
                            WowInterface.HookManager.WowStopClickToMove();
                        }

                        WowInterface.HookManager.WowUnitRightClick(selectedUnit);
                        UnitsAlreadyLootedList.Add(UnitLootQueue.Dequeue());

                        if (WowInterface.XMemory.Read(WowInterface.OffsetList.LootWindowOpen, out byte lootOpen) &&
                            lootOpen > 0)
                        {
                            WowInterface.HookManager.LuaLootEveryThing();

                            if (UnitLootQueue.Count > 0)
                            {
                                UnitLootQueue.Dequeue();
                            }
                        }
                    }
                }
                else
                {
                    if (UnitLootQueue.Count > 0)
                    {
                        UnitLootQueue.Dequeue();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void Execute()
        {
            if (WowInterface.ObjectManager.Player.IsCasting)
            {
                return;
            }

            // add nearby Units to the loot List
            if (Config.LootUnits)
            {
                IEnumerable <WowUnit> wowUnits = StateMachine.GetNearLootableUnits();

                for (int i = 0; i < wowUnits.Count(); ++i)
                {
                    WowUnit lootableUnit = wowUnits.ElementAt(i);

                    if (!UnitLootQueue.Contains(lootableUnit.Guid) && !UnitsAlreadyLootedList.Contains(lootableUnit.Guid))
                    {
                        UnitLootQueue.Enqueue(lootableUnit.Guid);
                    }
                }
            }

            if (UnitLootQueue.Count == 0)
            {
                StateMachine.SetState(BotState.Idle);
            }
            else
            {
                WowUnit selectedUnit = WowInterface.ObjectManager.WowObjects.OfType <WowUnit>()
                                       .Where(e => e.IsLootable)
                                       .OrderBy(e => e.Position.GetDistance(WowInterface.ObjectManager.Player.Position))
                                       .FirstOrDefault(e => e.Guid == UnitLootQueue.Peek());

                if (selectedUnit != null && LootTryCount < 3)
                {
                    // If enemies are nearby kill them first
                    // var path = WowInterface.PathfindingHandler.GetPath((int)WowInterface.ObjectManager.MapId,
                    //     WowInterface.ObjectManager.Player.Position, selectedUnit.Position);
                    // if (path != null)
                    // {
                    //     IEnumerable<WowUnit> nearbyEnemies =
                    //         WowInterface.ObjectManager.GetEnemiesInPath<WowUnit>(path, 10.0);
                    //     if (nearbyEnemies.Any())
                    //     {
                    //         var enemy = nearbyEnemies.FirstOrDefault();
                    //         WowInterface.HookManager.WowTargetGuid(enemy.Guid);
                    //         WowInterface.CombatClass.AttackTarget();
                    //         return;
                    //     }
                    // }

                    WowInterface.MovementEngine.SetMovementAction(MovementAction.Move, selectedUnit.Position);

                    if (LastOpenLootTry.Run())
                    {
                        if (WowInterface.ObjectManager.Player.Position.GetDistance(selectedUnit.Position) < MaxLootDistance)
                        {
                            WowInterface.HookManager.WowStopClickToMove();
                            Loot(selectedUnit);
                            ++LootTryCount;
                        }
                    }
                }
                else
                {
                    if (UnitLootQueue.Count > 0)
                    {
                        LootTryCount = 0;
                        UnitLootQueue.Dequeue();
                    }
                }
            }
        }