Exemple #1
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);
                }
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
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);
        }