Beispiel #1
0
        public override void Run()
        {
            MountTask.DismountMount();
            if (ObjectManager.ObjectManager.Me.IsMounted)
            {
                return;
            }
            Logging.Write("Player Attack " + _unit.Name + " (lvl " + _unit.Level + ")");
            UInt128 unkillableMob = Fight.StartFight(_unit.Guid);

            if (!_unit.IsDead && unkillableMob != 0 && _unit.HealthPercent == 100.0f)
            {
                Logging.Write("Can't reach " + _unit.Name + ", blacklisting it.");
                nManagerSetting.AddBlackList(unkillableMob, 2 * 60 * 1000); // 2 minutes
            }
            else if (_unit.IsDead)
            {
                Statistics.Kills++;
                Thread.Sleep(Usefuls.Latency + 1000);
                while (ObjectManager.ObjectManager.Me.InCombat &&
                       ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0)
                {
                    Thread.Sleep(50);
                }
                Fight.StopFight();
            }
        }
        public override void Run()
        {
            if (ObjectManager.ObjectManager.Me.InCombat && ObjectManager.ObjectManager.Me.IsMounted)
            {
                MountTask.DismountMount();
            }
            else if (ObjectManager.ObjectManager.Me.IsMounted)
            {
                Logging.Write("Please dismount as soon as is possible ! This product is passive when you are not yet in combat.");
                Thread.Sleep(500);
            }
            Logging.Write("Currently attacking " + _unit.Name + " (lvl " + _unit.Level + ")");
            UInt128 unkillableMob = Fight.StartFightDamageDealer(_unit.Guid);

            if (!_unit.IsDead && unkillableMob != 0)
            {
                Logging.Write("Can't reach " + _unit.Name + ", blacklisting it.");
                return;
            }
            if (_unit.IsDead)
            {
                Statistics.Kills++;
                _unit = AcquireTarger();
                if (_unit.IsValid)
                {
                    Run();
                }
                return;
            }
        }
    public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force)
    {
        // targetfinder function already checks that they are in LoS
        if (unit == null || !spell.IsKnown() || !spell.CanCast() || !unit.IsValid || unit.IsDead)
        {
            return(false);
        }

        if (wManager.wManagerSetting.CurrentSetting.IgnoreFightGoundMount && ObjectManager.Me.IsMounted)
        {
            return(false);
        }

        MountTask.DismountMount();

        if (ObjectManager.Me.IsCasting() && !force)
        {
            return(false);
        }

        if (ObjectManager.Me.GetMove && spell.Spell.CastTime > 0)
        {
            //MovementManager.StopMove();
            MovementManager.StopMoveTo(false, Usefuls.Latency + 500);
        }

        if (force)
        {
            Lua.LuaDoString("SpellStopCasting();");
        }

        if (AreaSpells.Contains(spell.Spell.Name))
        {
            /*spell.Launch(true, true, false);
             *  Thread.Sleep(Usefuls.Latency + 50);
             *  ClickOnTerrain.Pulse(unit.Position);*/

            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            //SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position);
            ClickOnTerrain.Pulse(unit.Position);
        }
        else
        {
            if (unit.Guid != ObjectManager.Me.Guid)
            {
                //FaceUnit(unit);
                MovementManager.Face(unit);
            }

            _disableTargeting = true;
            WoWUnit temp = ObjectManager.Target;
            TargetUnit(unit);
            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            TargetUnit(temp);
            //SpellManager.CastSpellByNameOn(spell.FullName(), GetLuaId(unit));
            //Interact.InteractObject also works and can be used to target another unit
            _disableTargeting = false;
        }
        return(true);
    }
Beispiel #4
0
        // Pull
        public static bool Pull(Cast cast, bool alwaysPull, List <AIOSpell> spells)
        {
            AIOSpell pullSpell = spells.Find(s => s != null && s.IsSpellUsable && s.KnownSpell);

            if (pullSpell == null)
            {
                RangeManager.SetRangeToMelee();
                return(false);
            }

            WoWUnit closestHostileFromTarget = GetClosestHostileFrom(ObjectManager.Target, 20);

            if (closestHostileFromTarget == null && !alwaysPull)
            {
                RangeManager.SetRangeToMelee();
                return(false);
            }

            float pullRange = pullSpell.MaxRange;

            if (ObjectManager.Target.GetDistance > pullRange - 2 ||
                ObjectManager.Target.GetDistance < 6 ||
                TraceLine.TraceLineGo(ObjectManager.Target.Position))
            {
                RangeManager.SetRangeToMelee();
                return(false);
            }

            if (closestHostileFromTarget != null && RangeManager.GetRange() < pullRange)
            {
                Logger.Log($"Pulling from distance (hostile unit {closestHostileFromTarget.Name} is too close)");
            }

            if (ObjectManager.Me.IsMounted)
            {
                MountTask.DismountMount();
            }

            RangeManager.SetRange(pullRange - 1);
            Thread.Sleep(300);

            if (cast.OnTarget(pullSpell))
            {
                Thread.Sleep(500);
                if (pullSpell.GetCurrentCooldown > 0)
                {
                    Usefuls.WaitIsCasting();
                    if (pullSpell.Name == "Shoot" || pullSpell.Name == "Throw" || pullSpell.Name == "Avenger's Shield")
                    {
                        Thread.Sleep(1500);
                    }
                    return(true);
                }
            }

            return(false);
        }
Beispiel #5
0
        public static void DoTasks()
        {
            MimesisHelpers.MimesisEvent evt = GetBestTask;
            if (evt.eType == MimesisHelpers.eventType.none)
            {
                return; // "new instance of MimesisEvent" => nothing to do
            }
            switch (evt.eType)
            {
            case MimesisHelpers.eventType.pickupQuest:
            case MimesisHelpers.eventType.turninQuest:
                List <WoWUnit> listU = ObjectManager.GetWoWUnitByEntry(evt.EventValue1);
                if (listU.Count > 0)
                {
                    WoWUnit u       = listU[0];
                    Npc     quester = new Npc();
                    quester.Entry    = evt.EventValue1;
                    quester.Position = u.Position;
                    quester.Name     = u.Name;
                    bool cancelPickUp = false;
                    if (evt.eType == MimesisHelpers.eventType.pickupQuest && !Quest.GetQuestCompleted(evt.EventValue2) && !Quest.GetLogQuestId().Contains(evt.EventValue2))
                    {
                        Quest.QuestPickUp(ref quester, evt.EventString1, evt.EventValue2, out cancelPickUp);
                    }
                    else if (evt.eType == MimesisHelpers.eventType.turninQuest && Quest.GetLogQuestId().Contains(evt.EventValue2) && Quest.GetLogQuestIsComplete(evt.EventValue2))
                    {
                        Quest.QuestTurnIn(ref quester, Quest.GetLogQuestTitle(evt.EventValue2), evt.EventValue2);
                    }
                    CleanQuestEvents(cancelPickUp);
                }
                break;

            case MimesisHelpers.eventType.mount:
                switch ((MountCapacity)evt.EventValue1)
                {
                case MountCapacity.Ground:
                    MountTask.MountingGroundMount(true);
                    break;

                case MountCapacity.Fly:
                    MountTask.MountingFlyingMount(true);
                    break;

                case MountCapacity.Swimm:
                    MountTask.MountingAquaticMount(true);
                    break;

                default:
                    MountTask.DismountMount(true);
                    break;
                }
                myTaskList.Remove(evt);
                break;
            }
        }
Beispiel #6
0
        private static Npc DoSpawnRobot(string robot, Npc.NpcType type, bool checkOnly = false)
        {
            int robotItemId;
            int robotEntryId;
            int gossipOption = 0;

            switch (robot)
            {
            case "74A":
                robotItemId  = 18232;
                robotEntryId = 14337;
                break;

            case "110G":
                robotItemId  = 34113;
                robotEntryId = 24780;
                break;

            case "Jeeves":
                robotItemId  = 49040;
                robotEntryId = 35642;
                gossipOption = 2;
                break;

            default:
                return(null);
            }
            if (!checkOnly)
            {
                MountTask.DismountMount();
                ItemsManager.UseItem(ItemsManager.GetItemNameById(robotItemId));
                Thread.Sleep(2000);
            }
            WoWUnit unitRobot = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(robotEntryId));

            if (!unitRobot.IsValid || !unitRobot.IsAlive)
            {
                return(null);
            }
            Npc npcRobot = new Npc
            {
                Entry          = unitRobot.Entry,
                Position       = unitRobot.Position,
                Name           = unitRobot.Name,
                ContinentIdInt = Usefuls.ContinentId,
                Faction        = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde"
                    ? Npc.FactionType.Horde
                    : Npc.FactionType.Alliance,
                SelectGossipOption = gossipOption,
                Type = type
            };

            return(npcRobot);
        }
Beispiel #7
0
 public override void Run()
 {
     MountTask.DismountMount();
     Heal.StartHealBot();
     while (ObjectManager.ObjectManager.Me.HealthPercent < 100 ||
            (Party.IsInGroup() &&
             Party.GetPartyPlayersGUID()
             .Any(playerInMyParty => new WoWUnit((uint)playerInMyParty).HealthPercent < 100)))
     {
         Thread.Sleep(200);
     }
     Heal.StopHeal();
 }
Beispiel #8
0
        public override void Run()
        {
            if (ObjectManager.ObjectManager.Me.IsMounted)
            {
                MovementManager.FindTarget(_unit, CombatClass.GetAggroRange);
                Thread.Sleep(100);
                if (MovementManager.InMovement)
                {
                    return;
                }
                MountTask.DismountMount();
            }
            Logging.Write("Player Attacked by " + _unit.Name + " (lvl " + _unit.Level + ")");
            UInt128 unkillableMob = Fight.StartFight(_unit.Guid);

            if (!_unit.IsDead && unkillableMob != 0 && _unit.HealthPercent == 100.0f)
            {
                if (!nManagerSetting.IsBlackListed(unkillableMob))
                {
                    // Don't re-blacklist it if it was temporary blacklisted for Evading.
                    Logging.Write("Blacklisting " + _unit.Name);
                    nManagerSetting.AddBlackList(unkillableMob, 2 * 60 * 1000); // 2 minutes
                }
            }
            else if (_unit.IsDead)
            {
                Statistics.Kills++;
                if (Products.Products.ProductName == "Quester" && !_unit.IsTapped)
                {
                    Quest.KilledMobsToCount.Add(_unit.Entry); // we may update a quest requiring killing this unit
                }
                if (ObjectManager.ObjectManager.GetNumberAttackPlayer() <= 0)
                {
                    Thread.Sleep(Usefuls.Latency + 500);
                }

                while (!ObjectManager.ObjectManager.Me.IsMounted && ObjectManager.ObjectManager.Me.InCombat && ObjectManager.ObjectManager.GetNumberAttackPlayer() <= 0)
                {
                    Thread.Sleep(150);
                }
                Fight.StopFight();
            }
        }
 public override void Run()
 {
     Logging.Write("AutoItemCombiner is now running, trying to combines all items...");
     if (Usefuls.IsFlying)
     {
         MountTask.DismountMount();
         Thread.Sleep(400);
         MountTask.DismountMount();
         Thread.Sleep(400);
     }
     for (int i = _loadedCombinables.Items.Count - 1; i > 0; i--)
     {
         if (Usefuls.BadBottingConditions || Usefuls.ShouldFight)
         {
             return;
         }
         var combinable = _loadedCombinables.Items[i];
         if (!_tempItemStock.ContainsKey(combinable.ItemId) || _tempItemStock[combinable.ItemId] <= combinable.PerAmount)
         {
             continue;
         }
         int   remainder;
         int   amountToCombine = System.Math.DivRem(ItemsManager.GetItemCount(combinable.ItemId), combinable.PerAmount, out remainder);
         Timer t = new Timer(amountToCombine * 1000);
         while (System.Math.DivRem(ItemsManager.GetItemCount(combinable.ItemId), combinable.PerAmount, out remainder) > 0)
         {
             if (Usefuls.BadBottingConditions || Usefuls.ShouldFight)
             {
                 return;
             }
             ItemsManager.UseItem(combinable.ItemId);
             Thread.Sleep(50 + Usefuls.Latency);
             if (t.IsReady)
             {
                 break;
             }
         }
     }
     _remakeTimer.Reset();
 }
Beispiel #10
0
 // Token: 0x06000017 RID: 23
 private static void discoverTaxi(FlightMasterDB flightMasterToDiscover)
 {
     FNVFlightMasterSettings.Load();
     Main.fillDB();
     if (GoToTask.ToPosition(flightMasterToDiscover.position, 3.5f, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore))
     {
         GoToTask.ToPosition(flightMasterToDiscover.position, 3.5f, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore);
         if (GoToTask.ToPositionAndIntecractWithNpc(flightMasterToDiscover.position, flightMasterToDiscover.NPCId, -1, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore, false))
         {
             wManagerSetting.ClearBlacklistOfCurrentProductSession();
             GoToTask.ToPositionAndIntecractWithNpc(flightMasterToDiscover.position, flightMasterToDiscover.NPCId, -1, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore, false);
             if (ObjectManager.Me.IsMounted)
             {
                 MountTask.DismountMount(false, false, 100);
             }
             Usefuls.SelectGossipOption(GossipOptionsType.taxi);
             Thread.Sleep(Usefuls.Latency + 1500);
             while (Main._updateNodes)
             {
                 Logging.Write("[tbcFlightMaster]: Taxi node update in progress...");
                 Thread.Sleep(10000);
             }
             Logging.Write("[tbcFlightMaster]: Flight Master " + flightMasterToDiscover.name + " discovered");
             flightMasterToDiscover.alreadyDiscovered = true;
             FNVFlightMasterSettings.flightMasterSaveChanges(flightMasterToDiscover, true);
             Thread.Sleep(Usefuls.Latency * 5);
             Main.timer                = 0;
             Main.discoverTaxiNode     = null;
             Main._taxiToDiscover      = false;
             Main._discoverInProessing = false;
             Main._discoverTaxiTimer   = true;
             Main.Reenable();
             return;
         }
     }
     Main._discoverInProessing = false;
 }
