public bool Enter() { SatDown = false; // get the center from where to cal the distance, this is needed // to prevent going out of the follow trigger radius, which // would cause a suspicous loop of running around Vector3 originPos = Bot.Player.Position; // StateMachine.Get<StateFollowing>().IsUnitToFollowThere(out IWowUnit unit, false) ? unit.Position : Bot.Player.Position; IWowGameobject seat = Bot.Objects.WowObjects.OfType <IWowGameobject>() .OrderBy(e => e.Position.GetDistance(originPos)) .FirstOrDefault(e => e.GameObjectType == WowGameObjectType.Chair // make sure no one sits on the chair besides ourself && !Bot.Objects.WowObjects.OfType <IWowUnit>() .Where(e => e.Guid != Bot.Wow.PlayerGuid) .Any(x => e.Position.GetDistance(x.Position) < 0.6f) && e.Position.GetDistance(originPos) < MaxDistance - 0.2f); if (seat != null) { CurrentSeat = seat; return(true); } return(false); }
private void RenderOres(int halfWidth, int halfHeight, Graphics graphics, float scale, Vector3 playerPosition, float playerRotation) { IEnumerable <IWowGameobject> oreNodes = AmeisenBot.Bot.Objects.WowObjects .OfType <IWowGameobject>() .Where(e => Enum.IsDefined(typeof(WowOreId), e.DisplayId)); for (int i = 0; i < oreNodes.Count(); ++i) { IWowGameobject gameobject = oreNodes.ElementAt(i); Point positionOnMap = GetRelativePosition(playerPosition, gameobject.Position, playerRotation, halfWidth, halfHeight, scale); RenderGameobject(positionOnMap.X, positionOnMap.Y, ((WowOreId)gameobject.DisplayId).ToString(), OreBrush, TextBrush, TextFont, graphics); } }
public void Execute() { if (Finished) { return; } IWowGameobject lootableObject = Bot.Objects.WowObjects.OfType <IWowGameobject>() .Where(e => e.DisplayId == ObjectDisplayId) .OrderBy(e => e.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(); if (lootableObject != null) { if (lootableObject.Position.GetDistance(Bot.Player.Position) > 3.0) { Bot.Movement.SetMovementAction(MovementAction.Move, lootableObject.Position); } else { if (RightClickEvent.Run()) { Bot.Movement.Reset(); Bot.Wow.StopClickToMove(); Bot.Wow.InteractWithObject(lootableObject.BaseAddress); } } } else { AreaNode selectedArea = Area .OrderBy(e => e.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(e => e.Position.GetDistance(Bot.Player.Position) < e.Radius); if (selectedArea != null) { Bot.Movement.SetMovementAction(MovementAction.Move, selectedArea.Position); } } }
public void Execute() { if (!CheckedMails) { if (CurrentMailbox.GetDistance(Bot.Player.Position) > 3.5f) { Bot.Movement.SetMovementAction(MovementAction.Move, CurrentMailbox); } else { Bot.Movement.StopMovement(); IWowGameobject mailbox = Bot.Objects.WowObjects.OfType <IWowGameobject>() .FirstOrDefault(e => e.GameObjectType == WowGameObjectType.Mailbox && e.Position.GetDistance(CurrentMailbox) < 1.0f); if (mailbox != null) { Bot.Wow.InteractWithObject(mailbox.BaseAddress); Bot.Wow.LuaDoString("for i=1,GetInboxNumItems()do AutoLootMailItem(i)end"); } CheckedMails = true; MailboxCheckTime = DateTime.UtcNow + TimeSpan.FromSeconds(Rnd.Next(7, 16)); } } else if (!ReturnedToOrigin && MailboxCheckTime < DateTime.UtcNow) { if (CurrentMailbox.GetDistance(OriginPosition) > 8.0f) { Bot.Movement.SetMovementAction(MovementAction.Move, OriginPosition); } else { Bot.Movement.StopMovement(); ReturnedToOrigin = true; } } }
public void Execute() { if (PlacedCampfire && SatDown) { return; } IWowGameobject nearCampfire = Bot.Objects.All.OfType <IWowGameobject>() .FirstOrDefault(e => e.DisplayId == (int)WowGameObjectDisplayId.CookingCampfire && Bot.Objects.PartymemberGuids.Contains(e.CreatedBy)); if (nearCampfire != null && !SatDown) { Bot.Wow.FacePosition(Bot.Player.BaseAddress, Bot.Player.Position, nearCampfire.Position, true); Bot.Wow.SendChatMessage(Rnd.Next(0, 2) == 1 ? "/sit" : "/sleep"); SatDown = true; } else if (!PlacedCampfire) { Bot.Wow.CastSpell("Basic Campfire"); PlacedCampfire = true; } }
public void Execute() { Combat(); IWowGameobject FlagNode = Bot.Objects.All .OfType <IWowGameobject>() .Where(x => Enum.IsDefined(typeof(Flags), x.DisplayId) && x.Position.GetDistance(Bot.Player.Position) < 15) .OrderBy(x => x.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(); if (FlagNode != null) { Bot.Movement.SetMovementAction(MovementAction.Move, FlagNode.Position); if (Bot.Player.Position.GetDistance(FlagNode.Position) <= 4) { Bot.Movement.StopMovement(); if (CaptureFlagEvent.Run()) { Bot.Wow.InteractWithObject(FlagNode); } } else { Bot.Movement.SetMovementAction(MovementAction.Move, FlagNode.Position); } } else { if (Bot.Wow.ExecuteLuaAndRead(BotUtils.ObfuscateLua("{v:0}=\"\" for i = 1, GetNumMapLandmarks(), 1 do base, status = GetMapLandmarkInfo(i) {v:0}= {v:0}..base..\":\"..status..\";\" end"), out string result)) { Vector3 currentNode = PathBase[CurrentNodeCounter]; string[] AllBaseList = result.Split(';'); if (Bot.Player.HasBuffById(34976)) { if (AllBaseList[CurrentNodeCounter].Contains(FactionFlagState)) { Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); } else { ++CurrentNodeCounter; if (CurrentNodeCounter >= PathBase.Count) { CurrentNodeCounter = 0; } } } else { if (AllBaseList[CurrentNodeCounter].Contains("Uncontrolled") || AllBaseList[CurrentNodeCounter].Contains("In Conflict") || AllBaseList[CurrentNodeCounter].Contains(FactionFlagState)) { Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); } if (Bot.Player.Position.GetDistance(currentNode) < 10.0f) { ++CurrentNodeCounter; if (CurrentNodeCounter >= PathBase.Count) { CurrentNodeCounter = 0; } } else if (FactionFlagState != null && AllBaseList[CurrentNodeCounter].Contains(FactionFlagState)) { ++CurrentNodeCounter; if (CurrentNodeCounter >= PathBase.Count) { CurrentNodeCounter = 0; } } else if (FlagNode != null) { IEnumerable <IWowPlayer> enemiesNearFlag = Bot.GetNearEnemies <IWowPlayer>(FlagNode.Position, 40); IEnumerable <IWowPlayer> friendsNearFlag = Bot.GetNearFriends <IWowPlayer>(FlagNode.Position, 40); IEnumerable <IWowPlayer> friendsNearPlayer = Bot.GetNearFriends <IWowPlayer>(Bot.Player.Position, 20); if (enemiesNearFlag != null) { if (enemiesNearFlag.Count() >= 2) { if (friendsNearFlag != null && (friendsNearFlag.Any() || friendsNearPlayer.Any())) { Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); return; } } else { Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); return; } } } else { Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); } } } } }
private void ExecuteMining(IMiningProfile miningProfile) { if (Bot.Player.IsCasting) { return; } if (CheckForPathRecovering) { Vector3 closestNode = miningProfile.Path.OrderBy(e => e.GetDistance(Bot.Player.Position)).First(); CurrentNodeCounter = miningProfile.Path.IndexOf(closestNode) + 1; CheckForPathRecovering = false; NodeTryCounter = 0; } if (Bot.Character.Inventory.FreeBagSlots < 3 && SellActionsNeeded == 0) { SellActionsNeeded = (int)Math.Ceiling(Bot.Character.Inventory.Items.Count / 12.0); // 12 items per mail CheckForPathRecovering = true; } if (SellActionsNeeded > 0) { IWowGameobject mailboxNode = Bot.Objects.WowObjects.OfType <IWowGameobject>() .Where(x => Enum.IsDefined(typeof(MailBox), x.DisplayId) && x.Position.GetDistance(Bot.Player.Position) < 15) .OrderBy(x => x.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(); if (mailboxNode != null) { Bot.Movement.SetMovementAction(MovementAction.Move, mailboxNode.Position); if (Bot.Player.Position.GetDistance(mailboxNode.Position) <= 4) { Bot.Movement.StopMovement(); if (MailSentEvent.Run()) { Bot.Wow.InteractWithObject(mailboxNode.BaseAddress); Bot.Wow.LuaDoString("MailFrameTab2:Click();"); int usedItems = 0; foreach (IWowInventoryItem item in Bot.Character.Inventory.Items) { if (Config.ItemSellBlacklist.Contains(item.Name) || item.Name.Contains("Mining Pick", StringComparison.OrdinalIgnoreCase)) { continue; } Bot.Wow.UseContainerItem(item.BagId, item.BagSlot); ++usedItems; } if (usedItems > 0) { Bot.Wow.LuaDoString($"SendMail('{Config.JobEngineMailReceiver}', '{Config.JobEngineMailHeader}', '{Config.JobEngineMailText}')"); --SellActionsNeeded; } else { SellActionsNeeded = 0; } } } else { Bot.Movement.SetMovementAction(MovementAction.Move, mailboxNode.Position); } } else { Vector3 currentNode = miningProfile.MailboxNodes.OrderBy(x => x.GetDistance(Bot.Player.Position)).FirstOrDefault(); Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); } return; } if (SelectedPosition == default) { // search for nodes int miningSkill = Bot.Character.Skills.ContainsKey("Mining") ? Bot.Character.Skills["Mining"].Item1 : 0; IWowGameobject nearestNode = Bot.Objects.WowObjects.OfType <IWowGameobject>() .Where(e => !NodeBlacklist.Contains(e.Guid) && Enum.IsDefined(typeof(WowOreId), e.DisplayId) && miningProfile.OreTypes.Contains((WowOreId)e.DisplayId) && (((WowOreId)e.DisplayId) == WowOreId.Copper || (((WowOreId)e.DisplayId) == WowOreId.Tin && miningSkill >= 65) || (((WowOreId)e.DisplayId) == WowOreId.Silver && miningSkill >= 75) || (((WowOreId)e.DisplayId) == WowOreId.Iron && miningSkill >= 125) || (((WowOreId)e.DisplayId) == WowOreId.Gold && miningSkill >= 155) || (((WowOreId)e.DisplayId) == WowOreId.Mithril && miningSkill >= 175) || (((WowOreId)e.DisplayId) == WowOreId.DarkIron && miningSkill >= 230) || (((WowOreId)e.DisplayId) == WowOreId.SmallThorium && miningSkill >= 245) || (((WowOreId)e.DisplayId) == WowOreId.RichThorium && miningSkill >= 275) || (((WowOreId)e.DisplayId) == WowOreId.FelIron && miningSkill >= 300) || (((WowOreId)e.DisplayId) == WowOreId.Adamantite && miningSkill >= 325) || (((WowOreId)e.DisplayId) == WowOreId.Cobalt && miningSkill >= 350) || (((WowOreId)e.DisplayId) == WowOreId.Khorium && miningSkill >= 375) || (((WowOreId)e.DisplayId) == WowOreId.Saronite && miningSkill >= 400) || (((WowOreId)e.DisplayId) == WowOreId.Titanium && miningSkill >= 450))) .OrderBy(x => x.Position.GetDistance(Bot.Player.Position)) .FirstOrDefault(); if (nearestNode != null) { // select node and try to find it SelectedPosition = nearestNode.Position; SelectedGuid = nearestNode.Guid; } else { // if no node was found, follow the path Vector3 currentNode = miningProfile.Path[CurrentNodeCounter]; Bot.Movement.SetMovementAction(MovementAction.Move, currentNode); if (Bot.Player.Position.GetDistance(currentNode) < 3.0f) { ++CurrentNodeCounter; if (CurrentNodeCounter >= miningProfile.Path.Count) { if (!miningProfile.IsCirclePath) { miningProfile.Path.Reverse(); } CurrentNodeCounter = 0; } } } } else { // move to the node double distanceToNode = Bot.Player.Position.GetDistance(SelectedPosition); IWowGameobject node = Bot.GetWowObjectByGuid <IWowGameobject>(SelectedGuid); if (node == null) { // if we are 20m or less near the node and its still not loaded, we can ignore it SelectedPosition = default; SelectedGuid = 0; } else if (distanceToNode < 3.0f) { if (Bot.Player.IsMounted) { Bot.Wow.DismissCompanion("MOUNT"); return; } Bot.Movement.StopMovement(); if (MiningEvent.Run()) { if (Bot.Memory.Read(Bot.Wow.Offsets.LootWindowOpen, out byte lootOpen) && lootOpen > 0) { Bot.Wow.LootEverything(); } else { Bot.Wow.InteractWithObject(node.BaseAddress); } } CheckForPathRecovering = true; NodeTryCounter = 0; } else if (!Bot.Movement.SetMovementAction(MovementAction.Move, node.Position)) { if (NodeTryCounter > 2) { NodeBlacklist.Add(node.Guid); NodeTryCounter = 0; } ++NodeTryCounter; } } }
public void Execute() { if ((CurrentSpot == default || SpotSelected + SpotDuration <= DateTime.UtcNow) && !Bot.Player.IsCasting && Bot.Db.TryGetPointsOfInterest(Bot.Objects.MapId, PoiType.FishingSpot, Bot.Player.Position, 256.0f, out IEnumerable <Vector3> pois)) { CurrentSpot = pois.ElementAt(Rnd.Next(0, pois.Count() - 1)); SpotSelected = DateTime.UtcNow; SpotDuration = TimeSpan.FromSeconds(new Random().Next(MinDuration, MaxDuration)); } if (CurrentSpot != default) { if (Bot.Player.Position.GetDistance(CurrentSpot) > 3.5f) { Bot.Movement.SetMovementAction(MovementAction.Move, CurrentSpot); return; } else if (Bot.Wow.IsClickToMoveActive()) { Bot.Movement.StopMovement(); return; } if (!BotMath.IsFacing(Bot.Player.Position, Bot.Player.Rotation, CurrentSpot)) { Bot.Wow.FacePosition(Bot.Player.BaseAddress, Bot.Player.Position, CurrentSpot); return; } } if (!IsFishingRodEquipped()) { IWowInventoryItem fishingRod = Bot.Character.Inventory.Items.OfType <WowWeapon>() .FirstOrDefault(e => e.WeaponType == WowWeaponType.FishingPole); if (fishingRod != null) { Bot.Wow.EquipItem(fishingRod.Name); } } IWowGameobject fishingBobber = Bot.Objects.WowObjects.OfType <IWowGameobject>() .FirstOrDefault(e => e.GameObjectType == WowGameObjectType.FishingBobber && e.CreatedBy == Bot.Wow.PlayerGuid); if (!Started) { Started = true; CooldownStart = DateTime.UtcNow; Duration = TimeSpan.FromSeconds(Rnd.Next(MinDuration, MaxDuration)); } else if (CooldownStart + Duration <= DateTime.UtcNow) { Started = false; CooldownStart = default; Duration = default; CurrentSpot = default; return; } if (!Bot.Player.IsCasting || fishingBobber == null) { Bot.Wow.CastSpell("Fishing"); } else if (fishingBobber.Flags[(int)WowGameObjectFlag.NoDespawn]) { Bot.Wow.InteractWithObject(fishingBobber.BaseAddress); Bot.Wow.LootEverything(); } }