예제 #1
0
파일: PPather.cs 프로젝트: Bia10/boogiebot
        public bool WalkTo(Coordinate loc, bool AbortIfUnsafe, int timeout, bool AllowDead)
        {
            if (loc.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates()) < 4.5f &&
                Math.Abs(loc.O) < PI / 8)
            {
                mover.Stop();
                return(true);
            }

            GSpellTimer   approachTimeout = new GSpellTimer(timeout, false);
            StuckDetecter sd     = new StuckDetecter(this, 1, 2);
            GSpellTimer   t      = new GSpellTimer(0);
            bool          doJump = random.Next(4) == 0;
            EasyMover     em     = null;

            do
            {
                UpdateMyPos();

                // Check for stuck
                if (sd.checkStuck())
                {
                    BoogieCore.Log(LogType.System, "Major stuck on approach. Giving up");
                    mover.Stop();
                    return(false);
                }


                double distance = loc.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());
                bool   moved;
                if (distance < 8)
                {
                    moved = mover.moveTowardsFacing(loc, 4.5f, loc);
                }
                else
                {
                    if (em == null)
                    {
                        em = new EasyMover(this, new Location(loc), false, AbortIfUnsafe);
                    }
                    EasyMover.MoveResult mr = em.move();

                    moved = true;
                    if (mr != EasyMover.MoveResult.Moving)
                    {
                        moved = false;
                    }
                }

                if (!moved)
                {
                    mover.Stop();
                    BoogieCore.Log(LogType.System, "did not move");
                    return(true);
                }
            } while (!approachTimeout.IsReadySlow);
            mover.Stop();
            BoogieCore.Log(LogType.System, "Approach timed out");
            return(false);
        }
예제 #2
0
        public override bool Do()
        {
            if (em == null)
            {
                return(true);                // WTF!
            }
            // mount if we're really far away
            if (monster.DistanceToSelf >= mountRange)
            {
                if (PPather.PatherSettings.UseMount != "Never Mount")
                {
                    if (PPather.PatherSettings.UseMount == "Always Mount" ||
                        (PPather.PatherSettings.UseMount == "Let Task Decide" &&
                         UseMount == true))
                    {
                        Helpers.Mount.MountUp();
                    }
                }
            }

            if (GContext.Main.Me.Target != monster &&
                tabSpam.IsReady &&
                monster.DistanceToSelf < 50f &&
                monster.Reaction != GReaction.Friendly)
            {
                GContext.Main.SendKey("Common.Target");
                tabSpam.Reset();
            }

            if (GetLocation().GetDistanceTo(to) > GContext.Main.MeleeDistance &&
                monster.DistanceToSelf < 30f || updateTimer.IsReady)
            {
                // need a new path, monster moved
                to = GetLocation();
                em = new EasyMover(ppather, to, false, true);
                updateTimer.Reset();
            }

            MoveResult = em.move(howClose);
            if (MoveResult != EasyMover.MoveResult.Moving)
            {
                return(true);                // done, can't do more
            }
            Location meLocation = new Location(GContext.Main.Me.Location);

            if (meLocation.GetDistanceTo(to) < howClose)
            {
                PPather.mover.Stop();
                Helpers.Mount.Dismount();
                monster.Face(PPather.PI / 8);
                return(true);
            }
            return(false);
        }
예제 #3
0
        public override bool Do()
        {
            if (em == null)
            {
                return(true);                // WTF!
            }
            Location meLocation            = new Location(GContext.Main.Me.Location);
            float    distanceToDestination = meLocation.GetDistanceTo(to);
            float    mountRange            = PPather.PatherSettings.MountRange;

            // mount if it's far enough away
            if (distanceToDestination >= mountRange)
            {
                if (PPather.PatherSettings.UseMount != "Never Mount")
                {
                    if (PPather.PatherSettings.UseMount == "Always Mount" ||
                        (PPather.PatherSettings.UseMount == "Let Task Decide" &&
                         UseMount == true))
                    {
                        Helpers.Mount.MountUp();
                    }
                }
            }
            MoveResult = em.move(howClose);
            if (MoveResult != EasyMover.MoveResult.Moving)
            {
                return(true);                // done, can't do more
            }
            if (distanceToDestination < howClose && Math.Abs(meLocation.Z - to.Z) < howClose)
            {
                // we're here so dismount, if we weren't mounted it doesn't matter
                //Helpers.Mount.Dismount();

                PPather.mover.Stop();
                return(true);
            }

            return(false);
        }