Beispiel #11
0
 // Token: 0x06000016 RID: 22
 private static void takeTaxi(FlightMasterDB from, FlightMasterDB to)
 {
     if (GoToTask.ToPosition(from.position, 3.5f, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore))
     {
         if (GoToTask.ToPositionAndIntecractWithNpc(from.position, from.NPCId, -1, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore, false))
         {
             while (!ObjectManager.Me.IsOnTaxi)
             {
                 if (ObjectManager.Me.IsMounted)
                 {
                     MountTask.DismountMount(false, false, 100);
                 }
                 Usefuls.SelectGossipOption(GossipOptionsType.taxi);
                 Thread.Sleep(Usefuls.Latency + 1500);
                 while (Main._updateNodes)
                 {
                     Logging.Write("[tbcFlightMaster]: Taxi node update in progress, waiting...");
                     Thread.Sleep(10000);
                 }
                 int num = Lua.LuaDoString <int>("for i=0,30 do if string.find(TaxiNodeName(i),\'" + to.name.Replace("'", "\\'") + "\') then return i end end", "");
                 Lua.LuaDoString("TakeTaxiNode(" + num + ")", false);
                 Logging.Write("[tbcFlightMaster]: Taking Taxi from " + from.name + " to " + to.name);
                 Thread.Sleep(Usefuls.Latency + 500);
                 Keyboard.DownKey(Memory.WowMemory.Memory.WindowHandle, Keys.Escape);
                 Thread.Sleep(Usefuls.Latency + 2500);
                 if (!ObjectManager.Me.IsOnTaxi)
                 {
                     GoToTask.ToPositionAndIntecractWithNpc(from.position, from.NPCId, -1, false, (object context) => Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause && !Conditions.IsAttackedAndCannotIgnore, false);
                 }
             }
             if (ObjectManager.Me.IsOnTaxi)
             {
                 Main.waitFlying(to.name);
             }
         }
     }
 }
