/// <summary> /// Stops the bots mechanisms, hooks, ... /// </summary> public void StopBot() { // Disconnect from Server AmeisenClient.Unregister( Me, IPAddress.Parse(AmeisenSettings.Settings.ameisenServerIP), AmeisenSettings.Settings.ameisenServerPort); // Save WoW's window positions SafeNativeMethods.Rect wowRect = AmeisenCore.GetWowDiemsions(WowExe.process.MainWindowHandle); AmeisenSettings.Settings.wowRectT = wowRect.Top; AmeisenSettings.Settings.wowRectB = wowRect.Bottom; AmeisenSettings.Settings.wowRectL = wowRect.Left; AmeisenSettings.Settings.wowRectR = wowRect.Right; // Stop object updates AmeisenObjectManager.Stop(); // Stop the statemachine AmeisenStateMachineManager.Stop(); // Unhook Events AmeisenEventHook?.Stop(); // Unhook the EndScene AmeisenHook.DisposeHooking(); // Detach BlackMagic, causing weird crash right now... //Blackmagic.Close(); // Stop logging AmeisenLogger.Instance.StopLogging(); }
/// <summary> /// Starts the bots mechanisms, hooks, ... /// </summary> /// <param name="wowExe">WowExe to start the bot on</param> public void StartBot(WowExe wowExe) { WowExe = wowExe; // Load Settings AmeisenSettings.LoadFromFile(wowExe.characterName); // Load old WoW Position if (AmeisenSettings.Settings.saveBotWindowPosition) { if (AmeisenSettings.Settings.wowRectL != 0 && AmeisenSettings.Settings.wowRectR != 0 && AmeisenSettings.Settings.wowRectT != 0 && AmeisenSettings.Settings.wowRectB != 0) { AmeisenCore.SetWindowPosition( wowExe.process.MainWindowHandle, (int)AmeisenSettings.Settings.wowRectL, (int)AmeisenSettings.Settings.wowRectT, (int)AmeisenSettings.Settings.wowRectB - (int)AmeisenSettings.Settings.wowRectT, (int)AmeisenSettings.Settings.wowRectR - (int)AmeisenSettings.Settings.wowRectL); } } // Connect to DB if (AmeisenSettings.Settings.databaseAutoConnect) { AmeisenDBManager.ConnectToMySQL( string.Format(sqlConnectionString, AmeisenSettings.Settings.databaseIP, AmeisenSettings.Settings.databasePort, AmeisenSettings.Settings.databaseName, AmeisenSettings.Settings.databaseUsername, AmeisenSettings.Settings.databasePasswort) ); } // Attach to Proccess Blackmagic = new BlackMagic(wowExe.process.Id); IsBlackmagicAttached = Blackmagic.IsProcessOpen; // TODO: make this non static AmeisenCore.BlackMagic = Blackmagic; // Hook EndScene AmeisenHook = new AmeisenHook(Blackmagic); IsEndsceneHooked = AmeisenHook.isHooked; // TODO: make this non static AmeisenCore.AmeisenHook = AmeisenHook; // Hook Events /*AmeisenEventHook = new AmeisenEventHook(); * AmeisenEventHook.Init(); * AmeisenEventHook.Subscribe("UI_ERROR_MESSAGE");*/ // Start our object updates AmeisenObjectManager = new AmeisenObjectManager(AmeisenDataHolder, AmeisenDBManager); AmeisenObjectManager.Start(); // Load the combatclass IAmeisenCombatClass combatClass = CompileAndLoadCombatClass(AmeisenSettings.Settings.combatClassPath); // Init our MovementEngine to hposition ourself according to our formation AmeisenMovementEngine = new AmeisenMovementEngine(new DefaultFormation()) { MemberCount = 40 }; // Start the StateMachine AmeisenStateMachineManager = new AmeisenStateMachineManager( AmeisenDataHolder, AmeisenDBManager, AmeisenMovementEngine, combatClass); // Deafult Idle state AmeisenStateMachineManager.StateMachine.PushAction(BotState.Idle); AmeisenStateMachineManager.Start(); // Connect to Server if (Settings.serverAutoConnect) { AmeisenClient.Register( Me, IPAddress.Parse(AmeisenSettings.Settings.ameisenServerIP), AmeisenSettings.Settings.ameisenServerPort); } }
/// <summary> /// Starts the bots mechanisms, hooks, ... /// </summary> /// <param name="wowExe">WowExe to start the bot on</param> public void StartBot(WowExe wowExe) { AmeisenLogger.Instance.currentUsername = wowExe.characterName; AmeisenLogger.Instance.RefreshLogName(); WowExe = wowExe; LootableUnits = new Queue <Unit>(); // Load Settings AmeisenSettings.LoadFromFile(wowExe.characterName); // Load old WoW Position if (AmeisenSettings.Settings.saveBotWindowPosition) { if (AmeisenSettings.Settings.wowRectL > 0 && AmeisenSettings.Settings.wowRectR > 0 && AmeisenSettings.Settings.wowRectT > 0 && AmeisenSettings.Settings.wowRectB > 0) { AmeisenCore.SetWindowPosition( wowExe.process.MainWindowHandle, (int)AmeisenSettings.Settings.wowRectL, (int)AmeisenSettings.Settings.wowRectT, (int)AmeisenSettings.Settings.wowRectB - (int)AmeisenSettings.Settings.wowRectT, (int)AmeisenSettings.Settings.wowRectR - (int)AmeisenSettings.Settings.wowRectL); } } // Connect to DB if (AmeisenSettings.Settings.databaseAutoConnect) { ConnectToDB(); } // Connect to NavmeshServer if (AmeisenSettings.Settings.navigationServerAutoConnect) { AmeisenNavmeshClient = new AmeisenNavmeshClient( AmeisenSettings.Settings.navigationServerIp, AmeisenSettings.Settings.navigationServerPort ); } // Attach to Proccess Blackmagic = new BlackMagic(wowExe.process.Id); IsBlackmagicAttached = Blackmagic.IsProcessOpen; // TODO: make this non static AmeisenCore.BlackMagic = Blackmagic; // Hook EndScene AmeisenHook = new AmeisenHook(Blackmagic); IsEndsceneHooked = AmeisenHook.isHooked; // TODO: make this non static AmeisenCore.AmeisenHook = AmeisenHook; // Unlimit fps to speed up loading, we will limit them later again AmeisenCore.RunSlashCommand($"/console maxfps 30"); AmeisenCore.RunSlashCommand($"/console maxfpsbk 30"); // Init our CharacterMangager to keep track of our stats/items/money AmeisenCharacterManager = new AmeisenCharacterManager(); AmeisenCharacterManager.UpdateCharacterAsync(); // Hook Events AmeisenEventHook = new AmeisenEventHook(); AmeisenEventHook.Init(); AmeisenEventHook.Subscribe(WowEvents.PLAYER_ENTERING_WORLD, OnPlayerEnteringWorld); AmeisenEventHook.Subscribe(WowEvents.LOOT_OPENED, OnLootWindowOpened); AmeisenEventHook.Subscribe(WowEvents.LOOT_BIND_CONFIRM, OnLootBindOnPickup); AmeisenEventHook.Subscribe(WowEvents.READY_CHECK, OnReadyCheck); AmeisenEventHook.Subscribe(WowEvents.PARTY_INVITE_REQUEST, OnPartyInvitation); AmeisenEventHook.Subscribe(WowEvents.CONFIRM_SUMMON, OnSummonRequest); AmeisenEventHook.Subscribe(WowEvents.RESURRECT_REQUEST, OnResurrectRequest); AmeisenEventHook.Subscribe(WowEvents.PLAYER_REGEN_DISABLED, OnRegenDisabled); AmeisenEventHook.Subscribe(WowEvents.PLAYER_REGEN_ENABLED, OnRegenEnabled); AmeisenEventHook.Subscribe(WowEvents.START_LOOT_ROLL, OnStartLootRoll); AmeisenEventHook.Subscribe(WowEvents.ITEM_PUSH, OnNewItem); AmeisenEventHook.Subscribe(WowEvents.PARTY_MEMBERS_CHANGED, OnGroupChanged); //AmeisenEventHook.Subscribe(WowEvents.COMBAT_LOG_EVENT_UNFILTERED, OnCombatLogEvent); // LoadingscreenChecker, stops our hook if we are in loadingscreens IsLoadingScreenCheckerActive = true; LoadingScreenCheckerThread = new Thread(new ThreadStart(LoadingScreenChecker)); LoadingScreenCheckerThread.Start(); // Start our object updates AmeisenObjectManager = new AmeisenObjectManager(AmeisenDataHolder, AmeisenDBManager); AmeisenObjectManager.Start(); // Load the combatclass // CombatClass = CompileAndLoadCombatClass(AmeisenSettings.Settings.combatClassPath); if (CombatPackage == null) { CombatPackage = LoadDefaultClassForSpec(); } // Init our MovementEngine to position ourself according to our formation AmeisenMovementEngine = new AmeisenMovementEngine(new DefaultFormation()) { MemberCount = 40 }; // Start the StateMachine AmeisenStateMachineManager = new AmeisenStateMachineManager( AmeisenDataHolder, AmeisenDBManager, AmeisenMovementEngine, CombatPackage, AmeisenCharacterManager, AmeisenNavmeshClient); // Deafult Idle state AmeisenStateMachineManager.StateMachine.PushAction(BotState.Idle); AmeisenStateMachineManager.Start(); // Connect to Server if (Settings.serverAutoConnect) { ConnectToServer(); } // Ultralow Gfx if (Settings.autoUltralowGfx) { AmeisenCore.RunSlashCommand("/console farclip 350"); AmeisenCore.RunSlashCommand("/console groundEffectDensity 0"); AmeisenCore.RunSlashCommand("/console groundEffectDistance 0"); AmeisenCore.RunSlashCommand("/console environmentDetail 0"); AmeisenCore.RunSlashCommand("/console particleDensity 10"); AmeisenCore.RunSlashCommand("/console shadowMode 0"); AmeisenCore.RunSlashCommand("/console waterDetail 0"); AmeisenCore.RunSlashCommand("/console reflectionMode 0"); AmeisenCore.RunSlashCommand("/console sunShafts 0"); AmeisenCore.RunSlashCommand("/console basemip 1"); AmeisenCore.RunSlashCommand("/console terrainMipLevel 1"); AmeisenCore.RunSlashCommand("/console projectedTextures 0"); AmeisenCore.RunSlashCommand("/console weatherDensity 0"); AmeisenCore.RunSlashCommand("/console componentTextureLevel 0"); AmeisenCore.RunSlashCommand("/console textureFilteringMode 0"); } // Limit fps AmeisenCore.RunSlashCommand($"/console maxfps {Settings.maxFpsForeground}"); AmeisenCore.RunSlashCommand($"/console maxfpsbk {Settings.maxFpsBackground}"); }