Exemple #1
0
 public override void Stop()
 {
     base.Stop();
     WaypointQueue.Clear();
     AmeisenCore.RunSlashCommand("/cleartarget");
     Target = null;
 }
Exemple #2
0
        /// <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();
        }
Exemple #3
0
        public override void DoThings()
        {
            if (WaypointQueue.Count > 0)
            {
                base.DoThings();
            }

            Unit   unitToLoot = AmeisenDataHolder.LootableUnits.Peek();
            double distance   = Utils.GetDistance(Me.pos, unitToLoot.pos);

            if (distance > 3)
            {
                if (!WaypointQueue.Contains(unitToLoot.pos))
                {
                    WaypointQueue.Enqueue(unitToLoot.pos);
                }
            }
            else
            {
                AmeisenCore.TargetGUID(unitToLoot.Guid);
                AmeisenCore.LuaDoString("InteractUnit(\"target\");");
                Thread.Sleep(1000);
                // We should have looted it by now based on the event
                AmeisenDataHolder.LootableUnits.Dequeue();
            }
        }
Exemple #4
0
 public void ReplaceItem(Item currentItem, Item newItem)
 {
     AmeisenCore.LuaDoString($"EquipItemByName(\"{newItem.Name}\", {currentItem.Slot});");
     AmeisenCore.LuaDoString("ConfirmBindOnUse();");
     AmeisenCore.RunSlashCommand("/click StaticPopup1Button1");
     AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"Equipped new Item...", this);
 }
Exemple #5
0
 public static void MoveToPos(Me me, Unit unitToAttack, double distance = 2.0)
 {
     if (Utils.GetDistance(me.pos, unitToAttack.pos) >= distance)
     {
         AmeisenCore.MovePlayerToXYZ(unitToAttack.pos, InteractionType.MOVE);
     }
 }
Exemple #6
0
        private void GoToCorpseAndRevive()
        {
            Vector3 corpsePosition = AmeisenCore.GetCorpsePosition();

            corpsePosition.X = (int)corpsePosition.X;
            corpsePosition.Y = (int)corpsePosition.Y;
            corpsePosition.Z = (int)corpsePosition.Z;

            if (InstanceEntrances.ContainsKey(corpsePosition))
            {
                // Dungeon/Raid workaround
                // because blizzard decided to put the corpse at very low Z axis values that
                // we cant navigate to them, so we are going to use the position of the entrance instead
                corpsePosition = InstanceEntrances[corpsePosition];
            }

            if (corpsePosition.X != 0 && corpsePosition.Y != 0 && corpsePosition.Z != 0)
            {
                if (!WaypointQueue.Contains(corpsePosition))
                {
                    WaypointQueue.Enqueue(corpsePosition);
                }
            }

            if (Utils.GetDistance(Me.pos, corpsePosition) < 4.0)
            {
                AmeisenCore.RetrieveCorpse(true);
            }
        }
Exemple #7
0
        /// <summary>
        /// Cast a spell
        /// </summary>
        /// <param name="me">you</param>
        /// <param name="target">target to cast the spell on</param>
        /// <param name="spellname">spell to cast</param>
        /// <param name="onMyself">cast sepll on yourself</param>
        /// <param name="waitOnCastToFinish">wait for the cast to finish</param>
        public static void CastSpellByName(Me me, Unit target, string spellname, bool onMyself, bool waitOnCastToFinish = true)
        {
            SpellInfo spellInfo = GetSpellInfo(spellname);

            if (IsUnitValid(target))
            {
                if (!IsFacingMelee(me, target))
                {
                    FaceUnit(me, target);
                }
            }

            AmeisenCore.CastSpellByName(spellname, onMyself);

            if (waitOnCastToFinish)
            {
                int sleeptime = spellInfo.castTime - 100;
                Thread.Sleep(sleeptime > 0 ? sleeptime : 0);

                FaceUnit(me, target);
                Thread.Sleep(100);

                while (AmeisenCore.GetUnitCastingInfo(LuaUnit.player).duration >= 100)
                {
                    Thread.Sleep(100);
                }
            }
        }
        private void UpdateNodeInDB(Me me)
        {
            int zoneID = AmeisenCore.GetZoneID();
            int mapID  = AmeisenCore.GetMapID();

            // Me
            AmeisenDBManager.UpdateOrAddNode(new MapNode(me.pos, zoneID, mapID));

            List <ulong> copyOfPartymembers = me.PartymemberGuids;

            // fix with a lock or something alike...
            try
            {
                // All partymembers
                foreach (ulong guid in copyOfPartymembers)
                {
                    Unit unit = (Unit)GetWoWObjectFromGUID(guid);
                    if (unit != null && Utils.GetDistance(me.pos, unit.pos) < 75)
                    {
                        AmeisenDBManager.UpdateOrAddNode(new MapNode(unit.pos, zoneID, mapID));
                    }
                }
            }
            catch { }
        }
 private void DoRandomEmote()
 {
     if (Environment.TickCount >= TickCountToExecuteRandomEmote)
     {
         AmeisenCore.LuaDoString($"DoEmote(\"{randomEmoteList[new Random().Next(randomEmoteList.Length)]}\");");
         TickCountToExecuteRandomEmote = Environment.TickCount + new Random().Next(60000, 600000);
     }
 }