Beispiel #12
0
        public override void Run()
        {
            try
            {
                if (MovementManager.InMovement)
                {
                    return;
                }

                // Get if this zone is last zone
                if (LastZone != digsitesZone.id)
                {
                    _nbTryFarmInThisZone = 0; // Reset nb try farm if zone is not last zone
                }
                LastZone = digsitesZone.id;   // Set lastzone

                // Solving Every X Min
                if (timerAutoSolving == null)
                {
                    timerAutoSolving = new Timer(SolvingEveryXMin * 1000 * 60);
                }
                if (timerAutoSolving.IsReady && !ObjectManager.ObjectManager.Me.IsDeadMe &&
                    !ObjectManager.ObjectManager.Me.InCombat)
                {
                    MovementManager.StopMove();
                    LongMove.StopLongMove();
                    if (Archaeology.SolveAllArtifact(UseKeystones) > 0)
                    {
                        if (CrateRestored)
                        {
                            Archaeology.CrateRestoredArtifact();
                        }
                    }
                    timerAutoSolving = new Timer(SolvingEveryXMin * 1000 * 60);
                }

                if (MovementManager.InMovement)
                {
                    return;
                }

                // Loop farm in zone // We must check Me.IsIndoor because no archeology is indoor
                int nbStuck = 0; // Nb of stuck direct
                try
                {
                    if (myState != LocState.LocalMove)
                    {
                        MountTask.DismountMount();
                    }

                    ObjectManager.WoWGameObject t =
                        ObjectManager.ObjectManager.GetNearestWoWGameObject(
                            ObjectManager.ObjectManager.GetWoWGameObjectByEntry(Archaeology.ArchaeologyItemsFindList));
                    if (t.IsValid) // If found then loot
                    {
                        nbCastSurveyError  = 0;
                        _lastGreenPosition = new Point();
                        _AntiPingPong      = false;
                        _greenCount        = 0;
                        if (myState == LocState.Looting)
                        {
                            if (timerLooting != null && timerLooting.IsReady)
                            {
                                MovementsAction.Jump();
                                Thread.Sleep(1500);
                            }
                            else
                            {
                                return;
                            }
                        }
                        bool         ValidPath;
                        List <Point> points = PathFinder.FindPath(t.Position, out ValidPath, false);
                        if (!ValidPath)
                        {
                            points.Add(t.Position);
                        }
                        MovementManager.Go(points);
                        if (nbLootAttempt > 2)
                        {
                            MovementManager.StopMove();
                            LongMove.StopLongMove();
                            if (Archaeology.SolveAllArtifact(UseKeystones) == 0)
                            {
                                nManagerSetting.AddBlackList(t.Guid); // bugged artifacts not lootable
                                Logging.Write("Black-listing bugged artifact");
                            }
                            else if (CrateRestored)
                            {
                                Archaeology.CrateRestoredArtifact();
                            }
                            nbLootAttempt = 0;
                            return;
                        }
                        Logging.Write("Loot " + t.Name);
                        Timer timer = new Timer(1000 * Math.DistanceListPoint(points) / 3);

                        while (MovementManager.InMovement && !timer.IsReady && t.GetDistance > 3.5f)
                        {
                            Thread.Sleep(100);
                            if (ObjectManager.ObjectManager.Me.InInevitableCombat || ObjectManager.ObjectManager.Me.IsDeadMe)
                            {
                                return;
                            }
                        }
                        MovementManager.StopMove(); // avoid a red wow error
                        Thread.Sleep(150);
                        Interact.InteractWith(t.GetBaseAddress);
                        while (ObjectManager.ObjectManager.Me.IsCast)
                        {
                            Thread.Sleep(100);
                        }
                        if (ObjectManager.ObjectManager.Me.InCombat)
                        {
                            return;
                        }
                        Statistics.Farms++;
                        nbLootAttempt++;
                        myState = LocState.Looting;
                        if (timerLooting == null)
                        {
                            timerLooting = new Timer(1000 * 5);
                        }
                        else
                        {
                            timerLooting.Reset();
                        }
                        return;
                    }
                    if (_nbTryFarmInThisZone > MaxTryByDigsite) // If try > config try black list
                    {
                        nbLootAttempt = 0;
                        BlackListDigsites.Add(digsitesZone.id);
                        Logging.Write("Black List Digsite: " + digsitesZone.name);
                        myState           = LocState.LocalMove;
                        nbCastSurveyError = 0;
                        return;
                    }
                    bool moreMovementNeeded = false;
                    if (qPOI != null && !qPOI.ValidPoint && qPOI.Center.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) < 40.0f)
                    {
#pragma warning disable 168
                        // We call qPOI.MiddlePoint to make the WoWQuestPOIPoint instance compute the middle point, but I don't care were it is
                        Point p = qPOI.MiddlePoint; // we are near enough to compute it
#pragma warning restore 168
                        if (Usefuls.IsFlying)
                        {
                            moreMovementNeeded = true;
                            MovementManager.StopMove();
                        }
                    }
                    // Go To Zone
                    if (qPOI != null && (moreMovementNeeded || !qPOI.IsInside(ObjectManager.ObjectManager.Me.Position)))
                    {
                        if (MountTask.GetMountCapacity() == MountCapacity.Feet || MountTask.GetMountCapacity() == MountCapacity.Ground)
                        {
                            int LodestoneID = 117389;
                            if (!_travelDisabled && ItemsManager.GetItemCount(LodestoneID) > 0 &&
                                Usefuls.RealContinentId == 1116 &&
                                qPOI.Center.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) > 3000f)
                            {
                                ObjectManager.WoWItem item = ObjectManager.ObjectManager.GetWoWItemById(LodestoneID);
                                if (item != null && item.IsValid && !ItemsManager.IsItemOnCooldown(LodestoneID) && ItemsManager.IsItemUsable(LodestoneID))
                                {
                                    Logging.Write("Using a Draenor Archaeologist's Lodestone");
                                    Products.Products.InManualPause = true; // Prevent triggering "Player teleported"
                                    ItemsManager.UseItem(LodestoneID);
                                    Thread.Sleep(3000 + Usefuls.Latency);
                                    digsitesZone = new Digsite(); // Reset the choice made
                                    return;
                                }
                            }
                            Logging.Write("Not inside, then go to Digsite " + digsitesZone.name);
                            Point me = ObjectManager.ObjectManager.Me.Position;
                            if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f)
                            {
                                if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                                {
                                    _travelLocation = Products.Products.TravelFrom;
                                    Products.Products.TravelRegenerated = false;
                                }
                            }
                            if ((_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled && !Usefuls.IsFlying)
                            {
                                MovementManager.StopMove();
                                Logging.Write("Calling travel system to go to digsite " + digsitesZone.name + " (" + digsitesZone.id + ")...");
                                Products.Products.TravelToContinentId   = Usefuls.ContinentId;
                                Products.Products.TravelTo              = qPOI.Center;
                                Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                                Products.Products.TravelFrom            = me;
                                // Pass the check for valid destination as a lambda
                                Products.Products.TargetValidationFct = qPOI.IsInside;
                                _travelLocation = Products.Products.TravelFrom;
                                return;
                            }
                            if (_travelLocation.DistanceTo(me) <= 0.1f)
                            {
                                _travelDisabled = true;
                            }
                            List <Point> newPath;
                            newPath = PathFinder.FindPath(qPOI.Center);
                            MovementManager.Go(newPath);
                        }
                        else if (qPOI.ValidPoint)
                        {
                            if (moreMovementNeeded || !qPOI.IsInside(ObjectManager.ObjectManager.Me.Position))
                            {
                                Point destination = new Point(qPOI.MiddlePoint);
                                destination.Type = "flying";
                                if (moreMovementNeeded)
                                {
                                    Logging.Write("Landing on the digsite");
                                }
                                else
                                {
                                    Logging.Write("Not inside, then go to Digsite " + digsitesZone.name + "; X: " + destination.X + "; Y: " + destination.Y + "; Z: " + (int)destination.Z);
                                }
                                MovementManager.Go(new List <Point>(new[] { destination })); // MoveTo Digsite
                            }
                        }
                        else
                        {
                            // here we need to go to center, THEN compute middle point
                            Point destination = qPOI.Center;
                            destination.Z   += 40.0f;
                            destination.Type = "flying";
                            Logging.Write("Go to Digsite " + digsitesZone.name + "; X: " + destination.X + "; Y: " + destination.Y + "; Z: " + (int)destination.Z);
                            MovementManager.Go(new List <Point>(new[] { destination })); // MoveTo Digsite
                        }
                        myState = LocState.LocalMove;
                        return;
                    }
                    // Find loot with Survey
                    nbLootAttempt = 0;
                    t             = ObjectManager.ObjectManager.GetNearestWoWGameObject(
                        ObjectManager.ObjectManager.GetWoWGameObjectByDisplayId(Archaeology.SurveyList));
                    if (t.GetBaseAddress == 0 || myState == LocState.GoingNextPoint ||
                        // recast if we moved even if last is still spawned
                        myState == LocState.Looting)
                    // after we looted we need to recast survey spell, even if the previous one is still spawned
                    {
                        if (!Archaeology.DigsiteZoneIsAvailable(digsitesZone))
                        {
                            return;
                        }

                        if (myState == LocState.LocalMove)
                        {
                            MountTask.DismountMount();
                        }

                        surveySpell.Launch();
                        myState = LocState.Survey;
                        if (ObjectManager.ObjectManager.Me.InCombat)
                        {
                            return;
                        }
                        Thread.Sleep(1750 + Usefuls.Latency); // let's wait a fair bit
                        nbCastSurveyError++;
                        if (nbCastSurveyError > 3)
                        {
                            if (ObjectManager.ObjectManager.Me.Position.DistanceTo2D(qPOI.MiddlePoint) < 5)
                            {
                                // This means we are in a wrong digsite
                                List <Digsite> listDigsitesZone;
                                if (!_inSecondDigSiteWithSameName)
                                {
                                    listDigsitesZone = Archaeology.GetDigsitesZoneAvailable(t.Name);
                                }
                                else // very very rare case I had: back to the first digsite with same name after the 2nd one
                                {
                                    listDigsitesZone = Archaeology.GetDigsitesZoneAvailable();
                                }
                                foreach (Digsite dg in listDigsitesZone)
                                {
                                    if (dg.name == t.Name)
                                    {
                                        digsitesZone = dg;
                                    }
                                }
                                WoWResearchSite OneSite;
                                if (!_inSecondDigSiteWithSameName)
                                {
                                    OneSite = WoWResearchSite.FromName(digsitesZone.name, true);
                                }
                                else
                                {
                                    OneSite = WoWResearchSite.FromName(digsitesZone.name, false);
                                }
                                qPOI = WoWQuestPOIPoint.FromSetId(OneSite.Record.QuestIdPoint);
                                _inSecondDigSiteWithSameName = !_inSecondDigSiteWithSameName;
                                nbCastSurveyError            = 0;
                                return;
                            }
                            if (MountTask.GetMountCapacity() == MountCapacity.Feet || MountTask.GetMountCapacity() == MountCapacity.Ground)
                            {
                                Logging.Write("Too many errors, then go to Digsite " + digsitesZone.name);
                                List <Point> newPath = PathFinder.FindPath(qPOI.Center);
                                MovementManager.Go(newPath);
                            }
                            else
                            {
                                if (qPOI != null)
                                {
                                    Point destination = qPOI.MiddlePoint;
                                    Logging.Write("Too many errors, then go to Digsite " + digsitesZone.name + "; X: " + destination.X + "; Y: " + destination.Y + "; Z: " + (int)destination.Z);
                                    MovementManager.Go(new List <Point>(new[] { destination })); // MoveTo Digsite
                                }
                            }
                            nbCastSurveyError = 0;
                            return;
                        }
                        _nbTryFarmInThisZone++;
                        return;
                    }
                    if (myState == LocState.GoingNextPoint)
                    {
                        return;
                    }
                    nbCastSurveyError = 0; // Reset try cast survey
                    if ((ObjectManager.ObjectManager.Me.InCombat &&
                         !(ObjectManager.ObjectManager.Me.IsMounted &&
                           (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))))
                    {
                        return;
                    }
                    Point p0;
                    float angle;
                    {
                        Point p;
                        float distance, distanceMin, distanceMax, decrement, increment;
                        if (t.DisplayId == 10103) // Survey Tool (Red) 100 yard
                        {
                            distance           = 90f;
                            distanceMin        = 20f;
                            distanceMax        = 210f;
                            increment          = 8f;
                            decrement          = 8f;
                            _lastGreenPosition = new Point();
                            _AntiPingPong      = false;
                            _greenCount        = 0;
                        }
                        else if (t.DisplayId == 10102) // Survey Tool (Yellow) 50 yard
                        {
                            distance           = 46f;
                            distanceMin        = 20f;
                            distanceMax        = 60f;
                            increment          = 7f;
                            decrement          = 6.5f;
                            _lastGreenPosition = new Point();
                            _AntiPingPong      = false;
                            _greenCount        = 0;
                        }
                        else // Survey Tool (Green) 25 yard (t.DisplayId == 10101)
                        {
                            _greenCount++;
                            increment = 4f;
                            if (_greenCount >= 10)
                            {
                                _greenCount        = 0;
                                _lastGreenPosition = new Point();
                                Point destination = qPOI.MiddlePoint;
                                _AntiPingPong = false;
                                Logging.Write("Stuck, then go to Digsite " + digsitesZone.name + "; X: " + destination.X + "; Y: " + destination.Y + "; Z: " + (int)destination.Z);
                                MountTask.Mount(true, true);
                                MovementManager.Go(new List <Point>(new[] { destination })); // MoveTo Digsite
                                return;
                            }
                            if (_AntiPingPong)
                            {
                                Logging.Write("Ping-pong detected, shortening the distance");
                                distance    = 11f;
                                distanceMin = 6f;
                                distanceMax = 16f;
                                decrement   = 4f;
                            }
                            else
                            {
                                distance    = 19f;
                                distanceMin = 7f;
                                distanceMax = 41f;
                                decrement   = 3f;
                            }
                        }
                        {
                            float d = distance;
                            p0    = new Point(t.Position);
                            angle = t.Orientation;
                            p     = Math.GetPosition2DOfAngleAndDistance(p0, angle, d);
                            p.Z   = PathFinder.GetZPosition(p, true);
                            bool valid;
                            PathFinder.FindPath(p, out valid);
                            if (qPOI != null)
                            {
                                bool IamOutOfWater = IsPointOutOfWater(ObjectManager.ObjectManager.Me.Position);
                                while (!valid || p.Z == 0 || !qPOI.IsInside(p) || !(!IamOutOfWater || IsPointOutOfWater(p)))
                                {
                                    if (d + increment > distanceMax)
                                    {
                                        break;
                                    }
                                    d += increment;
                                    Point newone = Math.GetPosition2DOfAngleAndDistance(p0, angle, d);
                                    if (qPOI.IsInside(newone))
                                    {
                                        p    = new Point(newone);
                                        p.Z += d / 10.0f; // just so that GetZ don't find caves too easiely
                                        p.Z  = PathFinder.GetZPosition(p, true);
                                        if (p.Z == 0)     // if p == 0 we don't care about the path
                                        {
                                            valid = false;
                                        }
                                        else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                        {
                                            valid = false;
                                        }
                                    }
                                    // Since these direction are approximate, also search in a pi/5 angle
                                    if (!valid /* && t.DisplayId == 10103*/)
                                    {
                                        float angleplus = Math.FixAngle(angle + ((float)System.Math.PI / 10f));
                                        newone = Math.GetPosition2DOfAngleAndDistance(p0, angleplus, d);
                                        p      = new Point(newone);
                                        p.Z   += d / 10.0f; // just so that GetZ don't find caves too easiely
                                        p.Z    = PathFinder.GetZPosition(p, true);
                                        if (p.Z == 0)       // if p == 0 we don't care about the path
                                        {
                                            valid = false;
                                        }
                                        else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                        {
                                            valid = false;
                                        }
                                        if (valid)
                                        {
                                            Logging.Write("Angles+ for distance " + d);
                                        }
                                    }
                                    if (!valid /* && t.DisplayId == 10103*/)
                                    {
                                        float angleminus = Math.FixAngle(angle - ((float)System.Math.PI / 10f));
                                        newone = Math.GetPosition2DOfAngleAndDistance(p0, angleminus, d);
                                        p      = new Point(newone);
                                        p.Z   += d / 10.0f; // just so that GetZ don't find caves too easiely
                                        p.Z    = PathFinder.GetZPosition(p, true);
                                        if (p.Z == 0)       // if p == 0 we don't care about the path
                                        {
                                            valid = false;
                                        }
                                        else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                        {
                                            valid = false;
                                        }
                                        if (valid)
                                        {
                                            Logging.Write("Angles- for distance " + d);
                                        }
                                    }
                                }
                                if (!valid || p.Z == 0 || !qPOI.IsInside(p) || !(!IamOutOfWater || IsPointOutOfWater(p)))
                                {
                                    d = distance;
                                    while (!valid || p.Z == 0 || !qPOI.IsInside(p) || !(!IamOutOfWater || IsPointOutOfWater(p)))
                                    {
                                        if (d - decrement < distanceMin)
                                        {
                                            break;
                                        }
                                        d -= decrement;
                                        Point newone = Math.GetPosition2DOfAngleAndDistance(p0, angle, d);
                                        if (qPOI.IsInside(newone))
                                        {
                                            p    = new Point(newone);
                                            p.Z += d / 10.0f; // just so that the the GetZ don't find caves too easiely
                                            p.Z  = PathFinder.GetZPosition(p, true);
                                            if (p.Z == 0)     // if p == 0 we don't care about the path
                                            {
                                                valid = false;
                                            }
                                            else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                            {
                                                valid = false;
                                            }
                                        }
                                        // Since these direction are approximate, also search in a pi/5 angle
                                        if (!valid /* && t.DisplayId == 10103*/)
                                        {
                                            float angleplus = Math.FixAngle(angle + ((float)System.Math.PI / 10f));
                                            newone = Math.GetPosition2DOfAngleAndDistance(p0, angleplus, d);
                                            p      = new Point(newone);
                                            p.Z   += d / 10.0f; // just so that GetZ don't find caves too easiely
                                            p.Z    = PathFinder.GetZPosition(p, true);
                                            if (p.Z == 0)       // if p == 0 we don't care about the path
                                            {
                                                valid = false;
                                            }
                                            else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                            {
                                                valid = false;
                                            }
                                            if (valid)
                                            {
                                                Logging.Write("Angles+ for distance " + d);
                                            }
                                        }
                                        if (!valid /* && t.DisplayId == 10103*/)
                                        {
                                            float angleminus = Math.FixAngle(angle - ((float)System.Math.PI / 10f));
                                            newone = Math.GetPosition2DOfAngleAndDistance(p0, angleminus, d);
                                            p      = new Point(newone);
                                            p.Z   += d / 10.0f; // just so that GetZ don't find caves too easiely
                                            p.Z    = PathFinder.GetZPosition(p, true);
                                            if (p.Z == 0)       // if p == 0 we don't care about the path
                                            {
                                                valid = false;
                                            }
                                            else if (Math.DistanceListPoint(PathFinder.FindLocalPath(p, out valid)) > d * 4 && d > 30)
                                            {
                                                valid = false;
                                            }
                                            if (valid)
                                            {
                                                Logging.Write("Angles- for distance " + d);
                                            }
                                        }
                                    }
                                }
                            }
                            // check pingpong but not a second time
                            if (_AntiPingPong)
                            {
                                _AntiPingPong = false;
                            }
                            else if (t.DisplayId == 10101 && _lastGreenPosition.IsValid && p.DistanceTo2D(_lastGreenPosition) <= 7f)
                            {
                                _AntiPingPong = true;
                            }
                            // then remmember the last Green Position
                            if (t.DisplayId == 10101)
                            {
                                _lastGreenPosition = new Point(ObjectManager.ObjectManager.Me.Position);
                            }
                            if (_AntiPingPong)
                            {
                                myState = LocState.LocalMove;
                                return;
                            }
                            Logging.Write("Distance " + d + " selected");
                        }
                        myState = LocState.GoingNextPoint;

                        // Find Path
                        bool         resultB;
                        List <Point> points = PathFinder.FindLocalPath(p, out resultB, false);

                        // If path not found find nearer
                        if (points.Count <= 0)
                        {
                            Point pt = Math.GetPosition2DOfAngleAndDistance(p0, angle, 15);
                            pt.Z   = ObjectManager.ObjectManager.Me.Position.Z;
                            points = PathFinder.FindLocalPath(pt, out resultB, false);
                            if (points.Count > 0 && resultB)
                            {
                                p = new Point(pt);
                            }
                        }

                        // Go to next position
                        if ((!resultB && p.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 10) ||
                            nbStuck >= 2)
                        // Use fly mount
                        {
                            p.Z = PathFinder.GetZPosition(p);

                            if (p.Z == 0)
                            {
                                p.Z = ObjectManager.ObjectManager.Me.Position.Z + 35;
                            }
                            else
                            {
                                p.Z = p.Z + 5.0f;
                            }

                            if ((ObjectManager.ObjectManager.Me.InCombat &&
                                 !(ObjectManager.ObjectManager.Me.IsMounted &&
                                   (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))))
                            {
                                return;
                            }
                            MountTask.Mount(true, true);
                            LongMove.LongMoveByNewThread(p);
                            Timer timer = new Timer(2000 * points[points.Count - 1].DistanceTo(ObjectManager.ObjectManager.Me.Position) / 3);

                            while (LongMove.IsLongMove && !timer.IsReady &&
                                   ObjectManager.ObjectManager.Me.Position.DistanceTo2D(p) > 0.5f)
                            {
                                if ((ObjectManager.ObjectManager.Me.InCombat &&
                                     !(ObjectManager.ObjectManager.Me.IsMounted &&
                                       (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))))
                                {
                                    LongMove.StopLongMove();
                                    return;
                                }
                                Thread.Sleep(100);
                            }
                            LongMove.StopLongMove();
                            while (MovementManager.IsUnStuck)
                            {
                                if (ObjectManager.ObjectManager.Me.IsDeadMe)
                                {
                                    return;
                                }
                                Thread.Sleep(100);
                                LongMove.StopLongMove();
                            }
                            MovementManager.StopMove();
                            MountTask.DismountMount();
// ReSharper disable RedundantAssignment
                            nbStuck = 0;
// ReSharper restore RedundantAssignment
                        }
                        else //  walk to next position
                        {
                            float d1 = Math.DistanceListPoint(points);
                            float d2 = points[0].DistanceTo(points[points.Count - 1]);
                            // here we will try to shortcut the path using a fly mount
                            if (MountTask.GetMountCapacity() == MountCapacity.Fly && d1 > 80 && d1 > (d2 * 2))
                            {
                                Point startpoint = new Point(ObjectManager.ObjectManager.Me.Position);
                                Point endpoint   = new Point(points[points.Count - 1]);
                                float z1         = startpoint.Z;
                                float z2         = endpoint.Z;
                                float zref       = System.Math.Max(z1, z2) + 6.0f;
                                Point pref1      = new Point(startpoint);
                                pref1.Z = zref;
                                Point pref2 = new Point(endpoint);
                                pref2.Z = zref;
                                bool badres = TraceLine.TraceLineGo(startpoint, pref1) ||
                                              TraceLine.TraceLineGo(pref1, pref2) ||
                                              TraceLine.TraceLineGo(pref2, endpoint);
                                if (!badres)
                                {
                                    Logging.Write("Flying to shortcut the path");
                                    MountTask.Mount(true, true);
                                    if (Usefuls.IsFlying) // Failsafe: in case we are indoor don't try
                                    {
                                        points   = new List <Point>();
                                        pref1.Z += 2f;
                                        pref2.Z += 2f;
                                        points.Add(pref1);
                                        points.Add(pref2);
                                        points.Add(endpoint);
                                    }
                                }
                            }
                            if (d1 > nManagerSetting.CurrentSetting.MinimumDistanceToUseMount && !nManagerSetting.CurrentSetting.UseGroundMount)
                            {
                                MountTask.Mount();
                            }
                            if (Usefuls.IsFlying)
                            {
                                for (int i = 0; i < points.Count; i++)
                                {
                                    points[i].Type = "flying";
                                }
                            }
                            MovementManager.Go(points);
                            float d = Math.DistanceListPoint(points) / 3;
                            if (d > 200)
                            {
                                d = 200;
                            }
                            float tm_t = 1000 * d / 2 + 1500;
                            if (Usefuls.IsSwimming)
                            {
                                tm_t /= 0.6f;
                            }
                            Timer timer = new Timer(tm_t);
                            while (MovementManager.InMovement && !timer.IsReady &&
                                   ObjectManager.ObjectManager.Me.Position.DistanceTo2D(p) > 0.5f)
                            {
                                if ((ObjectManager.ObjectManager.Me.InCombat &&
                                     !(ObjectManager.ObjectManager.Me.IsMounted &&
                                       (nManagerSetting.CurrentSetting.IgnoreFightIfMounted || Usefuls.IsFlying))))
                                {
                                    return;
                                }
                                Thread.Sleep(100);
                            }
                            // incremente nbstuck if player is stuck
                            if (ObjectManager.ObjectManager.Me.Position.DistanceTo(t.Position) < 5 ||
                                (MovementManager.InMovement && !ObjectManager.ObjectManager.Me.InInevitableCombat &&
                                 timer.IsReady))
                            {
// ReSharper disable RedundantAssignment
                                nbStuck++;
                            }
// ReSharper restore RedundantAssignment
                            else
                            {
// ReSharper disable RedundantAssignment
                                nbStuck = 0;
                            }
// ReSharper restore RedundantAssignment
                            if (ObjectManager.ObjectManager.Me.InInevitableCombat)
                            {
                                return;
                            }
                            MovementManager.StopMove();
                            while (MovementManager.IsUnStuck)
                            {
                                if (ObjectManager.ObjectManager.Me.IsDeadMe)
                                {
                                    return;
                                }
                                Thread.Sleep(100);
                                MovementManager.StopMove();
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            catch
            {
            }
        }
Beispiel #13
0
        public override void Run()
        {
            List <Npc> listNPCs = new List <Npc>();
            Npc        mailBox  = null;

            // Stop fisher if needed
            if (Products.Products.ProductName == "Fisherbot" && FishingTask.IsLaunched)
            {
                FishingTask.StopLoopFish();
                // Then break the cast
                MovementsAction.MoveBackward(true);
                Thread.Sleep(50);
                MovementsAction.MoveBackward(false);
            }
            // If we need to send items.
            if (nManagerSetting.CurrentSetting.ActivateAutoMaillingFeature && !_suspendMailing &&
                nManagerSetting.CurrentSetting.MaillingFeatureRecipient != string.Empty &&
                Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SendMailWhenLessThanXSlotLeft)
            {
                if (_useMollE)
                {
                    MountTask.DismountMount();
                    ItemsManager.UseItem(ItemsManager.GetItemNameById(40768));
                    Thread.Sleep(2000);
                    WoWGameObject portableMailbox = ObjectManager.ObjectManager.GetNearestWoWGameObject(
                        ObjectManager.ObjectManager.GetWoWGameObjectById(191605));
                    if (portableMailbox.IsValid &&
                        portableMailbox.CreatedBy == ObjectManager.ObjectManager.Me.Guid)
                    {
                        mailBox = new Npc
                        {
                            Entry          = portableMailbox.Entry,
                            Position       = portableMailbox.Position,
                            Name           = portableMailbox.Name,
                            ContinentIdInt = Usefuls.ContinentId,
                            Faction        = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde"
                                ? Npc.FactionType.Horde
                                : Npc.FactionType.Alliance,
                            SelectGossipOption = 0,
                            Type = Npc.NpcType.Mailbox
                        };
                    }
                }
                if (mailBox == null && NpcDB.GetNpcNearby(Npc.NpcType.Mailbox).Entry > 0)
                {
                    mailBox = NpcDB.GetNpcNearby(Npc.NpcType.Mailbox);
                }
                listNPCs.Add(mailBox);
            }
            // If we need to repair.
            if (ObjectManager.ObjectManager.Me.GetDurability <=
                nManagerSetting.CurrentSetting.RepairWhenDurabilityIsUnderPercent &&
                nManagerSetting.CurrentSetting.ActivateAutoRepairFeature)
            {
                if (_magicMountMammoth && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0)
                {
                    if (_travelersTundraMammoth.HaveBuff || _travelersTundraMammoth.IsSpellUsable)
                    {
                        if (!_travelersTundraMammoth.HaveBuff)
                        {
                            MountTask.DismountMount();
                            _travelersTundraMammoth.Launch(true, true, true);
                            Thread.Sleep(2000);
                        }
                        if (ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde")
                        {
                            WoWUnit drixBlackwrench =
                                ObjectManager.ObjectManager.GetNearestWoWUnit(
                                    ObjectManager.ObjectManager.GetWoWUnitByEntry(32641));
                            if (drixBlackwrench.IsValid && drixBlackwrench.IsAlive)
                            {
                                Npc drixBlackwrenchNpc = new Npc
                                {
                                    Entry              = drixBlackwrench.Entry,
                                    Position           = drixBlackwrench.Position,
                                    Name               = drixBlackwrench.Name,
                                    ContinentIdInt     = Usefuls.ContinentId,
                                    Faction            = Npc.FactionType.Horde,
                                    SelectGossipOption = 0,
                                    Type               = Npc.NpcType.Repair
                                };
                                listNPCs.Add(drixBlackwrenchNpc);
                            }
                        }
                        else
                        {
                            WoWUnit gnimo =
                                ObjectManager.ObjectManager.GetNearestWoWUnit(
                                    ObjectManager.ObjectManager.GetWoWUnitByEntry(32639));
                            if (gnimo.IsValid && gnimo.IsAlive)
                            {
                                Npc gnimoNpc = new Npc
                                {
                                    Entry              = gnimo.Entry,
                                    Position           = gnimo.Position,
                                    Name               = gnimo.Name,
                                    ContinentIdInt     = Usefuls.ContinentId,
                                    Faction            = Npc.FactionType.Alliance,
                                    SelectGossipOption = 0,
                                    Type               = Npc.NpcType.Repair
                                };
                                listNPCs.Add(gnimoNpc);
                            }
                        }
                    }
                }
                else if (_magicMountYak && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0)
                {
                    if (_grandExpeditionYak.HaveBuff || _grandExpeditionYak.IsSpellUsable)
                    {
                        if (!_grandExpeditionYak.HaveBuff)
                        {
                            MountTask.DismountMount();
                            _grandExpeditionYak.Launch(true, true, true);
                            Thread.Sleep(2000);
                        }
                        WoWUnit cousinSlowhands =
                            ObjectManager.ObjectManager.GetNearestWoWUnit(
                                ObjectManager.ObjectManager.GetWoWUnitByEntry(62822));
                        if (cousinSlowhands.IsValid && cousinSlowhands.IsAlive)
                        {
                            Npc cousinSlowhandsNpc = new Npc
                            {
                                Entry          = cousinSlowhands.Entry,
                                Position       = cousinSlowhands.Position,
                                Name           = cousinSlowhands.Name,
                                ContinentIdInt = Usefuls.ContinentId,
                                Faction        = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde"
                                    ? Npc.FactionType.Horde
                                    : Npc.FactionType.Alliance,
                                SelectGossipOption = 0,
                                Type = Npc.NpcType.Repair
                            };
                            listNPCs.Add(cousinSlowhandsNpc);
                        }
                    }
                }
                else if (_use74A)
                {
                    Npc npcA = DoSpawnRobot("74A", Npc.NpcType.Repair);
                    if (npcA != null)
                    {
                        listNPCs.Add(npcA);
                    }
                }
                else if (_use110G)
                {
                    Npc npcG = DoSpawnRobot("110G", Npc.NpcType.Repair);
                    if (npcG != null)
                    {
                        listNPCs.Add(npcG);
                    }
                }
                else if (_useJeeves)
                {
                    Npc npcJeeves = DoSpawnRobot("Jeeves", Npc.NpcType.Repair);
                    if (npcJeeves != null)
                    {
                        listNPCs.Add(npcJeeves);
                    }
                }
                else
                {
                    if (NpcDB.GetNpcNearby(Npc.NpcType.Repair).Entry > 0)
                    {
                        listNPCs.Add(NpcDB.GetNpcNearby(Npc.NpcType.Repair));
                    }
                }
            }

            // If we need to sell.
            if (NeedFoodSupplies() || NeedDrinkSupplies() ||
                Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SellItemsWhenLessThanXSlotLeft &&
                nManagerSetting.CurrentSetting.ActivateAutoSellingFeature && !_suspendSelling)
            {
                if (_magicMountMammoth && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0)
                {
                    if (_travelersTundraMammoth.HaveBuff || _travelersTundraMammoth.IsSpellUsable)
                    {
                        if (!_travelersTundraMammoth.HaveBuff)
                        {
                            MountTask.DismountMount();
                            _travelersTundraMammoth.Launch(true, true, true);
                            Thread.Sleep(2000);
                        }
                        if (ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde")
                        {
                            WoWUnit mojodishu =
                                ObjectManager.ObjectManager.GetNearestWoWUnit(
                                    ObjectManager.ObjectManager.GetWoWUnitByEntry(32642));
                            if (mojodishu.IsValid && mojodishu.IsAlive)
                            {
                                Npc mojodishuNpc = new Npc
                                {
                                    Entry              = mojodishu.Entry,
                                    Position           = mojodishu.Position,
                                    Name               = mojodishu.Name,
                                    ContinentIdInt     = Usefuls.ContinentId,
                                    Faction            = Npc.FactionType.Horde,
                                    SelectGossipOption = 0,
                                    Type               = Npc.NpcType.Vendor
                                };
                                listNPCs.Add(mojodishuNpc);
                            }
                        }
                        else
                        {
                            WoWUnit hakmuddArgus =
                                ObjectManager.ObjectManager.GetNearestWoWUnit(
                                    ObjectManager.ObjectManager.GetWoWUnitByEntry(32638));
                            if (hakmuddArgus.IsValid && hakmuddArgus.IsAlive)
                            {
                                Npc hakmuddArgusNpc = new Npc
                                {
                                    Entry              = hakmuddArgus.Entry,
                                    Position           = hakmuddArgus.Position,
                                    Name               = hakmuddArgus.Name,
                                    ContinentIdInt     = Usefuls.ContinentId,
                                    Faction            = Npc.FactionType.Alliance,
                                    SelectGossipOption = 0,
                                    Type               = Npc.NpcType.Vendor
                                };
                                listNPCs.Add(hakmuddArgusNpc);
                            }
                        }
                    }
                }
                else if (_magicMountYak && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0)
                {
                    if (_grandExpeditionYak.HaveBuff || _grandExpeditionYak.IsSpellUsable)
                    {
                        if (!_grandExpeditionYak.HaveBuff)
                        {
                            MountTask.DismountMount();
                            _grandExpeditionYak.Launch(true, true, true);
                            Thread.Sleep(2000);
                        }
                        WoWUnit cousinSlowhands =
                            ObjectManager.ObjectManager.GetNearestWoWUnit(
                                ObjectManager.ObjectManager.GetWoWUnitByEntry(62822));
                        if (cousinSlowhands.IsValid && cousinSlowhands.IsAlive)
                        {
                            Npc cousinSlowhandsNpc = new Npc
                            {
                                Entry              = cousinSlowhands.Entry,
                                Position           = cousinSlowhands.Position,
                                Name               = cousinSlowhands.Name,
                                ContinentIdInt     = Usefuls.ContinentId,
                                Faction            = Npc.FactionType.Neutral,
                                SelectGossipOption = 0,
                                Type               = Npc.NpcType.Vendor
                            };
                            listNPCs.Add(cousinSlowhandsNpc);
                        }
                    }
                }
                else if (_use74A)
                {
                    Npc npcA = DoSpawnRobot("74A", Npc.NpcType.Vendor);
                    if (npcA != null)
                    {
                        listNPCs.Add(npcA);
                    }
                }
                else if (_use110G)
                {
                    Npc npcG = DoSpawnRobot("110G", Npc.NpcType.Vendor);
                    if (npcG != null)
                    {
                        listNPCs.Add(npcG);
                    }
                }
                else if (_useJeeves)
                {
                    Npc npcJeeves = DoSpawnRobot("Jeeves", Npc.NpcType.Vendor);
                    if (npcJeeves != null)
                    {
                        listNPCs.Add(npcJeeves);
                    }
                }
                else
                {
                    if (NpcDB.GetNpcNearby(Npc.NpcType.Vendor).Entry > 0)
                    {
                        listNPCs.Add(NpcDB.GetNpcNearby(Npc.NpcType.Vendor));
                    }
                }
            }

            #region Repairer, Seller/Buyer, MailBox

            if (listNPCs.Count > 0)
            {
                listNPCs.Sort(OnComparison);
                foreach (Npc npc in listNPCs)
                {
                    Npc  target   = npc;
                    bool doTravel = target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 400 || target.ContinentIdInt != Usefuls.ContinentId;
                    if (!doTravel && target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 400)
                    {
                        // Close NPC but no path ?
                        bool success;
                        PathFinder.FindPath(ObjectManager.ObjectManager.Me.Position, target.Position, Usefuls.ContinentNameMpq, out success);
                        if (!success)
                        {
                            doTravel = true;
                        }
                    }
                    //Start travel

                    if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f)
                    {
                        if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                        {
                            _travelLocation = Products.Products.TravelFrom;
                            Products.Products.TravelRegenerated = false;
                        }
                    }
                    if (doTravel && (_travelLocation == null || _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f) && !_travelDisabled && !Usefuls.IsFlying)
                    {
                        MovementManager.StopMove();
                        switch (npc.Type)
                        {
                        case Npc.NpcType.Repair:
                            Logging.Write("Calling travel system to NpcRepair " + npc.Name + " (" + npc.Entry + ")...");
                            break;

                        case Npc.NpcType.Vendor:
                            Logging.Write("Calling travel system to NpcVendor " + npc.Name + " (" + npc.Entry + ")...");
                            break;

                        case Npc.NpcType.Mailbox:
                            Logging.Write("Calling travel system to Mailbox " + npc.Name + " (" + npc.Entry + ")...");
                            break;

                        default:
                            Logging.Write("Calling travel system for ToTown to " + npc.Name + " (" + npc.Entry + ")...");
                            break;
                        }
                        Products.Products.TravelToContinentId   = target.ContinentIdInt;
                        Products.Products.TravelTo              = target.Position;
                        Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                        Products.Products.TravelFrom            = ObjectManager.ObjectManager.Me.Position;
                        // Pass the check for valid destination as a lambda
                        Products.Products.TargetValidationFct = Quest.IsNearQuestGiver; // compare me.Pos to dest.Pos
                        _travelLocation = Products.Products.TravelFrom;
                        return;
                    }
                    if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 0.1f)
                    {
                        _travelDisabled = true; // don't forget to release travel once arrived.
                    }
                    //Start target finding based on Seller.
                    uint baseAddress = MovementManager.FindTarget(ref target, 0, !ObjectManager.ObjectManager.Me.IsMounted);
                    if (!target.ValidPath)
                    {
                        Logging.WriteDebug("No valid path/travel to Npc " + target.Name + ", removing him from NpcDB.");
                        NpcDB.DelNpc(target);
                    }
                    if (MovementManager.InMovement)
                    {
                        return;
                    }
                    if (target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) >= 5f)
                    {
                        return;
                    }
                    _travelDisabled = false;
                    if (baseAddress == 0 && target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 5f)
                    {
                        NpcDB.DelNpc(target);
                    }
                    else if (baseAddress > 0)
                    {
                        if (!_travelersTundraMammoth.HaveBuff)
                        {
                            DoProspectingInTown(target);
                            DoMillingInTown(target);
                        }
                        Interact.InteractWith(baseAddress);
                        Thread.Sleep(500);
                        MovementManager.StopMove();
                        if (target.SelectGossipOption != 0)
                        {
                            Lua.LuaDoString("SelectGossipOption(" + target.SelectGossipOption + ")");
                            Thread.Sleep(500);
                        }
                        else if (target.Type == Npc.NpcType.Repair || target.Type == Npc.NpcType.Vendor)
                        {
                            if (!Gossip.SelectGossip(Gossip.GossipOption.Vendor))
                            {
                                Logging.WriteError("Problem with NPC " + npc.Name + " Removing it for NpcDB");
                                NpcDB.DelNpc(npc);
                                return;
                            }
                        }
                        // NPC Repairer
                        if (target.Type == Npc.NpcType.Repair)
                        {
                            Logging.Write("Repair items from " + target.Name + " (" + target.Entry + ").");
                            Vendor.RepairAllItems();
                            Thread.Sleep(1000);
                        }
                        // End NPC Repairer

                        if (target.Type == Npc.NpcType.Vendor)
                        {
                            // NPC Buyer
                            Logging.Write("Selling items to " + target.Name + " (" + target.Entry + ").");
                            List <WoWItemQuality> vQuality = new List <WoWItemQuality>();
                            if (nManagerSetting.CurrentSetting.SellGray)
                            {
                                vQuality.Add(WoWItemQuality.Poor);
                            }
                            if (nManagerSetting.CurrentSetting.SellWhite)
                            {
                                vQuality.Add(WoWItemQuality.Common);
                            }
                            if (nManagerSetting.CurrentSetting.SellGreen)
                            {
                                vQuality.Add(WoWItemQuality.Uncommon);
                            }
                            if (nManagerSetting.CurrentSetting.SellBlue)
                            {
                                vQuality.Add(WoWItemQuality.Rare);
                            }
                            if (nManagerSetting.CurrentSetting.SellPurple)
                            {
                                vQuality.Add(WoWItemQuality.Epic);
                            }
                            Vendor.SellItems(nManagerSetting.CurrentSetting.ForceToSellTheseItems, nManagerSetting.CurrentSetting.DontSellTheseItems, vQuality);
                            Thread.Sleep(3000);
                            if (Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SellItemsWhenLessThanXSlotLeft)
                            {
                                _suspendSelling = true;
                            }
                            // End NPC Buyer

                            // NPC Seller
                            if (NeedFoodSupplies() || NeedDrinkSupplies())
                            {
                                Logging.Write("Buying beverages and food from " + target.Name + " (" + target.Entry + ").");
                            }
                            for (int i = 0; i < 10 && NeedFoodSupplies(); i++)
                            {
                                Vendor.BuyItem(nManagerSetting.CurrentSetting.FoodName, 1);
                            }
                            for (int i = 0; i < 10 && NeedDrinkSupplies(); i++)
                            {
                                Vendor.BuyItem(nManagerSetting.CurrentSetting.BeverageName, 1);
                            }
                            // End NPC Seller
                        }
                        if (target.Type == Npc.NpcType.Repair || target.Type == Npc.NpcType.Vendor)
                        {
                            Gossip.CloseGossip();
                        }

                        // MailBox
                        if (target.Type == Npc.NpcType.Mailbox)
                        {
                            List <WoWItemQuality> mQuality = new List <WoWItemQuality>();
                            if (nManagerSetting.CurrentSetting.MailGray)
                            {
                                mQuality.Add(WoWItemQuality.Poor);
                            }
                            if (nManagerSetting.CurrentSetting.MailWhite)
                            {
                                mQuality.Add(WoWItemQuality.Common);
                            }
                            if (nManagerSetting.CurrentSetting.MailGreen)
                            {
                                mQuality.Add(WoWItemQuality.Uncommon);
                            }
                            if (nManagerSetting.CurrentSetting.MailBlue)
                            {
                                mQuality.Add(WoWItemQuality.Rare);
                            }
                            if (nManagerSetting.CurrentSetting.MailPurple)
                            {
                                mQuality.Add(WoWItemQuality.Epic);
                            }

                            bool mailSendingCompleted = false;
                            for (int i = 7; i > 0 && !mailSendingCompleted; i--)
                            {
                                Interact.InteractWith(baseAddress);
                                Thread.Sleep(1000);
                                Mail.SendMessage(nManagerSetting.CurrentSetting.MaillingFeatureRecipient,
                                                 nManagerSetting.CurrentSetting.MaillingFeatureSubject, "",
                                                 nManagerSetting.CurrentSetting.ForceToMailTheseItems,
                                                 nManagerSetting.CurrentSetting.DontMailTheseItems, mQuality,
                                                 out mailSendingCompleted);
                                Thread.Sleep(500);
                            }
                            if (mailSendingCompleted)
                            {
                                Logging.Write("Sending items to the player " + nManagerSetting.CurrentSetting.MaillingFeatureRecipient + " using " + target.Name + " (" +
                                              target.Entry + ").");
                            }
                            if (Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SendMailWhenLessThanXSlotLeft)
                            {
                                _suspendMailing = true;
                            }
                            Lua.LuaDoString("CloseMail()");
                        }
                        // End MailBox
                    }
                    // still on the road, but not in movement for some reasons
                }
            }

            #endregion Repairer, Seller/Buyer, MailBox
        }
Beispiel #14
0
        public static void LongMoveGo(Point point)
        {
            try
            {
                //MovementManager.StopMove();
                int timer = Others.Times;

                if (_used)
                {
                    _used = false;
                    while (_usedLoop)
                    {
                        Thread.Sleep(5);
                    }
                }
                _used     = true;
                _usedLoop = true;

                //MovementManager.StopMove();
                MountTask.Mount(false, true);

                Point pTemps = ObjectManager.ObjectManager.Me.Position;

                Timer timerSit         = new Timer(2500);
                bool  flyingPathFinder = false;

                while (Products.Products.IsStarted && (ObjectManager.ObjectManager.Me.IsMounted || MountTask.GetMountCapacity() == MountCapacity.Feet) &&
                       ObjectManager.ObjectManager.Me.Position.DistanceTo(point) > 3.5f && _used && _usedLoop)
                {
                    bool forceGround = false;
                    if (Usefuls.IsFlying)
                    {
                        Point pos = ObjectManager.ObjectManager.Me.Position;
                        if (point.DistanceTo2D(pos) <= 60 || flyingPathFinder && point.DistanceTo2D(pos) <= 110)
                        {
                            Point p           = new Point(ObjectManager.ObjectManager.Me.Position.LerpByDistance(point, 3f));
                            bool  failed      = false;
                            Point targetPoint = new Point();
                            if (p.IsValid && TraceLine.TraceLineGo(ObjectManager.ObjectManager.Me.Position, p, CGWorldFrameHitFlags.HitTestAllButLiquid))
                            {
                                if ((point.DistanceTo2D(pos) <= 60 || flyingPathFinder && point.DistanceTo2D(pos) <= 110))
                                {
                                    float degree     = 0f;
                                    bool  doContinue = false;
                                    try
                                    {
                                        LongMoveIsLanding = true;
                                        while (degree < 360)
                                        {
                                            var   rnd         = new Random();
                                            float radius      = rnd.Next(25, 50);
                                            float x           = (float)(pos.X + radius * System.Math.Cos(Math.DegreeToRadian(degree)));
                                            float y           = (float)(pos.Y + radius * System.Math.Sin(Math.DegreeToRadian(degree)));
                                            Point topPoint    = new Point(x, y, pos.Z);
                                            Point bottomPoint = new Point(x, y, PathFinder.GetZPosition(x, y));
                                            if (!TraceLine.TraceLineGo(topPoint, new Point(topPoint.LerpByDistance(point, 3f)), CGWorldFrameHitFlags.HitTestAllButLiquid))
                                            {
                                                targetPoint = topPoint;
                                                MovementManager.MoveTo(targetPoint);
                                                Thread.Sleep(2500);
                                                flyingPathFinder = true;
                                                doContinue       = true;
                                                break;
                                                // we want to go to topPoint and directly go to point.
                                            }
                                            else if (!TraceLine.TraceLineGo(topPoint, bottomPoint, CGWorldFrameHitFlags.HitTestAllButLiquid))
                                            {
                                                bool success;
                                                PathFinder.FindPath(bottomPoint, point, Usefuls.ContinentNameMpq, out success);
                                                if (success)
                                                {
                                                    targetPoint = topPoint;
                                                    MovementManager.MoveTo(targetPoint);
                                                    Thread.Sleep(2500);
                                                    flyingPathFinder = true;
                                                    break;
                                                    // we want to go to topPoint then dismount down to bottomPoint, then findPath to target.
                                                }
                                            }

                                            float randomDegree = rnd.Next(20, 30);
                                            degree += randomDegree;
                                            if (degree >= 360f)
                                            {
                                                failed = true;
                                            }
                                        }
                                    }
                                    finally
                                    {
                                        LongMoveIsLanding = false;
                                    }
                                    if (doContinue)
                                    {
                                        Thread.Sleep(1000);
                                        continue;
                                    }
                                }
                                if (!failed)
                                {
                                    if (ObjectManager.ObjectManager.Me.Position.DistanceTo(targetPoint) > 5f)
                                    {
                                        Thread.Sleep(2500);
                                    }
                                    if (ObjectManager.ObjectManager.Me.Position.DistanceTo(targetPoint) > 5f)
                                    {
                                        continue;
                                    }
                                    MountTask.DismountMount();
                                    _used     = false;
                                    _usedLoop = false;
                                    return;
                                }
                            }
                            else
                            {
                                MovementManager.MoveTo(p);
                                flyingPathFinder = false;
                            }
                        }
                    }
                    if (MountTask.GetMountCapacity() <= MountCapacity.Ground || forceGround)
                    {
                        if (RegenPath.IsReady && ObjectManager.ObjectManager.Me.Position.DistanceTo(point) > 3.5f)
                        {
                            RegenPath = new Timer(1000 * 60);
                            List <Point> getFullPath = PathFinder.FindPath(point);
                            MovementManager.Go(getFullPath);
                            RegenPath.Reset();
                        }
                        else
                        {
                            Thread.Sleep(1000);
                        }
                    }
                    else
                    {
                        if (!MovementManager.IsUnStuck)
                        {
                            if (ObjectManager.ObjectManager.Me.IsDeadMe)
                            {
                                return;
                            }
                            const int checkInFront   = 130; // was 100
                            const int checkCollision = 60;  // was 40
                            if (ObjectManager.ObjectManager.Me.Position.DistanceTo2D(point) > 15)
                            {
                                Point meTemps = ObjectManager.ObjectManager.Me.Position;
                                meTemps.Z = meTemps.Z - 2;

                                Point temps = new Point(point.X, point.Y, ObjectManager.ObjectManager.Me.Position.Z - 2.5f);
                                if (point.DistanceTo(ObjectManager.ObjectManager.Me.Position) > checkInFront)
                                {
                                    temps = Math.GetPosition2DOfLineByDistance(ObjectManager.ObjectManager.Me.Position, point,
                                                                               checkInFront);
                                    temps.Z = ObjectManager.ObjectManager.Me.Position.Z - 2.5f;
                                }
                                if (TraceLine.TraceLineGo(meTemps, temps) ||
                                    (ObjectManager.ObjectManager.Me.Position.Z + 10 < point.Z &&
                                     point.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) < 100))
                                {
                                    MovementsAction.Descend(false);
                                    MovementsAction.Ascend(true);
                                    timerSit = new Timer(1000);
                                    // If distance to colission < checkCollision stop moveto
                                    temps = new Point(point.X, point.Y, ObjectManager.ObjectManager.Me.Position.Z - 2.5f);
                                    if (point.DistanceTo(ObjectManager.ObjectManager.Me.Position) > checkInFront)
                                    {
                                        temps = Math.GetPosition2DOfLineByDistance(ObjectManager.ObjectManager.Me.Position,
                                                                                   point, checkCollision);
                                        temps.Z = ObjectManager.ObjectManager.Me.Position.Z - 2.5f;
                                    }
                                    if (TraceLine.TraceLineGo(meTemps, temps))
                                    {
                                        MovementManager.StopMoveTo(false);
                                    }
                                    // End Stop move to
                                    Thread.Sleep(800);
                                    if (pTemps.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 1f)
                                    {
                                        MovementManager.UnStuckFly();
                                    }
                                    else
                                    {
                                        pTemps = ObjectManager.ObjectManager.Me.Position;
                                    }
                                }
                                else
                                {
                                    MovementsAction.Ascend(false);

                                    if (timerSit.IsReady)
                                    {
                                        // If distance to ground > 100
                                        temps = new Point(ObjectManager.ObjectManager.Me.Position.X,
                                                          ObjectManager.ObjectManager.Me.Position.Y,
                                                          ObjectManager.ObjectManager.Me.Position.Z - altitude);
                                        Point tempsMe = new Point(ObjectManager.ObjectManager.Me.Position.X,
                                                                  ObjectManager.ObjectManager.Me.Position.Y,
                                                                  ObjectManager.ObjectManager.Me.Position.Z + 5f);
                                        Point temps2 = Math.GetPosition2DOfLineByDistance(tempsMe, point, 80);
                                        temps2.Z = ObjectManager.ObjectManager.Me.Position.Z - altitude;
                                        if (!TraceLine.TraceLineGo(tempsMe, temps))
                                        {
                                            if (!TraceLine.TraceLineGo(tempsMe, temps2))
                                            {
                                                MovementsAction.Descend(true);
                                            }
                                            else
                                            {
                                                timerSit = new Timer(1000);
                                                MovementsAction.Descend(false);
                                            }
                                        }
                                        else
                                        {
                                            timerSit = new Timer(1000);
                                            MovementsAction.Descend(false);
                                        }
                                        // End Stop move ground
                                    }
                                    MovementManager.MoveTo(point.X, point.Y, ObjectManager.ObjectManager.Me.Position.Z);
                                    if (Others.Times > (timer + 1500))
                                    {
                                        MovementManager.MoveTo(point.X, point.Y, ObjectManager.ObjectManager.Me.Position.Z);
                                        timer = Others.Times;
                                    }
                                }
                            }
                            else
                            {
                                MovementsAction.Descend(false);
                                MovementsAction.Ascend(false);

                                if (ObjectManager.ObjectManager.Me.Position.DistanceTo2D(point) <= 5f && ObjectManager.ObjectManager.Me.Position.DistanceZ(point) > 2f)
                                {
                                    MovementsAction.Descend(false);
                                    MovementsAction.Ascend(false);
                                    MovementManager.StopMove();
                                    MovementManager.StopMove();
                                    MountTask.Land();
                                }
                                else
                                {
                                    MovementManager.MoveTo(point);
                                }
                            }
                        }

                        if (ObjectManager.ObjectManager.Me.IsMounted && !Usefuls.IsFlying)
                        {
                            MovementsAction.Descend(false);
                            MovementsAction.Ascend(false);
                            MountTask.Mount(false, true);
                            MovementsAction.Ascend(true);
                            Thread.Sleep(1300);
                            MovementsAction.Ascend(false);
                        }
                    }
                    Thread.Sleep(150); //50
                }
                MovementsAction.Descend(false);
                MovementsAction.Ascend(false);
                _used     = false;
                _usedLoop = false;
                RegenPath.ForceReady();
            }
            catch (Exception exception)
            {
                MovementsAction.Descend(false);
                MovementsAction.Ascend(false);
                Logging.WriteError("LongMove > LongMoveGo(Point point): " + exception);
                _used     = false;
                _usedLoop = false;
                RegenPath.ForceReady();
            }
        }
    public static bool GoInteractwithFM(FlightMaster fm, bool openMapRequired = false)
    {
        if (GoToTask.ToPosition(fm.Position, 5f))
        {
            if (!Main.isLaunched ||
                !Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause ||
                ObjectManager.Me.Position.DistanceTo(fm.Position) > 10f)
            {
                return(false);
            }

            // We're in fight (possibly on mount)
            if (ObjectManager.Me.InCombatFlagOnly)
            {
                if (ObjectManager.Me.IsMounted)
                {
                    MountTask.DismountMount();
                }
                return(false);
            }

            // We have reached the FM
            if (ObjectManager.Me.IsMounted)
            {
                MountTask.DismountMount();
            }

            // Check if FM is here or dead
            WoWUnit nearbyFM = FindNearbyAliveFM(fm);
            if (nearbyFM == null)
            {
                fm.Disable("FlightMaster is absent or dead.");
                ResetFlags();
                return(false);
            }

            // Approach FM
            if (!GoToTask.ToPosition(nearbyFM.Position, 1f))
            {
                return(false);
            }

            Interact.InteractGameObject(ObjectManager.GetWoWUnitByEntry(fm.NPCId).First().GetBaseAddress);

            // Check if interaction successful
            if (!InteractWithFm(fm))
            {
                fm.Disable("Unable to interact with NPC");
                ResetFlags();
                return(false);
            }

            Usefuls.SelectGossipOption(GossipOptionsType.taxi);

            // Check if map open
            if (openMapRequired && !FmMapIsOpen(fm))
            {
                fm.Disable("Unable to open FM map");
                ResetFlags();
                return(false);
            }

            return(true);
        }
        // We haven't reach the FM yet
        return(false);
    }
Beispiel #16
0
        public static UInt128 StartFight(UInt128 guid = default(UInt128))
        {
            MovementManager.StopMove();
            WoWUnit targetNpc = null;

            try
            {
                if (guid == 0)
                {
                    targetNpc =
                        new WoWUnit(
                            ObjectManager.ObjectManager.GetNearestWoWUnit(
                                ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                }
                else
                {
                    targetNpc =
                        new WoWUnit(ObjectManager.ObjectManager.GetObjectByGuid(guid).GetBaseAddress);
                }

                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                }

                if (ObjectManager.ObjectManager.Me.IsMounted &&
                    (CombatClass.InAggroRange(targetNpc) || CombatClass.InRange(targetNpc)))
                {
                    MountTask.DismountMount();
                }

                InFight = true;

                if (!ObjectManager.ObjectManager.Me.IsCast)
                {
                    Interact.InteractWith(targetNpc.GetBaseAddress);
                }
                Thread.Sleep(100);
                if (ObjectManager.ObjectManager.Me.GetMove && !ObjectManager.ObjectManager.Me.IsCast)
                {
                    MovementManager.StopMoveTo();
                }

                Point positionStartTarget = targetNpc.Position;

                int timer = 0;
figthStart:
                // If pos start is very different
                if (targetNpc.Position.DistanceTo(positionStartTarget) > 50)
                {
                    return(0);
                }
                if (!targetNpc.Attackable)
                {
                    nManagerSetting.AddBlackList(targetNpc.Guid, 20000); // blacklist 20 sec
                    // Some become unattackable instead of being dead.
                    // Some will evade.
                }
                if (Usefuls.IsInBattleground && !Battleground.IsFinishBattleground())
                {
                    List <WoWUnit> tLUnit = ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer();
                    if (tLUnit.Count > 0)
                    {
                        if (ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).GetDistance < targetNpc.GetDistance &&
                            ObjectManager.ObjectManager.GetNearestWoWUnit(tLUnit).SummonedBy == 0)
                        {
                            return(0);
                        }
                    }
                }
                if ((ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InRange(targetNpc)) || TraceLine.TraceLineGo(targetNpc.Position)) // If obstacle or not in range
                {
                    bool         resultSucces;
                    List <Point> points = PathFinder.FindPath(targetNpc.Position, out resultSucces);
                    if (!resultSucces && !Usefuls.IsFlying && MountTask.GetMountCapacity() >= MountCapacity.Fly)
                    {
                        MountTask.Mount(true, true);
                    }

                    // TODO: Code a FindTarget that includes CombatClass.GetRange here or we will often do wierd thing with casters.
                    MovementManager.Go(points);
                    timer = Others.Times + (int)(Math.DistanceListPoint(points) / 3 * 1000) + 15000;

                    while (!ObjectManager.ObjectManager.Me.IsDeadMe && !targetNpc.IsDead && targetNpc.Attackable && !targetNpc.IsLootable &&
                           targetNpc.Health > 0 && targetNpc.IsValid &&
                           MovementManager.InMovement && InFight && Usefuls.InGame &&
                           (TraceLine.TraceLineGo(targetNpc.Position) || !CombatClass.InAggroRange(targetNpc))
                           )
                    {
                        // Mob already in fight
                        if (targetNpc.Type != Enums.WoWObjectType.Player && !(targetNpc.IsTargetingMe || targetNpc.Target == 0 || ((WoWUnit)ObjectManager.ObjectManager.GetObjectByGuid(targetNpc.Target)).
                                                                              SummonedBy == ObjectManager.ObjectManager.Me.Guid || targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid))
                        {
                            return(targetNpc.Guid);
                        }

                        // Timer
                        if (Others.Times > timer && TraceLine.TraceLineGo(targetNpc.Position))
                        {
                            return(targetNpc.Guid);
                        }

                        // Target Pos Verif
                        if (!targetNpc.Position.IsValid)
                        {
                            return(targetNpc.Guid);
                        }

                        // If pos start is very different
                        if (targetNpc.Position.DistanceTo(positionStartTarget) > 50)
                        {
                            return(0);
                        }

                        // Return if player/pet is attacked by another unit
                        if (ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0 && !targetNpc.IsTargetingMe && !(targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid && targetNpc.Target > 0))
                        {
                            return(0);
                        }
                        Thread.Sleep(50);
                    }
                }
                timer = Others.Times + (int)(ObjectManager.ObjectManager.Me.Position.DistanceTo(targetNpc.Position) / 3 * 1000) + 5000;
                if (MovementManager.InMovement)
                {
                    MovementManager.StopMove();
                }

                if (!ObjectManager.ObjectManager.Me.IsCast && ObjectManager.ObjectManager.Me.Target != targetNpc.Guid)
                {
                    Interact.InteractWith(targetNpc.GetBaseAddress);
                }

                InFight = true;
                Thread.Sleep(200);
                if (CombatClass.InAggroRange(targetNpc))
                {
                    if (ObjectManager.ObjectManager.Me.GetMove && !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        MovementManager.StopMoveTo();
                    }
                    if (!ObjectManager.ObjectManager.Me.GetMove && ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        MountTask.DismountMount();
                    }
                }

                // If target died after only 0.2sec of fight, let's find a new target.
                if (targetNpc.IsDead || !targetNpc.IsValid || targetNpc.Attackable)
                {
                    WoWUnit newTargetNpc = new WoWUnit(ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetHostileUnitAttackingPlayer()).GetBaseAddress);
                    if (newTargetNpc.IsValid && !ObjectManager.ObjectManager.Me.IsCast && ObjectManager.ObjectManager.Me.Target != newTargetNpc.Guid)
                    {
                        targetNpc = newTargetNpc;
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                        // Face the new target
                        MovementManager.Face(targetNpc);
                    }
                }

                while (!ObjectManager.ObjectManager.Me.IsDeadMe && !targetNpc.IsDead && targetNpc.Attackable && targetNpc.IsValid && InFight &&
                       targetNpc.IsValid && !ObjectManager.ObjectManager.Me.InTransport)
                {
                    // Return if player attacked and this target not attack player
                    if (targetNpc.Type != Enums.WoWObjectType.Player && !targetNpc.IsTargetingMe && !(targetNpc.Target == ObjectManager.ObjectManager.Pet.Guid && targetNpc.Target > 0) &&
                        ObjectManager.ObjectManager.GetNumberAttackPlayer() > 0)
                    {
                        return(0);
                    }

                    // Cancel fight if the mob was tapped by another player
                    if (targetNpc.IsTapped)
                    {
                        return(0);
                    }

                    // Target Pos Verif
                    if (!targetNpc.Position.IsValid)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }

                    // Target mob if not target
                    if (ObjectManager.ObjectManager.Me.Target != targetNpc.Guid && !targetNpc.IsDead && !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }

                    // Move to target if out of range
                    if (!ObjectManager.ObjectManager.Me.IsCast &&
                        ((!ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InAggroRange(targetNpc)) ||
                         ((ObjectManager.ObjectManager.Me.InCombat && !CombatClass.InRange(targetNpc)))))
                    {
                        int rJump = Others.Random(1, 20);
                        MovementManager.MoveTo(targetNpc);
                        if (rJump == 5)
                        {
                            MovementsAction.Jump();
                        }
                    }
                    // Create path if the mob is out of sight or out of range
                    if ((!CombatClass.InRange(targetNpc) && !ObjectManager.ObjectManager.Me.IsCast) ||
                        TraceLine.TraceLineGo(targetNpc.Position))
                    {
                        goto figthStart;
                    }
                    // Stop move if in range
                    if (CombatClass.InRange(targetNpc) && ObjectManager.ObjectManager.Me.GetMove &&
                        !ObjectManager.ObjectManager.Me.IsCast)
                    {
                        MovementManager.StopMoveTo();
                    }
                    if (ObjectManager.ObjectManager.Me.IsMounted)
                    {
                        MountTask.DismountMount();
                        Interact.InteractWith(targetNpc.GetBaseAddress);
                    }

                    // Face player to mob
                    MovementManager.Face(targetNpc);

                    // If obstacle between us and the target after this timer expires then stop the fight and blacklist
                    if (Others.Times > timer && TraceLine.TraceLineGo(targetNpc.Position) &&
                        targetNpc.HealthPercent > 90)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }

                    Thread.Sleep(75 + Usefuls.Latency);

                    // If timer expires and still not in fight, then stop the fight and blacklist
                    if (Others.Times > timer && !ObjectManager.ObjectManager.Me.InCombat && !targetNpc.IsDead)
                    {
                        InFight = false;
                        return(targetNpc.Guid);
                    }
                }

                MovementManager.StopMoveTo();
                InFight = false;
            }
            catch (Exception exception)
            {
                Logging.WriteError("StartFight(UInt128 guid = 0, bool inBg = false): " + exception);
                InFight = false;
            }
            try
            {
                if (targetNpc != null)
                {
                    return(targetNpc.Guid);
                }
            }
            catch
            {
                return(0);
            }
            return(0);
        }
    public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force)
    {
        //silly vanilla logic
        if (unit != null && unit.IsValid && unit.IsAlive && spell.IsKnown() && spell.GetCooldown() == 0 && !spell.IsUsable() && !spell.NotEnoughMana())
        {
            if (ObjectManager.Me.HaveBuff("Bear Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Bear Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Dire Bear Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Dire Bear Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Cat Form"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Cat Form"", true)");
            }
            if (ObjectManager.Me.HaveBuff("Ghost Wolf"))
            {
                Lua.LuaDoString(@"CastSpellByName(""Ghost Wolf"", true)");
            }
        }

        // targetfinder function already checks that they are in LoS
        if (unit == null || !spell.IsKnown() || !spell.CanCast() || !unit.IsValid || unit.IsDead)
        {
            return(false);
        }

        if (wManager.wManagerSetting.CurrentSetting.IgnoreFightGoundMount && ObjectManager.Me.IsMounted)
        {
            return(false);
        }

        MountTask.DismountMount();

        //already wanding, don't turn it on again!
        if (spell.Spell.Name == "Shoot" && IsAutoRepeating("Shoot"))
        {
            return(true);
        }

        if (ObjectManager.Me.IsCasting() && !force)
        {
            return(false);
        }

        if (ObjectManager.Me.GetMove && spell.Spell.CastTime > 0)
        {
            //MovementManager.StopMove();
            MovementManager.StopMoveTo(false, Usefuls.Latency + 500);
        }

        if (force)
        {
            Lua.LuaDoString("SpellStopCasting();");
        }

        if (AreaSpells.Contains(spell.Spell.Name))
        {
            /*spell.Launch(true, true, false);
             *  Thread.Sleep(Usefuls.Latency + 50);
             *  ClickOnTerrain.Pulse(unit.Position);*/

            Lua.LuaDoString("CastSpellByName(\"" + spell.FullName() + "\")");
            //SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position);
            ClickOnTerrain.Pulse(unit.Position);
        }
        else
        {
            //don't switch target if targeting enemy - rely on auto selfcast
            WoWUnit temp   = ObjectManager.Target;
            bool    onSelf = unit.Guid == ObjectManager.Me.Guid;

            if (!onSelf)
            {
                //FaceUnit(unit);
                MovementManager.Face(unit);
                _disableTargeting = true;
                TargetUnit(unit);
            }


            Lua.LuaDoString($"CastSpellByName('{spell.FullName()}', {onSelf.ToString().ToLower()})");

            if (!onSelf)
            {
                if (temp.Guid == 0 || !temp.IsValid)
                {
                    Lua.LuaDoString("ClearTarget();");
                }
                else
                {
                    TargetUnit(temp);
                }

                //SpellManager.CastSpellByNameOn(spell.FullName(), GetLuaId(unit));
                //Interact.InteractObject also works and can be used to target another unit
                _disableTargeting = false;
            }
        }
        return(true);
    }