예제 #4
0
파일: PPather.cs 프로젝트: Bia10/boogiebot
        // called when we have died, return when we are alive again
        private void GhostRun()
        {
            BoogieCore.Log(LogType.System, "I died. Let's resurrect");
            Coordinate CorpseLocation = null;



            Coordinate gloc = new Coordinate(0, 0, 0);

            if (CorpseLocation != null)
            {
                gloc = CorpseLocation;
            }

            Location   target = null;
            Coordinate gtarget;

            BoogieCore.Log(LogType.System, "Corpse is at " + gloc);

            if (gloc.Z == 0)
            {
                BoogieCore.Log(LogType.System, "hmm, corpse Z == 0");
                target = new Location(gloc);
                for (int q = 0; q < 50; q += 5)
                {
                    float stand_z = 0;
                    int   flags   = 0;
                    float x       = gloc.X + random.Next(20) - 10;
                    float y       = gloc.Y + random.Next(20) - 10;
                    bool  ok      = world.triangleWorld.FindStandableAt(x, y,
                                                                        -5000,
                                                                        5000,
                                                                        out stand_z, out flags, 0, 0);
                    if (ok)
                    {
                        target = new Location(x, y, stand_z);
                        break;
                    }
                }
            }
            else
            {
                target = new Location(gloc);
            }
            gtarget = new Coordinate(target.X, target.Y, target.Z);

            BoogieCore.Log(LogType.System, "Corpse is at " + target);
            EasyMover em = new EasyMover(this, target, false, false);

            // 2. Run to corpse
            while (Me.IsDead && Me.DistanceTo(gloc) > 20)     // fixme
            {
                EasyMover.MoveResult mr = em.move();
                if (mr != EasyMover.MoveResult.Moving)
                {
                    return;                                        // buhu
                }
                UpdateMyPos();
                Thread.Sleep(50);
            }
            mover.Stop();

            // 3. Find a safe place to res
            // is within 20 yds of corpse now, dialog must be up
            float SafeDistance = 25.0f;

            while (true)
            {
                // some brute force :p
                BoogieBot.Common.Object[] monsters = BoogieCore.world.getObjectListArray();
                float    best_score    = 1E30f;
                float    best_distance = 1E30f;
                Location best_loc      = null;
                for (float x = -35; x <= 35; x += 5)
                {
                    for (float y = -35; y <= 35; y += 5)
                    {
                        float      rx  = target.X + x;
                        float      ry  = target.Y + y;
                        Coordinate xxx = new Coordinate(rx, ry, 0);
                        if (xxx.DistanceTo(gtarget) < 35)
                        {
                            float stand_z = 0;
                            int   flags   = 0;
                            bool  ok      = world.triangleWorld.FindStandableAt(rx, ry,
                                                                                target.Z - 20,
                                                                                target.Z + 20,
                                                                                out stand_z, out flags, 0, 0);
                            if (ok)
                            {
                                float      score = 0.0f;
                                Coordinate l     = new Coordinate(rx, ry, stand_z);
                                foreach (BoogieBot.Common.Object monster in monsters)
                                {
                                    if (monster != null && !monster.IsDead)
                                    {
                                        float d = l.DistanceTo(monster.GetCoordinates());
                                        if (d < 35)
                                        {
                                            // one point per yard
                                            score += 35 - d;
                                        }
                                    }
                                }
                                float this_d = Me.DistanceTo(l);
                                if (score <= best_score && this_d < best_distance)
                                {
                                    best_score    = score;
                                    best_distance = this_d;
                                    best_loc      = new Location(l);
                                }
                            }
                        }
                    }
                }
                if (best_loc != null)
                {
                    Coordinate best_gloc = new Coordinate(best_loc.X, best_loc.Y, best_loc.Z);
                    // walk over there
                    WalkTo(best_gloc, false, 10000, true);

                    // Check if I am safe
                    bool safe = true;
                    BoogieBot.Common.Object unsafe_monster = null;
                    foreach (BoogieBot.Common.Object monster in monsters)
                    {
                        if (!monster.IsDead && !PPather.IsStupidItem(monster))
                        {
                            float d = Me.DistanceTo(monster.GetCoordinates());
                            if (d < SafeDistance)
                            {
                                if (Math.Abs(monster.GetPositionZ() - Me.Location.Z) < 15)
                                {
                                    safe           = false;
                                    unsafe_monster = monster;
                                }
                            }
                        }
                    }
                    if (safe)
                    {
                        break;     // yeah
                    }
                }

                // hmm, look again
                Thread.Sleep(2000);
                SafeDistance -= 0.5f;
            }
        }