Exemple #10
0
 private void ReleaseSpiritCheck()
 {
     if (AmeisenDataHolder.IsAllowedToReleaseSpirit)
     {
         if (Me.Health == 0)
         {
             AmeisenCore.ReleaseSpirit();
             Thread.Sleep(2000);
         }
     }
 }
Exemple #11
0
        /// <summary>
        /// Read one of the following deatails:
        ///
        /// itemName, itemLink, itemRarity, itemLevel, itemMinLevel,
        /// itemType, itemSubType, itemStackCount, itemEquipLoc,
        /// itemIcon, itemSellPrice, itemClassID, itemSubClassID,
        /// bindType, expacID, itemSetID, isCraftingReagent.
        ///
        /// May returns nothing when the item is still beeing queried!
        /// </summary>
        /// <param name="detailToRead">detail to read</param>
        /// <returns>detail as string</returns>
        private string ReadItemDetail(string detailToRead)
        {
            StringBuilder cmd = new StringBuilder();

            cmd.Append("itemName, itemLink, itemRarity, itemLevel, itemMinLevel, ");
            cmd.Append("itemType, itemSubType, itemStackCount, itemEquipLoc, ");
            cmd.Append("itemIcon, itemSellPrice, itemClassID, itemSubClassID, ");
            cmd.Append("bindType, expacID, itemSetID, isCraftingReagent = ");
            cmd.Append($"GetItemInfo({Id})");
            return(AmeisenCore.GetLocalizedText(cmd.ToString(), detailToRead));
        }
Exemple #12
0
 /// <summary>
 /// Turn into a specified Units direction
 /// </summary>
 /// <param name="me">me object</param>
 /// <param name="unit">unit to turn to</param>
 public static void FaceUnit(Me me, Unit unit)
 {
     if (IsUnitValid(unit))
     {
         /*unit.Update();
          * AmeisenCore.MovePlayerToXYZ(
          *  unit.pos,
          *  InteractionType.FACETARGET,
          *  0);*/
         AmeisenCore.FaceUnit(me, unit);
     }
 }
Exemple #13
0
 public static void FaceTarget(Me me, Unit target)
 {
     if (target != null)
     {
         target.Update();
         if (!Utils.IsFacing(me.pos, me.Rotation, target.pos))
         {
             AmeisenCore.InteractWithGUID(
                 target.pos,
                 target.Guid,
                 InteractionType.FACETARGET);
         }
     }
 }
        /// <summary>
        /// Change the state of out FSM
        /// </summary>
        private void WatchForStateChanges()
        {
            while (Active)
            {
                Thread.Sleep(AmeisenDataHolder.Settings.stateMachineStateUpdateMillis);

                if (AmeisenCore.IsInLoadingScreen())
                {
                    continue;
                }

                // Am I in combat
                if (InCombatCheck())
                {
                    continue;
                }

                // Is there loot waiting for me
                if (IsLootThere())
                {
                    continue;
                }

                // Am I dead?
                if (DeadCheck())
                {
                    continue;
                }

                // Do I need to release my spirit
                if (ReleaseSpiritCheck())
                {
                    continue;
                }

                // Bot stuff check
                if (BotStuffCheck())
                {
                    continue;
                }

                // Is me supposed to follow
                if (FollowCheck())
                {
                    continue;
                }

                AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"FSM: {StateMachine.GetCurrentState()}", this);
            }
        }