Beispiel #18
0
        public static int SolveAllArtifact(bool useKeystone)
        {
            try
            {
                int nbSolved = 0;
                if (archaeologySpell == null)
                {
                    archaeologySpell = new Spell("Archaeology");
                }

                Lua.RunMacroText("/cast " + archaeologySpell.NameInGame);
                int j = 1;
                while (j <= 18)
                {
                    Lua.RunMacroText("/click ArchaeologyFrameSummaryButton");
                    if (j == 13)
                    {
                        Lua.RunMacroText("/click ArchaeologyFrameSummarytButton");
                        Lua.RunMacroText("/click ArchaeologyFrameSummaryPageNextPageButton");
                    }
                    string buttonName;
                    if (j > 12)
                    {
                        buttonName = "ArchaeologyFrameSummaryPageRace" + (j - 12);
                    }
                    else
                    {
                        buttonName = "ArchaeologyFrameSummaryPageRace" + j;
                    }

                    if (IsButtonActive(buttonName))
                    {
                        Lua.RunMacroText("/click " + buttonName);
                    }
                    else
                    {
                        j++;
                        continue;
                    }
                    Thread.Sleep(200 + Usefuls.Latency);
                    if (useKeystone)
                    {
                        bool moreToSocket;
                        do
                        {
                            moreToSocket = false;
                            string randomString1 = Others.GetRandomString(Others.Random(4, 10));
                            string randomString2 = Others.GetRandomString(Others.Random(4, 10));
                            Lua.LuaDoString(randomString1 + " = SocketItemToArtifact(); if " + randomString1 + " then " + randomString2 + "=\"1\" else " + randomString2 + "=\"0\" end");
                            if (Lua.GetLocalizedText(randomString2) == "1")
                            {
                                moreToSocket = true;
                                Thread.Sleep(250 + Usefuls.Latency);
                            }
                        } while (moreToSocket);
                    }
                    string randomString3 = Others.GetRandomString(Others.Random(4, 10));
                    string randomString4 = Others.GetRandomString(Others.Random(4, 10));
                    Lua.LuaDoString(randomString3 + " = CanSolveArtifact(); if " + randomString3 + " then " + randomString4 + "=\"1\" else " + randomString4 + "=\"0\" end");
                    bool canSolve = Lua.GetLocalizedText(randomString4) == "1";
                    if (canSolve)
                    {
                        nbSolved++;
                        Lua.RunMacroText("/click ArchaeologyFrameArtifactPageSolveFrameSolveButton");
                        if (Usefuls.GetContainerNumFreeSlots >= 1)
                        {
                            j--;
                        }
                        Thread.Sleep(2050 + Usefuls.Latency); // Spell cast time is 2.0secs
                    }
                    j++;
                    Thread.Sleep(200 + Usefuls.Latency);
                }
                Lua.RunMacroText("/click ArchaeologyFrameCloseButton");
                if (ObjectManager.ObjectManager.Me.Level < 90 || Usefuls.GetContainerNumFreeSlots <= 0)
                {
                    return(nbSolved);
                }
                for (int i = 79896; i <= 79917; i++)
                {
                    if (i == 79906 || i == 79907)
                    {
                        continue;
                    }
                    WoWItem item = ObjectManager.ObjectManager.GetWoWItemById(i);
                    if (item == null || !item.IsValid || ItemsManager.IsItemOnCooldown(i) ||
                        !ItemsManager.IsItemUsable(i))
                    {
                        continue;
                    }
                    while (ItemsManager.GetItemCount(i) > 0)
                    {
                        MountTask.DismountMount();
                        ItemsManager.UseItem(i);
                        Thread.Sleep(1550 + Usefuls.Latency); // Spell cast time is 1.5secs
                    }
                }
                for (int i = 95375; i <= 95382; i++)
                {
                    WoWItem item = ObjectManager.ObjectManager.GetWoWItemById(i);
                    if (item == null || !item.IsValid || ItemsManager.IsItemOnCooldown(i) ||
                        !ItemsManager.IsItemUsable(i))
                    {
                        continue;
                    }
                    while (ItemsManager.GetItemCount(i) > 0)
                    {
                        MountTask.DismountMount();
                        ItemsManager.UseItem(i);
                        Thread.Sleep(1550 + Usefuls.Latency); // Spell cast time is 1.5secs
                    }
                }
                return(nbSolved);
            }
            catch (Exception e)
            {
                Logging.WriteError("Archaeology >  solveAllArtifact(): " + e);
                return(0);
            }
        }
