예제 #1
0
        public override void Execute()
        {
            if (UnitLootList.Count == 0)
            {
                AmeisenBotStateMachine.SetState(AmeisenBotState.Idle);
            }
            else
            {
                if (UnitsAlreadyLootedList.Contains(UnitLootList.Peek()))
                {
                    UnitLootList.Dequeue();
                    return;
                }

                WowUnit selectedUnit = ObjectManager.WowObjects.OfType <WowUnit>().FirstOrDefault(e => e.Guid == UnitLootList.Peek());
                if (selectedUnit != null && selectedUnit.IsDead && selectedUnit.IsLootable)
                {
                    if (ObjectManager.Player.Position.GetDistance(selectedUnit.Position) > 3.0)
                    {
                        MovementEngine.SetState(MovementEngineState.Moving, selectedUnit.Position);
                        MovementEngine.Execute();
                    }
                    else
                    {
                        do
                        {
                            HookManager.RightClickUnit(selectedUnit);
                            LootTryCount++;
                            Task.Delay(500).GetAwaiter().GetResult();
                        } while (AmeisenBotStateMachine.XMemory.ReadByte(OffsetList.LootWindowOpen, out byte lootOpen) &&
                                 lootOpen == 0 &&
                                 LootTryCount < 2);

                        UnitsAlreadyLootedList.Add(UnitLootList.Dequeue());
                    }
                }
                else
                {
                    UnitLootList.Dequeue();
                }
            }
        }
예제 #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))
                    {
                        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();
                    }
                }
            }
        }
예제 #3
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();
                    }
                }
            }
        }
예제 #4
0
        public override void Execute()
        {
            // add nearby Units to the loot List
            if (Config.LootUnits)
            {
                foreach (WowUnit lootableUnit in StateMachine.GetNearLootableUnits())
                {
                    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 && selectedUnit.IsDead && selectedUnit.IsLootable)
                {
                    if (WowInterface.ObjectManager.Player.Position.GetDistance(selectedUnit.Position) > 3.0)
                    {
                        WowInterface.MovementEngine.SetState(MovementEngineState.Moving, selectedUnit.Position);
                        WowInterface.MovementEngine.Execute();
                    }
                    else if (DateTime.Now - LastOpenLootTry > TimeSpan.FromSeconds(1))
                    {
                        WowInterface.HookManager.StopClickToMoveIfActive(WowInterface.ObjectManager.Player);

                        WowInterface.HookManager.UnitOnRightClick(selectedUnit);
                        if (WowInterface.XMemory.Read(WowInterface.OffsetList.LootWindowOpen, out byte lootOpen) &&
                            lootOpen > 0)
                        {
                            WowInterface.HookManager.LootEveryThing();
                            UnitsAlreadyLootedList.Add(UnitLootQueue.Dequeue());

                            if (UnitLootQueue.Count > 0)
                            {
                                UnitLootQueue.Dequeue();
                            }
                        }

                        LastOpenLootTry = DateTime.Now;
                    }
                }
                else
                {
                    if (UnitLootQueue.Count > 0)
                    {
                        UnitLootQueue.Dequeue();
                    }
                }
            }
        }