Exemple #15
0
        public static Unit TargetTargetToHeal(Me me, List <WowObject> activeWowObjects)
        {
            // Get the one with the lowest hp and target him/her
            List <Unit> units = PartymembersInCombat(me, activeWowObjects);

            if (units.Count > 0)
            {
                Unit u = units.OrderBy(o => o.HealthPercentage).ToList()[0];
                u.Update();
                AmeisenCore.TargetGUID(u.Guid);
                return(u);
            }
            return(null);
        }
Exemple #16
0
        /// <summary>
        /// Very basic Obstacle avoidance.
        ///
        /// Need to change this to a better waypoint system that uses our MapNode Database...
        /// </summary>
        /// <param name="initialPosition">initial position</param>
        /// <param name="activePosition">position now</param>
        /// <returns>if we havent moved 0.5m in the 2 vectors, jump and return true</returns>
        private bool CheckIfWeAreStuckIfYesJump(Vector3 initialPosition, Vector3 activePosition)
        {
            // we are possibly stuck at a fence or something alike
            if (MovedSinceLastTick != 0 && MovedSinceLastTick < 1000)
            {
                if (MovedSinceLastTick < AmeisenDataHolder.Settings.MovementJumpThreshold)
                {
                    AmeisenCore.CharacterJumpAsync();
                    AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"Jumping: {MovedSinceLastTick}", this);
                    return true;
                }
            }

            MovedSinceLastTick = Utils.GetDistance(initialPosition, activePosition);
            return false;
        }
Exemple #17
0
        private void GoToCorpseAndRevive()
        {
            Vector3 corpsePosition = AmeisenCore.GetCorpsePosition();

            if (corpsePosition.X != 0 && corpsePosition.Y != 0 && corpsePosition.Z != 0)
            {
                if (!WaypointQueue.Contains(corpsePosition))
                {
                    WaypointQueue.Enqueue(corpsePosition);
                }
            }

            if (Utils.GetDistance(Me.pos, corpsePosition) < 10.0)
            {
                AmeisenCore.RetrieveCorpse(true);
            }
        }
Exemple #18
0
        public static Unit AssistParty(Me me, List <WowObject> activeWowObjects)
        {
            // Get the one with the lowest hp and assist him/her
            List <Unit> units = PartymembersInCombat(me, activeWowObjects);

            if (units.Count > 0)
            {
                Unit u = units.OrderBy(o => o.HealthPercentage).ToList()[0];
                u.Update();

                Unit targetToAttack = (Unit)GetWoWObjectFromGUID(u.TargetGuid, activeWowObjects);
                targetToAttack.Update();
                AmeisenCore.TargetGUID(targetToAttack.Guid);
                me.Update();
                return(targetToAttack);
            }
            return(null);
        }
Exemple #19
0
        public void EquipAllBetterItems()
        {
            bool replacedItem = false;

            if (Character.FullyLoaded)
            {
                foreach (Item item in Character.Equipment.AsList())
                {
                    if (item.Id != 0)
                    {
                        List <InventoryItem> itemsLikeItem = GetAllItemsLike(item);

                        if (itemsLikeItem.Count > 0)
                        {
                            Item possibleNewItem = itemsLikeItem.First();
                            if (CompareItems(item, possibleNewItem))
                            {
                                ReplaceItem(item, possibleNewItem);
                                replacedItem = true;
                            }
                        }
                    }
                    else
                    {
                        // we have no item equipped
                        List <InventoryItem> bestForSlotItem = GetAllItemsForSlot(item);
                        if (bestForSlotItem.Count > 0)
                        {
                            AmeisenCore.RunSlashCommand($"/equip {bestForSlotItem.First().Name}");
                            replacedItem = true;
                        }
                    }
                }
            }
            else
            {
                AmeisenLogger.Instance.Log(LogLevel.WARNING, "Could not Equip better items, Character is still loading", this);
            }

            if (replacedItem)
            {
                UpdateCharacterAsync();
            }
        }