Beispiel #19
0
    internal static void Pull()
    {
        Main.SetRangeToMelee();

        // Check if surrounding enemies
        if (ObjectManager.Target.GetDistance < _pullRange && !_pullFromAfar)
        {
            _pullFromAfar = ToolBox.CheckIfEnemiesOnPull(ObjectManager.Target, _pullRange);
        }

        // Check stance
        if (!InBattleStance() &&
            ObjectManager.Me.Rage < 10 &&
            !_pullFromAfar &&
            !_settings.AlwaysPull)
        {
            Cast(BattleStance);
        }

        // Pull from afar
        if ((_pullFromAfar &&
             _pullMeleeTimer.ElapsedMilliseconds < 5000) || _settings.AlwaysPull &&
            ObjectManager.Target.GetDistance < 24f)
        {
            Spell pullMethod = null;

            if (Shoot.IsSpellUsable &&
                Shoot.KnownSpell)
            {
                pullMethod = Shoot;
            }

            if (Throw.IsSpellUsable &&
                Throw.KnownSpell)
            {
                pullMethod = Throw;
            }

            if (pullMethod == null)
            {
                Main.Log("Can't pull from distance. Please equip a ranged weapon in order to Throw or Shoot.");
                _pullFromAfar = false;
            }
            else
            {
                if (Me.IsMounted)
                {
                    MountTask.DismountMount();
                }

                Main.SetRange(_pullRange);
                if (Cast(pullMethod))
                {
                    Thread.Sleep(2000);
                }
            }
        }

        // Melee ?
        if (_pullMeleeTimer.ElapsedMilliseconds <= 0 &&
            ObjectManager.Target.GetDistance <= _pullRange + 3)
        {
            _pullMeleeTimer.Start();
        }

        if (_pullMeleeTimer.ElapsedMilliseconds > 5000)
        {
            Main.LogDebug("Going in Melee range");
            Main.SetRangeToMelee();
            _pullMeleeTimer.Reset();
        }

        // Check if caster in list
        if (_casterEnemies.Contains(ObjectManager.Target.Name))
        {
            _fightingACaster = true;
        }

        // Charge Battle Stance
        if (InBattleStance() &&
            ObjectManager.Target.GetDistance > 9f &&
            ObjectManager.Target.GetDistance < 24f &&
            !_pullFromAfar)
        {
            if (Cast(Charge))
            {
                return;
            }
        }

        // Charge Berserker Stance
        if (InBerserkStance() &&
            ObjectManager.Target.GetDistance > 9f &&
            ObjectManager.Target.GetDistance < 24f &&
            !_pullFromAfar)
        {
            if (Cast(Intercept))
            {
                return;
            }
        }
    }
