public override void Enter() { if (WowInterface.ObjectManager.IsWorldLoaded) { if (WowInterface.WowProcess != null && !WowInterface.WowProcess.HasExited && FirstStart) { FirstStart = false; WowInterface.XMemory.ReadString(WowInterface.OffsetList.PlayerName, Encoding.ASCII, out string playerName); StateMachine.PlayerName = playerName; if (!WowInterface.EventHookManager.IsActive) { WowInterface.EventHookManager.Start(); } WowInterface.HookManager.LuaDoString($"SetCVar(\"maxfps\", {Config.MaxFps});SetCVar(\"maxfpsbk\", {Config.MaxFps})"); WowInterface.HookManager.WowEnableClickToMove(); } if (RefreshCharacterEvent.Run()) { WowInterface.CharacterManager.UpdateAll(); } WowInterface.MovementEngine.StopMovement(); IdleActionManager.Reset(); } }
public StateIdle(AmeisenBotStateMachine stateMachine, AmeisenBotConfig config, WowInterface wowInterface) : base(stateMachine, config, wowInterface) { FirstStart = true; IdleActionManager = new IdleActionManager(config.IdleActionsMaxCooldown, config.IdleActionsMinCooldown, new List <IIdleAction>() { new AuctionHouseIdleAction(), new CheckMailsIdleAction(), new FishingIdleAction(), new LookAroundIdleAction(), new LookAtGroupIdleAction(), new RandomEmoteIdleAction(), new SitByCampfireIdleAction(), new SitToChairIdleAction(stateMachine, Config.MinFollowDistance), }); 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)); IdleActionEvent = new TimegatedEvent(TimeSpan.FromMilliseconds(1000)); }
public override void Execute() { // WowInterface.MovementEngine.SetMovementAction(MovementAction.Moving, new Vector3(-4918, -940, 501)); // return; // do we need to loot stuff if (LootCheckEvent.Run() && WowInterface.CharacterManager.Inventory.FreeBagSlots > 0 && StateMachine.GetNearLootableUnits().Any()) { StateMachine.SetState(BotState.Looting); return; } // do we need to eat something if (EatCheckEvent.Run() && StateMachine.GetState <StateEating>().NeedToEat()) { StateMachine.SetState(BotState.Eating); return; } // we are on a battleground if (WowInterface.XMemory.Read(WowInterface.OffsetList.BattlegroundStatus, out int bgStatus) && bgStatus == 3 && !Config.BattlegroundUsePartyMode) { StateMachine.SetState(BotState.Battleground); return; } // we are in a dungeon if (WowInterface.ObjectManager.MapId.IsDungeonMap() && !Config.DungeonUsePartyMode) { StateMachine.SetState(BotState.Dungeon); return; } // do we need to repair our equipment if (Config.AutoRepair && RepairCheckEvent.Run() && StateMachine.GetState <StateRepairing>().NeedToRepair() && StateMachine.GetState <StateRepairing>().IsRepairNpcNear(out _)) { StateMachine.SetState(BotState.Repairing); return; } // do we need to sell stuff if (Config.AutoSell && BagSlotCheckEvent.Run() && StateMachine.GetState <StateSelling>().NeedToSell() && StateMachine.GetState <StateSelling>().IsVendorNpcNear(out _)) { StateMachine.SetState(BotState.Selling); return; } // do i need to complete/get quests if (Config.AutoTalkToNearQuestgivers && IsUnitToFollowThere(out WowUnit unitToFollow, true) && unitToFollow != null && unitToFollow.TargetGuid != 0) { if (QuestgiverCheckEvent.Run() && HandleAutoQuestMode(unitToFollow)) { return; } } // do i need to follow someone if ((!Config.Autopilot || WowInterface.ObjectManager.MapId.IsDungeonMap()) && IsUnitToFollowThere(out _)) { StateMachine.SetState(BotState.Following); return; } // do buffing etc... if (WowInterface.CombatClass != null) { WowInterface.CombatClass.OutOfCombatExecute(); } if (StateMachine.StateOverride != BotState.Idle && StateMachine.StateOverride != BotState.None) { StateMachine.SetState(StateMachine.StateOverride); } if (Config.IdleActions && IdleActionEvent.Run()) { IdleActionManager.Tick(Config.Autopilot); } }