Exemple #20
0
        private void FindClosestRepairNpc()
        {
            if (!IGotTheDamnMammoth)
            {
                AmeisenLogger.Instance.Log(LogLevel.DEBUG, "Searching for Units to repair equipment...", this);
                List <RememberedUnit> possibleUnits = AmeisenDBManager.GetRememberedUnits(UnitTrait.SELL);
                AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"Found {possibleUnits.Count} Units to repair at", this);

                RememberedUnit closestUnit = null;

                double lastDistance = 100000;
                foreach (RememberedUnit unit in possibleUnits)
                {
                    double currentDistance = Utils.GetDistance(Me.pos, unit.Position);
                    if (currentDistance < lastDistance)
                    {
                        closestUnit  = unit;
                        lastDistance = currentDistance;
                    }
                }

                if (closestUnit != null)
                {
                    AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"Unit to sell trash found: {closestUnit.Name}", this);
                    GoToUnitAndRepair(closestUnit);
                }
                else
                {
                    AmeisenLogger.Instance.Log(LogLevel.DEBUG, "No Unit to sell trash found...", this);
                }
            }
            else
            {
                AmeisenLogger.Instance.Log(LogLevel.DEBUG, "I got the mammoth to sell trash...", this);

                if (AmeisenCore.IsOutdoors)
                {
                    AmeisenCore.CastSpellByName("Traveler's Tundra Mammoth", false);

                    Thread.Sleep(2000);
                    SellTrashAtUnit(null, true);
                }
            }
        }
        private bool ReleaseSpiritCheck()
        {
            if (AmeisenDataHolder.IsAllowedToReleaseSpirit)
            {
                if (Me.Health == 0)
                {
                    AmeisenCore.ReleaseSpirit();
                    Thread.Sleep(1000);

                    while (AmeisenCore.IsInLoadingScreen())
                    {
                        Thread.Sleep(200);
                    }

                    return(true);
                }
            }
            return(false);
        }
Exemple #22
0
        public static void CastSpellByName(Me me, Unit target, string name, bool onMyself)
        {
            SpellInfo spellInfo = GetSpellInfo(name, onMyself);

            if (!onMyself && !AmeisenCore.IsSpellInRage(name))
            {
                MoveToPos(me, target);
            }
            else
            {
                AmeisenCore.InteractWithGUID(
                    target.pos,
                    target.Guid,
                    InteractionType.STOP);
            }
            FaceTarget(me, target);
            AmeisenCore.CastSpellByName(name, onMyself);
            Thread.Sleep(spellInfo.castTime + 100);
        }
Exemple #23
0
        /// <summary>
        /// Move to a node with a max of 10 tries, if we aren't in the node range
        /// after this, there is something fishy going on
        /// </summary>
        /// <param name="targetPosition">position to move to</param>
        private void MoveToNode(Vector3 targetPosition)
        {
            int currentTry = 0;
            while (currentTry < 10 && Utils.GetDistance(Me.pos, targetPosition) > AmeisenDataHolder.Settings.followDistance)
            {
                CheckIfWeAreStuckIfYesJump(targetPosition, LastPosition);

                if (targetPosition.Z == 0)
                {
                    targetPosition.Z = Me.pos.Z;
                }

                AmeisenCore.MovePlayerToXYZ(targetPosition, InteractionType.MOVE);
                Thread.Sleep(100);

                Me.Update();
                LastPosition = Me.pos;
                currentTry++;
            }
        }
Exemple #24
0
        public void UpdateInventory()
        {
            InventoryItems = new List <InventoryItem>();
            string inventoryItemsJson = AmeisenCore.GetLocalizedText(GetInventoryItems.Lua(), GetInventoryItems.OutVar());
            List <RawInventoryItem> rawInventoryItems = new List <RawInventoryItem>();

            try
            {
                rawInventoryItems = JsonConvert.DeserializeObject <List <RawInventoryItem> >(inventoryItemsJson);
            }
            catch
            {
                InventoryItems = new List <InventoryItem>();
                AmeisenLogger.Instance.Log(LogLevel.ERROR, $"Failes to parse InventoryItems", this);
            }

            foreach (RawInventoryItem rawInventoryItem in rawInventoryItems)
            {
                InventoryItems.Add(new InventoryItem(rawInventoryItem));
            }
        }
Exemple #25
0
        public void UpdateSpells()
        {
            Spells = new List <Spell>();
            string          spellJson = AmeisenCore.GetLocalizedText(GetSpells.Lua(), GetSpells.OutVar());
            List <RawSpell> rawSpells = new List <RawSpell>();

            try
            {
                rawSpells = JsonConvert.DeserializeObject <List <RawSpell> >(spellJson);
            }
            catch
            {
                InventoryItems = new List <InventoryItem>();
                AmeisenLogger.Instance.Log(LogLevel.ERROR, $"Failes to parse Spells", this);
            }

            foreach (RawSpell rawSpell in rawSpells)
            {
                Spells.Add(new Spell(rawSpell));
            }
        }