Beispiel #20
0
        public override void Run()
        {
            if (!Products.IsStarted || ObjectManager.Me.IsDeadMe || ObjectManager.Me.InCombatBlizzard)
            {
                return;
            }
            if (!FisherbotSetting.CurrentSetting.FishSchool)
            {
                if (_firstRun && FishingTask.IsLaunched)
                {
                    _firstRun = false;
                }
                // If we have a saved position and we don't fish, then go to position
                if (FisherbotSetting.CurrentSetting.FisherbotPosition.IsValid && (!FishingTask.IsLaunched || _beenFighting) && !_firstRun)
                {
                    _beenFighting = false;
                    if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 5)
                    {
                        LongMove.LongMoveGo(FisherbotSetting.CurrentSetting.FisherbotPosition);
                    }
                    else if (ObjectManager.Me.Position.DistanceTo(FisherbotSetting.CurrentSetting.FisherbotPosition) > 1.5f)
                    {
                        MovementManager.MoveTo(FisherbotSetting.CurrentSetting.FisherbotPosition);
                    }
                    MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation);
                }
                // If we don't fish or the timer is null, then start a new timer, save position and fish
                if (timer == null || !FishingTask.IsLaunched)
                {
                    timer = new nManager.Helpful.Timer(10 * 60 * 1000 + 10 * 1000);
                    FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position;
                    FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation;
                    Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName);
                    FishingTask.LoopFish(0, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName, false,
                                         FisherbotSetting.AutomaticallyUseDraenorSecondaryBait);
                }
                // If the timer ended, stop fishing, equip weapon, null the timer
                else if (timer.IsReady)
                {
                    FishingTask.StopLoopFish();
                    ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName);
                    if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName))
                    {
                        ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName);
                    }

                    timer = null;
                }
                // We are in timer, we fish, then save the position
                else
                {
                    if (FishingTask._lastSuccessfullFishing > Environment.TickCount - 5000)
                    {
                        FisherbotSetting.CurrentSetting.FisherbotPosition = ObjectManager.Me.Position;
                        FisherbotSetting.CurrentSetting.FisherbotRotation = ObjectManager.Me.Rotation;
                        // We successfully fished in the last 5 seconds, let's record our position again.
                    }
                    if (FishingTask._lastSuccessfullFishing != 0 && FishingTask._lastSuccessfullFishing < Environment.TickCount - 25000)
                    {
                        // We did not catch a single thing in the last 25 seconds...
                        FishingTask.StopLoopFish();
                        return;
                    }
                    // _lastSuccessfullFishing is fine or we never fished yet, let it load :)
                    Thread.Sleep(500);
                }
                // No more while, we test what we need and return
                return;
            }

            // Nodes fishing code
            if (_node.IsValid)
            {
                FisherbotSetting.CurrentSetting.FisherbotPosition =
                    Bot.Profile.Points[Math.NearestPointOfListPoints(Bot.Profile.Points, _node.Position)];
                Logging.Write("Fish " + _node.Name + " > " + _node.Position);
            }

            if (FisherbotSetting.CurrentSetting.FishSchool)
            {
                Point whereToGo = Fishing.FindTheUltimatePoint(_node.Position);
                if (whereToGo.Type == "invalid")
                {
                    Logging.Write("No valid point found");
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
                bool         r;
                List <Point> points = PathFinder.FindPath(whereToGo, out r);
                if (points.Count <= 1 || points.Count >= 20)
                {
                    points.Clear();
                    points.Add(ObjectManager.Me.Position);
                    points.Add(whereToGo);
                }
                else
                {
                    for (int i = 0; i < points.Count; i++)
                    {
                        if (points[i].Z < whereToGo.Z)
                        {
                            points[i].Z = whereToGo.Z;
                        }
                    }
                }
                Logging.Write("Going to point > " + whereToGo.X + " ; " + whereToGo.Y + " ; " + whereToGo.Z + " ; " +
                              points[0].Type);
                MovementManager.Go(points);

                timer = new nManager.Helpful.Timer(((int)Math.DistanceListPoint(points) / 3 * 1000) + 4000);
                while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted &&
                       !ObjectManager.Me.IsDeadMe &&
                       !ObjectManager.Me.InInevitableCombat &&
                       !timer.IsReady && MovementManager.InMovement)
                {
                    if (ObjectManager.Me.Position.DistanceTo2D(whereToGo) <= 0.2f)
                    {
                        MovementManager.StopMove();
                        break;
                    }
                    Thread.Sleep(50);
                }

                if (timer.IsReady && _node.GetDistance2D > DistanceMax)
                {
                    Logging.Write("Fishing failed - No nearby point found (distance near position = " +
                                  ObjectManager.Me.Position.DistanceTo2D(
                                      FisherbotSetting.CurrentSetting.FisherbotPosition).ToString(CultureInfo.InvariantCulture) + ")");
                    MovementManager.StopMove();
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
            }

            // Stop move
            MovementManager.StopMove();
            MountTask.DismountMount();

            // Face
            if (_node.IsValid)
            {
                MovementManager.Face(_node);
            }
            else
            {
                MovementManager.Face(FisherbotSetting.CurrentSetting.FisherbotRotation);
            }

            // Ce met a la bonne distance du banc de poisson
            if (_node.IsValid)
            {
                int nbIsSwimming = 0;
                timer = new nManager.Helpful.Timer(1000 * 8);
                while ((Usefuls.IsSwimming || _node.GetDistance > DistanceMax || _node.GetDistance < DistanceMin) &&
                       Products.IsStarted && !ObjectManager.Me.IsDeadMe && !ObjectManager.Me.InCombat && !timer.IsReady)
                {
                    if (nbIsSwimming * 100 > TimeTryFindGoodPos)
                    {
                        FishingTask.StopLoopFish();
                        MovementsAction.MoveBackward(false);
                        MovementsAction.MoveForward(false);
                        Logging.Write("BlackList " + _node.Name);
                        nManagerSetting.AddBlackList(_node.Guid);
                        return;
                    }
                    FishingTask.StopLoopFish();
                    MovementManager.Face(_node);

                    if (Usefuls.IsSwimming || _node.GetDistance < DistanceMin)
                    {
                        MovementsAction.MoveForward(false);
                        MovementsAction.MoveBackward(true);
                    }
                    if (_node.GetDistance > DistanceMax)
                    {
                        MovementsAction.MoveBackward(false);
                        MovementsAction.MoveForward(true);
                    }

                    nbIsSwimming++;
                    Thread.Sleep(100);
                }
                MovementsAction.MoveBackward(false);
                MovementsAction.MoveForward(false);
                if (timer.IsReady)
                {
                    Logging.Write("Fishing failed - Out of range" + timer.IsReady.ToString());
                    MovementManager.StopMove();
                    nManagerSetting.AddBlackList(_node.Guid);
                    return;
                }
            }

            // Fish
            Fishing.EquipFishingPoles(FisherbotSetting.CurrentSetting.FishingPoleName);
            FishingTask.LoopFish(_node.Guid, FisherbotSetting.CurrentSetting.UseLure, FisherbotSetting.CurrentSetting.LureName, FisherbotSetting.CurrentSetting.FishingPoleName,
                                 FisherbotSetting.CurrentSetting.PrecisionMode, FisherbotSetting.AutomaticallyUseDraenorSecondaryBait);

            timer = new nManager.Helpful.Timer(2 * 60 * 1000);
            while ((_node.IsValid || !FisherbotSetting.CurrentSetting.FishSchool) && Products.IsStarted &&
                   !ObjectManager.Me.IsDeadMe &&
                   !ObjectManager.Me.InCombat && !timer.IsReady &&
                   FishingTask.IsLaunched)
            {
                if (ObjectManager.Me.Position.DistanceTo2D(FisherbotSetting.CurrentSetting.FisherbotPosition) > 3.5f &&
                    !FisherbotSetting.CurrentSetting.FishSchool)
                {
                    break;
                }
                Thread.Sleep(300);
            }
            FishingTask.StopLoopFish();
            ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.WeaponName);
            if (!string.IsNullOrEmpty(FisherbotSetting.CurrentSetting.ShieldName))
            {
                ItemsManager.EquipItemByName(FisherbotSetting.CurrentSetting.ShieldName);
            }
        }