예제 #5
0
파일: PPather.cs 프로젝트: Bia10/boogiebot
        public bool Approach(BoogieBot.Common.Object monster, bool AbortIfUnsafe, int timeout)
        {
            BoogieCore.Log(LogType.System, "[Approach] 1");
            Coordinate loc    = monster.GetCoordinates();
            float      DistTo = loc.DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());

            BoogieCore.Log(LogType.System, "[Approach] Distance to object: {0}", DistTo);
            if (DistTo < 4.5f &&
                Math.Abs(loc.O) < PI / 8)
            {
                mover.Stop();
                return(true);
            }

            GSpellTimer   approachTimeout = new GSpellTimer(timeout, false);
            StuckDetecter sd              = new StuckDetecter(this, 1, 2);
            GSpellTimer   t               = new GSpellTimer(0);
            bool          doJump          = random.Next(4) == 0;
            EasyMover     em              = null;
            GSpellTimer   NewTargetUpdate = new GSpellTimer(1000);


            BoogieCore.Log(LogType.System, "[Approach] 2");
            do
            {
                BoogieCore.Log(LogType.System, "[Approach] 3");
                UpdateMyPos();
                BoogieCore.Log(LogType.System, "[Approach] 4");
                // Check for stuck
                if (sd.checkStuck())
                {
                    BoogieCore.Log(LogType.System, "[Approach] 5");
                    BoogieCore.Log(LogType.System, "Major stuck on approach. Giving up");
                    mover.Stop();
                    return(false);
                }
                double distance = monster.GetCoordinates().DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());
                BoogieCore.Log(LogType.System, "[Approach] 6 - Dist = {0}", distance);
                bool moved;

                if (distance < 8)
                {
                    loc = monster.GetCoordinates();
                    BoogieCore.Log(LogType.System, "[Approach] 7");
                    moved = mover.moveTowardsFacing(loc, 4.5f, loc);
                    BoogieCore.Log(LogType.System, "[Approach] 8 {0}", moved);
                }
                else
                {
                    BoogieCore.Log(LogType.System, "[Approach] 9");
                    if (em == null)
                    {
                        loc = monster.GetCoordinates();
                        em  = new EasyMover(this, new Location(loc), false, AbortIfUnsafe);
                    }
                    BoogieCore.Log(LogType.System, "[Approach] 10");
                    EasyMover.MoveResult mr = em.move();
                    BoogieCore.Log(LogType.System, "[Approach] 11 {0}", mr);
                    moved = true;
                    if (mr != EasyMover.MoveResult.Moving)
                    {
                        moved = false;
                    }
                    BoogieCore.Log(LogType.System, "[Approach] 12");
                }
                BoogieCore.Log(LogType.System, "[Approach] 13");

                if (!moved)
                {
                    mover.Stop();
                    return(true);
                }
            } while (!approachTimeout.IsReadySlow);
            mover.Stop();
            BoogieCore.Log(LogType.System, "Approach timed out");
            return(false);
        }