Exemple #26
0
        private void SellTrashAtUnit(RememberedUnit unit, bool mammoth = false)
        {
            if (mammoth)
            {
                AmeisenCore.TargetUnitByName("Gnimo");
            }
            else
            {
                AmeisenCore.TargetUnitByName(unit.Name);
            }

            if (Target != null)
            {
                Target.Update();
                AmeisenCore.LuaDoString("InteractUnit(\"target\");");
                Thread.Sleep(500);
                AmeisenCore.SellAllGrayItems();
                AmeisenLogger.Instance.Log(LogLevel.DEBUG, "Sold all gray stuff", this);
                Thread.Sleep(1000);
            }
        }
        /// <summary>
        /// Starts the ObjectUpdates
        /// </summary>
        public void Start()
        {
            ActiveWoWObjects = AmeisenCore.GetAllWoWObjects();

            foreach (WowObject t in ActiveWoWObjects)
            {
                if (t.GetType() == typeof(Me))
                {
                    Me = (Me)t;
                    break;
                }
            }

            objectUpdateTimer          = new System.Timers.Timer(AmeisenDataHolder.Settings.dataRefreshRate);
            objectUpdateTimer.Elapsed += ObjectUpdateTimer;
            objectUpdateThread         = new Thread(new ThreadStart(StartTimer));
            objectUpdateThread.Start();

            nodeDBUpdateTimer          = new System.Timers.Timer(AmeisenDataHolder.Settings.dataRefreshRate);
            nodeDBUpdateTimer.Elapsed += NodeDBUpdateTimer;
            nodeDBUpdateTimer.Start();
        }
Exemple #28
0
        public void UpdateFromItem(Item item)
        {
            // Experimental! but should be 100x faster
            string itemStatsJson = AmeisenCore.GetLocalizedText(GetItemStats.Lua(item.Slot), GetItemStats.OutVar());

            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"GetItemStatsLuaJSON: {itemStatsJson}", this);
            // parse this JSON
            try
            {
                RawStats rawItem = JsonConvert.DeserializeObject <RawStats>(itemStatsJson);
                Armor       = rawItem.armor;
                Strenght    = rawItem.strenght;
                Agility     = rawItem.agility;
                Stamina     = rawItem.stamina;
                Intellect   = rawItem.intellect;
                Spirit      = rawItem.spirit;
                Attackpower = rawItem.attackpower;
                Spellpower  = rawItem.spellpower;
                Mana        = rawItem.mana;
            }
            catch { }
        }
Exemple #29
0
        /// <summary>
        /// Check the LuaUnit for its reaction to you
        /// </summary>
        /// <param name="luaUnit">luaunit to check</param>
        /// <returns>wether the unit reacts friendly or not</returns>
        public static bool IsFriendly(LuaUnit luaUnit)
        {
            UnitReaction reaction = AmeisenCore.GetUnitReaction(luaUnit);

            switch (reaction)
            {
            case UnitReaction.FRIENDLY:
                return(true);

            case UnitReaction.HONORED:
                return(true);

            case UnitReaction.REVERED:
                return(true);

            case UnitReaction.EXALTED:
                return(true);

            default:
                return(false);
            }
        }
Exemple #30
0
        /// <summary>
        /// Move into a spell range
        /// </summary>
        /// <param name="me">me object</param>
        /// <param name="unitToAttack">unit to attack</param>
        /// <param name="distance">distance how close you want to get to the target</param>
        public static void MoveInRange(Me me, Unit unitToAttack, double distance)
        {
            int count = 0;

            while (Utils.GetDistance(me.pos, unitToAttack.pos) > distance &&
                   count < 5)
            {
                AmeisenCore.MovePlayerToXYZ(
                    unitToAttack.pos,
                    InteractionType.MOVE,
                    distance);
                me.Update();
                unitToAttack.Update();

                Thread.Sleep(50);
                count++;
            }

            AmeisenCore.InteractWithGUID(
                unitToAttack.pos,
                unitToAttack.Guid,
                InteractionType.STOP);
        }