Beispiel #21
0
        public static void QuestPickUp(ref Npc npc, string questName, int questId, out bool cancelPickUp, bool ignoreBlacklist = false, bool forceTravel = false)
        {
            if (npc.ForceTravel)
            {
                forceTravel = true;
            }
            cancelPickUp = false;
            if (AbandonnedId == questId) // should happen only when we do a different quest requirement for optimization
            {
                AbandonnedId = 0;
                return;
            }
            if (AbandonnedId != 0)
            {
                AbandonQuest(AbandonnedId);
            }
            AbandonnedId = 0;
            Point   me   = ObjectManager.ObjectManager.Me.Position;
            WoWUnit mNpc = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(npc.Entry, true), false, ignoreBlacklist, true);

            // We have the NPC in memory and he is closer than the QuesterDB entry. (some Npc moves)
            if (mNpc.IsValid && mNpc.HasQuests)
            {
                npc.Position = mNpc.Position;
            }
            WoWGameObject mObj = ObjectManager.ObjectManager.GetNearestWoWGameObject(ObjectManager.ObjectManager.GetWoWGameObjectByEntry(npc.Entry), ignoreBlacklist);

            if (mObj.IsValid && mObj.HasQuests)
            {
                npc.Position = mObj.Position;
            }
            bool bypassTravel = false;

            if (me.DistanceTo(npc.Position) <= 800f)
            {
                PathFinder.FindPath(npc.Position, out bypassTravel);
            }
            if (Usefuls.IsFlying && npc.ContinentIdInt == Usefuls.ContinentId)
            {
                bypassTravel = true;
            }
            else if (Usefuls.IsFlying)
            {
                MountTask.DismountMount();
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f)
            {
                if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                {
                    _travelLocation = Products.Products.TravelFrom;
                    Products.Products.TravelRegenerated = false;
                }
            }
            if (!bypassTravel && (_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled)
            {
                MovementManager.StopMove();
                Logging.Write("Calling travel system for PickUpQuest " + questName + "(" + questId + ") from " + npc.Name + " (" + npc.Entry + ")...");
                Products.Products.TravelToContinentId   = npc.ContinentIdInt;
                Products.Products.TravelTo              = npc.Position;
                Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                Products.Products.TravelFrom            = me;
                Products.Products.ForceTravel           = forceTravel;
                // Pass the check for valid destination as a lambda
                Products.Products.TargetValidationFct = IsNearQuestGiver;
                _travelLocation = Products.Products.TravelFrom;
                return;
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) <= 0.1f)
            {
                _travelDisabled = true;
            }
            //Start target finding based on QuestGiver.
            uint baseAddress = MovementManager.FindTarget(ref npc, 4.5f, true, true, 0f, ignoreBlacklist); // can pick up quest on dead NPC.

            if (MovementManager.InMovement)
            {
                return;
            }
            _travelDisabled = false; // reset travel
            if (baseAddress > 0)
            {
                var tmpNpc = ObjectManager.ObjectManager.GetObjectByGuid(npc.Guid);
                if (tmpNpc is WoWUnit)
                {
                    var unitTest = tmpNpc as WoWUnit;
                    if (unitTest.IsValid && unitTest.GetDistance < 20f && !unitTest.HasQuests)
                    {
                        _travelDisabled = false; // reset travel
                        nManagerSetting.AddBlackList(unitTest.Guid, 30000);
                        Logging.Write("Npc QuestGiver " + unitTest.Name + " (" + unitTest.Entry + ", distance: " + unitTest.GetDistance +
                                      ") does not have any available quest for the moment. Blacklisting it for 30 seconds.");
                        cancelPickUp = true;
                        return;
                    }
                }
            }
            //End target finding based on QuestGiver.
            if (mObj.IsValid && mObj.GetDistance <= 4.5f || npc.Position.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) <= 4.5f && npc.Position.DistanceZ(ObjectManager.ObjectManager.Me.Position) < 6f ||
                npc.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 4.5f)
            {
                if (baseAddress <= 0)
                {
                    cancelPickUp = true; // We are there but no NPC waiting for us.
                    // This code is there for Mimesis and I'm not currently working on Quester, so I'm not going to "return;" there as quester will be even more lost.
                    npc.Ignore(120000);
                    return;
                }
                if (Usefuls.IsFlying)
                {
                    MountTask.Land();
                }
                InteractTarget(ref npc, baseAddress);
                Logging.Write("PickUpQuest " + questName + " (" + questId + ") from " + npc.Name + " (" + npc.Entry + ")");
                int id = GetQuestID();
                if (GetNumGossipAvailableQuests() == 0 && id == questId)
                {
                    AcceptQuest();
                    Thread.Sleep(Usefuls.Latency + 500);
                }
                if (GetLogQuestId().Contains(questId))
                {
                    CloseWindow();
                }
                else
                {
                    bool systemWorks = GetGossipAvailableQuestsWorks();
                    if (systemWorks) // 2 quest gossip systems = 2 different codes :(
                    {
                        for (int i = 1; i <= GetNumGossipAvailableQuests(); i++)
                        {
                            SelectGossipAvailableQuest(i);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == 0)
                            {
                                systemWorks = false;
                                break;
                            }
                            if (id == questId)
                            {
                                AcceptQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                id = GetQuestID();
                                CloseWindow();
                                if (id != questId)
                                {
                                    AbandonQuest(id);
                                }
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            AbandonQuest(id);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                        }
                    }
                    if (!systemWorks)
                    {
                        int gossipid = 1;
                        while (GetAvailableTitle(gossipid) != "")
                        {
                            SelectAvailableQuest(gossipid);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == questId)
                            {
                                AcceptQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                id = GetQuestID();
                                CloseWindow();
                                if (id != questId)
                                {
                                    AbandonQuest(id);
                                }
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            AbandonQuest(id);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                            gossipid++;
                        }
                    }
                }
                KilledMobsToCount.Clear();
                Thread.Sleep(Usefuls.Latency);
            }
            CloseWindow();
        }
