Example #1
0
        public void Stop()
        {
            StateMachineTimer.Stop();

            HookManager.DisposeHook();
            EventHookManager.Stop();

            if (ObjectManager.Player?.Name.Length > 0)
            {
                if (Config.SaveWowWindowPosition)
                {
                    SaveWowWindowPosition();
                }

                if (Config.SaveBotWindowPosition)
                {
                    SaveBotWindowPosition();
                }
            }

            BotCache.Save();

            if (Config.AutocloseWow)
            {
                XMemory.Process.Kill();
            }

            AmeisenLogger.Instance.Log($"Stopping AmeisenBot...", LogLevel.Master);
            AmeisenLogger.Instance.Stop();
        }
Example #2
0
 private void HandleEventPull()
 {
     if (EventHookManager.IsSetUp &&
         LastEventPull + TimeSpan.FromSeconds(1) < DateTime.Now)
     {
         EventHookManager.ReadEvents();
         LastEventPull = DateTime.Now;
     }
 }
Example #3
0
        public AmeisenBotStateMachine(
            string botDataPath,
            Process wowProcess,
            AmeisenBotConfig config,
            XMemory xMemory,
            IOffsetList offsetList,
            ObjectManager objectManager,
            CharacterManager characterManager,
            HookManager hookManager,
            EventHookManager eventHookManager,
            IAmeisenBotCache botCache,
            IPathfindingHandler pathfindingHandler,
            IMovementEngine movementEngine,
            ICombatClass combatClass)
        {
            AmeisenLogger.Instance.Log("Starting AmeisenBotStateMachine...", LogLevel.Verbose);

            BotDataPath      = botDataPath;
            Config           = config;
            XMemory          = xMemory;
            OffsetList       = offsetList;
            ObjectManager    = objectManager;
            CharacterManager = characterManager;
            HookManager      = hookManager;
            EventHookManager = eventHookManager;
            BotCache         = botCache;

            LastObjectUpdate = DateTime.Now;
            LastGhostCheck   = DateTime.Now;
            LastEventPull    = DateTime.Now;

            LastState    = AmeisenBotState.None;
            UnitLootList = new Queue <ulong>();

            States = new Dictionary <AmeisenBotState, State>()
            {
                { AmeisenBotState.None, new StateNone(this, config) },
                { AmeisenBotState.StartWow, new StateStartWow(this, config, wowProcess, xMemory) },
                { AmeisenBotState.Login, new StateLogin(this, config, offsetList, characterManager) },
                { AmeisenBotState.LoadingScreen, new StateLoadingScreen(this, xMemory, config, objectManager) },
                { AmeisenBotState.Idle, new StateIdle(this, config, offsetList, objectManager, characterManager, hookManager, eventHookManager, combatClass, UnitLootList) },
                { AmeisenBotState.Dead, new StateDead(this, config, objectManager, hookManager) },
                { AmeisenBotState.Ghost, new StateGhost(this, config, offsetList, objectManager, characterManager, hookManager, pathfindingHandler, movementEngine) },
                { AmeisenBotState.Following, new StateFollowing(this, config, objectManager, characterManager, pathfindingHandler, movementEngine) },
                { AmeisenBotState.Attacking, new StateAttacking(this, config, objectManager, characterManager, hookManager, pathfindingHandler, movementEngine, combatClass) },
                { AmeisenBotState.Repairing, new StateRepairing(this, config, objectManager, hookManager, characterManager, pathfindingHandler, movementEngine) },
                { AmeisenBotState.Selling, new StateSelling(this, config, objectManager, hookManager, characterManager, pathfindingHandler, movementEngine) },
                { AmeisenBotState.Healing, new StateEating(this, config, objectManager, characterManager) },
                { AmeisenBotState.InsideAoeDamage, new StateInsideAoeDamage(this, config, objectManager, characterManager, pathfindingHandler, movementEngine) },
                { AmeisenBotState.Looting, new StateLooting(this, config, offsetList, objectManager, characterManager, hookManager, pathfindingHandler, movementEngine, UnitLootList) }
            };

            CurrentState = States.First();
            CurrentState.Value.Enter();
        }
Example #4
0
 public StateIdle(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, IOffsetList offsetList, ObjectManager objectManager, CharacterManager characterManager, HookManager hookManager, EventHookManager eventHookManager, ICombatClass combatClass, Queue <ulong> unitLootList) : base(stateMachine)
 {
     Config           = config;
     OffsetList       = offsetList;
     ObjectManager    = objectManager;
     HookManager      = hookManager;
     EventHookManager = eventHookManager;
     CharacterManager = characterManager;
     CombatClass      = combatClass;
     UnitLootList     = unitLootList;
 }
