public void AmeisenBotStateMachineCombatEngineTest() { TestWowDataAdapter wowDataAdapter = new TestWowDataAdapter(); AmeisenBotStateMachine stateMachine = new AmeisenBotStateMachine( wowDataAdapter, new TestWowActionExecutor(), null, new BasicMeleeMovementProvider(), new TestSpellStrategy() ); Assert.IsTrue(stateMachine.CurrentState is BotStateIdle); wowDataAdapter.SetMeInCombat(true); stateMachine.CurrentState.Execute(); Assert.IsTrue(stateMachine.CurrentState is BotStateCombat); stateMachine.CurrentState.Execute(); stateMachine.CurrentState.Execute(); stateMachine.CurrentState.Execute(); Assert.IsTrue(stateMachine.CurrentState is BotStateCombat); wowDataAdapter.SetMeInCombat(false); stateMachine.CurrentState.Execute(); Assert.IsTrue(stateMachine.CurrentState is BotStateIdle); }
#pragma warning restore IDE0051 public DruidFeralCat(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) : base(wowInterface, stateMachine) { MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { markOfTheWildSpell, () => CastSpellIfPossible(markOfTheWildSpell, WowInterface.ObjectManager.PlayerGuid, true, 0, true) }, { catFormSpell, () => CastSpellIfPossible(catFormSpell, 0, true) }, { savageRoarSpell, () => CastSpellIfPossibleRogue(savageRoarSpell, WowInterface.ObjectManager.TargetGuid, true, true, 1) } }; TargetAuraManager.DebuffsToKeepActive = new Dictionary <string, CastFunction>() { { ripSpell, () => WowInterface.ObjectManager.Player.ComboPoints == 5 && CastSpellIfPossibleRogue(ripSpell, WowInterface.ObjectManager.TargetGuid, true, true, 5) }, { rakeSpell, () => CastSpellIfPossible(rakeSpell, WowInterface.ObjectManager.TargetGuid, true) }, { mangleSpell, () => CastSpellIfPossible(mangleSpell, WowInterface.ObjectManager.TargetGuid, true) } }; TargetInterruptManager.InterruptSpells = new SortedList <int, CastInterruptFunction>() { { 0, (x) => CastSpellIfPossible(faerieFireSpell, x.Guid, true) }, }; AutoAttackEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(4000)); GroupAuraManager.SpellsToKeepActiveOnParty.Add((markOfTheWildSpell, (spellName, guid) => CastSpellIfPossible(spellName, guid, true))); }
protected BasicCombatClass(AmeisenBotStateMachine stateMachine) { WowInterface = WowInterface.I; StateMachine = stateMachine; Configureables = new Dictionary <string, dynamic>() { { "HealingItemHealthThreshold", 30.0 }, { "HealingItemManaThreshold", 30.0 } }; CooldownManager = new CooldownManager(WowInterface.CharacterManager.SpellBook.Spells); RessurrectionTargets = new Dictionary <string, DateTime>(); TargetManagerDps = new TargetManager(new DpsTargetSelectionLogic(), TimeSpan.FromMilliseconds(250)); TargetManagerTank = new TargetManager(new TankTargetSelectionLogic(), TimeSpan.FromMilliseconds(250)); TargetManagerHeal = new TargetManager(new HealTargetSelectionLogic(), TimeSpan.FromMilliseconds(250)); MyAuraManager = new AuraManager(() => WowInterface.ObjectManager.Player?.Auras); TargetAuraManager = new AuraManager(() => WowInterface.ObjectManager.Target?.Auras); GroupAuraManager = new GroupAuraManager(WowInterface); TargetInterruptManager = new InterruptManager(new List <WowUnit>() { WowInterface.ObjectManager.Target }, null); EventCheckFacing = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); EventAutoAttack = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); }
public WarlockDestruction(AmeisenBotStateMachine stateMachine) : base(stateMachine) { PetManager = new PetManager ( WowInterface, TimeSpan.FromSeconds(1), null, () => WowInterface.CharacterManager.SpellBook.IsSpellKnown(summonImpSpell) && TryCastSpell(summonImpSpell, 0, true), () => WowInterface.CharacterManager.SpellBook.IsSpellKnown(summonImpSpell) && TryCastSpell(summonImpSpell, 0, true) ); MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>(); WowInterface.CharacterManager.SpellBook.OnSpellBookUpdate += () => { if (SpellChain.Get(WowInterface.CharacterManager.SpellBook.IsSpellKnown, out string armorToUse, felArmorSpell, demonArmorSpell, demonSkinSpell)) { MyAuraManager.BuffsToKeepActive.Add(armorToUse, () => TryCastSpell(armorToUse, 0, true)); } }; TargetAuraManager.DebuffsToKeepActive = new Dictionary <string, CastFunction>() { { corruptionSpell, () => !WowInterface.ObjectManager.Target.HasBuffByName(seedOfCorruptionSpell) && TryCastSpell(corruptionSpell, WowInterface.ObjectManager.TargetGuid, true) }, { curseOfTheElementsSpell, () => TryCastSpell(curseOfTheElementsSpell, WowInterface.ObjectManager.TargetGuid, true) }, { immolateSpell, () => TryCastSpell(immolateSpell, WowInterface.ObjectManager.TargetGuid, true) } }; }
public StateLogin(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, IOffsetList offsetList, CharacterManager characterManager) : base(stateMachine) { Config = config; OffsetList = offsetList; CharacterManager = characterManager; LoginHandler = new DefaultLoginHandler(AmeisenBotStateMachine.XMemory, offsetList); }
public HunterMarksmanship(AmeisenBotStateMachine stateMachine) : base(stateMachine) { PetManager = new PetManager ( WowInterface, TimeSpan.FromSeconds(15), () => TryCastSpell(mendPetSpell, 0, true), () => TryCastSpell(callPetSpell, 0), () => TryCastSpell(revivePetSpell, 0) ); MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { aspectOfTheViperSpell, () => WowInterface.ObjectManager.Player.ManaPercentage < 20.0 && TryCastSpell(aspectOfTheViperSpell, 0, true) } }; WowInterface.CharacterManager.SpellBook.OnSpellBookUpdate += () => { if (SpellChain.Run(WowInterface.CharacterManager.SpellBook.IsSpellKnown, out string aspectToUse, aspectOfTheDragonhawkSpell, aspectOfTheHawkSpell)) { MyAuraManager.BuffsToKeepActive.Add(aspectToUse, () => WowInterface.ObjectManager.Player.ManaPercentage > 50.0 && TryCastSpell(aspectToUse, 0, true)); } }; TargetAuraManager.DebuffsToKeepActive = new Dictionary <string, CastFunction>() { { huntersMarkSpell, () => TryCastSpell(huntersMarkSpell, WowInterface.ObjectManager.TargetGuid, true) }, { serpentStingSpell, () => TryCastSpell(serpentStingSpell, WowInterface.ObjectManager.TargetGuid, true) } }; TargetInterruptManager.InterruptSpells = new SortedList <int, CastInterruptFunction>() { { 0, (x) => TryCastSpell(silencingShotSpell, x.Guid, true) } }; }
public DruidBalance(AmeisenBotStateMachine stateMachine) : base(stateMachine) { MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { moonkinFormSpell, () => TryCastSpell(moonkinFormSpell, 0, true) }, { thornsSpell, () => TryCastSpell(thornsSpell, 0, true) }, { markOfTheWildSpell, () => TryCastSpell(markOfTheWildSpell, WowInterface.ObjectManager.PlayerGuid, true, 0, true) } }; TargetAuraManager.DebuffsToKeepActive = new Dictionary <string, CastFunction>() { { moonfireSpell, () => LunarEclipse && TryCastSpell(moonfireSpell, WowInterface.ObjectManager.TargetGuid, true) }, { insectSwarmSpell, () => SolarEclipse && TryCastSpell(insectSwarmSpell, WowInterface.ObjectManager.TargetGuid, true) } }; TargetInterruptManager.InterruptSpells = new SortedList <int, CastInterruptFunction>() { { 0, (x) => TryCastSpell(faerieFireSpell, x.Guid, true) }, }; GroupAuraManager.SpellsToKeepActiveOnParty.Add((markOfTheWildSpell, (spellName, guid) => TryCastSpell(spellName, guid, true))); SolarEclipse = false; LunarEclipse = true; }
#pragma warning restore IDE0051 public HunterMarksmanship(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) : base(wowInterface, stateMachine) { PetManager = new PetManager( WowInterface.ObjectManager.Pet, TimeSpan.FromSeconds(15), () => CastSpellIfPossible(mendPetSpell, 0, true), () => CastSpellIfPossible(callPetSpell, 0), () => CastSpellIfPossible(revivePetSpell, 0)); MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { aspectOfTheDragonhawkSpell, () => CastSpellIfPossible(aspectOfTheDragonhawkSpell, 0, true) } }; TargetAuraManager.DebuffsToKeepActive = new Dictionary <string, CastFunction>() { { huntersMarkSpell, () => CastSpellIfPossible(huntersMarkSpell, WowInterface.ObjectManager.TargetGuid, true) }, { serpentStingSpell, () => CastSpellIfPossible(serpentStingSpell, WowInterface.ObjectManager.TargetGuid, true) } }; TargetInterruptManager.InterruptSpells = new SortedList <int, CastInterruptFunction>() { { 0, (x) => CastSpellIfPossible(silencingShotSpell, x.Guid, true) } }; AutoAttackEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(4000)); }
public AmeisenBot(string botDataPath, string accountName, AmeisenBotConfig config, IntPtr mainWindowHandle = default) { if (mainWindowHandle == default) { mainWindowHandle = Process.GetCurrentProcess().MainWindowHandle; } SetupLogging(botDataPath, accountName); string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Config = config; AccountName = accountName; BotDataPath = botDataPath; MainWindowHandle = mainWindowHandle; CurrentExecutionMs = 0; CurrentExecutionCount = 0; stateMachineTimerBusy = 0; AmeisenLogger.Instance.Log("AmeisenBot", $"AmeisenBot ({version}) starting...", LogLevel.Master); AmeisenLogger.Instance.Log("AmeisenBot", $"AccountName: {accountName}", LogLevel.Master); AmeisenLogger.Instance.Log("AmeisenBot", $"BotDataPath: {botDataPath}", LogLevel.Verbose); Stopwatch = new Stopwatch(); StateMachineTimer = new Timer(Config.StateMachineTickMs); StateMachineTimer.Elapsed += StateMachineTimerTick; WowInterface = new WowInterface(); SetupWowInterface(); AmeisenLogger.Instance.Log("AmeisenBot", $"Using OffsetList: {WowInterface.OffsetList.GetType()}", LogLevel.Master); if (!Directory.Exists(BotDataPath)) { Directory.CreateDirectory(BotDataPath); AmeisenLogger.Instance.Log("AmeisenBot", $"Creating folder {botDataPath}", LogLevel.Verbose); } StateMachine = new AmeisenBotStateMachine(BotDataPath, Config, WowInterface); StateMachine.OnStateMachineStateChanged += HandleLoadWowPosition; InitCombatClasses(); if (config.UseBuiltInCombatClass) { LoadDefaultCombatClass(); } else { LoadCustomCombatClass(); } // if a combatclass specified an ItemComparator // use it instead of the default one if (WowInterface.CombatClass?.ItemComparator != null) { WowInterface.CharacterManager.ItemComparator = WowInterface.CombatClass.ItemComparator; } }
public StateAttacking(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, WowInterface wowInterface) : base(stateMachine, config, wowInterface) { Enemies = new List <WowUnit>(); CombatClassStopwatch = new Stopwatch(); // default distance values DistanceToTarget = WowInterface.CombatClass == null || WowInterface.CombatClass.IsMelee ? 3.0 : 25.0; }
public StateFollowing(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, ObjectManager objectManager, CharacterManager characterManager, IPathfindingHandler pathfindingHandler, IMovementEngine movementEngine) : base(stateMachine) { Config = config; ObjectManager = objectManager; CharacterManager = characterManager; PathfindingHandler = pathfindingHandler; MovementEngine = movementEngine; }
public QuestEngine(WowInterface wowInterface, AmeisenBotConfig config, AmeisenBotStateMachine stateMachine) { WowInterface = wowInterface; Config = config; StateMachine = stateMachine; CompletedQuests = new List <int>(); QueryCompletedQuestsEvent = new TimegatedEvent(TimeSpan.FromSeconds(2)); }
public void IsMeSupposedToFollowTest() { AmeisenBot ameisenBot = new AmeisenBot(null, new TestWowDataAdapter(), null, null); AmeisenBotStateMachine stateMachine = new AmeisenBotStateMachine(ameisenBot.WowDataAdapter, null, null, null, null); WowUnit unitToFollow = stateMachine.FindUnitToFollow(); Assert.IsTrue(stateMachine.IsMeSupposedToFollow(unitToFollow)); }
public GrindingEngine(WowInterface wowInterface, AmeisenBotConfig config, AmeisenBotStateMachine stateMachine) { WowInterface = wowInterface; Config = config; StateMachine = stateMachine; Blacklist = new List <ulong>(); TargetInLosEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(500)); }
public DungeonEngine(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) { WowInterface = wowInterface; StateMachine = stateMachine; CurrentNodes = new Queue <DungeonNode>(); CompletedNodes = new List <DungeonNode>(); Reset(); }
public StateGhost(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, IOffsetList offsetList, ObjectManager objectManager, CharacterManager characterManager, HookManager hookManager, IPathfindingHandler pathfindingHandler, IMovementEngine movementEngine) : base(stateMachine) { Config = config; ObjectManager = objectManager; CharacterManager = characterManager; HookManager = hookManager; OffsetList = offsetList; PathfindingHandler = pathfindingHandler; MovementEngine = movementEngine; }
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; }
public DungeonEngine(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) { WowInterface = wowInterface; CurrentNodes = new Queue <DungeonNode>(); ExitDungeonEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(1000)); RootSelector = new Selector <DungeonBlackboard> ( "HasFinishedDungeon", (b) => Progress == 100.0, new Leaf <DungeonBlackboard>("LeaveDungeon", (b) => ExitDungeon()), new Selector <DungeonBlackboard> ( "IDied", (b) => IDied, new Sequence <DungeonBlackboard> ( new Leaf <DungeonBlackboard>("RecoverDeathPosition", (b) => MoveToPosition(DeathPosition)), new Leaf <DungeonBlackboard>("SetIDiedToFalse", (b) => { IDied = false; return(BehaviorTreeStatus.Success); }) ), new Selector <DungeonBlackboard> ( "AmITheLeader", (b) => WowInterface.ObjectManager.PartyleaderGuid == WowInterface.ObjectManager.PlayerGuid || !WowInterface.ObjectManager.PartymemberGuids.Any(), new Selector <DungeonBlackboard> ( "AreAllPlayersPresent", (b) => AreAllPlayersPresent(48.0), new Leaf <DungeonBlackboard>("FollowNodePath", (b) => FollowNodePath()), new Leaf <DungeonBlackboard>("WaitForPlayersToArrive", (b) => { return(BehaviorTreeStatus.Success); }) ), new Selector <DungeonBlackboard> ( "IsDungeonLeaderInRange", (b) => WowInterface.ObjectManager.Partyleader != null, new Leaf <DungeonBlackboard>("FollowLeader", (b) => MoveToPosition(WowInterface.ObjectManager.Partyleader.Position, 0f, MovementAction.Following)), new Leaf <DungeonBlackboard>("WaitForLeaderToArrive", (b) => { return(BehaviorTreeStatus.Success); }) ) ) ) ); BehaviorTree = new AmeisenBotBehaviorTree <DungeonBlackboard> ( "DungeonBehaviorTree", RootSelector, DungeonBlackboard ); }
public DruidRestoration(AmeisenBotStateMachine stateMachine) : base(stateMachine) { MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { treeOfLifeSpell, () => WowInterface.ObjectManager.PartymemberGuids.Any() && TryCastSpell(treeOfLifeSpell, WowInterface.ObjectManager.PlayerGuid, true) }, { markOfTheWildSpell, () => TryCastSpell(markOfTheWildSpell, WowInterface.ObjectManager.PlayerGuid, true) } }; GroupAuraManager.SpellsToKeepActiveOnParty.Add((markOfTheWildSpell, (spellName, guid) => TryCastSpell(spellName, guid, true))); SwiftmendEvent = new TimegatedEvent(TimeSpan.FromSeconds(15)); }
public DungeonEngine(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) { WowInterface = wowInterface; StateMachine = stateMachine; CurrentNodes = new ConcurrentQueue <DungeonNode>(); CompletedNodes = new List <DungeonNode>(); ExitDungeonEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(1000)); Reset(); }
public StateIdle(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, WowInterface wowInterface) : base(stateMachine, config, wowInterface) { FirstStart = true; BagSlotCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(5000)); EatCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(2000)); LootCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(2000)); RepairCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(5000)); QuestgiverCheckEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(2000)); QuestgiverRightClickEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(3000)); RefreshCharacterEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(1000)); }
public StateLooting(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, IOffsetList offsetList, ObjectManager objectManager, CharacterManager characterManager, HookManager hookManager, IPathfindingHandler pathfindingHandler, IMovementEngine movementEngine, Queue <ulong> unitLootList) : base(stateMachine) { Config = config; ObjectManager = objectManager; CharacterManager = characterManager; HookManager = hookManager; OffsetList = offsetList; PathfindingHandler = pathfindingHandler; MovementEngine = movementEngine; UnitLootList = unitLootList; UnitsAlreadyLootedList = new List <ulong>(); }
public override void Execute() { if (HookManager.GetFreeBagSlotCount() > 4 || !CharacterManager.Inventory.Items.Any(e => e.Price > 0)) { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); return; } WowUnit selectedUnit = ObjectManager.WowObjects.OfType <WowUnit>() .OrderBy(e => e.Position.GetDistance(ObjectManager.Player.Position)) .FirstOrDefault(e => e.GetType() != typeof(WowPlayer) && e.IsRepairVendor && e.Position.GetDistance(ObjectManager.Player.Position) < 50); if (selectedUnit != null && !selectedUnit.IsDead) { double distance = ObjectManager.Player.Position.GetDistance(selectedUnit.Position); if (distance > 5.0) { MovementEngine.SetState(MovementEngineState.Moving, selectedUnit.Position); MovementEngine.Execute(); } else { if (distance > 4) { CharacterManager.InteractWithUnit(selectedUnit, 20.9f, 2f); } else { HookManager.RightClickUnit(selectedUnit); Task.Delay(1000).GetAwaiter().GetResult(); HookManager.SellAllGrayItems(); foreach (IWowItem item in CharacterManager.Inventory.Items.Where(e => e.Price > 0)) { IWowItem itemToSell = item; if (CharacterManager.IsItemAnImprovement(item, out IWowItem itemToReplace)) { itemToSell = itemToReplace; HookManager.ReplaceItem(null, item); } HookManager.UseItemByBagAndSlot(itemToSell.BagId, itemToSell.BagSlot); } } } } else { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); } }
public override void Execute() { if (XMemory.Process != null && XMemory.Process.HasExited) { AmeisenBotStateMachine.SetState(AmeisenBotState.None); } ObjectManager.RefreshIsWorldLoaded(); if (ObjectManager.IsWorldLoaded) { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); } }
public ShamanRestoration(AmeisenBotStateMachine stateMachine) : base(stateMachine) { MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { waterShieldSpell, () => TryCastSpell(waterShieldSpell, 0, true) } }; SpellUsageHealDict = new Dictionary <int, string>() { { 0, riptideSpell }, { 5000, healingWaveSpell }, }; }
public RogueAssassination(AmeisenBotStateMachine stateMachine) : base(stateMachine) { MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { sliceAndDiceSpell, () => TryCastSpellRogue(sliceAndDiceSpell, 0, true, true, 1) }, { coldBloodSpell, () => TryCastSpellRogue(coldBloodSpell, 0, true) } }; TargetInterruptManager.InterruptSpells = new SortedList <int, CastInterruptFunction>() { { 0, (x) => TryCastSpellRogue(kickSpell, x.Guid, true) } }; }
public StateAttacking(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, ObjectManager objectManager, CharacterManager characterManager, HookManager hookManager, IPathfindingHandler pathfindingHandler, IMovementEngine movementEngine, ICombatClass combatClass) : base(stateMachine) { Config = config; ObjectManager = objectManager; CharacterManager = characterManager; HookManager = hookManager; PathfindingHandler = pathfindingHandler; MovementEngine = movementEngine; CombatClass = combatClass; // default distance values DistanceToTarget = combatClass == null || combatClass.IsMelee ? 3.0 : 25.0; }
#pragma warning restore IDE0051 public ShamanRestoration(WowInterface wowInterface, AmeisenBotStateMachine stateMachine) : base(wowInterface, stateMachine) { UseDefaultTargetSelection = false; MyAuraManager.BuffsToKeepActive = new Dictionary <string, CastFunction>() { { waterShieldSpell, () => CastSpellIfPossible(waterShieldSpell, 0, true) } }; SpellUsageHealDict = new Dictionary <int, string>() { { 0, riptideSpell }, { 5000, healingWaveSpell }, }; }
public override void Execute() { if (ObjectManager.Player.IsDead) { HookManager.ReleaseSpirit(); } else if (HookManager.IsGhost("player")) { AmeisenBotStateMachine.SetState(AmeisenBotState.Ghost); } else { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); } }
public override void Enter() { if (Config.AutostartWow) { AmeisenBotStateMachine.SetState(AmeisenBotState.StartWow); } else if (Config.AutoLogin) { AmeisenBotStateMachine.SetState(AmeisenBotState.Login); } else { AmeisenBotStateMachine.SetState(AmeisenBotState.Idle); } }