Beispiel #22
0
        public static void QuestTurnIn(ref Npc npc, string questName, int questId, bool ignoreBlacklist = false, bool forceTravel = false)
        {
            if (npc.ForceTravel)
            {
                forceTravel = true;
            }
            Point   me   = ObjectManager.ObjectManager.Me.Position;
            WoWUnit mNpc = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(npc.Entry, true), false, ignoreBlacklist, true);

            if (mNpc.IsValid && mNpc.CanTurnIn)
            {
                npc.Position = mNpc.Position;
            }
            WoWGameObject mObj = ObjectManager.ObjectManager.GetNearestWoWGameObject(ObjectManager.ObjectManager.GetWoWGameObjectByEntry(npc.Entry), ignoreBlacklist);

            if (mObj.IsValid && mObj.CanTurnIn)
            {
                npc.Position = mObj.Position;
            }
            bool bypassTravel = false;

            if (me.DistanceTo(npc.Position) <= 800f)
            {
                PathFinder.FindPath(npc.Position, out bypassTravel);
            }
            if (Usefuls.IsFlying && npc.ContinentIdInt == Usefuls.ContinentId)
            {
                bypassTravel = true;
            }
            else if (Usefuls.IsFlying)
            {
                MountTask.DismountMount();
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f)
            {
                if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                {
                    _travelLocation = Products.Products.TravelFrom;
                    Products.Products.TravelRegenerated = false;
                }
            }
            if (!bypassTravel && (_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled)
            {
                MovementManager.StopMove();
                Logging.Write("Calling travel system for TurnInQuest " + questName + "(" + questId + ") from " + npc.Name + " (" + npc.Entry + ")...");
                Products.Products.TravelToContinentId   = npc.ContinentIdInt;
                Products.Products.TravelTo              = npc.Position;
                Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                Products.Products.TravelFrom            = me;
                Products.Products.ForceTravel           = forceTravel;
                // Pass the check for valid destination as a lambda
                Products.Products.TargetValidationFct = IsNearQuestGiver;
                _travelLocation = Products.Products.TravelFrom;
                return;
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(me) <= 0.1f)
            {
                _travelDisabled = true;
            }
            //Start target finding based on QuestGiver.
            uint baseAddress = MovementManager.FindTarget(ref npc, 4.5f, true, true, 0f, ignoreBlacklist);

            if (MovementManager.InMovement)
            {
                return;
            }

            if (baseAddress > 0)
            {
                var tmpNpc = ObjectManager.ObjectManager.GetObjectByGuid(npc.Guid);
                if (tmpNpc is WoWUnit)
                {
                    var unitTest = tmpNpc as WoWUnit;
                    if (unitTest.IsValid && unitTest.GetDistance < 20f && !unitTest.CanTurnIn)
                    {
                        _travelDisabled = false; // reset travel
                        nManagerSetting.AddBlackList(unitTest.Guid, 30000);
                        Logging.Write("Npc QuestGiver " + unitTest.Name + " (" + unitTest.Entry + ", distance: " + unitTest.GetDistance +
                                      ") cannot TurnIn any quest right now. Blacklisting it for 30 seconds.");
                        return;
                    }
                }
            }
            _travelDisabled = false; // reset travel
            ItemInfo equip = null;

            //End target finding based on QuestGiver.
            if (mObj.IsValid && mObj.GetDistance <= 4.5f || npc.Position.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) < 4.5f && npc.Position.DistanceZ(ObjectManager.ObjectManager.Me.Position) < 6f ||
                npc.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 4.5f)
            {
                if (baseAddress <= 0)
                {
                    npc.Ignore(120000);
                    return;
                }
                if (Usefuls.IsFlying)
                {
                    MountTask.Land();
                }
                InteractTarget(ref npc, baseAddress);
                Logging.Write("QuestTurnIn " + questName + " (" + questId + ") to " + npc.Name + " (" + npc.Entry + ")");
                int id = GetQuestID();
                if (GetNumGossipActiveQuests() == 0 && id == questId)
                {
                    if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                    {
                        Lua.RunMacroText("/click QuestFrameCompleteButton");
                        Thread.Sleep(300);
                    }
                    equip = CompleteQuest();
                    Thread.Sleep(Usefuls.Latency + 500);
                }
                if (!GetLogQuestId().Contains(questId)) // It's no more in the quest log, then we did turn in it sucessfuly
                {
                    id = GetQuestID();
                    FinishedQuestSet.Add(questId);
                    CloseWindow();
                    AbandonnedId = id;
                }
                else
                {
                    bool systemWorks = GetGossipActiveQuestsWorks();
                    if (systemWorks) // 2 quest gossip systems = 2 different codes :(
                    {
                        for (int i = 1; i <= GetNumGossipActiveQuests(); i++)
                        {
                            SelectGossipActiveQuest(i);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == 0)
                            {
                                systemWorks = false;
                                break;
                            }
                            if (id == questId)
                            {
                                if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                                {
                                    Lua.RunMacroText("/click QuestFrameCompleteButton");
                                    Thread.Sleep(300);
                                }
                                equip = CompleteQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                // here it can be the next quest id presented automatically when the current one is turned in
                                id = GetQuestID();
                                CloseWindow();
                                if (GetLogQuestId().Contains(questId))
                                {
                                    equip = null;
                                    Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\"");
                                    break;
                                }
                                FinishedQuestSet.Add(questId);
                                AbandonnedId = id;
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                        }
                    }
                    if (!systemWorks)
                    {
                        int gossipid = 1;
                        while (GetActiveTitle(gossipid) != "")
                        {
                            SelectActiveQuest(gossipid);
                            Thread.Sleep(Usefuls.Latency + 500);
                            id = GetQuestID();
                            if (id == questId)
                            {
                                if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton"))
                                {
                                    Lua.RunMacroText("/click QuestFrameCompleteButton");
                                    Thread.Sleep(300);
                                }
                                equip = CompleteQuest();
                                Thread.Sleep(Usefuls.Latency + 500);
                                CloseWindow();
                                if (GetLogQuestId().Contains(questId))
                                {
                                    equip = null;
                                    Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\"");
                                    break;
                                }
                                FinishedQuestSet.Add(questId);
                                break;
                            }
                            CloseWindow();
                            Thread.Sleep(Usefuls.Latency + 500);
                            Interact.InteractWith(baseAddress);
                            Thread.Sleep(Usefuls.Latency + 500);
                            gossipid++;
                        }
                    }
                }
            }
            Thread.Sleep(Usefuls.Latency);
            if (equip != null)
            {
                ItemSelection.EquipItem(equip);
                Thread.Sleep(Usefuls.Latency + 500);
            }
            CloseWindow();
            if (!GetLogQuestId().Contains(questId))
            {
                FinishedQuestSet.Add(questId);
            }
        }
    internal static void Pull()
    {
        // Check if surrounding enemies
        if (ObjectManager.Target.GetDistance < _pullRange && !_pullFromAfar)
        {
            _pullFromAfar = ToolBox.CheckIfEnemiesOnPull(ObjectManager.Target, _pullRange);
        }

        // Pull from afar
        if ((_pullFromAfar && _pullMeleeTimer.ElapsedMilliseconds < 5000) || _settings.AlwaysPull &&
            ObjectManager.Target.GetDistance <= _pullRange)
        {
            Spell pullMethod = null;

            if (Shoot.IsSpellUsable && Shoot.KnownSpell)
            {
                pullMethod = Shoot;
            }

            if (Throw.IsSpellUsable && Throw.KnownSpell)
            {
                pullMethod = Throw;
            }

            if (pullMethod == null)
            {
                Main.Log("Can't pull from distance. Please equip a ranged weapon in order to Throw or Shoot.");
                _pullFromAfar = false;
            }
            else
            {
                if (Me.IsMounted)
                {
                    MountTask.DismountMount();
                }

                Main.SetRange(_pullRange);
                if (Cast(pullMethod))
                {
                    Thread.Sleep(2000);
                }
            }
        }

        // Melee ?
        if (_pullMeleeTimer.ElapsedMilliseconds <= 0 && ObjectManager.Target.GetDistance <= _pullRange + 3)
        {
            _pullMeleeTimer.Start();
        }

        if (_pullMeleeTimer.ElapsedMilliseconds > 5000)
        {
            Main.LogDebug("Going in Melee range");
            Main.SetRangeToMelee();
            _pullMeleeTimer.Reset();
        }

        // Check if caster in list
        if (_casterEnemies.Contains(ObjectManager.Target.Name))
        {
            _fightingACaster = true;
        }

        // Stealth
        if (!Me.HaveBuff("Stealth") && !_pullFromAfar && ObjectManager.Target.GetDistance > 15f &&
            ObjectManager.Target.GetDistance < 25f && _settings.StealthApproach && Backstab.KnownSpell &&
            (!ToolBox.HasPoisonDebuff() || _settings.StealthWhenPoisoned))
        {
            if (Cast(Stealth))
            {
                return;
            }
        }

        // Un-Stealth
        if (Me.HaveBuff("Stealth") && _pullFromAfar && ObjectManager.Target.GetDistance > 15f)
        {
            if (Cast(Stealth))
            {
                return;
            }
        }

        // Stealth approach
        if (Me.HaveBuff("Stealth") && ObjectManager.Target.GetDistance > 3f && !_isStealthApproching && !_pullFromAfar)
        {
            Main.SetRangeToMelee();
            _stealthApproachTimer.Start();
            _isStealthApproching = true;
            if (ObjectManager.Me.IsAlive && ObjectManager.Target.IsAlive)
            {
                while (Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                       (ObjectManager.Target.GetDistance > Main.GetRange() - 1) &&
                       !ToolBox.CheckIfEnemiesOnPull(ObjectManager.Target, _pullRange) &&
                       Fight.InFight &&
                       _stealthApproachTimer.ElapsedMilliseconds <= 15000 &&
                       Me.HaveBuff("Stealth"))
                {
                    // deactivate autoattack
                    ToggleAutoAttack(false);

                    Vector3 position = ToolBox.BackofVector3(ObjectManager.Target.Position, ObjectManager.Target, 2.5f);
                    MovementManager.MoveTo(position);
                    // Wait follow path
                    Thread.Sleep(50);
                }

                if (ToolBox.CheckIfEnemiesOnPull(ObjectManager.Target, _pullRange) && Me.HaveBuff("Stealth"))
                {
                    _pullFromAfar = true;
                    if (Cast(Stealth))
                    {
                        return;
                    }
                }

                // Opener
                if (ToolBox.MeBehindTarget())
                {
                    if (_settings.UseGarrote)
                    {
                        if (Cast(Garrote))
                        {
                            MovementManager.StopMove();
                        }
                    }
                    if (Cast(Backstab))
                    {
                        MovementManager.StopMove();
                    }
                    if (Cast(CheapShot))
                    {
                        MovementManager.StopMove();
                    }
                    if (Cast(Hemorrhage) || Cast(SinisterStrike))
                    {
                        MovementManager.StopMove();
                    }
                }
                else
                {
                    if (CheapShot.KnownSpell)
                    {
                        if (Cast(CheapShot))
                        {
                            MovementManager.StopMove();
                        }
                    }
                    else if (HaveDaggerInMH() && Gouge.KnownSpell)
                    {
                        if (Cast(Gouge))
                        {
                            MovementManager.StopMove();
                        }
                    }
                    else
                    {
                        if (Cast(Hemorrhage) || Cast(SinisterStrike))
                        {
                            MovementManager.StopMove();
                        }
                    }
                }

                if (_stealthApproachTimer.ElapsedMilliseconds > 15000)
                {
                    Main.Log("_stealthApproachTimer time out");
                    _pullFromAfar = true;
                }

                ToggleAutoAttack(true);
                _isStealthApproching = false;
            }
        }

        // Auto
        if (ObjectManager.Target.GetDistance < 6f && !Me.HaveBuff("Stealth"))
        {
            ToggleAutoAttack(true);
        }
    }
Beispiel #24
0
        public static bool TravelToQuestZone(Point destination, ref bool travelToQuestZone, int continentId = -1, bool forceTravel = false, string reason = "TravelToQuestZone")
        {
            bool doTravel = forceTravel;

            if (continentId == -1)
            {
                continentId = Usefuls.ContinentId;
            }
            if (continentId == Usefuls.ContinentId && Usefuls.IsFlying && !forceTravel)
            {
                return(false);
            }
            if (continentId == Usefuls.ContinentId && Usefuls.IsFlying && forceTravel)
            {
                MountTask.DismountMount();
                // land before generating paths...
            }
            if (continentId != Usefuls.ContinentId)
            {
                doTravel = true;
            }
            if (ObjectManager.ObjectManager.Me.Position.DistanceTo(destination) > 800f)
            {
                doTravel = true;
            }
            else if (!doTravel)
            {
                // We are closer, check for a valid path.
                PathFinder.FindPath(destination, out doTravel);
                doTravel = !doTravel; // reverse result
            }
            if (!travelToQuestZone && !forceTravel)
            {
                doTravel = false;
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f)
            {
                if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid)
                {
                    _travelLocation = Products.Products.TravelFrom;
                    Products.Products.TravelRegenerated = false;
                }
            }
            if (doTravel && (_travelLocation == null || _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f) && !_travelDisabled)
            {
                MovementManager.StopMove();
                Logging.Write("Calling travel system for " + reason + "...");
                travelToQuestZone = false;
                Products.Products.TravelToContinentId   = continentId;
                Products.Products.TravelTo              = destination;
                Products.Products.TravelFromContinentId = Usefuls.ContinentId;
                Products.Products.TravelFrom            = ObjectManager.ObjectManager.Me.Position;
                Products.Products.ForceTravel           = forceTravel;
                // Pass the check for valid destination as a lambda
                Products.Products.TargetValidationFct = Quest.IsNearQuestGiver; // compare me.Pos to dest.Pos
                _travelLocation = Products.Products.TravelFrom;
                return(true);
            }
            if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 0.1f)
            {
                _travelDisabled = true; // release travel once arrived.
            }
            return(false);
        }