Example #5
0
        private void SubscribeToWowEvents()
        {
            EventHookManager.Subscribe("PARTY_INVITE_REQUEST", OnPartyInvitation);
            EventHookManager.Subscribe("RESURRECT_REQUEST", OnResurrectRequest);
            EventHookManager.Subscribe("CONFIRM_SUMMON", OnSummonRequest);
            EventHookManager.Subscribe("READY_CHECK", OnReadyCheck);
            EventHookManager.Subscribe("LOOT_OPENED", OnLootWindowOpened);
            EventHookManager.Subscribe("LOOT_BIND_CONFIRM", OnConfirmBindOnPickup);
            EventHookManager.Subscribe("CONFIRM_LOOT_ROLL", OnConfirmBindOnPickup);
            EventHookManager.Subscribe("START_LOOT_ROLL", OnLootRollStarted);
            EventHookManager.Subscribe("BAG_UPDATE", OnBagChanged);
            EventHookManager.Subscribe("PLAYER_EQUIPMENT_CHANGED", OnEquipmentChanged);

            //// EventHookManager.Subscribe("DELETE_ITEM_CONFIRM", OnConfirmDeleteItem);
            //// EventHookManager.Subscribe("COMBAT_LOG_EVENT_UNFILTERED", OnCombatLog);
        }
Example #6
0
        public override void Enter()
        {
            // first start
            if (!HookManager.IsWoWHooked)
            {
                AmeisenBotStateMachine.XMemory.ReadString(OffsetList.PlayerName, Encoding.ASCII, out string playerName);
                AmeisenBotStateMachine.PlayerName = playerName;

                HookManager.SetupEndsceneHook();
                HookManager.SetMaxFps((byte)Config.MaxFps);

                EventHookManager.Start();

                CharacterManager.UpdateAll();
            }
        }
Example #7
0
        public AmeisenBot(string botDataPath, string accountName, AmeisenBotConfig config)
        {
            SetupLogging(botDataPath, accountName);
            AmeisenLogger.Instance.Log("AmeisenBot starting...", LogLevel.Master);

            string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();

            AmeisenLogger.Instance.Log($"version: {version}", LogLevel.Master);

            Config = config;

            AccountName = accountName;
            AmeisenLogger.Instance.Log($"AccountName: {botDataPath}", LogLevel.Master);

            BotDataPath = botDataPath;
            AmeisenLogger.Instance.Log($"BotDataPath: {botDataPath}", LogLevel.Verbose);

            CurrentExecutionMs    = 0;
            CurrentExecutionCount = 0;
            stateMachineTimerBusy = 0;

            StateMachineTimer          = new Timer(config.StateMachineTickMs);
            StateMachineTimer.Elapsed += StateMachineTimerTick;

            OffsetList = new OffsetList335a();
            AmeisenLogger.Instance.Log($"Using OffsetList: {OffsetList.GetType().ToString()}", LogLevel.Master);

            XMemory            = new XMemory();
            BotCache           = new InMemoryBotCache(Path.Combine(BotDataPath, accountName, "cache.bin"));
            ObjectManager      = new ObjectManager(XMemory, OffsetList, BotCache);
            HookManager        = new HookManager(XMemory, OffsetList, ObjectManager, BotCache);
            CharacterManager   = new CharacterManager(XMemory, config, OffsetList, ObjectManager, HookManager);
            EventHookManager   = new EventHookManager(HookManager);
            PathfindingHandler = new NavmeshServerClient(Config.NavmeshServerIp, Config.NameshServerPort);
            MovementSettings   = new MovementSettings();
            MovemenEngine      = new SmartMovementEngine(
                () => ObjectManager.Player.Position,
                () => ObjectManager.Player.Rotation,
                CharacterManager.MoveToPosition,
                (Vector3 start, Vector3 end) => PathfindingHandler.GetPath(ObjectManager.MapId, start, end),
                CharacterManager.Jump,
                ObjectManager,
                MovementSettings);

            if (!Directory.Exists(BotDataPath))
            {
                Directory.CreateDirectory(BotDataPath);
                AmeisenLogger.Instance.Log($"Creating folder {botDataPath}", LogLevel.Verbose);
            }

            if (config.UseBuiltInCombatClass)
            {
                LoadDefaultCombatClass();
            }
            else
            {
                LoadCustomCombatClass();
            }

            if (CombatClass?.ItemComparator != null)
            {
                CharacterManager.ItemComparator = CombatClass.ItemComparator;
            }

            StateMachine = new AmeisenBotStateMachine(BotDataPath, WowProcess, Config, XMemory, OffsetList, ObjectManager, CharacterManager, HookManager, EventHookManager, BotCache, PathfindingHandler, MovemenEngine, CombatClass);
            StateMachine.OnStateMachineStateChanged += HandlePositionLoad;
        }